Documentation ¶
Index ¶
- Constants
- Variables
- type ApiErr
- type AuthRequest
- type AuthToken
- type BackoffConfig
- type Client
- type ConfigSetter
- func WithDebug(debug bool) ConfigSetter
- func WithHttpClientPtr(httpClient *http.Client) ConfigSetter
- func WithProxyHost(host string) ConfigSetter
- func WithProxyPassword(pass string) ConfigSetter
- func WithProxyPort(i int32) ConfigSetter
- func WithProxyUsername(username string) ConfigSetter
- func WithRateLimitMaxRetries(maxRetries int32) ConfigSetter
- func WithRateLimitMaxWait(maxWait time.Duration) ConfigSetter
- func WithRateLimitMinWait(minWait time.Duration) ConfigSetter
- func WithRequestTimeout(requestTimeout time.Duration) ConfigSetter
- func WithTestingDisableHttpsCheck(httpsCheck bool) ConfigSetter
- func WithUserAgentExtra(userAgent string) ConfigSetter
- func WithZWAAPIKeyID(keyID string) ConfigSetter
- func WithZWAAPISecret(apiSecret string) ConfigSetter
- func WithZWACloud(cloud string) ConfigSetter
- type Configuration
Constants ¶
View Source
const ( JSessionIDTimeout = 30 // minutes. MaxNumOfRetries = 100 RetryWaitMaxSeconds = 20 RetryWaitMinSeconds = 5 )
View Source
const ( VERSION = "3.0.0" ZWA_API_KEY_ID = "ZWA_API_KEY_ID" ZWA_API_SECRET = "ZWA_API_SECRET" )
Variables ¶
View Source
var (
// ContextAccessToken takes a string OAuth2 access token as authentication for the request.
ContextAccessToken = contextKey("access_token")
)
Functions ¶
This section is empty.
Types ¶
type AuthRequest ¶
type AuthToken ¶
type AuthToken struct { TokenType string `json:"token_type"` AccessToken string `json:"token"` ExpiresIn int `json:"expires_in"` }
func Authenticate ¶
type BackoffConfig ¶
type Client ¶
type Client struct { sync.Mutex Config *Configuration }
func NewClient ¶
func NewClient(config *Configuration) (*Client, error)
type ConfigSetter ¶
type ConfigSetter func(*Configuration)
func WithDebug ¶
func WithDebug(debug bool) ConfigSetter
func WithHttpClientPtr ¶
func WithHttpClientPtr(httpClient *http.Client) ConfigSetter
WithHttpClient sets the HttpClient in the Config.
func WithProxyHost ¶
func WithProxyHost(host string) ConfigSetter
func WithProxyPassword ¶
func WithProxyPassword(pass string) ConfigSetter
func WithProxyPort ¶
func WithProxyPort(i int32) ConfigSetter
func WithProxyUsername ¶
func WithProxyUsername(username string) ConfigSetter
func WithRateLimitMaxRetries ¶
func WithRateLimitMaxRetries(maxRetries int32) ConfigSetter
func WithRateLimitMaxWait ¶
func WithRateLimitMaxWait(maxWait time.Duration) ConfigSetter
func WithRateLimitMinWait ¶
func WithRateLimitMinWait(minWait time.Duration) ConfigSetter
func WithRequestTimeout ¶
func WithRequestTimeout(requestTimeout time.Duration) ConfigSetter
func WithTestingDisableHttpsCheck ¶
func WithTestingDisableHttpsCheck(httpsCheck bool) ConfigSetter
func WithUserAgentExtra ¶
func WithUserAgentExtra(userAgent string) ConfigSetter
WithUserAgent sets the UserAgent in the Config.
func WithZWAAPIKeyID ¶
func WithZWAAPIKeyID(keyID string) ConfigSetter
ConfigSetter type defines a function that modifies a Config struct. WithClientID sets the ClientID in the Config.
func WithZWAAPISecret ¶
func WithZWAAPISecret(apiSecret string) ConfigSetter
WithClientSecret sets the ClientSecret in the Config.
func WithZWACloud ¶
func WithZWACloud(cloud string) ConfigSetter
type Configuration ¶
type Configuration struct { sync.Mutex Logger logger.Logger HTTPClient *http.Client BaseURL *url.URL DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` Debug bool `json:"debug,omitempty"` UserAgentExtra string Context context.Context ZWA struct { Client struct { ZWAAPIKeyID string `yaml:"key_id" envconfig:"ZWA_API_KEY_ID"` ZWAAPISecret string `yaml:"key_secret" envconfig:"ZWA_API_SECRET"` ZWACloud string `yaml:"cloud" envconfig:"ZWA_CLOUD"` AuthToken *AuthToken `yaml:"authToken"` AccessToken *AuthToken `yaml:"accessToken"` Proxy struct { Port int32 `yaml:"port" envconfig:"ZWA_CLIENT_PROXY_PORT"` Host string `yaml:"host" envconfig:"ZWA_CLIENT_PROXY_HOST"` Username string `yaml:"username" envconfig:"ZWA_CLIENT_PROXY_USERNAME"` Password string `yaml:"password" envconfig:"ZWA_CLIENT_PROXY_PASSWORD"` } `yaml:"proxy"` RequestTimeout time.Duration `yaml:"requestTimeout" envconfig:"ZWA_CLIENT_REQUEST_TIMEOUT"` RateLimit struct { MaxRetries int32 `yaml:"maxRetries" envconfig:"ZWA_CLIENT_RATE_LIMIT_MAX_RETRIES"` RetryWaitMin time.Duration `yaml:"minWait" envconfig:"ZWA_CLIENT_RATE_LIMIT_MIN_WAIT"` RetryWaitMax time.Duration `yaml:"maxWait" envconfig:"ZZWA_CLIENT_RATE_LIMIT_MAX_WAIT"` BackoffConf *BackoffConfig } `yaml:"rateLimit"` } `yaml:"client"` Testing struct { DisableHttpsCheck bool `yaml:"disableHttpsCheck" envconfig:"ZWA_TESTING_DISABLE_HTTPS_CHECK"` } `yaml:"testing"` } `yaml:"zwa"` }
func NewConfiguration ¶
func NewConfiguration(conf ...ConfigSetter) (*Configuration, error)
func (*Configuration) AddDefaultHeader ¶
func (c *Configuration) AddDefaultHeader(key string, value string)
AddDefaultHeader adds a new HTTP header to the default header in the request
func (*Configuration) SetBackoffConfig ¶
func (cfg *Configuration) SetBackoffConfig(backoffConf *BackoffConfig)
Click to show internal directories.
Click to hide internal directories.