Documentation ¶
Overview ¶
Package jira interacts with the Jira server. It requests v3 and v1 version of the Jira cloud API using Get and GetV1 methods.
See v3: https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/, and v1: https://developer.atlassian.com/cloud/jira/software/rest/intro/
Index ¶
- Constants
- Variables
- type Board
- type BoardResult
- type Client
- func (c *Client) AddIssueComment(key, comment string) error
- func (c *Client) AssignIssue(key, assignee string) error
- func (c *Client) AssignIssueV2(key, assignee string) error
- func (c *Client) Boards(project, boardType string) (*BoardResult, error)
- func (c *Client) Create(req *CreateRequest) (*CreateResponse, error)
- func (c *Client) CreateV2(req *CreateRequest) (*CreateResponse, error)
- func (c *Client) Edit(key string, req *EditRequest) error
- func (c *Client) EpicIssues(key, jql string, limit uint) (*SearchResult, error)
- func (c *Client) EpicIssuesAdd(key string, issues ...string) error
- func (c *Client) EpicIssuesRemove(issues ...string) error
- func (c *Client) Get(ctx context.Context, path string, headers Header) (*http.Response, error)
- func (c *Client) GetCreateMeta(req *CreateMetaRequest) (*CreateMetaResponse, error)
- func (c *Client) GetIssue(key string, opts ...filter.Filter) (*Issue, error)
- func (c *Client) GetIssueLinkTypes() ([]*IssueLinkType, error)
- func (c *Client) GetIssueV2(key string, opts ...filter.Filter) (*Issue, error)
- func (c *Client) GetV1(ctx context.Context, path string, headers Header) (*http.Response, error)
- func (c *Client) GetV2(ctx context.Context, path string, headers Header) (*http.Response, error)
- func (c *Client) LinkIssue(inwardIssue, outwardIssue, linkType string) error
- func (c *Client) Me() (*Me, error)
- func (c *Client) Post(ctx context.Context, path string, body []byte, headers Header) (*http.Response, error)
- func (c *Client) PostV1(ctx context.Context, path string, body []byte, headers Header) (*http.Response, error)
- func (c *Client) PostV2(ctx context.Context, path string, body []byte, headers Header) (*http.Response, error)
- func (c *Client) Project() ([]*Project, error)
- func (c *Client) Put(ctx context.Context, path string, body []byte, headers Header) (*http.Response, error)
- func (c *Client) PutV2(ctx context.Context, path string, body []byte, headers Header) (*http.Response, error)
- func (c *Client) Search(jql string, limit uint) (*SearchResult, error)
- func (c *Client) SearchV2(jql string, limit uint) (*SearchResult, error)
- func (c *Client) SprintIssues(boardID, sprintID int, jql string, limit uint) (*SearchResult, error)
- func (c *Client) SprintIssuesAdd(id string, issues ...string) error
- func (c *Client) Sprints(boardID int, qp string, startAt, max int) (*SprintResult, error)
- func (c *Client) SprintsInBoards(boardIDs []int, qp string, limit int) []*Sprint
- func (c *Client) Transition(key string, data *TransitionRequest) (int, error)
- func (c *Client) Transitions(key string) ([]*Transition, error)
- func (c *Client) TransitionsV2(key string) ([]*Transition, error)
- func (c *Client) UserSearch(opt *UserSearchOptions) ([]*User, error)
- func (c *Client) UserSearchV2(opt *UserSearchOptions) ([]*User, error)
- type ClientFunc
- type Config
- type CreateMetaIssueType
- type CreateMetaRequest
- type CreateMetaResponse
- type CreateRequest
- type CreateResponse
- type EditRequest
- type EditResponse
- type Epic
- type ErrMultipleFailed
- type ErrUnexpectedResponse
- type Errors
- type Header
- type Issue
- type IssueFields
- type IssueLinkType
- type IssueType
- type Me
- type Project
- type SearchResult
- type Sprint
- type SprintResult
- type Transition
- type TransitionRequest
- type TransitionRequestData
- type User
- type UserSearchOptions
Constants ¶
const ( // BoardTypeScrum represents a scrum board type. BoardTypeScrum = "scrum" // BoardTypeAll represents all board types. BoardTypeAll = "" )
const ( // RFC3339 is jira datetime format. RFC3339 = "2006-01-02T15:04:05-0700" // InstallationTypeCloud represents Jira cloud server. InstallationTypeCloud = "Cloud" // InstallationTypeLocal represents on-premise Jira servers. InstallationTypeLocal = "Local" )
const ( // EpicFieldName represents epic name field in create metadata. EpicFieldName = "Epic Name" // EpicFieldLink represents epic link field in create metadata. EpicFieldLink = "Epic Link" )
const ( // IssueTypeEpic is an epic issue type. IssueTypeEpic = "Epic" // IssueTypeSubTask is a sub-task issue type. IssueTypeSubTask = "Sub-task" // AssigneeNone is an empty assignee. AssigneeNone = "none" // AssigneeDefault is a default assignee. AssigneeDefault = "default" )
const ( // ProjectTypeClassic is a classic project type. ProjectTypeClassic = "classic" // ProjectTypeNextGen is a next gen project type. ProjectTypeNextGen = "next-gen" )
const ( SprintStateActive = "active" SprintStateClosed = "closed" SprintStateFuture = "future" )
Sprint states.
Variables ¶
var ( // ErrNoResult denotes no results. ErrNoResult = fmt.Errorf("jira: no result") // ErrEmptyResponse denotes empty response from the server. ErrEmptyResponse = fmt.Errorf("jira: empty response from server") )
var ErrInvalidSearchOption = fmt.Errorf("invalid search option")
ErrInvalidSearchOption denotes invalid search option was given.
Functions ¶
This section is empty.
Types ¶
type BoardResult ¶
type BoardResult struct { MaxResults int `json:"maxResults"` Total int `json:"total"` Boards []*Board `json:"values"` }
BoardResult holds response from /board endpoint.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a jira client.
func NewClient ¶
func NewClient(c Config, opts ...ClientFunc) *Client
NewClient instantiates new jira client.
func (*Client) AddIssueComment ¶
AddIssueComment adds comment to an issue using POST /issue/{key}/comment endpoint. It only supports plain text comments at the moment.
func (*Client) AssignIssue ¶
AssignIssue assigns issue to the user using v3 version of the PUT /issue/{key}/assignee endpoint.
func (*Client) AssignIssueV2 ¶ added in v0.1.0
AssignIssueV2 assigns issue to the user using v2 version of the PUT /issue/{key}/assignee endpoint.
func (*Client) Boards ¶
func (c *Client) Boards(project, boardType string) (*BoardResult, error)
Boards gets all boards in a project.
func (*Client) Create ¶
func (c *Client) Create(req *CreateRequest) (*CreateResponse, error)
Create creates an issue using v3 version of the POST /issue endpoint.
func (*Client) CreateV2 ¶
func (c *Client) CreateV2(req *CreateRequest) (*CreateResponse, error)
CreateV2 creates an issue using v2 version of the POST /issue endpoint.
func (*Client) Edit ¶
func (c *Client) Edit(key string, req *EditRequest) error
Edit updates an issue using POST /issue endpoint.
func (*Client) EpicIssues ¶
func (c *Client) EpicIssues(key, jql string, limit uint) (*SearchResult, error)
EpicIssues fetches issues in the given epic.
func (*Client) EpicIssuesAdd ¶
EpicIssuesAdd adds issues to an epic.
func (*Client) EpicIssuesRemove ¶
EpicIssuesRemove removes issues from epics.
func (*Client) GetCreateMeta ¶
func (c *Client) GetCreateMeta(req *CreateMetaRequest) (*CreateMetaResponse, error)
GetCreateMeta gets create metadata using GET /issue/createmeta endpoint.
func (*Client) GetIssueLinkTypes ¶
func (c *Client) GetIssueLinkTypes() ([]*IssueLinkType, error)
GetIssueLinkTypes fetches issue link types using GET /issueLinkType endpoint.
func (*Client) GetIssueV2 ¶
GetIssueV2 fetches issue details using v2 version of Jira GET /issue/{key} endpoint.
func (*Client) LinkIssue ¶
LinkIssue connects issues to the given link type using POST /issueLink endpoint.
func (*Client) Post ¶
func (c *Client) Post(ctx context.Context, path string, body []byte, headers Header) (*http.Response, error)
Post sends POST request to v3 version of the jira api.
func (*Client) PostV1 ¶
func (c *Client) PostV1(ctx context.Context, path string, body []byte, headers Header) (*http.Response, error)
PostV1 sends POST request to v1 version of the jira api.
func (*Client) PostV2 ¶
func (c *Client) PostV2(ctx context.Context, path string, body []byte, headers Header) (*http.Response, error)
PostV2 sends POST request to v2 version of the jira api.
func (*Client) Put ¶
func (c *Client) Put(ctx context.Context, path string, body []byte, headers Header) (*http.Response, error)
Put sends PUT request to v3 version of the jira api.
func (*Client) PutV2 ¶
func (c *Client) PutV2(ctx context.Context, path string, body []byte, headers Header) (*http.Response, error)
PutV2 sends PUT request to v2 version of the jira api.
func (*Client) Search ¶
func (c *Client) Search(jql string, limit uint) (*SearchResult, error)
Search searches for issues using v3 version of the Jira GET /search endpoint.
func (*Client) SearchV2 ¶ added in v0.1.0
func (c *Client) SearchV2(jql string, limit uint) (*SearchResult, error)
SearchV2 searches an issues using v2 version of the Jira GET /search endpoint.
func (*Client) SprintIssues ¶
SprintIssues fetches issues in the given sprint.
func (*Client) SprintIssuesAdd ¶ added in v0.2.0
SprintIssuesAdd adds issues to the sprint.
func (*Client) Sprints ¶
Sprints fetches all sprints for a given board.
qp is an additional query parameters in key, value pair format, eg: state=closed.
func (*Client) SprintsInBoards ¶
SprintsInBoards fetches sprints across given board IDs.
qp is an additional query parameters in key, value pair format, eg: state=closed.
func (*Client) Transition ¶
func (c *Client) Transition(key string, data *TransitionRequest) (int, error)
Transition moves issue from one state to another using POST /issue/{key}/transitions endpoint.
func (*Client) Transitions ¶
func (c *Client) Transitions(key string) ([]*Transition, error)
Transitions fetches valid transitions for an issue using v3 version of the GET /issue/{key}/transitions endpoint.
func (*Client) TransitionsV2 ¶ added in v0.1.0
func (c *Client) TransitionsV2(key string) ([]*Transition, error)
TransitionsV2 fetches valid transitions for an issue using v2 version of the GET /issue/{key}/transitions endpoint.
func (*Client) UserSearch ¶
func (c *Client) UserSearch(opt *UserSearchOptions) ([]*User, error)
UserSearch search for user details using v3 version of the GET /user/assignable/search endpoint.
func (*Client) UserSearchV2 ¶ added in v0.1.0
func (c *Client) UserSearchV2(opt *UserSearchOptions) ([]*User, error)
UserSearchV2 search for user details using v2 version of the GET /user/assignable/search endpoint.
type ClientFunc ¶
type ClientFunc func(*Client)
ClientFunc decorates option for client.
func WithTimeout ¶
func WithTimeout(to time.Duration) ClientFunc
WithTimeout is a functional opt to attach timeout to the client.
type CreateMetaIssueType ¶
CreateMetaIssueType struct holds issue types from GET /issue/createmeta endpoint.
type CreateMetaRequest ¶
CreateMetaRequest struct holds request data for createmeta request.
type CreateMetaResponse ¶
type CreateMetaResponse struct { Projects []struct { Key string `json:"key"` Name string `json:"name"` IssueTypes []*CreateMetaIssueType `json:"issuetypes"` } `json:"projects"` }
CreateMetaResponse struct holds response from GET /issue/createmeta endpoint.
type CreateRequest ¶
type CreateRequest struct { Project string Name string IssueType string // ParentIssueKey is required when creating a sub-task for classic project. // This can also be used to attach epic for next-gen project. ParentIssueKey string Summary string Body interface{} // string in v1/v2 and adf.ADF in v3 Priority string Labels []string Components []string // EpicField is the dynamic epic field name // that changes per jira installation. EpicField string // contains filtered or unexported fields }
CreateRequest struct holds request data for create request.
func (*CreateRequest) ForProjectType ¶ added in v0.2.0
func (cr *CreateRequest) ForProjectType(pt string)
ForProjectType set jira project type.
type CreateResponse ¶
CreateResponse struct holds response from POST /issue endpoint.
type EditRequest ¶
type EditRequest struct { IssueType string ParentIssueKey string Summary string Body string Assignee string Priority string Labels []string Components []string }
EditRequest struct holds request data for edit request. Setting an Assignee requires an account ID.
type EditResponse ¶
EditResponse struct holds response from POST /issue endpoint.
type ErrMultipleFailed ¶ added in v0.2.0
type ErrMultipleFailed struct {
Msg string
}
ErrMultipleFailed represents a grouped error, usually when multiple request fails when running them in a loop.
func (*ErrMultipleFailed) Error ¶ added in v0.2.0
func (e *ErrMultipleFailed) Error() string
type ErrUnexpectedResponse ¶
ErrUnexpectedResponse denotes response code other than the expected one.
func (*ErrUnexpectedResponse) Error ¶
func (e *ErrUnexpectedResponse) Error() string
type Issue ¶
type Issue struct { Key string `json:"key"` Fields IssueFields `json:"fields"` }
Issue holds issue info.
type IssueFields ¶
type IssueFields struct { Summary string `json:"summary"` Description interface{} `json:"description"` // string in v1/v2, adf.ADF in v3 Labels []string `json:"labels"` Resolution struct { Name string `json:"name"` } `json:"resolution"` IssueType IssueType `json:"issueType"` Assignee struct { Name string `json:"displayName"` } `json:"assignee"` Priority struct { Name string `json:"name"` } `json:"priority"` Reporter struct { Name string `json:"displayName"` } `json:"reporter"` Watches struct { IsWatching bool `json:"isWatching"` WatchCount int `json:"watchCount"` } `json:"watches"` Status struct { Name string `json:"name"` } `json:"status"` Components []struct { Name string `json:"name"` } `json:"components"` Comment struct { Comments []struct { ID string `json:"id"` Author User `json:"author"` Body interface{} `json:"body"` // string in v1/v2, adf.ADF in v3 Created string `json:"created"` } `json:"comments"` Total int `json:"total"` } `json:"comment"` IssueLinks []struct { LinkType struct { Name string `json:"name"` Inward string `json:"inward"` Outward string `json:"outward"` } `json:"type"` InwardIssue *Issue `json:"inwardIssue,omitempty"` OutwardIssue *Issue `json:"outwardIssue,omitempty"` } `json:"issueLinks"` Created string `json:"created"` Updated string `json:"updated"` }
IssueFields holds issue fields.
type IssueLinkType ¶
type IssueLinkType struct { ID string `json:"id"` Name string `json:"name"` Inward string `json:"inward"` Outward string `json:"outward"` }
IssueLinkType holds issue link type info.
type IssueType ¶
type IssueType struct { ID string `json:"id"` Name string `json:"name"` Handle string `json:"untranslatedName,omitempty"` // This field may not exist in older version of the API. Subtask bool `json:"subtask"` }
IssueType holds issue type info.
type Project ¶
type Project struct { Key string `json:"key"` Name string `json:"name"` Lead struct { Name string `json:"displayName"` } `json:"lead"` Type string `json:"style"` }
Project holds project info.
type SearchResult ¶
type SearchResult struct { StartAt int `json:"startAt"` MaxResults int `json:"maxResults"` Total int `json:"total"` Issues []*Issue `json:"issues"` }
SearchResult struct holds response from /search endpoint.
type Sprint ¶
type Sprint struct { ID int `json:"id"` Name string `json:"name"` Status string `json:"state"` StartDate string `json:"startDate"` EndDate string `json:"endDate"` CompleteDate string `json:"completeDate,omitempty"` BoardID int `json:"originBoardId,omitempty"` }
Sprint holds sprint info.
type SprintResult ¶
type SprintResult struct { MaxResults int `json:"maxResults"` StartAt int `json:"startAt"` IsLast bool `json:"isLast"` Sprints []*Sprint `json:"values"` }
SprintResult holds response from /board/{boardID}/sprint endpoint.
type Transition ¶
type Transition struct { ID json.Number `json:"id"` Name string `json:"name"` IsAvailable bool `json:"isAvailable"` }
Transition holds issue transition info.
type TransitionRequest ¶
type TransitionRequest struct {
Transition *TransitionRequestData `json:"transition"`
}
TransitionRequest struct holds request data for transition request.
type TransitionRequestData ¶
TransitionRequestData is a transition request data.