Repository: xanzy/go-gitlab
Pull request #1999 (2024-08-27 11:19:19)

Update jira integration pt2
This was actually missing for the Jira-integration-update from this MR: 
https://github.com/xanzy/go-gitlab/pull/1970

Docs:
https://docs.gitlab.com/ee/api/integrations.html#jira



Patch:
diff --git a/services.go b/services.go
index a7eeb72..fcaa71e 100644
--- a/services.go
+++ b/services.go
@@ -1102,12 +1102,22 @@ type JiraService struct {
 // GitLab API docs:
 // https://docs.gitlab.com/ee/api/integrations.html#jira
 type JiraServiceProperties struct {
-	URL                   string   `json:"url"`
-	APIURL                string   `json:"api_url"`
-	ProjectKeys           []string `json:"project_keys" `
-	Username              string   `json:"username" `
-	Password              string   `json:"password" `
-	JiraIssueTransitionID string   `json:"jira_issue_transition_id"`
+	URL                          string   `json:"url"`
+	APIURL                       string   `json:"api_url"`
+	Username                     string   `json:"username" `
+	Password                     string   `json:"password" `
+	Active                       bool     `json:"active"`
+	JiraAuthType                 int      `json:"jira_auth_type"`
+	JiraIssuePrefix              string   `json:"jira_issue_prefix"`
+	JiraIssueRegex               string   `json:"jira_issue_regex"`
+	JiraIssueTransitionAutomatic bool     `json:"jira_issue_transition_automatic"`
+	JiraIssueTransitionID        string   `json:"jira_issue_transition_id"`
+	CommitEvents                 bool     `json:"commit_events"`
+	MergeRequestsEvents          bool     `json:"merge_requests_events"`
+	CommentOnEventEnabled        bool     `json:"comment_on_event_enabled"`
+	IssuesEnabled                bool     `json:"issues_enabled"`
+	ProjectKeys                  []string `json:"project_keys" `
+	UseInheritedSettings         bool     `json:"use_inherited_settings"`
 
 	// Deprecated: This parameter was removed in GitLab 17.0
 	ProjectKey string `json:"project_key" `
@@ -1152,7 +1162,7 @@ func (s *ServicesService) GetJiraService(pid interface{}, options ...RequestOpti
 	if err != nil {
 		return nil, nil, err
 	}
-	u := fmt.Sprintf("projects/%s/services/jira", PathEscape(project))
+	u := fmt.Sprintf("projects/%s/integrations/jira", PathEscape(project))
 
 	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
 	if err != nil {
@@ -1204,7 +1214,7 @@ func (s *ServicesService) SetJiraService(pid interface{}, opt *SetJiraServiceOpt
 	if err != nil {
 		return nil, err
 	}
-	u := fmt.Sprintf("projects/%s/services/jira", PathEscape(project))
+	u := fmt.Sprintf("projects/%s/integrations/jira", PathEscape(project))
 
 	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
 	if err != nil {
@@ -1223,7 +1233,7 @@ func (s *ServicesService) DeleteJiraService(pid interface{}, options ...RequestO
 	if err != nil {
 		return nil, err
 	}
-	u := fmt.Sprintf("projects/%s/services/jira", PathEscape(project))
+	u := fmt.Sprintf("projects/%s/integrations/jira", PathEscape(project))
 
 	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
 	if err != nil {


Test patch:
diff --git a/services_test.go b/services_test.go
index 69d2bfc..a698bc8 100644
--- a/services_test.go
+++ b/services_test.go
@@ -376,27 +376,36 @@ func TestDisableSlackApplication(t *testing.T) {
 func TestGetJiraService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/0/services/jira", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/0/integrations/jira", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, http.MethodGet)
+		fmt.Fprint(w, `{"id":1, "properties": {}}`)
+	})
+
+	mux.HandleFunc("/api/v4/projects/1/integrations/jira", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodGet)
 		fmt.Fprint(w, `{"id":1, "properties": {"jira_issue_transition_id": "2"}}`)
 	})
 
-	mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/2/integrations/jira", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodGet)
 		fmt.Fprint(w, `{"id":1, "properties": {"jira_issue_transition_id": 2}}`)
 	})
 
-	mux.HandleFunc("/api/v4/projects/2/services/jira", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/3/integrations/jira", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodGet)
 		fmt.Fprint(w, `{"id":1, "properties": {"jira_issue_transition_id": "2,3"}}`)
 	})
 
-	mux.HandleFunc("/api/v4/projects/3/services/jira", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/4/integrations/jira", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodGet)
-		fmt.Fprint(w, `{"id":1, "properties": {}}`)
+		fmt.Fprint(w, `{"id":1, "properties": {"jira_auth_type": 1}}`)
 	})
 
 	want := []*JiraService{
+		{
+			Service:    Service{ID: 1},
+			Properties: &JiraServiceProperties{},
+		},
 		{
 			Service: Service{ID: 1},
 			Properties: &JiraServiceProperties{
@@ -416,8 +425,10 @@ func TestGetJiraService(t *testing.T) {
 			},
 		},
 		{
-			Service:    Service{ID: 1},
-			Properties: &JiraServiceProperties{},
+			Service: Service{ID: 1},
+			Properties: &JiraServiceProperties{
+				JiraAuthType: 1,
+			},
 		},
 	}
 
@@ -436,7 +447,7 @@ func TestGetJiraService(t *testing.T) {
 func TestSetJiraService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/integrations/jira", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodPut)
 	})
 
@@ -467,7 +478,7 @@ func TestSetJiraService(t *testing.T) {
 func TestSetJiraServiceProjecKeys(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/integrations/jira", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodPut)
 	})
 
@@ -498,7 +509,7 @@ func TestSetJiraServiceProjecKeys(t *testing.T) {
 func TestSetJiraServiceAuthTypeBasicAuth(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/integrations/jira", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodPut)
 	})
 
@@ -518,7 +529,7 @@ func TestSetJiraServiceAuthTypeBasicAuth(t *testing.T) {
 func TestSetJiraServiceAuthTypeTokenAuth(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/integrations/jira", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodPut)
 	})
 
@@ -537,7 +548,7 @@ func TestSetJiraServiceAuthTypeTokenAuth(t *testing.T) {
 func TestDeleteJiraService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/integrations/jira", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodDelete)
 	})