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.Status; _connection = client.Connection; } /// /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or /// a tag name. /// /// Only users with pull access can see this. /// The owner of the repository /// The name of the repository /// The reference (SHA, branch name, or tag name) to list commits for /// public IObservable GetAll(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); return GetAll(owner, name ,reference, ApiOptions.None); } /// /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or /// a tag name. /// /// Only users with pull access can see this. /// The owner of the repository /// The name of the repository /// The reference (SHA, branch name, or tag name) to list commits for /// Options for changing the API response /// public IObservable GetAll(string owner, string name, string reference, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages(ApiUrls.CommitStatuses(owner, name, reference), options); } /// /// Retrieves a combined view of statuses for the specified reference. A reference can be a commit SHA, a branch name, or /// a tag name. /// /// Only users with pull access can see this. /// The owner of the repository /// The name of the repository /// The reference (SHA, branch name, or tag name) to list commits for /// public IObservable GetCombined(string owner, string name, string reference) { return _client.GetCombined(owner, name, reference).ToObservable(); } /// /// Creates a commit status for the specified ref. /// /// The owner of the repository /// The name of the repository /// The reference (SHA, branch name, or tag name) to list commits for /// The commit status to create /// public IObservable Create(string owner, string name, string reference, NewCommitStatus commitStatus) { return _client.Create(owner, name, reference, commitStatus).ToObservable(); } } }