client

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package client provides the core HTTP client for making API requests.

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"
	// ValidateAPIKeyEndpoint is the path for the API key validation
	// endpoint.
	ValidateAPIKeyEndpoint = "api_keys/validate"
)
View Source
const (
	// Max value for limit in pagination queries.
	MaxLimit = 2000
)

Variables

View Source
var (
	GitCommit           = "NOCOMMIT"
	CortexServerVersion = "UNKNOWN"
	CortexPAPIVersion   = "UNKNOWN"
	GoVersion           = "UNKNOWN"
	BuildDate           = "UNKNOWN"
)

Functions

func GetOrGenerateRequestID added in v1.0.4

func GetOrGenerateRequestID(ctx context.Context) (context.Context, string)

GetOrGenerateRequestID retrieves existing request ID or generates new one

func GetRequestID added in v1.0.4

func GetRequestID(ctx context.Context) string

GetRequestID retrieves the request ID from context Returns empty string if not found

func NewTransport

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

NewTransport wraps t with debug-level request/response logging via client.

func WithRequestID added in v1.0.4

func WithRequestID(ctx context.Context, requestID string) context.Context

WithRequestID adds a request ID to the context

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 a Config object.

func NewClientFromConfig

func NewClientFromConfig(cfg *config.Config) (*Client, error)

NewClientFromConfig creates and initializes a new core HTTP client from a config object. It takes a pointer to a Config, which should be fully configured.

func NewTestClient added in v1.0.4

func NewTestClient(t *testing.T) *Client

func (*Client) APIKeyID added in v1.0.4

func (c *Client) APIKeyID() int

APIKeyID returns the Cortex API key ID.

func (*Client) APIKeyType

func (c *Client) APIKeyType() string

APIKeyType returns the Cortex API key type.

func (*Client) APIURL

func (c *Client) APIURL() string

APIURL returns the API URL for the Cortex.

func (*Client) CrashStackDir

func (c *Client) CrashStackDir() string

CrashStackDir returns the crash stack directory.

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 HTTP calls to the Cortex Cloud API. It returns the raw response body and a structured SDK error if any error occurs.

func (Client) IsCortexClient

func (Client) IsCortexClient()

Marker method for CortexClient interface compliance.

func (*Client) LogLevel

func (c *Client) LogLevel() string

LogLevel returns the log level.

func (*Client) Logger

func (c *Client) Logger() log.Logger

Logger returns the logger.

func (*Client) MaxRetries

func (c *Client) MaxRetries() int

MaxRetries returns the maximum number of retries.

func (*Client) RetryMaxDelay

func (c *Client) RetryMaxDelay() time.Duration

RetryMaxDelay returns the maximum retry delay.

func (*Client) SkipLoggingTransport

func (c *Client) SkipLoggingTransport() bool

SkipLoggingTransport returns whether to skip logging transport.

func (*Client) SkipSSLVerify

func (c *Client) SkipSSLVerify() bool

SkipSSLVerify returns whether to skip TLS certificate verification.

func (*Client) Timeout

func (c *Client) Timeout() time.Duration

Timeout returns the HTTP timeout.

func (*Client) ValidateAPIKey

func (c *Client) ValidateAPIKey(ctx context.Context) (bool, error)

ValidateAPIKey validates the configured API Key against the target Cortex tenant.

type DoOptions

type DoOptions struct {
	RequestWrapperKeys  []string
	ResponseWrapperKeys []string
}

type InternalClient

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

InternalClient abstracts the core client's logging and log-level settings.

Jump to

Keyboard shortcuts

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