Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 156 additions & 18 deletions src/main/java/org/gitlab4j/api/AwardEmojiApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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

/**
* Get a list of award emoji for the specified note.
* Get a list of award emoji for the specified issue note.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the issue IID of the issue that owns the note
* @param noteId the note ID to get the award emojis for
* @return a list of AwardEmoji for the specified note
* @throws GitLabApiException if any exception occurs
*/
public List<AwardEmoji> getIssueNoteAwardEmojis(Object projectIdOrPath, Integer issueIid, Integer noteId) throws GitLabApiException {
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
return response.readEntity(new GenericType<List<AwardEmoji>>() {});
}

/**
* Get a list of award emoji for the specified issue note.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji</code></pre>
*
Expand All @@ -79,8 +96,23 @@ public List<AwardEmoji> getSnippetAwardEmojis(Object projectIdOrPath, Integer sn
* @throws GitLabApiException if any exception occurs
*/
public List<AwardEmoji> getNoteAwardEmojis(Object projectIdOrPath, Integer issueIid, Integer noteId) throws GitLabApiException {
return getIssueNoteAwardEmojis(projectIdOrPath, issueIid, noteId);
}

/**
* Get a list of award emoji for the specified merge request note.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param mergeRequestIid the merge request IID of the merge request that owns the note
* @param noteId the note ID to get the award emojis for
* @return a list of AwardEmoji for the specified note
* @throws GitLabApiException if any exception occurs
*/
public List<AwardEmoji> getMergeRequestNoteAwardEmojis(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId) throws GitLabApiException {
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji");
return response.readEntity(new GenericType<List<AwardEmoji>>() {});
}

Expand All @@ -92,7 +124,7 @@ public List<AwardEmoji> getNoteAwardEmojis(Object projectIdOrPath, Integer issue
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the issue IID to get the award emoji for
* @param awardId the ID of the award emoji to get
* @return an AwardEmoji instance for the specified award emoji
* @return an AwardEmoji instance for the specified award emoji
* @throws GitLabApiException if any exception occurs
*/
public AwardEmoji getIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer awardId) throws GitLabApiException {
Expand All @@ -109,7 +141,7 @@ public AwardEmoji getIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, I
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param mergeRequestIid the merge request IID to get the award emoji for
* @param awardId the ID of the award emoji to get
* @return an AwardEmoji instance for the specified award emoji
* @return an AwardEmoji instance for the specified award emoji
* @throws GitLabApiException if any exception occurs
*/
public AwardEmoji getMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer awardId) throws GitLabApiException {
Expand All @@ -126,7 +158,7 @@ public AwardEmoji getMergeRequestAwardEmoji(Object projectIdOrPath, Integer merg
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param snippetId the snippet ID to get the award emoji for
* @param awardId the ID of the award emoji to get
* @return an AwardEmoji instance for the specified award emoji
* @return an AwardEmoji instance for the specified award emoji
* @throws GitLabApiException if any exception occurs
*/
public AwardEmoji getSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, Integer awardId) throws GitLabApiException {
Expand All @@ -136,20 +168,56 @@ public AwardEmoji getSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId
}

/**
* Get the specified award emoji for the specified note.
* Get the specified award emoji for the specified issue note.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the issue IID of the issue that owns the note
* @param noteId the note ID to get the award emoji from
* @param awardId the ID of the award emoji to get
* @return an AwardEmoji instance for the specified award emoji
* @return an AwardEmoji instance for the specified award emoji
* @throws GitLabApiException if any exception occurs
*/
public AwardEmoji getIssueNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException {
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
return (response.readEntity(AwardEmoji.class));
}

/**
* Get the specified award emoji for the specified issue note.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the issue IID of the issue that owns the note
* @param noteId the note ID to get the award emoji from
* @param awardId the ID of the award emoji to get
* @return an AwardEmoji instance for the specified award emoji
* @throws GitLabApiException if any exception occurs
* @deprecated use {@link #getIssueNoteAwardEmoji(Object, Integer, Integer, Integer)} instead
*/
@Deprecated
public AwardEmoji getNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException {
return getIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId);
}

/**
* Get the specified award emoji for the specified merge request note.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji/:award_id</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param mergeRequestIid the merge request IID of the merge request that owns the note
* @param noteId the note ID to get the award emoji from
* @param awardId the ID of the award emoji to get
* @return an AwardEmoji instance for the specified award emoji
* @throws GitLabApiException if any exception occurs
*/
public AwardEmoji getMergeRequestNoteAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, Integer awardId) throws GitLabApiException {
Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId);
return (response.readEntity(AwardEmoji.class));
}

Expand All @@ -161,7 +229,7 @@ public AwardEmoji getNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, In
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the issue IID to add the award emoji to
* @param name the name of the award emoji to add
* @return an AwardEmoji instance for the added award emoji
* @return an AwardEmoji instance for the added award emoji
* @throws GitLabApiException if any exception occurs
*/
public AwardEmoji addIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, String name) throws GitLabApiException {
Expand All @@ -179,7 +247,7 @@ public AwardEmoji addIssueAwardEmoji(Object projectIdOrPath, Integer issueIid, S
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param mergeRequestIid the merge request IID to add the award emoji to
* @param name the name of the award emoji to add
* @return an AwardEmoji instance for the added award emoji
* @return an AwardEmoji instance for the added award emoji
* @throws GitLabApiException if any exception occurs
*/
public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, String name) throws GitLabApiException {
Expand All @@ -197,7 +265,7 @@ public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Integer merg
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param snippetId the snippet ID to add the award emoji to
* @param name the name of the award emoji to add
* @return an AwardEmoji instance for the added award emoji
* @return an AwardEmoji instance for the added award emoji
* @throws GitLabApiException if any exception occurs
*/
public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, String name) throws GitLabApiException {
Expand All @@ -208,21 +276,58 @@ public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId
}

/**
* Add an award emoji for the specified note.
* Add an award emoji for the specified issue note.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the issue IID of the issue that owns the note
* @param noteId the note ID to add the award emoji to
* @param name the name of the award emoji to add
* @return an AwardEmoji instance for the added award emoji
* @return an AwardEmoji instance for the added award emoji
* @throws GitLabApiException if any exception occurs
*/
public AwardEmoji addIssueNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, String name) throws GitLabApiException {
GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
Response response = post(Response.Status.CREATED, form.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
return (response.readEntity(AwardEmoji.class));
}

/**
* Add an award emoji for the specified issue note.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the issue IID of the issue that owns the note
* @param noteId the note ID to add the award emoji to
* @param name the name of the award emoji to add
* @return an AwardEmoji instance for the added award emoji
* @throws GitLabApiException if any exception occurs
* @deprecated use {@link #addIssueNoteAwardEmoji(Object, Integer, Integer, String)}
*/
@Deprecated
public AwardEmoji addNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, String name) throws GitLabApiException {
return addIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, name);
}

/**
* Add an award emoji for the specified merge request note.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/notes/:noteId/award_emoji</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param mergeRequestIid the merge request IID of the merge request that owns the note
* @param noteId the note ID to add the award emoji to
* @param name the name of the award emoji to add
* @return an AwardEmoji instance for the added award emoji
* @throws GitLabApiException if any exception occurs
*/
public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, String name) throws GitLabApiException {
GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
Response response = post(Response.Status.CREATED, form.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji");
return (response.readEntity(AwardEmoji.class));
}

Expand Down Expand Up @@ -269,10 +374,26 @@ public void deleteMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRe
public void deleteSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, Integer awardId) throws GitLabApiException {
delete(Response.Status.NO_CONTENT, null,
"projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji", awardId);
}
}

/**
* Delete an award emoji from the specified issue note.
*
* <pre><code>GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param issueIid the issue IID that owns the note
* @param noteId the note ID of the note to delete the award emoji from
* @param awardId the ID of the award emoji to delete
* @throws GitLabApiException if any exception occurs
*/
public void deleteIssueNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException {
delete(Response.Status.NO_CONTENT, null,
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
}

/**
* Delete an award emoji from the specified note.
* Delete an award emoji from the specified issue note.
*
* <pre><code>GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id</code></pre>
*
Expand All @@ -281,9 +402,26 @@ public void deleteSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, I
* @param noteId the note ID of the note to delete the award emoji from
* @param awardId the ID of the award emoji to delete
* @throws GitLabApiException if any exception occurs
* @deprecated use {@link #deleteIssueNoteAwardEmoji(Object, Integer, Integer, Integer)} instead
*/
@Deprecated
public void deleteNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException {
deleteIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId);
}

/**
* Delete an award emoji from the specified merge request note.
*
* <pre><code>GitLab Endpoint: DELETE /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji/:award_id</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param mergeRequestIid the merge request IID of the merge request that owns the note
* @param noteId the note ID of the note to delete the award emoji from
* @param awardId the ID of the award emoji to delete
* @throws GitLabApiException if any exception occurs
*/
public void deleteMergeRequestNoteAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, Integer awardId) throws GitLabApiException {
delete(Response.Status.NO_CONTENT, null,
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId);
}
}