@@ -23,7 +23,7 @@ public SystemHooksApi(GitLabApi gitLabApi) {
2323 *
2424 * <pre><code>GitLab Endpoint: GET /hooks</code></pre>
2525 *
26- * @return a list of SystemHookEvent
26+ * @return a list of SystemHook
2727 * @throws GitLabApiException if any exception occurs
2828 */
2929 public List <SystemHook > getSystemHooks () throws GitLabApiException {
@@ -38,7 +38,7 @@ public List<SystemHook> getSystemHooks() throws GitLabApiException {
3838 *
3939 * @param page the page to get
4040 * @param perPage the number of deploy keys per page
41- * @return the list of SystemHookEvent in the specified range
41+ * @return the list of SystemHook in the specified range
4242 * @throws GitLabApiException if any exception occurs
4343 */
4444 public List <SystemHook > getSystemHooks (int page , int perPage ) throws GitLabApiException {
@@ -51,8 +51,8 @@ public List<SystemHook> getSystemHooks(int page, int perPage) throws GitLabApiEx
5151 *
5252 * <pre><code>GitLab Endpoint: GET /hooks</code></pre>
5353 *
54- * @param itemsPerPage the number of SystemHookEvent instances that will be fetched per page
55- * @return a Pager of SystemHookEvent
54+ * @param itemsPerPage the number of SystemHook instances that will be fetched per page
55+ * @return a Pager of SystemHook
5656 * @throws GitLabApiException if any exception occurs
5757 */
5858 public Pager <SystemHook > getSystemHooks (int itemsPerPage ) throws GitLabApiException {
@@ -64,13 +64,27 @@ public Pager<SystemHook> getSystemHooks(int itemsPerPage) throws GitLabApiExcept
6464 *
6565 * <pre><code>GitLab Endpoint: GET /hooks</code></pre>
6666 *
67- * @return a Stream of SystemHookEvent
67+ * @return a Stream of SystemHook
6868 * @throws GitLabApiException if any exception occurs
6969 */
7070 public Stream <SystemHook > getSystemHookStream () throws GitLabApiException {
7171 return (getSystemHooks (getDefaultPerPage ()).stream ());
7272 }
7373
74+ /**
75+ * Get a list of all system hooks. This method requires admin access.
76+ *
77+ * <pre><code>GitLab Endpoint: GET /hooks</code></pre>
78+ *
79+ * @param hookId the ID of the system hook.
80+ * @return the SystemHook
81+ * @throws GitLabApiException if any exception occurs
82+ */
83+ public SystemHook getSystemHook (Long hookId ) throws GitLabApiException {
84+ Response response = get (Response .Status .OK , null , "hooks" , hookId );
85+ return response .readEntity (SystemHook .class );
86+ }
87+
7488 /**
7589 * Add a new system hook. This method requires admin access.
7690 *
@@ -81,7 +95,7 @@ public Stream<SystemHook> getSystemHookStream() throws GitLabApiException {
8195 * @param pushEvents when true, the hook will fire on push events, optional
8296 * @param tagPushEvents when true, the hook will fire on new tags being pushed, optional
8397 * @param enableSslVerification do SSL verification when triggering the hook, optional
84- * @return an SystemHookEvent instance with info on the added system hook
98+ * @return an SystemHook instance with info on the added system hook
8599 * @throws GitLabApiException if any exception occurs
86100 */
87101 public SystemHook addSystemHook (
@@ -104,7 +118,7 @@ public SystemHook addSystemHook(
104118 * @param url the hook URL, required
105119 * @param token secret token to validate received payloads, optional
106120 * @param systemHook the systemHook to create
107- * @return an SystemHookEvent instance with info on the added system hook
121+ * @return an SystemHook instance with info on the added system hook
108122 * @throws GitLabApiException if any exception occurs
109123 */
110124 public SystemHook addSystemHook (String url , String token , SystemHook systemHook ) throws GitLabApiException {
@@ -116,6 +130,8 @@ public SystemHook addSystemHook(String url, String token, SystemHook systemHook)
116130 GitLabApiForm formData = new GitLabApiForm ()
117131 .withParam ("url" , url , true )
118132 .withParam ("token" , token )
133+ .withParam ("name" , systemHook .getName ())
134+ .withParam ("description" , systemHook .getDescription ())
119135 .withParam ("push_events" , systemHook .getPushEvents ())
120136 .withParam ("tag_push_events" , systemHook .getTagPushEvents ())
121137 .withParam ("merge_requests_events" , systemHook .getMergeRequestsEvents ())
@@ -166,7 +182,7 @@ public void deleteSystemHook(Long hookId) throws GitLabApiException {
166182 *
167183 * <pre><code>GitLab Endpoint: GET /hooks/:hook_id</code></pre>
168184 *
169- * @param hook the SystemHookEvent instance to test
185+ * @param hook the SystemHook instance to test
170186 * @throws GitLabApiException if any exception occurs
171187 */
172188 public void testSystemHook (SystemHook hook ) throws GitLabApiException {
@@ -194,4 +210,19 @@ public void testSystemHook(Long hookId) throws GitLabApiException {
194210
195211 get (Response .Status .OK , null , "hooks" , hookId );
196212 }
213+
214+ /**
215+ * Add a new system hook. This method requires admin access.
216+ *
217+ * <pre><code>GitLab Endpoint: PUT /hooks/:hook_id/url_variables/:key</code></pre>
218+ *
219+ * @param hookId the ID of the system hook
220+ * @param key Key of the URL variable
221+ * @param value Value of the URL variable.
222+ * @throws GitLabApiException if any exception occurs
223+ */
224+ public void addSystemHookUrlVariable (Long hookId , String key , String value ) throws GitLabApiException {
225+ GitLabApiForm formData = new GitLabApiForm ().withParam ("value" , value , true );
226+ put (Response .Status .CREATED , formData , "hooks" , hookId , "url_variables" , key );
227+ }
197228}
0 commit comments