2020-09-14 18:31:56 +00:00
|
|
|
package jira
|
|
|
|
|
2021-10-06 17:33:14 +00:00
|
|
|
import "context"
|
|
|
|
|
|
|
|
// StatusService handles staties 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/v2/#api-group-Workflow-statuses
|
2020-09-14 18:31:56 +00:00
|
|
|
type StatusService struct {
|
|
|
|
client *Client
|
|
|
|
}
|
|
|
|
|
2021-10-06 17:33:14 +00:00
|
|
|
// Status represents the current status of a Jira issue.
|
2020-09-14 18:31:56 +00:00
|
|
|
// Typical status are "Open", "In Progress", "Closed", ...
|
2021-10-06 17:33:14 +00:00
|
|
|
// Status can be user defined in every Jira instance.
|
2020-09-14 18:31:56 +00:00
|
|
|
type Status struct {
|
|
|
|
Self string `json:"self" structs:"self"`
|
|
|
|
Description string `json:"description" structs:"description"`
|
|
|
|
IconURL string `json:"iconUrl" structs:"iconUrl"`
|
|
|
|
Name string `json:"name" structs:"name"`
|
|
|
|
ID string `json:"id" structs:"id"`
|
|
|
|
StatusCategory StatusCategory `json:"statusCategory" structs:"statusCategory"`
|
|
|
|
}
|
|
|
|
|
2021-10-06 17:33:14 +00:00
|
|
|
// GetAllStatusesWithContext returns a list of all statuses associated with workflows.
|
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/v2/#api-rest-api-2-status-get
|
|
|
|
func (s *StatusService) GetAllStatusesWithContext(ctx context.Context) ([]Status, *Response, error) {
|
2020-09-14 18:31:56 +00:00
|
|
|
apiEndpoint := "rest/api/2/status"
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
statusList := []Status{}
|
|
|
|
resp, err := s.client.Do(req, &statusList)
|
|
|
|
if err != nil {
|
|
|
|
return nil, resp, NewJiraError(resp, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return statusList, resp, nil
|
|
|
|
}
|
2021-10-06 17:33:14 +00:00
|
|
|
|
|
|
|
// GetAllStatuses wraps GetAllStatusesWithContext using the background context.
|
|
|
|
func (s *StatusService) GetAllStatuses() ([]Status, *Response, error) {
|
|
|
|
return s.GetAllStatusesWithContext(context.Background())
|
|
|
|
}
|