Documentation ¶
Overview ¶
Package jira contains the Jira bridge implementation
Index ¶
- Constants
- Variables
- func ParseTime(timeStr string) (time.Time, error)
- func UpdateIssueStatus(client *Client, issueKeyOrID string, desiredStateNameOrID string) (time.Time, error)
- type ChangeLogEntry
- type ChangeLogItem
- type ChangeLogIterator
- type ChangeLogPage
- type Client
- func (client *Client) AddComment(issueKeyOrID, body string) (*Comment, error)
- func (client *Client) CreateIssue(projectIDOrKey, title, body string, extra map[string]interface{}) (*IssueCreateResult, error)
- func (client *Client) DoTransition(issueKeyOrID string, transitionID string) (time.Time, error)
- func (client *Client) GetChangeLog(idOrKey string, maxResults int, startAt int) (*ChangeLogPage, error)
- func (client *Client) GetComments(idOrKey string, maxResults int, startAt int) (*CommentPage, error)
- func (client *Client) GetIssue(idOrKey string, fields []string, expand []string, properties []string) (*Issue, error)
- func (client *Client) GetProject(projectIDOrKey string) (*Project, error)
- func (client *Client) GetServerInfo() (*ServerInfo, error)
- func (client *Client) GetServerTime() (Time, error)
- func (client *Client) GetTransitions(issueKeyOrID string) (*TransitionList, error)
- func (client *Client) IterChangeLog(idOrKey string, pageSize int) *ChangeLogIterator
- func (client *Client) IterComments(idOrKey string, pageSize int) *CommentIterator
- func (client *Client) IterSearch(jql string, pageSize int) *SearchIterator
- func (client *Client) Login(credType, login, password string) error
- func (client *Client) RefreshSessionToken(username, password string) error
- func (client *Client) RefreshSessionTokenRaw(credentialsJSON []byte) error
- func (client *Client) Search(jql string, maxResults int, startAt int) (*SearchResult, error)
- func (client *Client) SetTokenCredentials(username, password string) error
- func (client *Client) UpdateComment(issueKeyOrID, commentID, body string) (*Comment, error)
- func (client *Client) UpdateIssueBody(issueKeyOrID, body string) (time.Time, error)
- func (client *Client) UpdateIssueTitle(issueKeyOrID, title string) (time.Time, error)
- func (client *Client) UpdateLabels(issueKeyOrID string, added, removed []bug.Label) (time.Time, error)
- type ClientTransport
- type Comment
- type CommentCreate
- type CommentIterator
- type CommentPage
- type Issue
- type IssueCreate
- type IssueCreateFields
- type IssueCreateResult
- type IssueFields
- type IssueType
- type Jira
- func (j *Jira) Configure(repo *cache.RepoCache, params core.BridgeParams, interactive bool) (core.Configuration, error)
- func (*Jira) LoginMetaKey() string
- func (*Jira) NewExporter() core.Exporter
- func (*Jira) NewImporter() core.Importer
- func (*Jira) Target() string
- func (*Jira) ValidParams() map[string]interface{}
- func (*Jira) ValidateConfig(conf core.Configuration) error
- type Project
- type SearchIterator
- type SearchRequest
- type SearchResult
- type ServerInfo
- type Session
- type SessionQuery
- type SessionResponse
- type Status
- type StatusCategory
- type Time
- type Transition
- type TransitionList
- type User
Constants ¶
const TimeFormat = "2006-01-02T15:04:05.999999999Z0700"
Variables ¶
var (
ErrMissingCredentials = errors.New("missing credentials")
)
Functions ¶
Types ¶
type ChangeLogEntry ¶
type ChangeLogEntry struct { ID string `json:"id"` Author User `json:"author"` Created Time `json:"created"` Items []ChangeLogItem `json:"items"` }
ChangeLogEntry One entry in a changelog https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue-getIssue
type ChangeLogItem ¶
type ChangeLogItem struct { Field string `json:"field"` FieldType string `json:"fieldtype"` From string `json:"from"` FromString string `json:"fromString"` To string `json:"to"` ToString string `json:"toString"` }
ChangeLogItem "field-change" data within a changelog entry. A single changelog entry might effect multiple fields. For example, closing an issue generally requires a change in "status" and "resolution" https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue-getIssue
type ChangeLogIterator ¶
type ChangeLogIterator struct { Err error // contains filtered or unexported fields }
ChangeLogIterator cursor within paginated results from the /search endpoint
func (*ChangeLogIterator) HasError ¶
func (cli *ChangeLogIterator) HasError() bool
HasError returns true if the iterator is holding an error
func (*ChangeLogIterator) HasNext ¶
func (cli *ChangeLogIterator) HasNext() bool
HasNext returns true if there is another item available in the result set
func (*ChangeLogIterator) Next ¶
func (cli *ChangeLogIterator) Next() *ChangeLogEntry
Next Return the next item in the result set and advance the iterator. Advancing the iterator may require fetching a new page.
type ChangeLogPage ¶
type ChangeLogPage struct { StartAt int `json:"startAt"` MaxResults int `json:"maxResults"` Total int `json:"total"` IsLast bool `json:"isLast"` // Cloud-only Entries []ChangeLogEntry `json:"histories"` Values []ChangeLogEntry `json:"values"` }
ChangeLogPage A collection of changes to issue metadata https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue-getIssue
func (*ChangeLogPage) IsLastPage ¶
func (clp *ChangeLogPage) IsLastPage() bool
IsLastPage return true if there are no more items beyond this page
func (*ChangeLogPage) NextStartAt ¶
func (clp *ChangeLogPage) NextStartAt() int
NextStartAt return the index of the first item on the next page
type Client ¶
Client Thin wrapper around the http.Client providing jira-specific methods for API endpoints
func NewClient ¶
NewClient Construct a new client connected to the provided server and utilizing the given context for asynchronous events
func (*Client) AddComment ¶
AddComment adds a new comment to an issue (and returns it).
func (*Client) CreateIssue ¶
func (client *Client) CreateIssue(projectIDOrKey, title, body string, extra map[string]interface{}) (*IssueCreateResult, error)
CreateIssue creates a new JIRA issue and returns it
func (*Client) DoTransition ¶
DoTransition changes the "status" of an issue
func (*Client) GetChangeLog ¶
func (client *Client) GetChangeLog(idOrKey string, maxResults int, startAt int) (*ChangeLogPage, error)
GetChangeLog fetch one page of the changelog for an issue via the /issue/{IssueIdOrKey}/changelog endpoint (for JIRA cloud) or /issue/{IssueIdOrKey} with (fields=*none&expand=changelog) (for JIRA server) https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue
func (*Client) GetComments ¶
func (client *Client) GetComments(idOrKey string, maxResults int, startAt int) (*CommentPage, error)
GetComments returns a page of comments via the issue/{IssueIdOrKey}/comment endpoint https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue-getComment
func (*Client) GetIssue ¶
func (client *Client) GetIssue(idOrKey string, fields []string, expand []string, properties []string) (*Issue, error)
GetIssue fetches an issue object via the /issue/{IssueIdOrKey} endpoint https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue
func (*Client) GetProject ¶
GetProject returns the project JSON object given its id or key
func (*Client) GetServerInfo ¶
func (client *Client) GetServerInfo() (*ServerInfo, error)
GetServerInfo Fetch server information from the /serverinfo endpoint https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue
func (*Client) GetServerTime ¶
GetServerTime returns the current time on the server
func (*Client) GetTransitions ¶
func (client *Client) GetTransitions(issueKeyOrID string) (*TransitionList, error)
GetTransitions returns a list of available transitions for an issue
func (*Client) IterChangeLog ¶
func (client *Client) IterChangeLog(idOrKey string, pageSize int) *ChangeLogIterator
IterChangeLog returns an iterator over entries in the changelog for an issue
func (*Client) IterComments ¶
func (client *Client) IterComments(idOrKey string, pageSize int) *CommentIterator
IterComments returns an iterator over paginated comments within an issue
func (*Client) IterSearch ¶
func (client *Client) IterSearch(jql string, pageSize int) *SearchIterator
IterSearch return an iterator over paginated results for a JQL search
func (*Client) RefreshSessionToken ¶
RefreshSessionToken formulate the JSON request object from the user credentials and POST it to the /session endpoint and get a session cookie
func (*Client) RefreshSessionTokenRaw ¶
RefreshSessionTokenRaw POST credentials to the /session endpoint and get a session cookie
func (*Client) Search ¶
Search Perform an issue a JQL search on the /search endpoint https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/search
func (*Client) SetTokenCredentials ¶
SetTokenCredentials POST credentials to the /session endpoint and get a session cookie
func (*Client) UpdateComment ¶
UpdateComment changes the text of a comment
func (*Client) UpdateIssueBody ¶
UpdateIssueBody changes the "description" field of a JIRA issue
func (*Client) UpdateIssueTitle ¶
UpdateIssueTitle changes the "summary" field of a JIRA issue
type ClientTransport ¶
type ClientTransport struct {
// contains filtered or unexported fields
}
ClientTransport wraps http.RoundTripper by adding a "Content-Type=application/json" header
func (*ClientTransport) RoundTrip ¶
RoundTrip overrides the default by adding the content-type header
func (*ClientTransport) SetCredentials ¶
func (ct *ClientTransport) SetCredentials(username string, token string)
type Comment ¶
type Comment struct { ID string `json:"id"` Body string `json:"body"` Author User `json:"author"` UpdateAuthor User `json:"updateAuthor"` Created Time `json:"created"` Updated Time `json:"updated"` }
Comment the JSON object for a single comment item returned in a list of comments https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue-getComments
type CommentCreate ¶
type CommentCreate struct {
Body string `json:"body"`
}
CommentCreate the JSOn object that is POSTed to the /comment endpoint to create a new comment
type CommentIterator ¶
type CommentIterator struct { Err error // contains filtered or unexported fields }
CommentIterator cursor within paginated results from the /comment endpoint
func (*CommentIterator) HasError ¶
func (ci *CommentIterator) HasError() bool
HasError returns true if the iterator is holding an error
func (*CommentIterator) HasNext ¶
func (ci *CommentIterator) HasNext() bool
HasNext returns true if there is another item available in the result set
func (*CommentIterator) Next ¶
func (ci *CommentIterator) Next() *Comment
Next Return the next item in the result set and advance the iterator. Advancing the iterator may require fetching a new page.
type CommentPage ¶
type CommentPage struct { StartAt int `json:"startAt"` MaxResults int `json:"maxResults"` Total int `json:"total"` Comments []Comment `json:"comments"` }
CommentPage the JSON object holding a single page of comments returned either by direct query or within an issue query https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue-getComments
func (*CommentPage) IsLastPage ¶
func (cp *CommentPage) IsLastPage() bool
IsLastPage return true if there are no more items beyond this page
func (*CommentPage) NextStartAt ¶
func (cp *CommentPage) NextStartAt() int
NextStartAt return the index of the first item on the next page
type Issue ¶
type Issue struct { ID string `json:"id"` Key string `json:"key"` Fields IssueFields `json:"fields"` ChangeLog ChangeLogPage `json:"changelog"` }
Issue Top-level object for an issue https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue-getIssue
type IssueCreate ¶
type IssueCreate struct {
Fields IssueCreateFields `json:"fields"`
}
IssueCreate the JSON object that is POSTed to the /issue endpoint to create a new issue
type IssueCreateFields ¶
type IssueCreateFields struct { Project Project `json:"project"` Summary string `json:"summary"` Description string `json:"description"` IssueType IssueType `json:"issuetype"` }
IssueCreateFields fields that are included in an IssueCreate request
type IssueCreateResult ¶
IssueCreateResult the JSON object returned after issue creation.
type IssueFields ¶
type IssueFields struct { Creator User `json:"creator"` Created Time `json:"created"` Description string `json:"description"` Summary string `json:"summary"` Comments CommentPage `json:"comment"` Labels []string `json:"labels"` }
IssueFields the JSON object returned as the "fields" member of an issue. There are a very large number of fields and many of them are custom. We only grab a few that we need. https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/issue-getIssue
type IssueType ¶
type IssueType struct {
ID string `json:"id"`
}
IssueType the JSON object representing an issue type (i.e. "bug", "task") Note that we don't use all the fields so we have only implemented a couple.
type Jira ¶
type Jira struct{}
Jira Main object for the bridge
func (*Jira) Configure ¶
func (j *Jira) Configure(repo *cache.RepoCache, params core.BridgeParams, interactive bool) (core.Configuration, error)
Configure sets up the bridge configuration
func (*Jira) LoginMetaKey ¶
func (*Jira) NewExporter ¶
NewExporter returns the jira exporter
func (*Jira) NewImporter ¶
NewImporter returns the jira importer
func (*Jira) ValidParams ¶
func (*Jira) ValidateConfig ¶
func (*Jira) ValidateConfig(conf core.Configuration) error
ValidateConfig returns true if all required keys are present
type Project ¶
Project the JSON object representing a project. Note that we don't use all the fields so we have only implemented a couple.
type SearchIterator ¶
type SearchIterator struct { Err error // contains filtered or unexported fields }
SearchIterator cursor within paginated results from the /search endpoint
func (*SearchIterator) HasError ¶
func (si *SearchIterator) HasError() bool
HasError returns true if the iterator is holding an error
func (*SearchIterator) HasNext ¶
func (si *SearchIterator) HasNext() bool
HasNext returns true if there is another item available in the result set
func (*SearchIterator) Next ¶
func (si *SearchIterator) Next() *Issue
Next Return the next item in the result set and advance the iterator. Advancing the iterator may require fetching a new page.
type SearchRequest ¶
type SearchRequest struct { JQL string `json:"jql"` StartAt int `json:"startAt"` MaxResults int `json:"maxResults"` Fields []string `json:"fields"` }
SearchRequest the JSON object POSTed to the /search endpoint
type SearchResult ¶
type SearchResult struct { StartAt int `json:"startAt"` MaxResults int `json:"maxResults"` Total int `json:"total"` Issues []Issue `json:"issues"` }
SearchResult The result type from querying the search endpoint https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/search
func (*SearchResult) IsLastPage ¶
func (sr *SearchResult) IsLastPage() bool
IsLastPage return true if there are no more items beyond this page
func (*SearchResult) NextStartAt ¶
func (sr *SearchResult) NextStartAt() int
NextStartAt return the index of the first item on the next page
type ServerInfo ¶
type ServerInfo struct { BaseURL string `json:"baseUrl"` Version string `json:"version"` VersionNumbers []int `json:"versionNumbers"` BuildNumber int `json:"buildNumber"` BuildDate Time `json:"buildDate"` ServerTime Time `json:"serverTime"` ScmInfo string `json:"scmInfo"` BuildPartnerName string `json:"buildPartnerName"` ServerTitle string `json:"serverTitle"` }
ServerInfo general server information returned by the /serverInfo endpoint. Notably `ServerTime` will tell you the time on the server.
type Session ¶
Session credential cookie name/value pair received after logging in and required to be sent on all subsequent requests
type SessionQuery ¶
SessionQuery the JSON object that is POSTed to the /session endpoint in order to login and get a session cookie
type SessionResponse ¶
type SessionResponse struct {
Session Session `json:"session"`
}
SessionResponse the JSON object returned from a /session query (login)
type Status ¶
type Status struct { ID string `json:"id"` Name string `json:"name"` Self string `json:"self"` Description string `json:"description"` StatusCategory StatusCategory `json:"statusCategory"` }
Status the JSON object representing a status (i.e. "Open", "Closed")
type StatusCategory ¶
type StatusCategory struct { ID int `json:"id"` Key string `json:"key"` Self string `json:"self"` ColorName string `json:"colorName"` Name string `json:"name"` }
StatusCategory the JSON object representing a status category
type Time ¶
Time is just a time.Time with a JSON serialization
func (*Time) UnmarshalJSON ¶
UnmarshalJSON parses an RFC3339 date string into a time object borrowed from: https://stackoverflow.com/a/39180230/141023
type Transition ¶
Transition the JSON object represenging a transition from one Status to another Status in a JIRA workflow
type TransitionList ¶
type TransitionList struct {
Transitions []Transition `json:"transitions"`
}
TransitionList the JSON object returned from the /transitions endpoint