@@ -80,12 +80,32 @@ public Stream<SystemHook> getSystemHookStream() throws GitLabApiException {
8080 * @param token secret token to validate received payloads, optional
8181 * @param pushEvents when true, the hook will fire on push events, optional
8282 * @param tagPushEvents when true, the hook will fire on new tags being pushed, optional
83- * @param enablSsslVerification do SSL verification when triggering the hook, optional
83+ * @param enableSslVerification do SSL verification when triggering the hook, optional
8484 * @return an SystemHookEvent instance with info on the added system hook
8585 * @throws GitLabApiException if any exception occurs
8686 */
8787 public SystemHook addSystemHook (String url , String token , Boolean pushEvents ,
88- Boolean tagPushEvents , Boolean enablSsslVerification ) throws GitLabApiException {
88+ Boolean tagPushEvents , Boolean enableSslVerification ) throws GitLabApiException {
89+
90+ SystemHook systemHook = new SystemHook ().withPushEvents (pushEvents )
91+ .withTagPushEvents (tagPushEvents )
92+ .withEnableSslVerification (enableSslVerification );
93+
94+ return addSystemHook (url , token , systemHook );
95+ }
96+
97+ /**
98+ * Add a new system hook. This method requires admin access.
99+ *
100+ * <pre><code>GitLab Endpoint: POST /hooks</code></pre>
101+ *
102+ * @param url the hook URL, required
103+ * @param token secret token to validate received payloads, optional
104+ * @param systemHook the systemHook to create
105+ * @return an SystemHookEvent instance with info on the added system hook
106+ * @throws GitLabApiException if any exception occurs
107+ */
108+ public SystemHook addSystemHook (String url , String token , SystemHook systemHook ) throws GitLabApiException {
89109
90110 if (url == null ) {
91111 throw new RuntimeException ("url cannot be null" );
@@ -94,9 +114,11 @@ public SystemHook addSystemHook(String url, String token, Boolean pushEvents,
94114 GitLabApiForm formData = new GitLabApiForm ()
95115 .withParam ("url" , url , true )
96116 .withParam ("token" , token )
97- .withParam ("push_events" , pushEvents )
98- .withParam ("tag_push_events" , tagPushEvents )
99- .withParam ("enable_ssl_verification" , enablSsslVerification );
117+ .withParam ("push_events" , systemHook .getPushEvents ())
118+ .withParam ("tag_push_events" , systemHook .getTagPushEvents ())
119+ .withParam ("merge_requests_events" , systemHook .getMergeRequestsEvents ())
120+ .withParam ("repository_update_events" , systemHook .getRepositoryUpdateEvents ())
121+ .withParam ("enable_ssl_verification" , systemHook .getEnableSslVerification ());
100122 Response response = post (Response .Status .CREATED , formData , "hooks" );
101123 return (response .readEntity (SystemHook .class ));
102124 }
0 commit comments