Help us shape the future of Go! Take the 2026 Go Developer Survey

client

package
v2.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

Package client provides authenticated HTTP transport for the Arcane API.

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 provides authenticated requests, token refresh, and response decoding for the Arcane API.

func New

func New(cfg *types.Config) (*Client, error)

New validates configuration and creates an authenticated client with the configured environment and a ten-minute timeout.

func NewFromConfig

func NewFromConfig() (*Client, error)

NewFromConfig loads persisted configuration and applies invocation overrides before creating a client.

func NewFromConfigUnauthenticated

func NewFromConfigUnauthenticated() (*Client, error)

NewFromConfigUnauthenticated loads config and returns an unauthenticated client.

func NewUnauthenticated

func NewUnauthenticated(cfg *types.Config) (*Client, error)

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

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

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

func (c *Client) DeleteJSON[T any](ctx context.Context, path string) (*base.ApiResponse[T], error)

DeleteJSON performs a DELETE and decodes the standard API envelope, enforcing HTTP and API success.

func (*Client) DeleteWithBody added in v2.6.0

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

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

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

DoRaw performs a request and returns the response payload when status is 2xx.

func (*Client) EnvID

func (c *Client) EnvID() string

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

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

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

func (c *Client) GetJSON[T any](ctx context.Context, path string) (*base.ApiResponse[T], error)

GetJSON performs a GET and decodes the standard API envelope, enforcing HTTP and API success.

func (*Client) Post

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

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

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

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

func (c *Client) SetEnvironment(envID string)

SetEnvironment changes the environment ID for subsequent requests on this client.

func (*Client) SetRetryPolicy

func (c *Client) SetRetryPolicy(maxAttempts int, baseBackoff, maxBackoff time.Duration)

SetRetryPolicy configures retry behavior for idempotent requests.

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration)

SetTimeout changes the timeout for subsequent requests.

func (*Client) TestConnection

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

TestConnection checks the API version endpoint and returns transport or status failures.

Jump to

Keyboard shortcuts

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