using System.Collections.Generic; using System.Threading.Tasks; namespace Octokit { /// /// A client for GitHub's Issue Comments API. /// /// /// See the Issue Comments API documentation for more information. /// public class IssueCommentsClient : ApiClient, IIssueCommentsClient { /// /// Instantiates a new GitHub Issue Comments API client. /// /// An API connection public IssueCommentsClient(IApiConnection apiConnection) : base(apiConnection) { } /// /// Gets a single Issue Comment by id. /// /// http://developer.github.com/v3/issues/comments/#get-a-single-comment /// The owner of the repository /// The name of the repository /// The issue comment id [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/comments/{comment_id}")] public Task Get(string owner, string name, int id) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return ApiConnection.Get(ApiUrls.IssueComment(owner, name, id), null, AcceptHeaders.ReactionsPreview); } /// /// Gets a single Issue Comment by id. /// /// http://developer.github.com/v3/issues/comments/#get-a-single-comment /// The Id of the repository /// The issue comment id [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/issues/comments/{comment_id}")] public Task Get(long repositoryId, int id) { return ApiConnection.Get(ApiUrls.IssueComment(repositoryId, id), null, AcceptHeaders.ReactionsPreview); } /// /// Gets Issue Comments for a repository. /// /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository /// The owner of the repository /// The name of the repository [ManualRoute("GET", "/repos/{owner}/{repo}/issues/comments")] public Task> GetAllForRepository(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return GetAllForRepository(owner, name, new IssueCommentRequest(), ApiOptions.None); } /// /// Gets Issue Comments for a repository. /// /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository /// The Id of the repository [ManualRoute("GET", "/repositories/{id}/issues/comments")] public Task> GetAllForRepository(long repositoryId) { return GetAllForRepository(repositoryId, new IssueCommentRequest(), ApiOptions.None); } /// /// Gets Issue Comments for a repository. /// /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository /// The owner of the repository /// The name of the repository /// Options for changing the API response [ManualRoute("GET", "/repos/{owner}/{repo}/issues/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 GetAllForRepository(owner, name, new IssueCommentRequest(), options); } /// /// Gets Issue Comments for a repository. /// /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository /// The Id of the repository /// Options for changing the API response [ManualRoute("GET", "/repositories/{id}/issues/comments")] public Task> GetAllForRepository(long repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); return GetAllForRepository(repositoryId, new IssueCommentRequest(), options); } /// /// Gets Issue Comments for a repository. /// /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository /// The owner of the repository /// The name of the repository /// The sorting parameters [ManualRoute("GET", "/repos/{owner}/{repo}/issues/comments")] public Task> GetAllForRepository(string owner, string name, IssueCommentRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(request, nameof(request)); return GetAllForRepository(owner, name, request, ApiOptions.None); } /// /// Gets Issue Comments for a repository. /// /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository /// The Id of the repository /// The sorting parameters [ManualRoute("GET", "/repositories/{id}/issues/comments")] public Task> GetAllForRepository(long repositoryId, IssueCommentRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); return GetAllForRepository(repositoryId, request, ApiOptions.None); } /// /// Gets Issue Comments for a repository. /// /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository /// The owner of the repository /// The name of the repository /// The sorting parameters /// Options for changing the API response [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/comments")] public Task> GetAllForRepository(string owner, string name, IssueCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); } /// /// Gets Issue Comments for a repository. /// /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository /// The Id of the repository /// The sorting parameters /// Options for changing the API response [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/issues/comments")] public Task> GetAllForRepository(long repositoryId, IssueCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); return ApiConnection.GetAll(ApiUrls.IssueComments(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); } /// /// Gets Issue Comments for a specified Issue. /// /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue /// The owner of the repository /// The name of the repository /// The issue number [ManualRoute("GET", "/repos/{owner}/{repo}/issues/{number]/comments")] public Task> GetAllForIssue(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return GetAllForIssue(owner, name, number, ApiOptions.None); } /// /// Gets Issue Comments for a specified Issue. /// /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue /// The Id of the repository /// The issue number [ManualRoute("GET", "/repositories/{id}/issues/{number}/comments")] public Task> GetAllForIssue(long repositoryId, int number) { return GetAllForIssue(repositoryId, number, ApiOptions.None); } /// /// Gets Issue Comments for a specified Issue. /// /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue /// The owner of the repository /// The name of the repository /// The issue number /// Options for changing the API response [ManualRoute("GET", "/repos/{owner}/{repo}/issues/{number]/comments")] public Task> GetAllForIssue(string owner, string name, int number, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); return GetAllForIssue(owner, name, number, new IssueCommentRequest(), options); } /// /// Gets Issue Comments for a specified Issue. /// /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue /// The Id of the repository /// The issue number /// Options for changing the API response [ManualRoute("GET", "/repositories/{id}/issues/{number}/comments")] public Task> GetAllForIssue(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); return GetAllForIssue(repositoryId, number, new IssueCommentRequest(), options); } /// /// Gets Issue Comments for a specified Issue. /// /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue /// The owner of the repository /// The name of the repository /// The issue number /// The sorting parameters [ManualRoute("GET", "/repos/{owner}/{repo}/issues/{number]/comments")] public Task> GetAllForIssue(string owner, string name, int number, IssueCommentRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(request, nameof(request)); return GetAllForIssue(owner, name, number, request, ApiOptions.None); } /// /// Gets Issue Comments for a specified Issue. /// /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue /// The Id of the repository /// The issue number /// The sorting parameters [ManualRoute("GET", "/repositories/{id}/issues/{number}/comments")] public Task> GetAllForIssue(long repositoryId, int number, IssueCommentRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); return GetAllForIssue(repositoryId, number, request, ApiOptions.None); } /// /// Gets Issue Comments for a specified Issue. /// /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue /// The owner of the repository /// The name of the repository /// The issue number /// The sorting parameters /// Options for changing the API response [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/{number]/comments")] public Task> GetAllForIssue(string owner, string name, int number, IssueCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name, number), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); } /// /// Gets Issue Comments for a specified Issue. /// /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue /// The Id of the repository /// The issue number /// The sorting parameters /// Options for changing the API response [ManualRoute("GET", "/repositories/{id}/issues/{number}/comments")] [Preview("squirrel-girl")] public Task> GetAllForIssue(long repositoryId, int number, IssueCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); return ApiConnection.GetAll(ApiUrls.IssueComments(repositoryId, number), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); } /// /// Creates a new Issue Comment for a specified Issue. /// /// http://developer.github.com/v3/issues/comments/#create-a-comment /// The owner of the repository /// The name of the repository /// The number of the issue /// The new comment to add to the issue [ManualRoute("POST", "/repos/{owner}/{repo}/issues/{number]/comments")] public Task Create(string owner, string name, int number, string newComment) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(newComment, nameof(newComment)); return ApiConnection.Post(ApiUrls.IssueComments(owner, name, number), new BodyWrapper(newComment)); } /// /// Creates a new Issue Comment for a specified Issue. /// /// http://developer.github.com/v3/issues/comments/#create-a-comment /// The Id of the repository /// The number of the issue /// The new comment to add to the issue [ManualRoute("POST", "/repositories/{id}/issues/{number}/comments")] public Task Create(long repositoryId, int number, string newComment) { Ensure.ArgumentNotNull(newComment, nameof(newComment)); return ApiConnection.Post(ApiUrls.IssueComments(repositoryId, number), new BodyWrapper(newComment)); } /// /// Updates a specified Issue Comment. /// /// http://developer.github.com/v3/issues/comments/#edit-a-comment /// The owner of the repository /// The name of the repository /// The comment id /// The modified comment [ManualRoute("PATCH", "/repos/{owner}/{repo}/issues/comments/{id}")] public Task Update(string owner, string name, int id, string commentUpdate) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(commentUpdate, nameof(commentUpdate)); return ApiConnection.Patch(ApiUrls.IssueComment(owner, name, id), new BodyWrapper(commentUpdate)); } /// /// Updates a specified Issue Comment. /// /// http://developer.github.com/v3/issues/comments/#edit-a-comment /// The Id of the repository /// The comment id /// The modified comment [ManualRoute("PATCH", "/repositories/{id}/issues/comments/{number}")] public Task Update(long repositoryId, int id, string commentUpdate) { Ensure.ArgumentNotNull(commentUpdate, nameof(commentUpdate)); return ApiConnection.Patch(ApiUrls.IssueComment(repositoryId, id), new BodyWrapper(commentUpdate)); } /// /// Deletes the specified Issue Comment /// /// http://developer.github.com/v3/issues/comments/#delete-a-comment /// The owner of the repository /// The name of the repository /// The comment id [ManualRoute("DELETE", "/repos/{owner}/{repo}/issues/comments/{id}")] public Task Delete(string owner, string name, int id) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); return ApiConnection.Delete(ApiUrls.IssueComment(owner, name, id)); } /// /// Deletes the specified Issue Comment /// /// http://developer.github.com/v3/issues/comments/#delete-a-comment /// The Id of the repository /// The comment id [ManualRoute("DELETE", "/repositories/{id}/issues/comments/{number}")] public Task Delete(long repositoryId, int id) { return ApiConnection.Delete(ApiUrls.IssueComment(repositoryId, id)); } } }