Documentation ¶
Index ¶
- type ConnectionProfile
- type Job
- type MockResponse
- type RestClient
- func (r *RestClient) CallCreateMethod(baseURL string, query *RestQuery, body map[string]interface{}) (int, RestResponse, error)
- func (r *RestClient) CallDeleteMethod(baseURL string, query *RestQuery, body map[string]interface{}) (int, RestResponse, error)
- func (r *RestClient) CallUpdateMethod(baseURL string, query *RestQuery, body map[string]interface{}) (int, RestResponse, error)
- func (r *RestClient) Equals(r2 *RestClient) (ok bool, firstDiff string)
- func (r *RestClient) GetNilOrOneRecord(baseURL string, query *RestQuery, body map[string]interface{}) (int, map[string]interface{}, error)
- func (r *RestClient) GetZeroOrMoreRecords(baseURL string, query *RestQuery, body map[string]interface{}) (int, []map[string]interface{}, error)
- func (r *RestClient) NewQuery() *RestQuery
- func (r *RestClient) Wait(uuid string) (int, RestResponse, error)
- type RestError
- type RestQuery
- type RestResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionProfile ¶
type ConnectionProfile struct { // TODO: add certs in addition to basic authentication // TODO: Add Timeout (currently hardcoded to 10 seconds) Hostname string Username string Password string ValidateCerts bool MaxConcurrentRequests int }
ConnectionProfile describes out to reach a cluster or svm
type MockResponse ¶
type MockResponse struct { ExpectedMethod string ExpectedURL string StatusCode int Response RestResponse Err error }
MockResponse is used in Unit Testing to mock expected REST responses. It validate sthat the request matches ExpectedMethod and ExpectedURL, to return the other elements.
type RestClient ¶
type RestClient struct {
// contains filtered or unexported fields
}
RestClient to interact with the ONTAP REST API
func NewClient ¶
func NewClient(ctx context.Context, cxProfile ConnectionProfile, tag string, jobCompletionTimeOut int) (*RestClient, error)
NewClient creates a new REST client and a supporting HTTP client
func NewMockedRestClient ¶
func NewMockedRestClient(responses []MockResponse) (*RestClient, error)
NewMockedRestClient is used in Unit Testing to mock expected REST responses.
func (*RestClient) CallCreateMethod ¶
func (r *RestClient) CallCreateMethod(baseURL string, query *RestQuery, body map[string]interface{}) (int, RestResponse, error)
CallCreateMethod returns response from POST results. An error is reported if an error is received.
func (*RestClient) CallDeleteMethod ¶
func (r *RestClient) CallDeleteMethod(baseURL string, query *RestQuery, body map[string]interface{}) (int, RestResponse, error)
CallDeleteMethod returns response from DELETE results. An error is reported if an error is received.
func (*RestClient) CallUpdateMethod ¶
func (r *RestClient) CallUpdateMethod(baseURL string, query *RestQuery, body map[string]interface{}) (int, RestResponse, error)
CallUpdateMethod returns response from PATCH results. An error is reported if an error is received.
func (*RestClient) Equals ¶
func (r *RestClient) Equals(r2 *RestClient) (ok bool, firstDiff string)
Equals is a test function for Unit Testing
func (*RestClient) GetNilOrOneRecord ¶
func (r *RestClient) GetNilOrOneRecord(baseURL string, query *RestQuery, body map[string]interface{}) (int, map[string]interface{}, error)
GetNilOrOneRecord returns nil if no record is found or a single record. An error is reported if multiple records are received.
func (*RestClient) GetZeroOrMoreRecords ¶
func (r *RestClient) GetZeroOrMoreRecords(baseURL string, query *RestQuery, body map[string]interface{}) (int, []map[string]interface{}, error)
GetZeroOrMoreRecords returns a list of records.
func (*RestClient) NewQuery ¶
func (r *RestClient) NewQuery() *RestQuery
NewQuery is used to provide query parameters. Set and Add functions are inherited from url.Values
func (*RestClient) Wait ¶
func (r *RestClient) Wait(uuid string) (int, RestResponse, error)
Wait waits for job to finish.
type RestQuery ¶
RestQuery is a wrapper around urlValues, and supports a Fields method in addition to Set, Add.
type RestResponse ¶
type RestResponse struct { NumRecords int `mapstructure:"num_records"` Records []map[string]interface{} RestError RestError `mapstructure:"error"` StatusCode int HTTPError string ErrorType string Job map[string]interface{} Jobs []map[string]interface{} }
RestResponse to return a list of records (can be empty) and/or errors.