using System.Collections.Generic; using System.Threading.Tasks; namespace Octokit { /// /// A client for GitHub's Issue Milestones API. /// /// /// See the Issue Milestones API documentation for more information. /// public class MilestonesClient : ApiClient, IMilestonesClient { /// /// Instantiates a new GitHub Issue Milestones API client. /// /// An API connection public MilestonesClient(IApiConnection apiConnection) : base(apiConnection) { } /// /// Gets a single Milestone by number. /// /// /// http://developer.github.com/v3/issues/milestones/#get-a-single-milestone /// /// public Task Get(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); return ApiConnection.Get(ApiUrls.Milestone(owner, name, number)); } /// /// Gets a single Milestone by number. /// /// /// http://developer.github.com/v3/issues/milestones/#get-a-single-milestone /// /// public Task Get(int repositoryId, int number) { return ApiConnection.Get(ApiUrls.Milestone(repositoryId, number)); } /// /// Gets all open milestones for the repository. /// /// /// http://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository /// /// The owner of the repository /// The name of the repository /// public Task> GetAllForRepository(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); return GetAllForRepository(owner, name, new MilestoneRequest()); } /// /// Gets all open milestones for the repository. /// /// /// http://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository /// /// The ID of the repository /// public Task> GetAllForRepository(int repositoryId) { return GetAllForRepository(repositoryId, new MilestoneRequest()); } /// /// Gets all open milestones for the repository. /// /// /// http://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository /// /// The owner of the repository /// The name of the repository /// Options for changing the API response /// public Task> GetAllForRepository(string owner, string name, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(options, "options"); return GetAllForRepository(owner, name, new MilestoneRequest(), options); } /// /// Gets all open milestones for the repository. /// /// /// http://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository /// /// The ID of the repository /// Options for changing the API response /// public Task> GetAllForRepository(int repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, "options"); return GetAllForRepository(repositoryId, new MilestoneRequest(), options); } /// /// Gets all open milestones for the repository. /// /// /// http://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository /// /// The owner of the repository /// The name of the repository /// Used to filter and sort the list of Milestones returned /// public Task> GetAllForRepository(string owner, string name, MilestoneRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); return GetAllForRepository(owner, name, request, ApiOptions.None); } /// /// Gets all open milestones for the repository. /// /// /// http://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository /// /// The ID of the repository /// Used to filter and sort the list of Milestones returned /// public Task> GetAllForRepository(int repositoryId, MilestoneRequest request) { Ensure.ArgumentNotNull(request, "request"); return GetAllForRepository(repositoryId, request, ApiOptions.None); } /// /// Gets all open milestones for the repository. /// /// /// http://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository /// /// The owner of the repository /// The name of the repository /// Used to filter and sort the list of Milestones returned /// Options for changing the API response /// public Task> GetAllForRepository(string owner, string name, MilestoneRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(options, "options"); return ApiConnection.GetAll(ApiUrls.Milestones(owner, name), request.ToParametersDictionary(), options); } /// /// Gets all open milestones for the repository. /// /// /// http://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository /// /// The ID of the repository /// Used to filter and sort the list of Milestones returned /// Options for changing the API response /// public Task> GetAllForRepository(int repositoryId, MilestoneRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(options, "options"); return ApiConnection.GetAll(ApiUrls.Milestones(repositoryId), request.ToParametersDictionary(), options); } /// /// Creates a milestone for the specified repository. Any user with pull access to a repository can create an /// Milestone. /// /// http://developer.github.com/v3/issues/milestones/#create-a-milestone /// The owner of the repository /// The name of the repository /// A instance describing the new Milestone to create /// public Task Create(string owner, string name, NewMilestone newMilestone) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(newMilestone, "newMilestone"); return ApiConnection.Post(ApiUrls.Milestones(owner, name), newMilestone); } /// /// Creates a milestone for the specified repository. Any user with pull access to a repository can create an /// Milestone. /// /// http://developer.github.com/v3/issues/milestones/#create-a-milestone /// The ID of the repository /// A instance describing the new Milestone to create /// public Task Create(int repositoryId, NewMilestone newMilestone) { Ensure.ArgumentNotNull(newMilestone, "newMilestone"); return ApiConnection.Post(ApiUrls.Milestones(repositoryId), newMilestone); } /// /// Creates a milestone for the specified repository. Any user with pull access to a repository can create an /// Milestone. /// /// http://developer.github.com/v3/issues/milestones/#update-a-milestone /// The owner of the repository /// The name of the repository /// The Milestone number /// An instance describing the changes to make to the Milestone /// /// public Task Update(string owner, string name, int number, MilestoneUpdate milestoneUpdate) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(milestoneUpdate, "milestoneUpdate"); return ApiConnection.Patch(ApiUrls.Milestone(owner, name, number), milestoneUpdate); } /// /// Creates a milestone for the specified repository. Any user with pull access to a repository can create an /// Milestone. /// /// http://developer.github.com/v3/issues/milestones/#update-a-milestone /// The ID of the repository /// The Milestone number /// An instance describing the changes to make to the Milestone /// /// public Task Update(int repositoryId, int number, MilestoneUpdate milestoneUpdate) { Ensure.ArgumentNotNull(milestoneUpdate, "milestoneUpdate"); return ApiConnection.Patch(ApiUrls.Milestone(repositoryId, number), milestoneUpdate); } /// /// Deletes a milestone for the specified repository. Any user with pull access to a repository can create an /// Milestone. /// /// http://developer.github.com/v3/issues/milestones/#delete-a-milestone /// The owner of the repository /// The name of the repository /// The milestone number /// public Task Delete(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); return ApiConnection.Delete(ApiUrls.Milestone(owner, name, number)); } /// /// Deletes a milestone for the specified repository. Any user with pull access to a repository can create an /// Milestone. /// /// http://developer.github.com/v3/issues/milestones/#delete-a-milestone /// The ID of the repository /// The milestone number /// public Task Delete(int repositoryId, int number) { return ApiConnection.Delete(ApiUrls.Milestone(repositoryId, number)); } } }