client

package
v0.0.0-...-6e535ca Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2016 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an HTTP REST wrapper. Use one of Get/Porst/Put/Delete to get a request object.

func NewClient

func NewClient(host string, version string) (*Client, error)

NewClient returns a new REST client for specified server.

func NewDriverClient

func NewDriverClient(driverName string) (*Client, error)

NewDriver returns a new REST client for specified driver.

func (*Client) ClusterManager

func (c *Client) ClusterManager() cluster.Cluster

ClusterManager returns a REST wrapper for the Cluster interface.

func (*Client) Delete

func (c *Client) Delete() *Request

Put returns a Request object setup for DELETE call.

func (*Client) Get

func (c *Client) Get() *Request

Get returns a Request object setup for GET call.

func (*Client) Post

func (c *Client) Post() *Request

Post returns a Request object setup for POST call.

func (*Client) Put

func (c *Client) Put() *Request

Put returns a Request object setup for PUT call.

func (*Client) Status

func (c *Client) Status() (*Status, error)

Status sends a Status request at the /status REST endpoint.

func (*Client) VolumeDriver

func (c *Client) VolumeDriver() volume.VolumeDriver

VolumeDriver returns a REST wrapper for the VolumeDriver interface.

type Request

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

Request is contructed iteratively by the client and finally dispatched. A REST endpoint is accessed with the following convention: base_url/<version>/<resource>/[<instance>]

func NewRequest

func NewRequest(client *http.Client, base *url.URL, verb string, version string) *Request

NewRequest instance

func (*Request) Body

func (r *Request) Body(v interface{}) *Request

Body sets the request Body.

func (*Request) Do

func (r *Request) Do() *Response

Do executes the request and returns a Response.

func (*Request) Instance

func (r *Request) Instance(instance string) *Request

Instance specifies the instance of the resource to be accessed.

func (*Request) QueryOption

func (r *Request) QueryOption(key string, value string) *Request

QueryOption adds specified options to query.

func (*Request) QueryOptionLabel

func (r *Request) QueryOptionLabel(key string, labels map[string]string) *Request

QueryOptionLabel adds specified label to query.

func (*Request) Resource

func (r *Request) Resource(resource string) *Request

Resource specifies the resource to be accessed.

func (*Request) SetHeader

func (r *Request) SetHeader(key, value string) *Request

SetHeader adds specified header values to query.

func (*Request) Timeout

func (r *Request) Timeout(d time.Duration) *Request

Timeout makes the request use the given duration as a timeout. Sets the "timeout" parameter.

func (*Request) URL

func (r *Request) URL() *url.URL

URL returns the current working URL.

func (*Request) UsePath

func (r *Request) UsePath(path string) *Request

UsePath use the specified path and don't build up a request.

type Response

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

Response is a representation of HTTP response received from the server.

func (Response) Body

func (r Response) Body() ([]byte, error)

Body return http body, valid only if there is no error

func (Response) Error

func (r Response) Error() error

Error executing the request.

func (Response) StatusCode

func (r Response) StatusCode() int

StatusCode HTTP status code returned.

func (Response) Unmarshal

func (r Response) Unmarshal(v interface{}) error

Unmarshal result into obj

type Status

type Status struct {
	Message   string
	ErrorCode int
}

Status upon error, attempts to parse the body of a response into a meaningful status.

Jump to

Keyboard shortcuts

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