@@ -113,8 +113,8 @@ public Pager<Note> getIssueNotes(Integer projectId, Integer issueIid, int itemsP
113
113
* Get the specified issues's note.
114
114
*
115
115
* @param projectId the project ID to get the issues for
116
- * @param issueIid the issue IID to get the notes for
117
- * @param noteId the ID of the Note to get
116
+ * @param issueIid the issue IID to get the notes for
117
+ * @param noteId the ID of the Note to get
118
118
* @return a Note instance for the specified IDs
119
119
* @throws GitLabApiException if any exception occurs
120
120
*/
@@ -127,8 +127,8 @@ public Note getIssueNote(Integer projectId, Integer issueIid, Integer noteId) th
127
127
* Create a issues's note.
128
128
*
129
129
* @param projectId the project ID to create the issues for
130
- * @param issueIid the issue IID to create the notes for
131
- * @param body the content of note
130
+ * @param issueIid the issue IID to create the notes for
131
+ * @param body the content of note
132
132
* @return the created Note instance
133
133
* @throws GitLabApiException if any exception occurs
134
134
*/
@@ -140,16 +140,18 @@ public Note createIssueNote(Integer projectId, Integer issueIid, String body) th
140
140
* Create a issues's note.
141
141
*
142
142
* @param projectId the project ID to create the issues for
143
- * @param issueIid the issue IID to create the notes for
144
- * @param body the content of note
143
+ * @param issueIid the issue IID to create the notes for
144
+ * @param body the content of note
145
145
* @param createdAt the created time of note
146
146
* @return the created Note instance
147
147
* @throws GitLabApiException if any exception occurs
148
148
*/
149
149
public Note createIssueNote (Integer projectId , Integer issueIid , String body , Date createdAt ) throws GitLabApiException {
150
+
150
151
if (projectId == null ) {
151
152
throw new RuntimeException ("projectId cannot be null" );
152
153
}
154
+
153
155
GitLabApiForm formData = new GitLabApiForm ()
154
156
.withParam ("body" , body , true )
155
157
.withParam ("created_at" , createdAt );
@@ -161,19 +163,20 @@ public Note createIssueNote(Integer projectId, Integer issueIid, String body, Da
161
163
* Update the specified issues's note.
162
164
*
163
165
* @param projectId the project ID to update the issues for
164
- * @param issueIid the issue IID to update the notes for
165
- * @param nodeId the ID of the node to update
166
- * @param body the update content for the Note
166
+ * @param issueIid the issue IID to update the notes for
167
+ * @param noteId the ID of the node to update
168
+ * @param body the update content for the Note
167
169
* @return the modified Note instance
168
170
* @throws GitLabApiException if any exception occurs
169
171
*/
170
- public Note updateIssueNote (Integer projectId , Integer issueIid , Integer nodeId , String body ) throws GitLabApiException {
172
+ public Note updateIssueNote (Integer projectId , Integer issueIid , Integer noteId , String body ) throws GitLabApiException {
173
+
171
174
if (projectId == null ) {
172
175
throw new RuntimeException ("projectId cannot be null" );
173
176
}
174
- GitLabApiForm formData = new GitLabApiForm ()
175
- .withParam ("body" , body , true );
176
- Response response = put (Response .Status .CREATED , formData .asMap (), "projects" , projectId , "issues" , issueIid , "notes" , nodeId );
177
+
178
+ GitLabApiForm formData = new GitLabApiForm () .withParam ("body" , body , true );
179
+ Response response = put (Response .Status .CREATED , formData .asMap (), "projects" , projectId , "issues" , issueIid , "notes" , noteId );
177
180
return (response .readEntity (Note .class ));
178
181
}
179
182
@@ -186,16 +189,216 @@ public Note updateIssueNote(Integer projectId, Integer issueIid, Integer nodeId,
186
189
* @throws GitLabApiException if any exception occurs
187
190
*/
188
191
public void deleteIssueNote (Integer projectId , Integer issueIid , Integer noteId ) throws GitLabApiException {
192
+
189
193
if (projectId == null ) {
190
194
throw new RuntimeException ("projectId cannot be null" );
191
195
}
196
+
192
197
if (issueIid == null ) {
193
198
throw new RuntimeException ("issueIid cannot be null" );
194
199
}
200
+
195
201
if (noteId == null ) {
196
202
throw new RuntimeException ("noteId cannot be null" );
197
203
}
204
+
198
205
Response .Status expectedStatus = (isApiVersion (GitLabApi .ApiVersion .V3 ) ? Response .Status .OK : Response .Status .NO_CONTENT );
199
206
delete (expectedStatus , getDefaultPerPageParam (), "projects" , projectId , "issues" , issueIid , "notes" , noteId );
200
207
}
208
+
209
+ /**
210
+ * Gets a list of all notes for a single merge request. Only returns the first page
211
+ *
212
+ * GET /projects/:id/merge_requests/:merge_request_iid/notes
213
+ *
214
+ * @param projectId the project ID to get the issues for
215
+ * @param mergeRequestIid the issue ID to get the notes for
216
+ * @return a list of the merge request's notes
217
+ * @throws GitLabApiException if any exception occurs
218
+ */
219
+ public List <Note > getMergeRequestNotes (Integer projectId , Integer mergeRequestIid ) throws GitLabApiException {
220
+ return (getMergeRequestNotes (projectId , mergeRequestIid , null , null , 1 , getDefaultPerPage ()));
221
+ }
222
+
223
+ /**
224
+ * Gets a list of all notes for a single merge request. Only returns the first page
225
+ *
226
+ * GET /projects/:id/merge_requests/:merge_request_iid/notes
227
+ *
228
+ * @param projectId the project ID to get the issues for
229
+ * @param mergeRequestIid the issue ID to get the notes for
230
+ * @param sortOrder return merge request notes sorted in the specified sort order, default is DESC
231
+ * @param orderBy return merge request notes ordered by CREATED_AT or UPDATED_AT, default is CREATED_AT
232
+ * @return a list of the merge request's notes
233
+ * @throws GitLabApiException if any exception occurs
234
+ */
235
+ public List <Note > getMergeRequestNotes (Integer projectId , Integer mergeRequestIid , SortOrder sortOrder , Note .OrderBy orderBy ) throws GitLabApiException {
236
+ return (getMergeRequestNotes (projectId , mergeRequestIid , sortOrder , orderBy , 1 , getDefaultPerPage ()));
237
+ }
238
+
239
+ /**
240
+ * Gets a list of all notes for a single merge request using the specified page and per page settings.
241
+ *
242
+ * GET /projects/:id/merge_requests/:merge_request_iid/notes
243
+ *
244
+ * @param projectId the project ID to get the issues for
245
+ * @param mergeRequestIid the merge request IID to get the notes for
246
+ * @param page the page to get
247
+ * @param perPage the number of notes per page
248
+ * @return the list of notes in the specified range
249
+ * @throws GitLabApiException if any exception occurs
250
+ */
251
+ public List <Note > getMergeRequestNotes (Integer projectId , Integer mergeRequestIid , int page , int perPage ) throws GitLabApiException {
252
+ return (getMergeRequestNotes (projectId , mergeRequestIid , null , null , page , perPage ));
253
+ }
254
+
255
+ /**
256
+ * Gets a list of all notes for a single merge request using the specified page and per page settings.
257
+ *
258
+ * GET /projects/:id/merge_requests/:merge_request_iid/notes
259
+ *
260
+ * @param projectId the project ID to get the issues for
261
+ * @param mergeRequestIid the merge request IID to get the notes for
262
+ * @param sortOrder return merge request notes sorted in the specified sort order, default is DESC
263
+ * @param orderBy return merge request notes ordered by CREATED_AT or UPDATED_AT, default is CREATED_AT
264
+ * @param page the page to get
265
+ * @param perPage the number of notes per page
266
+ * @return the list of notes in the specified range
267
+ * @throws GitLabApiException if any exception occurs
268
+ */
269
+ public List <Note > getMergeRequestNotes (Integer projectId , Integer mergeRequestIid ,
270
+ SortOrder sortOrder , Note .OrderBy orderBy , int page , int perPage ) throws GitLabApiException {
271
+
272
+ GitLabApiForm formData = new GitLabApiForm ()
273
+ .withParam ("sort" , sortOrder )
274
+ .withParam ("order_by" , orderBy )
275
+ .withParam (PAGE_PARAM , page )
276
+ .withParam (PER_PAGE_PARAM , perPage );
277
+ Response response = get (Response .Status .OK , formData .asMap (), "projects" , projectId , "merge_requests" , mergeRequestIid , "notes" );
278
+ return (response .readEntity (new GenericType <List <Note >>() {}));
279
+ }
280
+
281
+ /**
282
+ * Get a Pager of all notes for a single merge request
283
+ *
284
+ * GET /projects/:id/merge_requests/:merge_request_iid/notes
285
+ *
286
+ * @param projectId the project ID to get the issues for
287
+ * @param mergeRequestIid the merge request IID to get the notes for
288
+ * @param itemsPerPage the number of notes per page
289
+ * @return the list of notes in the specified range
290
+ * @throws GitLabApiException if any exception occurs
291
+ */
292
+ public Pager <Note > getMergeRequestNotes (Integer projectId , Integer mergeRequestIid , int itemsPerPage ) throws GitLabApiException {
293
+ return (getMergeRequestNotes (projectId , mergeRequestIid , null , null , itemsPerPage ));
294
+ }
295
+
296
+ /**
297
+ * Get a Pager of all notes for a single merge request
298
+ *
299
+ * GET /projects/:id/merge_requests/:merge_request_iid/notes
300
+ *
301
+ * @param projectId the project ID to get the issues for
302
+ * @param mergeRequestIid the merge request IID to get the notes for
303
+ * @param sortOrder return merge request notes sorted in the specified sort order, default is DESC
304
+ * @param orderBy return merge request notes ordered by CREATED_AT or UPDATED_AT, default is CREATED_AT
305
+ * @param itemsPerPage the number of notes per page
306
+ * @return the list of notes in the specified range
307
+ * @throws GitLabApiException if any exception occurs
308
+ */
309
+ public Pager <Note > getMergeRequestNotes (Integer projectId , Integer mergeRequestIid ,
310
+ SortOrder sortOrder , Note .OrderBy orderBy , int itemsPerPage ) throws GitLabApiException {
311
+
312
+ GitLabApiForm formData = new GitLabApiForm ()
313
+ .withParam ("sort" , sortOrder )
314
+ .withParam ("order_by" , orderBy )
315
+ .withParam (PAGE_PARAM , 1 )
316
+ .withParam (PER_PAGE_PARAM , itemsPerPage );
317
+ return (new Pager <Note >(this , Note .class , itemsPerPage , formData .asMap (),
318
+ "projects" , projectId , "merge_requests" , mergeRequestIid , "notes" ));
319
+ }
320
+
321
+ /**
322
+ * Get the specified merge request's note.
323
+ *
324
+ * @param projectId the project ID to get the issues for
325
+ * @param mergeRequestIid the merge request IID to get the notes for
326
+ * @param noteId the ID of the Note to get
327
+ * @return a Note instance for the specified IDs
328
+ * @throws GitLabApiException if any exception occurs
329
+ */
330
+ public Note getMergeRequestNote (Integer projectId , Integer mergeRequestIid , Integer noteId ) throws GitLabApiException {
331
+ Response response = get (Response .Status .OK , getDefaultPerPageParam (),
332
+ "projects" , projectId , "merge_requests" , mergeRequestIid , "notes" , noteId );
333
+ return (response .readEntity (Note .class ));
334
+ }
335
+
336
+ /**
337
+ * Create a merge request's note.
338
+ *
339
+ * @param projectId the project ID to create the issues for
340
+ * @param mergeRequestIid the merge request IID to create the notes for
341
+ * @param body the content of note
342
+ * @return the created Note instance
343
+ * @throws GitLabApiException if any exception occurs
344
+ */
345
+ public Note createMergeRequestNote (Integer projectId , Integer mergeRequestIid , String body ) throws GitLabApiException {
346
+
347
+ if (projectId == null ) {
348
+ throw new RuntimeException ("projectId cannot be null" );
349
+ }
350
+
351
+ GitLabApiForm formData = new GitLabApiForm ().withParam ("body" , body , true );
352
+ Response response = post (Response .Status .CREATED , formData ,
353
+ "projects" , projectId , "merge_requests" , mergeRequestIid , "notes" );
354
+ return (response .readEntity (Note .class ));
355
+ }
356
+
357
+ /**
358
+ * Update the specified merge request's note.
359
+ *
360
+ * @param projectId the project ID to update the issues for
361
+ * @param mergeRequestIid the merge request IID to update the notes for
362
+ * @param noteId the ID of the node to update
363
+ * @param body the update content for the Note
364
+ * @return the modified Note instance
365
+ * @throws GitLabApiException if any exception occurs
366
+ */
367
+ public Note updateMergeRequestNote (Integer projectId , Integer mergeRequestIid , Integer noteId , String body ) throws GitLabApiException {
368
+
369
+ if (projectId == null ) {
370
+ throw new RuntimeException ("projectId cannot be null" );
371
+ }
372
+
373
+ GitLabApiForm formData = new GitLabApiForm ().withParam ("body" , body , true );
374
+ Response response = put (Response .Status .CREATED , formData .asMap (),
375
+ "projects" , projectId , "merge_requests" , mergeRequestIid , "notes" , noteId );
376
+ return (response .readEntity (Note .class ));
377
+ }
378
+
379
+ /**
380
+ * Delete the specified merge request's note.
381
+ *
382
+ * @param projectId the project ID to delete the issues for
383
+ * @param mergeRequestIid the merge request IID to delete the notes for
384
+ * @param noteId the ID of the node to delete
385
+ * @throws GitLabApiException if any exception occurs
386
+ */
387
+ public void deleteMergeRequestNote (Integer projectId , Integer mergeRequestIid , Integer noteId ) throws GitLabApiException {
388
+
389
+ if (projectId == null ) {
390
+ throw new RuntimeException ("projectId cannot be null" );
391
+ }
392
+
393
+ if (mergeRequestIid == null ) {
394
+ throw new RuntimeException ("mergeRequestIid cannot be null" );
395
+ }
396
+
397
+ if (noteId == null ) {
398
+ throw new RuntimeException ("noteId cannot be null" );
399
+ }
400
+
401
+ Response .Status expectedStatus = (isApiVersion (GitLabApi .ApiVersion .V3 ) ? Response .Status .OK : Response .Status .NO_CONTENT );
402
+ delete (expectedStatus , getDefaultPerPageParam (), "projects" , projectId , "merge_requests" , mergeRequestIid , "notes" , noteId );
403
+ }
201
404
}
0 commit comments