Documentation
¶
Index ¶
- Variables
- func ADFDescription(description string, acceptanceCriteria []string, documentURL string) map[string]any
- type AttachmentContent
- type Client
- func (c *Client) AddComment(ctx context.Context, issueKey string, body map[string]any) (*Comment, error)
- func (c *Client) AddSimpleComment(ctx context.Context, issueKey string, simpleComment string) (*Comment, error)
- func (c *Client) CreateIssue(ctx context.Context, body map[string]any) (*IssueResponse, error)
- func (c *Client) CreateIssueLink(ctx context.Context, linkType, inwardIssueKey, outwardIssueKey string) error
- func (c *Client) DeleteIssueLink(ctx context.Context, linkID string) error
- func (c *Client) Do(request *http.Request, responseTarget any) error
- func (c *Client) DownloadAttachment(ctx context.Context, attachmentID string, maxBytes int64) (*AttachmentContent, error)
- func (c *Client) GetIssue(ctx context.Context, issueKey string, fields []string, properties []string) (*Issue, error)
- func (c *Client) GetIssueLinkTypes(ctx context.Context) ([]string, error)
- func (c *Client) GetIssueLinks(ctx context.Context, issueKey string) ([]IssueLink, error)
- func (c *Client) GetIssueProperty(ctx context.Context, issueKey, propertyKey string) (string, error)
- func (c *Client) ListIssueLinks(ctx context.Context, issueKey string) ([]IssueLink, error)
- func (c *Client) NewRequest(ctx context.Context, method, path string, body any) (*http.Request, error)
- func (c *Client) SearchIssues(ctx context.Context, search IssueSearch) (*IssueSearchResult, error)
- func (c *Client) SearchJQL(ctx context.Context, jql string, maxResults int, nextPageToken string) (*SearchResult, error)
- func (c *Client) SetIssueProperty(ctx context.Context, issueKey, propertyKey string, value any) error
- func (c *Client) UpdateIssue(ctx context.Context, issueKey string, edit IssueUpdate) error
- type Comment
- type Issue
- type IssueLink
- type IssueResponse
- type IssueSearch
- type IssueSearchResult
- type IssueUpdate
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
var ErrAttachmentTooLarge = errors.New("attachment too large")
ErrAttachmentTooLarge means an attachment's content is longer than the limit the caller passed.
Functions ¶
func ADFDescription ¶
func ADFDescription(description string, acceptanceCriteria []string, documentURL string) map[string]any
adfDescription renders a work item as an Atlassian Document Format document. ADF has no Markdown fallback: a heading is a heading node and a bullet is a list node, so the same prose that renders on GitHub has to be translated rather than passed through.
Types ¶
type AttachmentContent ¶ added in v0.16.1
AttachmentContent is a downloaded attachment.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles communication with Jira Rest API
func NewClient ¶
NewClient creates new Jira API client Accepts custom *http.Client, uses DefaultClient if nil [i.e base URL https://my-domain.atlassian.net and auth creds ]
func (*Client) AddComment ¶ added in v0.17.0
func (c *Client) AddComment(ctx context.Context, issueKey string, body map[string]any) (*Comment, error)
AddComment posts a comment on an issue. The body is an Atlassian Document Format document, such as ADFDescription(markdown, nil, "") returns for Markdown text.
func (*Client) AddSimpleComment ¶ added in v0.17.0
func (c *Client) AddSimpleComment(ctx context.Context, issueKey string, simpleComment string) (*Comment, error)
AddSimpleComment declares the comment as an ADFDescription with no acceptance criteria or document url. Basically the simplest wrapper a client can have to add a comment to a ticket.
func (*Client) CreateIssue ¶
CreateIssue creates a new issue in Jira
func (*Client) CreateIssueLink ¶
func (c *Client) CreateIssueLink(ctx context.Context, linkType, inwardIssueKey, outwardIssueKey string) error
CreateIssueLink creates a link between two issues
func (*Client) DeleteIssueLink ¶ added in v0.9.1
DeleteIssueLink removes an issue link by ID.
func (*Client) Do ¶
Do executes an API request and unmarshals the response body into responseTarget. A 429 or 5xx is sent again up to 5 times. Retry-After, a number of seconds, is the wait when Jira sends it. Otherwise the wait starts at one second and doubles up to 16 seconds. The wait uses the request context, so a canceled caller stops between attempts.
func (*Client) DownloadAttachment ¶ added in v0.16.1
func (c *Client) DownloadAttachment(ctx context.Context, attachmentID string, maxBytes int64) (*AttachmentContent, error)
DownloadAttachment returns the content of the attachment with attachmentID, retrying as Do does. It asks Jira to serve the content itself rather than redirect to the media service, so the client's credentials are only ever sent to Jira. Content longer than maxBytes is not read past the limit and returns ErrAttachmentTooLarge.
func (*Client) GetIssue ¶ added in v0.9.1
func (c *Client) GetIssue(ctx context.Context, issueKey string, fields []string, properties []string) (*Issue, error)
GetIssue fetches an issue with the named fields and issue properties, or with every navigable field when no fields are named.
func (*Client) GetIssueLinkTypes ¶
GetIssueLinkTypes fetches all valid link types on the Jira instance
func (*Client) GetIssueLinks ¶
GetIssueLinks returns the links on an issue whose other end is inward, such as its blockers.
func (*Client) GetIssueProperty ¶
func (c *Client) GetIssueProperty(ctx context.Context, issueKey, propertyKey string) (string, error)
GetIssueProperty retrieves the id stored in an issue property's value.
func (*Client) ListIssueLinks ¶ added in v0.9.1
ListIssueLinks returns every link on an issue, inward and outward, with the ID DeleteIssueLink needs.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(ctx context.Context, method, path string, body any) (*http.Request, error)
NewRequest creates an API request A relative path can be provided, e.g. "/rest/api/3/issue"
func (*Client) SearchIssues ¶ added in v0.9.1
func (c *Client) SearchIssues(ctx context.Context, search IssueSearch) (*IssueSearchResult, error)
SearchIssues runs a JQL search and returns each issue with the requested fields and issue properties, so a caller reads a page of issues in one request.
func (*Client) SearchJQL ¶
func (c *Client) SearchJQL(ctx context.Context, jql string, maxResults int, nextPageToken string) (*SearchResult, error)
SearchJQL executes a JQL query and returns SearchResult
func (*Client) SetIssueProperty ¶ added in v0.9.1
func (c *Client) SetIssueProperty(ctx context.Context, issueKey, propertyKey string, value any) error
SetIssueProperty stores value under propertyKey on an issue, replacing any existing value.
func (*Client) UpdateIssue ¶ added in v0.9.1
UpdateIssue edits an issue. An empty update sends nothing.
type Comment ¶ added in v0.17.0
type Comment struct {
ID string `json:"id"`
}
Comment is a comment Jira created on an issue.
type Issue ¶ added in v0.9.1
type Issue struct {
ID string `json:"id"`
Key string `json:"key"`
Fields map[string]json.RawMessage `json:"fields"`
Properties map[string]json.RawMessage `json:"properties"`
}
Issue is a fetched Jira issue. Fields and Properties hold each returned value undecoded, so callers decode only what they asked for.
type IssueLink ¶
IssueLink is an issue link seen from the issue it was listed on. Exactly one of InwardIssue and OutwardIssue names the other issue; for a "Blocks" link listed on the blocked issue, InwardIssue is the blocker.
type IssueResponse ¶
IssueResponse is a basic representation of a created / fetched Jira issue
type IssueSearch ¶ added in v0.9.1
type IssueSearch struct {
JQL string
Fields []string
Properties []string
MaxResults int
NextPageToken string
}
IssueSearch selects the issues SearchIssues returns and what each carries.
type IssueSearchResult ¶ added in v0.9.1
type IssueSearchResult struct {
Issues []Issue `json:"issues"`
NextPageToken string `json:"nextPageToken"`
IsLast bool `json:"isLast"`
}
IssueSearchResult is one page of SearchIssues results.
type IssueUpdate ¶ added in v0.9.1
type IssueUpdate struct {
// Fields replaces each named field's value.
Fields map[string]any
// Update applies Jira's per-field operations, such as {"labels": [{"add": "x"}]}.
Update map[string]any
// Properties sets each named issue property in the same request as the edit.
Properties map[string]any
}
IssueUpdate describes an edit to one issue.
type SearchResult ¶
type SearchResult struct {
Issues []IssueResponse `json:"issues"`
NextPageToken string
IsLast bool
}
SearchResult is a response from JQL search