jira

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatIssue

func FormatIssue(issue *Issue) string

FormatIssue returns a formatted string representation of an issue

func LoadToken

func LoadToken() (*config.JiraToken, error)

LoadToken loads the Jira token from the config file

func SaveToken

func SaveToken(token *config.JiraToken) error

SaveToken saves the Jira token to the config file

Types

type Client

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

func NewClient

func NewClient() (*Client, error)

func (*Client) AddComment added in v0.27.0

func (c *Client) AddComment(ctx context.Context, issueKey string, body string) (*Comment, error)

AddComment adds a comment to an issue

func (*Client) CreateIssue added in v0.24.0

func (c *Client) CreateIssue(ctx context.Context, req CreateIssueRequest) (*Issue, error)

CreateIssue creates a new Jira issue

func (*Client) DeleteComment added in v0.30.0

func (c *Client) DeleteComment(ctx context.Context, issueKey string, commentID string) error

DeleteComment deletes a comment from an issue.

func (*Client) DeleteIssue added in v0.24.0

func (c *Client) DeleteIssue(ctx context.Context, issueKey string, deleteSubtasks bool) error

DeleteIssue deletes an issue by key. If deleteSubtasks is true, subtasks are also deleted.

func (*Client) EnsureAuth

func (c *Client) EnsureAuth(ctx context.Context) error

EnsureAuth ensures we have a valid token, refreshing or re-authenticating as needed

func (*Client) FindUser added in v0.24.0

func (c *Client) FindUser(ctx context.Context, query string) ([]User, error)

FindUser searches for users by query (email, name, etc.)

func (*Client) GetCurrentUser added in v0.3.0

func (c *Client) GetCurrentUser(ctx context.Context) (*User, error)

GetCurrentUser fetches the authenticated user's info

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, issueKey string) (*Issue, error)

GetIssue fetches a single issue by key (e.g., "TEL-117")

func (*Client) GetMyIssues

func (c *Client) GetMyIssues(ctx context.Context, maxResults int) (*SearchResult, error)

GetMyIssues fetches issues assigned to the current user

func (*Client) GetProjectKeys

func (c *Client) GetProjectKeys(ctx context.Context) ([]string, error)

GetProjectKeys returns just the project keys (e.g., DEV, TEL)

func (*Client) GetRecentIssues

func (c *Client) GetRecentIssues(ctx context.Context, maxResults int) (*SearchResult, error)

GetRecentIssues fetches recently updated issues

func (*Client) GetSiteURL

func (c *Client) GetSiteURL() string

GetSiteURL returns the browsable Jira site URL (e.g., https://company.atlassian.net)

func (*Client) LinkIssues added in v0.26.0

func (c *Client) LinkIssues(ctx context.Context, req LinkIssuesRequest) error

LinkIssues creates a link between two issues

func (*Client) ListLinkTypes added in v0.26.0

func (c *Client) ListLinkTypes(ctx context.Context) ([]IssueLinkType, error)

ListLinkTypes returns all available issue link types

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context) ([]Project, error)

ListProjects fetches all accessible Jira projects

func (*Client) ListTransitions added in v0.27.0

func (c *Client) ListTransitions(ctx context.Context, issueKey string) ([]Transition, error)

ListTransitions returns available transitions for an issue

func (*Client) SearchIssues

func (c *Client) SearchIssues(ctx context.Context, jql string, maxResults int) (*SearchResult, error)

SearchIssues searches for issues using JQL

func (*Client) TransitionIssue added in v0.27.0

func (c *Client) TransitionIssue(ctx context.Context, issueKey string, transitionNameOrID string) error

TransitionIssue moves an issue to a new status

func (*Client) UpdateIssue added in v0.27.0

func (c *Client) UpdateIssue(ctx context.Context, issueKey string, req UpdateIssueRequest) error

UpdateIssue updates an existing issue's fields

type Comment

type Comment struct {
	ID     string `json:"id"`
	Author *struct {
		DisplayName string `json:"displayName"`
	} `json:"author"`
	Body    any    `json:"body"`
	Created string `json:"created"`
	Updated string `json:"updated"`
}

type CreateIssueRequest added in v0.24.0

type CreateIssueRequest struct {
	ProjectKey  string   // Required: project key (e.g., "DEV")
	IssueType   string   // Required: issue type (e.g., "Task", "Bug", "Story", "Sub-task")
	Summary     string   // Required: issue summary/title
	Description string   // Optional: plain text description
	Labels      []string // Optional: labels to apply
	Assignee    string   // Optional: account ID or email
	Priority    string   // Optional: "Lowest", "Low", "Medium", "High", "Highest"
	Parent      string   // Optional: parent issue key for subtasks (e.g., "DEV-123")
}

CreateIssueRequest contains the parameters for creating a new issue

type Issue

type Issue struct {
	ID     string `json:"id"`
	Key    string `json:"key"`
	Self   string `json:"self"`
	Fields struct {
		Summary     string `json:"summary"`
		Description any    `json:"description"`
		Status      struct {
			Name string `json:"name"`
		} `json:"status"`
		IssueType struct {
			Name string `json:"name"`
		} `json:"issuetype"`
		Priority struct {
			Name string `json:"name"`
		} `json:"priority"`
		Assignee *struct {
			DisplayName  string `json:"displayName"`
			EmailAddress string `json:"emailAddress"`
		} `json:"assignee"`
		Reporter *struct {
			DisplayName  string `json:"displayName"`
			EmailAddress string `json:"emailAddress"`
		} `json:"reporter"`
		Created    string   `json:"created"`
		Updated    string   `json:"updated"`
		Labels     []string `json:"labels"`
		Parent     *Issue   `json:"parent"`
		Subtasks   []Issue  `json:"subtasks"`
		IssueLinks []struct {
			ID   string `json:"id"`
			Type struct {
				Name    string `json:"name"`
				Inward  string `json:"inward"`
				Outward string `json:"outward"`
			} `json:"type"`
			InwardIssue *struct {
				Key    string `json:"key"`
				Fields struct {
					Summary string `json:"summary"`
					Status  struct {
						Name string `json:"name"`
					} `json:"status"`
				} `json:"fields"`
			} `json:"inwardIssue"`
			OutwardIssue *struct {
				Key    string `json:"key"`
				Fields struct {
					Summary string `json:"summary"`
					Status  struct {
						Name string `json:"name"`
					} `json:"status"`
				} `json:"fields"`
			} `json:"outwardIssue"`
		} `json:"issuelinks"`
		Comment *struct {
			Comments []Comment `json:"comments"`
			Total    int       `json:"total"`
		} `json:"comment"`
	} `json:"fields"`
}

type IssueLinkType added in v0.26.0

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

IssueLinkType represents a type of link between issues

type JiraSiteInfo

type JiraSiteInfo struct {
	CloudID string
	SiteURL string
}

JiraSiteInfo contains cloud ID and browsable site URL

type LinkIssuesRequest added in v0.26.0

type LinkIssuesRequest struct {
	InwardIssue  string // The issue that is the source of the link (e.g., "DEV-123")
	OutwardIssue string // The issue that is the target of the link (e.g., "DEV-456")
	LinkType     string // The type of link (e.g., "Relates", "Blocks", "Duplicates")
}

LinkIssuesRequest contains the parameters for linking two issues

type OAuthFlow

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

func NewOAuthFlow

func NewOAuthFlow(cfg *config.Config) *OAuthFlow

func (*OAuthFlow) ExchangeCode

func (o *OAuthFlow) ExchangeCode(ctx context.Context, code string) (*config.JiraToken, error)

ExchangeCode exchanges an authorization code for tokens

func (*OAuthFlow) GetAuthURL

func (o *OAuthFlow) GetAuthURL(state string) string

GetAuthURL returns the URL to start the OAuth flow

func (*OAuthFlow) GetSiteInfo

func (o *OAuthFlow) GetSiteInfo(ctx context.Context, accessToken string) (*JiraSiteInfo, error)

GetSiteInfo fetches the Jira site info (CloudID and SiteURL) from the accessible-resources API

func (*OAuthFlow) RefreshToken

func (o *OAuthFlow) RefreshToken(ctx context.Context, refreshToken string) (*config.JiraToken, error)

RefreshToken refreshes an expired access token

func (*OAuthFlow) StartAuthServer

func (o *OAuthFlow) StartAuthServer(ctx context.Context) (*config.JiraToken, error)

StartAuthServer starts a local server to handle the OAuth callback

type Project

type Project struct {
	ID          string `json:"id"`
	Key         string `json:"key"`
	Name        string `json:"name"`
	ProjectType string `json:"projectTypeKey"`
	Self        string `json:"self"`
}

Project represents a Jira project

type SearchResult

type SearchResult struct {
	StartAt    int     `json:"startAt"`
	MaxResults int     `json:"maxResults"`
	Total      int     `json:"total"`
	IsLast     bool    `json:"isLast"`
	Issues     []Issue `json:"issues"`
}

type Transition added in v0.27.0

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

Transition represents an available workflow transition

type UpdateIssueRequest added in v0.27.0

type UpdateIssueRequest struct {
	Summary      *string  // New summary/title (nil = don't change)
	Description  *string  // New description (nil = don't change)
	Assignee     *string  // New assignee email or account ID (nil = don't change, empty string = unassign)
	Priority     *string  // New priority name (nil = don't change)
	AddLabels    []string // Labels to add
	RemoveLabels []string // Labels to remove
}

UpdateIssueRequest contains the parameters for updating an issue

type User added in v0.3.0

type User struct {
	AccountID    string `json:"accountId"`
	DisplayName  string `json:"displayName"`
	EmailAddress string `json:"emailAddress"`
}

User represents the authenticated Jira user

Jump to

Keyboard shortcuts

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