const ( // AssigneeAutomatic represents the value of the "Assignee: Automatic" of JIRA AssigneeAutomatic = "-1" )
func CheckResponse(r *http.Response) error
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. The caller is responsible to analyze the response body. The body can contain JSON (if the error is intended) or xml (sometimes JIRA just failes).
type Attachment struct { Self string `json:"self,omitempty"` ID string `json:"id,omitempty"` Filename string `json:"filename,omitempty"` Author *User `json:"author,omitempty"` Created string `json:"created,omitempty"` Size int `json:"size,omitempty"` MimeType string `json:"mimeType,omitempty"` Content string `json:"content,omitempty"` Thumbnail string `json:"thumbnail,omitempty"` }
Attachment represents a JIRA attachment
type AuthenticationService struct {
// contains filtered or unexported fields
}
AuthenticationService handles authentication for the JIRA instance / API.
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#authentication
func (s *AuthenticationService) AcquireSessionCookie(username, password string) (bool, error)
AcquireSessionCookie creates a new session for a user in JIRA. Once a session has been successfully created it can be used to access any of JIRA's remote APIs and also the web UI by passing the appropriate HTTP Cookie header. The header will by automatically applied to every API request. Note that it is generally preferrable to use HTTP BASIC authentication with the REST API. However, this resource may be used to mimic the behaviour of JIRA's log-in page (e.g. to display log-in errors to a user).
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#auth/1/session
func (s *AuthenticationService) Authenticated() bool
Authenticated reports if the current Client has an authenticated session with JIRA
type AvatarUrls struct { Four8X48 string `json:"48x48,omitempty"` Two4X24 string `json:"24x24,omitempty"` One6X16 string `json:"16x16,omitempty"` Three2X32 string `json:"32x32,omitempty"` }
AvatarUrls represents different dimensions of avatars / images
type Board struct { ID int `json:"id,omitempty"` Self string `json:"self,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` FilterID int `json:"filterId,omitempty"` }
Board represents a JIRA agile board
type BoardListOptions struct { // BoardType filters results to boards of the specified type. // Valid values: scrum, kanban. BoardType string `url:"boardType,omitempty"` // Name filters results to boards that match or partially match the specified name. Name string `url:"name,omitempty"` // ProjectKeyOrID filters results to boards that are relevant to a project. // Relevance meaning that the JQL filter defined in board contains a reference to a project. ProjectKeyOrID string `url:"projectKeyOrId,omitempty"` SearchOptions }
BoardListOptions specifies the optional parameters to the BoardService.GetList
type BoardService struct {
// contains filtered or unexported fields
}
BoardService handles Agile Boards for the JIRA instance / API.
JIRA API docs: https://docs.atlassian.com/jira-software/REST/server/
func (s *BoardService) CreateBoard(board *Board) (*Board, *Response, error)
CreateBoard creates a new board. Board name, type and filter Id is required. name - Must be less than 255 characters. type - Valid values: scrum, kanban filterId - Id of a filter that the user has permissions to view. Note, if the user does not have the 'Create shared objects' permission and tries to create a shared board, a private board will be created instead (remember that board sharing depends on the filter sharing).
JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-createBoard
func (s *BoardService) DeleteBoard(boardID int) (*Board, *Response, error)
DeleteBoard will delete an agile board.
JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-deleteBoard
func (s *BoardService) GetAllBoards(opt *BoardListOptions) (*BoardsList, *Response, error)
GetAllBoards will returns all boards. This only includes boards that the user has permission to view.
JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getAllBoards
func (s *BoardService) GetAllSprints(boardID string) ([]Sprint, *Response, error)
GetAllSprints will returns all sprints from a board, for a given board Id. This only includes sprints that the user has permission to view.
JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board/{boardId}/sprint
func (s *BoardService) GetBoard(boardID int) (*Board, *Response, error)
GetBoard will returns the board for the given boardID. This board will only be returned if the user has permission to view it.
JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-getBoard
type BoardsList struct { MaxResults int `json:"maxResults"` StartAt int `json:"startAt"` Total int `json:"total"` IsLast bool `json:"isLast"` Values []Board `json:"values"` }
BoardsList reflects a list of agile boards
type Client struct { // Services used for talking to different parts of the JIRA API. Authentication *AuthenticationService Issue *IssueService Project *ProjectService Board *BoardService Sprint *SprintService // contains filtered or unexported fields }
A Client manages communication with the JIRA API.
func NewClient(httpClient *http.Client, baseURL string) (*Client, error)
NewClient returns a new JIRA API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication you can follow the preferred solution and provide an http.Client that will perform the authentication for you with OAuth and HTTP Basic (such as that provided by the golang.org/x/oauth2 library). As an alternative you can use Session Cookie based authentication provided by this package as well. See https://docs.atlassian.com/jira/REST/latest/#authentication baseURL is the HTTP endpoint of your JIRA instance and should always be specified with a trailing slash.
func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
func (c *Client) GetBaseURL() url.URL
GetBaseURL will return you the Base URL. This is the same URL as in the NewClient constructor
func (c *Client) NewMultiPartRequest(method, urlStr string, buf *bytes.Buffer) (*http.Request, error)
NewMultiPartRequest creates an API request including a multi-part file. A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by buf is a multipart form.
func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type Comment struct { ID string `json:"id,omitempty"` Self string `json:"self,omitempty"` Name string `json:"name,omitempty"` Author User `json:"author,omitempty"` Body string `json:"body,omitempty"` UpdateAuthor User `json:"updateAuthor,omitempty"` Updated string `json:"updated,omitempty"` Created string `json:"created,omitempty"` Visibility CommentVisibility `json:"visibility,omitempty"` }
Comment represents a comment by a person to an issue in JIRA.
type CommentVisibility struct { Type string `json:"type,omitempty"` Value string `json:"value,omitempty"` }
CommentVisibility represents he visibility of a comment. E.g. Type could be "role" and Value "Administrators"
type Comments struct { Comments []*Comment `json:"comments,omitempty"` }
Comments represents a list of Comment.
type Component struct { Self string `json:"self,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` }
Component represents a "component" of a JIRA issue. Components can be user defined in every JIRA instance.
type CreateTransitionPayload struct { Transition TransitionPayload `json:"transition"` }
CreateTransitionPayload is used for creating new issue transitions
type CustomFields map[string]string
CustomFields represents custom fields of JIRA This can heavily differ between JIRA instances
type Epic struct { ID int `json:"id"` Key string `json:"key"` Self string `json:"self"` Name string `json:"name"` Summary string `json:"summary"` Done bool `json:"done"` }
Epic represents the epic to which an issue is associated Not that this struct does not process the returned "color" value
type FixVersion struct { Archived *bool `json:"archived,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` ProjectID int `json:"projectId,omitempty"` ReleaseDate string `json:"releaseDate,omitempty"` Released *bool `json:"released,omitempty"` Self string `json:"self,omitempty"` UserReleaseDate string `json:"userReleaseDate,omitempty"` }
FixVersion represents a software release in which an issue is fixed.
type Issue struct { Expand string `json:"expand,omitempty"` ID string `json:"id,omitempty"` Self string `json:"self,omitempty"` Key string `json:"key,omitempty"` Fields *IssueFields `json:"fields,omitempty"` }
Issue represents a JIRA issue.
type IssueFields struct { // TODO Missing fields // * "timespent": null, // * "aggregatetimespent": null, // * "workratio": -1, // * "lastViewed": null, // * "timeestimate": null, // * "aggregatetimeoriginalestimate": null, // * "timeoriginalestimate": null, // * "timetracking": {}, // * "aggregatetimeestimate": null, // * "environment": null, // * "duedate": null, Type IssueType `json:"issuetype"` Project Project `json:"project,omitempty"` Resolution *Resolution `json:"resolution,omitempty"` Priority *Priority `json:"priority,omitempty"` Resolutiondate string `json:"resolutiondate,omitempty"` Created string `json:"created,omitempty"` Watches *Watches `json:"watches,omitempty"` Assignee *User `json:"assignee,omitempty"` Updated string `json:"updated,omitempty"` Description string `json:"description,omitempty"` Summary string `json:"summary"` Creator *User `json:"Creator,omitempty"` Reporter *User `json:"reporter,omitempty"` Components []*Component `json:"components,omitempty"` Status *Status `json:"status,omitempty"` Progress *Progress `json:"progress,omitempty"` AggregateProgress *Progress `json:"aggregateprogress,omitempty"` Worklog *Worklog `json:"worklog,omitempty"` IssueLinks []*IssueLink `json:"issuelinks,omitempty"` Comments *Comments `json:"comment,omitempty"` FixVersions []*FixVersion `json:"fixVersions,omitempty"` Labels []string `json:"labels,omitempty"` Subtasks []*Subtasks `json:"subtasks,omitempty"` Attachments []*Attachment `json:"attachment,omitempty"` Epic *Epic `json:"epic,omitempty"` }
IssueFields represents single fields of a JIRA issue. Every JIRA issue has several fields attached.
type IssueLink struct { ID string `json:"id,omitempty"` Self string `json:"self,omitempty"` Type IssueLinkType `json:"type"` OutwardIssue *Issue `json:"outwardIssue"` InwardIssue *Issue `json:"inwardIssue"` Comment *Comment `json:"comment,omitempty"` }
IssueLink represents a link between two issues in JIRA.
type IssueLinkType struct { ID string `json:"id,omitempty"` Self string `json:"self,omitempty"` Name string `json:"name"` Inward string `json:"inward"` Outward string `json:"outward"` }
IssueLinkType represents a type of a link between to issues in JIRA. Typical issue link types are "Related to", "Duplicate", "Is blocked by", etc.
type IssueService struct {
// contains filtered or unexported fields
}
IssueService handles Issues for the JIRA instance / API.
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issue
func (s *IssueService) AddComment(issueID string, comment *Comment) (*Comment, *Response, error)
AddComment adds a new comment to issueID.
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issue-addComment
func (s *IssueService) AddLink(issueLink *IssueLink) (*Response, error)
AddLink adds a link between two issues.
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issueLink
func (s *IssueService) Create(issue *Issue) (*Issue, *Response, error)
Create creates an issue or a sub-task from a JSON representation. Creating a sub-task is similar to creating a regular issue, with two important differences: The issueType field must correspond to a sub-task issue type and you must provide a parent field in the issue create request containing the id or key of the parent issue.
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issue-createIssues
func (s *IssueService) DoTransition(ticketID, transitionID string) (*Response, error)
DoTransition performs a transition on an issue. When performing the transition you can update or set other issue fields.
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issue-doTransition
func (s *IssueService) DownloadAttachment(attachmentID string) (*Response, error)
DownloadAttachment returns a Response of an attachment for a given attachmentID. The attachment is in the Response.Body of the response. This is an io.ReadCloser. The caller should close the resp.Body.
func (s *IssueService) Get(issueID string) (*Issue, *Response, error)
Get returns a full representation of the issue for the given issue key. JIRA will attempt to identify the issue by the issueIdOrKey path parameter. This can be an issue id, or an issue key. If the issue cannot be found via an exact match, JIRA will also look for the issue in a case-insensitive way, or by looking to see if the issue was moved.
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issue-getIssue
func (s *IssueService) GetCustomFields(issueID string) (CustomFields, *Response, error)
GetCustomFields returns a map of customfield_* keys with string values
func (s *IssueService) GetTransitions(id string) ([]Transition, *Response, error)
GetTransitions gets a list of the transitions possible for this issue by the current user, along with fields that are required and their types.
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issue-getTransitions
func (s *IssueService) PostAttachment(attachmentID string, r io.Reader, attachmentName string) (*[]Attachment, *Response, error)
PostAttachment uploads r (io.Reader) as an attachment to a given attachmentID
func (s *IssueService) Search(jql string, options *SearchOptions) ([]Issue, *Response, error)
Search will search for tickets according to the jql
JIRA API docs: https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-query-issues
type IssueType struct { Self string `json:"self,omitempty"` ID string `json:"id,omitempty"` Description string `json:"description,omitempty"` IconURL string `json:"iconUrl,omitempty"` Name string `json:"name,omitempty"` Subtask bool `json:"subtask,omitempty"` AvatarID int `json:"avatarId,omitempty"` }
IssueType represents a type of a JIRA issue. Typical types are "Request", "Bug", "Story", ...
type IssuesInSprintResult struct { Issues []Issue `json:"issues"` }
IssuesInSprintResult represents a wrapper struct for search result
type IssuesWrapper struct { Issues []string `json:"issues"` }
IssuesWrapper represents a wrapper struct for moving issues to sprint
type Priority struct { Self string `json:"self,omitempty"` IconURL string `json:"iconUrl,omitempty"` Name string `json:"name,omitempty"` ID string `json:"id,omitempty"` }
Priority represents a priority of a JIRA issue. Typical types are "Normal", "Moderate", "Urgent", ...
type Progress struct { Progress int `json:"progress"` Total int `json:"total"` }
Progress represents the progress of a JIRA issue.
type Project struct { Expand string `json:"expand,omitempty"` Self string `json:"self,omitempty"` ID string `json:"id,omitempty"` Key string `json:"key,omitempty"` Description string `json:"description,omitempty"` Lead User `json:"lead,omitempty"` Components []ProjectComponent `json:"components,omitempty"` IssueTypes []IssueType `json:"issueTypes,omitempty"` URL string `json:"url,omitempty"` Email string `json:"email,omitempty"` AssigneeType string `json:"assigneeType,omitempty"` Versions []Version `json:"versions,omitempty"` Name string `json:"name,omitempty"` Roles struct { Developers string `json:"Developers,omitempty"` } `json:"roles,omitempty"` AvatarUrls AvatarUrls `json:"avatarUrls,omitempty"` ProjectCategory ProjectCategory `json:"projectCategory,omitempty"` }
Project represents a JIRA Project.
type ProjectCategory struct { Self string `json:"self"` ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` }
ProjectCategory represents a single project category
type ProjectComponent struct { Self string `json:"self"` ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` Lead User `json:"lead"` AssigneeType string `json:"assigneeType"` Assignee User `json:"assignee"` RealAssigneeType string `json:"realAssigneeType"` RealAssignee User `json:"realAssignee"` IsAssigneeTypeValid bool `json:"isAssigneeTypeValid"` Project string `json:"project"` ProjectID int `json:"projectId"` }
ProjectComponent represents a single component of a project
type ProjectList []struct { Expand string `json:"expand"` Self string `json:"self"` ID string `json:"id"` Key string `json:"key"` Name string `json:"name"` AvatarUrls AvatarUrls `json:"avatarUrls"` ProjectTypeKey string `json:"projectTypeKey"` ProjectCategory ProjectCategory `json:"projectCategory,omitempty"` }
ProjectList represent a list of Projects
type ProjectService struct {
// contains filtered or unexported fields
}
ProjectService handles projects for the JIRA instance / API.
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/project
func (s *ProjectService) Get(projectID string) (*Project, *Response, error)
Get returns a full representation of the project for the given issue key. JIRA will attempt to identify the project by the projectIdOrKey path parameter. This can be an project id, or an project key.
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/project-getProject
func (s *ProjectService) GetList() (*ProjectList, *Response, error)
GetList gets all projects form JIRA
JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/project-getAllProjects
type Resolution struct { Self string `json:"self"` ID string `json:"id"` Description string `json:"description"` Name string `json:"name"` }
Resolution represents a resolution of a JIRA issue. Typical types are "Fixed", "Suspended", "Won't Fix", ...
type Response struct { *http.Response StartAt int MaxResults int Total int }
Response represents JIRA API response. It wraps http.Response returned from API and provides information about paging.
type SearchOptions struct { // StartAt: The starting index of the returned projects. Base index: 0. StartAt int `url:"startAt,omitempty"` // MaxResults: The maximum number of projects to return per page. Default: 50. MaxResults int `url:"maxResults,omitempty"` }
SearchOptions specifies the optional parameters to various List methods that support pagination. Pagination is used for the JIRA REST APIs to conserve server resources and limit response size for resources that return potentially large collection of items. A request to a pages API will result in a values array wrapped in a JSON object with some paging metadata Default Pagination options
type Session struct { Self string `json:"self,omitempty"` Name string `json:"name,omitempty"` Session struct { Name string `json:"name"` Value string `json:"value"` } `json:"session,omitempty"` LoginInfo struct { FailedLoginCount int `json:"failedLoginCount"` LoginCount int `json:"loginCount"` LastFailedLoginTime string `json:"lastFailedLoginTime"` PreviousLoginTime string `json:"previousLoginTime"` } `json:"loginInfo"` Cookies []*http.Cookie }
Session represents a Session JSON response by the JIRA API.
type Sprint struct { ID int `json:"id"` Name string `json:"name"` CompleteDate *time.Time `json:"completeDate"` EndDate *time.Time `json:"endDate"` StartDate *time.Time `json:"startDate"` OriginBoardID int `json:"originBoardId"` Self string `json:"self"` State string `json:"state"` }
Sprint represents a sprint on JIRA agile board
type SprintService struct {
// contains filtered or unexported fields
}
SprintService handles sprints in JIRA Agile API. See https://docs.atlassian.com/jira-software/REST/cloud/
func (s *SprintService) GetIssuesForSprint(sprintID int) ([]Issue, *Response, error)
GetIssuesForSprint returns all issues in a sprint, for a given sprint Id. This only includes issues that the user has permission to view. By default, the returned issues are ordered by rank.
JIRA API Docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/sprint-getIssuesForSprint
func (s *SprintService) MoveIssuesToSprint(sprintID int, issueIDs []string) (*Response, error)
MoveIssuesToSprint moves issues to a sprint, for a given sprint Id. Issues can only be moved to open or active sprints. The maximum number of issues that can be moved in one operation is 50.
JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/sprint-moveIssuesToSprint
type Status struct { Self string `json:"self"` Description string `json:"description"` IconURL string `json:"iconUrl"` Name string `json:"name"` ID string `json:"id"` StatusCategory StatusCategory `json:"statusCategory"` }
Status represents the current status of a JIRA issue. Typical status are "Open", "In Progress", "Closed", ... Status can be user defined in every JIRA instance.
type StatusCategory struct { Self string `json:"self"` ID int `json:"id"` Name string `json:"name"` Key string `json:"key"` ColorName string `json:"colorName"` }
StatusCategory represents the category a status belongs to. Those categories can be user defined in every JIRA instance.
type Subtasks struct { ID string `json:"id"` Key string `json:"key"` Self string `json:"self"` Fields IssueFields `json:"fields"` }
Subtasks represents all issues of a parent issue.
type Time time.Time
Time represents the Time definition of JIRA as a time.Time of go
func (t *Time) UnmarshalJSON(b []byte) error
UnmarshalJSON will transform the JIRA time into a time.Time during the transformation of the JIRA JSON response
type Transition struct { ID string `json:"id"` Name string `json:"name"` Fields map[string]TransitionField `json:"fields"` }
Transition represents an issue transition in JIRA
type TransitionField struct { Required bool `json:"required"` }
TransitionField represents the value of one Transistion
type TransitionPayload struct { ID string `json:"id"` }
TransitionPayload represents the request payload of Transistion calls like DoTransition
type User struct { Self string `json:"self,omitempty"` Name string `json:"name,omitempty"` Key string `json:"key,omitempty"` EmailAddress string `json:"emailAddress,omitempty"` AvatarUrls AvatarUrls `json:"avatarUrls,omitempty"` DisplayName string `json:"displayName,omitempty"` Active bool `json:"active,omitempty"` TimeZone string `json:"timeZone,omitempty"` }
User represents a user who is this JIRA issue assigned to.
type Version struct { Self string `json:"self"` ID string `json:"id"` Name string `json:"name"` Archived bool `json:"archived"` Released bool `json:"released"` ReleaseDate string `json:"releaseDate"` UserReleaseDate string `json:"userReleaseDate"` ProjectID int `json:"projectId"` // Unlike other IDs, this is returned as a number }
Version represents a single release version of a project
type Watches struct { Self string `json:"self,omitempty"` WatchCount int `json:"watchCount,omitempty"` IsWatching bool `json:"isWatching,omitempty"` }
Watches represents a type of how many user are "observing" a JIRA issue to track the status / updates.
type Worklog struct { StartAt int `json:"startAt"` MaxResults int `json:"maxResults"` Total int `json:"total"` Worklogs []WorklogRecord `json:"worklogs"` }
Worklog represents the work log of a JIRA issue. One Worklog contains zero or n WorklogRecords JIRA Wiki: https://confluence.atlassian.com/jira/logging-work-on-an-issue-185729605.html
type WorklogRecord struct { Self string `json:"self"` Author User `json:"author"` UpdateAuthor User `json:"updateAuthor"` Comment string `json:"comment"` Created Time `json:"created"` Updated Time `json:"updated"` Started Time `json:"started"` TimeSpent string `json:"timeSpent"` TimeSpentSeconds int `json:"timeSpentSeconds"` ID string `json:"id"` IssueID string `json:"issueId"` }
WorklogRecord represents one entry of a Worklog