client

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 22 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// NonceLength defines the length of the cryptographic nonce used in
	// authentication headers.
	NonceLength = 64
	// AuthCharset is the character set used for generating the nonce.
	AuthCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
)
View Source
const (
	// Max value for limit in pagination queries.
	MaxLimit = 2000
)

Variables

View Source
var (
	GitCommit = "NOCOMMIT"
	GoVersion = runtime.Version()
	BuildDate = ""
)

Functions

func NewTransport

func NewTransport(t http.RoundTripper, client InternalClient) *transport

NewTransport creates a wrapper around an http.RoundTripper, designed to be used for the `Transport` field of http.Client.

This logs each pair of HTTP request/response that it handles. The logging is done via the `InternalClient` interface.

Types

type Client

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

Client is the core HTTP client for interacting with the Cortex Cloud API.

This client is intended for internal use by higher-level SDK modules. All configuration is passed during its creation via an api.Config object.

func NewClient

func NewClient(cfg *api.Config) (*Client, error)

NewClient creates and initializes a new core HTTP client. It takes a pointer to an api.Config, which should be fully configured by the user-facing API module.

func (*Client) Do

func (c *Client) Do(ctx context.Context, method string, endpoint string, pathParams *[]string, queryParams *url.Values, input, output any, opts *DoOptions) ([]byte, error)

Do performs the given API request.

This is the core method for making authenticated calls to the Cortex Cloud API. It returns the raw response body and a structured SDK error if any error occurs (network, HTTP status, or unmarshaling).

type DoOptions

type DoOptions struct {
	RequestWrapperKey  string
	ResponseWrapperKey string
}

type InternalClient

type InternalClient interface {
	LogLevelIsSetTo(string) bool
	Log(ctx context.Context, level, msg string)
	PreRequestValidationEnabled() bool
}

InternalClient is an interface that the transport layer uses to interact with the core client's logging and validation settings. This interface allows for a clean separation of concerns and avoids direct dependency on the concrete Client struct, promoting testability.

Jump to

Keyboard shortcuts

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