client

package
v4.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 24 Imported by: 1

Documentation

Overview

The api client for prism'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"`
	MaxRedirects          int           `json:"maxRedirects,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"`
	RootCACertificateFile string
	ClientCertificateFile string
	ClientKeyFile         string
	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)
MaxRedirects (optional) : Maximum number of redirect attempts to be made at a time (default: 10)
ReadTimeout (optional) : Read timeout for all operations (default: 30 sec)
ConnectTimeout (optional) : Connection timeout for all operations (default: 30 sec)
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)
RootCACertificateFile (string) : PEM encoded Root CA certificate file path
ClientCertificateFile (string) : PEM encoded client certificate file path
ClientKeyFile (string) : PEM encoded client key file path
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) Contains

func (a *ApiClient) Contains(source []string, match string) bool

func (*ApiClient) DownloadFile

func (a *ApiClient) DownloadFile(response *http.Response) (*string, error)

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) SetMaxRedirects

func (a *ApiClient) SetMaxRedirects(maxRedirects int)

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

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