git-bug: github.com/MichaelMure/git-bug/bridge/jira Index | Files

package jira

import "github.com/MichaelMure/git-bug/bridge/jira"

Package jira contains the Jira bridge implementation

Index

Package Files

client.go config.go export.go import.go jira.go

Constants

const TimeFormat = "2006-01-02T15:04:05.999999999Z0700"

Variables

var (
    ErrMissingCredentials = errors.New("missing credentials")
)

func ParseTime Uses

func ParseTime(timeStr string) (time.Time, error)

ParseTime parse an RFC3339 string with nanoseconds

func UpdateIssueStatus Uses

func UpdateIssueStatus(client *Client, issueKeyOrID string, desiredStateNameOrID string) (time.Time, error)

UpdateIssueStatus attempts to change the "status" field by finding a transition which achieves the desired state and then performing that transition

type ChangeLogEntry Uses

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 Uses

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 Uses

type ChangeLogIterator struct {
    Err error
    // contains filtered or unexported fields
}

ChangeLogIterator cursor within paginated results from the /search endpoint

func (*ChangeLogIterator) HasError Uses

func (cli *ChangeLogIterator) HasError() bool

HasError returns true if the iterator is holding an error

func (*ChangeLogIterator) HasNext Uses

func (cli *ChangeLogIterator) HasNext() bool

HasNext returns true if there is another item available in the result set

func (*ChangeLogIterator) Next Uses

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 Uses

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 Uses

func (clp *ChangeLogPage) IsLastPage() bool

IsLastPage return true if there are no more items beyond this page

func (*ChangeLogPage) NextStartAt Uses

func (clp *ChangeLogPage) NextStartAt() int

NextStartAt return the index of the first item on the next page

type Client Uses

type Client struct {
    *http.Client
    // contains filtered or unexported fields
}

Client Thin wrapper around the http.Client providing jira-specific methods for API endpoints

func NewClient Uses

func NewClient(ctx context.Context, serverURL string) *Client

NewClient Construct a new client connected to the provided server and utilizing the given context for asynchronous events

func (*Client) AddComment Uses

func (client *Client) AddComment(issueKeyOrID, body string) (*Comment, error)

AddComment adds a new comment to an issue (and returns it).

func (*Client) CreateIssue Uses

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 Uses

func (client *Client) DoTransition(issueKeyOrID string, transitionID string) (time.Time, error)

DoTransition changes the "status" of an issue

func (*Client) GetChangeLog Uses

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 Uses

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 Uses

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 Uses

func (client *Client) GetProject(projectIDOrKey string) (*Project, error)

GetProject returns the project JSON object given its id or key

func (*Client) GetServerInfo Uses

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 Uses

func (client *Client) GetServerTime() (Time, error)

GetServerTime returns the current time on the server

func (*Client) GetTransitions Uses

func (client *Client) GetTransitions(issueKeyOrID string) (*TransitionList, error)

GetTransitions returns a list of available transitions for an issue

func (*Client) IterChangeLog Uses

func (client *Client) IterChangeLog(idOrKey string, pageSize int) *ChangeLogIterator

IterChangeLog returns an iterator over entries in the changelog for an issue

func (*Client) IterComments Uses

func (client *Client) IterComments(idOrKey string, pageSize int) *CommentIterator

IterComments returns an iterator over paginated comments within an issue

func (*Client) IterSearch Uses

func (client *Client) IterSearch(jql string, pageSize int) *SearchIterator

IterSearch return an iterator over paginated results for a JQL search

func (*Client) Login Uses

func (client *Client) Login(credType, login, password string) error

Login POST credentials to the /session endpoint and get a session cookie

func (*Client) RefreshSessionToken Uses

func (client *Client) RefreshSessionToken(username, password string) error

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 Uses

func (client *Client) RefreshSessionTokenRaw(credentialsJSON []byte) error

RefreshSessionTokenRaw POST credentials to the /session endpoint and get a session cookie

func (*Client) Search Uses

func (client *Client) Search(jql string, maxResults int, startAt int) (*SearchResult, error)

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 Uses

func (client *Client) SetTokenCredentials(username, password string) error

SetTokenCredentials POST credentials to the /session endpoint and get a session cookie

func (*Client) UpdateComment Uses

func (client *Client) UpdateComment(issueKeyOrID, commentID, body string) (
    *Comment, error)

UpdateComment changes the text of a comment

func (*Client) UpdateIssueBody Uses

func (client *Client) UpdateIssueBody(issueKeyOrID, body string) (time.Time, error)

UpdateIssueBody changes the "description" field of a JIRA issue

func (*Client) UpdateIssueTitle Uses

func (client *Client) UpdateIssueTitle(issueKeyOrID, title string) (time.Time, error)

UpdateIssueTitle changes the "summary" field of a JIRA issue

func (*Client) UpdateLabels Uses

func (client *Client) UpdateLabels(issueKeyOrID string, added, removed []bug.Label) (time.Time, error)

UpdateLabels changes labels for an issue

type ClientTransport Uses

type ClientTransport struct {
    // contains filtered or unexported fields
}

ClientTransport wraps http.RoundTripper by adding a "Content-Type=application/json" header

func (*ClientTransport) RoundTrip Uses

func (ct *ClientTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip overrides the default by adding the content-type header

func (*ClientTransport) SetCredentials Uses

func (ct *ClientTransport) SetCredentials(username string, token string)

type Comment Uses

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 Uses

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 Uses

type CommentIterator struct {
    Err error
    // contains filtered or unexported fields
}

CommentIterator cursor within paginated results from the /comment endpoint

func (*CommentIterator) HasError Uses

func (ci *CommentIterator) HasError() bool

HasError returns true if the iterator is holding an error

func (*CommentIterator) HasNext Uses

func (ci *CommentIterator) HasNext() bool

HasNext returns true if there is another item available in the result set

func (*CommentIterator) Next Uses

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 Uses

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 Uses

func (cp *CommentPage) IsLastPage() bool

IsLastPage return true if there are no more items beyond this page

func (*CommentPage) NextStartAt Uses

func (cp *CommentPage) NextStartAt() int

NextStartAt return the index of the first item on the next page

type Issue Uses

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 Uses

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 Uses

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 Uses

type IssueCreateResult struct {
    ID  string `json:"id"`
    Key string `json:"key"`
}

IssueCreateResult the JSON object returned after issue creation.

type IssueFields Uses

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 Uses

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 Uses

type Jira struct{}

Jira Main object for the bridge

func (*Jira) Configure Uses

func (j *Jira) Configure(repo *cache.RepoCache, params core.BridgeParams) (core.Configuration, error)

Configure sets up the bridge configuration

func (*Jira) LoginMetaKey Uses

func (*Jira) LoginMetaKey() string

func (*Jira) NewExporter Uses

func (*Jira) NewExporter() core.Exporter

NewExporter returns the jira exporter

func (*Jira) NewImporter Uses

func (*Jira) NewImporter() core.Importer

NewImporter returns the jira importer

func (*Jira) Target Uses

func (*Jira) Target() string

Target returns "jira"

func (*Jira) ValidParams Uses

func (*Jira) ValidParams() map[string]interface{}

func (*Jira) ValidateConfig Uses

func (*Jira) ValidateConfig(conf core.Configuration) error

ValidateConfig returns true if all required keys are present

type Project Uses

type Project struct {
    ID  string `json:"id,omitempty"`
    Key string `json:"key,omitempty"`
}

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 Uses

type SearchIterator struct {
    Err error
    // contains filtered or unexported fields
}

SearchIterator cursor within paginated results from the /search endpoint

func (*SearchIterator) HasError Uses

func (si *SearchIterator) HasError() bool

HasError returns true if the iterator is holding an error

func (*SearchIterator) HasNext Uses

func (si *SearchIterator) HasNext() bool

HasNext returns true if there is another item available in the result set

func (*SearchIterator) Next Uses

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 Uses

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 Uses

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 Uses

func (sr *SearchResult) IsLastPage() bool

IsLastPage return true if there are no more items beyond this page

func (*SearchResult) NextStartAt Uses

func (sr *SearchResult) NextStartAt() int

NextStartAt return the index of the first item on the next page

type ServerInfo Uses

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 Uses

type Session struct {
    Name  string `json:"name"`
    Value string `json:"value"`
}

Session credential cookie name/value pair received after logging in and required to be sent on all subsequent requests

type SessionQuery Uses

type SessionQuery struct {
    Username string `json:"username"`
    Password string `json:"password"`
}

SessionQuery the JSON object that is POSTed to the /session endpoint in order to login and get a session cookie

type SessionResponse Uses

type SessionResponse struct {
    Session Session `json:"session"`
}

SessionResponse the JSON object returned from a /session query (login)

type Status Uses

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 Uses

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 Uses

type Time struct {
    time.Time
}

Time is just a time.Time with a JSON serialization

func (*Time) UnmarshalJSON Uses

func (t *Time) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON parses an RFC3339 date string into a time object borrowed from: https://stackoverflow.com/a/39180230/141023

type Transition Uses

type Transition struct {
    ID   string `json:"id"`
    Name string `json:"name"`
    To   Status `json:"to"`
}

Transition the JSON object represenging a transition from one Status to another Status in a JIRA workflow

type TransitionList Uses

type TransitionList struct {
    Transitions []Transition `json:"transitions"`
}

TransitionList the JSON object returned from the /transitions endpoint

type User Uses

type User struct {
    DisplayName  string `json:"displayName"`
    EmailAddress string `json:"emailAddress"`
    Key          string `json:"key"`
    Name         string `json:"name"`
}

User the JSON object representing a JIRA user https://docs.atlassian.com/software/jira/docs/api/REST/8.2.6/#api/2/user

Package jira imports 24 packages (graph) and is imported by 1 packages. Updated 2020-07-11. Refresh now. Tools for package owners.