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:
34
metaissue.go
34
metaissue.go
@ -1,6 +1,7 @@
|
||||
package jira
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@ -47,16 +48,21 @@ type MetaIssueType struct {
|
||||
Fields tcontainer.MarshalMap `json:"fields,omitempty"`
|
||||
}
|
||||
|
||||
// GetCreateMeta makes the api call to get the meta information required to create a ticket
|
||||
func (s *IssueService) GetCreateMeta(projectkeys string) (*CreateMetaInfo, *Response, error) {
|
||||
return s.GetCreateMetaWithOptions(&GetQueryOptions{ProjectKeys: projectkeys, Expand: "projects.issuetypes.fields"})
|
||||
// GetCreateMetaWithContext makes the api call to get the meta information required to create a ticket
|
||||
func (s *IssueService) GetCreateMetaWithContext(ctx context.Context, projectkeys string) (*CreateMetaInfo, *Response, error) {
|
||||
return s.GetCreateMetaWithOptionsWithContext(ctx, &GetQueryOptions{ProjectKeys: projectkeys, Expand: "projects.issuetypes.fields"})
|
||||
}
|
||||
|
||||
// GetCreateMetaWithOptions makes the api call to get the meta information without requiring to have a projectKey
|
||||
func (s *IssueService) GetCreateMetaWithOptions(options *GetQueryOptions) (*CreateMetaInfo, *Response, error) {
|
||||
// GetCreateMeta wraps GetCreateMetaWithContext using the background context.
|
||||
func (s *IssueService) GetCreateMeta(projectkeys string) (*CreateMetaInfo, *Response, error) {
|
||||
return s.GetCreateMetaWithContext(context.Background(), projectkeys)
|
||||
}
|
||||
|
||||
// GetCreateMetaWithOptionsWithContext makes the api call to get the meta information without requiring to have a projectKey
|
||||
func (s *IssueService) GetCreateMetaWithOptionsWithContext(ctx context.Context, options *GetQueryOptions) (*CreateMetaInfo, *Response, error) {
|
||||
apiEndpoint := "rest/api/2/issue/createmeta"
|
||||
|
||||
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
|
||||
req, err := s.client.NewRequestWithContext(ctx, "GET", apiEndpoint, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -78,11 +84,16 @@ func (s *IssueService) GetCreateMetaWithOptions(options *GetQueryOptions) (*Crea
|
||||
return meta, resp, nil
|
||||
}
|
||||
|
||||
// GetEditMeta makes the api call to get the edit meta information for an issue
|
||||
func (s *IssueService) GetEditMeta(issue *Issue) (*EditMetaInfo, *Response, error) {
|
||||
// GetCreateMetaWithOptions wraps GetCreateMetaWithOptionsWithContext using the background context.
|
||||
func (s *IssueService) GetCreateMetaWithOptions(options *GetQueryOptions) (*CreateMetaInfo, *Response, error) {
|
||||
return s.GetCreateMetaWithOptionsWithContext(context.Background(), options)
|
||||
}
|
||||
|
||||
// GetEditMetaWithContext makes the api call to get the edit meta information for an issue
|
||||
func (s *IssueService) GetEditMetaWithContext(ctx context.Context, issue *Issue) (*EditMetaInfo, *Response, error) {
|
||||
apiEndpoint := fmt.Sprintf("/rest/api/2/issue/%s/editmeta", issue.Key)
|
||||
|
||||
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
|
||||
req, err := s.client.NewRequestWithContext(ctx, "GET", apiEndpoint, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -97,6 +108,11 @@ func (s *IssueService) GetEditMeta(issue *Issue) (*EditMetaInfo, *Response, erro
|
||||
return meta, resp, nil
|
||||
}
|
||||
|
||||
// GetEditMeta wraps GetEditMetaWithContext using the background context.
|
||||
func (s *IssueService) GetEditMeta(issue *Issue) (*EditMetaInfo, *Response, error) {
|
||||
return s.GetEditMetaWithContext(context.Background(), issue)
|
||||
}
|
||||
|
||||
// GetProjectWithName returns a project with "name" from the meta information received. If not found, this returns nil.
|
||||
// The comparison of the name is case insensitive.
|
||||
func (m *CreateMetaInfo) GetProjectWithName(name string) *MetaProject {
|
||||
|
Reference in New Issue
Block a user