diff options
Diffstat (limited to 'vendor/github.com/xanzy/go-gitlab/services.go')
-rw-r--r-- | vendor/github.com/xanzy/go-gitlab/services.go | 142 |
1 files changed, 138 insertions, 4 deletions
diff --git a/vendor/github.com/xanzy/go-gitlab/services.go b/vendor/github.com/xanzy/go-gitlab/services.go index e93ae60..890e5a3 100644 --- a/vendor/github.com/xanzy/go-gitlab/services.go +++ b/vendor/github.com/xanzy/go-gitlab/services.go @@ -45,8 +45,10 @@ type Service struct { MergeRequestsEvents bool `json:"merge_requests_events"` TagPushEvents bool `json:"tag_push_events"` NoteEvents bool `json:"note_events"` + ConfidentialNoteEvents bool `json:"confidential_note_events"` PipelineEvents bool `json:"pipeline_events"` JobEvents bool `json:"job_events"` + WikiPageEvents bool `json:"wiki_page_events"` } // SetGitLabCIServiceOptions represents the available SetGitLabCIService() @@ -252,7 +254,28 @@ type SlackService struct { // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#slack type SlackServiceProperties struct { - NotifyOnlyBrokenPipelines bool `json:"notify_only_broken_pipelines"` + // Note: NotifyOnlyBrokenPipelines and NotifyOnlyDefaultBranch are not + // just "bool" because in some cases gitlab returns + // "notify_only_broken_pipelines": true, and in other cases + // "notify_only_broken_pipelines": "1". The same is for + // "notify_only_default_branch" field. + // We need to handle this, until the bug will be fixed. + // Ref: https://gitlab.com/gitlab-org/gitlab-ce/issues/50122 + + NotifyOnlyBrokenPipelines BoolValue `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"` + NotifyOnlyDefaultBranch BoolValue `url:"notify_only_default_branch,omitempty" json:"notify_only_default_branch,omitempty"` + WebHook string `url:"webhook,omitempty" json:"webhook,omitempty"` + Username string `url:"username,omitempty" json:"username,omitempty"` + Channel string `url:"channel,omitempty" json:"channel,omitempty"` + PushChannel string `url:"push_channel,omitempty" json:"push_channel,omitempty"` + IssueChannel string `url:"issue_channel,omitempty" json:"issue_channel,omitempty"` + ConfidentialIssueChannel string `url:"confidential_issue_channel,omitempty" json:"confidential_issue_channel,omitempty"` + MergeRequestChannel string `url:"merge_request_channel,omitempty" json:"merge_request_channel,omitempty"` + NoteChannel string `url:"note_channel,omitempty" json:"note_channel,omitempty"` + ConfidentialNoteChannel string `url:"confidential_note_channel,omitempty" json:"confidential_note_channel,omitempty"` + TagPushChannel string `url:"tag_push_channel,omitempty" json:"tag_push_channel,omitempty"` + PipelineChannel string `url:"pipeline_channel,omitempty" json:"pipeline_channel,omitempty"` + WikiPageChannel string `url:"wiki_page_channel,omitempty" json:"wiki_page_channel,omitempty"` } // GetSlackService gets Slack service settings for a project. @@ -286,9 +309,32 @@ func (s *ServicesService) GetSlackService(pid interface{}, options ...OptionFunc // GitLab API docs: // https://docs.gitlab.com/ce/api/services.html#edit-slack-service type SetSlackServiceOptions struct { - WebHook *string `url:"webhook,omitempty" json:"webhook,omitempty" ` - Username *string `url:"username,omitempty" json:"username,omitempty" ` - Channel *string `url:"channel,omitempty" json:"channel,omitempty"` + WebHook *string `url:"webhook,omitempty" json:"webhook,omitempty"` + Username *string `url:"username,omitempty" json:"username,omitempty"` + Channel *string `url:"channel,omitempty" json:"channel,omitempty"` + NotifyOnlyBrokenPipelines *bool `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"` + NotifyOnlyDefaultBranch *bool `url:"notify_only_default_branch,omitempty" json:"notify_only_default_branch,omitempty"` + PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` + PushChannel *string `url:"push_channel,omitempty" json:"push_channel,omitempty"` + IssuesEvents *bool `url:"issues_events,omitempty" json:"issues_events,omitempty"` + IssueChannel *string `url:"issue_channel,omitempty" json:"issue_channel,omitempty"` + ConfidentialIssuesEvents *bool `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"` + ConfidentialIssueChannel *string `url:"confidential_issue_channel,omitempty" json:"confidential_issue_channel,omitempty"` + MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` + MergeRequestChannel *string `url:"merge_request_channel,omitempty" json:"merge_request_channel,omitempty"` + TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` + TagPushChannel *string `url:"tag_push_channel,omitempty" json:"tag_push_channel,omitempty"` + NoteEvents *bool `url:"note_events,omitempty" json:"note_events,omitempty"` + NoteChannel *string `url:"note_channel,omitempty" json:"note_channel,omitempty"` + ConfidentialNoteEvents *bool `url:"confidential_note_events" json:"confidential_note_events"` + // TODO: Currently, GitLab ignores this option (not implemented yet?), so + // there is no way to set it. Uncomment when this is fixed. + // See: https://gitlab.com/gitlab-org/gitlab-ce/issues/49730 + //ConfidentialNoteChannel *string `json:"confidential_note_channel,omitempty"` + PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"` + PipelineChannel *string `url:"pipeline_channel,omitempty" json:"pipeline_channel,omitempty"` + WikiPageChannel *string `url:"wiki_page_channel,omitempty" json:"wiki_page_channel,omitempty"` + WikiPageEvents *bool `url:"wiki_page_events" json:"wiki_page_events"` } // SetSlackService sets Slack service for a project @@ -513,3 +559,91 @@ func (s *ServicesService) DeleteJenkinsCIService(pid interface{}, options ...Opt return s.client.Do(req, nil) } + +// MicrosoftTeamsService represents Microsoft Teams service settings. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/services.html#microsoft-teams +type MicrosoftTeamsService struct { + Service + Properties *MicrosoftTeamsServiceProperties `json:"properties"` +} + +// MicrosoftTeamsServiceProperties represents Microsoft Teams specific properties. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/services.html#microsoft-teams +type MicrosoftTeamsServiceProperties struct { + WebHook string `json:"webhook"` +} + +// GetMicrosoftTeamsService gets MicrosoftTeams service settings for a project. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/services.html#get-microsoft-teams-service-settings +func (s *ServicesService) GetMicrosoftTeamsService(pid interface{}, options ...OptionFunc) (*MicrosoftTeamsService, *Response, error) { + project, err := parseID(pid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("projects/%s/services/microsoft-teams", url.QueryEscape(project)) + + req, err := s.client.NewRequest("GET", u, nil, options) + if err != nil { + return nil, nil, err + } + + svc := new(MicrosoftTeamsService) + resp, err := s.client.Do(req, svc) + if err != nil { + return nil, resp, err + } + + return svc, resp, err +} + +// SetMicrosoftTeamsServiceOptions represents the available SetMicrosoftTeamsService() +// options. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/services.html#create-edit-microsoft-teams-service +type SetMicrosoftTeamsServiceOptions struct { + WebHook *string `url:"webhook,omitempty" json:"webhook,omitempty"` +} + +// SetMicrosoftTeamsService sets Microsoft Teams service for a project +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/services.html#create-edit-microsoft-teams-service +func (s *ServicesService) SetMicrosoftTeamsService(pid interface{}, opt *SetMicrosoftTeamsServiceOptions, options ...OptionFunc) (*Response, error) { + project, err := parseID(pid) + if err != nil { + return nil, err + } + u := fmt.Sprintf("projects/%s/services/microsoft-teams", url.QueryEscape(project)) + + req, err := s.client.NewRequest("PUT", u, opt, options) + if err != nil { + return nil, err + } + return s.client.Do(req, nil) +} + +// DeleteMicrosoftTeamsService deletes Microsoft Teams service for project. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/services.html#delete-microsoft-teams-service +func (s *ServicesService) DeleteMicrosoftTeamsService(pid interface{}, options ...OptionFunc) (*Response, error) { + project, err := parseID(pid) + if err != nil { + return nil, err + } + u := fmt.Sprintf("projects/%s/services/microsoft-teams", url.QueryEscape(project)) + + req, err := s.client.NewRequest("DELETE", u, nil, options) + if err != nil { + return nil, err + } + + return s.client.Do(req, nil) +} |