Documentation
¶
Index ¶
- Constants
- Variables
- type ApiErr
- type Client
- func (c *Client) BulkDelete(ctx context.Context, endpoint string, payload interface{}) (*http.Response, error)
- func (c *Client) Create(ctx context.Context, endpoint string, o interface{}) (interface{}, error)
- func (c *Client) CreateWithRawPayload(ctx context.Context, endpoint string, payload string) ([]byte, error)
- func (c *Client) CreateWithSlicePayload(ctx context.Context, endpoint string, slice interface{}) ([]byte, error)
- func (c *Client) Delete(ctx context.Context, endpoint string) error
- func (c *Client) GenericRequest(ctx context.Context, baseUrl, endpoint, method string, body io.Reader, ...) ([]byte, error)
- func (c *Client) GetContentType() string
- func (c *Client) Logout(ctx context.Context) error
- func (c *Client) Read(ctx context.Context, endpoint string, o interface{}) error
- func (c *Client) Request(ctx context.Context, endpoint, method string, data []byte, contentType string) ([]byte, error)
- func (c *Client) Update(ctx context.Context, endpoint string, o interface{}) (interface{}, error)
- func (c *Client) UpdateWithPut(ctx context.Context, endpoint string, o interface{}) (interface{}, error)
- func (c *Client) UpdateWithSlicePayload(ctx context.Context, endpoint string, slice interface{}) ([]byte, error)
- func (c *Client) WithCacheCleanWindow(i time.Duration)
- func (c *Client) WithCacheTtl(i time.Duration)
- func (client *Client) WithFreshCache()
- type ConfigSetter
- func WithCache(cache bool) ConfigSetter
- func WithCacheManager(cacheManager cache.Cache) ConfigSetter
- func WithCacheMaxSizeMB(size int64) ConfigSetter
- func WithCacheTti(i time.Duration) ConfigSetter
- func WithCacheTtl(i time.Duration) 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 WithZconAPIKey(apiKey string) ConfigSetter
- func WithZconCloud(cloud string) ConfigSetter
- func WithZconPassword(password string) ConfigSetter
- func WithZconUsername(username string) ConfigSetter
- type Configuration
- type Credentials
- type Session
Constants ¶
const ( JSessionIDTimeout = 30 // minutes. MaxNumOfRetries = 100 RetryWaitMaxSeconds = 20 RetryWaitMinSeconds = 5 )
const ( VERSION = "3.0.0" ZCON_USERNAME = "ZCON_USERNAME" ZCON_PASSWORD = "ZCON_PASSWORD" ZCON_API_KEY = "ZCON_API_KEY" ZCON_CLOUD = "ZCON_CLOUD" )
Variables ¶
var (
// ContextAccessToken takes a string OAuth2 access token as authentication for the request.
ContextAccessToken = contextKey("access_token")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { sync.Mutex URL string HTTPClient *http.Client Logger logger.Logger UserAgent string // contains filtered or unexported fields }
func NewClient ¶
func NewClient(config *Configuration) (*Client, error)
func (*Client) BulkDelete ¶ added in v3.0.11
func (c *Client) BulkDelete(ctx context.Context, endpoint string, payload interface{}) (*http.Response, error)
BulkDelete sends an HTTP POST request for bulk deletion and expects a 204 No Content response.
func (*Client) CreateWithRawPayload ¶ added in v3.0.11
func (c *Client) CreateWithRawPayload(ctx context.Context, endpoint string, payload string) ([]byte, error)
CreateWithRawPayload sends an HTTP POST request with a raw string payload.
func (*Client) CreateWithSlicePayload ¶ added in v3.0.11
func (*Client) GenericRequest ¶ added in v3.0.11
func (c *Client) GenericRequest(ctx context.Context, baseUrl, endpoint, method string, body io.Reader, urlParams url.Values, contentType string) ([]byte, error)
Request ... // Needs to review this function.
func (*Client) GetContentType ¶
func (*Client) Request ¶
func (c *Client) Request(ctx context.Context, endpoint, method string, data []byte, contentType string) ([]byte, error)
Request ... // Needs to review this function.
func (*Client) UpdateWithPut ¶
func (c *Client) UpdateWithPut(ctx context.Context, endpoint string, o interface{}) (interface{}, error)
Update ...
func (*Client) UpdateWithSlicePayload ¶ added in v3.0.11
func (*Client) WithCacheCleanWindow ¶
func (*Client) WithCacheTtl ¶
func (*Client) WithFreshCache ¶
func (client *Client) WithFreshCache()
type ConfigSetter ¶ added in v3.0.11
type ConfigSetter func(*Configuration)
func WithCache ¶ added in v3.0.11
func WithCache(cache bool) ConfigSetter
func WithCacheManager ¶ added in v3.0.11
func WithCacheManager(cacheManager cache.Cache) ConfigSetter
func WithCacheMaxSizeMB ¶ added in v3.0.11
func WithCacheMaxSizeMB(size int64) ConfigSetter
func WithCacheTti ¶ added in v3.0.11
func WithCacheTti(i time.Duration) ConfigSetter
func WithCacheTtl ¶ added in v3.0.11
func WithCacheTtl(i time.Duration) ConfigSetter
func WithDebug ¶ added in v3.0.11
func WithDebug(debug bool) ConfigSetter
func WithHttpClientPtr ¶ added in v3.0.11
func WithHttpClientPtr(httpClient *http.Client) ConfigSetter
WithHttpClient sets the HttpClient in the Config.
func WithProxyHost ¶ added in v3.0.11
func WithProxyHost(host string) ConfigSetter
func WithProxyPassword ¶ added in v3.0.11
func WithProxyPassword(pass string) ConfigSetter
func WithProxyPort ¶ added in v3.0.11
func WithProxyPort(i int32) ConfigSetter
func WithProxyUsername ¶ added in v3.0.11
func WithProxyUsername(username string) ConfigSetter
func WithRateLimitMaxRetries ¶ added in v3.0.11
func WithRateLimitMaxRetries(maxRetries int32) ConfigSetter
func WithRateLimitMaxWait ¶ added in v3.0.11
func WithRateLimitMaxWait(maxWait time.Duration) ConfigSetter
func WithRateLimitMinWait ¶ added in v3.0.11
func WithRateLimitMinWait(minWait time.Duration) ConfigSetter
func WithRequestTimeout ¶ added in v3.0.11
func WithRequestTimeout(requestTimeout time.Duration) ConfigSetter
func WithTestingDisableHttpsCheck ¶ added in v3.0.11
func WithTestingDisableHttpsCheck(httpsCheck bool) ConfigSetter
func WithUserAgentExtra ¶ added in v3.0.11
func WithUserAgentExtra(userAgent string) ConfigSetter
WithUserAgent sets the UserAgent in the Config.
func WithZconAPIKey ¶ added in v3.0.11
func WithZconAPIKey(apiKey string) ConfigSetter
WithZconAPIKey sets the ApiKey in the Config.
func WithZconCloud ¶ added in v3.0.11
func WithZconCloud(cloud string) ConfigSetter
WithZconAPIKey sets the ApiKey in the Config.
func WithZconPassword ¶ added in v3.0.11
func WithZconPassword(password string) ConfigSetter
WithZconPassword sets the Password in the Config.
func WithZconUsername ¶ added in v3.0.11
func WithZconUsername(username string) ConfigSetter
ConfigSetter type defines a function that modifies a Config struct. WithZconUsername sets the Username in the Config.
type Configuration ¶ added in v3.0.11
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 ZCON struct { Client struct { ZCONUsername string `yaml:"username" envconfig:"ZCON_USERNAME"` ZCONPassword string `yaml:"password" envconfig:"ZCON_PASSWORD"` ZCONApiKey string `yaml:"apiKey" envconfig:"ZCON_API_KEY"` ZCONCloud string `yaml:"cloud" envconfig:"ZCON_CLOUD"` Cache struct { Enabled bool `yaml:"enabled" envconfig:"ZCON_CLIENT_CACHE_ENABLED"` DefaultTtl time.Duration `yaml:"defaultTtl" envconfig:"ZCON_CLIENT_CACHE_DEFAULT_TTL"` DefaultTti time.Duration `yaml:"defaultTti" envconfig:"ZCON_CLIENT_CACHE_DEFAULT_TTI"` DefaultCacheMaxSizeMB int64 `yaml:"defaultTti" envconfig:"ZCON_CLIENT_CACHE_DEFAULT_SIZE"` } `yaml:"cache"` Proxy struct { Port int32 `yaml:"port" envconfig:"ZCON_CLIENT_PROXY_PORT"` Host string `yaml:"host" envconfig:"ZCON_CLIENT_PROXY_HOST"` Username string `yaml:"username" envconfig:"ZCON_CLIENT_PROXY_USERNAME"` Password string `yaml:"password" envconfig:"ZCON_CLIENT_PROXY_PASSWORD"` } `yaml:"proxy"` RequestTimeout time.Duration `yaml:"requestTimeout" envconfig:"ZCON_CLIENT_REQUEST_TIMEOUT"` RateLimit struct { MaxRetries int32 `yaml:"maxRetries" envconfig:"ZCON_CLIENT_RATE_LIMIT_MAX_RETRIES"` RetryWaitMin time.Duration `yaml:"minWait" envconfig:"ZCON_CLIENT_RATE_LIMIT_MIN_WAIT"` RetryWaitMax time.Duration `yaml:"maxWait" envconfig:"ZCON_CLIENT_RATE_LIMIT_MAX_WAIT"` } `yaml:"rateLimit"` } `yaml:"client"` Testing struct { DisableHttpsCheck bool `yaml:"disableHttpsCheck" envconfig:"ZCON_TESTING_DISABLE_HTTPS_CHECK"` } `yaml:"testing"` } `yaml:"zcon"` CacheManager cache.Cache }
func NewConfiguration ¶ added in v3.0.11
func NewConfiguration(conf ...ConfigSetter) (*Configuration, error)
func (*Configuration) AddDefaultHeader ¶ added in v3.0.11
func (c *Configuration) AddDefaultHeader(key string, value string)
AddDefaultHeader adds a new HTTP header to the default header in the request
type Credentials ¶
type Credentials struct { Username string `json:"username"` Password string `json:"password"` APIKey string `json:"apiKey"` TimeStamp string `json:"timestamp"` }
Credentials ...
type Session ¶
type Session struct { AuthType string `json:"authType"` ObfuscateAPIKey bool `json:"obfuscateApiKey"` PasswordExpiryTime int `json:"passwordExpiryTime"` PasswordExpiryDays int `json:"passwordExpiryDays"` Source string `json:"source"` JSessionID string `json:"jSessionID,omitempty"` }
func MakeAuthRequestZCON ¶
func MakeAuthRequestZCON(credentials *Credentials, baseURL string, client *http.Client, userAgent string) (*Session, error)
MakeAuthRequestZIA authenticates using the provided credentials and returns the session or an error.