client

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package client provides an HTTP client for the Jira REST API v2 and the Jira Agile REST API (boards/sprints).

Authentication is performed using a Bearer token (Jira Cloud personal access token or Jira Server/Data Center personal access token).

The client automatically prefixes all requests with the configured server URL and the appropriate API base path:

  • /rest/api/2 – core Jira API (v2)
  • /rest/agile/1.0 – Jira Agile (boards, sprints)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatCustomField

func FormatCustomField(raw json.RawMessage) string

FormatCustomField converts a raw JSON value from IssueFields.Extra into a human-readable string. It handles common Jira value shapes (plain strings, named objects, arrays) without requiring callers to know the field schema.

Types

type ADFString

type ADFString string

ADFString is a string value that may be unmarshaled from either a JSON string or an Atlassian Document Format object. In both cases the plain-text content is stored in the string value.

func (*ADFString) UnmarshalJSON

func (a *ADFString) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It handles three cases:

  1. A JSON string — stored as-is.
  2. An ADF document object — plain text is extracted recursively.
  3. JSON null — left as empty string.

type Attachment

type Attachment struct {
	ID       string `json:"id"`
	Self     string `json:"self"`
	Filename string `json:"filename"`
	Author   *User  `json:"author"`
	Created  string `json:"created"`
	Size     int64  `json:"size"`
	MimeType string `json:"mimeType"`
	Content  string `json:"content"`
}

Attachment represents a file attached to a Jira issue.

type Board

type Board struct {
	ID       int            `json:"id"`
	Name     string         `json:"name"`
	Type     string         `json:"type"`
	Self     string         `json:"self"`
	Location *BoardLocation `json:"location"`
}

Board represents a Jira Agile board.

type BoardList

type BoardList struct {
	MaxResults int     `json:"maxResults"`
	StartAt    int     `json:"startAt"`
	Total      int     `json:"total"`
	IsLast     bool    `json:"isLast"`
	Values     []Board `json:"values"`
}

BoardList is a paginated list of boards.

type BoardLocation

type BoardLocation struct {
	ProjectID   int    `json:"projectId"`
	ProjectKey  string `json:"projectKey"`
	ProjectName string `json:"projectName"`
}

BoardLocation describes where a board is scoped.

type Client

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

Client is a configured Jira API client.

func New

func New(cfg *config.Config) *Client

New creates a new Client from the supplied configuration.

func (*Client) AddAttachment

func (c *Client) AddAttachment(ctx context.Context, issueKey, filePath string) ([]Attachment, error)

AddAttachment uploads a file as an attachment to an issue.

API: POST /rest/api/2/issue/{issueIdOrKey}/attachments

func (*Client) AddComment

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

AddComment adds a comment to an issue.

API: POST /rest/api/2/issue/{issueIdOrKey}/comment

func (*Client) AddVote

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

AddVote casts a vote for an issue.

API: POST /rest/api/2/issue/{issueIdOrKey}/votes

func (*Client) AddWatcher

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

AddWatcher adds a user as a watcher on an issue.

API: POST /rest/api/2/issue/{issueIdOrKey}/watchers

func (*Client) AddWorklog

func (c *Client) AddWorklog(ctx context.Context, issueKey, timeSpent, started, comment string) (*Worklog, error)

AddWorklog adds a worklog entry to an issue.

API: POST /rest/api/2/issue/{issueIdOrKey}/worklog

func (*Client) AssignIssue

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

AssignIssue assigns an issue to a user. Pass an empty accountID to unassign.

API: PUT /rest/api/2/issue/{issueIdOrKey}/assignee

func (*Client) CreateComponent

func (c *Client) CreateComponent(ctx context.Context, projectKey, name, description string) (*Component, error)

CreateComponent creates a new project component.

API: POST /rest/api/2/component

func (*Client) CreateIssue

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

CreateIssue creates a new Jira issue.

API: POST /rest/api/2/issue

func (*Client) CreateProject

func (c *Client) CreateProject(ctx context.Context, req *CreateProjectRequest) (*Project, error)

CreateProject creates a new Jira project.

API: POST /rest/api/2/project

func (*Client) CreateSprint

func (c *Client) CreateSprint(ctx context.Context, req *CreateSprintRequest) (*Sprint, error)

CreateSprint creates a new sprint on a board.

API: POST /rest/agile/1.0/sprint

func (*Client) CreateVersion

func (c *Client) CreateVersion(ctx context.Context, projectKey, name, description, releaseDate string) (*Version, error)

CreateVersion creates a new project version.

API: POST /rest/api/2/version

func (*Client) DeleteAttachment

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

DeleteAttachment deletes an attachment by ID.

API: DELETE /rest/api/2/attachment/{id}

func (*Client) DeleteComment

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

DeleteComment deletes a comment.

API: DELETE /rest/api/2/issue/{issueIdOrKey}/comment/{id}

func (*Client) DeleteComponent

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

DeleteComponent deletes a project component.

API: DELETE /rest/api/2/component/{id}

func (*Client) DeleteIssue

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

DeleteIssue deletes a Jira issue.

API: DELETE /rest/api/2/issue/{issueIdOrKey}

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

DeleteIssueLink removes a link between issues.

API: DELETE /rest/api/2/issueLink/{linkId}

func (*Client) DeleteProject

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

DeleteProject deletes a project.

API: DELETE /rest/api/2/project/{projectIdOrKey}

func (*Client) DeleteVersion

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

DeleteVersion deletes a project version.

API: DELETE /rest/api/2/version/{id}

func (*Client) DeleteWorklog

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

DeleteWorklog deletes a worklog entry.

API: DELETE /rest/api/2/issue/{issueIdOrKey}/worklog/{id}

func (*Client) GetBoards

func (c *Client) GetBoards(ctx context.Context, projectKey string, maxResults int) (*BoardList, error)

GetBoards returns all boards visible to the current user.

API: GET /rest/agile/1.0/board

func (*Client) GetComments

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

GetComments retrieves all comments for an issue.

API: GET /rest/api/2/issue/{issueIdOrKey}/comment

func (*Client) GetComponents

func (c *Client) GetComponents(ctx context.Context, projectKey string) ([]Component, error)

GetComponents returns all components for a project.

API: GET /rest/api/2/project/{projectIdOrKey}/components

func (*Client) GetConfiguration added in v1.2.0

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

GetConfiguration returns the instance-level configuration flags.

API: GET /rest/api/2/configuration Works on both Jira Cloud and Jira Server / Data Center.

func (*Client) GetCurrentUser

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

GetCurrentUser returns the currently authenticated user.

API: GET /rest/api/2/myself

func (*Client) GetEditMeta added in v1.2.0

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

GetEditMeta returns the edit metadata for an existing issue, including the allowed values for each editable field.

API: GET /rest/api/2/issue/{issueKey}/editmeta Ref: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-editmeta-get

func (*Client) GetFieldContexts added in v1.2.0

func (c *Client) GetFieldContexts(ctx context.Context, fieldID string, opts FieldContextOptions) (*FieldContextPage, error)

GetFieldContexts returns the contexts for a custom field.

API: GET /rest/api/2/field/{fieldId}/context

func (*Client) GetFieldOptions added in v1.2.0

func (c *Client) GetFieldOptions(ctx context.Context, fieldID string, contextID string, onlyOptions bool, startAt, maxResults int) (*FieldOptionPage, error)

GetFieldOptions returns the options (allowed values) for a custom field context.

API: GET /rest/api/2/field/{fieldId}/context/option

func (*Client) GetFields

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

GetFields returns all field definitions.

API: GET /rest/api/2/field

func (*Client) GetIssue

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

GetIssue retrieves a single Jira issue by its key or ID.

API: GET /rest/api/2/issue/{issueIdOrKey}

func (*Client) GetIssueLinkTypes

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

GetIssueLinkTypes returns all available link types.

API: GET /rest/api/2/issueLinkType

func (*Client) GetIssueTypes

func (c *Client) GetIssueTypes(ctx context.Context) ([]IssueType, error)

GetIssueTypes returns all issue types.

API: GET /rest/api/2/issuetype

func (*Client) GetPriorities

func (c *Client) GetPriorities(ctx context.Context) ([]Priority, error)

GetPriorities returns all issue priorities.

API: GET /rest/api/2/priority

func (*Client) GetProject

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

GetProject returns a single project by key or ID.

API: GET /rest/api/2/project/{projectIdOrKey}

func (*Client) GetProjectStatuses added in v1.2.0

func (c *Client) GetProjectStatuses(ctx context.Context, projectKey string) ([]ProjectIssueTypeStatuses, error)

GetProjectStatuses returns the statuses available for each issue type in the given project.

API: GET /rest/api/2/project/{projectIdOrKey}/statuses Works on both Jira Cloud and Jira Server / Data Center.

func (*Client) GetProjects

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

GetProjects returns all projects visible to the current user.

API: GET /rest/api/2/project

func (*Client) GetResolutions added in v1.2.0

func (c *Client) GetResolutions(ctx context.Context) ([]Resolution, error)

GetResolutions returns all resolutions defined on the Jira instance.

API: GET /rest/api/2/resolution Works on both Jira Cloud and Jira Server / Data Center.

func (*Client) GetServerInfo added in v1.2.0

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

GetServerInfo returns build and runtime information about the Jira instance.

API: GET /rest/api/2/serverInfo Works on both Jira Cloud and Jira Server / Data Center.

func (*Client) GetSprintIssues

func (c *Client) GetSprintIssues(ctx context.Context, sprintID int) (*SearchResult, error)

GetSprintIssues returns all issues in a sprint.

API: GET /rest/agile/1.0/sprint/{sprintId}/issue

func (*Client) GetSprints

func (c *Client) GetSprints(ctx context.Context, boardID int, state string) (*SprintList, error)

GetSprints returns all sprints for a board.

API: GET /rest/agile/1.0/board/{boardId}/sprint

func (*Client) GetStatuses

func (c *Client) GetStatuses(ctx context.Context) ([]Status, error)

GetStatuses returns all issue statuses.

API: GET /rest/api/2/status

func (*Client) GetTransitions

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

GetTransitions returns the available transitions for an issue.

API: GET /rest/api/2/issue/{issueIdOrKey}/transitions

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, accountID string) (*User, error)

GetUser retrieves a user by account ID.

API: GET /rest/api/2/user?accountId={accountId}

func (*Client) GetVersions

func (c *Client) GetVersions(ctx context.Context, projectKey string) ([]Version, error)

GetVersions returns all versions for a project.

API: GET /rest/api/2/project/{projectIdOrKey}/versions

func (*Client) GetVotes

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

GetVotes retrieves vote information for an issue.

API: GET /rest/api/2/issue/{issueIdOrKey}/votes

func (*Client) GetWatchers

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

GetWatchers retrieves the watcher list for an issue.

API: GET /rest/api/2/issue/{issueIdOrKey}/watchers

func (*Client) GetWorklogs

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

GetWorklogs retrieves worklogs for an issue.

API: GET /rest/api/2/issue/{issueIdOrKey}/worklog

func (*Client) LinkIssues

func (c *Client) LinkIssues(ctx context.Context, linkTypeName, inwardKey, outwardKey, comment string) error

LinkIssues creates a link between two issues.

API: POST /rest/api/2/issueLink

func (*Client) RemoveVote

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

RemoveVote removes the current user's vote from an issue.

API: DELETE /rest/api/2/issue/{issueIdOrKey}/votes

func (*Client) RemoveWatcher

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

RemoveWatcher removes a watcher from an issue.

API: DELETE /rest/api/2/issue/{issueIdOrKey}/watchers?accountId={accountId}

func (*Client) SearchFields added in v1.2.0

func (c *Client) SearchFields(ctx context.Context, opts FieldSearchOptions) (*FieldSearchPage, error)

SearchFields returns a paginated list of field definitions.

API: GET /rest/api/2/field/search

func (*Client) SearchIssues

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

SearchIssues executes a JQL search and returns matching issues.

API: GET /rest/api/2/search

func (*Client) SearchUsers

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

SearchUsers searches for users.

API: GET /rest/api/2/user/search?query={query}

func (*Client) TransitionIssue

func (c *Client) TransitionIssue(ctx context.Context, issueKey, transitionID string, fields map[string]interface{}) error

TransitionIssue moves an issue to a new state by transition ID.

API: POST /rest/api/2/issue/{issueIdOrKey}/transitions

func (*Client) UpdateComment

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

UpdateComment updates an existing comment.

API: PUT /rest/api/2/issue/{issueIdOrKey}/comment/{id}

func (*Client) UpdateComponent

func (c *Client) UpdateComponent(ctx context.Context, componentID string, fields map[string]interface{}) (*Component, error)

UpdateComponent updates a project component.

API: PUT /rest/api/2/component/{id}

func (*Client) UpdateIssue

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

UpdateIssue updates an existing Jira issue.

API: PUT /rest/api/2/issue/{issueIdOrKey}

func (*Client) UpdateProject

func (c *Client) UpdateProject(ctx context.Context, projectKey string, fields map[string]interface{}) (*Project, error)

UpdateProject updates a project.

API: PUT /rest/api/2/project/{projectIdOrKey}

func (*Client) UpdateSprint

func (c *Client) UpdateSprint(ctx context.Context, sprintID int, fields map[string]interface{}) (*Sprint, error)

UpdateSprint updates a sprint.

API: PUT /rest/agile/1.0/sprint/{sprintId}

func (*Client) UpdateVersion

func (c *Client) UpdateVersion(ctx context.Context, versionID string, fields map[string]interface{}) (*Version, error)

UpdateVersion updates a project version.

API: PUT /rest/api/2/version/{id}

type Comment

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

Comment represents a Jira issue comment.

type CommentList

type CommentList struct {
	Total      int       `json:"total"`
	StartAt    int       `json:"startAt"`
	MaxResults int       `json:"maxResults"`
	Comments   []Comment `json:"comments"`
}

CommentList is the paginated list of comments returned by the API.

type Component

type Component struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Lead        *User  `json:"lead"`
	Project     string `json:"project"`
}

Component represents a Jira project component.

type Configuration added in v1.2.0

type Configuration struct {
	VotingEnabled           bool                      `json:"votingEnabled"`
	WatchingEnabled         bool                      `json:"watchingEnabled"`
	UnassignedIssuesAllowed bool                      `json:"unassignedIssuesAllowed"`
	SubTasksEnabled         bool                      `json:"subTasksEnabled"`
	IssueLinkingEnabled     bool                      `json:"issueLinkingEnabled"`
	TimeTrackingEnabled     bool                      `json:"timeTrackingEnabled"`
	AttachmentsEnabled      bool                      `json:"attachmentsEnabled"`
	TimeTracking            TimeTrackingConfiguration `json:"timeTrackingConfiguration"`
}

Configuration holds instance-level feature flags and settings.

type CreateIssueFields

type CreateIssueFields struct {
	Project     IDObj     `json:"project"`
	Summary     string    `json:"summary"`
	Description string    `json:"description,omitempty"`
	IssueType   NamedObj  `json:"issuetype"`
	Priority    *NamedObj `json:"priority,omitempty"`
	Assignee    *IDObj    `json:"assignee,omitempty"`
	Labels      []string  `json:"labels,omitempty"`
	Components  []IDObj   `json:"components,omitempty"`
	FixVersions []IDObj   `json:"fixVersions,omitempty"`
	DueDate     string    `json:"duedate,omitempty"`
	Parent      *IDObj    `json:"parent,omitempty"`
}

CreateIssueFields contains the field values for issue creation.

type CreateIssueRequest

type CreateIssueRequest struct {
	Fields CreateIssueFields `json:"fields"`
}

CreateIssueRequest is the payload for creating a new issue.

type CreateIssueResponse

type CreateIssueResponse struct {
	ID   string `json:"id"`
	Key  string `json:"key"`
	Self string `json:"self"`
}

CreateIssueResponse is the response from creating a new issue.

type CreateProjectRequest

type CreateProjectRequest struct {
	Key            string `json:"key"`
	Name           string `json:"name"`
	Description    string `json:"description,omitempty"`
	ProjectTypeKey string `json:"projectTypeKey"`
	LeadAccountID  string `json:"leadAccountId,omitempty"`
	AssigneeType   string `json:"assigneeType,omitempty"`
}

CreateProjectRequest is the payload for creating a project.

type CreateSprintRequest

type CreateSprintRequest struct {
	Name          string `json:"name"`
	Goal          string `json:"goal,omitempty"`
	StartDate     string `json:"startDate,omitempty"`
	EndDate       string `json:"endDate,omitempty"`
	OriginBoardID int    `json:"originBoardId"`
}

CreateSprintRequest is the payload for creating a sprint.

type EditMeta added in v1.2.0

type EditMeta struct {
	Fields map[string]EditMetaField `json:"fields"`
}

EditMeta is the response from GET /rest/api/2/issue/{issueKey}/editmeta.

type EditMetaAllowedValue added in v1.2.0

type EditMetaAllowedValue struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Value       string `json:"value"`
	Description string `json:"description"`
}

EditMetaAllowedValue is one entry in the allowedValues list for a field. Both select-style fields (value) and object-style fields (name, id) are covered by this struct.

type EditMetaField added in v1.2.0

type EditMetaField struct {
	Required      bool                   `json:"required"`
	Schema        map[string]interface{} `json:"schema"`
	Name          string                 `json:"name"`
	AllowedValues []EditMetaAllowedValue `json:"allowedValues"`
}

EditMetaField describes a single field as returned by the editmeta endpoint.

type Field

type Field struct {
	ID         string `json:"id"`
	Key        string `json:"key"`
	Name       string `json:"name"`
	Custom     bool   `json:"custom"`
	Orderable  bool   `json:"orderable"`
	Navigable  bool   `json:"navigable"`
	Searchable bool   `json:"searchable"`
}

Field represents a Jira issue field definition.

type FieldContext added in v1.2.0

type FieldContext struct {
	ID              string `json:"id"`
	Name            string `json:"name"`
	Description     string `json:"description"`
	IsGlobalContext bool   `json:"isGlobalContext"`
	IsAnyIssueType  bool   `json:"isAnyIssueType"`
}

FieldContext represents a custom field context.

type FieldContextOptions added in v1.2.0

type FieldContextOptions struct {
	// IsAnyIssueType filters to contexts that apply to all issue types (true) or a subset (false).
	// nil means no filter.
	IsAnyIssueType *bool
	// IsGlobalContext filters to global contexts (true) or project-scoped (false).
	// nil means no filter.
	IsGlobalContext *bool
	// ContextIDs filters to specific context IDs.
	ContextIDs []int
	StartAt    int
	MaxResults int
}

FieldContextOptions configures the context list request.

type FieldContextPage added in v1.2.0

type FieldContextPage struct {
	Total      int            `json:"total"`
	StartAt    int            `json:"startAt"`
	MaxResults int            `json:"maxResults"`
	IsLast     bool           `json:"isLast"`
	Values     []FieldContext `json:"values"`
}

FieldContextPage is the paginated response from GET /rest/api/2/field/{fieldId}/context.

type FieldOption added in v1.2.0

type FieldOption struct {
	ID        string `json:"id"`
	Value     string `json:"value"`
	Disabled  bool   `json:"disabled"`
	ContextID string `json:"contextId,omitempty"`
}

FieldOption represents an option (allowed value) for a custom field.

type FieldOptionPage added in v1.2.0

type FieldOptionPage struct {
	Total      int           `json:"total"`
	StartAt    int           `json:"startAt"`
	MaxResults int           `json:"maxResults"`
	IsLast     bool          `json:"isLast"`
	Values     []FieldOption `json:"values"`
}

FieldOptionPage is the paginated response from the field options endpoint.

type FieldSearchOptions added in v1.2.0

type FieldSearchOptions struct {
	// IDs filters to specific field IDs.
	IDs []string
	// Query filters by name/description substring.
	Query string
	// Type filters by field type: "system" or "custom".
	Type string
	// OrderBy orders results: "contextsCount", "lastUsed", "name", "screensCount", "projectsCount".
	OrderBy string
	// Expand includes additional data: "screensCount", "contextsCount", "lastUsed".
	Expand string
	// ProjectIDs filters to fields used in these projects.
	ProjectIDs []int
	StartAt    int
	MaxResults int
}

FieldSearchOptions configures the paginated field search.

type FieldSearchPage added in v1.2.0

type FieldSearchPage struct {
	Total      int                 `json:"total"`
	StartAt    int                 `json:"startAt"`
	MaxResults int                 `json:"maxResults"`
	IsLast     bool                `json:"isLast"`
	Values     []FieldSearchResult `json:"values"`
}

FieldSearchPage is the paginated response from GET /rest/api/2/field/search.

type FieldSearchResult added in v1.2.0

type FieldSearchResult struct {
	ID            string          `json:"id"`
	Key           string          `json:"key"`
	Name          string          `json:"name"`
	Description   string          `json:"description"`
	Custom        bool            `json:"custom"`
	Searchable    bool            `json:"searchable"`
	Navigable     bool            `json:"navigable"`
	Orderable     bool            `json:"orderable"`
	IsLocked      bool            `json:"isLocked"`
	SearcherKey   string          `json:"searcherKey"`
	ScreensCount  int             `json:"screensCount"`
	ContextsCount int             `json:"contextsCount"`
	ProjectsCount int             `json:"projectsCount"`
	Schema        json.RawMessage `json:"schema"`
}

FieldSearchResult represents an individual field returned by the paginated field search endpoint, which includes additional metadata not available from the simple GET /field endpoint.

type IDObj

type IDObj struct {
	ID  string `json:"id,omitempty"`
	Key string `json:"key,omitempty"`
}

IDObj is a simple ID-only reference.

type Issue

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

	// Raw stores the original JSON bytes received from the API.
	// It is used by --all-fields to output the response without the
	// omitempty suppression applied during normal typed marshaling.
	Raw json.RawMessage `json:"-"`
}

Issue represents a Jira issue as returned by the API.

func (*Issue) UnmarshalJSON

func (i *Issue) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a Jira issue, capturing the raw bytes alongside the typed fields so that callers can round-trip the original payload when needed.

type IssueFields

type IssueFields struct {
	Summary      string        `json:"summary,omitempty"`
	Description  ADFString     `json:"description,omitempty"`
	Status       NamedObj      `json:"status,omitempty"`
	Priority     NamedObj      `json:"priority,omitempty"`
	Assignee     *User         `json:"assignee,omitempty"`
	Reporter     *User         `json:"reporter,omitempty"`
	IssueType    NamedObj      `json:"issuetype,omitempty"`
	Project      ProjectShort  `json:"project,omitempty"`
	Labels       []string      `json:"labels,omitempty"`
	Components   []NamedObj    `json:"components,omitempty"`
	FixVersions  []NamedObj    `json:"fixVersions,omitempty"`
	Created      string        `json:"created,omitempty"`
	Updated      string        `json:"updated,omitempty"`
	DueDate      string        `json:"duedate,omitempty"`
	Votes        *Votes        `json:"votes,omitempty"`
	Watches      *Watches      `json:"watches,omitempty"`
	Comment      *CommentList  `json:"comment,omitempty"`
	TimeTracking *TimeTracking `json:"timetracking,omitempty"`
	Parent       *IssueRef     `json:"parent,omitempty"`

	// Extra holds any fields not explicitly modelled above (e.g. customfield_10001).
	// Values are stored as raw JSON for lazy decoding; use FormatCustomField to render them.
	Extra map[string]json.RawMessage `json:"-"`
}

IssueFields contains the field values of a Jira issue.

func (IssueFields) MarshalJSON

func (f IssueFields) MarshalJSON() ([]byte, error)

MarshalJSON serialises IssueFields including any custom fields stored in Extra, so that --output json round-trips all field data back to the caller. It also manually omits zero-value struct fields (NamedObj, ProjectShort) that encoding/json's omitempty cannot handle — omitempty only suppresses pointers, strings, slices, maps, and numeric types, not struct values.

func (*IssueFields) UnmarshalJSON

func (f *IssueFields) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes the Jira fields object. Known fields are decoded into their typed struct fields; unrecognised fields (e.g. custom fields) are stored verbatim in Extra.

type IssueLinkType

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

IssueLinkType describes the type of an issue link.

type IssueLinkTypeList

type IssueLinkTypeList struct {
	IssueLinkTypes []IssueLinkType `json:"issueLinkTypes"`
}

IssueLinkTypeList is a list of issue link types.

type IssueRef

type IssueRef struct {
	ID  string `json:"id,omitempty"`
	Key string `json:"key,omitempty"`
}

IssueRef is a lightweight reference to another issue (e.g. parent).

type IssueType

type IssueType struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Subtask     bool   `json:"subtask"`
}

IssueType represents a Jira issue type.

type NamedObj

type NamedObj struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name"`
	Self string `json:"self,omitempty"`
}

NamedObj is a simple name-only sub-object used throughout the Jira API.

type Priority

type Priority struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

Priority represents a Jira issue priority.

type Project

type Project struct {
	ID          string `json:"id"`
	Key         string `json:"key"`
	Name        string `json:"name"`
	Self        string `json:"self"`
	Description string `json:"description"`
	Lead        *User  `json:"lead"`
	ProjectType string `json:"projectTypeKey"`
	Style       string `json:"style"`
	IsPrivate   bool   `json:"isPrivate"`
}

Project represents a Jira project.

type ProjectIssueTypeStatuses added in v1.2.0

type ProjectIssueTypeStatuses struct {
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	Subtask  bool     `json:"subtask"`
	Statuses []Status `json:"statuses"`
}

ProjectIssueTypeStatuses groups the workflow statuses available for one issue type within a project.

type ProjectShort

type ProjectShort struct {
	ID   string `json:"id,omitempty"`
	Key  string `json:"key,omitempty"`
	Name string `json:"name,omitempty"`
}

ProjectShort is a minimal project representation.

type Resolution added in v1.2.0

type Resolution struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

Resolution represents a Jira issue resolution.

type SearchOptions

type SearchOptions struct {
	JQL        string
	Fields     []string
	StartAt    int
	MaxResults int
}

SearchOptions configures a JQL search.

type SearchResult

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

SearchResult is the response from the search endpoint.

type ServerInfo added in v1.2.0

type ServerInfo struct {
	BaseURL        string `json:"baseUrl"`
	Version        string `json:"version"`
	DeploymentType string `json:"deploymentType"`
	BuildNumber    int    `json:"buildNumber"`
	BuildDate      string `json:"buildDate"`
	ServerTime     string `json:"serverTime"`
	ScmInfo        string `json:"scmInfo"`
	ServerTitle    string `json:"serverTitle"`
}

ServerInfo contains build and runtime information about the Jira instance.

type Sprint

type Sprint struct {
	ID            int    `json:"id"`
	Name          string `json:"name"`
	State         string `json:"state"`
	StartDate     string `json:"startDate"`
	EndDate       string `json:"endDate"`
	CompleteDate  string `json:"completeDate"`
	Goal          string `json:"goal"`
	OriginBoardID int    `json:"originBoardId"`
}

Sprint represents a Jira Agile sprint.

type SprintList

type SprintList struct {
	MaxResults int      `json:"maxResults"`
	StartAt    int      `json:"startAt"`
	Total      int      `json:"total"`
	IsLast     bool     `json:"isLast"`
	Values     []Sprint `json:"values"`
}

SprintList is a paginated list of sprints.

type Status

type Status struct {
	ID          string         `json:"id"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Category    StatusCategory `json:"statusCategory"`
}

Status represents a Jira issue status.

type StatusCategory added in v1.2.0

type StatusCategory struct {
	ID   int    `json:"id"`
	Key  string `json:"key"`
	Name string `json:"name"`
}

StatusCategory is the category of a Jira status. Its id field is a number in the REST API response (unlike most other id fields which are strings).

type TimeTracking

type TimeTracking struct {
	OriginalEstimate         string `json:"originalEstimate,omitempty"`
	RemainingEstimate        string `json:"remainingEstimate,omitempty"`
	TimeSpent                string `json:"timeSpent,omitempty"`
	OriginalEstimateSeconds  int    `json:"originalEstimateSeconds,omitempty"`
	RemainingEstimateSeconds int    `json:"remainingEstimateSeconds,omitempty"`
	TimeSpentSeconds         int    `json:"timeSpentSeconds,omitempty"`
}

TimeTracking holds time estimate information.

type TimeTrackingConfiguration added in v1.2.0

type TimeTrackingConfiguration struct {
	WorkingHoursPerDay float64 `json:"workingHoursPerDay"`
	WorkingDaysPerWeek float64 `json:"workingDaysPerWeek"`
	TimeFormat         string  `json:"timeFormat"`
	DefaultUnit        string  `json:"defaultUnit"`
}

TimeTrackingConfiguration holds time-tracking settings.

type Transition

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

Transition represents a Jira workflow transition.

type TransitionList

type TransitionList struct {
	Transitions []Transition `json:"transitions"`
}

TransitionList is the list of available transitions for an issue.

type UpdateIssueRequest

type UpdateIssueRequest struct {
	Fields map[string]interface{} `json:"fields"`
}

UpdateIssueRequest is the payload for updating an existing issue.

type User

type User struct {
	AccountID    string `json:"accountId,omitempty"`
	Name         string `json:"name,omitempty"`
	DisplayName  string `json:"displayName,omitempty"`
	EmailAddress string `json:"emailAddress,omitempty"`
	Active       bool   `json:"active"`
	Self         string `json:"self,omitempty"`
}

User represents a Jira user.

type Version

type Version struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Released    bool   `json:"released"`
	Archived    bool   `json:"archived"`
	ReleaseDate string `json:"releaseDate"`
	ProjectID   int    `json:"projectId"`
}

Version represents a Jira project version (release).

type Votes

type Votes struct {
	Votes    int  `json:"votes"`
	HasVoted bool `json:"hasVoted"`
}

Votes holds vote count information.

type WatcherList

type WatcherList struct {
	Self       string `json:"self"`
	WatchCount int    `json:"watchCount"`
	IsWatching bool   `json:"isWatching"`
	Watchers   []User `json:"watchers"`
}

WatcherList holds watcher information for an issue.

type Watches

type Watches struct {
	WatchCount int  `json:"watchCount"`
	IsWatching bool `json:"isWatching"`
}

Watches holds watcher count information.

type Worklog

type Worklog struct {
	ID               string    `json:"id"`
	Self             string    `json:"self"`
	Author           *User     `json:"author"`
	Comment          ADFString `json:"comment"`
	Started          string    `json:"started"`
	TimeSpent        string    `json:"timeSpent"`
	TimeSpentSeconds int       `json:"timeSpentSeconds"`
}

Worklog represents a Jira worklog entry.

type WorklogList

type WorklogList struct {
	Total      int       `json:"total"`
	StartAt    int       `json:"startAt"`
	MaxResults int       `json:"maxResults"`
	Worklogs   []Worklog `json:"worklogs"`
}

WorklogList is a paginated list of worklogs.

Jump to

Keyboard shortcuts

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