taiga

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package taiga is an HTTP client for the Taiga REST API v1.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToOutput

func ToOutput(err error) *output.Error

ToOutput maps client errors to the stable error envelope.

Types

type APIError

type APIError struct {
	Status       int
	Method, Path string
	Body         []byte
}

APIError is a non-2xx response from Taiga.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) IsVersionConflict

func (e *APIError) IsVersionConflict() bool

IsVersionConflict reports Taiga's optimistic-concurrency rejection (409, or 400 with a "version" key).

type Client

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

func New

func New(baseURL string, ts TokenSource, opts ...Option) *Client

New builds a client for baseURL (scheme://host, already normalized).

func (*Client) BaseURL

func (c *Client) BaseURL() string

func (*Client) Do

func (c *Client) Do(ctx context.Context, r Request) (*Response, error)

Do sends one API request. GET is retried up to twice on network errors and 5xx.

func (*Client) GetAll

func (c *Client) GetAll(ctx context.Context, path string, q url.Values) ([]json.RawMessage, error)

GetAll returns every item of a list endpoint, asking Taiga to disable pagination and, if it paginates anyway, following the page number announced in X-Pagination-Next.

func (*Client) PrepareVersioned

func (c *Client) PrepareVersioned(ctx context.Context, path string, patch map[string]any) (map[string]any, map[string]json.RawMessage, error)

PrepareVersioned reads the resource and returns the body that would be sent (for --dry-run).

func (*Client) WriteVersioned

func (c *Client) WriteVersioned(ctx context.Context, method, path string, patch map[string]any, force bool) (*Response, error)

WriteVersioned applies patch with optimistic concurrency and one guarded retry.

type ConflictError

type ConflictError struct {
	Method, Path string
	Fields       []string
}

ConflictError means another writer changed the fields we are updating.

func (*ConflictError) Error

func (e *ConflictError) Error() string

type NetworkError

type NetworkError struct {
	Method, Path string
	Err          error
}

NetworkError wraps transport failures.

func (*NetworkError) Error

func (e *NetworkError) Error() string

func (*NetworkError) Unwrap

func (e *NetworkError) Unwrap() error

type Option

type Option func(*Client)

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

func WithRetryWait

func WithRetryWait(d time.Duration) Option

type Request

type Request struct {
	Method string
	Path   string
	Query  url.Values
	Body   any
	Header http.Header
}

type Response

type Response struct {
	Status int
	Header http.Header
	Body   []byte
}

type StaticToken

type StaticToken Token

StaticToken is a fixed token (TAIGA_TOKEN, tests).

func (StaticToken) Token

func (s StaticToken) Token(context.Context) (Token, error)

type Token

type Token struct{ Type, Value string }

type TokenSource

type TokenSource interface {
	Token(ctx context.Context) (Token, error)
}

Jump to

Keyboard shortcuts

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