jira

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package jira contains a small Jira Cloud API client tailored to jiratui's workflow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImageReferenceToken added in v0.4.0

func ImageReferenceToken(imageID, alt string) string

ImageReferenceToken returns the textarea representation of an image occurrence.

func IsSameLocalDay

func IsSameLocalDay(t time.Time, day time.Time, loc *time.Location) bool

IsSameLocalDay reports whether t falls on day in loc.

func StatusCategoryForName

func StatusCategoryForName(status string) string

StatusCategoryForName maps common Jira status names to a report bucket.

Types

type AttachmentMeta added in v0.4.0

type AttachmentMeta struct {
	Enabled     bool
	UploadLimit int
}

AttachmentMeta contains Jira's site-wide attachment limits.

type Board

type Board struct {
	ID   int
	Name string
	Type string
}

Board is a Jira agile board.

type BoardConfiguration

type BoardConfiguration struct {
	EstimationFieldID   string
	EstimationFieldName string
}

BoardConfiguration contains agile board metadata needed by setup discovery.

type Client

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

Client is a Jira Cloud REST API client.

func NewClient

func NewClient(baseURL, username, token string) (*Client, error)

NewClient creates a Jira Cloud API client using email + API token basic auth.

func (*Client) ActiveSprint

func (c *Client) ActiveSprint(ctx context.Context, boardID int) (Sprint, error)

ActiveSprint returns the active sprint for a Scrum board.

func (*Client) AddAttachment added in v0.4.0

func (c *Client) AddAttachment(ctx context.Context, issueKey string, image DescriptionImage) (DescriptionImage, error)

AddAttachment uploads an image attachment and returns its description media metadata.

func (*Client) AddIssuesToSprint

func (c *Client) AddIssuesToSprint(ctx context.Context, sprintID int, issueKeys []string) error

AddIssuesToSprint adds issues to a Jira sprint.

func (*Client) AssignIssue

func (c *Client) AssignIssue(ctx context.Context, issueKey string, accountID string) error

AssignIssue assigns an issue to a Jira Cloud account.

func (*Client) AttachmentMeta added in v0.4.0

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

AttachmentMeta returns whether attachments are enabled and the tenant upload limit in bytes.

func (*Client) BoardConfiguration

func (c *Client) BoardConfiguration(ctx context.Context, boardID int) (BoardConfiguration, error)

BoardConfiguration returns agile board settings such as the estimation field.

func (*Client) CreateTask

func (c *Client) CreateTask(ctx context.Context, input CreateTaskInput) (Issue, error)

CreateTask creates a Jira Task. Add it to a sprint with AddIssuesToSprint afterwards.

func (*Client) DeleteTask added in v0.3.0

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

DeleteTask permanently deletes an issue.

func (*Client) Fields

func (c *Client) Fields(ctx context.Context) ([]Field, error)

Fields returns Jira fields visible to the authenticated user.

func (*Client) FindAttachmentByFilename added in v0.4.0

func (c *Client) FindAttachmentByFilename(ctx context.Context, issueKey, filename string, source DescriptionImage) (DescriptionImage, bool, error)

FindAttachmentByFilename reconciles an attachment upload whose response may have been lost.

func (*Client) FindTaskBySaveID added in v0.4.0

func (c *Client) FindTaskBySaveID(ctx context.Context, projectKey, saveID string, createdAfter time.Time) (Issue, bool, error)

FindTaskBySaveID reconciles a create whose Jira response may have been lost.

func (*Client) Issue added in v0.4.0

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

Issue returns one Jira issue with its structured description.

func (*Client) IssueStatusChanges

func (c *Client) IssueStatusChanges(ctx context.Context, issue Issue) ([]StatusChange, error)

IssueStatusChanges returns status changes for an issue from Jira changelog.

func (*Client) Myself

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

Myself returns the authenticated Jira user.

func (*Client) Project

func (c *Client) Project(ctx context.Context, projectKeyOrID string) (Project, error)

Project returns a Jira project with its issue types.

func (*Client) ProjectIssueTypes

func (c *Client) ProjectIssueTypes(ctx context.Context, projectID string) ([]IssueType, error)

ProjectIssueTypes returns issue types available to a project.

func (*Client) SearchBoards

func (c *Client) SearchBoards(ctx context.Context, projectKeyOrID string) ([]Board, error)

SearchBoards returns agile boards for a project key or id.

func (*Client) SearchMySprintIssues

func (c *Client) SearchMySprintIssues(ctx context.Context, projectKey string, sprintID int, storyPointsFieldID string) ([]Issue, error)

SearchMySprintIssues returns issues assigned to the current user in a sprint.

func (*Client) SearchProjects

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

SearchProjects returns Jira projects matching query.

func (*Client) SearchUpdatedIssues

func (c *Client) SearchUpdatedIssues(ctx context.Context, projectKey string, sprintID int, since time.Time, storyPointsFieldID string) ([]Issue, error)

SearchUpdatedIssues returns sprint issues updated since the given time.

func (*Client) TransitionIssue

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

TransitionIssue applies a Jira workflow transition.

func (*Client) Transitions

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

Transitions returns all valid workflow transitions for an issue.

func (*Client) UpdateStoryPoints

func (c *Client) UpdateStoryPoints(ctx context.Context, issueKey, storyPointsFieldID string, points *float64) error

UpdateStoryPoints sets or clears the story points custom field for an issue.

func (*Client) UpdateTask added in v0.2.0

func (c *Client) UpdateTask(ctx context.Context, issueKey, summary, description string) error

UpdateTask updates an issue's summary and description.

func (*Client) UpdateTaskFields added in v0.4.0

func (c *Client) UpdateTaskFields(ctx context.Context, issueKey string, summary *string, description *Description) error

UpdateTaskFields updates only the supplied task fields.

type CreateTaskInput

type CreateTaskInput struct {
	ProjectKey      string
	IssueTypeID     string
	AssigneeID      string
	Summary         string
	Description     Description
	StoryPoints     *float64
	StoryPointsID   string
	AdditionalField map[string]any
	SaveID          string
}

CreateTaskInput is the payload for creating a Task in the active sprint.

type Description added in v0.4.0

type Description struct {
	EditorText        string
	Editable          bool
	UnsupportedReason string
	Images            []DescriptionImage
	References        []DescriptionImageReference
	RawADF            []byte
}

Description is the editable projection and preservation state of Jira ADF.

func ParseDescriptionEditor added in v0.4.0

func ParseDescriptionEditor(text string, base Description) (Description, error)

ParseDescriptionEditor validates editor text and reconciles its image references.

func PlainDescription added in v0.4.0

func PlainDescription(text string) Description

PlainDescription creates an editable description containing only plain text.

func (Description) MissingPendingImageData added in v0.4.0

func (d Description) MissingPendingImageData() []DescriptionImage

MissingPendingImageData returns referenced images that cannot be uploaded or serialized.

func (Description) ReferencedPendingImages added in v0.4.0

func (d Description) ReferencedPendingImages() []DescriptionImage

ReferencedPendingImages returns pending images in first-reference order.

func (Description) WithUploadedImage added in v0.4.0

func (d Description) WithUploadedImage(uploaded DescriptionImage) (Description, error)

WithUploadedImage records Jira attachment metadata and releases pending bytes.

func (Description) WithoutImageData added in v0.4.0

func (d Description) WithoutImageData() Description

WithoutImageData returns description metadata safe for ordinary issue caches.

type DescriptionImage added in v0.4.0

type DescriptionImage struct {
	ID           string
	AttachmentID string
	Filename     string
	MIMEType     string
	Data         []byte
	URL          string
	MediaID      string
	Collection   string
	Width        int
	Height       int
}

DescriptionImage is one image in a task draft, independent of its references.

func NewDescriptionImage added in v0.4.0

func NewDescriptionImage(filename, mimeType string, data []byte, width, height int) (DescriptionImage, error)

NewDescriptionImage creates a pending image with a stable draft-scoped ID.

type DescriptionImageReference added in v0.4.0

type DescriptionImageReference struct {
	ImageID      string
	Alt          string
	Presentation []byte
}

DescriptionImageReference is one block-level occurrence of a description image.

type Field

type Field struct {
	ID         string
	Name       string
	Custom     bool
	SchemaType string
}

Field is a Jira field exposed by the REST API.

type Issue

type Issue struct {
	ID                 string
	Key                string
	Summary            string
	Description        string
	DescriptionContent Description
	Status             Status
	IssueType          IssueType
	Assignee           *User
	StoryPoints        *float64
	Updated            time.Time
}

Issue is the minimal issue shape used by jiratui.

type IssueType

type IssueType struct {
	ID               string
	Name             string
	UntranslatedName string
	Subtask          bool
}

IssueType is a Jira issue type.

type Project

type Project struct {
	ID         string
	Key        string
	Name       string
	IssueTypes []IssueType
}

Project is a Jira project visible to the authenticated user.

type Sprint

type Sprint struct {
	ID        int
	Name      string
	State     string
	StartDate time.Time
	EndDate   time.Time
}

Sprint is a Jira agile sprint.

type Status

type Status struct {
	ID       string
	Name     string
	Category StatusCategory
}

Status is a Jira issue status.

type StatusCategory

type StatusCategory struct {
	Key  string
	Name string
}

StatusCategory is Jira's status category.

type StatusChange

type StatusChange struct {
	IssueKey     string
	IssueSummary string
	FromStatus   string
	ToStatus     string
	ToCategory   string
	AuthorID     string
	At           time.Time
}

StatusChange is a status transition extracted from an issue changelog.

type Transition

type Transition struct {
	ID       string
	Name     string
	ToStatus Status
}

Transition is a valid Jira workflow transition for an issue.

type User

type User struct {
	AccountID   string
	DisplayName string
	Email       string
}

User is a Jira user.

Jump to

Keyboard shortcuts

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