client

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout bounds a whole request including retries.

Variables

This section is empty.

Functions

func Redact

func Redact(m map[string]any) map[string]any

Redact returns a copy of m with every value not on the allowlist replaced.

Types

type APIError

type APIError struct {
	Status  int
	Method  string
	Path    string
	Message string
	Code    string
	Details map[string]any
	Raw     []byte
}

func NewAPIError

func NewAPIError(status int, body []byte, method, path string) *APIError

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) ExitCode

func (e *APIError) ExitCode() int

type Client

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

func New

func New(o Options) *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, query url.Values, body any) ([]byte, error)

Returns the raw body alongside any *APIError so JSON callers can still emit the error envelope. Pass a literal nil for body, not a typed nil pointer.

type Options

type Options struct {
	BaseURL string
	APIKey  string
	Version string
	Debug   bool
	// Zero means DefaultTimeout. Without it a stalled connection can hang forever.
	Timeout time.Duration
	// DebugOut receives --debug dumps. Never stdout: data goes to stdout so that
	// `--output json > file` stays clean.
	DebugOut io.Writer
}

Jump to

Keyboard shortcuts

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