1
1
package org .gitlab4j .api ;
2
2
3
- import javax .ws .rs .core .Form ;
4
- import javax .ws .rs .core .Response ;
5
-
6
3
import org .gitlab4j .api .GitLabApi .ApiVersion ;
4
+ import org .gitlab4j .api .services .ExternalUncycloService ;
7
5
import org .gitlab4j .api .services .HipChatService ;
8
6
import org .gitlab4j .api .services .JiraService ;
9
7
import org .gitlab4j .api .services .SlackService ;
10
8
9
+ import javax .ws .rs .core .Form ;
10
+ import javax .ws .rs .core .Response ;
11
+
11
12
/**
12
13
* Access for the services API. Currently only the gitlab-ci, HipChatService, Slack, and JIRA service are supported.
13
14
* See <a href="https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/services.md">GitLab documentation</a> for more info.
@@ -20,11 +21,12 @@ public ServicesApi(GitLabApi gitLabApi) {
20
21
21
22
/**
22
23
* Activates the gitlab-ci service for a project.
23
- *
24
+ * <p>
24
25
* PUT /projects/:id/services/gitlab-ci
26
+ *
25
27
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
26
- * @param token for authentication
27
- * @param projectCIUrl URL of the GitLab-CI project
28
+ * @param token for authentication
29
+ * @param projectCIUrl URL of the GitLab-CI project
28
30
* @throws GitLabApiException if any exception occurs
29
31
* @deprecated No longer supported
30
32
*/
@@ -37,7 +39,7 @@ public void setGitLabCI(Object projectIdOrPath, String token, String projectCIUr
37
39
38
40
/**
39
41
* Deletes the gitlab-ci service for a project.
40
- *
42
+ * <p>
41
43
* DELETE /projects/:id/services/gitlab-ci
42
44
*
43
45
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@@ -51,7 +53,7 @@ public void deleteGitLabCI(Object projectIdOrPath) throws GitLabApiException {
51
53
52
54
/**
53
55
* Get the HipChatService notification configuration for a project.
54
- *
56
+ * <p>
55
57
* Get /projects/:id/services/hipchat
56
58
*
57
59
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@@ -60,16 +62,16 @@ public void deleteGitLabCI(Object projectIdOrPath) throws GitLabApiException {
60
62
*/
61
63
public HipChatService getHipChatService (Object projectIdOrPath ) throws GitLabApiException {
62
64
Response response = get (Response .Status .OK , null , "projects" , getProjectIdOrPath (projectIdOrPath ), "services" , "hipchat" );
63
- return (response .readEntity (HipChatService .class ));
65
+ return (response .readEntity (HipChatService .class ));
64
66
}
65
-
67
+
66
68
/**
67
69
* Updates the HipChatService notification settings for a project.
68
- *
70
+ * <p>
69
71
* PUT /projects/:id/services/hipchat
70
- *
72
+ * <p>
71
73
* The following properties on the HipChatService instance are utilized in the update of the settings:
72
- *
74
+ * <p>
73
75
* pushEvents (optional) - Enable notifications for push events
74
76
* issuesEvents (optional) - Enable notifications for issue events
75
77
* confidentialIssuesEvents (optional) - Enable notifications for confidential issue events
@@ -87,7 +89,7 @@ public HipChatService getHipChatService(Object projectIdOrPath) throws GitLabApi
87
89
* notifyOnlyBrokenPipelines (optional) - Send notifications for broken pipelines
88
90
*
89
91
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
90
- * @param hipChat the HipChatService instance holding the settings
92
+ * @param hipChat the HipChatService instance holding the settings
91
93
* @return a HipChatService instance holding the newly updated settings
92
94
* @throws GitLabApiException if any exception occurs
93
95
*/
@@ -114,13 +116,13 @@ public HipChatService updateHipChatService(Object projectIdOrPath, HipChatServic
114
116
115
117
/**
116
118
* Activates HipChatService notifications.
117
- *
119
+ * <p>
118
120
* PUT /projects/:id/services/hipchat
119
121
*
120
122
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
121
- * @param token for authentication
122
- * @param room HipChatService Room
123
- * @param server HipChatService Server URL
123
+ * @param token for authentication
124
+ * @param room HipChatService Room
125
+ * @param server HipChatService Server URL
124
126
* @throws GitLabApiException if any exception occurs
125
127
* @deprecated replaced with {@link #updateHipChatService(Object, HipChatService) updateHipChat} method
126
128
*/
@@ -134,7 +136,7 @@ public void setHipChat(Object projectIdOrPath, String token, String room, String
134
136
135
137
/**
136
138
* Deletes the HipChatService service for a project.
137
- *
139
+ * <p>
138
140
* DELETE /projects/:id/services/hipchat
139
141
*
140
142
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@@ -147,7 +149,7 @@ public void deleteHipChat(Object projectIdOrPath) throws GitLabApiException {
147
149
148
150
/**
149
151
* Deletes the HipChatService service for a project.
150
- *
152
+ * <p>
151
153
* DELETE /projects/:id/services/hipchat
152
154
*
153
155
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@@ -160,7 +162,7 @@ public void deleteHipChatService(Object projectIdOrPath) throws GitLabApiExcepti
160
162
161
163
/**
162
164
* Get the Slack notification settings for a project.
163
- *
165
+ * <p>
164
166
* Get /projects/:id/services/slack
165
167
*
166
168
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@@ -169,16 +171,16 @@ public void deleteHipChatService(Object projectIdOrPath) throws GitLabApiExcepti
169
171
*/
170
172
public SlackService getSlackService (Object projectIdOrPath ) throws GitLabApiException {
171
173
Response response = get (Response .Status .OK , null , "projects" , getProjectIdOrPath (projectIdOrPath ), "services" , "slack" );
172
- return (response .readEntity (SlackService .class ));
174
+ return (response .readEntity (SlackService .class ));
173
175
}
174
176
175
177
/**
176
178
* Updates the Slack notification settings for a project.
177
- *
179
+ * <p>
178
180
* PUT /projects/:id/services/slack
179
- *
181
+ * <p>
180
182
* The following properties on the SlackService instance are utilized in the update of the settings:
181
- *
183
+ * <p>
182
184
* webhook (required) - https://hooks.slack.com/services/...
183
185
* username (optional) - username
184
186
* defaultChannel (optional) - Default channel to use if others are not configured
@@ -203,7 +205,7 @@ public SlackService getSlackService(Object projectIdOrPath) throws GitLabApiExce
203
205
* pipelineChannel (optional) - The name of the channel to receive pipeline events notifications
204
206
* wikiPageChannel (optional) - The name of the channel to receive wiki page events notifications
205
207
*
206
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
208
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
207
209
* @param slackNotifications the SlackService instance holding the settings
208
210
* @return a SlackService instance holding the newly updated settings
209
211
* @throws GitLabApiException if any exception occurs
@@ -212,7 +214,7 @@ public SlackService updateSlackService(Object projectIdOrPath, SlackService slac
212
214
GitLabApiForm formData = new GitLabApiForm ()
213
215
.withParam ("webhook" , slackNotifications .getWebhook (), true )
214
216
.withParam ("username" , slackNotifications .getUsername ())
215
- .withParam ("channel" , slackNotifications .getDefaultChannel ())
217
+ .withParam ("channel" , slackNotifications .getDefaultChannel ())
216
218
.withParam ("notify_only_broken_pipelines" , slackNotifications .getNotifyOnlyBrokenPipelines ())
217
219
.withParam ("notify_only_default_branch" , slackNotifications .getNotifyOnlyDefaultBranch ())
218
220
.withParam ("push_events" , slackNotifications .getPushEvents ())
@@ -239,7 +241,7 @@ public SlackService updateSlackService(Object projectIdOrPath, SlackService slac
239
241
240
242
/**
241
243
* Deletes the Slack notifications service for a project.
242
- *
244
+ * <p>
243
245
* DELETE /projects/:id/services/slack
244
246
*
245
247
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@@ -249,10 +251,10 @@ public void deleteSlackService(Object projectIdOrPath) throws GitLabApiException
249
251
Response .Status expectedStatus = (isApiVersion (ApiVersion .V3 ) ? Response .Status .OK : Response .Status .NO_CONTENT );
250
252
delete (expectedStatus , null , "projects" , getProjectIdOrPath (projectIdOrPath ), "services" , "slack" );
251
253
}
252
-
254
+
253
255
/**
254
256
* Get the JIRA service settings for a project.
255
- *
257
+ * <p>
256
258
* Get /projects/:id/services/jira
257
259
*
258
260
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@@ -261,16 +263,16 @@ public void deleteSlackService(Object projectIdOrPath) throws GitLabApiException
261
263
*/
262
264
public JiraService getJiraService (Object projectIdOrPath ) throws GitLabApiException {
263
265
Response response = get (Response .Status .OK , null , "projects" , getProjectIdOrPath (projectIdOrPath ), "services" , "jira" );
264
- return (response .readEntity (JiraService .class ));
266
+ return (response .readEntity (JiraService .class ));
265
267
}
266
268
267
269
/**
268
270
* Updates the JIRA service settings for a project.
269
- *
271
+ * <p>
270
272
* PUT /projects/:id/services/jira
271
- *
273
+ * <p>
272
274
* The following properties on the JiraService instance are utilized in the update of the settings:
273
- *
275
+ * <p>
274
276
* mergeRequestsEvents (optional) - Enable notifications for merge request events
275
277
* commitEvents (optional) - Enable notifications for commit events
276
278
* url (required) - The URL to the JIRA project which is being linked to this GitLab project, e.g., https://jira.example.com.
@@ -281,7 +283,7 @@ public JiraService getJiraService(Object projectIdOrPath) throws GitLabApiExcept
281
283
* jiraIssueTransitionId (optional) - The ID of a transition that moves issues to a closed state.
282
284
*
283
285
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
284
- * @param jira the JiraService instance holding the settings
286
+ * @param jira the JiraService instance holding the settings
285
287
* @return a JiraService instance holding the newly updated settings
286
288
* @throws GitLabApiException if any exception occurs
287
289
*/
@@ -293,15 +295,18 @@ public JiraService updateJiraService(Object projectIdOrPath, JiraService jira) t
293
295
.withParam ("api_url" , jira .getApiUrl ())
294
296
.withParam ("project_key" , jira .getProjectKey ())
295
297
.withParam ("username" , jira .getUsername (), true )
296
- .withParam ("password" , jira .getPassword (), true )
298
+ .withParam ("password" , jira .getPassword (), true )
297
299
.withParam ("jira_issue_transition_id" , jira .getJiraIssueTransitionId ());
298
300
Response response = put (Response .Status .OK , formData .asMap (), "projects" , getProjectIdOrPath (projectIdOrPath ), "services" , "jira" );
299
301
return (response .readEntity (JiraService .class ));
300
302
}
301
303
304
+
305
+
306
+
302
307
/**
303
308
* Deletes the JIRA service for a project.
304
- *
309
+ * <p>
305
310
* DELETE /projects/:id/services/jira
306
311
*
307
312
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
@@ -311,4 +316,55 @@ public void deleteJiraService(Object projectIdOrPath) throws GitLabApiException
311
316
Response .Status expectedStatus = (isApiVersion (ApiVersion .V3 ) ? Response .Status .OK : Response .Status .NO_CONTENT );
312
317
delete (expectedStatus , null , "projects" , getProjectIdOrPath (projectIdOrPath ), "services" , "jira" );
313
318
}
319
+
320
+
321
+ /**
322
+ * Get the JIRA service settings for a project.
323
+ * <p>
324
+ * Get /projects/:id/services/external-wiki
325
+ *
326
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
327
+ * @return a ExternalUncycloService instance holding the External Uncyclo service settings
328
+ * @throws GitLabApiException if any exception occurs
329
+ */
330
+ public ExternalUncycloService getExternalUncycloService (Object projectIdOrPath ) throws GitLabApiException {
331
+ Response response = this .get (Response .Status .OK , null , "projects" , getProjectIdOrPath (projectIdOrPath ), "services" , "external-wiki" );
332
+ return (response .readEntity (ExternalUncycloService .class ));
333
+ }
334
+
335
+
336
+ /**
337
+ * Updates the ExternalUncycloService service settings for a project.
338
+ * <p>
339
+ * PUT /projects/:id/services/external-wiki
340
+ * <p>
341
+ * The following properties on the JiraService instance are utilized in the update of the settings:
342
+ * <p>
343
+ * external_wiki_url (required) - The URL to the External Uncyclo project which is being linked to this GitLab project, e.g., http://www.wikidot.com/
344
+ *
345
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
346
+ * @param externalUncyclo the ExternalUncycloService instance holding the settings
347
+ * @return a ExternalUncycloService instance holding the newly updated settings
348
+ * @throws GitLabApiException if any exception occurs
349
+ */
350
+ public ExternalUncycloService updateExternalUncycloService (Object projectIdOrPath , ExternalUncycloService externalUncyclo ) throws GitLabApiException {
351
+ GitLabApiForm formData = new GitLabApiForm ()
352
+ .withParam ("external_wiki_url" , externalUncyclo .getExternalUncycloUrl ());
353
+ Response response = put (Response .Status .OK , formData .asMap (), "projects" , getProjectIdOrPath (projectIdOrPath ), "services" , "external-wiki" );
354
+ return (response .readEntity (ExternalUncycloService .class ));
355
+ }
356
+
357
+ /**
358
+ * Deletes the ExternalUncyclo service for a project.
359
+ * <p>
360
+ * DELETE /projects/:id/services/external-wiki
361
+ *
362
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
363
+ * @throws GitLabApiException if any exception occurs
364
+ */
365
+ public void deleteExternalUncycloService (Object projectIdOrPath ) throws GitLabApiException {
366
+ Response .Status expectedStatus = (isApiVersion (ApiVersion .V3 ) ? Response .Status .OK : Response .Status .NO_CONTENT );
367
+ delete (expectedStatus , null , "projects" , getProjectIdOrPath (projectIdOrPath ), "services" , "external-wiki" );
368
+
369
+ }
314
370
}
0 commit comments