jira

package
v1.238.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: BSD-3-Clause Imports: 8 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 small HTTP client for an on-prem Jira Data Center/Server instance (e.g. jira.cc.hm.edu). It authenticates with a Personal Access Token (PAT) via the `Authorization: Bearer <PAT>` header and talks to the REST API v2 (`/rest/api/2/...`). It mirrors the structure of the zpa package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	ID       string `json:"id"`
	Filename string `json:"filename"`
	Size     int    `json:"size"`
	MimeType string `json:"mimeType"`
	Content  string `json:"content"` // download URL
}

Attachment is the subset of Jira's attachment representation we read back.

type Comment

type Comment struct {
	ID      string `json:"id"`
	Author  *User  `json:"author,omitempty"`
	Body    string `json:"body"`
	Created string `json:"created"`
	Updated string `json:"updated"`
}

Comment is a single issue comment.

type CommentPage

type CommentPage struct {
	Comments []Comment `json:"comments"`
	Total    int       `json:"total"`
}

CommentPage is the (paginated) comment container embedded in an issue's fields.

type Issue

type Issue struct {
	ID     string      `json:"id"`
	Key    string      `json:"key"`
	Self   string      `json:"self"`
	Fields IssueFields `json:"fields"`
}

Issue is the subset of a Jira issue we read back.

type IssueFields

type IssueFields struct {
	Summary     string       `json:"summary"`
	Description string       `json:"description"`
	Status      *NamedRef    `json:"status,omitempty"`
	IssueType   *NamedRef    `json:"issuetype,omitempty"`
	Project     *ProjectRef  `json:"project,omitempty"`
	Reporter    *User        `json:"reporter,omitempty"`
	Created     string       `json:"created,omitempty"`
	Comment     *CommentPage `json:"comment,omitempty"`
}

type IssueWithRequestType

type IssueWithRequestType struct {
	Issue
	RequestType string
}

IssueWithRequestType is an issue plus its JSM customer request type name (empty when the issue was not raised through a request type).

type Jira

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

func New

func New(baseurl, token, project string) *Jira

New builds a Jira client. baseurl is the instance root (e.g. "https://jira.cc.hm.edu"); a trailing slash is trimmed. token is the PAT. It does not perform any network call; use Myself to verify the connection.

func (*Jira) AddAttachment

func (j *Jira) AddAttachment(key, filename string, data []byte) ([]Attachment, error)

AddAttachment uploads a file to an issue. Jira's attachment endpoint is multipart/form-data (not JSON) and requires the X-Atlassian-Token: no-check header to bypass the XSRF check, so it does not go through do().

func (*Jira) AddComment

func (j *Jira) AddComment(key, body string) error

AddComment posts a plain-text comment to an issue.

func (*Jira) Comments

func (j *Jira) Comments(key string) ([]Comment, error)

Comments returns all comments of an issue, oldest first (Jira's default order).

func (*Jira) CreateIssue

func (j *Jira) CreateIssue(in NewIssue) (*Issue, error)

CreateIssue creates a new issue and returns the created key/id.

func (*Jira) GetIssue

func (j *Jira) GetIssue(key string) (*Issue, error)

GetIssue fetches a single issue by key (e.g. "PLEX-42").

func (*Jira) Myself

func (j *Jira) Myself() (*User, error)

Myself calls GET /rest/api/2/myself and returns the authenticated user. It is the cheapest way to verify that baseurl and PAT are valid.

func (*Jira) OpenIssues

func (j *Jira) OpenIssues(project string) ([]Issue, error)

OpenIssues returns the not-yet-done issues of a project (statusCategory != Done), newest first. project falls back to the configured default when empty; if both are empty the search spans all projects the PAT can see.

func (*Jira) OpenIssuesWithRequestType

func (j *Jira) OpenIssuesWithRequestType(project string) ([]IssueWithRequestType, error)

OpenIssuesWithRequestType returns the open (not-done) issues of a project, each annotated with its JSM customer request type. project falls back to the configured default when empty.

func (*Jira) Search

func (j *Jira) Search(jql string) ([]Issue, error)

Search runs a JQL query and returns the matching issues, transparently paging through the result set (up to searchMaxIssues). Only the fields needed for a list view (summary, status, issuetype) are requested.

func (*Jira) TransitionIssue

func (j *Jira) TransitionIssue(key, transitionID string) error

TransitionIssue moves an issue through the given transition id.

func (*Jira) TransitionIssueByName

func (j *Jira) TransitionIssueByName(key, name string) error

TransitionIssueByName is a convenience wrapper that looks up the transition by (case-insensitive) name and applies it — handy because IDs differ per workflow while names like "Done" are stable.

func (*Jira) Transitions

func (j *Jira) Transitions(key string) ([]Transition, error)

Transitions lists the transitions available for an issue in its current status. Their IDs are what TransitionIssue expects — they are workflow- and status-specific, not global.

type NamedRef

type NamedRef struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type NewIssue

type NewIssue struct {
	ProjectKey  string
	IssueType   string
	Summary     string
	Description string
}

NewIssue describes an issue to be created. ProjectKey and IssueType fall back to the client defaults / "Task" when empty.

type ProjectRef

type ProjectRef struct {
	Key string `json:"key,omitempty"`
}

type Transition

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

Transition is one of the workflow transitions currently available on an issue.

type User

type User struct {
	Name         string `json:"name"`
	Key          string `json:"key"`
	DisplayName  string `json:"displayName"`
	EmailAddress string `json:"emailAddress"`
	Active       bool   `json:"active"`
}

User is the subset of Jira's user representation we care about.

Jump to

Keyboard shortcuts

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