Skip to content

Commit

Permalink
Add jira project_keys field - fix #1959
Browse files Browse the repository at this point in the history
  • Loading branch information
ebuildy committed Jun 23, 2024
1 parent a62c545 commit ff0683c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 16 deletions.
36 changes: 20 additions & 16 deletions services.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,12 +1102,15 @@ 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"`
ProjectKey string `json:"project_key" `
Username string `json:"username" `
Password string `json:"password" `
JiraIssueTransitionID string `json:"jira_issue_transition_id"`
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"`

// Deprecated: This parameter was removed in GitLab 17.0
ProjectKey string `json:"project_key" `
}

// UnmarshalJSON decodes the Jira Service Properties.
Expand Down Expand Up @@ -1171,16 +1174,17 @@ func (s *ServicesService) GetJiraService(pid interface{}, options ...RequestOpti
// GitLab API docs:
// https://docs.gitlab.com/ee/api/integrations.html#edit-jira-service
type SetJiraServiceOptions struct {
URL *string `url:"url,omitempty" json:"url,omitempty"`
APIURL *string `url:"api_url,omitempty" json:"api_url,omitempty"`
ProjectKey *string `url:"project_key,omitempty" json:"project_key,omitempty" `
Username *string `url:"username,omitempty" json:"username,omitempty" `
Password *string `url:"password,omitempty" json:"password,omitempty" `
Active *bool `url:"active,omitempty" json:"active,omitempty"`
JiraIssueTransitionID *string `url:"jira_issue_transition_id,omitempty" json:"jira_issue_transition_id,omitempty"`
CommitEvents *bool `url:"commit_events,omitempty" json:"commit_events,omitempty"`
MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
CommentOnEventEnabled *bool `url:"comment_on_event_enabled,omitempty" json:"comment_on_event_enabled,omitempty"`
URL *string `url:"url,omitempty" json:"url,omitempty"`
APIURL *string `url:"api_url,omitempty" json:"api_url,omitempty"`
ProjectKey *string `url:"project_key,omitempty" json:"project_key,omitempty" `
ProjectKeys *[]string `url:"project_keys,comma,omitempty" json:"project_keys,omitempty" `
Username *string `url:"username,omitempty" json:"username,omitempty" `
Password *string `url:"password,omitempty" json:"password,omitempty" `
Active *bool `url:"active,omitempty" json:"active,omitempty"`
JiraIssueTransitionID *string `url:"jira_issue_transition_id,omitempty" json:"jira_issue_transition_id,omitempty"`
CommitEvents *bool `url:"commit_events,omitempty" json:"commit_events,omitempty"`
MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
CommentOnEventEnabled *bool `url:"comment_on_event_enabled,omitempty" json:"comment_on_event_enabled,omitempty"`
}

// SetJiraService sets Jira service for a project
Expand Down
26 changes: 26 additions & 0 deletions services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,32 @@ 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) {
testMethod(t, r, http.MethodPut)
})

opt := &SetJiraServiceOptions{
URL: Ptr("asd"),
APIURL: Ptr("asd"),
ProjectKeys: Ptr([]string{"as"}),
Username: Ptr("aas"),
Password: Ptr("asd"),
Active: Ptr(true),
JiraIssueTransitionID: Ptr("2,3"),
CommitEvents: Ptr(true),
CommentOnEventEnabled: Ptr(true),
MergeRequestsEvents: Ptr(true),
}

_, err := client.Services.SetJiraService(1, opt)
if err != nil {
t.Fatalf("Services.SetJiraService returns an error: %v", err)
}
}

func TestDeleteJiraService(t *testing.T) {
mux, client := setup(t)

Expand Down

0 comments on commit ff0683c

Please sign in to comment.