client

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2015 License: Apache-2.0, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultResponseLimit = 100

DefaultResponseLimit is the default number of responses to return on requests that can be limited.

Functions

func CheckConnection

func CheckConnection(client *http.Client, controllerURL url.URL) error

CheckConnection checks that the user is connected to a network and the URL points to a valid controller.

func CreateHTTPClient

func CreateHTTPClient(sslVerify bool) *http.Client

CreateHTTPClient creates a HTTP Client with proper SSL options.

func Delete

func Delete() error

Delete user's settings file.

func FindHome

func FindHome() string

FindHome returns the HOME directory of the current user

Types

type Client

type Client struct {
	// HTTP client used to communicate with the API.
	HTTPClient *http.Client

	// SSLVerify determines whether or not to verify SSL conections.
	SSLVerify bool

	// URL used to communicate with the controller.
	ControllerURL url.URL

	// Token is used to authenticate the request against the API.
	Token string

	// Username is the name of the user performing requests against the API.
	Username string

	// ResponseLimit is the number of results to return on requests that can be limited.
	ResponseLimit int
}

Client oversees the interaction between the client and controller

func New

func New() (*Client, error)

New creates a new client from a settings file.

func (Client) BasicRequest

func (c Client) BasicRequest(method string, path string, body []byte) (string, error)

BasicRequest makes a simple http request on the controller.

func (Client) LimitedRequest

func (c Client) LimitedRequest(path string, results int) (string, int, error)

LimitedRequest allows limiting the number of responses in a request.

func (Client) Request

func (c Client) Request(method string, path string, body []byte) (*http.Response, error)

Request makes a HTTP request on the controller.

func (Client) Save

func (c Client) Save() error

Save settings to a file

Jump to

Keyboard shortcuts

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