api

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the Taufinity API client with retry/backoff and auth support.

func New

func New(baseURL string) *Client

New creates a new API client for the given base URL.

func (*Client) DeleteWithAuth

func (c *Client) DeleteWithAuth(ctx context.Context, path string) (*Response, error)

DeleteWithAuth performs an authenticated DELETE request.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) (*Response, error)

Get performs a GET request (always executed, even in dry-run).

func (*Client) GetWithAuth

func (c *Client) GetWithAuth(ctx context.Context, path string) (*Response, error)

GetWithAuth performs an authenticated GET request.

func (*Client) PostJSON

func (c *Client) PostJSON(ctx context.Context, path string, body any) (*Response, error)

PostJSON performs a POST request with JSON body.

func (*Client) PostJSONWithAuth

func (c *Client) PostJSONWithAuth(ctx context.Context, path string, body any) (*Response, error)

PostJSONWithAuth performs an authenticated POST request with JSON body.

func (*Client) PostMultipart

func (c *Client) PostMultipart(ctx context.Context, path string, body io.Reader, contentType string) (*Response, error)

PostMultipart performs an authenticated POST request with multipart form data.

func (*Client) SetAuth

func (c *Client) SetAuth(token string)

SetAuth sets an explicit auth token (overrides saved credentials).

func (*Client) SetDebug

func (c *Client) SetDebug(enabled bool)

SetDebug enables or disables debug request logging via a structured slog logger. When enabled, all HTTP requests and non-2xx responses are logged to stderr at Debug level.

func (*Client) SetDryRun

func (c *Client) SetDryRun(enabled bool)

SetDryRun enables or disables dry-run mode. In dry-run mode, non-GET requests are logged but not executed.

func (*Client) SetDryRunOutput

func (c *Client) SetDryRunOutput(w io.Writer)

SetDryRunOutput sets the writer for dry-run output.

func (*Client) SetOrg

func (c *Client) SetOrg(orgID string)

SetOrg sets the organization ID to include in requests.

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, path, filePath string) (*Response, error)

UploadFile performs a multipart file upload.

func (*Client) ValidateAuth

func (c *Client) ValidateAuth(ctx context.Context) error

ValidateAuth checks if authentication is valid, refreshing if needed. Call this before starting work to fail fast on auth issues.

type Response

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

Response wraps the HTTP response.

func (*Response) DecodeJSON

func (r *Response) DecodeJSON(v any) error

DecodeJSON decodes the response body as JSON.

func (*Response) Error

func (r *Response) Error() error

Error returns an error if the response is not successful.

func (*Response) IsSuccess

func (r *Response) IsSuccess() bool

IsSuccess returns true if the status code is 2xx.

Jump to

Keyboard shortcuts

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