|
4 | 4 | import org.gitlab4j.api.services.ExternalWikiService;
|
5 | 5 | import org.gitlab4j.api.services.HipChatService;
|
6 | 6 | import org.gitlab4j.api.services.JiraService;
|
| 7 | +import org.gitlab4j.api.services.MattermostService; |
7 | 8 | import org.gitlab4j.api.services.SlackService;
|
8 | 9 |
|
9 | 10 | import javax.ws.rs.core.Form;
|
@@ -315,7 +316,7 @@ public void deleteJiraService(Object projectIdOrPath) throws GitLabApiException
|
315 | 316 | }
|
316 | 317 |
|
317 | 318 | /**
|
318 |
| - * Get the JIRA service settings for a project. |
| 319 | + * Get the ExternalWiki service settings for a project. |
319 | 320 | *
|
320 | 321 | * <pre><code>GitLab Endpoint: GET /projects/:id/services/external-wiki</code></pre>
|
321 | 322 | *
|
@@ -362,4 +363,96 @@ public void deleteExternalWikiService(Object projectIdOrPath) throws GitLabApiEx
|
362 | 363 | delete(expectedStatus, null, "projects", getProjectIdOrPath(projectIdOrPath), "services", "external-wiki");
|
363 | 364 |
|
364 | 365 | }
|
| 366 | + |
| 367 | + /** |
| 368 | + * Get the Mattermost service settings for a project. |
| 369 | + * |
| 370 | + * <pre><code>GitLab Endpoint: GET /projects/:id/services/mattermost</code></pre> |
| 371 | + * |
| 372 | + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path |
| 373 | + * @return a MattermostService instance holding the Mattermost service settings |
| 374 | + * @throws GitLabApiException if any exception occurs |
| 375 | + */ |
| 376 | + public MattermostService getMattermostService(Object projectIdOrPath) throws GitLabApiException { |
| 377 | + Response response = this.get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "services", "mattermost"); |
| 378 | + return (response.readEntity(MattermostService.class)); |
| 379 | + } |
| 380 | + |
| 381 | + /** |
| 382 | + * Updates the Mattermost service settings for a project. |
| 383 | + * |
| 384 | + * <pre><code>GitLab Endpoint: PUT /projects/:id/services/mattermost</code></pre> |
| 385 | + * |
| 386 | + * The following properties on the MattermostService instance are utilized in the update of the settings: |
| 387 | + * <p> |
| 388 | + * webhook (required) - https://hooks.slack.com/services/... |
| 389 | + * username (optional) - username |
| 390 | + * defaultChannel (optional) - Default channel to use if others are not configured |
| 391 | + * notifyOnlyBrokenPipelines (optional) - Send notifications for broken pipelines |
| 392 | + * notifyOnlyDefault_branch (optional) - Send notifications only for the default branch |
| 393 | + * pushEvents (optional) - Enable notifications for push events |
| 394 | + * issuesEvents (optional) - Enable notifications for issue events |
| 395 | + * confidentialIssuesEvents (optional) - Enable notifications for confidential issue events |
| 396 | + * mergeRequestsEvents (optional) - Enable notifications for merge request events |
| 397 | + * tagPushEvents (optional) - Enable notifications for tag push events |
| 398 | + * noteEvents (optional) - Enable notifications for note events |
| 399 | + * confidentialNoteEvents (optional) - Enable notifications for confidential note events |
| 400 | + * pipelineEvents (optional) - Enable notifications for pipeline events |
| 401 | + * wikiPageEvents (optional) - Enable notifications for wiki page events |
| 402 | + * pushChannel (optional) - The name of the channel to receive push events notifications |
| 403 | + * issueChannel (optional) - The name of the channel to receive issues events notifications |
| 404 | + * confidentialIssueChannel (optional) - The name of the channel to receive confidential issues events notifications |
| 405 | + * mergeRequestChannel (optional) - The name of the channel to receive merge request events notifications |
| 406 | + * noteChannel (optional) - The name of the channel to receive note events notifications |
| 407 | + * confidentialNoteChannel (optional) - The name of the channel to receive confidential note events notifications |
| 408 | + * tagPushChannel (optional) - The name of the channel to receive tag push events notifications |
| 409 | + * pipelineChannel (optional) - The name of the channel to receive pipeline events notifications |
| 410 | + * wikiPageChannel (optional) - The name of the channel to receive wiki page events notifications |
| 411 | + * |
| 412 | + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path |
| 413 | + * @param mattermostNotifications the MattermostService instance holding the settings |
| 414 | + * @return a MattermostService instance holding the newly updated settings |
| 415 | + * @throws GitLabApiException if any exception occurs |
| 416 | + */ |
| 417 | + public MattermostService updateMattermostService(Object projectIdOrPath, MattermostService mattermostNotifications) throws GitLabApiException { |
| 418 | + GitLabApiForm formData = new GitLabApiForm() |
| 419 | + .withParam("webhook", mattermostNotifications.getWebhook(), true) |
| 420 | + .withParam("username", mattermostNotifications.getUsername()) |
| 421 | + .withParam("channel", mattermostNotifications.getDefaultChannel()) |
| 422 | + .withParam("notify_only_broken_pipelines", mattermostNotifications.getNotifyOnlyBrokenPipelines()) |
| 423 | + .withParam("notify_only_default_branch", mattermostNotifications.getNotifyOnlyDefaultBranch()) |
| 424 | + .withParam("push_events", mattermostNotifications.getPushEvents()) |
| 425 | + .withParam("issues_events", mattermostNotifications.getIssuesEvents()) |
| 426 | + .withParam("confidential_issues_events", mattermostNotifications.getConfidentialIssuesEvents()) |
| 427 | + .withParam("merge_requests_events", mattermostNotifications.getMergeRequestsEvents()) |
| 428 | + .withParam("tag_push_events", mattermostNotifications.getTagPushEvents()) |
| 429 | + .withParam("note_events", mattermostNotifications.getNoteEvents()) |
| 430 | + .withParam("confidential_note_events", mattermostNotifications.getConfidentialNoteEvents()) |
| 431 | + .withParam("pipeline_events", mattermostNotifications.getPipelineEvents()) |
| 432 | + .withParam("wiki_page_events", mattermostNotifications.getWikiPageEvents()) |
| 433 | + .withParam("push_channel", mattermostNotifications.getPushChannel()) |
| 434 | + .withParam("issue_channel", mattermostNotifications.getIssueChannel()) |
| 435 | + .withParam("confidential_issue_channel", mattermostNotifications.getConfidentialIssueChannel()) |
| 436 | + .withParam("merge_request_channel", mattermostNotifications.getMergeRequestChannel()) |
| 437 | + .withParam("note_channel", mattermostNotifications.getNoteChannel()) |
| 438 | + .withParam("confidential_note_channel", mattermostNotifications.getConfidentialNoteChannel()) |
| 439 | + .withParam("tag_push_channel", mattermostNotifications.getTagPushChannel()) |
| 440 | + .withParam("pipeline_channel", mattermostNotifications.getPipelineChannel()) |
| 441 | + .withParam("wiki_page_channel", mattermostNotifications.getWikiPageChannel()); |
| 442 | + Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "services", "mattermost"); |
| 443 | + return (response.readEntity(MattermostService.class)); |
| 444 | + } |
| 445 | + |
| 446 | + /** |
| 447 | + * Deletes the Mattermost service for a project. |
| 448 | + * |
| 449 | + * <pre><code>GitLab Endpoint: DELETE /projects/:id/services/external-wiki</code></pre> |
| 450 | + * |
| 451 | + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path |
| 452 | + * @throws GitLabApiException if any exception occurs |
| 453 | + */ |
| 454 | + public void deleteMattermostService(Object projectIdOrPath) throws GitLabApiException { |
| 455 | + Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT); |
| 456 | + delete(expectedStatus, null, "projects", getProjectIdOrPath(projectIdOrPath), "services", "mattermost"); |
| 457 | + } |
365 | 458 | }
|
0 commit comments