Documentation
¶
Overview ¶
Package jira provides a client for the JIRA Cloud REST API.
Index ¶
- type Board
- type BoardConfig
- type BoardFilter
- type BoardListResult
- type ChangeItem
- type Changelog
- type ChangelogEntry
- type ChangelogResult
- type Client
- func (c *Client) BaseURL() string
- func (c *Client) BrowseURL(issueKey string) string
- func (c *Client) FetchIssuesWithHistory(ctx context.Context, jql string, progressFn func(current, total int)) ([]IssueWithHistory, error)
- func (c *Client) GetBoardConfiguration(ctx context.Context, boardID int) (*BoardConfig, error)
- func (c *Client) GetFilter(ctx context.Context, filterID string) (*Filter, error)
- func (c *Client) GetFullChangelog(ctx context.Context, issueKey string) ([]ChangelogEntry, error)
- func (c *Client) GetIssueChangelog(ctx context.Context, issueKey string, startAt int) (*ChangelogResult, error)
- func (c *Client) GetIssueWithChangelog(ctx context.Context, issueKey string) (*IssueWithHistory, error)
- func (c *Client) ListBoards(ctx context.Context, projectKey string) ([]Board, error)
- func (c *Client) SearchAllIssues(ctx context.Context, jql string, fields string, expand string) ([]Issue, error)
- func (c *Client) SearchIssues(ctx context.Context, jql string, opts SearchOptions) (*SearchResult, error)
- func (c *Client) TestConnection(ctx context.Context) error
- func (c *Client) WhoAmI(ctx context.Context) (*User, error)
- func (c *Client) WithDebug(v bool) *Client
- func (c *Client) WithDumpResponses(v bool) *Client
- type Credentials
- type Epic
- type ErrorResponse
- type Fields
- type Filter
- type Issue
- type IssueType
- type IssueWithHistory
- type JiraTime
- type PaginatedResponse
- type Parent
- type Priority
- type Project
- type Resolution
- type SearchOptions
- type SearchResult
- type Status
- type StatusCategory
- type StatusTransition
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoardConfig ¶
type BoardConfig struct {
Filter BoardFilter `json:"filter"`
}
BoardConfig represents a JIRA board's configuration.
type BoardFilter ¶
type BoardFilter struct {
ID string `json:"id"`
}
BoardFilter represents the filter reference in a board config.
type BoardListResult ¶
type BoardListResult struct {
PaginatedResponse
Values []Board `json:"values"`
}
BoardListResult represents the paginated board list response.
type ChangeItem ¶
type ChangeItem 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"`
}
ChangeItem represents a single field change.
type Changelog ¶
type Changelog struct {
PaginatedResponse
Histories []ChangelogEntry `json:"histories"`
}
Changelog represents the changelog for an issue.
type ChangelogEntry ¶
type ChangelogEntry struct {
ID string `json:"id"`
Created JiraTime `json:"created"`
Author User `json:"author"`
Items []ChangeItem `json:"items"`
}
ChangelogEntry represents a single changelog entry.
type ChangelogResult ¶
type ChangelogResult struct {
PaginatedResponse
Values []ChangelogEntry `json:"values"`
}
ChangelogResult represents the standalone changelog API response.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main JIRA Cloud API client.
func NewClient ¶
func NewClient(creds Credentials) *Client
NewClient creates a new JIRA Cloud API client.
func (*Client) FetchIssuesWithHistory ¶
func (c *Client) FetchIssuesWithHistory(ctx context.Context, jql string, progressFn func(current, total int)) ([]IssueWithHistory, error)
FetchIssuesWithHistory fetches all issues matching JQL and their changelogs. This is the main entry point for metrics calculations.
func (*Client) GetBoardConfiguration ¶
GetBoardConfiguration returns the configuration for a board, including its filter.
func (*Client) GetFullChangelog ¶
GetFullChangelog fetches all changelog entries for an issue, handling pagination.
func (*Client) GetIssueChangelog ¶
func (c *Client) GetIssueChangelog(ctx context.Context, issueKey string, startAt int) (*ChangelogResult, error)
GetIssueChangelog fetches the changelog for a specific issue.
func (*Client) GetIssueWithChangelog ¶
func (c *Client) GetIssueWithChangelog(ctx context.Context, issueKey string) (*IssueWithHistory, error)
GetIssueWithChangelog fetches an issue with its full changelog.
func (*Client) ListBoards ¶
ListBoards returns all agile boards for the given project key. It resolves the project key to a numeric ID and uses the projectLocation parameter, which is more reliable than projectKeyOrId for finding boards.
func (*Client) SearchAllIssues ¶
func (c *Client) SearchAllIssues(ctx context.Context, jql string, fields string, expand string) ([]Issue, error)
SearchAllIssues fetches all issues matching the JQL query, handling pagination.
func (*Client) SearchIssues ¶
func (c *Client) SearchIssues(ctx context.Context, jql string, opts SearchOptions) (*SearchResult, error)
SearchIssues performs a JQL search with pagination.
func (*Client) TestConnection ¶
TestConnection verifies the JIRA credentials work.
func (*Client) WhoAmI ¶
WhoAmI returns the authenticated JIRA user. Useful for printing a "Connected as ..." line after credentials are saved.
func (*Client) WithDebug ¶
WithDebug toggles per-request debug logging (method, URL, status, duration).
func (*Client) WithDumpResponses ¶
WithDumpResponses toggles full response-body dumping. Off by default; only enable on commands that explicitly opt in via --debug-upstream-response.
type Credentials ¶
type Credentials struct {
Domain string // e.g., "mycompany" (becomes mycompany.atlassian.net)
Email string // User email
APIToken string // API token from id.atlassian.com/manage/api-tokens
BaseURLOverride string // If set, use instead of https://{domain}.atlassian.net
}
Credentials holds JIRA Cloud authentication details.
func (*Credentials) BaseURL ¶
func (c *Credentials) BaseURL() string
BaseURL returns the JIRA Cloud base URL.
type ErrorResponse ¶
type ErrorResponse struct {
ErrorMessages []string `json:"errorMessages"`
Errors map[string]string `json:"errors"`
}
ErrorResponse represents a JIRA API error.
type Fields ¶
type Fields struct {
Summary string `json:"summary"`
Description any `json:"description,omitempty"` // Can be string or ADF object
Status Status `json:"status"`
IssueType IssueType `json:"issuetype"`
Created JiraTime `json:"created"`
Updated JiraTime `json:"updated"`
ResolutionDate *JiraTime `json:"resolutiondate,omitempty"`
Resolution *Resolution `json:"resolution,omitempty"`
Project Project `json:"project"`
Assignee *User `json:"assignee,omitempty"`
Reporter *User `json:"reporter,omitempty"`
Priority *Priority `json:"priority,omitempty"`
Labels []string `json:"labels,omitempty"`
Parent *Parent `json:"parent,omitempty"` // For subtasks or stories linked to epics
Epic *Epic `json:"epic,omitempty"` // Epic link (older style)
}
Fields contains issue field data.
type Issue ¶
type Issue struct {
Key string `json:"key"`
ID string `json:"id"`
Self string `json:"self"`
Fields Fields `json:"fields"`
Changelog *Changelog `json:"changelog,omitempty"`
}
Issue represents a JIRA issue.
type IssueType ¶
type IssueType struct {
ID string `json:"id"`
Name string `json:"name"`
Subtask bool `json:"subtask"`
Hierarchical int `json:"hierarchyLevel,omitempty"`
}
IssueType represents issue type (Story, Bug, Epic, etc.).
type IssueWithHistory ¶
type IssueWithHistory struct {
Issue
Transitions []StatusTransition
}
IssueWithHistory combines an issue with its parsed status transitions.
type JiraTime ¶
JiraTime handles JIRA's datetime format.
func (JiraTime) MarshalJSON ¶
MarshalJSON formats time for JIRA API.
func (*JiraTime) UnmarshalJSON ¶
UnmarshalJSON parses JIRA's datetime format.
type PaginatedResponse ¶
type PaginatedResponse struct {
StartAt int `json:"startAt"`
MaxResults int `json:"maxResults"`
Total int `json:"total"`
IsLast bool `json:"isLast,omitempty"`
}
PaginatedResponse represents JIRA's standard pagination structure.
type Parent ¶
type Parent struct {
ID string `json:"id"`
Key string `json:"key"`
Fields struct {
Summary string `json:"summary"`
Status Status `json:"status"`
IssueType IssueType `json:"issuetype"`
} `json:"fields"`
}
Parent represents the parent issue (for subtasks or epic links).
type Resolution ¶
Resolution represents the resolution set when closing an issue.
type SearchOptions ¶
type SearchOptions struct {
StartAt int
MaxResults int
Fields string // Comma-separated field names
Expand string // changelog, transitions, etc.
}
SearchOptions configures JQL search requests.
type SearchResult ¶
type SearchResult struct {
PaginatedResponse
Issues []Issue `json:"issues"`
}
SearchResult represents the JQL search response.
type Status ¶
type Status struct {
ID string `json:"id"`
Name string `json:"name"`
StatusCategory StatusCategory `json:"statusCategory"`
}
Status represents issue status.
type StatusCategory ¶
type StatusCategory struct {
ID int `json:"id"`
Key string `json:"key"` // new, indeterminate, done
Name string `json:"name"` // To Do, In Progress, Done
}
StatusCategory represents the status category.
type StatusTransition ¶
StatusTransition represents a status change extracted from changelog.
func ExtractStatusTransitions ¶
func ExtractStatusTransitions(entries []ChangelogEntry) []StatusTransition
ExtractStatusTransitions parses changelog entries to find status changes.