Documentation
¶
Overview ¶
Package client provides authenticated HTTP transport for the Arcane API.
Index ¶
- type Client
- func (c *Client) Delete(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) DeleteJSON[T any](ctx context.Context, path string) (*base.ApiResponse[T], error)
- func (c *Client) DeleteWithBody(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *Client) DoEnvelope[T any](ctx context.Context, method, path string, body any) (*base.ApiResponse[T], error)
- func (c *Client) DoJSON[T any](ctx context.Context, method, path string, body any, headers ...http.Header) (T, error)
- func (c *Client) DoRaw(ctx context.Context, method, path string, body any) ([]byte, error)
- func (c *Client) EnvID() string
- func (c *Client) Get(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) GetJSON[T any](ctx context.Context, path string) (*base.ApiResponse[T], error)
- func (c *Client) Post(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *Client) PostJSON[T any](ctx context.Context, path string, body any) (*base.ApiResponse[T], error)
- func (c *Client) Put(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *Client) PutJSON[T any](ctx context.Context, path string, body any) (*base.ApiResponse[T], error)
- func (c *Client) Request(ctx context.Context, method, path string, body any, headers ...http.Header) (*http.Response, error)
- func (c *Client) RequestRaw(ctx context.Context, method, path string, body io.Reader, ...) (*http.Response, error)
- func (c *Client) SetEnvironment(envID string)
- func (c *Client) SetRetryPolicy(maxAttempts int, baseBackoff, maxBackoff time.Duration)
- func (c *Client) SetTimeout(timeout time.Duration)
- func (c *Client) TestConnection(ctx context.Context) error
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 provides authenticated requests, token refresh, and response decoding for the Arcane API.
func New ¶
New validates configuration and creates an authenticated client with the configured environment and a ten-minute timeout.
func NewFromConfig ¶
NewFromConfig loads persisted configuration and applies invocation overrides before creating a client.
func NewFromConfigUnauthenticated ¶
NewFromConfigUnauthenticated loads config and returns an unauthenticated client.
func NewUnauthenticated ¶
NewUnauthenticated creates a client that can call unauthenticated endpoints (e.g. /api/auth/login). It only validates that server_url is configured.
func (*Client) Delete ¶
Delete makes a DELETE request to the specified path. It is a convenience wrapper around Request for removing resources.
func (*Client) DeleteJSON ¶ added in v2.10.0
DeleteJSON performs a DELETE and decodes the standard API envelope, enforcing HTTP and API success.
func (*Client) DeleteWithBody ¶ added in v2.6.0
DeleteWithBody sends a DELETE request with a JSON options body.
func (*Client) DoEnvelope ¶ added in v2.16.0
func (c *Client) DoEnvelope[T any](ctx context.Context, method, path string, body any) (*base.ApiResponse[T], error)
DoEnvelope sends a request and decodes the shared envelope, enforcing HTTP and API success.
func (*Client) DoJSON ¶
func (c *Client) DoJSON[T any](ctx context.Context, method, path string, body any, headers ...http.Header) (T, error)
DoJSON enforces HTTP success and decodes a response without requiring the standard API envelope.
func (*Client) DoRaw ¶
DoRaw performs a request and returns the response payload when status is 2xx.
func (*Client) EnvID ¶
EnvID returns the current environment ID configured for this client. The environment ID is used to scope API requests to a specific environment.
func (*Client) Get ¶
Get makes a GET request to the specified path. It is a convenience wrapper around Request for retrieving resources.
func (*Client) GetJSON ¶ added in v2.10.0
GetJSON performs a GET and decodes the standard API envelope, enforcing HTTP and API success.
func (*Client) Post ¶
Post makes a POST request to the specified path with a JSON body. It is a convenience wrapper around Request for creating resources.
func (*Client) PostJSON ¶ added in v2.10.0
func (c *Client) PostJSON[T any](ctx context.Context, path string, body any) (*base.ApiResponse[T], error)
PostJSON performs a POST with a JSON body and decodes the standard API envelope, enforcing HTTP and API success.
func (*Client) Put ¶
Put makes a PUT request to the specified path with a JSON body. It is a convenience wrapper around Request for updating resources.
func (*Client) PutJSON ¶ added in v2.10.0
func (c *Client) PutJSON[T any](ctx context.Context, path string, body any) (*base.ApiResponse[T], error)
PutJSON performs a PUT with a JSON body and decodes the standard API envelope, enforcing HTTP and API success.
func (*Client) Request ¶
func (c *Client) Request(ctx context.Context, method, path string, body any, headers ...http.Header) (*http.Response, error)
Request sends JSON or raw reader bodies with authentication; streaming bodies skip retries and token refresh.
func (*Client) RequestRaw ¶
func (c *Client) RequestRaw(ctx context.Context, method, path string, body io.Reader, headers map[string]string) (*http.Response, error)
RequestRaw sends a streaming body with custom headers, without JSON encoding or automatic replay.
func (*Client) SetEnvironment ¶
SetEnvironment changes the environment ID for subsequent requests on this client.
func (*Client) SetRetryPolicy ¶
SetRetryPolicy configures retry behavior for idempotent requests.
func (*Client) SetTimeout ¶
SetTimeout changes the timeout for subsequent requests.