diff --git a/src/main/java/org/gitlab4j/api/services/SlackService.java b/src/main/java/org/gitlab4j/api/services/SlackService.java new file mode 100644 index 0000000000000000000000000000000000000000..3ce7df66f2ff1a1bc5c3bf425da5444aedbefc3c --- /dev/null +++ b/src/main/java/org/gitlab4j/api/services/SlackService.java @@ -0,0 +1,264 @@ +package org.gitlab4j.api.services; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class SlackService extends NotificationService { + + public static final String WEBHOOK_PROP = "webhook"; + public static final String USERNAME_PROP = "username"; + public static final String NOTIFY_ONLY_BROKEN_PIPELINES_PROP = "notify_only_broken_pipelines"; + public static final String NOTIFY_ONLY_DEFAULT_BRANCH_PROP = "notify_only_default_branch"; + public static final String PUSH_CHANNEL_PROP = "push_channel"; + public static final String ISSUE_CHANNEL_PROP = "issue_channel"; + public static final String CONFIDENTIAL_ISSUE_CHANNEL_PROP = "confidential_issue_channel"; + public static final String MERGE_REQUEST_CHANNEL_PROP = "merge_request_channel"; + public static final String NOTE_CHANNEL_PROP = "note_channel"; + public static final String CONFIDENTIAL_NOTE_CHANNEL_PROP = "confidential_note_channel"; + public static final String TAG_PUSH_CHANNEL_PROP = "tag_push_channel"; + public static final String PIPELINE_CHANNEL_PROP = "pipeline_channel"; + public static final String WIKI_PAGE_CHANNEL_PROP = "wiki_page_channel"; + + private String defaultChannel; + + public SlackService withPushEvents(Boolean pushEvents) { + return withPushEvents(pushEvents, this); + } + + public SlackService withIssuesEvents(Boolean issuesEvents) { + return withIssuesEvents(issuesEvents, this); + } + + public SlackService withConfidentialIssuesEvents(Boolean confidentialIssuesEvents) { + return withConfidentialIssuesEvents(confidentialIssuesEvents, this); + } + + public SlackService withMergeRequestsEvents(Boolean mergeRequestsEvents) { + return withMergeRequestsEvents(mergeRequestsEvents, this); + } + + public SlackService withTagPushEvents(Boolean tagPushEvents) { + return withTagPushEvents(tagPushEvents, this); + } + + public SlackService withNoteEvents(Boolean noteEvents) { + return withNoteEvents(noteEvents, this); + } + + public SlackService withConfidentialNoteEvents(Boolean confidentialNoteEvents) { + return withConfidentialNoteEvents(confidentialNoteEvents, this); + } + + public SlackService withPipelineEvents(Boolean pipelineEvents) { + return withPipelineEvents(pipelineEvents, this); + } + + public SlackService withWikiPageEvents(Boolean wikiPageEvents) { + return withWikiPageEvents(wikiPageEvents, this); + } + + public SlackService withJobEvents(Boolean jobEvents) { + return withPipelineEvents(jobEvents, this); + } + + @JsonIgnore + public String getWebhook() { + return ((String) getProperty(WEBHOOK_PROP)); + } + + public void setWebhook(String webhook) { + setProperty(WEBHOOK_PROP, webhook); + } + + public SlackService withWebhook(String webhook) { + setWebhook(webhook); + return (this); + } + + @JsonIgnore + public String getUsername() { + return ((String) getProperty(USERNAME_PROP)); + } + + public void setUsername(String username) { + setProperty(USERNAME_PROP, username); + } + + public SlackService withUsername(String username) { + setUsername(username); + return (this); + } + + @JsonIgnore + public String getDefaultChannel() { + return (defaultChannel); + } + + public void setDefaultChannel(String defaultChannel) { + this.defaultChannel = defaultChannel; + } + + public SlackService withDefaultChannelk(String defaultChannel) { + this.defaultChannel = defaultChannel; + return (this); + } + + @JsonIgnore + public Boolean getNotifyOnlyBrokenPipelines() { + return ((Boolean) getProperty(NOTIFY_ONLY_BROKEN_PIPELINES_PROP, Boolean.FALSE)); + } + + public void setNotifyOnlyBrokenPipelines(Boolean notifyOnlyBrokenPipelines) { + setProperty(NOTIFY_ONLY_BROKEN_PIPELINES_PROP, notifyOnlyBrokenPipelines); + } + + public SlackService withNotifyOnlyBrokenPipelines(Boolean notifyOnlyBrokenPipelines) { + setNotifyOnlyBrokenPipelines(notifyOnlyBrokenPipelines); + return (this); + } + + @JsonIgnore + public Boolean getNotifyOnlyDefaultBranch() { + return ((Boolean) getProperty(NOTIFY_ONLY_DEFAULT_BRANCH_PROP, Boolean.FALSE)); + } + + public void setNotifyOnlyDefaultBranch(Boolean notifyOnlyDefaultBranch) { + setProperty(NOTIFY_ONLY_DEFAULT_BRANCH_PROP, notifyOnlyDefaultBranch); + } + + public SlackService withNotifyOnlyDefaultBranch(Boolean notifyOnlyDefaultBranch) { + setNotifyOnlyDefaultBranch(notifyOnlyDefaultBranch); + return (this); + } + + @JsonIgnore + public String getPushChannel() { + return ((String) getProperty(PUSH_CHANNEL_PROP)); + } + + public void setPushChannel(String pushChannel) { + setProperty(PUSH_CHANNEL_PROP, pushChannel); + } + + public SlackService withPushChannel(String pushChannel) { + setPushChannel(pushChannel); + return (this); + } + + @JsonIgnore + public String getIssueChannel() { + return ((String) getProperty(ISSUE_CHANNEL_PROP)); + } + + public void setIssueChannel(String issueChannel) { + setProperty(ISSUE_CHANNEL_PROP, issueChannel); + } + + public SlackService withIssueChannel(String issueChannel) { + setIssueChannel(issueChannel); + return (this); + } + + @JsonIgnore + public String getConfidentialIssueChannel() { + return ((String) getProperty(CONFIDENTIAL_ISSUE_CHANNEL_PROP)); + } + + public void setConfidentialIssueChannel(String confidentialIssueChannel) { + setProperty(CONFIDENTIAL_ISSUE_CHANNEL_PROP, confidentialIssueChannel); + } + + public SlackService withConfidentialIssueChannel(String confidentialIssueChannel) { + setConfidentialIssueChannel(confidentialIssueChannel); + return (this); + } + + @JsonIgnore + public String getMergeRequestChannel() { + return ((String) getProperty(MERGE_REQUEST_CHANNEL_PROP)); + } + + public void setMergeRequestChannel(String mergeRequestChannel) { + setProperty(MERGE_REQUEST_CHANNEL_PROP, mergeRequestChannel); + } + + public SlackService withMergeRequestChannel(String mergeRequestChannel) { + setMergeRequestChannel(mergeRequestChannel); + return (this); + } + + @JsonIgnore + public String getNoteChannel() { + return ((String) getProperty(NOTE_CHANNEL_PROP)); + } + + public void setNoteChannel(String noteChannel) { + setProperty(NOTE_CHANNEL_PROP, noteChannel); + } + + public SlackService withNoteChannel(String noteChannel) { + setNoteChannel(noteChannel); + return (this); + } + + @JsonIgnore + public String getConfidentialNoteChannel() { + return ((String) getProperty(CONFIDENTIAL_NOTE_CHANNEL_PROP)); + } + + public void setConfidentialNoteChannel(String noteChannel) { + setProperty(NOTE_CHANNEL_PROP, noteChannel); + } + + public SlackService withConfidentialNoteChannel(String confidentialNoteChannel) { + setConfidentialNoteChannel(confidentialNoteChannel); + return (this); + } + + @JsonIgnore + public String getTagPushChannel() { + return ((String) getProperty(TAG_PUSH_CHANNEL_PROP)); + } + + public void setTagPushChannel(String tagPushChannel) { + setProperty(TAG_PUSH_CHANNEL_PROP, tagPushChannel); + } + + public SlackService withTagPushChannel(String tagPushChannel) { + setTagPushChannel(tagPushChannel); + return (this); + } + + @JsonIgnore + public String getPipelineChannel() { + return ((String) getProperty(PIPELINE_CHANNEL_PROP)); + } + + public void setPipelineChannel(String pipelineChannel) { + setProperty(PIPELINE_CHANNEL_PROP, pipelineChannel); + } + + public SlackService withPipelineChannel(String pipelineChannel) { + setPipelineChannel(pipelineChannel); + return (this); + } + + @JsonIgnore + public String getWikiPageChannel() { + return ((String) getProperty(WIKI_PAGE_CHANNEL_PROP)); + } + + public void setWikiPageChannel(String wikiPageChannel) { + setProperty(WIKI_PAGE_CHANNEL_PROP, wikiPageChannel); + } + + public SlackService withWikiPageChannel(String wikiPageChannel) { + setWikiPageChannel(wikiPageChannel); + return (this); + } +} diff --git a/src/test/resources/org/gitlab4j/api/slack-notifications.json b/src/test/resources/org/gitlab4j/api/slack-notifications.json new file mode 100644 index 0000000000000000000000000000000000000000..89682357475d10f7b548a3687abe1c829ce71cef --- /dev/null +++ b/src/test/resources/org/gitlab4j/api/slack-notifications.json @@ -0,0 +1,31 @@ +{ + "id": 100, + "title": "Slack notifications", + "created_at": "2018-04-21T17:08:36.759Z", + "updated_at": "2018-04-23T00:12:51.843Z", + "active": true, + "push_events": true, + "issues_events": false, + "confidential_issues_events": false, + "merge_requests_events": false, + "tag_push_events": false, + "note_events": false, + "confidential_note_events": false, + "pipeline_events": false, + "wiki_page_events": false, + "job_events": true, + "properties": { + "webhook": "https://hooks.slack.com/services/AAAA1BBB/ABCDEFGHI/aBCdef1Gerer65ere54gdffd", + "username": "GitLab", + "notify_only_broken_pipelines": false, + "notify_only_default_branch": true, + "push_channel": "pushes", + "issue_channel": "", + "confidential_issue_channel": "", + "merge_request_channel": "", + "note_channel": "", + "tag_push_channel": "", + "pipeline_channel": "", + "wiki_page_channel": "" + } +} \ No newline at end of file