client

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const NumRetryRequests = 3

NumRetryRequests specifies the number for retries to attempt

View Source
const UNDEFPORT = -1

UNDEFPORT undefined port

Variables

This section is empty.

Functions

This section is empty.

Types

type CvpClient

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

	Timeout time.Duration
	Client  *resty.Client
	Headers map[string]string
	SessID  string

	API   *cvpapi.CvpRestAPI
	Debug bool
	// 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) Get

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

Get implemented as part of cvprac api client interface

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

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

Jump to

Keyboard shortcuts

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