Skip to content

Commit 558cabe

Browse files
authored
Add Award Emoji API support (#214, #219)
1 parent b89b7f0 commit 558cabe

File tree

6 files changed

+447
-0
lines changed

6 files changed

+447
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ The API has been broken up into sub APIs classes to make it easier to learn and
135135

136136
### Available Sub APIs
137137
------------------
138+
&nbsp;&nbsp;[AwardEmojiApi](#awardemojiapi)<br/>
138139
&nbsp;&nbsp;[CommitsApi](#commitsapi)<br/>
139140
&nbsp;&nbsp;[DeployKeysApi](#deploykeysapi)<br/>
140141
&nbsp;&nbsp;[EpicsApi](#epicsapi)<br/>
@@ -165,6 +166,12 @@ The API has been broken up into sub APIs classes to make it easier to learn and
165166
### Sub API Examples
166167
----------------
167168

169+
#### AwardEmojiApi
170+
```java
171+
// Get a list of AwardEmoji belonging to the specified issue (group ID = 1, issues IID = 1)
172+
List<AwardEmoji> awardEmojis = gitLabApi.getAwardEmojiApi().getIssuAwardEmojis(1, 1);
173+
```
174+
168175
#### CommitsApi
169176
```java
170177
// Get a list of commits associated with the specified branch that fall within the specified time window
Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,289 @@
1+
package org.gitlab4j.api;
2+
3+
import java.util.List;
4+
5+
import javax.ws.rs.core.GenericType;
6+
import javax.ws.rs.core.Response;
7+
8+
import org.gitlab4j.api.models.AwardEmoji;
9+
10+
/**
11+
* This class implements the client side API for the GitLab Award Emoji API calls.
12+
*
13+
* @see <a href="https://docs.gitlab.com/ce/api/award_emoji.html">GitLab Award Emoji API Documentaion</a>
14+
* @since v4.8.31
15+
*/
16+
public class AwardEmojiApi extends AbstractApi {
17+
18+
public AwardEmojiApi(GitLabApi gitLabApi) {
19+
super(gitLabApi);
20+
}
21+
22+
/**
23+
* Get a list of award emoji for the specified issue.
24+
*
25+
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/award_emoji</code></pre>
26+
*
27+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
28+
* @param issueIid the issue IID to get the award emojis for
29+
* @return a list of AwardEmoji for the specified issue
30+
* @throws GitLabApiException if any exception occurs
31+
*/
32+
public List<AwardEmoji> getIssueAwardEmojis(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
33+
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
34+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji");
35+
return response.readEntity(new GenericType<List<AwardEmoji>>() {});
36+
}
37+
38+
/**
39+
* Get a list of award emoji for the specified merge request.
40+
*
41+
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/award_emoji</code></pre>
42+
*
43+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
44+
* @param mergeRequestIid the merge request IID to get the award emojis for
45+
* @return a list of AwardEmoji for the specified merge request
46+
* @throws GitLabApiException if any exception occurs
47+
*/
48+
public List<AwardEmoji> getMergeRequestAwardEmojis(Object projectIdOrPath, Integer mergeRequestIid) throws GitLabApiException {
49+
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
50+
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji");
51+
return response.readEntity(new GenericType<List<AwardEmoji>>() {});
52+
}
53+
54+
/**
55+
* Get a list of award emoji for the specified snippet.
56+
*
57+
* <pre><code>GitLab Endpoint: GET /projects/:id/snippets/:snippet_id/award_emoji</code></pre>
58+
*
59+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
60+
* @param snippetId the snippet ID to get the award emojis for
61+
* @return a list of AwardEmoji for the specified snippet
62+
* @throws GitLabApiException if any exception occurs
63+
*/
64+
public List<AwardEmoji> getSnippetAwardEmojis(Object projectIdOrPath, Integer snippetId) throws GitLabApiException {
65+
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
66+
"projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji");
67+
return response.readEntity(new GenericType<List<AwardEmoji>>() {});
68+
}
69+
70+
/**
71+
* Get a list of award emoji for the specified 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> getNoteAwardEmojis(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 the specified award emoji for the specified issue.
89+
*
90+
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/award_emoji/:award_id</code></pre>
91+
*
92+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
93+
* @param issueIid the issue IID to get the award emoji for
94+
* @param awardId the ID of the award emoji to get
95+
* @return an AwardEmoji instance for the specified award emoji
96+
* @throws GitLabApiException if any exception occurs
97+
*/
98+
public AwardEmoji getIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer awardId) throws GitLabApiException {
99+
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
100+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji", awardId);
101+
return (response.readEntity(AwardEmoji.class));
102+
}
103+
104+
/**
105+
* Get the specified award emoji for the specified merge request.
106+
*
107+
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/award_emoji/:award_id</code></pre>
108+
*
109+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
110+
* @param mergeRequestIid the merge request IID to get the award emoji for
111+
* @param awardId the ID of the award emoji to get
112+
* @return an AwardEmoji instance for the specified award emoji
113+
* @throws GitLabApiException if any exception occurs
114+
*/
115+
public AwardEmoji getMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer awardId) throws GitLabApiException {
116+
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
117+
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji", awardId);
118+
return (response.readEntity(AwardEmoji.class));
119+
}
120+
121+
/**
122+
* Get the specified award emoji for the specified snippet.
123+
*
124+
* <pre><code>GitLab Endpoint: GET /projects/:id/snippets/:snippet_id/award_emoji/:award_id</code></pre>
125+
*
126+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
127+
* @param snippetId the snippet ID to get the award emoji for
128+
* @param awardId the ID of the award emoji to get
129+
* @return an AwardEmoji instance for the specified award emoji
130+
* @throws GitLabApiException if any exception occurs
131+
*/
132+
public AwardEmoji getSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, Integer awardId) throws GitLabApiException {
133+
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
134+
"projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji", awardId);
135+
return (response.readEntity(AwardEmoji.class));
136+
}
137+
138+
/**
139+
* Get the specified award emoji for the specified note.
140+
*
141+
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id</code></pre>
142+
*
143+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
144+
* @param issueIid the issue IID of the issue that owns the note
145+
* @param noteId the note ID to get the award emoji from
146+
* @param awardId the ID of the award emoji to get
147+
* @return an AwardEmoji instance for the specified award emoji
148+
* @throws GitLabApiException if any exception occurs
149+
*/
150+
public AwardEmoji getNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException {
151+
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
152+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
153+
return (response.readEntity(AwardEmoji.class));
154+
}
155+
156+
/**
157+
* Add an award emoji for the specified issue.
158+
*
159+
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/award_emoji</code></pre>
160+
*
161+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
162+
* @param issueIid the issue IID to add the award emoji to
163+
* @param name the name of the award emoji to add
164+
* @return an AwardEmoji instance for the added award emoji
165+
* @throws GitLabApiException if any exception occurs
166+
*/
167+
public AwardEmoji addIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, String name) throws GitLabApiException {
168+
GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
169+
Response response = post(Response.Status.CREATED, form.asMap(),
170+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji");
171+
return (response.readEntity(AwardEmoji.class));
172+
}
173+
174+
/**
175+
* Add an award emoji to the specified merge request.
176+
*
177+
* <pre><code>GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/award_emoji</code></pre>
178+
*
179+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
180+
* @param mergeRequestIid the merge request IID to add the award emoji to
181+
* @param name the name of the award emoji to add
182+
* @return an AwardEmoji instance for the added award emoji
183+
* @throws GitLabApiException if any exception occurs
184+
*/
185+
public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, String name) throws GitLabApiException {
186+
GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
187+
Response response = post(Response.Status.CREATED, form.asMap(),
188+
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji");
189+
return (response.readEntity(AwardEmoji.class));
190+
}
191+
192+
/**
193+
* Add an award emoji to the specified snippet.
194+
*
195+
* <pre><code>GitLab Endpoint: POST /projects/:id/snippets/:snippet_id/award_emoji</code></pre>
196+
*
197+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
198+
* @param snippetId the snippet ID to add the award emoji to
199+
* @param name the name of the award emoji to add
200+
* @return an AwardEmoji instance for the added award emoji
201+
* @throws GitLabApiException if any exception occurs
202+
*/
203+
public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, String name) throws GitLabApiException {
204+
GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
205+
Response response = post(Response.Status.CREATED, form.asMap(),
206+
"projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji");
207+
return (response.readEntity(AwardEmoji.class));
208+
}
209+
210+
/**
211+
* Add an award emoji for the specified note.
212+
*
213+
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji</code></pre>
214+
*
215+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
216+
* @param issueIid the issue IID of the issue that owns the note
217+
* @param noteId the note ID to add the award emoji to
218+
* @param name the name of the award emoji to add
219+
* @return an AwardEmoji instance for the added award emoji
220+
* @throws GitLabApiException if any exception occurs
221+
*/
222+
public AwardEmoji addNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, String name) throws GitLabApiException {
223+
GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
224+
Response response = post(Response.Status.CREATED, form.asMap(),
225+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
226+
return (response.readEntity(AwardEmoji.class));
227+
}
228+
229+
/**
230+
* Delete an award emoji from the specified issue.
231+
*
232+
* <pre><code>GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/award_emoji/:award_id</code></pre>
233+
*
234+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
235+
* @param issueIid the issue IID to delete the award emoji from
236+
* @param awardId the ID of the award emoji to delete
237+
* @throws GitLabApiException if any exception occurs
238+
*/
239+
public void deleteIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer awardId) throws GitLabApiException {
240+
delete(Response.Status.NO_CONTENT, null,
241+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji", awardId);
242+
}
243+
244+
/**
245+
* Delete an award emoji from the specified merge request.
246+
*
247+
* <pre><code>GitLab Endpoint: DELETE /projects/:id/merge_requests/:merge_request_iid/award_emoji/:award_id</code></pre>
248+
*
249+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
250+
* @param mergeRequestIid the merge request IID to delete the award emoji from
251+
* @param awardId the ID of the award emoji to delete
252+
* @throws GitLabApiException if any exception occurs
253+
*/
254+
public void deleteMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer awardId) throws GitLabApiException {
255+
delete(Response.Status.NO_CONTENT, null,
256+
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji", awardId);
257+
}
258+
259+
/**
260+
* Delete an award emoji from the specified snippet.
261+
*
262+
* <pre><code>GitLab Endpoint: DELETE /projects/:id/snippets/:snippet_id/award_emoji/:award_id</code></pre>
263+
*
264+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
265+
* @param snippetId the snippet ID to delete the award emoji from
266+
* @param awardId the ID of the award emoji to delete
267+
* @throws GitLabApiException if any exception occurs
268+
*/
269+
public void deleteSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, Integer awardId) throws GitLabApiException {
270+
delete(Response.Status.NO_CONTENT, null,
271+
"projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji", awardId);
272+
}
273+
274+
/**
275+
* Delete an award emoji from the specified note.
276+
*
277+
* <pre><code>GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id</code></pre>
278+
*
279+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
280+
* @param issueIid the issue IID that owns the note
281+
* @param noteId the note ID of the note to delete the award emoji from
282+
* @param awardId the ID of the award emoji to delete
283+
* @throws GitLabApiException if any exception occurs
284+
*/
285+
public void deleteNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException {
286+
delete(Response.Status.NO_CONTENT, null,
287+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
288+
}
289+
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public String getApiNamespace() {
4848
private int defaultPerPage = DEFAULT_PER_PAGE;
4949
private Session session;
5050

51+
private AwardEmojiApi awardEmojiApi;
5152
private CommitsApi commitsApi;
5253
private DeployKeysApi deployKeysApi;
5354
private EpicsApi epicsApi;
@@ -809,6 +810,25 @@ class VersionApi extends AbstractApi {
809810
return (response.readEntity(Version.class));
810811
}
811812

813+
/**
814+
* Gets the AwardEmojiApi instance owned by this GitLabApi instance. The AwardEmojiApi is used
815+
* to perform all award emoji related API calls.
816+
*
817+
* @return the AwardEmojiApi instance owned by this GitLabApi instance
818+
*/
819+
public AwardEmojiApi getAwardEmojiApi() {
820+
821+
if (awardEmojiApi == null) {
822+
synchronized (this) {
823+
if (awardEmojiApi == null) {
824+
awardEmojiApi = new AwardEmojiApi(this);
825+
}
826+
}
827+
}
828+
829+
return (awardEmojiApi);
830+
}
831+
812832
/**
813833
* Gets the CommitsApi instance owned by this GitLabApi instance. The CommitsApi is used
814834
* to perform all commit related API calls.

0 commit comments

Comments
 (0)