session

package
v0.0.0-...-e7d04ab Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 17 Imported by: 11

Documentation

Index

Constants

View Source
const DEFAULT_API_RETRY_INTERVAL = 500
View Source
const DEFAULT_API_TENANT = "admin"
View Source
const DEFAULT_API_TIMEOUT = time.Duration(60 * time.Second)
View Source
const DEFAULT_AVI_VERSION = "17.1.2"
View Source
const DEFAULT_MAX_API_RETRIES = 3

Variables

This section is empty.

Functions

func DisableControllerStatusCheckOnFailure

func DisableControllerStatusCheckOnFailure(controllerStatusCheck bool) func(*AviSession) error

func SetApiRetryInterval

func SetApiRetryInterval(api_retry_interval int) func(*AviSession) error

func SetAuthToken

func SetAuthToken(authToken string) func(*AviSession) error

SetAuthToken - Use this for NewAviSession option argument for setting authToken

func SetCloud

func SetCloud(cloud string) func(*ApiOptions) error

func SetCloudUUID

func SetCloudUUID(cloudUUID string) func(*ApiOptions) error

func SetControllerStatusCheckLimits

func SetControllerStatusCheckLimits(numRetries, retryInterval int) func(*AviSession) error

SetControllerStatusCheckLimits allows client to limit the number of tries the SDK should attempt to reach the controller at the time gap of specified time intervals.

func SetIncludeName

func SetIncludeName(includeName bool) func(*ApiOptions) error

func SetInsecure

func SetInsecure(avisess *AviSession) error

SetInsecure - Use this for NewAviSession option argument for allowing insecure connection to AviController

func SetLazyAuthentication

func SetLazyAuthentication(lazyAuthentication bool) func(*AviSession) error

SetTimeout -

func SetMaxApiRetries

func SetMaxApiRetries(max_api_retries int) func(*AviSession) error

func SetName

func SetName(name string) func(*ApiOptions) error

func SetOptTenant

func SetOptTenant(tenant string) func(*ApiOptions) error

func SetParams

func SetParams(params map[string]string) func(*ApiOptions) error

func SetPassword

func SetPassword(password string) func(*AviSession) error

SetPassword - Use this for NewAviSession option argument for setting password

func SetRefreshAuthTokenCallback

func SetRefreshAuthTokenCallback(f func() string) func(*AviSession) error

SetAuthToken - Use this for NewAviSession option argument for setting authToken

func SetRefreshAuthTokenCallbackV2

func SetRefreshAuthTokenCallbackV2(f func() (string, error)) func(*AviSession) error

SetAuthToken V2 - Use this for NewAviSession option argument for setting authToken with option to return error found during token generation

func SetResult

func SetResult(result interface{}) func(*ApiOptions) error

func SetSkipDefault

func SetSkipDefault(skipDefault bool) func(*ApiOptions) error

func SetTenant

func SetTenant(tenant string) func(*AviSession) error

SetTenant - Use this for NewAviSession option argument for setting tenant

func SetTimeout

func SetTimeout(timeout time.Duration) func(*AviSession) error

SetTimeout -

func SetTransport

func SetTransport(transport *http.Transport) func(*AviSession) error

SetTransport - Use this for NewAviSession option argument for configuring http transport to enable connection

func SetVersion

func SetVersion(version string) func(*AviSession) error

SetVersion - Use this for NewAviSession option argument for setting version

Types

type ApiOptions

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

type ApiOptionsParams

type ApiOptionsParams func(*ApiOptions) error

type AviCollectionResult

type AviCollectionResult struct {
	Count   int
	Results json.RawMessage
	Next    string
}

AviCollectionResult for representing the collection type results from Avi

type AviError

type AviError struct {
	// aviresult holds the standard header (code and message) that is included in
	// responses from Avi.
	AviResult

	// verb is the HTTP verb (GET, POST, PUT, PATCH, or DELETE) that was
	// used in the request that resulted in the error.
	Verb string

	// url is the URL that was used in the request that resulted in the error.
	Url string

	// HttpStatusCode is the HTTP response status code (e.g., 200, 404, etc.).
	HttpStatusCode int
	// contains filtered or unexported fields
}

AviError represents an error resulting from a request to the Avi Controller

func (AviError) Error

func (err AviError) Error() string

Error implements the error interface.

type AviResult

type AviResult struct {
	// Code should match the HTTP status code.
	Code int `json:"code"`

	// Message should contain a short description of the result of the requested
	// operation.
	Message *string `json:"message"`
}

type AviSession

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

AviSession maintains a session to the specified Avi Controller

func NewAviSession

func NewAviSession(host string, username string, options ...func(*AviSession) error) (*AviSession, error)

NewAviSession initiates a session to AviController and returns it

func (*AviSession) CheckControllerStatus

func (avisess *AviSession) CheckControllerStatus() (bool, *http.Response, error)

Checking for controller up state. Flexible to wait on controller status infinitely or for fixed time span.

func (*AviSession) Delete

func (avisess *AviSession) Delete(uri string, params ...interface{}) error

Delete issues a DELETE request against the avisess REST API.

func (*AviSession) DeleteObject

func (avisess *AviSession) DeleteObject(uri string, options ...ApiOptionsParams) error

DeleteObject performs DELETE Operation and delete the data

func (*AviSession) Get

func (avisess *AviSession) Get(uri string, response interface{}, options ...ApiOptionsParams) error

Get issues a GET request against the avisess REST API.

func (*AviSession) GetCollection

func (avisess *AviSession) GetCollection(uri string, objList interface{}, options ...ApiOptionsParams) error

GetCollection performs a collection API call and unmarshals the results into objList, which should be an array type

func (*AviSession) GetCollectionRaw

func (avisess *AviSession) GetCollectionRaw(uri string, options ...ApiOptionsParams) (AviCollectionResult, error)

GetCollectionRaw issues a GET request and returns a AviCollectionResult with unmarshaled (raw) results section.

func (*AviSession) GetControllerVersion

func (avisess *AviSession) GetControllerVersion() (string, error)

GetControllerVersion gets the version number from the Avi Controller

func (*AviSession) GetMultipartRaw

func (avisess *AviSession) GetMultipartRaw(verb string, uri string, file_loc_ptr *os.File, options ...ApiOptionsParams) error

GetMultipartRaw performs a GET API call and returns multipart raw data (File Download) The verb input is ignored and kept only for backwards compatibility

func (*AviSession) GetObject

func (avisess *AviSession) GetObject(obj string, options ...ApiOptionsParams) error

GetObject performs GET and return object data

func (*AviSession) GetObjectByName

func (avisess *AviSession) GetObjectByName(obj string, name string, result interface{}, options ...ApiOptionsParams) error

GetObjectByName performs GET with name filter

func (*AviSession) GetRaw

func (avisess *AviSession) GetRaw(uri string) ([]byte, error)

GetRaw performs a GET API call and returns raw data

func (*AviSession) GetUri

func (avisess *AviSession) GetUri(obj string, options ...ApiOptionsParams) (string, error)

GetUri returns the URI

func (*AviSession) Logout

func (avisess *AviSession) Logout() error

Logout performs log out operation of the Avi Controller

func (*AviSession) Patch

func (avisess *AviSession) Patch(uri string, payload interface{}, patchOp string, response interface{}, options ...ApiOptionsParams) error

Post issues a PATCH request against the avisess REST API. allowed patchOp - add, replace, remove

func (*AviSession) Post

func (avisess *AviSession) Post(uri string, payload interface{}, response interface{}, options ...ApiOptionsParams) error

Post issues a POST request against the avisess REST API.

func (*AviSession) PostMultipartFileObjectRequest

func (avisess *AviSession) PostMultipartFileObjectRequest(fileLocPtr *os.File, tenant string, fileParams map[string]string) error

PostMultipartRequest performs a POST API call and uploads multipart data to API fileobject/upload

func (*AviSession) PostMultipartRequest

func (avisess *AviSession) PostMultipartRequest(verb string, uri string, file_loc_ptr *os.File, options ...ApiOptionsParams) error

PostMultipartRequest performs a POST API call and uploads multipart data The verb input is ignored and kept only for backwards compatibility

func (*AviSession) PostMultipartWafAppSignatureObjectRequest

func (avisess *AviSession) PostMultipartWafAppSignatureObjectRequest(fileLocPtr *os.File, uri string, tenant string, fileParams map[string]string) error

PostMultipartRequest performs a POST API call and uploads multipart data to API fileobject/upload

func (*AviSession) PostRaw

func (avisess *AviSession) PostRaw(uri string, payload interface{}) ([]byte, error)

PostRaw performs a POST API call and returns raw data

func (*AviSession) Put

func (avisess *AviSession) Put(uri string, payload interface{}, response interface{}, options ...ApiOptionsParams) error

Put issues a PUT request against the avisess REST API.

func (*AviSession) ResetPassword

func (avisess *AviSession) ResetPassword(password string) error

func (*AviSession) RestRequest

func (avisess *AviSession) RestRequest(verb string, uri string, payload interface{}, tenant string, lastError error,
	retryNum ...int) (*http.Response, error)

RestRequest exports restRequest from the SDK Returns http.Response for accessing the whole http Response struct including headers and response body

Jump to

Keyboard shortcuts

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