client

package
v4.0.1-beta.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: UNKNOWN not legal advice Imports: 23 Imported by: 0

Documentation

Overview

The api client for vmm'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

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
}

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"`
	DownloadDirectory string        `json:"downloadDirectory,omitempty"`
	DownloadChunkSize int           `json:"downloadChunkSize,omitempty"`
	LoggerFile        string        `json:"loggerFile,omitempty"`
	// contains filtered or unexported fields
}

API client to handle the client-server communication, and is invariant across implementations.

Scheme (optional) : URI scheme for connecting to the cluster (HTTP or HTTPS using SSL/TLS) (default : https)
Host (required) : Host IPV4, IPV6 or FQDN for all http request made by this client (default : localhost)
Port (optional) : Port for the host to connect to make all http request (default : 9440)
Username (required) : Username to connect to a cluster
Password (required) : Password to connect to a cluster
Debug (optional) : flag to enable debug logging (default : empty)
VerifySSL (optional) : Verify SSL certificate of cluster (default: true)
MaxRetryAttempts (optional) : Maximum number of retry attempts to be made at a time (default: 5)
ReadTimeout (optional) : Read timeout for all operations in milliseconds
ConnectTimeout (optional) : Connection timeout for all operations in milliseconds
RetryInterval (optional) : Interval between successive retry attempts (default: 3 sec)
DownloadDirectory (optional) : Directory location on local for files to download (default: Current Directory)
DownloadChunkSize (optional) : Chunk size in bytes for files to download (default: 8*1024 bytes)
LoggerFile (optional) : 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)

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) (interface{}, 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

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"`
}

Provides basic http authentication to a request passed via context using ContextBasicAuth

type GenericOpenAPIError

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

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

func (GenericOpenAPIError) DeserializedModel

func (e GenericOpenAPIError) DeserializedModel() interface{}

Returns deserialized response body if compatible with GenericOpenAPIError.Model

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

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
}

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.

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

Jump to

Keyboard shortcuts

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