jirarest

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParamFields        = "fields"
	ParamJQL           = "jql"
	ParamMaxResults    = "maxResults"
	ParamStartAt       = "startAt"
	ParamValidateQuery = "validateQuery"
)
View Source
const (
	APIURL2ListCustomFields = `/rest/api/2/field`

	StatusDone         = "Done"
	StatusOpen         = "Open"
	StatusCustomClosed = "Closed"

	MaxResults    = uint(1000)
	MetaParamRank = "_rank"

	TimeTimeSpent                     = "Time Spent"
	TimeTimeEstimate                  = "Time Estimate"
	TimeTimeOriginalEstimate          = "Time Original Estimate"
	TimeAggregateTimeOriginalEstimate = "Aggregate Time Original Estimate"
	TimeAggregateTimeSpent            = "Aggregate Time Spent"
	TimeAggregateTimeEstimate         = "Aggregate Time Estimate"
	TimeTimeRemaining                 = "Time Remaining"
	TimeTimeRemainingOriginal         = "Time Remaining Original"
)
View Source
const (
	CustomFieldNameEpicLink = "Epic Link"
)

Variables

View Source
var ErrJiraRESTClientCannotBeNil = errors.New("jirarest.Client cannot be nil")

Functions

func BacklogAPIURL

func BacklogAPIURL(baseURL string, boardID uint, qry *BoardBacklogParams) string

BacklogAPIURL returns a backlog issues API URL described at https://docs.atlassian.com/jira-software/REST/7.3.1/ . The description is here: Returns all issues from the board's backlog, for the given board Id. This only includes issues that the user has permission to view. The backlog contains incomplete issues that are not assigned to any future or active sprint. Note, if the user does not have permission to view the board, no issues will be returned at all. Issues returned from this resource include Agile fields, like sprint, closedSprints, flagged, and epic. By default, the returned issues are ordered by rank. Reference: https://docs.atlassian.com/jira-software/REST/7.3.1/#agile/1.0/board-getIssuesForBacklog

func BuildJiraIssueURL

func BuildJiraIssueURL(baseURL, issueKey string) string

func DefaultIssuesSetTableColumns

func DefaultIssuesSetTableColumns() *table.ColumnDefinitions

func GetCustomValueString

func GetCustomValueString(iss jira.Issue, customFieldKey string) (string, error)

GetCustomValueString attempts to return a string if either the custom value is a simple string or is an `IssueCustomField`, in which case it returns the `value` property.

func GetUnmarshalCustomValue

func GetUnmarshalCustomValue(iss jira.Issue, customFieldKey string, v any) error

GetUnmarshalCustomValue can be used to unmarshal a value to `IssueCustomField{}`.

func HTTPClientBasicAuthFile

func HTTPClientBasicAuthFile(filename, credsKey string) (hclient *http.Client, serverURL string, err error)

func IssueFieldsCustomFieldString

func IssueFieldsCustomFieldString(fields *jira.IssueFields, id string) string

IssueFieldsCustomFieldString returns a string custom field, e.g "Epic Link"

func IssueToEpic

func IssueToEpic(iss jira.Issue) (*jira.Epic, error)

func JiraClientBasicAuth

func JiraClientBasicAuth(creds *goauth.CredentialsBasicAuth) (*jira.Client, error)

func JiraClientBasicAuthFile

func JiraClientBasicAuthFile(filename, credsKey string) (*jira.Client, error)

func KeysJQL

func KeysJQL(keys []string) string

func UserPassCredsBasic

func UserPassCredsBasic(filename, credsKey string) (*goauth.CredentialsBasicAuth, error)

Types

type API added in v0.8.0

type API struct {
	Client       *Client
	Backlog      *BacklogService
	CustomFields *CustomFieldsService
}

func NewAPI added in v0.8.0

func NewAPI(client *Client) API

type BacklogService added in v0.6.0

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

func NewBacklogService added in v0.6.0

func NewBacklogService(client *Client) *BacklogService

func (*BacklogService) GetBacklogIssuesAll added in v0.6.0

func (s *BacklogService) GetBacklogIssuesAll(boardID uint, jql string) (*IssuesResponse, [][]byte, error)

func (*BacklogService) GetBacklogIssuesResponse added in v0.6.0

func (s *BacklogService) GetBacklogIssuesResponse(boardID uint, qry *BoardBacklogParams) (*IssuesResponse, []byte, error)

func (*BacklogService) GetBacklogIssuesSetAll added in v0.6.0

func (s *BacklogService) GetBacklogIssuesSetAll(boardID uint, jql string) (*IssuesSet, [][]byte, error)

type BoardBacklogParams added in v0.6.0

type BoardBacklogParams struct {
	StartAt       uint   `url:"startAt"`
	MaxResults    uint   `url:"maxResults"`
	JQL           string `url:"jql"`
	ValidateQuery bool   `url:"validateQuery"`
	Fields        string `url:"fields"`
	Expand        string `url:"expand"`
}

func (BoardBacklogParams) URLValues added in v0.6.0

func (p BoardBacklogParams) URLValues() url.Values

type Client added in v0.7.0

type Client struct {
	Config     gojira.Config
	HTTPClient *http.Client
	JiraClient *jira.Client
}

func ClientsBasicAuthFile

func ClientsBasicAuthFile(filename, credsKey string) (*Client, error)

func (*Client) GetIssuesSetForKeys added in v0.7.0

func (c *Client) GetIssuesSetForKeys(keys []string) (*IssuesSet, error)

func (*Client) Issue added in v0.7.0

func (c *Client) Issue(key string) (*jira.Issue, error)

func (*Client) SearchIssues added in v0.7.0

func (c *Client) SearchIssues(jql string) (Issues, error)

SearchIssues returns all issues for a JQL query, automatically handling API pagination.

func (*Client) SearchIssuesMulti added in v0.7.0

func (c *Client) SearchIssuesMulti(jqls ...string) (Issues, error)

func (*Client) SearchIssuesSetForJQL added in v0.7.0

func (c *Client) SearchIssuesSetForJQL(jql string) (*IssuesSet, error)

type CustomCol

type CustomCol struct {
	Name       string
	Type       string
	Func       func(iss jira.Issue) (string, error)
	RenderSkip bool
}

type CustomField

type CustomField struct {
	ID               string            `json:"id"` // "customfield_12345"
	Key              string            `json:"key"`
	Name             string            `json:"name"`
	UntranslatedName string            `json:"untranslatedName"`
	Custom           bool              `json:"custom"`
	Orderable        bool              `json:"orderable"`
	Navigable        bool              `json:"navigable"`
	Searchable       bool              `json:"searchable"`
	ClauseNames      []string          `json:"clauseNames"`
	Schema           CustomFieldSchema `json:"schema"`
}

type CustomFieldSchema

type CustomFieldSchema struct {
	Type     string `json:"type"`
	Custom   string `json:"custom"`
	CustomID int    `json:"customId"`
}

type CustomFields

type CustomFields []CustomField

func (CustomFields) FilterByIDs

func (cfs CustomFields) FilterByIDs(ids ...string) CustomFields

func (CustomFields) FilterByNames

func (cfs CustomFields) FilterByNames(names ...string) CustomFields

func (CustomFields) SortByName

func (cfs CustomFields) SortByName(asc bool) CustomFields

func (CustomFields) Table

func (cfs CustomFields) Table(name string) table.Table

func (CustomFields) WriteTable

func (cfs CustomFields) WriteTable(w io.Writer)

type CustomFieldsService added in v0.8.0

type CustomFieldsService struct {
	JRClient *Client
}

func NewCustomFieldsService added in v0.8.0

func NewCustomFieldsService(client *Client) *CustomFieldsService

func (*CustomFieldsService) GetCustomField added in v0.8.0

func (svc *CustomFieldsService) GetCustomField(customFieldName string) (CustomField, error)
func (svc *CustomFieldsService) GetCustomFieldEpicLink() (CustomField, error)

func (*CustomFieldsService) GetCustomFields added in v0.8.0

func (svc *CustomFieldsService) GetCustomFields() (CustomFields, error)

type CustomTableCols

type CustomTableCols struct {
	Cols []CustomCol
}

type EpicsSet

type EpicsSet struct {
	EpicsMap map[string]jira.Epic
}

func NewEpicsSet

func NewEpicsSet() EpicsSet

func (*EpicsSet) AddIssues

func (es *EpicsSet) AddIssues(issues []jira.Issue) error

func (*EpicsSet) GetKeys

func (es *EpicsSet) GetKeys(jclient *jira.Client, epicKeys []string) error

type IssueCustomField

type IssueCustomField struct {
	ID    string `json:"id"`
	Self  string `json:"self"`
	Value string `json:"value"`
}

func GetIssueCustomValueStruct

func GetIssueCustomValueStruct(iss jira.Issue) (*IssueCustomField, error)

type IssueMeta added in v0.7.0

type IssueMeta struct {
	AssigneeName string
	CreateTime   *time.Time
	CreatorName  string
	EpicName     string
	Key          string
	KeyURL       string
	ParentKey    string
	Project      string
	ProjectKey   string
	Resolution   string
	Status       string
	Summary      string
	Type         string
	UpdateTime   *time.Time
}

func (IssueMeta) String added in v0.7.0

func (im IssueMeta) String() string

type IssueMetas added in v0.7.0

type IssueMetas []IssueMeta

type IssueMore added in v0.7.0

type IssueMore struct {
	Issue *jira.Issue
}

func (*IssueMore) AsigneeName added in v0.7.0

func (im *IssueMore) AsigneeName() string

func (*IssueMore) CreateTime added in v0.7.0

func (im *IssueMore) CreateTime() time.Time

func (*IssueMore) CreatorName added in v0.7.0

func (im *IssueMore) CreatorName() string

func (*IssueMore) CustomField added in v0.8.0

func (im *IssueMore) CustomField(customFieldLabel string) (IssueCustomField, error)

CustomField takes a custom value key such as `customfield_12345`.`

func (*IssueMore) EpicKey added in v0.8.1

func (im *IssueMore) EpicKey() string

func (*IssueMore) EpicName added in v0.7.0

func (im *IssueMore) EpicName() string

func (*IssueMore) EpicNameOrSummary added in v0.8.1

func (im *IssueMore) EpicNameOrSummary() string

func (*IssueMore) Key added in v0.7.0

func (im *IssueMore) Key() string

func (*IssueMore) KeyURL added in v0.7.0

func (im *IssueMore) KeyURL(baseURL string) string

func (*IssueMore) Meta added in v0.7.0

func (im *IssueMore) Meta(baseURL string) IssueMeta

func (*IssueMore) ParentKey added in v0.7.0

func (im *IssueMore) ParentKey() string

func (*IssueMore) Project added in v0.7.0

func (im *IssueMore) Project() string

func (*IssueMore) ProjectKey added in v0.7.0

func (im *IssueMore) ProjectKey() string

func (*IssueMore) Resolution added in v0.7.0

func (im *IssueMore) Resolution() string

func (*IssueMore) Status added in v0.7.0

func (im *IssueMore) Status() string

func (*IssueMore) Summary added in v0.7.0

func (im *IssueMore) Summary() string

func (*IssueMore) Type added in v0.7.0

func (im *IssueMore) Type() string

func (*IssueMore) UpdateTime added in v0.7.0

func (im *IssueMore) UpdateTime() time.Time

type Issues

type Issues []jira.Issue

func IssuesReadFileJSON added in v0.7.0

func IssuesReadFileJSON(filename string) (Issues, error)

func (Issues) AddRank added in v0.6.0

func (ii Issues) AddRank() Issues

func (Issues) CountsByProjectTypeStatus

func (ii Issues) CountsByProjectTypeStatus() *histogram.HistogramSets

CountsByProjectTypeStatus returns a `*histogram.Histogram` with issue counts by project, type, and status. This can be used to export CSV and XLSX sheets for analysis.

func (Issues) CountsByType

func (ii Issues) CountsByType() map[string]int

func (Issues) IssuesSet added in v0.6.0

func (ii Issues) IssuesSet(cfg *gojira.Config) (*IssuesSet, error)

func (Issues) WriteFileJSON added in v0.7.0

func (ii Issues) WriteFileJSON(filename, prefix, indent string) error

type IssuesResponse

type IssuesResponse struct {
	Issues     Issues `json:"issues" structs:"issues"`
	Expand     string `json:"expand"`
	StartAt    int    `json:"startAt" structs:"startAt"`
	MaxResults int    `json:"maxResults" structs:"maxResults"`
	Total      int    `json:"total" structs:"total"`
}

IssuesResponse is only a small wrapper around the Search (with JQL) method to be able to parse the results

func IssuesResponseReadFile

func IssuesResponseReadFile(filename string) (*IssuesResponse, error)

func ParseIssuesResponseBytes

func ParseIssuesResponseBytes(b []byte) (*IssuesResponse, error)

func ParseIssuesResponseReader

func ParseIssuesResponseReader(r io.Reader) (*IssuesResponse, error)

type IssuesSet

type IssuesSet struct {
	Config    *gojira.Config
	IssuesMap map[string]jira.Issue
	Parents   *IssuesSet
}

func NewIssuesSet

func NewIssuesSet(cfg *gojira.Config) *IssuesSet

func (*IssuesSet) Add

func (is *IssuesSet) Add(issues ...jira.Issue) error

func (*IssuesSet) Counts added in v0.6.0

func (is *IssuesSet) Counts() map[string]map[string]uint

func (*IssuesSet) CountsByProject added in v0.7.0

func (is *IssuesSet) CountsByProject() map[string]uint

func (*IssuesSet) CountsByProjectKey added in v0.7.0

func (is *IssuesSet) CountsByProjectKey() map[string]uint

func (*IssuesSet) CountsByStatus added in v0.6.0

func (is *IssuesSet) CountsByStatus() map[string]uint

func (*IssuesSet) CountsByTime added in v0.6.0

func (is *IssuesSet) CountsByTime() map[string]uint

func (*IssuesSet) CountsByType added in v0.6.0

func (is *IssuesSet) CountsByType() map[string]uint

func (*IssuesSet) EpicKeys

func (is *IssuesSet) EpicKeys(customFieldID string) []string

func (*IssuesSet) FilterByStatus added in v0.6.0

func (is *IssuesSet) FilterByStatus(inclStatuses, exclStatuses []string) (*IssuesSet, error)

func (*IssuesSet) FilterStatus added in v0.7.0

func (is *IssuesSet) FilterStatus(inclStatuses ...string) (*IssuesSet, error)

func (*IssuesSet) FilterType added in v0.7.0

func (is *IssuesSet) FilterType(inclTypes ...string) (*IssuesSet, error)

func (*IssuesSet) HistogramSets

func (is *IssuesSet) HistogramSets() *histogram.HistogramSets

func (*IssuesSet) InflateEpicKeys

func (is *IssuesSet) InflateEpicKeys(customFieldEpicLinkID string)

func (*IssuesSet) InflateEpics

func (is *IssuesSet) InflateEpics(jclient *jira.Client, customFieldIDEpicLink string) error

InflateEpics uses the Jira REST API to inflate the Issue struct with an Epic struct.

func (*IssuesSet) Issues

func (is *IssuesSet) Issues() Issues

func (*IssuesSet) Keys added in v0.7.0

func (is *IssuesSet) Keys() []string

func (*IssuesSet) Lineage added in v0.7.0

func (is *IssuesSet) Lineage(key string) (IssueMetas, error)

func (*IssuesSet) RetrieveIssues added in v0.7.0

func (is *IssuesSet) RetrieveIssues(client *Client, ids []string) error

func (*IssuesSet) RetrieveParents added in v0.7.0

func (is *IssuesSet) RetrieveParents(client *Client) error

func (*IssuesSet) RetrieveParentsIssuesSet added in v0.7.0

func (is *IssuesSet) RetrieveParentsIssuesSet(client *Client) (*IssuesSet, error)

func (*IssuesSet) Table

func (is *IssuesSet) Table(customCols *CustomTableCols) (table.Table, error)

func (*IssuesSet) TimeStats

func (is *IssuesSet) TimeStats() gojira.TimeStats

func (*IssuesSet) UnknownParents added in v0.7.0

func (is *IssuesSet) UnknownParents() []string

func (*IssuesSet) WriteFileJSON added in v0.7.0

func (is *IssuesSet) WriteFileJSON(name, prefix, indent string) error

type Status

type Status struct {
	Name        string
	Description string
}

func IssueStatuses

func IssueStatuses() []Status

Jump to

Keyboard shortcuts

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