client

package
v0.0.0-...-d42ddae Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_API_VERSION = "1.3.0"
	DEFAULT_API_BASEURL = "https://api.upcloud.com"

	// The default timeout (in seconds)
	DEFAULT_TIMEOUT = 10
)

Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents an API client

func New

func New(userName, password string) *Client

New creates ands returns a new client configured with the specified user and password

func (*Client) CreateRequestUrl

func (c *Client) CreateRequestUrl(location string) string

CreateRequestUrl creates and returns a complete request URL for the specified API location

func (*Client) GetTimeout

func (c *Client) GetTimeout() time.Duration

GetTimeout returns current timeout

func (*Client) PerformDeleteRequest

func (c *Client) PerformDeleteRequest(url string) error

PerformDeleteRequest performs a DELETE request to the specified URL and returns the response body and eventual errors

func (*Client) PerformGetRequest

func (c *Client) PerformGetRequest(url string) ([]byte, error)

PerformGetRequest performs a GET request to the specified URL and returns the response body and eventual errors

func (*Client) PerformPostRequest

func (c *Client) PerformPostRequest(url string, requestBody []byte) ([]byte, error)

PerformPostRequest performs a POST request to the specified URL and returns the response body and eventual errors

func (*Client) PerformPostRequestJsontoXMLFIXME

func (c *Client) PerformPostRequestJsontoXMLFIXME(url string, requestBody []byte) ([]byte, error)

PerformPostRequest performs a POST request to the specified URL and returns the response body and eventual errors FIXME

func (*Client) PerformPutRequest

func (c *Client) PerformPutRequest(url string, requestBody []byte) ([]byte, error)

PerformPutRequest performs a PUT request to the specified URL and returns the response body and eventual errors

func (*Client) PerformPutRequestXMLtoJsonFIXME

func (c *Client) PerformPutRequestXMLtoJsonFIXME(url string, requestBody []byte) ([]byte, error)

PerformPutRequest performs a PUT request to the specified URL and returns the response body and eventual errors

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration)

SetTimeout sets the client timeout to the specified amount of seconds

type Error

type Error struct {
	ErrorCode    int
	ErrorMessage string
	ResponseBody []byte
}

Error represents an error returned from the client. Errors are thrown when requests don't have a successful status code

func (*Error) Error

func (e *Error) Error() string

Error implements the Error interface

Jump to

Keyboard shortcuts

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