mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-08-06 22:13:02 +02:00
feat(context): Add support for context package
This commit is contained in:
13
status.go
13
status.go
@ -1,5 +1,7 @@
|
||||
package jira
|
||||
|
||||
import "context"
|
||||
|
||||
// StatusService handles staties for the JIRA instance / API.
|
||||
//
|
||||
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-group-Workflow-statuses
|
||||
@ -19,12 +21,12 @@ type Status struct {
|
||||
StatusCategory StatusCategory `json:"statusCategory" structs:"statusCategory"`
|
||||
}
|
||||
|
||||
// GetAllStatuses returns a list of all statuses associated with workflows.
|
||||
// GetAllStatusesWithContext returns a list of all statuses associated with workflows.
|
||||
//
|
||||
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-status-get
|
||||
func (s *StatusService) GetAllStatuses() ([]Status, *Response, error) {
|
||||
func (s *StatusService) GetAllStatusesWithContext(ctx context.Context) ([]Status, *Response, error) {
|
||||
apiEndpoint := "rest/api/2/status"
|
||||
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
|
||||
req, err := s.client.NewRequestWithContext(ctx, "GET", apiEndpoint, nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@ -38,3 +40,8 @@ func (s *StatusService) GetAllStatuses() ([]Status, *Response, error) {
|
||||
|
||||
return statusList, resp, nil
|
||||
}
|
||||
|
||||
// GetAllStatuses wraps GetAllStatusesWithContext using the background context.
|
||||
func (s *StatusService) GetAllStatuses() ([]Status, *Response, error) {
|
||||
return s.GetAllStatusesWithContext(context.Background())
|
||||
}
|
||||
|
Reference in New Issue
Block a user