session

package
v0.0.0-...-cc85715 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 21 Imported by: 5

Documentation

Overview

Copyright 2021 VMware, Inc. SPDX-License-Identifier: Apache License 2.0

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 = "18.2.6"
View Source
const DEFAULT_CSP_HOST = "console.cloud.vmware.com"
View Source
const DEFAULT_MAX_API_RETRIES = 3

Variables

This section is empty.

Functions

func DisableControllerStatusCheckOnFailure

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

func GetIPVersion

func GetIPVersion(ipAddr string) net.IP

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 SetCSPHost

func SetCSPHost(csphost string) func(*AviSession) error

func SetCSPToken

func SetCSPToken(csptoken string) func(*AviSession) error

SetCSPToken

func SetClient

func SetClient(client HttpClient) func(*AviSession) error

SetClient allows callers to inject their own HTTP client.

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 SetUserHeader

func SetUserHeader(user_headers map[string]string) func(*AviSession) error

SetUserHeader -

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 {

	// CSP_HOST specifies the CSP Host name
	CSP_HOST string

	// CSP_TOKEN specifies the API token of the csp host with which we can generate the access token
	CSP_TOKEN string

	// internal: variable to store generated csp access token
	CSP_ACCESS_TOKEN string
	// 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, options ...ApiOptionsParams) ([]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{}, options ...ApiOptionsParams) ([]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) PutRaw

func (avisess *AviSession) PutRaw(uri string, payload interface{}, options ...ApiOptionsParams) ([]byte, error)

PutRaw performs a POST API call and returns raw data

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

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpClient allows callers to inject their own implementations for the SDK to use.

Jump to

Keyboard shortcuts

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