jira

package
v0.1.112 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jira is a thin Jira REST API v3 transport: authentication, site and OAuth cloud resolution, error redaction and the raw read/write calls. It returns Jira's JSON as json.RawMessage; modelling it (ADF, issues, sync) is the caller's concern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client calls one Jira site.

func NewClient

func NewClient(ctx context.Context, conn connection.JiraConnection, opts ...Option) (*Client, error)

NewClient validates conn, which must already be hydrated, and resolves the site: a bearer connection asks Atlassian which sites the token reaches.

func (*Client) Account

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

Account is the authenticated user's account id, read once per client.

func (*Client) Attachments

func (c *Client) Attachments(ctx context.Context, key string) (json.RawMessage, error)

Attachments is the raw attachment array of an issue.

func (*Client) BaseURL

func (c *Client) BaseURL() string

BaseURL is the URL the REST paths are appended to; it differs from Site when requests go through the Atlassian API gateway.

func (*Client) CloudID

func (c *Client) CloudID() string

CloudID is the Atlassian cloud id requests are routed by, empty when they go straight to the site.

func (*Client) Comments

func (c *Client) Comments(ctx context.Context, key string) ([]json.RawMessage, error)

Comments reads every raw comment of an issue, following Jira's offset paging.

func (*Client) CreateComment

func (c *Client) CreateComment(ctx context.Context, key string, body any) (json.RawMessage, error)

CreateComment posts body, an Atlassian Document Format document, as a comment and returns the raw created comment.

func (*Client) DeleteAttachment

func (c *Client) DeleteAttachment(ctx context.Context, id string) error

DeleteAttachment removes an attachment.

func (*Client) DownloadAttachment

func (c *Client) DownloadAttachment(ctx context.Context, id string, w io.Writer) (Download, error)

DownloadAttachment streams an attachment's content into w.

func (*Client) Fields

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

Fields is the site's field catalog: system fields and custom fields.

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, opts GetIssueOptions) (json.RawMessage, error)

GetIssue is the raw issue document. It does not record the read in the user's recently viewed list.

func (*Client) JSON

func (c *Client) JSON(ctx context.Context, opts RequestOptions, out any) error

JSON makes a call and decodes its JSON response into out; a nil out discards the body.

func (*Client) Myself

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

Myself is the authenticated user's raw /myself document.

func (*Client) OpenAttachment

func (c *Client) OpenAttachment(ctx context.Context, id string) (*http.Response, error)

OpenAttachment starts an attachment download. The caller streams and closes the response body, and reads its announced ContentLength for progress.

func (c *Client) RemoteLinks(ctx context.Context, key string) ([]json.RawMessage, error)

RemoteLinks are the raw remote link documents of an issue.

func (*Client) Request

func (c *Client) Request(ctx context.Context, opts RequestOptions) (*http.Response, error)

Request makes an authenticated call and returns the response of a 2xx status; the caller closes its body. Any other status is an error carrying the truncated, redacted response body.

func (*Client) SearchPage

func (c *Client) SearchPage(ctx context.Context, opts SearchOptions) (SearchPage, error)

SearchPage reads one page of a JQL search. Follow NextPageToken until IsLast.

func (*Client) Site

func (c *Client) Site() string

Site is the site URL browse links hang off, such as https://acme.atlassian.net.

func (*Client) UploadAttachments

func (c *Client) UploadAttachments(ctx context.Context, key string, files []string) (json.RawMessage, error)

UploadAttachments attaches the files to an issue and returns the raw array of created attachments.

type Download

type Download struct {
	SHA256 string
	ETag   string
	Size   int64
	// ContentLength is the size Jira announced, -1 when it did not.
	ContentLength int64
}

Download describes the content DownloadAttachment wrote.

type FieldDefinition

type FieldDefinition struct {
	ID            string          `json:"id"`
	Name          string          `json:"name"`
	Schema        json.RawMessage `json:"schema,omitempty"`
	Required      *bool           `json:"required,omitempty"`
	Operations    []string        `json:"operations,omitempty"`
	AllowedValues json.RawMessage `json:"allowedValues,omitempty"`
}

FieldDefinition is one entry of Jira's field catalog.

type GetIssueOptions

type GetIssueOptions struct {
	Key    string
	Fields []string
}

GetIssueOptions selects an issue and the fields to return; "*all", Jira's own spelling of every field, is requested when Fields is empty.

type Identity

type Identity struct {
	AccountID   string `json:"accountId"`
	DisplayName string `json:"displayName"`
	Email       string `json:"emailAddress"`
	// Site is the Jira site the connection reaches.
	Site string `json:"-"`
}

Identity is who a connection authenticates as, read from /myself.

func Probe

Probe tests a stored jira connection by calling GET /rest/api/3/myself. Its value references resolve through resolver in the connection's namespace.

type Option

type Option func(*options)

Option customises NewClient.

func WithHTTPClient

func WithHTTPClient(client *httpclient.Client) Option

WithHTTPClient makes the caller's client carry the requests. It is the caller that configures its logging, HAR capture and transport; NewClient still sets its timeout and refuses redirects.

type RequestOptions

type RequestOptions struct {
	Method  string
	Path    string
	URL     string
	Query   url.Values
	Body    any
	Headers map[string]string
}

RequestOptions describes one REST call. Path is relative to /rest/api/3 and ignored when URL is an absolute URL.

type SearchOptions

type SearchOptions struct {
	JQL    string
	Fields []string
	Limit  int
	After  string
}

SearchOptions is one page of a JQL search. After is the NextPageToken of the previous page; Limit 0 leaves Jira's default page size.

type SearchPage

type SearchPage struct {
	Issues        []json.RawMessage `json:"issues"`
	NextPageToken string            `json:"nextPageToken"`
	// IsLast is nil when Jira did not say.
	IsLast *bool `json:"isLast"`
}

SearchPage is one page of /search/jql: the raw issues and the continuation.

Jump to

Keyboard shortcuts

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