client

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMissingCredentials   = "missing required credentials"
	ErrInvalidHost          = "invalid host configuration"
	ErrInvalidEndpoint      = "invalid endpoint configuration"
	ErrRateLimitExceeded    = "rate limit exceeded"
	ErrUnauthorized         = "unauthorized access"
	ErrForbidden            = "forbidden access"
	ErrNotFound             = "resource not found"
	ErrInternalServer       = "internal server error"
	ErrBadRequest           = "bad request"
	ErrTimeout              = "request timeout"
	ErrConnectionFailed     = "connection failed"
	ErrInvalidResponse      = "invalid response format"
	ErrMissingRequiredField = "missing required field"
	ErrInvalidFieldValue    = "invalid field value"
	ErrSandboxLimitation    = "sandbox environment limitation"
)

Common error messages

Variables

This section is empty.

Functions

func LoadEnvironmentVariables added in v1.2.0

func LoadEnvironmentVariables() error

LoadEnvironmentVariables loads environment variables from .env files It tries multiple possible paths for the .env file

func ParseAPIError added in v1.2.0

func ParseAPIError(statusCode int, body string, headers http.Header) error

ParseAPIError parses an API error from response

Types

type APIClient

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

APIClient represents the base API client

func NewAPIClient

func NewAPIClient(config *Configuration) *APIClient

NewAPIClient creates a new API client

func (*APIClient) BuildQueryString

func (c *APIClient) BuildQueryString(params map[string]interface{}) string

BuildQueryString builds a query string from parameters

func (*APIClient) CallAPI

func (c *APIClient) CallAPI(ctx context.Context, method, path string, body interface{}, headers map[string]string) (*http.Response, error)

CallAPI makes an API call

func (*APIClient) CallAPIWithArrayQueryParams

func (c *APIClient) CallAPIWithArrayQueryParams(ctx context.Context, method, path string, body interface{}, headers map[string]string, queryParams map[string][]string) (*http.Response, error)

CallAPIWithArrayQueryParams makes an API call with array query parameters

func (*APIClient) CallAPIWithQueryParams

func (c *APIClient) CallAPIWithQueryParams(ctx context.Context, method, path string, body interface{}, headers map[string]string, queryParams map[string]string) (*http.Response, error)

CallAPIWithQueryParams makes an API call with query parameters

func (*APIClient) GetConfig

func (c *APIClient) GetConfig() *Configuration

GetConfig returns the configuration

func (*APIClient) ProcessResponse

func (c *APIClient) ProcessResponse(resp *http.Response, target interface{}) error

ProcessResponse processes the API response

func (*APIClient) SetConfig

func (c *APIClient) SetConfig(config *Configuration)

SetConfig sets the configuration

type APIError

type APIError struct {
	StatusCode int
	Message    string
	Body       string
	Headers    http.Header
	RequestID  string
}

APIError represents an API error

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface

func (*APIError) IsRetryable added in v1.2.0

func (e *APIError) IsRetryable() bool

IsRetryable returns true if the error is retryable

type AuthenticationError

type AuthenticationError struct {
	Message   string
	RequestID string
}

AuthenticationError represents an authentication error

func (*AuthenticationError) Error

func (e *AuthenticationError) Error() string

Error implements the error interface

type Configuration

type Configuration struct {
	Host                   string
	UserAgent              string
	Debug                  bool
	DebugFile              string
	TempFolderPath         string
	LwaAuthSigner          *auth.LWAAuthorizationSigner
	HTTPClient             *http.Client
	BooleanFormatForQuery  string
	RateLimiterEnabled     bool
	RateLimitConfiguration map[string]interface{}
}

Configuration represents the SDK configuration

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration creates a new configuration

func NewConfigurationFromEnvironment added in v1.2.0

func NewConfigurationFromEnvironment() (*Configuration, error)

NewConfigurationFromEnvironment creates a new configuration by loading environment variables and creating credentials from them

func NewConfigurationFromMap

func NewConfigurationFromMap(configMap map[string]interface{}) (*Configuration, error)

NewConfigurationFromMap creates a new configuration from a map

func NewConfigurationWithCredentials

func NewConfigurationWithCredentials(credentials *auth.LWAAuthorizationCredentials) *Configuration

NewConfigurationWithCredentials creates a new configuration with LWA credentials

func NewConfigurationWithCredentialsAndCache

func NewConfigurationWithCredentialsAndCache(credentials *auth.LWAAuthorizationCredentials, cache auth.LWAAccessTokenCache) *Configuration

NewConfigurationWithCredentialsAndCache creates a new configuration with LWA credentials and cache

func (*Configuration) DisableCache

func (c *Configuration) DisableCache()

DisableCache disables token caching

func (*Configuration) EnableCache

func (c *Configuration) EnableCache(cache auth.LWAAccessTokenCache)

EnableCache enables token caching

func (*Configuration) GetBooleanFormatForQuery

func (c *Configuration) GetBooleanFormatForQuery() string

GetBooleanFormatForQuery returns the boolean format for query strings

func (*Configuration) GetHTTPClient

func (c *Configuration) GetHTTPClient() *http.Client

GetHTTPClient returns the HTTP client

func (*Configuration) GetHost

func (c *Configuration) GetHost() string

GetHost returns the API host

func (*Configuration) GetUserAgent

func (c *Configuration) GetUserAgent() string

GetUserAgent returns the user agent

func (*Configuration) IsDebug

func (c *Configuration) IsDebug() bool

IsDebug returns debug mode status

func (*Configuration) IsRateLimiterEnabled

func (c *Configuration) IsRateLimiterEnabled() bool

IsRateLimiterEnabled returns whether rate limiter is enabled

func (*Configuration) SetBooleanFormatForQuery

func (c *Configuration) SetBooleanFormatForQuery(format string)

SetBooleanFormatForQuery sets the boolean format for query strings

func (*Configuration) SetDebug

func (c *Configuration) SetDebug(debug bool)

SetDebug sets debug mode

func (*Configuration) SetHTTPClient

func (c *Configuration) SetHTTPClient(client *http.Client)

SetHTTPClient sets the HTTP client

func (*Configuration) SetHost

func (c *Configuration) SetHost(host string)

SetHost sets the API host

func (*Configuration) SetHostByRegion

func (c *Configuration) SetHostByRegion(region string)

SetHostByRegion sets the host based on region

func (*Configuration) SetRateLimiterEnabled

func (c *Configuration) SetRateLimiterEnabled(enabled bool)

SetRateLimiterEnabled sets whether rate limiter is enabled

func (*Configuration) SetUserAgent

func (c *Configuration) SetUserAgent(userAgent string)

SetUserAgent sets the user agent

func (*Configuration) SignRequest

func (c *Configuration) SignRequest(req *http.Request) error

SignRequest signs a request with LWA authorization

type ConfigurationError

type ConfigurationError struct {
	Message string
	Field   string
}

ConfigurationError represents a configuration error

func (*ConfigurationError) Error

func (e *ConfigurationError) Error() string

Error implements the error interface

type NetworkError added in v1.2.0

type NetworkError struct {
	Message string
	Cause   error
}

NetworkError represents a network-related error

func (*NetworkError) Error added in v1.2.0

func (e *NetworkError) Error() string

Error implements the error interface

func (*NetworkError) Unwrap added in v1.2.0

func (e *NetworkError) Unwrap() error

Unwrap returns the underlying error

type RateLimitExceededError

type RateLimitExceededError struct {
	Message    string
	RetryAfter int
	RequestID  string
}

RateLimitExceededError represents a rate limit exceeded error

func (*RateLimitExceededError) Error

func (e *RateLimitExceededError) Error() string

Error implements the error interface

type ValidationError added in v1.2.0

type ValidationError struct {
	Message      string
	Field        string
	Value        interface{}
	RequestID    string
	IsSandboxEnv bool
	Suggestions  []string
}

ValidationError represents a validation error

func (*ValidationError) Error added in v1.2.0

func (e *ValidationError) Error() string

Error implements the error interface

func (*ValidationError) IsSandboxError added in v1.2.0

func (e *ValidationError) IsSandboxError() bool

IsSandboxError returns true if this is likely a sandbox environment error

Jump to

Keyboard shortcuts

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