jira

package module
v0.0.0-...-eb07612 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2016 License: MIT Imports: 12 Imported by: 0

README

go-jira

GoDoc Build Status Go Report Card Coverage Status

Go client library for Atlassian JIRA.

Go client library for Atlassian JIRA

Features

  • Authentication (HTTP Basic, OAuth, Session Cookie)
  • Create and receive issues
  • Create and retrieve issue transitions (status updates)
  • Call every API endpoint of the JIRA, even it is not directly implemented in this library

This package is not JIRA API complete (yet), but you can call every API endpoint you want. See Call a not implemented API endpoint how to do this. For all possible API endpoints of JRIA have a look at latest JIRA REST API documentation.

Compatible JIRA versions

This package was tested against JIRA v6.3.4 and v7.1.2.

Installation

It is go gettable

$ go get github.com/andygrunwald/go-jira

(optional) to run unit / example tests:

$ cd $GOPATH/src/github.com/andygrunwald/go-jira
$ go test -v ./...

API

Please have a look at the GoDoc documentation for a detailed API description.

The latest JIRA REST API documentation was the base document for this package.

Examples

Further a few examples how the API can be used. A few more examples are available in the GoDoc examples section.

Get a single issue

Lets retrieve MESOS-3325 from the Apache Mesos project.

package main

import (
	"fmt"
	"github.com/andygrunwald/go-jira"
)

func main() {
	jiraClient, _ := jira.NewClient(nil, "https://issues.apache.org/jira/")
	issue, _, _ := jiraClient.Issue.Get("MESOS-3325")

	fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary)
	fmt.Printf("Type: %s\n", issue.Fields.Type.Name)
	fmt.Printf("Priority: %s\n", issue.Fields.Priority.Name)

	// MESOS-3325: Running mesos-slave@0.23 in a container causes slave to be lost after a restart
	// Type: Bug
	// Priority: Critical
}

Some actions require an authenticated user. Here is an example with a session cookie authentification.

package main

import (
	"fmt"
	"github.com/andygrunwald/go-jira"
)

func main() {
	jiraClient, err := jira.NewClient(nil, "https://your.jira-instance.com/")
	if err != nil {
		panic(err)
	}

	res, err := jiraClient.Authentication.AcquireSessionCookie("username", "password")
	if err != nil || res == false {
		fmt.Printf("Result: %v\n", res)
		panic(err)
	}

	issue, _, err := jiraClient.Issue.Get("SYS-5156")
	if err != nil {
		panic(err)
	}

	fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary)
}
Call a not implemented API endpoint

Not all API endpoints of the JIRA API are implemented into go-jira. But you can call them anyway: Lets get all public projects of Atlassian`s JIRA instance.

package main

import (
	"fmt"
	"github.com/andygrunwald/go-jira"
)

func main() {
	jiraClient, _ := jira.NewClient(nil, "https://jira.atlassian.com/")
	req, _ := jiraClient.NewRequest("GET", "/rest/api/2/project", nil)

	projects := new([]jira.Project)
	_, err := jiraClient.Do(req, projects)
	if err != nil {
		panic(err)
	}

	for _, project := range *projects {
		fmt.Printf("%s: %s\n", project.Key, project.Name)
	}

	// ...
	// BAM: Bamboo
	// BAMJ: Bamboo JIRA Plugin
	// CLOV: Clover
	// CONF: Confluence
	// ...
}

Implementations

Code structure

The code structure of this package was inspired by google/go-github.

There is one main part (the client). Based on this main client the other endpoints, like Issues or Authentication are extracted in services. E.g. IssueService or AuthenticationService. These services own a responsibility of the single endpoints / usecases of JIRA.

Contribution

Contribution, in any kind of way, is highly welcome! It doesn't matter if you are not able to write code. Creating issues or holding talks and help other people to use go-jira is contribution, too! A few examples:

  • Correct typos in the README / documentation
  • Reporting bugs
  • Implement a new feature or endpoint
  • Sharing the love if go-jira and help people to get use to it

If you are new to pull requests, checkout Collaborating on projects using issues and pull requests / Creating a pull request.

License

This project is released under the terms of the MIT license.

Documentation

Index

Constants

View Source
const (
	// AssigneeAutomatic represents the value of the "Assignee: Automatic" of JIRA
	AssigneeAutomatic = "-1"
)

Variables

This section is empty.

Functions

func CheckResponse

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).

Types

type Attachment

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

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 (*AuthenticationService) AcquireSessionCookie

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 (*AuthenticationService) Authenticated

func (s *AuthenticationService) Authenticated() bool

Authenticated reports if the current Client has an authenticated session with JIRA

func (*AuthenticationService) GetCurrentUser

func (s *AuthenticationService) GetCurrentUser() (*Session, error)

GetCurrentUser gets the details of the current user.

JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#auth/1/session

func (*AuthenticationService) Logout

func (s *AuthenticationService) Logout() error

Logout logs out the current user that has been authenticated and the session in the client is destroyed.

JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#auth/1/session

type AvatarUrls

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

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

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

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 (*BoardService) CreateBoard

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 (*BoardService) DeleteBoard

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 (*BoardService) GetAllBoards

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 (*BoardService) GetAllSprints

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 (*BoardService) GetBoard

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

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

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

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 (*Client) Do

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 (*Client) GetBaseURL

func (c *Client) GetBaseURL() url.URL

GetBaseURL will return you the Base URL. This is the same URL as in the NewClient constructor

func (*Client) NewMultiPartRequest

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 (*Client) NewRequest

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

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

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

type Comments struct {
	Comments []*Comment `json:"comments,omitempty"`
}

Comments represents a list of Comment.

type Component

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

type CreateTransitionPayload struct {
	Transition TransitionPayload `json:"transition"`
}

CreateTransitionPayload is used for creating new issue transitions

type CustomFields

type CustomFields map[string]string

CustomFields represents custom fields of JIRA This can heavily differ between JIRA instances

type Epic

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

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

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

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

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

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 (*IssueService) AddComment

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 (*IssueService) Create

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 (*IssueService) DoTransition

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 (*IssueService) DownloadAttachment

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 (*IssueService) Get

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 (*IssueService) GetCustomFields

func (s *IssueService) GetCustomFields(issueID string) (CustomFields, *Response, error)

GetCustomFields returns a map of customfield_* keys with string values

func (*IssueService) GetTransitions

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 (*IssueService) PostAttachment

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 (*IssueService) Search

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

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

type IssuesInSprintResult struct {
	Issues []Issue `json:"issues"`
}

IssuesInSprintResult represents a wrapper struct for search result

type IssuesWrapper

type IssuesWrapper struct {
	Issues []string `json:"issues"`
}

IssuesWrapper represents a wrapper struct for moving issues to sprint

type Priority

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

type Progress struct {
	Progress int `json:"progress"`
	Total    int `json:"total"`
}

Progress represents the progress of a JIRA issue.

type Project

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

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

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

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

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 (*ProjectService) Get

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 (*ProjectService) GetList

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

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

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

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

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

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

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 (*SprintService) GetIssuesForSprint

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 (*SprintService) MoveIssuesToSprint

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

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

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

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

type Time time.Time

Time represents the Time definition of JIRA as a time.Time of go

func (*Time) UnmarshalJSON

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

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

type TransitionField struct {
	Required bool `json:"required"`
}

TransitionField represents the value of one Transistion

type TransitionPayload

type TransitionPayload struct {
	ID string `json:"id"`
}

TransitionPayload represents the request payload of Transistion calls like DoTransition

type User

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

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

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

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL