client

package
v3.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: BSD-3-Clause Imports: 11 Imported by: 7

Documentation

Index

Constants

View Source
const UNDEFPORT = -1

UNDEFPORT undefined port

Variables

View Source
var (
	// DefaultTimeOut connection timeout default
	DefaultTimeOut = time.Duration(60 * time.Second)
	// DefaultProtocol uses https for default connection
	DefaultProtocol = "https"
	// DefaultHosts set to local host ip
	DefaultHosts = []string{"127.0.0.1"}
	// NumRetryRequests specifies the number for retries to attempt
	NumRetryRequests = 3
)

Functions

This section is empty.

Types

type CvpClient

type CvpClient struct {
	cvpapi.ClientInterface
	Hosts    []string
	HostPool *HostIterator
	Port     int
	Protocol string

	Timeout   time.Duration
	Transport http.RoundTripper
	Client    *resty.Client
	SessID    string

	API     *cvpapi.CvpRestAPI
	Debug   bool
	IsCvaas bool
	Tenant  string
	Token   string
	// contains filtered or unexported fields
}

CvpClient represents a CVP client api connection

func NewCvpClient

func NewCvpClient(options ...Option) (*CvpClient, error)

NewCvpClient creates a new CVP RESTful Client

func (*CvpClient) Connect

func (c *CvpClient) Connect(username string, password string) error

Connect Login to CVP and get a session ID and cookie.

func (*CvpClient) ConnectWithToken added in v3.0.3

func (c *CvpClient) ConnectWithToken(cvpToken string) error

Connect to CVP with a token. Takes the cvpToken parameter as an input for the string.

func (*CvpClient) Delete

func (c *CvpClient) Delete(url string, params *url.Values, data interface{}) ([]byte, error)

Delete implemented as part of cvprac api client interface

func (*CvpClient) Get

func (c *CvpClient) Get(url string, params *url.Values) ([]byte, error)

Get implemented as part of cvprac api client interface

func (*CvpClient) GetPort

func (c *CvpClient) GetPort() int

GetPort returns the port this client will use for connectivity

func (*CvpClient) GetSessionID

func (c *CvpClient) GetSessionID() string

GetSessionID returns the current Session ID

func (*CvpClient) Post

func (c *CvpClient) Post(url string, params *url.Values, data interface{}) ([]byte, error)

Post implemented as part of cvprac api client interface

func (*CvpClient) SetConnectTimeout

func (c *CvpClient) SetConnectTimeout(timeout int) error

SetConnectTimeout sets the connection timeout associated with this connection

func (*CvpClient) SetCvaas

func (c *CvpClient) SetCvaas(enable bool, tenant string) error

SetCvaas adds support for cvaas.

func (*CvpClient) SetDebug

func (c *CvpClient) SetDebug(enable bool) error

SetDebug enables or disables debugging.

func (*CvpClient) SetHosts

func (c *CvpClient) SetHosts(host ...string) error

SetHosts sets the hosts

func (*CvpClient) SetOption

func (c *CvpClient) SetOption(options ...Option) error

SetOption takes one or more option function and applies them in order

func (*CvpClient) SetPort

func (c *CvpClient) SetPort(port int) error

SetPort sets the port for this connection

func (*CvpClient) SetProtocol

func (c *CvpClient) SetProtocol(proto string) error

SetProtocol sets the protocol (i.e. http or https) associated with this connection

func (*CvpClient) SetTransport

func (c *CvpClient) SetTransport(transport http.RoundTripper) error

SetTransport sets the connection Transport associated with this connection

type HostIterator

type HostIterator struct {
	// contains filtered or unexported fields
}

HostIterator implements an itorator for a list of hostnames/ips

func NewHostIterator

func NewHostIterator(hosts []string) (*HostIterator, error)

NewHostIterator inits an itorator for host list

func (*HostIterator) Cycle

func (h *HostIterator) Cycle() string

Cycle returns the next host in the list. If we've exceeded the length of the list, then circle back to the first.

func (*HostIterator) Next

func (h *HostIterator) Next() bool

Next returns true if there is another element to iterate. False if we reach the end of the list

func (*HostIterator) Value

func (h *HostIterator) Value() string

Value returns the value for the current entry

type Option

type Option func(*CvpClient) error

Option is a Client Option...function that sets a value and returns

func ConnectTimeout

func ConnectTimeout(timeout int) Option

ConnectTimeout sets the connection timeout for this Client

func Cvaas

func Cvaas(enable bool, tenant string) Option

Cvaas enables the cvaas support for this Client

func Debug

func Debug(enable bool) Option

Debug sets the debug option for this Client

func Hosts

func Hosts(hosts ...string) Option

Hosts sets the available host ip/names to use for this Client

func Port

func Port(port int) Option

Port sets the port option for this Client

func Protocol

func Protocol(proto string) Option

Protocol sets the protocol option for this Client

func Transport

func Transport(transport http.RoundTripper) Option

Transport sets the connection Transport for this Client

Jump to

Keyboard shortcuts

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