-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathRepositoryCommentsClient.cs
270 lines (240 loc) · 13.6 KB
/
RepositoryCommentsClient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Repository Comments API.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/comments/">Repository Comments API documentation</a> for more information.
/// </remarks>
public class RepositoryCommentsClient : ApiClient, IRepositoryCommentsClient
{
/// <summary>
/// Instantiates a new GitHub Repository Comments API client.
/// </summary>
/// <param name="apiConnection">An API connection</param>
public RepositoryCommentsClient(IApiConnection apiConnection)
: base(apiConnection)
{
}
/// <summary>
/// Gets a single Repository Comment by number.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="commentId">The comment id</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment</remarks>
[ManualRoute("GET", "/repos/{owner}/{repo}/comments/{comment_id}")]
public Task<CommitComment> Get(string owner, string name, long commentId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return ApiConnection.Get<CommitComment>(ApiUrls.CommitComment(owner, name, commentId), null);
}
/// <summary>
/// Gets a single Repository Comment by number.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="commentId">The comment id</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment</remarks>
[ManualRoute("GET", "/repositories/{id}/comments/{number}")]
public Task<CommitComment> Get(long repositoryId, long commentId)
{
return ApiConnection.Get<CommitComment>(ApiUrls.CommitComment(repositoryId, commentId), null);
}
/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
[ManualRoute("GET", "/repos/{owner}/{repo}/comments")]
public Task<IReadOnlyList<CommitComment>> GetAllForRepository(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAllForRepository(owner, name, ApiOptions.None);
}
/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
[ManualRoute("GET", "/repositories/{id}/comments")]
public Task<IReadOnlyList<CommitComment>> GetAllForRepository(long repositoryId)
{
return GetAllForRepository(repositoryId, ApiOptions.None);
}
/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options to change the API response</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
[ManualRoute("GET", "/repos/{owner}/{repo}/comments")]
public Task<IReadOnlyList<CommitComment>> 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<CommitComment>(ApiUrls.CommitComments(owner, name), null, options);
}
/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="options">Options to change the API response</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
[ManualRoute("GET", "/repositories/{id}/comments")]
public Task<IReadOnlyList<CommitComment>> GetAllForRepository(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll<CommitComment>(ApiUrls.CommitComments(repositoryId), null, options);
}
/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="sha">The sha of the commit</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
[ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/comments")]
public Task<IReadOnlyList<CommitComment>> 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);
}
/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="sha">The sha of the commit</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
[ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/comments")]
public Task<IReadOnlyList<CommitComment>> GetAllForCommit(long repositoryId, string sha)
{
Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha));
return GetAllForCommit(repositoryId, sha, ApiOptions.None);
}
/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="sha">The sha of the commit</param>
/// <param name="options">Options to change the API response</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
[ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/comments")]
public Task<IReadOnlyList<CommitComment>> 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<CommitComment>(ApiUrls.CommitComments(owner, name, sha), null, options);
}
/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="sha">The sha of the commit</param>
/// <param name="options">Options to change the API response</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
[ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/comments")]
public Task<IReadOnlyList<CommitComment>> GetAllForCommit(long repositoryId, string sha, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll<CommitComment>(ApiUrls.CommitComments(repositoryId, sha), null, options);
}
/// <summary>
/// Creates a new Commit Comment for a specified Commit.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="sha">The sha reference of commit</param>
/// <param name="newCommitComment">The new comment to add to the commit</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks>
[ManualRoute("POST", "/repos/{owner}/{repo}/commits/{commit_sha}/comments")]
public Task<CommitComment> 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<CommitComment>(ApiUrls.CommitComments(owner, name, sha), newCommitComment);
}
/// <summary>
/// Creates a new Commit Comment for a specified Commit.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="sha">The sha reference of commit</param>
/// <param name="newCommitComment">The new comment to add to the commit</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks>
[ManualRoute("POST", "/repositories/{id}/commits/{commit_sha}/comments")]
public Task<CommitComment> Create(long repositoryId, string sha, NewCommitComment newCommitComment)
{
Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha));
Ensure.ArgumentNotNull(newCommitComment, nameof(newCommitComment));
return ApiConnection.Post<CommitComment>(ApiUrls.CommitComments(repositoryId, sha), newCommitComment);
}
/// <summary>
/// Updates a specified Commit Comment.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="commentId">The comment id</param>
/// <param name="commentUpdate">The modified comment</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#update-a-commit-comment</remarks>
[ManualRoute("PATCH", "/repos/{owner}/{repo}/comments/{comment_id}")]
public Task<CommitComment> 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<CommitComment>(ApiUrls.CommitComment(owner, name, commentId), new BodyWrapper(commentUpdate));
}
/// <summary>
/// Updates a specified Commit Comment.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="commentId">The comment id</param>
/// <param name="commentUpdate">The modified comment</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#update-a-commit-comment</remarks>
[ManualRoute("PATCH", "/repositories/{id}/comments/{number}")]
public Task<CommitComment> Update(long repositoryId, long commentId, string commentUpdate)
{
Ensure.ArgumentNotNull(commentUpdate, nameof(commentUpdate));
return ApiConnection.Patch<CommitComment>(ApiUrls.CommitComment(repositoryId, commentId), new BodyWrapper(commentUpdate));
}
/// <summary>
/// Deletes the specified Commit Comment
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="commentId">The comment id</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#delete-a-commit-comment</remarks>
[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));
}
/// <summary>
/// Deletes the specified Commit Comment
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="commentId">The comment id</param>
/// <remarks>http://developer.github.com/v3/repos/comments/#delete-a-commit-comment</remarks>
[ManualRoute("DELETE", "/repositories/{id}/comments/{number}")]
public Task Delete(long repositoryId, long commentId)
{
return ApiConnection.Delete(ApiUrls.CommitComment(repositoryId, commentId));
}
}
}