client

package
v9.4.46+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 18 Imported by: 73

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUnixServerPath

func GetUnixServerPath(socketName string, paths ...string) string

GetUnixServerPath returns a unix domain socket prepended with the provided path.

Types

type Client

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

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

func NewAuthClient

func NewAuthClient(host, version, authstring, accesstoken, userAgent string) (*Client, error)

NewAuthClient returns a new REST client for specified server.

func NewClient

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

NewClient returns a new REST client for specified server.

func (*Client) BaseURL

func (c *Client) BaseURL() string

func (*Client) Delete

func (c *Client) Delete() *Request

Delete 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) Patch

func (c *Client) Patch() *Request

Patch returns a Request object setup for PATCH 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) SetTLS

func (c *Client) SetTLS(tlsConfig *tls.Config)

func (*Client) Versions

func (c *Client) Versions(endpoint string) ([]string, error)

Versions send a request at the /versions REST endpoint.

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, authstring, userAgent string) *Request

NewRequest instance

func NewRequestWithContext

func NewRequestWithContext(
	ctx context.Context,
	client *http.Client,
	base *url.URL,
	verb string,
	version string,
	authstring,
	userAgent string,
) *Request

NewRequestWithContext takes in context which may describe a timeout

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) FormatError

func (r Response) FormatError() error

FormatError formats the error

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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