2020-09-14 18:31:56 +00:00
|
|
|
package jira
|
|
|
|
|
2021-10-06 17:33:14 +00:00
|
|
|
import "context"
|
|
|
|
|
|
|
|
// PriorityService handles priorities for the Jira instance / API.
|
2020-09-14 18:31:56 +00:00
|
|
|
//
|
2021-10-06 17:33:14 +00:00
|
|
|
// Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-Priority
|
2020-09-14 18:31:56 +00:00
|
|
|
type PriorityService struct {
|
|
|
|
client *Client
|
|
|
|
}
|
|
|
|
|
2021-10-06 17:33:14 +00:00
|
|
|
// Priority represents a priority of a Jira issue.
|
2020-09-14 18:31:56 +00:00
|
|
|
// Typical types are "Normal", "Moderate", "Urgent", ...
|
|
|
|
type Priority struct {
|
|
|
|
Self string `json:"self,omitempty" structs:"self,omitempty"`
|
|
|
|
IconURL string `json:"iconUrl,omitempty" structs:"iconUrl,omitempty"`
|
|
|
|
Name string `json:"name,omitempty" structs:"name,omitempty"`
|
|
|
|
ID string `json:"id,omitempty" structs:"id,omitempty"`
|
|
|
|
StatusColor string `json:"statusColor,omitempty" structs:"statusColor,omitempty"`
|
|
|
|
Description string `json:"description,omitempty" structs:"description,omitempty"`
|
|
|
|
}
|
|
|
|
|
2021-10-06 17:33:14 +00:00
|
|
|
// GetListWithContext gets all priorities from Jira
|
2020-09-14 18:31:56 +00:00
|
|
|
//
|
2021-10-06 17:33:14 +00:00
|
|
|
// Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-priority-get
|
|
|
|
func (s *PriorityService) GetListWithContext(ctx context.Context) ([]Priority, *Response, error) {
|
2020-09-14 18:31:56 +00:00
|
|
|
apiEndpoint := "rest/api/2/priority"
|
2021-10-06 17:33:14 +00:00
|
|
|
req, err := s.client.NewRequestWithContext(ctx, "GET", apiEndpoint, nil)
|
2020-09-14 18:31:56 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
priorityList := []Priority{}
|
|
|
|
resp, err := s.client.Do(req, &priorityList)
|
|
|
|
if err != nil {
|
|
|
|
return nil, resp, NewJiraError(resp, err)
|
|
|
|
}
|
|
|
|
return priorityList, resp, nil
|
|
|
|
}
|
2021-10-06 17:33:14 +00:00
|
|
|
|
|
|
|
// GetList wraps GetListWithContext using the background context.
|
|
|
|
func (s *PriorityService) GetList() ([]Priority, *Response, error) {
|
|
|
|
return s.GetListWithContext(context.Background())
|
|
|
|
}
|