using System.Collections.Generic;
using System.Threading.Tasks;
namespace Octokit
{
///
/// A client for GitHub's Repository Deployment Statuses API.
/// Gets and creates Deployment Statuses.
///
///
/// See the Repository Deployment Statuses API documentation for more information.
///
public class DeploymentStatusClient : ApiClient, IDeploymentStatusClient
{
public DeploymentStatusClient(IApiConnection apiConnection)
: base(apiConnection)
{
}
///
/// 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.
[ManualRoute("GET", "/repos/{owner}/{repo}/deployments/{deployment_id}/statuses")]
public Task> GetAll(string owner, string name, int deploymentId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAll(owner, name, deploymentId, ApiOptions.None);
}
///
/// 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 Id of the repository.
/// The id of the deployment.
[ManualRoute("GET", "/repositories/{id}/deployments/{deployment_id}/statuses")]
public Task> GetAll(long repositoryId, int deploymentId)
{
return GetAll(repositoryId, deploymentId, ApiOptions.None);
}
///
/// 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.
/// Options for changing the API response
[Preview("ant-man")]
[Preview("flash")]
[ManualRoute("GET", "/repos/{owner}/{repo}/deployments/{deployment_id}/statuses")]
public Task> GetAll(string owner, string name, int deploymentId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.DeploymentStatuses(owner, name, deploymentId),
null,
AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview),
options);
}
///
/// 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 Id of the repository.
/// The id of the deployment.
/// Options for changing the API response
[Preview("ant-man")]
[Preview("flash")]
[ManualRoute("GET", "/repositories/{id}/deployments/{deployment_id}/statuses")]
public Task> GetAll(long repositoryId, int deploymentId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.DeploymentStatuses(repositoryId, deploymentId),
null,
AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview),
options);
}
///
/// 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.
[Preview("ant-man")]
[Preview("flash")]
[ManualRoute("POST", "/repos/{owner}/{repo}/deployments/{deployment_id}/statuses")]
public Task Create(string owner, string name, int deploymentId, NewDeploymentStatus newDeploymentStatus)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(newDeploymentStatus, nameof(newDeploymentStatus));
return ApiConnection.Post(ApiUrls.DeploymentStatuses(owner, name, deploymentId),
newDeploymentStatus,
AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview));
}
///
/// 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 Id of the repository.
/// The id of the deployment.
/// The new deployment status to create.
[Preview("ant-man")]
[Preview("flash")]
[ManualRoute("POST", "/repositories/{id}/deployments/{deployment_id}/statuses")]
public Task Create(long repositoryId, int deploymentId, NewDeploymentStatus newDeploymentStatus)
{
Ensure.ArgumentNotNull(newDeploymentStatus, nameof(newDeploymentStatus));
return ApiConnection.Post(ApiUrls.DeploymentStatuses(repositoryId, deploymentId),
newDeploymentStatus,
AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview));
}
}
}