Documentation
¶
Overview ¶
Package taiga is an HTTP client for the Taiga REST API v1.
Index ¶
- func ToOutput(err error) *output.Error
- type APIError
- type Client
- func (c *Client) BaseURL() string
- func (c *Client) Do(ctx context.Context, r Request) (*Response, error)
- func (c *Client) GetAll(ctx context.Context, path string, q url.Values) ([]json.RawMessage, error)
- func (c *Client) PrepareVersioned(ctx context.Context, path string, patch map[string]any) (map[string]any, map[string]json.RawMessage, error)
- func (c *Client) WriteVersioned(ctx context.Context, method, path string, patch map[string]any, force bool) (*Response, error)
- func (c *Client) WriteVersionedFrom(ctx context.Context, method, path string, patch map[string]any, ...) (*Response, error)
- type ConflictError
- type NetworkError
- type Option
- type Request
- type Response
- type StaticToken
- type Token
- type TokenSource
- type UnreadableBodyError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIError ¶
APIError is a non-2xx response from Taiga.
func (*APIError) IsVersionConflict ¶
IsVersionConflict reports Taiga's optimistic-concurrency rejection: 409 or 412 (precondition failed), or 400 with a "version" key, which is what Taiga 6.7 answers in practice.
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) Do ¶
Do sends one API request. GET is retried up to twice on network errors and 5xx. A write whose 2xx answer cannot be read fails with *UnreadableBodyError, never with a network error.
func (*Client) GetAll ¶
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.
func (*Client) WriteVersionedFrom ¶ added in v0.2.0
func (c *Client) WriteVersionedFrom(ctx context.Context, method, path string, patch map[string]any, first map[string]json.RawMessage, force bool) (*Response, error)
WriteVersionedFrom writes patch with the version of first, the snapshot the caller used to compute it. On a version conflict it re-reads once and retries only when none of the patched fields changed since first (or force is set), so a merge is never applied over newer data.
type ConflictError ¶
ConflictError means another writer changed the fields we are updating.
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
type NetworkError ¶
NetworkError wraps transport failures.
func (*NetworkError) Error ¶
func (e *NetworkError) Error() string
func (*NetworkError) Unwrap ¶
func (e *NetworkError) Unwrap() error
type UnreadableBodyError ¶ added in v0.2.0
UnreadableBodyError is a write (POST, PATCH, PUT) that Taiga confirmed with a 2xx status whose body could not be read: the change is applied, so it must never look like a network error that is safe to repeat. The client never retries it.
func (*UnreadableBodyError) Error ¶ added in v0.2.0
func (e *UnreadableBodyError) Error() string
func (*UnreadableBodyError) Unwrap ¶ added in v0.2.0
func (e *UnreadableBodyError) Unwrap() error