Documentation
¶
Overview ¶
Package jira is a small HTTP client for an on-prem Jira Data Center/Server instance (e.g. jira.cc.hm.edu). It authenticates with a Personal Access Token (PAT) via the `Authorization: Bearer <PAT>` header and talks to the REST API v2 (`/rest/api/2/...`). It mirrors the structure of the zpa package.
Index ¶
- type Attachment
- type Comment
- type CommentPage
- type Issue
- type IssueFields
- type IssueWithRequestType
- type Jira
- func (j *Jira) AddAttachment(key, filename string, data []byte) ([]Attachment, error)
- func (j *Jira) AddComment(key, body string) error
- func (j *Jira) Comments(key string) ([]Comment, error)
- func (j *Jira) CreateIssue(in NewIssue) (*Issue, error)
- func (j *Jira) GetIssue(key string) (*Issue, error)
- func (j *Jira) Myself() (*User, error)
- func (j *Jira) OpenIssues(project string) ([]Issue, error)
- func (j *Jira) OpenIssuesWithRequestType(project string) ([]IssueWithRequestType, error)
- func (j *Jira) Search(jql string) ([]Issue, error)
- func (j *Jira) TransitionIssue(key, transitionID string) error
- func (j *Jira) TransitionIssueByName(key, name string) error
- func (j *Jira) Transitions(key string) ([]Transition, error)
- type NamedRef
- type NewIssue
- type ProjectRef
- type Transition
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
ID string `json:"id"`
Filename string `json:"filename"`
Size int `json:"size"`
MimeType string `json:"mimeType"`
Content string `json:"content"` // download URL
}
Attachment is the subset of Jira's attachment representation we read back.
type Comment ¶
type Comment struct {
ID string `json:"id"`
Author *User `json:"author,omitempty"`
Body string `json:"body"`
Created string `json:"created"`
Updated string `json:"updated"`
}
Comment is a single issue comment.
type CommentPage ¶
CommentPage is the (paginated) comment container embedded in an issue's fields.
type Issue ¶
type Issue struct {
ID string `json:"id"`
Key string `json:"key"`
Self string `json:"self"`
Fields IssueFields `json:"fields"`
}
Issue is the subset of a Jira issue we read back.
type IssueFields ¶
type IssueFields struct {
Summary string `json:"summary"`
Description string `json:"description"`
Status *NamedRef `json:"status,omitempty"`
IssueType *NamedRef `json:"issuetype,omitempty"`
Project *ProjectRef `json:"project,omitempty"`
Reporter *User `json:"reporter,omitempty"`
Created string `json:"created,omitempty"`
Comment *CommentPage `json:"comment,omitempty"`
}
type IssueWithRequestType ¶
IssueWithRequestType is an issue plus its JSM customer request type name (empty when the issue was not raised through a request type).
type Jira ¶
type Jira struct {
// contains filtered or unexported fields
}
func New ¶
New builds a Jira client. baseurl is the instance root (e.g. "https://jira.cc.hm.edu"); a trailing slash is trimmed. token is the PAT. It does not perform any network call; use Myself to verify the connection.
func (*Jira) AddAttachment ¶
func (j *Jira) AddAttachment(key, filename string, data []byte) ([]Attachment, error)
AddAttachment uploads a file to an issue. Jira's attachment endpoint is multipart/form-data (not JSON) and requires the X-Atlassian-Token: no-check header to bypass the XSRF check, so it does not go through do().
func (*Jira) AddComment ¶
AddComment posts a plain-text comment to an issue.
func (*Jira) Comments ¶
Comments returns all comments of an issue, oldest first (Jira's default order).
func (*Jira) CreateIssue ¶
CreateIssue creates a new issue and returns the created key/id.
func (*Jira) Myself ¶
Myself calls GET /rest/api/2/myself and returns the authenticated user. It is the cheapest way to verify that baseurl and PAT are valid.
func (*Jira) OpenIssues ¶
OpenIssues returns the not-yet-done issues of a project (statusCategory != Done), newest first. project falls back to the configured default when empty; if both are empty the search spans all projects the PAT can see.
func (*Jira) OpenIssuesWithRequestType ¶
func (j *Jira) OpenIssuesWithRequestType(project string) ([]IssueWithRequestType, error)
OpenIssuesWithRequestType returns the open (not-done) issues of a project, each annotated with its JSM customer request type. project falls back to the configured default when empty.
func (*Jira) Search ¶
Search runs a JQL query and returns the matching issues, transparently paging through the result set (up to searchMaxIssues). Only the fields needed for a list view (summary, status, issuetype) are requested.
func (*Jira) TransitionIssue ¶
TransitionIssue moves an issue through the given transition id.
func (*Jira) TransitionIssueByName ¶
TransitionIssueByName is a convenience wrapper that looks up the transition by (case-insensitive) name and applies it — handy because IDs differ per workflow while names like "Done" are stable.
func (*Jira) Transitions ¶
func (j *Jira) Transitions(key string) ([]Transition, error)
Transitions lists the transitions available for an issue in its current status. Their IDs are what TransitionIssue expects — they are workflow- and status-specific, not global.
type NewIssue ¶
NewIssue describes an issue to be created. ProjectKey and IssueType fall back to the client defaults / "Task" when empty.
type ProjectRef ¶
type ProjectRef struct {
Key string `json:"key,omitempty"`
}
type Transition ¶
Transition is one of the workflow transitions currently available on an issue.