linearapi

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultEndpoint is the default Linear API GraphQL endpoint.
	DefaultEndpoint = "https://api.linear.app/graphql"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for interacting with the Linear GraphQL API.

func NewClient

func NewClient(cfg ClientConfig) *Client

NewClient creates a new Linear API client with the provided configuration.

func NewClientWithToken

func NewClientWithToken(token string) *Client

NewClientWithToken creates a new Linear API client with just a token (convenience method).

func (*Client) ArchiveIssue

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

ArchiveIssue archives an issue.

func (*Client) CreateComment

func (c *Client) CreateComment(ctx context.Context, input CreateCommentInput) (Comment, error)

CreateComment creates a new comment on an issue.

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, input CreateIssueInput) (Issue, error)

CreateIssue creates a new issue.

func (*Client) Endpoint

func (c *Client) Endpoint() string

Endpoint returns the GraphQL endpoint being used.

func (*Client) FetchIssueByID

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

FetchIssueByID fetches a single issue by its ID.

func (*Client) FetchIssues

func (c *Client) FetchIssues(ctx context.Context, params FetchIssuesParams) ([]Issue, error)

FetchIssues fetches issues with optional filtering and sorting.

func (*Client) GetCurrentUser

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

GetCurrentUser fetches the current authenticated user.

func (*Client) ListIssueLabels

func (c *Client) ListIssueLabels(ctx context.Context, teamID string) ([]IssueLabel, error)

ListIssueLabels fetches both workspace and team labels, merges them, and returns a sorted list. Labels are de-duplicated by ID, with team labels taking precedence.

func (*Client) ListProjects

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

ListProjects fetches all projects for a team.

func (*Client) ListTeamLabels

func (c *Client) ListTeamLabels(ctx context.Context, teamID string) ([]IssueLabel, error)

ListTeamLabels fetches labels scoped to a specific team.

func (*Client) ListTeams

func (c *Client) ListTeams(ctx context.Context) ([]Team, error)

ListTeams fetches all teams the user has access to.

func (*Client) ListUsers

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

ListUsers fetches all users in a team.

func (*Client) ListWorkflowStates

func (c *Client) ListWorkflowStates(ctx context.Context, teamID string) ([]WorkflowState, error)

ListWorkflowStates fetches all workflow states for a team.

func (*Client) ListWorkspaceLabels

func (c *Client) ListWorkspaceLabels(ctx context.Context) ([]IssueLabel, error)

ListWorkspaceLabels fetches all workspace-level labels (not scoped to a team).

func (*Client) UnarchiveIssue

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

UnarchiveIssue unarchives an issue.

func (*Client) UpdateIssue

func (c *Client) UpdateIssue(ctx context.Context, input UpdateIssueInput) (Issue, error)

UpdateIssue updates an existing issue.

type ClientConfig

type ClientConfig struct {
	// Token is the Linear API key for authentication.
	Token string
	// Endpoint is the GraphQL API endpoint (defaults to Linear's production endpoint).
	Endpoint string
	// HTTPClient is an optional custom HTTP client (useful for testing).
	HTTPClient *http.Client
	// Timeout is the HTTP request timeout (defaults to 30s).
	Timeout time.Duration
}

ClientConfig contains configuration for creating a new Linear API client.

type Comment

type Comment struct {
	ID        string
	Body      string
	CreatedAt time.Time
	UpdatedAt time.Time
	Author    User
	IssueID   string
}

Comment represents a comment on a Linear issue.

type CommentCreateInput added in v0.2.0

type CommentCreateInput map[string]interface{}

CommentCreateInput is a custom scalar type for Linear's CommentCreateInput. The Go type name must match the GraphQL type name exactly.

func (CommentCreateInput) GetGraphQLType added in v0.2.0

func (CommentCreateInput) GetGraphQLType() string

GetGraphQLType returns the GraphQL type name for the input.

func (CommentCreateInput) MarshalJSON added in v0.2.0

func (c CommentCreateInput) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for CommentCreateInput.

type CreateCommentInput

type CreateCommentInput struct {
	IssueID string
	Body    string
}

CreateCommentInput contains input for creating a new comment.

type CreateIssueInput

type CreateIssueInput struct {
	TeamID      string
	Title       string
	Description string
	ProjectID   string
	StateID     string
	AssigneeID  string
	Priority    int
	ParentID    string // Parent issue ID (empty for top-level issues)
}

CreateIssueInput contains input for creating a new issue.

type FetchIssuesParams

type FetchIssuesParams struct {
	TeamID    string
	ProjectID string
	Search    string
	// OrderBy specifies the sort order. Valid API values are "updatedAt" and "createdAt".
	// "priority" is also supported and will be sorted client-side after fetching.
	OrderBy string
	First   int
}

FetchIssuesParams contains parameters for fetching issues.

type Issue

type Issue struct {
	ID          string
	Identifier  string
	Title       string
	Description string
	State       string
	StateID     string
	Assignee    string
	AssigneeID  string
	Priority    int
	UpdatedAt   time.Time
	CreatedAt   time.Time
	TeamID      string
	ProjectID   string
	URL         string
	Archived    bool
	Labels      []IssueLabel
	Parent      *IssueRef       // Parent issue reference (nil if top-level)
	Children    []IssueChildRef // Child/sub-issue references
	Comments    []Comment       // Comments on this issue
}

Issue represents a Linear issue.

type IssueChildRef

type IssueChildRef struct {
	ID         string
	Identifier string
	Title      string
	State      string
	StateID    string
}

IssueChildRef represents a lightweight reference to a child issue.

type IssueCreateInput

type IssueCreateInput map[string]interface{}

IssueCreateInput is a custom scalar type for Linear's IssueCreateInput. The Go type name must match the GraphQL type name exactly.

func (IssueCreateInput) GetGraphQLType

func (IssueCreateInput) GetGraphQLType() string

GetGraphQLType returns the GraphQL type name for the input.

func (IssueCreateInput) MarshalJSON

func (i IssueCreateInput) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for IssueCreateInput.

type IssueFilter

type IssueFilter map[string]interface{}

IssueFilter is a custom scalar type for Linear's IssueFilter input. It allows passing complex filter objects to the GraphQL API.

func (IssueFilter) GetGraphQLType

func (IssueFilter) GetGraphQLType() string

GetGraphQLType returns the GraphQL type name for the filter.

func (IssueFilter) MarshalJSON

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

MarshalJSON implements json.Marshaler for IssueFilter.

type IssueLabel

type IssueLabel struct {
	ID    string
	Name  string
	Color string // Hex color code (e.g., "#ff0000")
}

IssueLabel represents a label that can be applied to issues.

type IssueRef

type IssueRef struct {
	ID         string
	Identifier string
	Title      string
}

IssueRef represents a lightweight reference to an issue (for parent relationships).

type IssueUpdateInput

type IssueUpdateInput map[string]interface{}

IssueUpdateInput is a custom scalar type for Linear's IssueUpdateInput. The Go type name must match the GraphQL type name exactly.

func (IssueUpdateInput) GetGraphQLType

func (IssueUpdateInput) GetGraphQLType() string

GetGraphQLType returns the GraphQL type name for the input.

func (IssueUpdateInput) MarshalJSON

func (i IssueUpdateInput) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for IssueUpdateInput.

type PaginationOrderBy

type PaginationOrderBy string

PaginationOrderBy is a custom type for Linear's PaginationOrderBy enum. Valid values are "createdAt" and "updatedAt".

const (
	OrderByCreatedAt PaginationOrderBy = "createdAt"
	OrderByUpdatedAt PaginationOrderBy = "updatedAt"
)

Common PaginationOrderBy values.

func (PaginationOrderBy) GetGraphQLType

func (PaginationOrderBy) GetGraphQLType() string

GetGraphQLType returns the GraphQL type name for the enum.

type Project

type Project struct {
	ID     string
	Name   string
	TeamID string
}

Project represents a Linear project.

type Team

type Team struct {
	ID   string
	Key  string
	Name string
}

Team represents a Linear team.

type UpdateIssueInput

type UpdateIssueInput struct {
	ID          string
	Title       *string
	Description *string
	StateID     *string
	AssigneeID  *string
	Priority    *int
	LabelIDs    *[]string // nil = no change, empty slice = clear all, non-empty = set labels
	ParentID    *string   // nil = no change, empty string = clear parent, non-empty = set parent
}

UpdateIssueInput contains input for updating an issue.

type User

type User struct {
	ID          string
	Name        string
	DisplayName string
	Email       string
	IsMe        bool
}

User represents a Linear user.

type WorkflowState

type WorkflowState struct {
	ID       string
	Name     string
	Type     string // backlog, unstarted, started, completed, canceled
	Position float64
	TeamID   string
}

WorkflowState represents a workflow state in a Linear team.

Jump to

Keyboard shortcuts

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