From 1ff23e5d9e5b38e8d30f6a145616f4477a2165bd Mon Sep 17 00:00:00 2001 From: didacrarbones Date: Tue, 5 Oct 2021 10:39:31 +0200 Subject: [PATCH 1/2] Fix #767 : Adding merge request note award functions and renaming issue functions --- .../java/org/gitlab4j/api/AwardEmojiApi.java | 112 ++++++++++++++---- 1 file changed, 91 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/AwardEmojiApi.java b/src/main/java/org/gitlab4j/api/AwardEmojiApi.java index a38b1d7c2..e44ac1bd5 100644 --- a/src/main/java/org/gitlab4j/api/AwardEmojiApi.java +++ b/src/main/java/org/gitlab4j/api/AwardEmojiApi.java @@ -9,7 +9,7 @@ /** * This class implements the client side API for the GitLab Award Emoji API calls. - * + * * @see GitLab Award Emoji API Documentaion * @since v4.8.31 */ @@ -68,7 +68,7 @@ public List 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. * *
GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji
* @@ -78,9 +78,26 @@ public List getSnippetAwardEmojis(Object projectIdOrPath, Integer sn * @return a list of AwardEmoji for the specified note * @throws GitLabApiException if any exception occurs */ - public List getNoteAwardEmojis(Object projectIdOrPath, Integer issueIid, Integer noteId) throws GitLabApiException { + public List 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"); + "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji"); + return response.readEntity(new GenericType>() {}); + } + + /** + * Get a list of award emoji for the specified merge request note. + * + *
GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji
+ * + * @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 getMergeRequestNoteAwardEmojis(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId) throws GitLabApiException { + Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()), + "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji"); return response.readEntity(new GenericType>() {}); } @@ -92,7 +109,7 @@ public List 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 { @@ -109,7 +126,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 { @@ -126,7 +143,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 { @@ -136,7 +153,7 @@ 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. * *
GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
* @@ -144,12 +161,30 @@ public AwardEmoji getSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId * @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 getNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException { + 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); + "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId); + return (response.readEntity(AwardEmoji.class)); + } + + /** + * Get the specified award emoji for the specified merge request note. + * + *
GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji/:award_id
+ * + * @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), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId); return (response.readEntity(AwardEmoji.class)); } @@ -161,7 +196,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 { @@ -179,7 +214,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 { @@ -197,7 +232,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 { @@ -208,7 +243,7 @@ public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId } /** - * Add an award emoji for the specified note. + * Add an award emoji for the specified issue note. * *
GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji
* @@ -216,13 +251,32 @@ public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId * @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 addNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, String name) throws GitLabApiException { + 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"); + "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji"); + return (response.readEntity(AwardEmoji.class)); + } + + /** + * Add an award emoji for the specified merge request note. + * + *
GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/notes/:noteId/award_emoji
+ * + * @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 addNoteAwardEmoji(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), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji"); return (response.readEntity(AwardEmoji.class)); } @@ -269,10 +323,10 @@ 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 note. + * Delete an award emoji from the specified issue note. * *
GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
* @@ -284,6 +338,22 @@ public void deleteSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, I */ public void deleteNoteAwardEmoji(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); + "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId); + } + + /** + * Delete an award emoji from the specified merge request note. + * + *
GitLab Endpoint: DELETE /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji/:award_id
+ * + * @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 deleteNoteAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, Integer awardId) throws GitLabApiException { + delete(Response.Status.NO_CONTENT, null, + "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId); } } From 7c9c8c6f4473fa9cb6991285b27e277bb095f40c Mon Sep 17 00:00:00 2001 From: Gautier de Saint Martin Lacaze Date: Tue, 8 Mar 2022 17:26:58 +0100 Subject: [PATCH 2/2] Fix backward compatibility on AwardEmojiApi --- .../java/org/gitlab4j/api/AwardEmojiApi.java | 74 ++++++++++++++++++- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/AwardEmojiApi.java b/src/main/java/org/gitlab4j/api/AwardEmojiApi.java index e44ac1bd5..5e1ce181e 100644 --- a/src/main/java/org/gitlab4j/api/AwardEmojiApi.java +++ b/src/main/java/org/gitlab4j/api/AwardEmojiApi.java @@ -84,6 +84,21 @@ public List getIssueNoteAwardEmojis(Object projectIdOrPath, Integer return response.readEntity(new GenericType>() {}); } + /** + * Get a list of award emoji for the specified issue note. + * + *
GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji
+ * + * @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 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. * @@ -170,6 +185,24 @@ public AwardEmoji getIssueNoteAwardEmoji(Object projectIdOrPath, Integer issueIi return (response.readEntity(AwardEmoji.class)); } + /** + * Get the specified award emoji for the specified issue note. + * + *
GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
+ * + * @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. * @@ -261,6 +294,24 @@ public AwardEmoji addIssueNoteAwardEmoji(Object projectIdOrPath, Integer issueIi return (response.readEntity(AwardEmoji.class)); } + /** + * Add an award emoji for the specified issue note. + * + *
GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji
+ * + * @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. * @@ -273,7 +324,7 @@ public AwardEmoji addIssueNoteAwardEmoji(Object projectIdOrPath, Integer issueIi * @return an AwardEmoji instance for the added award emoji * @throws GitLabApiException if any exception occurs */ - public AwardEmoji addNoteAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, String name) throws GitLabApiException { + 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), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji"); @@ -336,11 +387,28 @@ public void deleteSnippetAwardEmoji(Object projectIdOrPath, Integer snippetId, I * @param awardId the ID of the award emoji to delete * @throws GitLabApiException if any exception occurs */ - public void deleteNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integer noteId, Integer awardId) throws GitLabApiException { + 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 issue note. + * + *
GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
+ * + * @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 + * @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. * @@ -352,7 +420,7 @@ public void deleteNoteAwardEmoji(Object projectIdOrPath, Integer issueIid, Integ * @param awardId the ID of the award emoji to delete * @throws GitLabApiException if any exception occurs */ - public void deleteNoteAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, Integer awardId) throws GitLabApiException { + public void deleteMergeRequestNoteAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, Integer awardId) throws GitLabApiException { delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId); }