jira

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("received 404")
View Source
var ErrUnauthorized = errors.New("received 401")

Functions

func NewAuthenticatedJira

func NewAuthenticatedJira(service, user string) (ticket.TicketSystem, error)

func NewJira

func NewJira(service, user string) ticket.TicketSystem

Types

type ApplicationRoles

type ApplicationRoles struct {
	Size           int64                  `json:"size"`
	Items          []ApplicationRolesItem `json:"items"`
	PagingCallback Callback               `json:"pagingCallback"`
	Callback       Callback               `json:"callback"`
	MaxResults     int64                  `json:"max-results"`
}

type ApplicationRolesItem

type ApplicationRolesItem struct {
	Key                  string   `json:"key"`
	Groups               []string `json:"groups"`
	Name                 string   `json:"name"`
	DefaultGroups        []string `json:"defaultGroups"`
	SelectedByDefault    bool     `json:"selectedByDefault"`
	Defined              bool     `json:"defined"`
	NumberOfSeats        int64    `json:"numberOfSeats"`
	RemainingSeats       int64    `json:"remainingSeats"`
	UserCount            int64    `json:"userCount"`
	UserCountDescription string   `json:"userCountDescription"`
	HasUnlimitedSeats    bool     `json:"hasUnlimitedSeats"`
	Platform             bool     `json:"platform"`
}

type Attachment

type Attachment struct {
	ID             int64            `json:"id"`
	Self           string           `json:"self"`
	Filename       string           `json:"filename"`
	Author         AttachmentAuthor `json:"author"`
	Created        string           `json:"created"`
	Size           int64            `json:"size"`
	MIMEType       string           `json:"mimeType"`
	Content        string           `json:"content"`
	Thumbnail      string           `json:"thumbnail"`
	MediaAPIFileID string           `json:"mediaApiFileId"`
}

type AttachmentAuthor

type AttachmentAuthor struct {
	Self        string     `json:"self"`
	Key         string     `json:"key"`
	AccountID   string     `json:"accountId"`
	AccountType string     `json:"accountType"`
	Name        string     `json:"name"`
	AvatarUrls  AvatarUrls `json:"avatarUrls"`
	DisplayName string     `json:"displayName"`
	Active      bool       `json:"active"`
}

type AuthorElement

type AuthorElement struct {
	Self        string `json:"self"`
	AccountID   string `json:"accountId"`
	DisplayName string `json:"displayName"`
	Active      bool   `json:"active"`
}

type AvatarUrls

type AvatarUrls struct {
	The16X16 string `json:"16x16"`
	The24X24 string `json:"24x24"`
	The32X32 string `json:"32x32"`
	The48X48 string `json:"48x48"`
}

type Backend

type Backend interface {
	// Call is the implementation for invoking Jira APIs.
	//
	// Body is marshalled into the request body and the response body is decoded into v.
	Call(method, path, username, password string, body interface{}, v interface{}) (*http.Response, error)
}

Backend is an interface for making calls against a Jira service. This interface exists to enable mocking for during testing if needed.

func NewBackend

func NewBackend(u string) Backend

type BackendImplementation

type BackendImplementation struct {
	URL *url.URL
	// contains filtered or unexported fields
}

func (*BackendImplementation) BasicAuth

func (s *BackendImplementation) BasicAuth(username, password string) string

BasicAuth returns the username and password user-id/password pair, encoded using Base64. See: https://datatracker.ietf.org/doc/html/rfc7617

func (*BackendImplementation) Call

func (s *BackendImplementation) Call(method, path, username, password string, body interface{}, v interface{}) (*http.Response, error)

Call is the implementation for invoking Jira APIs.

func (*BackendImplementation) Do

func (s *BackendImplementation) Do(req *http.Request, v interface{}) (*http.Response, error)

Do is used by Call to execute an API request and parse the response. It uses the backend's HTTP client to execute the request and unmarshals the response into v.

func (*BackendImplementation) NewRequest

func (s *BackendImplementation) NewRequest(method, path, auth, contentType string, body interface{}) (*http.Request, error)

NewRequest is used by Call to generate an http.Request. It handles encoding parameters and attaching the appropriate headers.

type Callback

type Callback struct {
}

type Comment

type Comment struct {
	Self         string        `json:"self"`
	ID           string        `json:"id"`
	Author       AuthorElement `json:"author"`
	Body         Description   `json:"body"`
	UpdateAuthor AuthorElement `json:"updateAuthor"`
	Created      string        `json:"created"`
	Updated      string        `json:"updated"`
	Visibility   Visibility    `json:"visibility"`
}

type ContentContent

type ContentContent struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type Description

type Description struct {
	Type    string               `json:"type"`
	Version int64                `json:"version"`
	Content []DescriptionContent `json:"content"`
}

type DescriptionContent

type DescriptionContent struct {
	Type    string           `json:"type"`
	Content []ContentContent `json:"content"`
}

type Groups

type Groups struct {
	Size           int64        `json:"size"`
	Items          []GroupsItem `json:"items"`
	PagingCallback Callback     `json:"pagingCallback"`
	Callback       Callback     `json:"callback"`
	MaxResults     int64        `json:"max-results"`
}

type GroupsItem

type GroupsItem struct {
	Name string `json:"name"`
	Self string `json:"self"`
}

type Insight

type Insight struct {
	TotalIssueCount     int64  `json:"totalIssueCount"`
	LastIssueUpdateTime string `json:"lastIssueUpdateTime"`
}

type InwardIssueFields

type InwardIssueFields struct {
	Status Status `json:"status"`
}

type IssueBean

type IssueBean struct {
	Expand string          `json:"expand"`
	ID     string          `json:"id"`
	Self   string          `json:"self"`
	Key    string          `json:"key"`
	Fields IssueBeanFields `json:"fields"`
}

func UnmarshalIssueBean

func UnmarshalIssueBean(data []byte) (IssueBean, error)

func (*IssueBean) Marshal

func (r *IssueBean) Marshal() ([]byte, error)

type IssueBeanFields

type IssueBeanFields struct {
	Issuetype   Issuetype    `json:"issuetype"`
	Watcher     Watcher      `json:"watcher"`
	Attachment  []Attachment `json:"attachment"`
	SubTasks    []Issuelink  `json:"sub-tasks"`
	Description Description  `json:"description"`
	Project     Project      `json:"project"`
	Comment     []Comment    `json:"comment"`
	Issuelinks  []Issuelink  `json:"issuelinks"`
	Worklog     []Worklog    `json:"worklog"`
	Updated     int64        `json:"updated"`
	Summary     string       `json:"summary"`
}

type IssueResource

type IssueResource interface {
	// GetIssue returns the details for an issue.
	GetIssue(key string) (IssueBean, error)
}

This resource represents Jira issues.

type Issuelink struct {
	ID           string     `json:"id"`
	Type         Type       `json:"type"`
	OutwardIssue *WardIssue `json:"outwardIssue,omitempty"`
	InwardIssue  *WardIssue `json:"inwardIssue,omitempty"`
}

type Issuetype

type Issuetype struct {
	Self           string `json:"self"`
	ID             string `json:"id"`
	Description    string `json:"description"`
	IconURL        string `json:"iconUrl"`
	Name           string `json:"name"`
	Subtask        bool   `json:"subtask"`
	AvatarID       int64  `json:"avatarId"`
	HierarchyLevel int64  `json:"hierarchyLevel"`
}

type JiraClient

type JiraClient interface {
	// SaveToKeyring saves the credentials of the current client to the
	// system keyring.
	SaveToKeyring(service, user string) error

	MyselfResource
	IssueResource
}

func InitializeApiFromInit

func InitializeApiFromInit(email, domain, token string) JiraClient

InitializeApiFromInit returns a new instance of JiraClient based on the passed init command values.

func NewJiraClient

func NewJiraClient(service, user string) (JiraClient, error)

NewJiraClient returns a new instance of JiraApi with credentials gathered from the local keyring.

type JiraCredentials

type JiraCredentials struct {
	Email  string
	Token  string
	Domain string
}

type MyselfResource

type MyselfResource interface {
	// GetCurrentUser returns details for the current user.
	GetCurrentUser() (User, error)
}

This resource represents information about the current user, such as basic details, group membership, application roles, preferences, and locale. Use it to get, create, update, and delete (restore default) values of the user's preferences and locale.

type Project

type Project struct {
	Self            string          `json:"self"`
	ID              string          `json:"id"`
	Key             string          `json:"key"`
	Name            string          `json:"name"`
	AvatarUrls      AvatarUrls      `json:"avatarUrls"`
	ProjectCategory ProjectCategory `json:"projectCategory"`
	Simplified      bool            `json:"simplified"`
	Style           string          `json:"style"`
	Insight         Insight         `json:"insight"`
}

type ProjectCategory

type ProjectCategory struct {
	Self        string `json:"self"`
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type Status

type Status struct {
	IconURL string `json:"iconUrl"`
	Name    string `json:"name"`
}

type Timetracking

type Timetracking struct {
	OriginalEstimate         string `json:"originalEstimate"`
	RemainingEstimate        string `json:"remainingEstimate"`
	TimeSpent                string `json:"timeSpent"`
	OriginalEstimateSeconds  int64  `json:"originalEstimateSeconds"`
	RemainingEstimateSeconds int64  `json:"remainingEstimateSeconds"`
	TimeSpentSeconds         int64  `json:"timeSpentSeconds"`
}

type Type

type Type struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Inward  string `json:"inward"`
	Outward string `json:"outward"`
}

type User

type User struct {
	Self             string           `json:"self"`
	Key              string           `json:"key"`
	AccountID        string           `json:"accountId"`
	AccountType      string           `json:"accountType"`
	Name             string           `json:"name"`
	EmailAddress     string           `json:"emailAddress"`
	AvatarUrls       AvatarUrls       `json:"avatarUrls"`
	DisplayName      string           `json:"displayName"`
	Active           bool             `json:"active"`
	TimeZone         string           `json:"timeZone"`
	Locale           string           `json:"locale"`
	Groups           Groups           `json:"groups"`
	ApplicationRoles ApplicationRoles `json:"applicationRoles"`
	Expand           string           `json:"expand"`
}

func UnmarshalUser

func UnmarshalUser(data []byte) (User, error)

func (*User) Marshal

func (r *User) Marshal() ([]byte, error)

type Visibility

type Visibility struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type WardIssue

type WardIssue struct {
	ID     string            `json:"id"`
	Key    string            `json:"key"`
	Self   string            `json:"self"`
	Fields InwardIssueFields `json:"fields"`
}

type Watcher

type Watcher struct {
	Self       string          `json:"self"`
	IsWatching bool            `json:"isWatching"`
	WatchCount int64           `json:"watchCount"`
	Watchers   []AuthorElement `json:"watchers"`
}

type Worklog

type Worklog struct {
	Self             string        `json:"self"`
	Author           AuthorElement `json:"author"`
	UpdateAuthor     AuthorElement `json:"updateAuthor"`
	Comment          Description   `json:"comment"`
	Updated          string        `json:"updated"`
	Visibility       Visibility    `json:"visibility"`
	Started          string        `json:"started"`
	TimeSpent        string        `json:"timeSpent"`
	TimeSpentSeconds int64         `json:"timeSpentSeconds"`
	ID               string        `json:"id"`
	IssueID          string        `json:"issueId"`
}

Jump to

Keyboard shortcuts

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