client

package
v4.0.2-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: UNKNOWN not legal advice Imports: 22 Imported by: 0

Documentation

Overview

The api client for storage's golang SDK

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParameterToJson

func ParameterToJson(obj interface{}) (string, error)

helper for converting interface{} parameters to json strings

func ParameterToString

func ParameterToString(obj interface{}, collectionFormat string) string

parameterToString convert interface{} parameters to string, using a delimiter if format is provided.

func ReportError

func ReportError(format string, b ...interface{}) error

Prevent trying to import "fmt"

Types

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type ApiClient

type ApiClient struct {
	Scheme           string `json:"scheme,omitempty"`
	Host             string `json:"host,omitempty"`
	Port             int    `json:"port,omitempty"`
	Username         string `json:"username,omitempty"`
	Password         string `json:"password,omitempty"`
	Debug            bool   `json:"debug,omitempty"`
	VerifySSL        bool
	Proxy            *Proxy
	MaxRetryAttempts int           `json:"maxRetryAttempts,omitempty"`
	ReadTimeout      time.Duration `json:"readTimeout,omitempty"`
	ConnectTimeout   time.Duration `json:"connectTimeout,omitempty"`
	RetryInterval    time.Duration `json:"retryInterval,omitempty"`
	LoggerFile       string        `json:"loggerFile,omitempty"`
	// contains filtered or unexported fields
}

*

Generic API client for Swagger client library builds.
Swagger generic API client. This client handles the client-
server communication, and is invariant across implementations. Specifics of
the methods and models for each application are generated from the Swagger
templates.

Parameters :-
  Scheme (string) : URI scheme for connecting to the cluster (HTTP or HTTPS using SSL/TLS) (default : https)
  Host (string) : Host IPV4, IPV6 or FQDN for all http request made by this client (default : localhost)
  Port (string) : Port for the host to connect to make all http request (default : 9440)
  Username (string) : Username to connect to a cluster
  Password (string) : Password to connect to a cluster
  Debug (bool) : flag to enable debug logging (default : empty)
  VerifySSL (bool) : Verify SSL certificate of cluster (default: true)
  MaxRetryAttempts (int) : Maximum number of retry attempts to be made at a time (default: 5)
  ReadTimeout (time.Duration) : Read timeout for all operations in milliseconds
  ConnectTimeout (time.Duration) : Connection timeout for all operations in milliseconds
  RetryInterval (time.Duration) : Interval between successive retry attempts (default: 3 sec)
  LoggerFile (string) : Log file to write activity logs

func NewApiClient

func NewApiClient() *ApiClient

*

Returns a newly generated ApiClient instance populated with default values

func (*ApiClient) AddDefaultHeader

func (a *ApiClient) AddDefaultHeader(headerName string, headerValue string)

AddDefaultHeader Adds a default header to current api client instance for all the HTTP calls.

func (*ApiClient) CallApi

func (a *ApiClient) CallApi(uri *string, httpMethod string, body interface{},
	queryParams url.Values, headerParams map[string]string, formParams url.Values,
	accepts []string, contentType []string, authNames []string) ([]byte, error)

Makes the HTTP request with given options and returns response body as byte array.

func (*ApiClient) GetAuthentication

func (a *ApiClient) GetAuthentication(authName string) interface{}

Get authentication for the given auth name (eg : basic, oauth, bearer, apiKey)

func (*ApiClient) GetAuthentications

func (a *ApiClient) GetAuthentications() map[string]interface{}

Get all authentications (key: authentication name, value: authentication)

func (*ApiClient) GetEtag

func (a *ApiClient) GetEtag(object interface{}) string

GetEtag Get ETag from an object if exists, otherwise returns empty string. The ETag is usually provided in the response of the GET API calls, which can further be used in other HTTP operations.

func (*ApiClient) SetAccessToken

func (a *ApiClient) SetAccessToken(accessToken string) error

Helper method to set access token for the first OAuth2 authentication.

func (*ApiClient) SetApiKey

func (a *ApiClient) SetApiKey(key string) error

Helper method to set API key value for the first API key authentication

func (*ApiClient) SetApiKeyPrefix

func (a *ApiClient) SetApiKeyPrefix(apiKeyPrefix string) error

Helper method to set API key prefix for the first API key authentication

func (*ApiClient) SetMaxRetryAttempts

func (a *ApiClient) SetMaxRetryAttempts(maxRetryAttempts int)

*

Helper method to set maximum retry attempts.
After the initial instantiation of ApiClient, maximum retry attempts must be modified only via this method

func (*ApiClient) SetPassword

func (a *ApiClient) SetPassword(password string)

Helper method to set password for the first HTTP basic authentication

func (*ApiClient) SetRetryIntervalInMilliSeconds

func (a *ApiClient) SetRetryIntervalInMilliSeconds(ms int)

*

Helper method to set retry back off period.
After the initial instantiation of ApiClient, back off period must be modified only via this method

func (*ApiClient) SetUserName

func (a *ApiClient) SetUserName(username string)

Helper method to set username for the first HTTP basic authentication.

func (*ApiClient) SetVerifySSL

func (a *ApiClient) SetVerifySSL(verifySSL bool)

*

Helper method to enable/disable SSL verification. By default, SSL verification is enabled.
Please note that disabling SSL verification is not recommended and should only be done for test purposes.

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type GenericOpenAPIError

type GenericOpenAPIError struct {
	Body   []byte
	Model  interface{}
	Status string
}

GenericOpenAPIError Provides access to the body (error), status and model on returned errors.

func (GenericOpenAPIError) DeserializedModel

func (e GenericOpenAPIError) DeserializedModel() interface{}

Error returns deserialized response body if compatible with GenericOpenAPIError.Model

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

type LeveledLogrus

type LeveledLogrus struct {
	*logrus.Logger
}

func (*LeveledLogrus) Debug

func (l *LeveledLogrus) Debug(msg string, keysAndValues ...interface{})

func (*LeveledLogrus) Error

func (l *LeveledLogrus) Error(msg string, keysAndValues ...interface{})

func (*LeveledLogrus) Info

func (l *LeveledLogrus) Info(msg string, keysAndValues ...interface{})

func (*LeveledLogrus) Warn

func (l *LeveledLogrus) Warn(msg string, keysAndValues ...interface{})

type OAuth

type OAuth struct {
	AccessToken string
}

OAuth provides OAuth authentication

type Proxy

type Proxy struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	Scheme   string `json:"scheme,omitempty"`
	Host     string `json:"host,omitempty"`
	Port     int    `json:"port,omitempty"`
}

*

Configuration for the Proxy Server that
requests are to be routed through.

Parameters :-
  Scheme (string) : URI Scheme for connecting to the proxy ("http", "https" or "socks5")
  Host (string) : Host of the proxy to which the client will connect to
  Port (string) : Port of the proxy to which the client will connect to
  Username (string) : Username to connect to the proxy
  Password (string) : Password to connect to the proxy

Jump to

Keyboard shortcuts

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