using System.Collections.Generic; using System.Threading.Tasks; namespace Octokit { /// /// A client for GitHub's Repository Comments API. /// /// /// See the Repository Comments API documentation for more information. /// public class RepositoryCommentsClient : ApiClient, IRepositoryCommentsClient { /// /// Instantiates a new GitHub Repository Comments API client. /// /// An API connection public RepositoryCommentsClient(IApiConnection apiConnection) : base(apiConnection) { } /// /// Gets a single Repository Comment by number. /// /// The owner of the repository /// The name of the repository /// The comment id /// http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment [ManualRoute("GET", "/repos/{owner}/{repo}/comments/{comment_id}")] public Task Get(string owner, string name, long commentId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return ApiConnection.Get(ApiUrls.CommitComment(owner, name, commentId), null); } /// /// Gets a single Repository Comment by number. /// /// The Id of the repository /// The comment id /// http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment [ManualRoute("GET", "/repositories/{id}/comments/{number}")] public Task Get(long repositoryId, long commentId) { return ApiConnection.Get(ApiUrls.CommitComment(repositoryId, commentId), null); } /// /// Gets Commit Comments for a repository. /// /// The owner of the repository /// The name of the repository /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository [ManualRoute("GET", "/repos/{owner}/{repo}/comments")] public Task> GetAllForRepository(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return GetAllForRepository(owner, name, ApiOptions.None); } /// /// Gets Commit Comments for a repository. /// /// The Id of the repository /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository [ManualRoute("GET", "/repositories/{id}/comments")] public Task> GetAllForRepository(long repositoryId) { return GetAllForRepository(repositoryId, ApiOptions.None); } /// /// Gets Commit Comments for a repository. /// /// The owner of the repository /// The name of the repository /// Options to change the API response /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository [ManualRoute("GET", "/repos/{owner}/{repo}/comments")] public Task> GetAllForRepository(string owner, string name, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); return ApiConnection.GetAll(ApiUrls.CommitComments(owner, name), null, options); } /// /// Gets Commit Comments for a repository. /// /// The Id of the repository /// Options to change the API response /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository [ManualRoute("GET", "/repositories/{id}/comments")] public Task> GetAllForRepository(long repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); return ApiConnection.GetAll(ApiUrls.CommitComments(repositoryId), null, options); } /// /// Gets Commit Comments for a specified Commit. /// /// The owner of the repository /// The name of the repository /// The sha of the commit /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/comments")] public Task> GetAllForCommit(string owner, string name, string sha) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha)); return GetAllForCommit(owner, name, sha, ApiOptions.None); } /// /// Gets Commit Comments for a specified Commit. /// /// The Id of the repository /// The sha of the commit /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/comments")] public Task> GetAllForCommit(long repositoryId, string sha) { Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha)); return GetAllForCommit(repositoryId, sha, ApiOptions.None); } /// /// Gets Commit Comments for a specified Commit. /// /// The owner of the repository /// The name of the repository /// The sha of the commit /// Options to change the API response /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/comments")] public Task> GetAllForCommit(string owner, string name, string sha, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha)); Ensure.ArgumentNotNull(options, nameof(options)); return ApiConnection.GetAll(ApiUrls.CommitComments(owner, name, sha), null, options); } /// /// Gets Commit Comments for a specified Commit. /// /// The Id of the repository /// The sha of the commit /// Options to change the API response /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/comments")] public Task> GetAllForCommit(long repositoryId, string sha, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha)); Ensure.ArgumentNotNull(options, nameof(options)); return ApiConnection.GetAll(ApiUrls.CommitComments(repositoryId, sha), null, options); } /// /// Creates a new Commit Comment for a specified Commit. /// /// The owner of the repository /// The name of the repository /// The sha reference of commit /// The new comment to add to the commit /// http://developer.github.com/v3/repos/comments/#create-a-commit-comment [ManualRoute("POST", "/repos/{owner}/{repo}/commits/{commit_sha}/comments")] public Task Create(string owner, string name, string sha, NewCommitComment newCommitComment) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha)); Ensure.ArgumentNotNull(newCommitComment, nameof(newCommitComment)); return ApiConnection.Post(ApiUrls.CommitComments(owner, name, sha), newCommitComment); } /// /// Creates a new Commit Comment for a specified Commit. /// /// The Id of the repository /// The sha reference of commit /// The new comment to add to the commit /// http://developer.github.com/v3/repos/comments/#create-a-commit-comment [ManualRoute("POST", "/repositories/{id}/commits/{commit_sha}/comments")] public Task Create(long repositoryId, string sha, NewCommitComment newCommitComment) { Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha)); Ensure.ArgumentNotNull(newCommitComment, nameof(newCommitComment)); return ApiConnection.Post(ApiUrls.CommitComments(repositoryId, sha), newCommitComment); } /// /// Updates a specified Commit Comment. /// /// The owner of the repository /// The name of the repository /// The comment id /// The modified comment /// http://developer.github.com/v3/repos/comments/#update-a-commit-comment [ManualRoute("PATCH", "/repos/{owner}/{repo}/comments/{comment_id}")] public Task Update(string owner, string name, long commentId, string commentUpdate) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(commentUpdate, nameof(commentUpdate)); return ApiConnection.Patch(ApiUrls.CommitComment(owner, name, commentId), new BodyWrapper(commentUpdate)); } /// /// Updates a specified Commit Comment. /// /// The Id of the repository /// The comment id /// The modified comment /// http://developer.github.com/v3/repos/comments/#update-a-commit-comment [ManualRoute("PATCH", "/repositories/{id}/comments/{number}")] public Task Update(long repositoryId, long commentId, string commentUpdate) { Ensure.ArgumentNotNull(commentUpdate, nameof(commentUpdate)); return ApiConnection.Patch(ApiUrls.CommitComment(repositoryId, commentId), new BodyWrapper(commentUpdate)); } /// /// Deletes the specified Commit Comment /// /// The owner of the repository /// The name of the repository /// The comment id /// http://developer.github.com/v3/repos/comments/#delete-a-commit-comment [ManualRoute("DELETE", "/repos/{owner}/{repo}/comments/{comment_id}")] public Task Delete(string owner, string name, long commentId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return ApiConnection.Delete(ApiUrls.CommitComment(owner, name, commentId)); } /// /// Deletes the specified Commit Comment /// /// The Id of the repository /// The comment id /// http://developer.github.com/v3/repos/comments/#delete-a-commit-comment [ManualRoute("DELETE", "/repositories/{id}/comments/{number}")] public Task Delete(long repositoryId, long commentId) { return ApiConnection.Delete(ApiUrls.CommitComment(repositoryId, commentId)); } } }