...

Source file src/github.com/xanzy/go-gitlab/services.go

Documentation: github.com/xanzy/go-gitlab

     1  //
     2  // Copyright 2021, Sander van Harmelen
     3  //
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  //     http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  //
    16  
    17  package gitlab
    18  
    19  import (
    20  	"encoding/json"
    21  	"fmt"
    22  	"net/http"
    23  	"strconv"
    24  	"time"
    25  )
    26  
    27  // ServicesService handles communication with the services related methods of
    28  // the GitLab API.
    29  //
    30  // GitLab API docs: https://docs.gitlab.com/ee/api/integrations.html
    31  type ServicesService struct {
    32  	client *Client
    33  }
    34  
    35  // Service represents a GitLab service.
    36  //
    37  // GitLab API docs: https://docs.gitlab.com/ee/api/integrations.html
    38  type Service struct {
    39  	ID                       int        `json:"id"`
    40  	Title                    string     `json:"title"`
    41  	Slug                     string     `json:"slug"`
    42  	CreatedAt                *time.Time `json:"created_at"`
    43  	UpdatedAt                *time.Time `json:"updated_at"`
    44  	Active                   bool       `json:"active"`
    45  	PushEvents               bool       `json:"push_events"`
    46  	IssuesEvents             bool       `json:"issues_events"`
    47  	AlertEvents              bool       `json:"alert_events"`
    48  	ConfidentialIssuesEvents bool       `json:"confidential_issues_events"`
    49  	CommitEvents             bool       `json:"commit_events"`
    50  	MergeRequestsEvents      bool       `json:"merge_requests_events"`
    51  	CommentOnEventEnabled    bool       `json:"comment_on_event_enabled"`
    52  	TagPushEvents            bool       `json:"tag_push_events"`
    53  	NoteEvents               bool       `json:"note_events"`
    54  	ConfidentialNoteEvents   bool       `json:"confidential_note_events"`
    55  	PipelineEvents           bool       `json:"pipeline_events"`
    56  	JobEvents                bool       `json:"job_events"`
    57  	WikiPageEvents           bool       `json:"wiki_page_events"`
    58  	VulnerabilityEvents      bool       `json:"vulnerability_events"`
    59  	DeploymentEvents         bool       `json:"deployment_events"`
    60  }
    61  
    62  // ListServices gets a list of all active services.
    63  //
    64  // GitLab API docs: https://docs.gitlab.com/ee/api/integrations.html#list-all-active-services
    65  func (s *ServicesService) ListServices(pid interface{}, options ...RequestOptionFunc) ([]*Service, *Response, error) {
    66  	project, err := parseID(pid)
    67  	if err != nil {
    68  		return nil, nil, err
    69  	}
    70  	u := fmt.Sprintf("projects/%s/services", PathEscape(project))
    71  
    72  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
    73  	if err != nil {
    74  		return nil, nil, err
    75  	}
    76  
    77  	var svcs []*Service
    78  	resp, err := s.client.Do(req, &svcs)
    79  	if err != nil {
    80  		return nil, resp, err
    81  	}
    82  
    83  	return svcs, resp, nil
    84  }
    85  
    86  // CustomIssueTrackerService represents Custom Issue Tracker service settings.
    87  //
    88  // GitLab API docs:
    89  // https://docs.gitlab.com/ee/api/integrations.html#custom-issue-tracker
    90  type CustomIssueTrackerService struct {
    91  	Service
    92  	Properties *CustomIssueTrackerServiceProperties `json:"properties"`
    93  }
    94  
    95  // CustomIssueTrackerServiceProperties represents Custom Issue Tracker specific properties.
    96  //
    97  // GitLab API docs:
    98  // https://docs.gitlab.com/ee/api/integrations.html#custom-issue-tracker
    99  type CustomIssueTrackerServiceProperties struct {
   100  	ProjectURL  string `json:"project_url,omitempty"`
   101  	IssuesURL   string `json:"issues_url,omitempty"`
   102  	NewIssueURL string `json:"new_issue_url,omitempty"`
   103  }
   104  
   105  // GetCustomIssueTrackerService gets Custom Issue Tracker service settings for a project.
   106  //
   107  // GitLab API docs:
   108  // https://docs.gitlab.com/ee/api/integrations.html#get-custom-issue-tracker-service-settings
   109  func (s *ServicesService) GetCustomIssueTrackerService(pid interface{}, options ...RequestOptionFunc) (*CustomIssueTrackerService, *Response, error) {
   110  	project, err := parseID(pid)
   111  	if err != nil {
   112  		return nil, nil, err
   113  	}
   114  	u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", PathEscape(project))
   115  
   116  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
   117  	if err != nil {
   118  		return nil, nil, err
   119  	}
   120  
   121  	svc := new(CustomIssueTrackerService)
   122  	resp, err := s.client.Do(req, svc)
   123  	if err != nil {
   124  		return nil, resp, err
   125  	}
   126  
   127  	return svc, resp, nil
   128  }
   129  
   130  // SetCustomIssueTrackerServiceOptions represents the available SetCustomIssueTrackerService()
   131  // options.
   132  //
   133  // GitLab API docs:
   134  // https://docs.gitlab.com/ee/api/integrations.html#createedit-custom-issue-tracker-service
   135  type SetCustomIssueTrackerServiceOptions struct {
   136  	NewIssueURL *string `url:"new_issue_url,omitempty" json:"new_issue_url,omitempty"`
   137  	IssuesURL   *string `url:"issues_url,omitempty" json:"issues_url,omitempty"`
   138  	ProjectURL  *string `url:"project_url,omitempty" json:"project_url,omitempty"`
   139  	Description *string `url:"description,omitempty" json:"description,omitempty"`
   140  	Title       *string `url:"title,omitempty" json:"title,omitempty"`
   141  	PushEvents  *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
   142  }
   143  
   144  // SetCustomIssueTrackerService sets Custom Issue Tracker service for a project.
   145  //
   146  // GitLab API docs:
   147  // https://docs.gitlab.com/ee/api/integrations.html#createedit-custom-issue-tracker-service
   148  func (s *ServicesService) SetCustomIssueTrackerService(pid interface{}, opt *SetCustomIssueTrackerServiceOptions, options ...RequestOptionFunc) (*Response, error) {
   149  	project, err := parseID(pid)
   150  	if err != nil {
   151  		return nil, err
   152  	}
   153  	u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", PathEscape(project))
   154  
   155  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
   156  	if err != nil {
   157  		return nil, err
   158  	}
   159  
   160  	return s.client.Do(req, nil)
   161  }
   162  
   163  // DeleteCustomIssueTrackerService deletes Custom Issue Tracker service settings for a project.
   164  //
   165  // GitLab API docs:
   166  // https://docs.gitlab.com/ee/api/integrations.html#delete-custom-issue-tracker-service
   167  func (s *ServicesService) DeleteCustomIssueTrackerService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
   168  	project, err := parseID(pid)
   169  	if err != nil {
   170  		return nil, err
   171  	}
   172  	u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", PathEscape(project))
   173  
   174  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
   175  	if err != nil {
   176  		return nil, err
   177  	}
   178  
   179  	return s.client.Do(req, nil)
   180  }
   181  
   182  // DataDogService represents DataDog service settings.
   183  //
   184  // GitLab API docs:
   185  // https://docs.gitlab.com/ee/api/integrations.html#datadog
   186  type DataDogService struct {
   187  	Service
   188  	Properties *DataDogServiceProperties `json:"properties"`
   189  }
   190  
   191  // DataDogServiceProperties represents DataDog specific properties.
   192  //
   193  // GitLab API docs:
   194  // https://docs.gitlab.com/ee/api/integrations.html#datadog
   195  type DataDogServiceProperties struct {
   196  	APIURL             string `url:"api_url,omitempty" json:"api_url,omitempty"`
   197  	DataDogEnv         string `url:"datadog_env,omitempty" json:"datadog_env,omitempty"`
   198  	DataDogService     string `url:"datadog_service,omitempty" json:"datadog_service,omitempty"`
   199  	DataDogSite        string `url:"datadog_site,omitempty" json:"datadog_site,omitempty"`
   200  	DataDogTags        string `url:"datadog_tags,omitempty" json:"datadog_tags,omitempty"`
   201  	ArchiveTraceEvents bool   `url:"archive_trace_events,omitempty" json:"archive_trace_events,omitempty"`
   202  }
   203  
   204  // GetDataDogService gets DataDog service settings for a project.
   205  //
   206  // GitLab API docs:
   207  // https://docs.gitlab.com/ee/api/integrations.html#get-datadog-integration-settings
   208  func (s *ServicesService) GetDataDogService(pid interface{}, options ...RequestOptionFunc) (*DataDogService, *Response, error) {
   209  	project, err := parseID(pid)
   210  	if err != nil {
   211  		return nil, nil, err
   212  	}
   213  	u := fmt.Sprintf("projects/%s/services/datadog", PathEscape(project))
   214  
   215  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
   216  	if err != nil {
   217  		return nil, nil, err
   218  	}
   219  
   220  	svc := new(DataDogService)
   221  	resp, err := s.client.Do(req, svc)
   222  	if err != nil {
   223  		return nil, resp, err
   224  	}
   225  
   226  	return svc, resp, nil
   227  }
   228  
   229  // SetDataDogServiceOptions represents the available SetDataDogService()
   230  // options.
   231  //
   232  // GitLab API docs:
   233  // https://docs.gitlab.com/ee/api/integrations.html#createedit-datadog-integration
   234  type SetDataDogServiceOptions struct {
   235  	APIKey             *string `url:"api_key,omitempty" json:"api_key,omitempty"`
   236  	APIURL             *string `url:"api_url,omitempty" json:"api_url,omitempty"`
   237  	DataDogEnv         *string `url:"datadog_env,omitempty" json:"datadog_env,omitempty"`
   238  	DataDogService     *string `url:"datadog_service,omitempty" json:"datadog_service,omitempty"`
   239  	DataDogSite        *string `url:"datadog_site,omitempty" json:"datadog_site,omitempty"`
   240  	DataDogTags        *string `url:"datadog_tags,omitempty" json:"datadog_tags,omitempty"`
   241  	ArchiveTraceEvents *bool   `url:"archive_trace_events,omitempty" json:"archive_trace_events,omitempty"`
   242  }
   243  
   244  // SetDataDogService sets DataDog service settings for a project.
   245  //
   246  // GitLab API docs:
   247  // https://docs.gitlab.com/ee/api/integrations.html#createedit-datadog-integration
   248  func (s *ServicesService) SetDataDogService(pid interface{}, opt *SetDataDogServiceOptions, options ...RequestOptionFunc) (*Response, error) {
   249  	project, err := parseID(pid)
   250  	if err != nil {
   251  		return nil, err
   252  	}
   253  	u := fmt.Sprintf("projects/%s/services/datadog", PathEscape(project))
   254  
   255  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
   256  	if err != nil {
   257  		return nil, err
   258  	}
   259  
   260  	return s.client.Do(req, nil)
   261  }
   262  
   263  // DeleteDataDogService deletes the DataDog service settings for a project.
   264  //
   265  // GitLab API docs:
   266  // https://docs.gitlab.com/ee/api/integrations.html#disable-datadog-integration
   267  func (s *ServicesService) DeleteDataDogService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
   268  	project, err := parseID(pid)
   269  	if err != nil {
   270  		return nil, err
   271  	}
   272  	u := fmt.Sprintf("projects/%s/services/datadog", PathEscape(project))
   273  
   274  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
   275  	if err != nil {
   276  		return nil, err
   277  	}
   278  
   279  	return s.client.Do(req, nil)
   280  }
   281  
   282  // DiscordService represents Discord service settings.
   283  //
   284  // GitLab API docs:
   285  // https://docs.gitlab.com/ee/api/integrations.html#discord
   286  type DiscordService struct {
   287  	Service
   288  	Properties *DiscordServiceProperties `json:"properties"`
   289  }
   290  
   291  // DiscordServiceProperties represents Discord specific properties.
   292  //
   293  // GitLab API docs:
   294  // https://docs.gitlab.com/ee/api/integrations.html#discord
   295  type DiscordServiceProperties struct {
   296  	BranchesToBeNotified      string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
   297  	NotifyOnlyBrokenPipelines bool   `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
   298  }
   299  
   300  // GetDiscordService gets Discord service settings for a project.
   301  //
   302  // GitLab API docs:
   303  // https://docs.gitlab.com/ee/api/integrations.html#get-discord-service-settings
   304  func (s *ServicesService) GetDiscordService(pid interface{}, options ...RequestOptionFunc) (*DiscordService, *Response, error) {
   305  	project, err := parseID(pid)
   306  	if err != nil {
   307  		return nil, nil, err
   308  	}
   309  	u := fmt.Sprintf("projects/%s/services/discord", PathEscape(project))
   310  
   311  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
   312  	if err != nil {
   313  		return nil, nil, err
   314  	}
   315  
   316  	svc := new(DiscordService)
   317  	resp, err := s.client.Do(req, svc)
   318  	if err != nil {
   319  		return nil, resp, err
   320  	}
   321  
   322  	return svc, resp, nil
   323  }
   324  
   325  // SetDiscordServiceOptions represents the available SetDiscordService()
   326  // options.
   327  //
   328  // GitLab API docs:
   329  // https://docs.gitlab.com/ee/api/integrations.html#createedit-discord-service
   330  type SetDiscordServiceOptions struct {
   331  	WebHook                   *string `url:"webhook,omitempty" json:"webhook,omitempty"`
   332  	BranchesToBeNotified      *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
   333  	ConfidentialIssuesEvents  *bool   `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"`
   334  	ConfidentialNoteEvents    *bool   `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"`
   335  	IssuesEvents              *bool   `url:"issues_events,omitempty" json:"issues_events,omitempty"`
   336  	MergeRequestsEvents       *bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
   337  	NoteEvents                *bool   `url:"note_events,omitempty" json:"note_events,omitempty"`
   338  	NotifyOnlyBrokenPipelines *bool   `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
   339  	PipelineEvents            *bool   `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
   340  	PushEvents                *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
   341  	TagPushEvents             *bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
   342  	WikiPageEvents            *bool   `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
   343  }
   344  
   345  // SetDiscordService sets Discord service for a project.
   346  //
   347  // GitLab API docs:
   348  // https://docs.gitlab.com/ee/api/integrations.html#createedit-discord-service
   349  func (s *ServicesService) SetDiscordService(pid interface{}, opt *SetDiscordServiceOptions, options ...RequestOptionFunc) (*Response, error) {
   350  	project, err := parseID(pid)
   351  	if err != nil {
   352  		return nil, err
   353  	}
   354  	u := fmt.Sprintf("projects/%s/services/discord", PathEscape(project))
   355  
   356  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
   357  	if err != nil {
   358  		return nil, err
   359  	}
   360  
   361  	return s.client.Do(req, nil)
   362  }
   363  
   364  // DeleteDiscordService deletes Discord service settings for a project.
   365  //
   366  // GitLab API docs:
   367  // https://docs.gitlab.com/ee/api/integrations.html#delete-discord-service
   368  func (s *ServicesService) DeleteDiscordService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
   369  	project, err := parseID(pid)
   370  	if err != nil {
   371  		return nil, err
   372  	}
   373  	u := fmt.Sprintf("projects/%s/services/discord", PathEscape(project))
   374  
   375  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
   376  	if err != nil {
   377  		return nil, err
   378  	}
   379  
   380  	return s.client.Do(req, nil)
   381  }
   382  
   383  // DroneCIService represents Drone CI service settings.
   384  //
   385  // GitLab API docs:
   386  // https://docs.gitlab.com/ee/api/integrations.html#drone
   387  type DroneCIService struct {
   388  	Service
   389  	Properties *DroneCIServiceProperties `json:"properties"`
   390  }
   391  
   392  // DroneCIServiceProperties represents Drone CI specific properties.
   393  //
   394  // GitLab API docs:
   395  // https://docs.gitlab.com/ee/api/integrations.html#drone
   396  type DroneCIServiceProperties struct {
   397  	DroneURL              string `json:"drone_url"`
   398  	EnableSSLVerification bool   `json:"enable_ssl_verification"`
   399  }
   400  
   401  // GetDroneCIService gets Drone CI service settings for a project.
   402  //
   403  // GitLab API docs:
   404  // https://docs.gitlab.com/ee/api/integrations.html#get-drone-settings
   405  func (s *ServicesService) GetDroneCIService(pid interface{}, options ...RequestOptionFunc) (*DroneCIService, *Response, error) {
   406  	project, err := parseID(pid)
   407  	if err != nil {
   408  		return nil, nil, err
   409  	}
   410  	u := fmt.Sprintf("projects/%s/services/drone-ci", PathEscape(project))
   411  
   412  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
   413  	if err != nil {
   414  		return nil, nil, err
   415  	}
   416  
   417  	svc := new(DroneCIService)
   418  	resp, err := s.client.Do(req, svc)
   419  	if err != nil {
   420  		return nil, resp, err
   421  	}
   422  
   423  	return svc, resp, nil
   424  }
   425  
   426  // SetDroneCIServiceOptions represents the available SetDroneCIService()
   427  // options.
   428  //
   429  // GitLab API docs:
   430  // https://docs.gitlab.com/ee/api/integrations.html#set-up-drone
   431  type SetDroneCIServiceOptions struct {
   432  	Token                 *string `url:"token,omitempty" json:"token,omitempty"`
   433  	DroneURL              *string `url:"drone_url,omitempty" json:"drone_url,omitempty"`
   434  	EnableSSLVerification *bool   `url:"enable_ssl_verification,omitempty" json:"enable_ssl_verification,omitempty"`
   435  	PushEvents            *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
   436  	MergeRequestsEvents   *bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
   437  	TagPushEvents         *bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
   438  }
   439  
   440  // SetDroneCIService sets Drone CI service for a project.
   441  //
   442  // GitLab API docs:
   443  // https://docs.gitlab.com/ee/api/integrations.html#set-up-drone
   444  func (s *ServicesService) SetDroneCIService(pid interface{}, opt *SetDroneCIServiceOptions, options ...RequestOptionFunc) (*Response, error) {
   445  	project, err := parseID(pid)
   446  	if err != nil {
   447  		return nil, err
   448  	}
   449  	u := fmt.Sprintf("projects/%s/services/drone-ci", PathEscape(project))
   450  
   451  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
   452  	if err != nil {
   453  		return nil, err
   454  	}
   455  
   456  	return s.client.Do(req, nil)
   457  }
   458  
   459  // DeleteDroneCIService deletes Drone CI service settings for a project.
   460  //
   461  // GitLab API docs:
   462  // https://docs.gitlab.com/ee/api/integrations.html#disable-drone
   463  func (s *ServicesService) DeleteDroneCIService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
   464  	project, err := parseID(pid)
   465  	if err != nil {
   466  		return nil, err
   467  	}
   468  	u := fmt.Sprintf("projects/%s/services/drone-ci", PathEscape(project))
   469  
   470  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
   471  	if err != nil {
   472  		return nil, err
   473  	}
   474  
   475  	return s.client.Do(req, nil)
   476  }
   477  
   478  // EmailsOnPushService represents Emails on Push service settings.
   479  //
   480  // GitLab API docs:
   481  // https://docs.gitlab.com/ee/api/integrations.html#emails-on-push
   482  type EmailsOnPushService struct {
   483  	Service
   484  	Properties *EmailsOnPushServiceProperties `json:"properties"`
   485  }
   486  
   487  // EmailsOnPushServiceProperties represents Emails on Push specific properties.
   488  //
   489  // GitLab API docs:
   490  // https://docs.gitlab.com/ee/api/integrations.html#emails-on-push
   491  type EmailsOnPushServiceProperties struct {
   492  	Recipients             string `json:"recipients"`
   493  	DisableDiffs           bool   `json:"disable_diffs"`
   494  	SendFromCommitterEmail bool   `json:"send_from_committer_email"`
   495  	PushEvents             bool   `json:"push_events"`
   496  	TagPushEvents          bool   `json:"tag_push_events"`
   497  	BranchesToBeNotified   string `json:"branches_to_be_notified"`
   498  }
   499  
   500  // GetEmailsOnPushService gets Emails on Push service settings for a project.
   501  //
   502  // GitLab API docs:
   503  // https://docs.gitlab.com/ee/api/integrations.html#get-emails-on-push-integration-settings
   504  func (s *ServicesService) GetEmailsOnPushService(pid interface{}, options ...RequestOptionFunc) (*EmailsOnPushService, *Response, error) {
   505  	project, err := parseID(pid)
   506  	if err != nil {
   507  		return nil, nil, err
   508  	}
   509  	u := fmt.Sprintf("projects/%s/integrations/emails-on-push", PathEscape(project))
   510  
   511  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
   512  	if err != nil {
   513  		return nil, nil, err
   514  	}
   515  
   516  	svc := new(EmailsOnPushService)
   517  	resp, err := s.client.Do(req, svc)
   518  	if err != nil {
   519  		return nil, resp, err
   520  	}
   521  
   522  	return svc, resp, nil
   523  }
   524  
   525  // SetEmailsOnPushServiceOptions represents the available SetEmailsOnPushService()
   526  // options.
   527  //
   528  // GitLab API docs:
   529  // https://docs.gitlab.com/ee/api/integrations.html#createedit-emails-on-push-integration
   530  type SetEmailsOnPushServiceOptions struct {
   531  	Recipients             *string `url:"recipients,omitempty" json:"recipients,omitempty"`
   532  	DisableDiffs           *bool   `url:"disable_diffs,omitempty" json:"disable_diffs,omitempty"`
   533  	SendFromCommitterEmail *bool   `url:"send_from_committer_email,omitempty" json:"send_from_committer_email,omitempty"`
   534  	PushEvents             *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
   535  	TagPushEvents          *bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
   536  	BranchesToBeNotified   *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
   537  }
   538  
   539  // SetEmailsOnPushService sets Emails on Push service for a project.
   540  //
   541  // GitLab API docs:
   542  // https://docs.gitlab.com/ee/api/integrations.html#createedit-emails-on-push-integration
   543  func (s *ServicesService) SetEmailsOnPushService(pid interface{}, opt *SetEmailsOnPushServiceOptions, options ...RequestOptionFunc) (*Response, error) {
   544  	project, err := parseID(pid)
   545  	if err != nil {
   546  		return nil, err
   547  	}
   548  	u := fmt.Sprintf("projects/%s/integrations/emails-on-push", PathEscape(project))
   549  
   550  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
   551  	if err != nil {
   552  		return nil, err
   553  	}
   554  
   555  	return s.client.Do(req, nil)
   556  }
   557  
   558  // DeleteEmailsOnPushService deletes Emails on Push service settings for a project.
   559  //
   560  // GitLab API docs:
   561  // https://docs.gitlab.com/ee/api/integrations.html#disable-emails-on-push-integration
   562  func (s *ServicesService) DeleteEmailsOnPushService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
   563  	project, err := parseID(pid)
   564  	if err != nil {
   565  		return nil, err
   566  	}
   567  	u := fmt.Sprintf("projects/%s/integrations/emails-on-push", PathEscape(project))
   568  
   569  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
   570  	if err != nil {
   571  		return nil, err
   572  	}
   573  
   574  	return s.client.Do(req, nil)
   575  }
   576  
   577  // ExternalWikiService represents External Wiki service settings.
   578  //
   579  // GitLab API docs:
   580  // https://docs.gitlab.com/ee/api/integrations.html#external-wiki
   581  type ExternalWikiService struct {
   582  	Service
   583  	Properties *ExternalWikiServiceProperties `json:"properties"`
   584  }
   585  
   586  // ExternalWikiServiceProperties represents External Wiki specific properties.
   587  //
   588  // GitLab API docs:
   589  // https://docs.gitlab.com/ee/api/integrations.html#external-wiki
   590  type ExternalWikiServiceProperties struct {
   591  	ExternalWikiURL string `json:"external_wiki_url"`
   592  }
   593  
   594  // GetExternalWikiService gets External Wiki service settings for a project.
   595  //
   596  // GitLab API docs:
   597  // https://docs.gitlab.com/ee/api/integrations.html#get-external-wiki-service-settings
   598  func (s *ServicesService) GetExternalWikiService(pid interface{}, options ...RequestOptionFunc) (*ExternalWikiService, *Response, error) {
   599  	project, err := parseID(pid)
   600  	if err != nil {
   601  		return nil, nil, err
   602  	}
   603  	u := fmt.Sprintf("projects/%s/services/external-wiki", PathEscape(project))
   604  
   605  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
   606  	if err != nil {
   607  		return nil, nil, err
   608  	}
   609  
   610  	svc := new(ExternalWikiService)
   611  	resp, err := s.client.Do(req, svc)
   612  	if err != nil {
   613  		return nil, resp, err
   614  	}
   615  
   616  	return svc, resp, nil
   617  }
   618  
   619  // SetExternalWikiServiceOptions represents the available SetExternalWikiService()
   620  // options.
   621  //
   622  // GitLab API docs:
   623  // https://docs.gitlab.com/ee/api/integrations.html#createedit-external-wiki-service
   624  type SetExternalWikiServiceOptions struct {
   625  	ExternalWikiURL *string `url:"external_wiki_url,omitempty" json:"external_wiki_url,omitempty"`
   626  }
   627  
   628  // SetExternalWikiService sets External Wiki service for a project.
   629  //
   630  // GitLab API docs:
   631  // https://docs.gitlab.com/ee/api/integrations.html#createedit-external-wiki-service
   632  func (s *ServicesService) SetExternalWikiService(pid interface{}, opt *SetExternalWikiServiceOptions, options ...RequestOptionFunc) (*Response, error) {
   633  	project, err := parseID(pid)
   634  	if err != nil {
   635  		return nil, err
   636  	}
   637  	u := fmt.Sprintf("projects/%s/services/external-wiki", PathEscape(project))
   638  
   639  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
   640  	if err != nil {
   641  		return nil, err
   642  	}
   643  
   644  	return s.client.Do(req, nil)
   645  }
   646  
   647  // DeleteExternalWikiService deletes External Wiki service for project.
   648  //
   649  // GitLab API docs:
   650  // https://docs.gitlab.com/ee/api/integrations.html#delete-external-wiki-service
   651  func (s *ServicesService) DeleteExternalWikiService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
   652  	project, err := parseID(pid)
   653  	if err != nil {
   654  		return nil, err
   655  	}
   656  	u := fmt.Sprintf("projects/%s/services/external-wiki", PathEscape(project))
   657  
   658  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
   659  	if err != nil {
   660  		return nil, err
   661  	}
   662  
   663  	return s.client.Do(req, nil)
   664  }
   665  
   666  // GithubService represents Github service settings.
   667  //
   668  // GitLab API docs:
   669  // https://docs.gitlab.com/ee/api/integrations.html#github-premium
   670  type GithubService struct {
   671  	Service
   672  	Properties *GithubServiceProperties `json:"properties"`
   673  }
   674  
   675  // GithubServiceProperties represents Github specific properties.
   676  //
   677  // GitLab API docs:
   678  // https://docs.gitlab.com/ee/api/integrations.html#github-premium
   679  type GithubServiceProperties struct {
   680  	RepositoryURL string `json:"repository_url"`
   681  	StaticContext bool   `json:"static_context"`
   682  }
   683  
   684  // GetGithubService gets Github service settings for a project.
   685  //
   686  // GitLab API docs:
   687  // https://docs.gitlab.com/ee/api/integrations.html#get-github-service-settings
   688  func (s *ServicesService) GetGithubService(pid interface{}, options ...RequestOptionFunc) (*GithubService, *Response, error) {
   689  	project, err := parseID(pid)
   690  	if err != nil {
   691  		return nil, nil, err
   692  	}
   693  	u := fmt.Sprintf("projects/%s/services/github", PathEscape(project))
   694  
   695  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
   696  	if err != nil {
   697  		return nil, nil, err
   698  	}
   699  
   700  	svc := new(GithubService)
   701  	resp, err := s.client.Do(req, svc)
   702  	if err != nil {
   703  		return nil, resp, err
   704  	}
   705  
   706  	return svc, resp, nil
   707  }
   708  
   709  // SetGithubServiceOptions represents the available SetGithubService()
   710  // options.
   711  //
   712  // GitLab API docs:
   713  // https://docs.gitlab.com/ee/api/integrations.html#createedit-github-service
   714  type SetGithubServiceOptions struct {
   715  	Token         *string `url:"token,omitempty" json:"token,omitempty"`
   716  	RepositoryURL *string `url:"repository_url,omitempty" json:"repository_url,omitempty"`
   717  	StaticContext *bool   `url:"static_context,omitempty" json:"static_context,omitempty"`
   718  }
   719  
   720  // SetGithubService sets Github service for a project
   721  //
   722  // GitLab API docs:
   723  // https://docs.gitlab.com/ee/api/integrations.html#createedit-github-service
   724  func (s *ServicesService) SetGithubService(pid interface{}, opt *SetGithubServiceOptions, options ...RequestOptionFunc) (*Response, error) {
   725  	project, err := parseID(pid)
   726  	if err != nil {
   727  		return nil, err
   728  	}
   729  	u := fmt.Sprintf("projects/%s/services/github", PathEscape(project))
   730  
   731  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
   732  	if err != nil {
   733  		return nil, err
   734  	}
   735  
   736  	return s.client.Do(req, nil)
   737  }
   738  
   739  // DeleteGithubService deletes Github service for a project
   740  //
   741  // GitLab API docs:
   742  // https://docs.gitlab.com/ee/api/integrations.html#delete-github-service
   743  func (s *ServicesService) DeleteGithubService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
   744  	project, err := parseID(pid)
   745  	if err != nil {
   746  		return nil, err
   747  	}
   748  	u := fmt.Sprintf("projects/%s/services/github", PathEscape(project))
   749  
   750  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
   751  	if err != nil {
   752  		return nil, err
   753  	}
   754  
   755  	return s.client.Do(req, nil)
   756  }
   757  
   758  // SlackApplication represents GitLab for slack application settings.
   759  //
   760  // GitLab API docs:
   761  // https://docs.gitlab.com/ee/api/integrations.html#gitlab-for-slack-app
   762  type SlackApplication struct {
   763  	Service
   764  	Properties *SlackApplicationProperties `json:"properties"`
   765  }
   766  
   767  // SlackApplicationProperties represents GitLab for slack application specific properties.
   768  //
   769  // GitLab API docs:
   770  // https://docs.gitlab.com/ee/api/integrations.html#gitlab-for-slack-app
   771  type SlackApplicationProperties struct {
   772  	Channel                   string `json:"channel"`
   773  	NotifyOnlyBrokenPipelines bool   `json:"notify_only_broken_pipelines"`
   774  	BranchesToBeNotified      string `json:"branches_to_be_notified"`
   775  	AlertEvents               bool   `json:"alert_events"`
   776  	IssuesEvents              bool   `json:"issues_events"`
   777  	ConfidentialIssuesEvents  bool   `json:"confidential_issues_events"`
   778  	MergeRequestsEvents       bool   `json:"merge_requests_events"`
   779  	NoteEvents                bool   `json:"note_events"`
   780  	ConfidentialNoteEvents    bool   `json:"confidential_note_events"`
   781  	DeploymentEvents          bool   `json:"deployment_events"`
   782  	IncidentsEvents           bool   `json:"incidents_events"`
   783  	PipelineEvents            bool   `json:"pipeline_events"`
   784  	PushEvents                bool   `json:"push_events"`
   785  	TagPushEvents             bool   `json:"tag_push_events"`
   786  	VulnerabilityEvents       bool   `json:"vulnerability_events"`
   787  	WikiPageEvents            bool   `json:"wiki_page_events"`
   788  
   789  	// Deprecated: This parameter has been replaced with BranchesToBeNotified.
   790  	NotifyOnlyDefaultBranch bool `json:"notify_only_default_branch"`
   791  }
   792  
   793  // GetSlackApplication gets the GitLab for Slack app integration settings for a
   794  // project.
   795  //
   796  // GitLab API docs:
   797  // https://docs.gitlab.com/ee/api/integrations.html#get-gitlab-for-slack-app-settings
   798  func (s *ServicesService) GetSlackApplication(pid interface{}, options ...RequestOptionFunc) (*SlackApplication, *Response, error) {
   799  	project, err := parseID(pid)
   800  	if err != nil {
   801  		return nil, nil, err
   802  	}
   803  	u := fmt.Sprintf("projects/%s/integrations/gitlab-slack-application", PathEscape(project))
   804  
   805  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
   806  	if err != nil {
   807  		return nil, nil, err
   808  	}
   809  
   810  	svc := new(SlackApplication)
   811  	resp, err := s.client.Do(req, svc)
   812  	if err != nil {
   813  		return nil, resp, err
   814  	}
   815  
   816  	return svc, resp, nil
   817  }
   818  
   819  // SetSlackApplicationOptions represents the available SetSlackApplication()
   820  // options.
   821  //
   822  // GitLab API docs:
   823  // https://docs.gitlab.com/ee/api/integrations.html#set-up-gitlab-for-slack-app
   824  type SetSlackApplicationOptions struct {
   825  	Channel                   *string `url:"channel,omitempty" json:"channel,omitempty"`
   826  	NotifyOnlyBrokenPipelines *bool   `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
   827  	BranchesToBeNotified      *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
   828  	AlertEvents               *bool   `url:"alert_events,omitempty" json:"alert_events,omitempty"`
   829  	IssuesEvents              *bool   `url:"issues_events,omitempty" json:"issues_events,omitempty"`
   830  	ConfidentialIssuesEvents  *bool   `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"`
   831  	MergeRequestsEvents       *bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
   832  	NoteEvents                *bool   `url:"note_events,omitempty" json:"note_events,omitempty"`
   833  	ConfidentialNoteEvents    *bool   `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"`
   834  	DeploymentEvents          *bool   `url:"deployment_events,omitempty" json:"deployment_events,omitempty"`
   835  	IncidentsEvents           *bool   `url:"incidents_events,omitempty" json:"incidents_events,omitempty"`
   836  	PipelineEvents            *bool   `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
   837  	PushEvents                *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
   838  	TagPushEvents             *bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
   839  	VulnerabilityEvents       *bool   `url:"vulnerability_events,omitempty" json:"vulnerability_events,omitempty"`
   840  	WikiPageEvents            *bool   `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
   841  
   842  	// Deprecated: This parameter has been replaced with BranchesToBeNotified.
   843  	NotifyOnlyDefaultBranch *bool `url:"notify_only_default_branch,omitempty" json:"notify_only_default_branch,omitempty"`
   844  }
   845  
   846  // SetSlackApplication update the GitLab for Slack app integration for a project.
   847  //
   848  // GitLab API docs:
   849  // https://docs.gitlab.com/ee/api/integrations.html#set-up-gitlab-for-slack-app
   850  func (s *ServicesService) SetSlackApplication(pid interface{}, opt *SetSlackApplicationOptions, options ...RequestOptionFunc) (*Response, error) {
   851  	project, err := parseID(pid)
   852  	if err != nil {
   853  		return nil, err
   854  	}
   855  	u := fmt.Sprintf("projects/%s/integrations/gitlab-slack-application", PathEscape(project))
   856  
   857  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
   858  	if err != nil {
   859  		return nil, err
   860  	}
   861  
   862  	return s.client.Do(req, nil)
   863  }
   864  
   865  // DisableSlackApplication disable the GitLab for Slack app integration for a project.
   866  //
   867  // GitLab API docs:
   868  // https://docs.gitlab.com/ee/api/integrations.html#disable-gitlab-for-slack-app
   869  func (s *ServicesService) DisableSlackApplication(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
   870  	project, err := parseID(pid)
   871  	if err != nil {
   872  		return nil, err
   873  	}
   874  	u := fmt.Sprintf("projects/%s/integrations/gitlab-slack-application", PathEscape(project))
   875  
   876  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
   877  	if err != nil {
   878  		return nil, err
   879  	}
   880  
   881  	return s.client.Do(req, nil)
   882  }
   883  
   884  // SetGitLabCIServiceOptions represents the available SetGitLabCIService()
   885  // options.
   886  //
   887  // GitLab API docs:
   888  // https://docs.gitlab.com/ee/api/integrations.html#edit-gitlab-ci-service
   889  type SetGitLabCIServiceOptions struct {
   890  	Token      *string `url:"token,omitempty" json:"token,omitempty"`
   891  	ProjectURL *string `url:"project_url,omitempty" json:"project_url,omitempty"`
   892  }
   893  
   894  // SetGitLabCIService sets GitLab CI service for a project.
   895  //
   896  // GitLab API docs:
   897  // https://docs.gitlab.com/ee/api/integrations.html#edit-gitlab-ci-service
   898  func (s *ServicesService) SetGitLabCIService(pid interface{}, opt *SetGitLabCIServiceOptions, options ...RequestOptionFunc) (*Response, error) {
   899  	project, err := parseID(pid)
   900  	if err != nil {
   901  		return nil, err
   902  	}
   903  	u := fmt.Sprintf("projects/%s/services/gitlab-ci", PathEscape(project))
   904  
   905  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
   906  	if err != nil {
   907  		return nil, err
   908  	}
   909  
   910  	return s.client.Do(req, nil)
   911  }
   912  
   913  // DeleteGitLabCIService deletes GitLab CI service settings for a project.
   914  //
   915  // GitLab API docs:
   916  // https://docs.gitlab.com/ee/api/integrations.html#delete-gitlab-ci-service
   917  func (s *ServicesService) DeleteGitLabCIService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
   918  	project, err := parseID(pid)
   919  	if err != nil {
   920  		return nil, err
   921  	}
   922  	u := fmt.Sprintf("projects/%s/services/gitlab-ci", PathEscape(project))
   923  
   924  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
   925  	if err != nil {
   926  		return nil, err
   927  	}
   928  
   929  	return s.client.Do(req, nil)
   930  }
   931  
   932  // SetHipChatServiceOptions represents the available SetHipChatService()
   933  // options.
   934  //
   935  // GitLab API docs:
   936  // https://docs.gitlab.com/ee/api/integrations.html#edit-hipchat-service
   937  type SetHipChatServiceOptions struct {
   938  	Token *string `url:"token,omitempty" json:"token,omitempty" `
   939  	Room  *string `url:"room,omitempty" json:"room,omitempty"`
   940  }
   941  
   942  // SetHipChatService sets HipChat service for a project
   943  //
   944  // GitLab API docs:
   945  // https://docs.gitlab.com/ee/api/integrations.html#edit-hipchat-service
   946  func (s *ServicesService) SetHipChatService(pid interface{}, opt *SetHipChatServiceOptions, options ...RequestOptionFunc) (*Response, error) {
   947  	project, err := parseID(pid)
   948  	if err != nil {
   949  		return nil, err
   950  	}
   951  	u := fmt.Sprintf("projects/%s/services/hipchat", PathEscape(project))
   952  
   953  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
   954  	if err != nil {
   955  		return nil, err
   956  	}
   957  
   958  	return s.client.Do(req, nil)
   959  }
   960  
   961  // DeleteHipChatService deletes HipChat service for project.
   962  //
   963  // GitLab API docs:
   964  // https://docs.gitlab.com/ee/api/integrations.html#delete-hipchat-service
   965  func (s *ServicesService) DeleteHipChatService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
   966  	project, err := parseID(pid)
   967  	if err != nil {
   968  		return nil, err
   969  	}
   970  	u := fmt.Sprintf("projects/%s/services/hipchat", PathEscape(project))
   971  
   972  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
   973  	if err != nil {
   974  		return nil, err
   975  	}
   976  
   977  	return s.client.Do(req, nil)
   978  }
   979  
   980  // JenkinsCIService represents Jenkins CI service settings.
   981  //
   982  // GitLab API docs:
   983  // https://docs.gitlab.com/ee/api/integrations.html#jenkins
   984  type JenkinsCIService struct {
   985  	Service
   986  	Properties *JenkinsCIServiceProperties `json:"properties"`
   987  }
   988  
   989  // JenkinsCIServiceProperties represents Jenkins CI specific properties.
   990  //
   991  // GitLab API docs:
   992  // https://docs.gitlab.com/ee/api/integrations.html#jenkins
   993  type JenkinsCIServiceProperties struct {
   994  	URL                   string `json:"jenkins_url"`
   995  	EnableSSLVerification bool   `json:"enable_ssl_verification"`
   996  	ProjectName           string `json:"project_name"`
   997  	Username              string `json:"username"`
   998  }
   999  
  1000  // GetJenkinsCIService gets Jenkins CI service settings for a project.
  1001  //
  1002  // GitLab API docs:
  1003  // https://docs.gitlab.com/ee/api/integrations.html#get-jenkins-settings
  1004  func (s *ServicesService) GetJenkinsCIService(pid interface{}, options ...RequestOptionFunc) (*JenkinsCIService, *Response, error) {
  1005  	project, err := parseID(pid)
  1006  	if err != nil {
  1007  		return nil, nil, err
  1008  	}
  1009  	u := fmt.Sprintf("projects/%s/services/jenkins", PathEscape(project))
  1010  
  1011  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  1012  	if err != nil {
  1013  		return nil, nil, err
  1014  	}
  1015  
  1016  	svc := new(JenkinsCIService)
  1017  	resp, err := s.client.Do(req, svc)
  1018  	if err != nil {
  1019  		return nil, resp, err
  1020  	}
  1021  
  1022  	return svc, resp, nil
  1023  }
  1024  
  1025  // SetJenkinsCIServiceOptions represents the available SetJenkinsCIService()
  1026  // options.
  1027  //
  1028  // GitLab API docs:
  1029  // https://docs.gitlab.com/ee/api/integrations.html#jenkins
  1030  type SetJenkinsCIServiceOptions struct {
  1031  	URL                   *string `url:"jenkins_url,omitempty" json:"jenkins_url,omitempty"`
  1032  	EnableSSLVerification *bool   `url:"enable_ssl_verification,omitempty" json:"enable_ssl_verification,omitempty"`
  1033  	ProjectName           *string `url:"project_name,omitempty" json:"project_name,omitempty"`
  1034  	Username              *string `url:"username,omitempty" json:"username,omitempty"`
  1035  	Password              *string `url:"password,omitempty" json:"password,omitempty"`
  1036  	PushEvents            *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
  1037  	MergeRequestsEvents   *bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
  1038  	TagPushEvents         *bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
  1039  }
  1040  
  1041  // SetJenkinsCIService sets Jenkins service for a project
  1042  //
  1043  // GitLab API docs:
  1044  // https://docs.gitlab.com/ee/api/integrations.html#set-up-jenkins
  1045  func (s *ServicesService) SetJenkinsCIService(pid interface{}, opt *SetJenkinsCIServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  1046  	project, err := parseID(pid)
  1047  	if err != nil {
  1048  		return nil, err
  1049  	}
  1050  	u := fmt.Sprintf("projects/%s/services/jenkins", PathEscape(project))
  1051  
  1052  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  1053  	if err != nil {
  1054  		return nil, err
  1055  	}
  1056  
  1057  	return s.client.Do(req, nil)
  1058  }
  1059  
  1060  // DeleteJenkinsCIService deletes Jenkins CI service for project.
  1061  //
  1062  // GitLab API docs:
  1063  // https://docs.gitlab.com/ee/api/integrations.html#disable-jenkins
  1064  func (s *ServicesService) DeleteJenkinsCIService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  1065  	project, err := parseID(pid)
  1066  	if err != nil {
  1067  		return nil, err
  1068  	}
  1069  	u := fmt.Sprintf("projects/%s/services/jenkins", PathEscape(project))
  1070  
  1071  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  1072  	if err != nil {
  1073  		return nil, err
  1074  	}
  1075  
  1076  	return s.client.Do(req, nil)
  1077  }
  1078  
  1079  // JiraService represents Jira service settings.
  1080  //
  1081  // GitLab API docs:
  1082  // https://docs.gitlab.com/ee/api/integrations.html#jira
  1083  type JiraService struct {
  1084  	Service
  1085  	Properties *JiraServiceProperties `json:"properties"`
  1086  }
  1087  
  1088  // JiraServiceProperties represents Jira specific properties.
  1089  //
  1090  // GitLab API docs:
  1091  // https://docs.gitlab.com/ee/api/integrations.html#jira
  1092  type JiraServiceProperties struct {
  1093  	URL                   string `json:"url"`
  1094  	APIURL                string `json:"api_url"`
  1095  	ProjectKey            string `json:"project_key" `
  1096  	Username              string `json:"username" `
  1097  	Password              string `json:"password" `
  1098  	JiraIssueTransitionID string `json:"jira_issue_transition_id"`
  1099  }
  1100  
  1101  // UnmarshalJSON decodes the Jira Service Properties.
  1102  //
  1103  // This allows support of JiraIssueTransitionID for both type string (>11.9) and float64 (<11.9)
  1104  func (p *JiraServiceProperties) UnmarshalJSON(b []byte) error {
  1105  	type Alias JiraServiceProperties
  1106  	raw := struct {
  1107  		*Alias
  1108  		JiraIssueTransitionID interface{} `json:"jira_issue_transition_id"`
  1109  	}{
  1110  		Alias: (*Alias)(p),
  1111  	}
  1112  
  1113  	if err := json.Unmarshal(b, &raw); err != nil {
  1114  		return err
  1115  	}
  1116  
  1117  	switch id := raw.JiraIssueTransitionID.(type) {
  1118  	case nil:
  1119  		// No action needed.
  1120  	case string:
  1121  		p.JiraIssueTransitionID = id
  1122  	case float64:
  1123  		p.JiraIssueTransitionID = strconv.Itoa(int(id))
  1124  	default:
  1125  		return fmt.Errorf("failed to unmarshal JiraTransitionID of type: %T", id)
  1126  	}
  1127  
  1128  	return nil
  1129  }
  1130  
  1131  // GetJiraService gets Jira service settings for a project.
  1132  //
  1133  // GitLab API docs:
  1134  // https://docs.gitlab.com/ee/api/integrations.html#get-jira-service-settings
  1135  func (s *ServicesService) GetJiraService(pid interface{}, options ...RequestOptionFunc) (*JiraService, *Response, error) {
  1136  	project, err := parseID(pid)
  1137  	if err != nil {
  1138  		return nil, nil, err
  1139  	}
  1140  	u := fmt.Sprintf("projects/%s/services/jira", PathEscape(project))
  1141  
  1142  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  1143  	if err != nil {
  1144  		return nil, nil, err
  1145  	}
  1146  
  1147  	svc := new(JiraService)
  1148  	resp, err := s.client.Do(req, svc)
  1149  	if err != nil {
  1150  		return nil, resp, err
  1151  	}
  1152  
  1153  	return svc, resp, nil
  1154  }
  1155  
  1156  // SetJiraServiceOptions represents the available SetJiraService()
  1157  // options.
  1158  //
  1159  // GitLab API docs:
  1160  // https://docs.gitlab.com/ee/api/integrations.html#edit-jira-service
  1161  type SetJiraServiceOptions struct {
  1162  	URL                   *string `url:"url,omitempty" json:"url,omitempty"`
  1163  	APIURL                *string `url:"api_url,omitempty" json:"api_url,omitempty"`
  1164  	ProjectKey            *string `url:"project_key,omitempty" json:"project_key,omitempty" `
  1165  	Username              *string `url:"username,omitempty" json:"username,omitempty" `
  1166  	Password              *string `url:"password,omitempty" json:"password,omitempty" `
  1167  	Active                *bool   `url:"active,omitempty" json:"active,omitempty"`
  1168  	JiraIssueTransitionID *string `url:"jira_issue_transition_id,omitempty" json:"jira_issue_transition_id,omitempty"`
  1169  	CommitEvents          *bool   `url:"commit_events,omitempty" json:"commit_events,omitempty"`
  1170  	MergeRequestsEvents   *bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
  1171  	CommentOnEventEnabled *bool   `url:"comment_on_event_enabled,omitempty" json:"comment_on_event_enabled,omitempty"`
  1172  }
  1173  
  1174  // SetJiraService sets Jira service for a project
  1175  //
  1176  // GitLab API docs:
  1177  // https://docs.gitlab.com/ee/api/integrations.html#edit-jira-service
  1178  func (s *ServicesService) SetJiraService(pid interface{}, opt *SetJiraServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  1179  	project, err := parseID(pid)
  1180  	if err != nil {
  1181  		return nil, err
  1182  	}
  1183  	u := fmt.Sprintf("projects/%s/services/jira", PathEscape(project))
  1184  
  1185  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  1186  	if err != nil {
  1187  		return nil, err
  1188  	}
  1189  
  1190  	return s.client.Do(req, nil)
  1191  }
  1192  
  1193  // DeleteJiraService deletes Jira service for project.
  1194  //
  1195  // GitLab API docs:
  1196  // https://docs.gitlab.com/ee/api/integrations.html#delete-jira-service
  1197  func (s *ServicesService) DeleteJiraService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  1198  	project, err := parseID(pid)
  1199  	if err != nil {
  1200  		return nil, err
  1201  	}
  1202  	u := fmt.Sprintf("projects/%s/services/jira", PathEscape(project))
  1203  
  1204  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  1205  	if err != nil {
  1206  		return nil, err
  1207  	}
  1208  
  1209  	return s.client.Do(req, nil)
  1210  }
  1211  
  1212  // MattermostService represents Mattermost service settings.
  1213  //
  1214  // GitLab API docs:
  1215  // https://docs.gitlab.com/ee/api/integrations.html#mattermost-notifications
  1216  type MattermostService struct {
  1217  	Service
  1218  	Properties *MattermostServiceProperties `json:"properties"`
  1219  }
  1220  
  1221  // MattermostServiceProperties represents Mattermost specific properties.
  1222  //
  1223  // GitLab API docs:
  1224  // https://docs.gitlab.com/ee/api/integrations.html#mattermost-notifications
  1225  type MattermostServiceProperties struct {
  1226  	WebHook                   string    `json:"webhook"`
  1227  	Username                  string    `json:"username"`
  1228  	Channel                   string    `json:"channel"`
  1229  	NotifyOnlyBrokenPipelines BoolValue `json:"notify_only_broken_pipelines"`
  1230  	BranchesToBeNotified      string    `json:"branches_to_be_notified"`
  1231  	ConfidentialIssueChannel  string    `json:"confidential_issue_channel"`
  1232  	ConfidentialNoteChannel   string    `json:"confidential_note_channel"`
  1233  	IssueChannel              string    `json:"issue_channel"`
  1234  	MergeRequestChannel       string    `json:"merge_request_channel"`
  1235  	NoteChannel               string    `json:"note_channel"`
  1236  	TagPushChannel            string    `json:"tag_push_channel"`
  1237  	PipelineChannel           string    `json:"pipeline_channel"`
  1238  	PushChannel               string    `json:"push_channel"`
  1239  	VulnerabilityChannel      string    `json:"vulnerability_channel"`
  1240  	WikiPageChannel           string    `json:"wiki_page_channel"`
  1241  }
  1242  
  1243  // GetMattermostService gets Mattermost service settings for a project.
  1244  //
  1245  // GitLab API docs:
  1246  // https://docs.gitlab.com/ee/api/integrations.html#get-slack-service-settings
  1247  func (s *ServicesService) GetMattermostService(pid interface{}, options ...RequestOptionFunc) (*MattermostService, *Response, error) {
  1248  	project, err := parseID(pid)
  1249  	if err != nil {
  1250  		return nil, nil, err
  1251  	}
  1252  	u := fmt.Sprintf("projects/%s/services/mattermost", PathEscape(project))
  1253  
  1254  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  1255  	if err != nil {
  1256  		return nil, nil, err
  1257  	}
  1258  
  1259  	svc := new(MattermostService)
  1260  	resp, err := s.client.Do(req, svc)
  1261  	if err != nil {
  1262  		return nil, resp, err
  1263  	}
  1264  
  1265  	return svc, resp, nil
  1266  }
  1267  
  1268  // SetMattermostServiceOptions represents the available SetMattermostService()
  1269  // options.
  1270  //
  1271  // GitLab API docs:
  1272  // https://docs.gitlab.com/ee/api/integrations.html#createedit-mattermost-notifications-service
  1273  type SetMattermostServiceOptions struct {
  1274  	WebHook                   *string `url:"webhook,omitempty" json:"webhook,omitempty"`
  1275  	Username                  *string `url:"username,omitempty" json:"username,omitempty"`
  1276  	Channel                   *string `url:"channel,omitempty" json:"channel,omitempty"`
  1277  	NotifyOnlyBrokenPipelines *bool   `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
  1278  	BranchesToBeNotified      *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
  1279  	PushEvents                *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
  1280  	IssuesEvents              *bool   `url:"issues_events,omitempty" json:"issues_events,omitempty"`
  1281  	ConfidentialIssuesEvents  *bool   `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"`
  1282  	MergeRequestsEvents       *bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
  1283  	TagPushEvents             *bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
  1284  	NoteEvents                *bool   `url:"note_events,omitempty" json:"note_events,omitempty"`
  1285  	ConfidentialNoteChannel   *string `url:"confidential_note_channel,omitempty" json:"confidential_note_channel,omitempty"`
  1286  	PipelineEvents            *bool   `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
  1287  	WikiPageEvents            *bool   `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
  1288  	PushChannel               *string `url:"push_channel,omitempty" json:"push_channel,omitempty"`
  1289  	IssueChannel              *string `url:"issue_channel,omitempty" json:"issue_channel,omitempty"`
  1290  	ConfidentialIssueChannel  *string `url:"confidential_issue_channel,omitempty" json:"confidential_issue_channel,omitempty"`
  1291  	MergeRequestChannel       *string `url:"merge_request_channel,omitempty" json:"merge_request_channel,omitempty"`
  1292  	NoteChannel               *string `url:"note_channel,omitempty" json:"note_channel,omitempty"`
  1293  	ConfidentialNoteEvents    *bool   `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"`
  1294  	TagPushChannel            *string `url:"tag_push_channel,omitempty" json:"tag_push_channel,omitempty"`
  1295  	PipelineChannel           *string `url:"pipeline_channel,omitempty" json:"pipeline_channel,omitempty"`
  1296  	WikiPageChannel           *string `url:"wiki_page_channel,omitempty" json:"wiki_page_channel,omitempty"`
  1297  }
  1298  
  1299  // MattermostSlashCommandsService represents Mattermost slash commands settings.
  1300  //
  1301  // GitLab API docs:
  1302  // https://docs.gitlab.com/ee/api/integrations.html#mattermost-slash-commands
  1303  type MattermostSlashCommandsService struct {
  1304  	Service
  1305  	Properties *MattermostSlashCommandsProperties `json:"properties"`
  1306  }
  1307  
  1308  // MattermostSlashCommandsProperties represents Mattermost slash commands specific properties.
  1309  //
  1310  // GitLab API docs:
  1311  // https://docs.gitlab.com/ee/api/integrations.html#mattermost-slash-commands
  1312  type MattermostSlashCommandsProperties struct {
  1313  	Token    string `json:"token"`
  1314  	Username string `json:"username,omitempty"`
  1315  }
  1316  
  1317  // GetMattermostSlashCommandsService gets Slack Mattermost commands service settings for a project.
  1318  //
  1319  // GitLab API docs:
  1320  // https://docs.gitlab.com/ee/api/integrations.html#get-mattermost-slash-command-integration-settings
  1321  func (s *ServicesService) GetMattermostSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*MattermostSlashCommandsService, *Response, error) {
  1322  	project, err := parseID(pid)
  1323  	if err != nil {
  1324  		return nil, nil, err
  1325  	}
  1326  	u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
  1327  
  1328  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  1329  	if err != nil {
  1330  		return nil, nil, err
  1331  	}
  1332  
  1333  	svc := new(MattermostSlashCommandsService)
  1334  	resp, err := s.client.Do(req, svc)
  1335  	if err != nil {
  1336  		return nil, resp, err
  1337  	}
  1338  
  1339  	return svc, resp, nil
  1340  }
  1341  
  1342  // SetMattermostSlashCommandsServiceOptions represents the available SetSlackSlashCommandsService()
  1343  // options.
  1344  //
  1345  // GitLab API docs:
  1346  // https://docs.gitlab.com/ee/api/integrations.html#get-mattermost-slash-command-integration-settings
  1347  type SetMattermostSlashCommandsServiceOptions struct {
  1348  	Token    *string `url:"token,omitempty" json:"token,omitempty"`
  1349  	Username *string `url:"username,omitempty" json:"username,omitempty"`
  1350  }
  1351  
  1352  // SetMattermostSlashCommandsService sets Mattermost slash commands service for a project
  1353  //
  1354  // GitLab API docs:
  1355  // https://docs.gitlab.com/ee/api/integrations.html#createedit-mattermost-slash-command-integration
  1356  func (s *ServicesService) SetMattermostSlashCommandsService(pid interface{}, opt *SetMattermostSlashCommandsServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  1357  	project, err := parseID(pid)
  1358  	if err != nil {
  1359  		return nil, err
  1360  	}
  1361  	u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
  1362  
  1363  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  1364  	if err != nil {
  1365  		return nil, err
  1366  	}
  1367  
  1368  	return s.client.Do(req, nil)
  1369  }
  1370  
  1371  // DeleteMattermostSlashCommandsService deletes Mattermost slash commands service for project.
  1372  //
  1373  // GitLab API docs:
  1374  // https://docs.gitlab.com/ee/api/integrations.html#disable-mattermost-slash-command-integration
  1375  func (s *ServicesService) DeleteMattermostSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  1376  	project, err := parseID(pid)
  1377  	if err != nil {
  1378  		return nil, err
  1379  	}
  1380  	u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
  1381  
  1382  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  1383  	if err != nil {
  1384  		return nil, err
  1385  	}
  1386  
  1387  	return s.client.Do(req, nil)
  1388  }
  1389  
  1390  // SetMattermostService sets Mattermost service for a project.
  1391  //
  1392  // GitLab API docs:
  1393  // https://docs.gitlab.com/ee/api/integrations.html#createedit-mattermost-notifications-service
  1394  func (s *ServicesService) SetMattermostService(pid interface{}, opt *SetMattermostServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  1395  	project, err := parseID(pid)
  1396  	if err != nil {
  1397  		return nil, err
  1398  	}
  1399  	u := fmt.Sprintf("projects/%s/services/mattermost", PathEscape(project))
  1400  
  1401  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  1402  	if err != nil {
  1403  		return nil, err
  1404  	}
  1405  
  1406  	return s.client.Do(req, nil)
  1407  }
  1408  
  1409  // DeleteMattermostService deletes Mattermost service for project.
  1410  //
  1411  // GitLab API docs:
  1412  // https://docs.gitlab.com/ee/api/integrations.html#delete-mattermost-notifications-service
  1413  func (s *ServicesService) DeleteMattermostService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  1414  	project, err := parseID(pid)
  1415  	if err != nil {
  1416  		return nil, err
  1417  	}
  1418  	u := fmt.Sprintf("projects/%s/services/mattermost", PathEscape(project))
  1419  
  1420  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  1421  	if err != nil {
  1422  		return nil, err
  1423  	}
  1424  
  1425  	return s.client.Do(req, nil)
  1426  }
  1427  
  1428  // MicrosoftTeamsService represents Microsoft Teams service settings.
  1429  //
  1430  // GitLab API docs:
  1431  // https://docs.gitlab.com/ee/api/integrations.html#microsoft-teams
  1432  type MicrosoftTeamsService struct {
  1433  	Service
  1434  	Properties *MicrosoftTeamsServiceProperties `json:"properties"`
  1435  }
  1436  
  1437  // MicrosoftTeamsServiceProperties represents Microsoft Teams specific properties.
  1438  //
  1439  // GitLab API docs:
  1440  // https://docs.gitlab.com/ee/api/integrations.html#microsoft-teams
  1441  type MicrosoftTeamsServiceProperties struct {
  1442  	WebHook                   string    `json:"webhook"`
  1443  	NotifyOnlyBrokenPipelines BoolValue `json:"notify_only_broken_pipelines"`
  1444  	BranchesToBeNotified      string    `json:"branches_to_be_notified"`
  1445  	IssuesEvents              BoolValue `json:"issues_events"`
  1446  	ConfidentialIssuesEvents  BoolValue `json:"confidential_issues_events"`
  1447  	MergeRequestsEvents       BoolValue `json:"merge_requests_events"`
  1448  	TagPushEvents             BoolValue `json:"tag_push_events"`
  1449  	NoteEvents                BoolValue `json:"note_events"`
  1450  	ConfidentialNoteEvents    BoolValue `json:"confidential_note_events"`
  1451  	PipelineEvents            BoolValue `json:"pipeline_events"`
  1452  	WikiPageEvents            BoolValue `json:"wiki_page_events"`
  1453  }
  1454  
  1455  // GetMicrosoftTeamsService gets MicrosoftTeams service settings for a project.
  1456  //
  1457  // GitLab API docs:
  1458  // https://docs.gitlab.com/ee/api/integrations.html#get-microsoft-teams-service-settings
  1459  func (s *ServicesService) GetMicrosoftTeamsService(pid interface{}, options ...RequestOptionFunc) (*MicrosoftTeamsService, *Response, error) {
  1460  	project, err := parseID(pid)
  1461  	if err != nil {
  1462  		return nil, nil, err
  1463  	}
  1464  	u := fmt.Sprintf("projects/%s/services/microsoft-teams", PathEscape(project))
  1465  
  1466  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  1467  	if err != nil {
  1468  		return nil, nil, err
  1469  	}
  1470  
  1471  	svc := new(MicrosoftTeamsService)
  1472  	resp, err := s.client.Do(req, svc)
  1473  	if err != nil {
  1474  		return nil, resp, err
  1475  	}
  1476  
  1477  	return svc, resp, nil
  1478  }
  1479  
  1480  // SetMicrosoftTeamsServiceOptions represents the available SetMicrosoftTeamsService()
  1481  // options.
  1482  //
  1483  // GitLab API docs:
  1484  // https://docs.gitlab.com/ee/api/integrations.html#create-edit-microsoft-teams-service
  1485  type SetMicrosoftTeamsServiceOptions struct {
  1486  	WebHook                   *string `url:"webhook,omitempty" json:"webhook,omitempty"`
  1487  	NotifyOnlyBrokenPipelines *bool   `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
  1488  	BranchesToBeNotified      *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
  1489  	PushEvents                *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
  1490  	IssuesEvents              *bool   `url:"issues_events,omitempty" json:"issues_events,omitempty"`
  1491  	ConfidentialIssuesEvents  *bool   `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"`
  1492  	MergeRequestsEvents       *bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
  1493  	TagPushEvents             *bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
  1494  	NoteEvents                *bool   `url:"note_events,omitempty" json:"note_events,omitempty"`
  1495  	ConfidentialNoteEvents    *bool   `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"`
  1496  	PipelineEvents            *bool   `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
  1497  	WikiPageEvents            *bool   `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
  1498  }
  1499  
  1500  // SetMicrosoftTeamsService sets Microsoft Teams service for a project
  1501  //
  1502  // GitLab API docs:
  1503  // https://docs.gitlab.com/ee/api/integrations.html#create-edit-microsoft-teams-service
  1504  func (s *ServicesService) SetMicrosoftTeamsService(pid interface{}, opt *SetMicrosoftTeamsServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  1505  	project, err := parseID(pid)
  1506  	if err != nil {
  1507  		return nil, err
  1508  	}
  1509  	u := fmt.Sprintf("projects/%s/services/microsoft-teams", PathEscape(project))
  1510  
  1511  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  1512  	if err != nil {
  1513  		return nil, err
  1514  	}
  1515  	return s.client.Do(req, nil)
  1516  }
  1517  
  1518  // DeleteMicrosoftTeamsService deletes Microsoft Teams service for project.
  1519  //
  1520  // GitLab API docs:
  1521  // https://docs.gitlab.com/ee/api/integrations.html#delete-microsoft-teams-service
  1522  func (s *ServicesService) DeleteMicrosoftTeamsService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  1523  	project, err := parseID(pid)
  1524  	if err != nil {
  1525  		return nil, err
  1526  	}
  1527  	u := fmt.Sprintf("projects/%s/services/microsoft-teams", PathEscape(project))
  1528  
  1529  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  1530  	if err != nil {
  1531  		return nil, err
  1532  	}
  1533  
  1534  	return s.client.Do(req, nil)
  1535  }
  1536  
  1537  // PipelinesEmailService represents Pipelines Email service settings.
  1538  //
  1539  // GitLab API docs:
  1540  // https://docs.gitlab.com/ee/api/integrations.html#pipeline-emails
  1541  type PipelinesEmailService struct {
  1542  	Service
  1543  	Properties *PipelinesEmailProperties `json:"properties"`
  1544  }
  1545  
  1546  // PipelinesEmailProperties represents PipelinesEmail specific properties.
  1547  //
  1548  // GitLab API docs:
  1549  // https://docs.gitlab.com/ee/api/integrations.html#pipeline-emails
  1550  type PipelinesEmailProperties struct {
  1551  	Recipients                string    `json:"recipients"`
  1552  	NotifyOnlyBrokenPipelines BoolValue `json:"notify_only_broken_pipelines"`
  1553  	NotifyOnlyDefaultBranch   BoolValue `json:"notify_only_default_branch"`
  1554  	BranchesToBeNotified      string    `json:"branches_to_be_notified"`
  1555  }
  1556  
  1557  // GetPipelinesEmailService gets Pipelines Email service settings for a project.
  1558  //
  1559  // GitLab API docs:
  1560  // https://docs.gitlab.com/ee/api/integrations.html#get-pipeline-emails-service-settings
  1561  func (s *ServicesService) GetPipelinesEmailService(pid interface{}, options ...RequestOptionFunc) (*PipelinesEmailService, *Response, error) {
  1562  	project, err := parseID(pid)
  1563  	if err != nil {
  1564  		return nil, nil, err
  1565  	}
  1566  	u := fmt.Sprintf("projects/%s/services/pipelines-email", PathEscape(project))
  1567  
  1568  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  1569  	if err != nil {
  1570  		return nil, nil, err
  1571  	}
  1572  
  1573  	svc := new(PipelinesEmailService)
  1574  	resp, err := s.client.Do(req, svc)
  1575  	if err != nil {
  1576  		return nil, resp, err
  1577  	}
  1578  
  1579  	return svc, resp, nil
  1580  }
  1581  
  1582  // SetPipelinesEmailServiceOptions represents the available
  1583  // SetPipelinesEmailService() options.
  1584  //
  1585  // GitLab API docs:
  1586  // https://docs.gitlab.com/ee/api/integrations.html#pipeline-emails
  1587  type SetPipelinesEmailServiceOptions struct {
  1588  	Recipients                *string `url:"recipients,omitempty" json:"recipients,omitempty"`
  1589  	NotifyOnlyBrokenPipelines *bool   `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
  1590  	NotifyOnlyDefaultBranch   *bool   `url:"notify_only_default_branch,omitempty" json:"notify_only_default_branch,omitempty"`
  1591  	AddPusher                 *bool   `url:"add_pusher,omitempty" json:"add_pusher,omitempty"`
  1592  	BranchesToBeNotified      *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
  1593  	PipelineEvents            *bool   `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
  1594  }
  1595  
  1596  // SetPipelinesEmailService sets Pipelines Email service for a project.
  1597  //
  1598  // GitLab API docs:
  1599  // https://docs.gitlab.com/ee/api/integrations.html#pipeline-emails
  1600  func (s *ServicesService) SetPipelinesEmailService(pid interface{}, opt *SetPipelinesEmailServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  1601  	project, err := parseID(pid)
  1602  	if err != nil {
  1603  		return nil, err
  1604  	}
  1605  	u := fmt.Sprintf("projects/%s/services/pipelines-email", PathEscape(project))
  1606  
  1607  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  1608  	if err != nil {
  1609  		return nil, err
  1610  	}
  1611  
  1612  	return s.client.Do(req, nil)
  1613  }
  1614  
  1615  // DeletePipelinesEmailService deletes Pipelines Email service settings for a project.
  1616  //
  1617  // GitLab API docs:
  1618  // https://docs.gitlab.com/ee/api/integrations.html#delete-pipeline-emails-service
  1619  func (s *ServicesService) DeletePipelinesEmailService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  1620  	project, err := parseID(pid)
  1621  	if err != nil {
  1622  		return nil, err
  1623  	}
  1624  	u := fmt.Sprintf("projects/%s/services/pipelines-email", PathEscape(project))
  1625  
  1626  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  1627  	if err != nil {
  1628  		return nil, err
  1629  	}
  1630  
  1631  	return s.client.Do(req, nil)
  1632  }
  1633  
  1634  // PrometheusService represents Prometheus service settings.
  1635  //
  1636  // GitLab API docs:
  1637  // https://docs.gitlab.com/ee/api/integrations.html#prometheus
  1638  type PrometheusService struct {
  1639  	Service
  1640  	Properties *PrometheusServiceProperties `json:"properties"`
  1641  }
  1642  
  1643  // PrometheusServiceProperties represents Prometheus specific properties.
  1644  //
  1645  // GitLab API docs:
  1646  // https://docs.gitlab.com/ee/api/integrations.html#prometheus
  1647  type PrometheusServiceProperties struct {
  1648  	APIURL                      string `json:"api_url"`
  1649  	GoogleIAPAudienceClientID   string `json:"google_iap_audience_client_id"`
  1650  	GoogleIAPServiceAccountJSON string `json:"google_iap_service_account_json"`
  1651  }
  1652  
  1653  // GetPrometheusService gets Prometheus service settings for a project.
  1654  //
  1655  // GitLab API docs:
  1656  // https://docs.gitlab.com/ee/api/integrations.html#get-prometheus-service-settings
  1657  func (s *ServicesService) GetPrometheusService(pid interface{}, options ...RequestOptionFunc) (*PrometheusService, *Response, error) {
  1658  	project, err := parseID(pid)
  1659  	if err != nil {
  1660  		return nil, nil, err
  1661  	}
  1662  	u := fmt.Sprintf("projects/%s/services/prometheus", PathEscape(project))
  1663  
  1664  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  1665  	if err != nil {
  1666  		return nil, nil, err
  1667  	}
  1668  
  1669  	svc := new(PrometheusService)
  1670  	resp, err := s.client.Do(req, svc)
  1671  	if err != nil {
  1672  		return nil, resp, err
  1673  	}
  1674  
  1675  	return svc, resp, nil
  1676  }
  1677  
  1678  // SetPrometheusServiceOptions represents the available SetPrometheusService()
  1679  // options.
  1680  //
  1681  // GitLab API docs:
  1682  // https://docs.gitlab.com/ee/api/integrations.html#createedit-prometheus-service
  1683  type SetPrometheusServiceOptions struct {
  1684  	APIURL                      *string `url:"api_url,omitempty" json:"api_url,omitempty"`
  1685  	GoogleIAPAudienceClientID   *string `url:"google_iap_audience_client_id,omitempty" json:"google_iap_audience_client_id,omitempty"`
  1686  	GoogleIAPServiceAccountJSON *string `url:"google_iap_service_account_json,omitempty" json:"google_iap_service_account_json,omitempty"`
  1687  }
  1688  
  1689  // SetPrometheusService sets Prometheus service for a project.
  1690  //
  1691  // GitLab API docs:
  1692  // https://docs.gitlab.com/ee/api/integrations.html#createedit-prometheus-service
  1693  func (s *ServicesService) SetPrometheusService(pid interface{}, opt *SetPrometheusServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  1694  	project, err := parseID(pid)
  1695  	if err != nil {
  1696  		return nil, err
  1697  	}
  1698  	u := fmt.Sprintf("projects/%s/services/prometheus", PathEscape(project))
  1699  
  1700  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  1701  	if err != nil {
  1702  		return nil, err
  1703  	}
  1704  
  1705  	return s.client.Do(req, nil)
  1706  }
  1707  
  1708  // DeletePrometheusService deletes Prometheus service settings for a project.
  1709  //
  1710  // GitLab API docs:
  1711  // https://docs.gitlab.com/ee/api/integrations.html#delete-prometheus-service
  1712  func (s *ServicesService) DeletePrometheusService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  1713  	project, err := parseID(pid)
  1714  	if err != nil {
  1715  		return nil, err
  1716  	}
  1717  	u := fmt.Sprintf("projects/%s/services/prometheus", PathEscape(project))
  1718  
  1719  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  1720  	if err != nil {
  1721  		return nil, err
  1722  	}
  1723  
  1724  	return s.client.Do(req, nil)
  1725  }
  1726  
  1727  // SlackService represents Slack service settings.
  1728  //
  1729  // GitLab API docs:
  1730  // https://docs.gitlab.com/ee/api/integrations.html#slack
  1731  type SlackService struct {
  1732  	Service
  1733  	Properties *SlackServiceProperties `json:"properties"`
  1734  }
  1735  
  1736  // SlackServiceProperties represents Slack specific properties.
  1737  //
  1738  // GitLab API docs:
  1739  // https://docs.gitlab.com/ee/api/integrations.html#slack
  1740  type SlackServiceProperties struct {
  1741  	WebHook                   string    `json:"webhook"`
  1742  	Username                  string    `json:"username"`
  1743  	Channel                   string    `json:"channel"`
  1744  	NotifyOnlyBrokenPipelines BoolValue `json:"notify_only_broken_pipelines"`
  1745  	NotifyOnlyDefaultBranch   BoolValue `json:"notify_only_default_branch"`
  1746  	BranchesToBeNotified      string    `json:"branches_to_be_notified"`
  1747  	AlertChannel              string    `json:"alert_channel"`
  1748  	ConfidentialIssueChannel  string    `json:"confidential_issue_channel"`
  1749  	ConfidentialNoteChannel   string    `json:"confidential_note_channel"`
  1750  	DeploymentChannel         string    `json:"deployment_channel"`
  1751  	IssueChannel              string    `json:"issue_channel"`
  1752  	MergeRequestChannel       string    `json:"merge_request_channel"`
  1753  	NoteChannel               string    `json:"note_channel"`
  1754  	TagPushChannel            string    `json:"tag_push_channel"`
  1755  	PipelineChannel           string    `json:"pipeline_channel"`
  1756  	PushChannel               string    `json:"push_channel"`
  1757  	VulnerabilityChannel      string    `json:"vulnerability_channel"`
  1758  	WikiPageChannel           string    `json:"wiki_page_channel"`
  1759  }
  1760  
  1761  // GetSlackService gets Slack service settings for a project.
  1762  //
  1763  // GitLab API docs:
  1764  // https://docs.gitlab.com/ee/api/integrations.html#get-slack-service-settings
  1765  func (s *ServicesService) GetSlackService(pid interface{}, options ...RequestOptionFunc) (*SlackService, *Response, error) {
  1766  	project, err := parseID(pid)
  1767  	if err != nil {
  1768  		return nil, nil, err
  1769  	}
  1770  	u := fmt.Sprintf("projects/%s/services/slack", PathEscape(project))
  1771  
  1772  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  1773  	if err != nil {
  1774  		return nil, nil, err
  1775  	}
  1776  
  1777  	svc := new(SlackService)
  1778  	resp, err := s.client.Do(req, svc)
  1779  	if err != nil {
  1780  		return nil, resp, err
  1781  	}
  1782  
  1783  	return svc, resp, nil
  1784  }
  1785  
  1786  // SetSlackServiceOptions represents the available SetSlackService()
  1787  // options.
  1788  //
  1789  // GitLab API docs:
  1790  // https://docs.gitlab.com/ee/api/integrations.html#edit-slack-service
  1791  type SetSlackServiceOptions struct {
  1792  	WebHook                   *string `url:"webhook,omitempty" json:"webhook,omitempty"`
  1793  	Username                  *string `url:"username,omitempty" json:"username,omitempty"`
  1794  	Channel                   *string `url:"channel,omitempty" json:"channel,omitempty"`
  1795  	NotifyOnlyBrokenPipelines *bool   `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
  1796  	NotifyOnlyDefaultBranch   *bool   `url:"notify_only_default_branch,omitempty" json:"notify_only_default_branch,omitempty"`
  1797  	BranchesToBeNotified      *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
  1798  	AlertChannel              *string `url:"alert_channel,omitempty" json:"alert_channel,omitempty"`
  1799  	AlertEvents               *bool   `url:"alert_events,omitempty" json:"alert_events,omitempty"`
  1800  	ConfidentialIssueChannel  *string `url:"confidential_issue_channel,omitempty" json:"confidential_issue_channel,omitempty"`
  1801  	ConfidentialIssuesEvents  *bool   `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"`
  1802  	ConfidentialNoteChannel   *string `url:"confidential_note_channel,omitempty" json:"confidential_note_channel,omitempty"`
  1803  	ConfidentialNoteEvents    *bool   `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"`
  1804  	DeploymentChannel         *string `url:"deployment_channel,omitempty" json:"deployment_channel,omitempty"`
  1805  	DeploymentEvents          *bool   `url:"deployment_events,omitempty" json:"deployment_events,omitempty"`
  1806  	IssueChannel              *string `url:"issue_channel,omitempty" json:"issue_channel,omitempty"`
  1807  	IssuesEvents              *bool   `url:"issues_events,omitempty" json:"issues_events,omitempty"`
  1808  	MergeRequestChannel       *string `url:"merge_request_channel,omitempty" json:"merge_request_channel,omitempty"`
  1809  	MergeRequestsEvents       *bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
  1810  	NoteChannel               *string `url:"note_channel,omitempty" json:"note_channel,omitempty"`
  1811  	NoteEvents                *bool   `url:"note_events,omitempty" json:"note_events,omitempty"`
  1812  	PipelineChannel           *string `url:"pipeline_channel,omitempty" json:"pipeline_channel,omitempty"`
  1813  	PipelineEvents            *bool   `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
  1814  	PushChannel               *string `url:"push_channel,omitempty" json:"push_channel,omitempty"`
  1815  	PushEvents                *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
  1816  	TagPushChannel            *string `url:"tag_push_channel,omitempty" json:"tag_push_channel,omitempty"`
  1817  	TagPushEvents             *bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
  1818  	WikiPageChannel           *string `url:"wiki_page_channel,omitempty" json:"wiki_page_channel,omitempty"`
  1819  	WikiPageEvents            *bool   `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
  1820  }
  1821  
  1822  // SetSlackService sets Slack service for a project
  1823  //
  1824  // GitLab API docs:
  1825  // https://docs.gitlab.com/ee/api/integrations.html#edit-slack-service
  1826  func (s *ServicesService) SetSlackService(pid interface{}, opt *SetSlackServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  1827  	project, err := parseID(pid)
  1828  	if err != nil {
  1829  		return nil, err
  1830  	}
  1831  	u := fmt.Sprintf("projects/%s/services/slack", PathEscape(project))
  1832  
  1833  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  1834  	if err != nil {
  1835  		return nil, err
  1836  	}
  1837  
  1838  	return s.client.Do(req, nil)
  1839  }
  1840  
  1841  // DeleteSlackService deletes Slack service for project.
  1842  //
  1843  // GitLab API docs:
  1844  // https://docs.gitlab.com/ee/api/integrations.html#delete-slack-service
  1845  func (s *ServicesService) DeleteSlackService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  1846  	project, err := parseID(pid)
  1847  	if err != nil {
  1848  		return nil, err
  1849  	}
  1850  	u := fmt.Sprintf("projects/%s/services/slack", PathEscape(project))
  1851  
  1852  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  1853  	if err != nil {
  1854  		return nil, err
  1855  	}
  1856  
  1857  	return s.client.Do(req, nil)
  1858  }
  1859  
  1860  // SlackSlashCommandsService represents Slack slash commands settings.
  1861  //
  1862  // GitLab API docs:
  1863  // https://docs.gitlab.com/ee/api/integrations.html#slack-slash-commands
  1864  type SlackSlashCommandsService struct {
  1865  	Service
  1866  	Properties *SlackSlashCommandsProperties `json:"properties"`
  1867  }
  1868  
  1869  // SlackSlashCommandsProperties represents Slack slash commands specific properties.
  1870  //
  1871  // GitLab API docs:
  1872  // https://docs.gitlab.com/ee/api/integrations.html#slack-slash-commands
  1873  type SlackSlashCommandsProperties struct {
  1874  	Token string `json:"token"`
  1875  }
  1876  
  1877  // GetSlackSlashCommandsService gets Slack slash commands service settings for a project.
  1878  //
  1879  // GitLab API docs:
  1880  // https://docs.gitlab.com/ee/api/integrations.html#get-slack-slash-command-integration-settings
  1881  func (s *ServicesService) GetSlackSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*SlackSlashCommandsService, *Response, error) {
  1882  	project, err := parseID(pid)
  1883  	if err != nil {
  1884  		return nil, nil, err
  1885  	}
  1886  	u := fmt.Sprintf("projects/%s/services/slack-slash-commands", PathEscape(project))
  1887  
  1888  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  1889  	if err != nil {
  1890  		return nil, nil, err
  1891  	}
  1892  
  1893  	svc := new(SlackSlashCommandsService)
  1894  	resp, err := s.client.Do(req, svc)
  1895  	if err != nil {
  1896  		return nil, resp, err
  1897  	}
  1898  
  1899  	return svc, resp, nil
  1900  }
  1901  
  1902  // SetSlackSlashCommandsServiceOptions represents the available SetSlackSlashCommandsService()
  1903  // options.
  1904  //
  1905  // GitLab API docs:
  1906  // https://docs.gitlab.com/ee/api/integrations.html#createedit-slack-slash-command-service
  1907  type SetSlackSlashCommandsServiceOptions struct {
  1908  	Token *string `url:"token,omitempty" json:"token,omitempty"`
  1909  }
  1910  
  1911  // SetSlackSlashCommandsService sets Slack slash commands service for a project
  1912  //
  1913  // GitLab API docs:
  1914  // https://docs.gitlab.com/13.12/ee/api/integrations.html#createedit-slack-slash-command-service
  1915  func (s *ServicesService) SetSlackSlashCommandsService(pid interface{}, opt *SetSlackSlashCommandsServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  1916  	project, err := parseID(pid)
  1917  	if err != nil {
  1918  		return nil, err
  1919  	}
  1920  	u := fmt.Sprintf("projects/%s/services/slack-slash-commands", PathEscape(project))
  1921  
  1922  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  1923  	if err != nil {
  1924  		return nil, err
  1925  	}
  1926  
  1927  	return s.client.Do(req, nil)
  1928  }
  1929  
  1930  // DeleteSlackSlashCommandsService deletes Slack slash commands service for project.
  1931  //
  1932  // GitLab API docs:
  1933  // https://docs.gitlab.com/13.12/ee/api/integrations.html#delete-slack-slash-command-service
  1934  func (s *ServicesService) DeleteSlackSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  1935  	project, err := parseID(pid)
  1936  	if err != nil {
  1937  		return nil, err
  1938  	}
  1939  	u := fmt.Sprintf("projects/%s/services/slack-slash-commands", PathEscape(project))
  1940  
  1941  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  1942  	if err != nil {
  1943  		return nil, err
  1944  	}
  1945  
  1946  	return s.client.Do(req, nil)
  1947  }
  1948  
  1949  // TelegramService represents Telegram service settings.
  1950  //
  1951  // Gitlab API docs:
  1952  // https://docs.gitlab.com/ee/api/integrations.html#telegram
  1953  type TelegramService struct {
  1954  	Service
  1955  	Properties *TelegramServiceProperties `json:"properties"`
  1956  }
  1957  
  1958  // TelegramServiceProperties represents Telegram specific properties.
  1959  //
  1960  // GitLab API docs:
  1961  // https://docs.gitlab.com/ee/api/integrations.html#set-up-telegram
  1962  type TelegramServiceProperties struct {
  1963  	Room                      string `json:"room"`
  1964  	NotifyOnlyBrokenPipelines bool   `json:"notify_only_broken_pipelines"`
  1965  	BranchesToBeNotified      string `json:"branches_to_be_notified"`
  1966  }
  1967  
  1968  // GetTelegramService gets MicrosoftTeams service settings for a project.
  1969  //
  1970  // GitLab API docs:
  1971  // https://docs.gitlab.com/ee/api/integrations.html#get-telegram-settings
  1972  func (s *ServicesService) GetTelegramService(pid interface{}, options ...RequestOptionFunc) (*TelegramService, *Response, error) {
  1973  	project, err := parseID(pid)
  1974  	if err != nil {
  1975  		return nil, nil, err
  1976  	}
  1977  	u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project))
  1978  
  1979  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  1980  	if err != nil {
  1981  		return nil, nil, err
  1982  	}
  1983  
  1984  	svc := new(TelegramService)
  1985  	resp, err := s.client.Do(req, svc)
  1986  	if err != nil {
  1987  		return nil, resp, err
  1988  	}
  1989  
  1990  	return svc, resp, nil
  1991  }
  1992  
  1993  // SetTelegramServiceOptions represents the available SetTelegramService()
  1994  // options.
  1995  //
  1996  // GitLab API docs:
  1997  // https://docs.gitlab.com/ee/api/integrations.html#set-up-telegram
  1998  type SetTelegramServiceOptions struct {
  1999  	Token                     *string `url:"token,omitempty" json:"token,omitempty"`
  2000  	Room                      *string `url:"room,omitempty" json:"room,omitempty"`
  2001  	NotifyOnlyBrokenPipelines *bool   `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
  2002  	BranchesToBeNotified      *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
  2003  	PushEvents                *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
  2004  	IssuesEvents              *bool   `url:"issues_events,omitempty" json:"issues_events,omitempty"`
  2005  	ConfidentialIssuesEvents  *bool   `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"`
  2006  	MergeRequestsEvents       *bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
  2007  	TagPushEvents             *bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
  2008  	NoteEvents                *bool   `url:"note_events,omitempty" json:"note_events,omitempty"`
  2009  	ConfidentialNoteEvents    *bool   `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"`
  2010  	PipelineEvents            *bool   `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
  2011  	WikiPageEvents            *bool   `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
  2012  }
  2013  
  2014  // SetTelegramService sets Telegram service for a project
  2015  //
  2016  // GitLab API docs:
  2017  // https://docs.gitlab.com/ee/api/integrations.html#set-up-telegram
  2018  func (s *ServicesService) SetTelegramService(pid interface{}, opt *SetTelegramServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  2019  	project, err := parseID(pid)
  2020  	if err != nil {
  2021  		return nil, err
  2022  	}
  2023  	u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project))
  2024  
  2025  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  2026  	if err != nil {
  2027  		return nil, err
  2028  	}
  2029  
  2030  	return s.client.Do(req, nil)
  2031  }
  2032  
  2033  // DeleteTelegramService deletes Telegram service for project.
  2034  //
  2035  // GitLab API docs:
  2036  // https://docs.gitlab.com/ee/api/integrations.html#disable-telegram
  2037  func (s *ServicesService) DeleteTelegramService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  2038  	project, err := parseID(pid)
  2039  	if err != nil {
  2040  		return nil, err
  2041  	}
  2042  	u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project))
  2043  
  2044  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  2045  	if err != nil {
  2046  		return nil, err
  2047  	}
  2048  
  2049  	return s.client.Do(req, nil)
  2050  }
  2051  
  2052  // YouTrackService represents YouTrack service settings.
  2053  //
  2054  // GitLab API docs:
  2055  // https://docs.gitlab.com/ee/api/integrations.html#youtrack
  2056  type YouTrackService struct {
  2057  	Service
  2058  	Properties *YouTrackServiceProperties `json:"properties"`
  2059  }
  2060  
  2061  // YouTrackServiceProperties represents YouTrack specific properties.
  2062  //
  2063  // GitLab API docs:
  2064  // https://docs.gitlab.com/ee/api/integrations.html#youtrack
  2065  type YouTrackServiceProperties struct {
  2066  	IssuesURL   string `json:"issues_url"`
  2067  	ProjectURL  string `json:"project_url"`
  2068  	Description string `json:"description"`
  2069  	PushEvents  bool   `json:"push_events"`
  2070  }
  2071  
  2072  // GetYouTrackService gets YouTrack service settings for a project.
  2073  //
  2074  // GitLab API docs:
  2075  // https://docs.gitlab.com/ee/api/integrations.html#get-youtrack-service-settings
  2076  func (s *ServicesService) GetYouTrackService(pid interface{}, options ...RequestOptionFunc) (*YouTrackService, *Response, error) {
  2077  	project, err := parseID(pid)
  2078  	if err != nil {
  2079  		return nil, nil, err
  2080  	}
  2081  	u := fmt.Sprintf("projects/%s/services/youtrack", PathEscape(project))
  2082  
  2083  	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
  2084  	if err != nil {
  2085  		return nil, nil, err
  2086  	}
  2087  
  2088  	svc := new(YouTrackService)
  2089  	resp, err := s.client.Do(req, svc)
  2090  	if err != nil {
  2091  		return nil, resp, err
  2092  	}
  2093  
  2094  	return svc, resp, nil
  2095  }
  2096  
  2097  // SetYouTrackServiceOptions represents the available SetYouTrackService()
  2098  // options.
  2099  //
  2100  // GitLab API docs:
  2101  // https://docs.gitlab.com/ee/api/integrations.html#createedit-youtrack-service
  2102  type SetYouTrackServiceOptions struct {
  2103  	IssuesURL   *string `url:"issues_url,omitempty" json:"issues_url,omitempty"`
  2104  	ProjectURL  *string `url:"project_url,omitempty" json:"project_url,omitempty"`
  2105  	Description *string `url:"description,omitempty" json:"description,omitempty"`
  2106  	PushEvents  *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
  2107  }
  2108  
  2109  // SetYouTrackService sets YouTrack service for a project
  2110  //
  2111  // GitLab API docs:
  2112  // https://docs.gitlab.com/ee/api/integrations.html#createedit-youtrack-service
  2113  func (s *ServicesService) SetYouTrackService(pid interface{}, opt *SetYouTrackServiceOptions, options ...RequestOptionFunc) (*Response, error) {
  2114  	project, err := parseID(pid)
  2115  	if err != nil {
  2116  		return nil, err
  2117  	}
  2118  	u := fmt.Sprintf("projects/%s/services/youtrack", PathEscape(project))
  2119  
  2120  	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
  2121  	if err != nil {
  2122  		return nil, err
  2123  	}
  2124  
  2125  	return s.client.Do(req, nil)
  2126  }
  2127  
  2128  // DeleteYouTrackService deletes YouTrack service settings for a project.
  2129  //
  2130  // GitLab API docs:
  2131  // https://docs.gitlab.com/ee/api/integrations.html#delete-youtrack-service
  2132  func (s *ServicesService) DeleteYouTrackService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
  2133  	project, err := parseID(pid)
  2134  	if err != nil {
  2135  		return nil, err
  2136  	}
  2137  	u := fmt.Sprintf("projects/%s/services/youtrack", PathEscape(project))
  2138  
  2139  	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
  2140  	if err != nil {
  2141  		return nil, err
  2142  	}
  2143  
  2144  	return s.client.Do(req, nil)
  2145  }
  2146  

View as plain text