2020-09-14 18:31:56 +00:00
|
|
|
package jira
|
|
|
|
|
2021-10-06 17:33:14 +00:00
|
|
|
import "context"
|
|
|
|
|
|
|
|
// StatusCategoryService handles status categories 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-Statuscategory
|
2020-09-14 18:31:56 +00:00
|
|
|
type StatusCategoryService struct {
|
|
|
|
client *Client
|
|
|
|
}
|
|
|
|
|
|
|
|
// StatusCategory represents the category a status belongs to.
|
2021-10-06 17:33:14 +00:00
|
|
|
// Those categories can be user defined in every Jira instance.
|
2020-09-14 18:31:56 +00:00
|
|
|
type StatusCategory struct {
|
|
|
|
Self string `json:"self" structs:"self"`
|
|
|
|
ID int `json:"id" structs:"id"`
|
|
|
|
Name string `json:"name" structs:"name"`
|
|
|
|
Key string `json:"key" structs:"key"`
|
|
|
|
ColorName string `json:"colorName" structs:"colorName"`
|
|
|
|
}
|
|
|
|
|
2021-10-06 17:33:14 +00:00
|
|
|
// These constants are the keys of the default Jira status categories
|
2020-09-14 18:31:56 +00:00
|
|
|
const (
|
|
|
|
StatusCategoryComplete = "done"
|
|
|
|
StatusCategoryInProgress = "indeterminate"
|
|
|
|
StatusCategoryToDo = "new"
|
|
|
|
StatusCategoryUndefined = "undefined"
|
|
|
|
)
|
|
|
|
|
2021-10-06 17:33:14 +00:00
|
|
|
// GetListWithContext gets all status categories 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-statuscategory-get
|
|
|
|
func (s *StatusCategoryService) GetListWithContext(ctx context.Context) ([]StatusCategory, *Response, error) {
|
2020-09-14 18:31:56 +00:00
|
|
|
apiEndpoint := "rest/api/2/statuscategory"
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
statusCategoryList := []StatusCategory{}
|
|
|
|
resp, err := s.client.Do(req, &statusCategoryList)
|
|
|
|
if err != nil {
|
|
|
|
return nil, resp, NewJiraError(resp, err)
|
|
|
|
}
|
|
|
|
return statusCategoryList, resp, nil
|
|
|
|
}
|
2021-10-06 17:33:14 +00:00
|
|
|
|
|
|
|
// GetList wraps GetListWithContext using the background context.
|
|
|
|
func (s *StatusCategoryService) GetList() ([]StatusCategory, *Response, error) {
|
|
|
|
return s.GetListWithContext(context.Background())
|
|
|
|
}
|