using Octokit.Reactive.Internal; using System; using System.Reactive.Threading.Tasks; namespace Octokit.Reactive.Clients { public class ObservableDeploymentStatusClient : IObservableDeploymentStatusClient { const string acceptsHeader = "application/vnd.github.cannonball-preview+json"; private IDeploymentStatusClient _client; private IConnection _connection; public ObservableDeploymentStatusClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); _client = client.Deployment.Status; _connection = client.Connection; } /// /// Gets all the statuses for the given deployment. Any user with pull access to a repository can /// view deployments. /// /// /// http://developer.github.com/v3/repos/deployments/#list-deployment-statuses /// /// The owner of the repository. /// The name of the repository. /// The id of the deployment. /// All deployment statuses for the given deployment. public IObservable GetAll(string owner, string name, int deploymentId) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); return _connection.GetAndFlattenAllPages( ApiUrls.DeploymentStatuses(owner, name, deploymentId), null, acceptsHeader); } /// /// Creates a new status for the given deployment. Users with push access can create deployment /// statuses for a given deployment. /// /// /// http://developer.github.com/v3/repos/deployments/#create-a-deployment-status /// /// The owner of the repository. /// The name of the repository. /// The id of the deployment. /// The new deployment status to create. /// public IObservable Create(string owner, string name, int deploymentId, NewDeploymentStatus newDeploymentStatus) { return _client.Create(owner, name, deploymentId, newDeploymentStatus).ToObservable(); } } }