@@ -80,12 +80,32 @@ public Stream<SystemHook> getSystemHookStream() throws GitLabApiException {
80
80
* @param token secret token to validate received payloads, optional
81
81
* @param pushEvents when true, the hook will fire on push events, optional
82
82
* @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
84
84
* @return an SystemHookEvent instance with info on the added system hook
85
85
* @throws GitLabApiException if any exception occurs
86
86
*/
87
87
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 {
89
109
90
110
if (url == null ) {
91
111
throw new RuntimeException ("url cannot be null" );
@@ -94,9 +114,11 @@ public SystemHook addSystemHook(String url, String token, Boolean pushEvents,
94
114
GitLabApiForm formData = new GitLabApiForm ()
95
115
.withParam ("url" , url , true )
96
116
.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 ());
100
122
Response response = post (Response .Status .CREATED , formData , "hooks" );
101
123
return (response .readEntity (SystemHook .class ));
102
124
}
0 commit comments