client

package
v1.103.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: Apache-2.0 Imports: 11 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBody

func DecodeBody(resp *http.Response, out interface{}) error

DecodeBody is used to JSON decode a body

func EncodeBody

func EncodeBody(obj interface{}) (io.Reader, error)

EncodeBody is used to encode a request body

func RequireOK

func RequireOK(resp *http.Response, err error) (*http.Response, error)

RequireOK is used to verify response status code is a successful one (200 OK)

Types

type Client

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

Client provides a client to the API.

func New

func New(cfg *spotinst.Config) *Client

New returns a new client.

func (*Client) Do

func (c *Client) Do(ctx context.Context, r *Request) (*http.Response, error)

Do runs a request with our client.

type Error

type Error struct {
	Response  *http.Response `json:"-"`
	Code      string         `json:"code"`
	Message   string         `json:"message"`
	Field     string         `json:"field"`
	RequestID string         `json:"requestId"`
}

func (Error) Error

func (e Error) Error() string

type Errors

type Errors []Error

func (Errors) Error

func (es Errors) Error() string

type Request

type Request struct {
	Obj    interface{}
	Params url.Values
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(method, path string) *Request

NewRequest is used to create a new request.

type Response

type Response struct {
	Request struct {
		ID string `json:"id"`
	} `json:"request"`
	Response struct {
		Errors []responseError   `json:"errors"`
		Items  []json.RawMessage `json:"items"`
	} `json:"response"`
}

Jump to

Keyboard shortcuts

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