client

package
Version: v1.101.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: Apache-2.0 Imports: 11 Imported by: 17

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
t or T : Toggle theme light dark auto
y or Y : Canonical URL