mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 11:05:56 +00:00
Adding observable commit status client
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableCommitStatusClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or
|
||||
/// a tag name.
|
||||
/// </summary>
|
||||
/// <remarks>Only users with pull access can see this.</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The reference (SHA, branch name, or tag name) to list commits for.</param>
|
||||
/// <returns></returns>
|
||||
IObservable<CommitStatus> GetAll(string owner, string name, string reference);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a commit status for the specified ref.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The reference (SHA, branch name, or tag name) to list commits for.</param>
|
||||
/// <param name="commitStatus">The commit status to create.</param>
|
||||
/// <returns></returns>
|
||||
IObservable<CommitStatus> Create(string owner, string name, string reference, NewCommitStatus commitStatus);
|
||||
}
|
||||
}
|
||||
@@ -88,5 +88,7 @@ namespace Octokit.Reactive
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <returns></returns>
|
||||
IObservable<string> GetReadmeHtml(string owner, string name);
|
||||
|
||||
IObservableCommitStatusClient CommitStatus { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableCommitStatusClient : IObservableCommitStatusClient
|
||||
{
|
||||
readonly ICommitStatusClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableCommitStatusClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Repository.CommitStatus;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or
|
||||
/// a tag name.
|
||||
/// </summary>
|
||||
/// <remarks>Only users with pull access can see this.</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The reference (SHA, branch name, or tag name) to list commits for.</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<CommitStatus> GetAll(string owner, string name, string reference)
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<CommitStatus>(ApiUrls.CommitStatus(owner, name, reference));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a commit status for the specified ref.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The reference (SHA, branch name, or tag name) to list commits for.</param>
|
||||
/// <param name="commitStatus">The commit status to create.</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<CommitStatus> Create(string owner, string name, string reference, NewCommitStatus commitStatus)
|
||||
{
|
||||
return _client.Create(owner, name, reference, commitStatus).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ namespace Octokit.Reactive
|
||||
readonly IOrganizationsClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
|
||||
public ObservableOrganizationsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Octokit.Reactive
|
||||
|
||||
_client = client.Repository;
|
||||
_connection = client.Connection;
|
||||
CommitStatus = new ObservableCommitStatusClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -105,5 +106,7 @@ namespace Octokit.Reactive
|
||||
|
||||
return _client.GetReadmeHtml(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
public IObservableCommitStatusClient CommitStatus { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@
|
||||
<Compile Include="..\SolutionInfo.cs">
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Clients\IObservableCommitStatusClient.cs" />
|
||||
<Compile Include="Clients\ObservableCommitStatusClient.cs" />
|
||||
<Compile Include="Clients\ObservableNotificationsClient.cs" />
|
||||
<Compile Include="Clients\ObservableAuthorizationsClient.cs" />
|
||||
<Compile Include="Clients\ObservableMiscellaneousClient.cs" />
|
||||
|
||||
Reference in New Issue
Block a user