Skip to content

Commit f08c095

Browse files
authored
Merge pull request #812 from gitlab4j/pr-768
Fix #767 : Adding merge request note award functions and renaming issue functions
2 parents e9e2a5b + 7c9c8c6 commit f08c095

File tree

1 file changed

+156
-18
lines changed

1 file changed

+156
-18
lines changed

src/main/java/org/gitlab4j/api/AwardEmojiApi.java

Lines changed: 156 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/**
1111
* This class implements the client side API for the GitLab Award Emoji API calls.
12-
*
12+
*
1313
* @see <a href="https://docs.gitlab.com/ce/api/award_emoji.html">GitLab Award Emoji API Documentaion</a>
1414
* @since v4.8.31
1515
*/
@@ -68,7 +68,24 @@ public List<AwardEmoji> getSnippetAwardEmojis(Object projectIdOrPath, Integer sn
6868
}
6969

7070
/**
71-
* Get a list of award emoji for the specified note.
71+
* Get a list of award emoji for the specified issue note.
72+
*
73+
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji</code></pre>
74+
*
75+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
76+
* @param issueIid the issue IID of the issue that owns the note
77+
* @param noteId the note ID to get the award emojis for
78+
* @return a list of AwardEmoji for the specified note
79+
* @throws GitLabApiException if any exception occurs
80+
*/
81+
public List<AwardEmoji> getIssueNoteAwardEmojis(Object projectIdOrPath, Integer issueIid, Integer noteId) throws GitLabApiException {
82+
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
83+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
84+
return response.readEntity(new GenericType<List<AwardEmoji>>() {});
85+
}
86+
87+
/**
88+
* Get a list of award emoji for the specified issue note.
7289
*
7390
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji</code></pre>
7491
*
@@ -79,8 +96,23 @@ public List<AwardEmoji> getSnippetAwardEmojis(Object projectIdOrPath, Integer sn
7996
* @throws GitLabApiException if any exception occurs
8097
*/
8198
public List<AwardEmoji> getNoteAwardEmojis(Object projectIdOrPath, Integer issueIid, Integer noteId) throws GitLabApiException {
99+
return getIssueNoteAwardEmojis(projectIdOrPath, issueIid, noteId);
100+
}
101+
102+
/**
103+
* Get a list of award emoji for the specified merge request note.
104+
*
105+
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji</code></pre>
106+
*
107+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
108+
* @param mergeRequestIid the merge request IID of the merge request that owns the note
109+
* @param noteId the note ID to get the award emojis for
110+
* @return a list of AwardEmoji for the specified note
111+
* @throws GitLabApiException if any exception occurs
112+
*/
113+
public List<AwardEmoji> getMergeRequestNoteAwardEmojis(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId) throws GitLabApiException {
82114
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
83-
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
115+
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji");
84116
return response.readEntity(new GenericType<List<AwardEmoji>>() {});
85117
}
86118

@@ -92,7 +124,7 @@ public List<AwardEmoji> getNoteAwardEmojis(Object projectIdOrPath, Integer issue
92124
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
93125
* @param issueIid the issue IID to get the award emoji for
94126
* @param awardId the ID of the award emoji to get
95-
* @return an AwardEmoji instance for the specified award emoji
127+
* @return an AwardEmoji instance for the specified award emoji
96128
* @throws GitLabApiException if any exception occurs
97129
*/
98130
public AwardEmoji getIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer awardId) throws GitLabApiException {
@@ -109,7 +141,7 @@ public AwardEmoji getIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, I
109141
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
110142
* @param mergeRequestIid the merge request IID to get the award emoji for
111143
* @param awardId the ID of the award emoji to get
112-
* @return an AwardEmoji instance for the specified award emoji
144+
* @return an AwardEmoji instance for the specified award emoji
113145
* @throws GitLabApiException if any exception occurs
114146
*/
115147
public AwardEmoji getMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer awardId) throws GitLabApiException {
@@ -126,7 +158,7 @@ public AwardEmoji getMergeRequestAwardEmoji(Object projectIdOrPath, Integer merg
126158
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
127159
* @param snippetId the snippet ID to get the award emoji for
128160
* @param awardId the ID of the award emoji to get
129-
* @return an AwardEmoji instance for the specified award emoji
161+
* @return an AwardEmoji instance for the specified award emoji
130162
* @throws GitLabApiException if any exception occurs
131163
*/
132164
public AwardEmoji getSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, Integer awardId) throws GitLabApiException {
@@ -136,20 +168,56 @@ public AwardEmoji getSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId
136168
}
137169

138170
/**
139-
* Get the specified award emoji for the specified note.
171+
* Get the specified award emoji for the specified issue note.
140172
*
141173
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id</code></pre>
142174
*
143175
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
144176
* @param issueIid the issue IID of the issue that owns the note
145177
* @param noteId the note ID to get the award emoji from
146178
* @param awardId the ID of the award emoji to get
147-
* @return an AwardEmoji instance for the specified award emoji
179+
* @return an AwardEmoji instance for the specified award emoji
148180
* @throws GitLabApiException if any exception occurs
149181
*/
182+
public AwardEmoji getIssueNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException {
183+
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
184+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
185+
return (response.readEntity(AwardEmoji.class));
186+
}
187+
188+
/**
189+
* Get the specified award emoji for the specified issue note.
190+
*
191+
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id</code></pre>
192+
*
193+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
194+
* @param issueIid the issue IID of the issue that owns the note
195+
* @param noteId the note ID to get the award emoji from
196+
* @param awardId the ID of the award emoji to get
197+
* @return an AwardEmoji instance for the specified award emoji
198+
* @throws GitLabApiException if any exception occurs
199+
* @deprecated use {@link #getIssueNoteAwardEmoji(Object, Integer, Integer, Integer)} instead
200+
*/
201+
@Deprecated
150202
public AwardEmoji getNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException {
203+
return getIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId);
204+
}
205+
206+
/**
207+
* Get the specified award emoji for the specified merge request note.
208+
*
209+
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji/:award_id</code></pre>
210+
*
211+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
212+
* @param mergeRequestIid the merge request IID of the merge request that owns the note
213+
* @param noteId the note ID to get the award emoji from
214+
* @param awardId the ID of the award emoji to get
215+
* @return an AwardEmoji instance for the specified award emoji
216+
* @throws GitLabApiException if any exception occurs
217+
*/
218+
public AwardEmoji getMergeRequestNoteAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, Integer awardId) throws GitLabApiException {
151219
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
152-
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
220+
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId);
153221
return (response.readEntity(AwardEmoji.class));
154222
}
155223

@@ -161,7 +229,7 @@ public AwardEmoji getNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, In
161229
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
162230
* @param issueIid the issue IID to add the award emoji to
163231
* @param name the name of the award emoji to add
164-
* @return an AwardEmoji instance for the added award emoji
232+
* @return an AwardEmoji instance for the added award emoji
165233
* @throws GitLabApiException if any exception occurs
166234
*/
167235
public AwardEmoji addIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, String name) throws GitLabApiException {
@@ -179,7 +247,7 @@ public AwardEmoji addIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, S
179247
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
180248
* @param mergeRequestIid the merge request IID to add the award emoji to
181249
* @param name the name of the award emoji to add
182-
* @return an AwardEmoji instance for the added award emoji
250+
* @return an AwardEmoji instance for the added award emoji
183251
* @throws GitLabApiException if any exception occurs
184252
*/
185253
public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, String name) throws GitLabApiException {
@@ -197,7 +265,7 @@ public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Integer merg
197265
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
198266
* @param snippetId the snippet ID to add the award emoji to
199267
* @param name the name of the award emoji to add
200-
* @return an AwardEmoji instance for the added award emoji
268+
* @return an AwardEmoji instance for the added award emoji
201269
* @throws GitLabApiException if any exception occurs
202270
*/
203271
public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, String name) throws GitLabApiException {
@@ -208,21 +276,58 @@ public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId
208276
}
209277

210278
/**
211-
* Add an award emoji for the specified note.
279+
* Add an award emoji for the specified issue note.
212280
*
213281
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji</code></pre>
214282
*
215283
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
216284
* @param issueIid the issue IID of the issue that owns the note
217285
* @param noteId the note ID to add the award emoji to
218286
* @param name the name of the award emoji to add
219-
* @return an AwardEmoji instance for the added award emoji
287+
* @return an AwardEmoji instance for the added award emoji
220288
* @throws GitLabApiException if any exception occurs
221289
*/
290+
public AwardEmoji addIssueNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, String name) throws GitLabApiException {
291+
GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
292+
Response response = post(Response.Status.CREATED, form.asMap(),
293+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
294+
return (response.readEntity(AwardEmoji.class));
295+
}
296+
297+
/**
298+
* Add an award emoji for the specified issue note.
299+
*
300+
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji</code></pre>
301+
*
302+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
303+
* @param issueIid the issue IID of the issue that owns the note
304+
* @param noteId the note ID to add the award emoji to
305+
* @param name the name of the award emoji to add
306+
* @return an AwardEmoji instance for the added award emoji
307+
* @throws GitLabApiException if any exception occurs
308+
* @deprecated use {@link #addIssueNoteAwardEmoji(Object, Integer, Integer, String)}
309+
*/
310+
@Deprecated
222311
public AwardEmoji addNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, String name) throws GitLabApiException {
312+
return addIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, name);
313+
}
314+
315+
/**
316+
* Add an award emoji for the specified merge request note.
317+
*
318+
* <pre><code>GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/notes/:noteId/award_emoji</code></pre>
319+
*
320+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
321+
* @param mergeRequestIid the merge request IID of the merge request that owns the note
322+
* @param noteId the note ID to add the award emoji to
323+
* @param name the name of the award emoji to add
324+
* @return an AwardEmoji instance for the added award emoji
325+
* @throws GitLabApiException if any exception occurs
326+
*/
327+
public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, String name) throws GitLabApiException {
223328
GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
224329
Response response = post(Response.Status.CREATED, form.asMap(),
225-
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
330+
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji");
226331
return (response.readEntity(AwardEmoji.class));
227332
}
228333

@@ -269,10 +374,26 @@ public void deleteMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRe
269374
public void deleteSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, Integer awardId) throws GitLabApiException {
270375
delete(Response.Status.NO_CONTENT, null,
271376
"projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji", awardId);
272-
}
377+
}
378+
379+
/**
380+
* Delete an award emoji from the specified issue note.
381+
*
382+
* <pre><code>GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id</code></pre>
383+
*
384+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
385+
* @param issueIid the issue IID that owns the note
386+
* @param noteId the note ID of the note to delete the award emoji from
387+
* @param awardId the ID of the award emoji to delete
388+
* @throws GitLabApiException if any exception occurs
389+
*/
390+
public void deleteIssueNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException {
391+
delete(Response.Status.NO_CONTENT, null,
392+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
393+
}
273394

274395
/**
275-
* Delete an award emoji from the specified note.
396+
* Delete an award emoji from the specified issue note.
276397
*
277398
* <pre><code>GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id</code></pre>
278399
*
@@ -281,9 +402,26 @@ public void deleteSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, I
281402
* @param noteId the note ID of the note to delete the award emoji from
282403
* @param awardId the ID of the award emoji to delete
283404
* @throws GitLabApiException if any exception occurs
405+
* @deprecated use {@link #deleteIssueNoteAwardEmoji(Object, Integer, Integer, Integer)} instead
284406
*/
407+
@Deprecated
285408
public void deleteNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException {
409+
deleteIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId);
410+
}
411+
412+
/**
413+
* Delete an award emoji from the specified merge request note.
414+
*
415+
* <pre><code>GitLab Endpoint: DELETE /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji/:award_id</code></pre>
416+
*
417+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
418+
* @param mergeRequestIid the merge request IID of the merge request that owns the note
419+
* @param noteId the note ID of the note to delete the award emoji from
420+
* @param awardId the ID of the award emoji to delete
421+
* @throws GitLabApiException if any exception occurs
422+
*/
423+
public void deleteMergeRequestNoteAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, Integer awardId) throws GitLabApiException {
286424
delete(Response.Status.NO_CONTENT, null,
287-
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
425+
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId);
288426
}
289427
}

0 commit comments

Comments
 (0)