|
| 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 FieldService struct { |
| 7 | + client *Client |
| 8 | +} |
| 9 | + |
| 10 | +// Priority represents a priority of a JIRA issue. |
| 11 | +// Typical types are "Normal", "Moderate", "Urgent", ... |
| 12 | +type Field struct { |
| 13 | + ID string `json:"id,omitempty" structs:"id,omitempty"` |
| 14 | + Key string `json:"key,omitempty" structs:"key,omitempty"` |
| 15 | + Name string `json:"name,omitempty" structs:"name,omitempty"` |
| 16 | + Custom bool `json:"custom,omitempty" structs:"custom,omitempty"` |
| 17 | + Navigable bool `json:"navigable,omitempty" structs:"navigable,omitempty"` |
| 18 | + Searchable bool `json:"searchable,omitempty" structs:"searchable,omitempty"` |
| 19 | + ClauseNames []string `json:"clauseNames,omitempty" structs:"clauseNames,omitempty"` |
| 20 | + Schema FieldSchema `json:"schema,omitempty" structs:"schema,omitempty"` |
| 21 | +} |
| 22 | + |
| 23 | +type FieldSchema struct { |
| 24 | + Type string `json:"type,omitempty" structs:"type,omitempty"` |
| 25 | + System string `json:"system,omitempty" structs:"system,omitempty"` |
| 26 | +} |
| 27 | + |
| 28 | +// GetList gets all fields from JIRA |
| 29 | +// |
| 30 | +// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-priority-get |
| 31 | +func (s *FieldService) GetList() ([]Field, *Response, error) { |
| 32 | + apiEndpoint := "rest/api/2/field" |
| 33 | + req, err := s.client.NewRequest("GET", apiEndpoint, nil) |
| 34 | + if err != nil { |
| 35 | + return nil, nil, err |
| 36 | + } |
| 37 | + |
| 38 | + fieldList := []Field{} |
| 39 | + resp, err := s.client.Do(req, &fieldList) |
| 40 | + if err != nil { |
| 41 | + return nil, resp, NewJiraError(resp, err) |
| 42 | + } |
| 43 | + return fieldList, resp, nil |
| 44 | +} |
0 commit comments