mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +00:00
[Feat] Add Repository Autolinks Client (#2868)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
|
||||
59
Octokit.Reactive/Clients/IObservableAutolinksClient.cs
Normal file
59
Octokit.Reactive/Clients/IObservableAutolinksClient.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
@@ -523,6 +522,14 @@ namespace Octokit.Reactive
|
||||
/// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
|
||||
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>
|
||||
/// A client for GitHub's Repo Collaborators.
|
||||
/// </summary>
|
||||
|
||||
72
Octokit.Reactive/Clients/ObservableAutolinksClient.cs
Normal file
72
Octokit.Reactive/Clients/ObservableAutolinksClient.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,10 @@ using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Reactive.Clients;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableRepositoriesClient : IObservableRepositoriesClient
|
||||
@@ -42,6 +42,7 @@ namespace Octokit.Reactive
|
||||
Traffic = new ObservableRepositoryTrafficClient(client);
|
||||
Project = new ObservableProjectsClient(client);
|
||||
Actions = new ObservableRepositoryActionsClient(client);
|
||||
Autolinks = new ObservableAutolinksClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -824,6 +825,14 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
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>
|
||||
/// A client for GitHub's Repository Branches API.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user