[Feat] Add Repository Autolinks Client (#2868)

This commit is contained in:
Slyck Lizzie
2024-02-01 14:56:26 -05:00
committed by GitHub
parent c9ddf3edc3
commit 2a87dd0802
13 changed files with 649 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
using System; using System;
using System.Reactive; using System.Reactive;
using System.Threading.Tasks;
namespace Octokit.Reactive namespace Octokit.Reactive
{ {

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Reactive;
namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Repository Autolinks API
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/repos/autolinks">API documentation</a> for more information.
/// </remarks>
public interface IObservableAutolinksClient
{
/// <summary>
/// Returns a single autolink reference by ID that was configured for the given repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <param name="autolinkId">The unique identifier of the autolink</param>
/// <remarks>See the <a href="https://docs.github.com/en/rest/repos/autolinks#get-an-autolink-reference-of-a-repository">API documentation</a> for more information.</remarks>
IObservable<Autolink> Get(string owner, string repo, int autolinkId);
/// <summary>
/// Returns a list of autolinks configured for the given repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <remarks>See the <a href="https://docs.github.com/en/rest/repos/autolinks#list-all-autolinks-of-a-repository">API documentation</a> for more information.</remarks>
IObservable<Autolink> GetAll(string owner, string repo);
/// <summary>
/// Returns a list of autolinks configured for the given repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <remarks>See the <a href="https://docs.github.com/en/rest/repos/autolinks#list-all-autolinks-of-a-repository">API documentation</a> for more information.</remarks>
IObservable<Autolink> GetAll(string owner, string repo, ApiOptions options);
/// <summary>
/// Create an autolink reference for a repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <param name="autolink">The Autolink object to be created for the repository</param>
/// <remarks>See the <a href="https://docs.github.com/en/rest/repos/autolinks#create-an-autolink-reference-for-a-repository">API documentation</a> for more information.</remarks>
IObservable<Autolink> Create(string owner, string repo, AutolinkRequest autolink);
/// <summary>
/// Deletes a single autolink reference by ID that was configured for the given repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <param name="autolinkId">The unique identifier of the autolink</param>
/// <remarks>See the <a href="https://docs.github.com/en/rest/repos/autolinks#delete-an-autolink-reference-from-a-repository">API documentation</a> for more information.</remarks>
IObservable<Unit> Delete(string owner, string repo, int autolinkId);
}
}

View File

@@ -1,8 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Reactive; using System.Reactive;
using System.Threading.Tasks;
namespace Octokit.Reactive namespace Octokit.Reactive
{ {
@@ -523,6 +522,14 @@ namespace Octokit.Reactive
/// <returns>The updated <see cref="T:Octokit.Repository"/></returns> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
IObservable<Repository> Edit(long repositoryId, RepositoryUpdate update); IObservable<Repository> Edit(long repositoryId, RepositoryUpdate update);
/// <summary>
/// A client for GitHub's Repository Autolinks API
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/repos/autolinks">API documentation</a> for more information.
/// </remarks>
IObservableAutolinksClient Autolinks { get; }
/// <summary> /// <summary>
/// A client for GitHub's Repo Collaborators. /// A client for GitHub's Repo Collaborators.
/// </summary> /// </summary>

View File

@@ -0,0 +1,72 @@
using System;
using System.Reactive;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
/// <inheritdoc/>
public class ObservableAutolinksClient : IObservableAutolinksClient
{
readonly IAutolinksClient _client;
readonly IConnection _connection;
public ObservableAutolinksClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));
_client = client.Repository.Autolinks;
_connection = client.Connection;
}
/// <inheritdoc/>
public IObservable<Autolink> Get(string owner, string repo, int autolinkId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
return _client.Get(owner, repo, autolinkId).ToObservable();
}
/// <inheritdoc/>
public IObservable<Autolink> GetAll(string owner, string repo)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
return this.GetAll(owner, repo, ApiOptions.None);
}
/// <inheritdoc/>
public IObservable<Autolink> GetAll(string owner, string repo, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<Autolink>(ApiUrls.AutolinksGetAll(owner, repo), options);
}
/// <inheritdoc/>
public IObservable<Autolink> Create(string owner, string repo, AutolinkRequest autolink)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
Ensure.ArgumentNotNull(autolink, nameof(autolink));
return _client.Create(owner, repo, autolink).ToObservable();
}
/// <inheritdoc/>
public IObservable<Unit> Delete(string owner, string repo, int autolinkId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
return _client.Delete(owner, repo, autolinkId).ToObservable();
}
}
}

View File

@@ -5,10 +5,10 @@ using System.Linq;
using System.Reactive; using System.Reactive;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Reactive.Threading.Tasks; using System.Reactive.Threading.Tasks;
using System.Threading.Tasks;
using Octokit.Reactive.Clients; using Octokit.Reactive.Clients;
using Octokit.Reactive.Internal; using Octokit.Reactive.Internal;
namespace Octokit.Reactive namespace Octokit.Reactive
{ {
public class ObservableRepositoriesClient : IObservableRepositoriesClient public class ObservableRepositoriesClient : IObservableRepositoriesClient
@@ -42,6 +42,7 @@ namespace Octokit.Reactive
Traffic = new ObservableRepositoryTrafficClient(client); Traffic = new ObservableRepositoryTrafficClient(client);
Project = new ObservableProjectsClient(client); Project = new ObservableProjectsClient(client);
Actions = new ObservableRepositoryActionsClient(client); Actions = new ObservableRepositoryActionsClient(client);
Autolinks = new ObservableAutolinksClient(client);
} }
/// <summary> /// <summary>
@@ -824,6 +825,14 @@ namespace Octokit.Reactive
/// </remarks> /// </remarks>
public IObservableRepositoryActionsClient Actions { get; private set; } public IObservableRepositoryActionsClient Actions { get; private set; }
/// <summary>
/// A client for GitHub's Repository Autolinks API
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/repos/autolinks">API documentation</a> for more information.
/// </remarks>
public IObservableAutolinksClient Autolinks { get; private set; }
/// <summary> /// <summary>
/// A client for GitHub's Repository Branches API. /// A client for GitHub's Repository Branches API.
/// </summary> /// </summary>

View File

@@ -0,0 +1,195 @@
using NSubstitute;
using System;
using System.Threading.Tasks;
using Xunit;
namespace Octokit.Tests.Clients
{
public class AutolinksClientTests
{
public class TheCtor
{
[Fact]
public void EnsuresNonNullArguments()
{
Assert.Throws<ArgumentNullException>(() => new AutolinksClient(null));
}
}
public class TheGetMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
await client.Get("fakeOwner", "fakeRepo", 42);
connection.Received().Get<Autolink>(
Arg.Is<Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepo/autolinks/42"));
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "repo", 42));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 42));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "repo", 42));
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", 42));
}
}
public class TheGetAllMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
await client.GetAll("fakeOwner", "fakeRepo");
connection.Received().GetAll<Autolink>(
Arg.Is<Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepo/autolinks"), Args.ApiOptions);
}
[Fact]
public async Task RequestsCorrectUrlWithApiOptions()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
var options = new ApiOptions
{
PageCount = 1,
PageSize = 1,
StartPage = 1
};
await client.GetAll("fakeOwner", "fakeRepo", options);
connection.Received(1)
.GetAll<Autolink>(Arg.Is<Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepo/autolinks"),
options);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "repo"));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "repo", ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "repo", null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "repo"));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", ""));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "repo", ApiOptions.None));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", ApiOptions.None));
}
}
public class TheCreateMethod
{
[Fact]
public async Task PostsToCorrectUrl()
{
var newAutolink = new AutolinkRequest("fakeKeyPrefix", "fakeUrlTemplate", true);
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
await client.Create("fakeOwner", "fakeRepo", newAutolink);
connection.Received().Post<Autolink>(
Arg.Is<Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepo/autolinks"),
Arg.Is<AutolinkRequest>(a => a.KeyPrefix == "fakeKeyPrefix"
&& a.UrlTemplate == "fakeUrlTemplate"
&& a.IsAlphanumeric == true));
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
var newAutolink = new AutolinkRequest("fakeKeyPrefix", "fakeUrlTemplate", true);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "repo", newAutolink));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, newAutolink));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "repo", null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
var newAutolink = new AutolinkRequest("fakeKeyPrefix", "fakeUrlTemplate", true);
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "repo", newAutolink));
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", newAutolink));
}
}
public class TheDeleteMethod
{
[Fact]
public async Task DeletesCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
await client.Delete("fakeOwner", "fakeRepo", 42);
connection.Received().Delete(
Arg.Is<Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepo/autolinks/42"));
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "repo", 42));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", null, 42));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new AutolinksClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "repo", 42));
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "", 42));
}
}
}
}

View File

@@ -0,0 +1,70 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Octokit
{
/// <inheritdoc/>
public class AutolinksClient : ApiClient, IAutolinksClient
{
/// <summary>
/// Initializes a new GitHub Repository Autolinks API client
/// </summary>
/// <param name="apiConnection">An API connection</param>
public AutolinksClient(IApiConnection apiConnection) : base(apiConnection)
{ }
/// <inheritdoc/>
[ManualRoute("GET", "/repos/{owner}/{repo}/autolinks/{autolinkId}")]
public Task<Autolink> Get(string owner, string repo, int autolinkId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
return ApiConnection.Get<Autolink>(ApiUrls.AutolinksGet(owner, repo, autolinkId));
}
/// <inheritdoc/>
[ManualRoute("GET", "/repos/{owner}/{repo}/autolinks")]
public Task<IReadOnlyList<Autolink>> GetAll(string owner, string repo)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
return GetAll(owner, repo, ApiOptions.None);
}
/// <inheritdoc/>
[ManualRoute("GET", "/repos/{owner}/{repo}/autolinks")]
public Task<IReadOnlyList<Autolink>> GetAll(string owner, string repo, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll<Autolink>(ApiUrls.AutolinksGetAll(owner, repo), options);
}
/// <inheritdoc/>
[ManualRoute("POST", "/repos/{owner}/{repo}/autolinks")]
public Task<Autolink> Create(string owner, string repo, AutolinkRequest autolink)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
Ensure.ArgumentNotNull(autolink, nameof(autolink));
return ApiConnection.Post<Autolink>(ApiUrls.AutolinksCreate(owner, repo), autolink);
}
/// <inheritdoc/>
[ManualRoute("DELETE", "/repos/{owner}/{repo}/autolinks/{autolinkId}")]
public Task Delete(string owner, string repo, int autolinkId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
return ApiConnection.Delete(ApiUrls.AutolinksDelete(owner, repo, autolinkId));
}
}
}

View File

@@ -0,0 +1,59 @@

using System.Collections.Generic;
using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Repository Autolinks API
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/repos/autolinks">API documentation</a> for more information.
/// </remarks>
public interface IAutolinksClient
{
/// <summary>
/// Returns a single autolink reference by ID that was configured for the given repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <param name="autolinkId">The unique identifier of the autolink</param>
/// <remarks>See the <a href="https://docs.github.com/en/rest/repos/autolinks#get-an-autolink-reference-of-a-repository">API documentation</a> for more information.</remarks>
Task<Autolink> Get(string owner, string repo, int autolinkId);
/// <summary>
/// Returns a list of autolinks configured for the given repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <remarks>See the <a href="https://docs.github.com/en/rest/repos/autolinks#list-all-autolinks-of-a-repository">API documentation</a> for more information.</remarks>
Task<IReadOnlyList<Autolink>> GetAll(string owner, string repo);
/// <summary>
/// Returns a list of autolinks configured for the given repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <remarks>See the <a href="https://docs.github.com/en/rest/repos/autolinks#list-all-autolinks-of-a-repository">API documentation</a> for more information.</remarks>
Task<IReadOnlyList<Autolink>> GetAll(string owner, string repo, ApiOptions options);
/// <summary>
/// Create an autolink reference for a repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <param name="autolink">The Autolink object to be created for the repository</param>
/// <remarks>See the <a href="https://docs.github.com/en/rest/repos/autolinks#create-an-autolink-reference-for-a-repository">API documentation</a> for more information.</remarks>
Task<Autolink> Create(string owner, string repo, AutolinkRequest autolink);
/// <summary>
/// Deletes a single autolink reference by ID that was configured for the given repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <param name="autolinkId">The unique identifier of the autolink</param>
/// <remarks>See the <a href="https://docs.github.com/en/rest/repos/autolinks#delete-an-autolink-reference-from-a-repository">API documentation</a> for more information.</remarks>
Task Delete(string owner, string repo, int autolinkId);
}
}

View File

@@ -28,6 +28,14 @@ namespace Octokit
/// </remarks> /// </remarks>
IRepositoryActionsClient Actions { get; } IRepositoryActionsClient Actions { get; }
/// <summary>
/// Client for managing Autolinks in a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/repos/autolinks">Repository Autolinks API documentation</a> for more information.
/// </remarks>
IAutolinksClient Autolinks { get; }
/// <summary> /// <summary>
/// Client for managing branches in a repository. /// Client for managing branches in a repository.
/// </summary> /// </summary>

View File

@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using Octokit.Clients;
namespace Octokit namespace Octokit
{ {
@@ -42,6 +43,8 @@ namespace Octokit
Traffic = new RepositoryTrafficClient(apiConnection); Traffic = new RepositoryTrafficClient(apiConnection);
Project = new ProjectsClient(apiConnection); Project = new ProjectsClient(apiConnection);
Actions = new RepositoryActionsClient(apiConnection); Actions = new RepositoryActionsClient(apiConnection);
Autolinks = new AutolinksClient(apiConnection);
} }
/// <summary> /// <summary>
@@ -1153,5 +1156,13 @@ namespace Octokit
/// Refer to the API documentation for more information: https://developer.github.com/v3/repos/projects/ /// Refer to the API documentation for more information: https://developer.github.com/v3/repos/projects/
/// </remarks> /// </remarks>
public IProjectsClient Project { get; private set; } public IProjectsClient Project { get; private set; }
/// <summary>
/// Access GitHub's Repository Autolinks API
/// </summary>
/// <remarks>
/// Refer to the API documentation for more information: https://docs.github.com/en/rest/repos/autolinks
/// </remarks>
public IAutolinksClient Autolinks { get; private set; }
} }
} }

View File

@@ -5542,7 +5542,7 @@ namespace Octokit
/// </summary> /// </summary>
/// <param name="owner">The owner of the repository</param> /// <param name="owner">The owner of the repository</param>
/// <param name="repository">The name of the repository</param> /// <param name="repository">The name of the repository</param>
/// <returns></returns> /// <returns>A Uri Instance</returns>
public static Uri ListArtifacts(string owner, string repository) public static Uri ListArtifacts(string owner, string repository)
{ {
return "repos/{0}/{1}/actions/artifacts".FormatUri(owner, repository); return "repos/{0}/{1}/actions/artifacts".FormatUri(owner, repository);
@@ -5554,7 +5554,7 @@ namespace Octokit
/// <param name="owner">The owner of the repository</param> /// <param name="owner">The owner of the repository</param>
/// <param name="repository">The name of the repository</param> /// <param name="repository">The name of the repository</param>
/// <param name="artifactId">The id of the artifact</param> /// <param name="artifactId">The id of the artifact</param>
/// <returns></returns> /// <returns>A Uri Instance</returns>
public static Uri Artifact(string owner, string repository, long artifactId) public static Uri Artifact(string owner, string repository, long artifactId)
{ {
return "repos/{0}/{1}/actions/artifacts/{2}".FormatUri(owner, repository, artifactId); return "repos/{0}/{1}/actions/artifacts/{2}".FormatUri(owner, repository, artifactId);
@@ -5567,7 +5567,7 @@ namespace Octokit
/// <param name="repository">The name of the repository</param> /// <param name="repository">The name of the repository</param>
/// <param name="artifactId">The id of the artifact</param> /// <param name="artifactId">The id of the artifact</param>
/// <param name="archiveFormat">The archive format e.g. zip</param> /// <param name="archiveFormat">The archive format e.g. zip</param>
/// <returns></returns> /// <returns>A Uri Instance</returns>
public static Uri DownloadArtifact(string owner, string repository, long artifactId, string archiveFormat) public static Uri DownloadArtifact(string owner, string repository, long artifactId, string archiveFormat)
{ {
return "repos/{0}/{1}/actions/artifacts/{2}/{3}".FormatUri(owner, repository, artifactId, archiveFormat); return "repos/{0}/{1}/actions/artifacts/{2}/{3}".FormatUri(owner, repository, artifactId, archiveFormat);
@@ -5579,7 +5579,7 @@ namespace Octokit
/// <param name="owner">The owner of the repository</param> /// <param name="owner">The owner of the repository</param>
/// <param name="repository">The name of the repository</param> /// <param name="repository">The name of the repository</param>
/// <param name="runId">The id of the workflow run</param> /// <param name="runId">The id of the workflow run</param>
/// <returns></returns> /// <returns>A Uri Instance</returns>
public static Uri ListWorkflowArtifacts(string owner, string repository, long runId) public static Uri ListWorkflowArtifacts(string owner, string repository, long runId)
{ {
return "repos/{0}/{1}/actions/runs/{2}/artifacts".FormatUri(owner, repository, runId); return "repos/{0}/{1}/actions/runs/{2}/artifacts".FormatUri(owner, repository, runId);
@@ -5591,7 +5591,7 @@ namespace Octokit
/// <param name="owner">The owner of the repository</param> /// <param name="owner">The owner of the repository</param>
/// <param name="repository">The name of the repository</param> /// <param name="repository">The name of the repository</param>
/// <param name="branch">The name of the branch to rename</param> /// <param name="branch">The name of the branch to rename</param>
/// <returns></returns> /// <returns>A Uri Instance</returns>
public static Uri RepositoryBranchRename(string owner, string repository, string branch) public static Uri RepositoryBranchRename(string owner, string repository, string branch)
{ {
return "repos/{0}/{1}/branches/{2}/rename".FormatUri(owner, repository, branch); return "repos/{0}/{1}/branches/{2}/rename".FormatUri(owner, repository, branch);
@@ -5601,7 +5601,7 @@ namespace Octokit
/// Returns the <see cref="Uri"/> to get or set an organization OIDC subject claim. /// Returns the <see cref="Uri"/> to get or set an organization OIDC subject claim.
/// </summary> /// </summary>
/// <param name="organization">The organization name</param> /// <param name="organization">The organization name</param>
/// <returns></returns> /// <returns>A Uri Instance</returns>
public static Uri ActionsOrganizationOidcSubjectClaim(string organization) public static Uri ActionsOrganizationOidcSubjectClaim(string organization)
{ {
return "orgs/{0}/actions/oidc/customization/sub".FormatUri(organization); return "orgs/{0}/actions/oidc/customization/sub".FormatUri(organization);
@@ -5612,10 +5612,56 @@ namespace Octokit
/// </summary> /// </summary>
/// <param name="owner">The account owner of the repository</param> /// <param name="owner">The account owner of the repository</param>
/// <param name="repository">The name of the repository</param> /// <param name="repository">The name of the repository</param>
/// <returns></returns> /// <returns>A Uri Instance</returns>
public static Uri ActionsRepositoryOidcSubjectClaim(string owner, string repository) public static Uri ActionsRepositoryOidcSubjectClaim(string owner, string repository)
{ {
return "repos/{0}/{1}/actions/oidc/customization/sub".FormatUri(owner, repository); return "repos/{0}/{1}/actions/oidc/customization/sub".FormatUri(owner, repository);
} }
/// <summary>
/// Returns the <see cref="Uri"/> to create an autolink
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <returns>A Uri Instance</returns>
public static Uri AutolinksCreate(string owner, string repo)
{
return "repos/{0}/{1}/autolinks".FormatUri(owner, repo);
}
/// <summary>
/// Returns the <see cref="Uri"/> to delete an autolink
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <param name="autolinkId">The unique identifier of the autolink</param>
/// <returns>A Uri Instance</returns>
public static Uri AutolinksDelete(string owner, string repo, int autolinkId)
{
return "repos/{0}/{1}/autolinks/{2}".FormatUri(owner, repo, autolinkId);
}
/// <summary>
/// Returns the <see cref="Uri"/> to get an autolink
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <param name="autolinkId">The unique identifier of the autolink</param>
/// <returns>A Uri Instance</returns>
public static Uri AutolinksGet(string owner, string repo, int autolinkId)
{
return "repos/{0}/{1}/autolinks/{2}".FormatUri(owner, repo, autolinkId);
}
/// <summary>
/// Returns the <see cref="Uri"/> to get a list of autolinks configured for the given repository
/// </summary>
/// <param name="owner">The account owner of the repository</param>
/// <param name="repo">The name of the repository</param>
/// <returns>A Uri Instance</returns>
public static Uri AutolinksGetAll(string owner, string repo)
{
return "repos/{0}/{1}/autolinks".FormatUri(owner, repo);
}
} }
} }

View File

@@ -0,0 +1,48 @@
using Octokit.Internal;
using System.Diagnostics;
namespace Octokit
{
/// <summary>
/// Represents a repository Autolink object.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class AutolinkRequest
{
public AutolinkRequest()
{ }
public AutolinkRequest(string keyPrefix, string urlTemplate, bool isAlphanumeric)
{
this.KeyPrefix = keyPrefix;
this.UrlTemplate = urlTemplate;
this.IsAlphanumeric = isAlphanumeric;
}
/// <summary>
/// This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit.
/// </summary>
public string KeyPrefix { get; set; }
/// <summary>
/// The URL must contain &lt;num&gt; for the reference number. &lt;num&gt; matches different characters depending on the value of is_alphanumeric.
/// </summary>
public string UrlTemplate { get; set; }
/// <summary>
/// Whether this autolink reference matches alphanumeric characters. If true, the &lt;num&gt; parameter of the url_template matches alphanumeric characters A-Z (case insensitive), 0-9, and -. If false, this autolink reference only matches numeric characters.
/// </summary>
public bool IsAlphanumeric { get; set; }
internal string DebuggerDisplay
{
get
{
return new SimpleJsonSerializer().Serialize(this);
}
}
}
}

View File

@@ -0,0 +1,54 @@
using Octokit.Internal;
using System.Diagnostics;
namespace Octokit
{
/// <summary>
/// Represents a repository Autolink object.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class Autolink
{
public Autolink()
{ }
public Autolink(int id, string keyPrefix, string urlTemplate, bool isAlphanumeric)
{
this.Id = id;
this.KeyPrefix = keyPrefix;
this.UrlTemplate = urlTemplate;
this.IsAlphanumeric = isAlphanumeric;
}
/// <summary>
/// The unique identifier of the autolink.
/// </summary>
public int Id { get; protected set; }
/// <summary>
/// This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit.
/// </summary>
public string KeyPrefix { get; protected set; }
/// <summary>
/// The URL must contain &lt;num&gt; for the reference number. &lt;num&gt; matches different characters depending on the value of is_alphanumeric.
/// </summary>
public string UrlTemplate { get; protected set; }
/// <summary>
/// Whether this autolink reference matches alphanumeric characters. If true, the &lt;num&gt; parameter of the url_template matches alphanumeric characters A-Z (case insensitive), 0-9, and -. If false, this autolink reference only matches numeric characters.
/// </summary>
public bool IsAlphanumeric { get; protected set; }
internal string DebuggerDisplay
{
get
{
return new SimpleJsonSerializer().Serialize(this);
}
}
}
}