|
| 1 | +package jira |
| 2 | + |
| 3 | +// PriorityService handles priorities for the JIRA instance / API. |
| 4 | +// |
| 5 | +// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-Priority |
| 6 | +type PriorityService struct { |
| 7 | + client *Client |
| 8 | +} |
| 9 | + |
| 10 | +// Priority represents a priority of a JIRA issue. |
| 11 | +// Typical types are "Normal", "Moderate", "Urgent", ... |
| 12 | +type Priority struct { |
| 13 | + Self string `json:"self,omitempty" structs:"self,omitempty"` |
| 14 | + IconURL string `json:"iconUrl,omitempty" structs:"iconUrl,omitempty"` |
| 15 | + Name string `json:"name,omitempty" structs:"name,omitempty"` |
| 16 | + ID string `json:"id,omitempty" structs:"id,omitempty"` |
| 17 | + StatusColor string `json:"statusColor,omitempty" structs:"statusColor,omitempty"` |
| 18 | + Description string `json:"description,omitempty" structs:"description,omitempty"` |
| 19 | +} |
| 20 | + |
| 21 | +// GetList gets all priorities from JIRA |
| 22 | +// |
| 23 | +// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-priority-get |
| 24 | +func (s *PriorityService) GetList() ([]Priority, *Response, error) { |
| 25 | + apiEndpoint := "rest/api/2/priority" |
| 26 | + req, err := s.client.NewRequest("GET", apiEndpoint, nil) |
| 27 | + if err != nil { |
| 28 | + return nil, nil, err |
| 29 | + } |
| 30 | + |
| 31 | + priorityList := []Priority{} |
| 32 | + resp, err := s.client.Do(req, priorityList) |
| 33 | + if err != nil { |
| 34 | + return nil, resp, NewJiraError(resp, err) |
| 35 | + } |
| 36 | + return priorityList, resp, nil |
| 37 | +} |
0 commit comments