client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks errors if exist errors in request

Types

type Client

type Client struct {
	Credentials *Credentials

	// Base URL for API requests.
	BaseURL *url.URL

	// User agent for client
	UserAgent string

	Cookies []*http.Cookie
	// contains filtered or unexported fields
}

Client Config Configuration of the client

func NewClient

func NewClient(credentials *Credentials) (*Client, error)

NewClient returns a new Nutanix API client.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) error

Do performs request passed

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates a request

func (*Client) NewUploadRequest

func (c *Client) NewUploadRequest(ctx context.Context, method, urlStr string, body []byte) (*http.Request, error)

NewUploadRequest Handles image uploads for image service

func (*Client) OnRequestCompleted

func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)

OnRequestCompleted sets the DO API request completion callback

type Credentials

type Credentials struct {
	URL         string
	Username    string
	Password    string
	Endpoint    string
	Port        string
	Insecure    bool
	SessionAuth bool
	ProxyURL    string
}

Credentials needed username and password

type ErrorResponse

type ErrorResponse struct {
	APIVersion  string            `json:"api_version,omitempty"`
	Code        int64             `json:"code,omitempty"`
	Kind        string            `json:"kind,omitempty"`
	MessageList []MessageResource `json:"message_list"`
	State       string            `json:"state"`
}

ErrorResponse ...

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type MessageResource

type MessageResource struct {

	// Custom key-value details relevant to the status.
	Details map[string]interface{} `json:"details,omitempty"`

	// If state is ERROR, a message describing the error.
	Message string `json:"message"`

	// If state is ERROR, a machine-readable snake-cased *string.
	Reason string `json:"reason"`
}

MessageResource ...

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response, interface{})

RequestCompletionCallback defines the type of the request callback function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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