client

package
v1.1.26 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEndpoint = "https://api.threatwinds.com"

DefaultEndpoint is the default ThreatWinds API base URL.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int    `json:"status_code"`
	Method     string `json:"-"`
	Path       string `json:"-"`
	Message    string `json:"message"`
	ErrorID    string `json:"error_id"`
	Body       []byte `json:"-"`
	// contains filtered or unexported fields
}

APIError is returned when an API call results in a 4xx or 5xx response. It implements the error interface.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) IsForbidden

func (e *APIError) IsForbidden() bool

func (*APIError) IsNotFound

func (e *APIError) IsNotFound() bool

func (*APIError) IsRateLimited

func (e *APIError) IsRateLimited() bool

func (*APIError) IsUnauthorized

func (e *APIError) IsUnauthorized() bool

func (*APIError) IsValidationError

func (e *APIError) IsValidationError() bool

func (*APIError) RetryAfter

func (e *APIError) RetryAfter() string

RetryAfter returns the Retry-After header value stored on the error, used by the retry logic to determine backoff duration.

type Client

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

Client is the root entry point for the ThreatWinds API SDK.

func New

func New(opts ...Option) (*Client, error)

New creates a configured API client. At least one authentication option (WithAPIKey or WithBearer) must be provided, but not both.

func (*Client) Auth

func (c *Client) Auth() *auth.Client

Auth returns the Auth service client (lazy-initialized).

func (*Client) Billing

func (c *Client) Billing() *billing.Client

Billing returns the Billing service client (lazy-initialized).

func (*Client) Close

func (c *Client) Close()

Close releases idle HTTP connections held by the SDK's internal transport. It is a no-op when the caller supplied their own http.Client via WithHTTPClient. Callers should invoke Close() when they are done with the client to avoid leaking TCP connections in long-running processes.

func (*Client) Compute

func (c *Client) Compute() *compute.Client

Compute returns the Compute service client (lazy-initialized).

type ListOptions

type ListOptions struct {
	Limit int // 0 = server default
	Page  int // 0 = server default
}

ListOptions holds pagination parameters for list endpoints.

type Option

type Option func(*clientConfig)

Option configures a Client via the functional options pattern.

func WithAPIKey

func WithAPIKey(keyID, secret string) Option

WithAPIKey sets API key authentication (key ID + secret).

func WithBearer

func WithBearer(token string) Option

WithBearer sets bearer token authentication.

func WithEndpoint

func WithEndpoint(url string) Option

WithEndpoint sets the API base URL.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient sets a custom HTTP client.

func WithMaxRetries

func WithMaxRetries(n int) Option

WithMaxRetries sets the maximum number of retry attempts.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the HTTP request timeout.

type SDKError

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

SDKError is returned by New() for configuration errors (not HTTP errors).

func (*SDKError) Error

func (e *SDKError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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