client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 11 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"
)

Common error messages

Variables

This section is empty.

Functions

This section is empty.

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
}

APIError represents an API error

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface

type AuthenticationError

type AuthenticationError struct {
	Message 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 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
}

ConfigurationError represents a configuration error

func (*ConfigurationError) Error

func (e *ConfigurationError) Error() string

Error implements the error interface

type RateLimitExceededError

type RateLimitExceededError struct {
	Message    string
	RetryAfter int
}

RateLimitExceededError represents a rate limit exceeded error

func (*RateLimitExceededError) Error

func (e *RateLimitExceededError) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

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