From f479805ef5057e3d89b5803459d636aa1a6bc5fa Mon Sep 17 00:00:00 2001 From: 06luki06 <95306265+06luki06@users.noreply.github.com> Date: Tue, 7 May 2024 10:18:32 +0200 Subject: [PATCH 1/3] Update ProjectApi.java Add the possibility of adding noteEvents via the addHook(). --- src/main/java/org/gitlab4j/api/ProjectApi.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/ProjectApi.java b/src/main/java/org/gitlab4j/api/ProjectApi.java index 9727f399..9f48e63d 100644 --- a/src/main/java/org/gitlab4j/api/ProjectApi.java +++ b/src/main/java/org/gitlab4j/api/ProjectApi.java @@ -1074,7 +1074,7 @@ public Project createProject(Project project, String importUrl) throws GitLabApi * Only working with GitLab 16.9 and above. * *
GitLab Endpoint: GET /projects/:id/avatar
- *
+ *
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @return an InputStream to read the raw file from
* @throws GitLabApiException if any exception occurs
@@ -2250,13 +2250,14 @@ public ProjectHook addHook(Object projectIdOrPath, String url, ProjectHook enabl
* @throws GitLabApiException if any exception occurs
*/
public ProjectHook addHook(Object projectIdOrPath, String url, boolean doPushEvents,
- boolean doIssuesEvents, boolean doMergeRequestsEvents) throws GitLabApiException {
+ boolean doIssuesEvents, boolean doMergeRequestsEvents, boolean doNoteEvents) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("url", url)
.withParam("push_events", doPushEvents)
.withParam("issues_events", doIssuesEvents)
- .withParam("merge_requests_events", doMergeRequestsEvents);
+ .withParam("merge_requests_events", doMergeRequestsEvents)
+ .withParam("note_events", doNoteEvents);
Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "hooks");
return (response.readEntity(ProjectHook.class));
From 672eb2f2b9b763bec078bc35d402b7db260f478d Mon Sep 17 00:00:00 2001
From: Jeremie Bresson GitLab Endpoint: POST /projects/:id/hooks
*
@@ -2250,17 +2251,33 @@ public ProjectHook addHook(Object projectIdOrPath, String url, ProjectHook enabl
* @throws GitLabApiException if any exception occurs
*/
public ProjectHook addHook(Object projectIdOrPath, String url, boolean doPushEvents,
- boolean doIssuesEvents, boolean doMergeRequestsEvents, boolean doNoteEvents) throws GitLabApiException {
-
- GitLabApiForm formData = new GitLabApiForm()
- .withParam("url", url)
- .withParam("push_events", doPushEvents)
- .withParam("issues_events", doIssuesEvents)
- .withParam("merge_requests_events", doMergeRequestsEvents)
- .withParam("note_events", doNoteEvents);
-
- Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "hooks");
- return (response.readEntity(ProjectHook.class));
+ boolean doIssuesEvents, boolean doMergeRequestsEvents) throws GitLabApiException {
+ return addHook(projectIdOrPath, url, doPushEvents, doIssuesEvents, doMergeRequestsEvents, null);
+ }
+
+ /**
+ * Adds a hook to project.
+ * Convenience method for {@link org.gitlab4j.api.ProjectApi.addHook(Object, String, ProjectHook, Boolean, String)}
+ *
+ * GitLab Endpoint: POST /projects/:id/hooks
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance, required
+ * @param url the callback URL for the hook
+ * @param doPushEvents flag specifying whether to do push events
+ * @param doIssuesEvents flag specifying whether to do issues events
+ * @param doMergeRequestsEvents flag specifying whether to do merge requests events
+ * @param doNoteEvents flag specifying whether to do note events
+ * @return the added ProjectHook instance
+ * @throws GitLabApiException if any exception occurs
+ */
+ public ProjectHook addHook(Object projectIdOrPath, String url, Boolean doPushEvents,
+ Boolean doIssuesEvents, Boolean doMergeRequestsEvents, Boolean doNoteEvents) throws GitLabApiException {
+ ProjectHook enabledHooks = new ProjectHook()
+ .withPushEvents(doPushEvents)
+ .withIssuesEvents(doIssuesEvents)
+ .withMergeRequestsEvents(doMergeRequestsEvents)
+ .withNoteEvents(doNoteEvents);
+ return addHook(projectIdOrPath, url, enabledHooks , null, null);
}
/**
From 4264a026165348b32f335b6b7277444086b7f30f Mon Sep 17 00:00:00 2001
From: Jeremie Bresson GitLab Endpoint: POST /projects/:id/hooks
*
@@ -2257,7 +2257,7 @@ public ProjectHook addHook(Object projectIdOrPath, String url, boolean doPushEve
/**
* Adds a hook to project.
- * Convenience method for {@link org.gitlab4j.api.ProjectApi.addHook(Object, String, ProjectHook, Boolean, String)}
+ * Convenience method for {@link #addHook(Object, String, ProjectHook, Boolean, String)}
*
* GitLab Endpoint: POST /projects/:id/hooks
*