Documentation
¶
Overview ¶
Package client provides the core HTTP client for making API requests.
Index ¶
- Constants
- Variables
- func NewTransport(t http.RoundTripper, client InternalClient) *transport
- type Client
- func (c *Client) APIKeyType() string
- func (c *Client) APIURL() string
- func (c *Client) CrashStackDir() string
- func (c *Client) Do(ctx context.Context, method string, endpoint string, pathParams *[]string, ...) ([]byte, error)
- func (c *Client) FQDN() string
- func (Client) IsCortexClient()
- func (c *Client) LogLevel() string
- func (c *Client) Logger() log.Logger
- func (c *Client) MaxRetries() int
- func (c *Client) RetryMaxDelay() time.Duration
- func (c *Client) SkipLoggingTransport() bool
- func (c *Client) SkipSSLVerify() bool
- func (c *Client) Timeout() time.Duration
- func (c *Client) ValidateAPIKey(ctx context.Context) (bool, error)
- type DoOptions
- type InternalClient
Constants ¶
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" )
const (
// Max value for limit in pagination queries.
MaxLimit = 2000
)
Variables ¶
var ( GitCommit = "NOCOMMIT" CortexServerVersion = "UNKNOWN" CortexPAPIVersion = "UNKNOWN" GoVersion = "UNKNOWN" BuildDate = "UNKNOWN" )
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 a Config object.
func NewClientFromConfig ¶
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 (*Client) APIKeyType ¶
APIKeyType returns the Cortex API key type.
func (*Client) CrashStackDir ¶
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) MaxRetries ¶
MaxRetries returns the maximum number of retries.
func (*Client) RetryMaxDelay ¶
RetryMaxDelay returns the maximum retry delay.
func (*Client) SkipLoggingTransport ¶
SkipLoggingTransport returns whether to skip logging transport.
func (*Client) SkipSSLVerify ¶
SkipSSLVerify returns whether to skip TLS certificate verification.
type InternalClient ¶
type InternalClient interface {
LogLevelIsSetTo(string) bool
Log(ctx context.Context, level, msg string)
}
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.