client

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package client contains types and functions for interacting with the control-plane API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the provided error is of type APIError and its status is equal to http.StatusNotFound

Types

type APIError

type APIError struct {
	Message string `json:"error"`
	Status  int    `json:"status"`
}

The APIError type represents an error response from the HTTP API.

func (APIError) Error

func (e APIError) Error() string

type Client

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

The Client type is used to perform requests against the control-plane API.

func New

func New(ctx context.Context, baseURL string) *Client

New returns a new instance of the Client type that will perform requests against the API at the given base URL. The provided context.Context is checked for the presence of an oauth token. If it exists, the underlying HTTP client is bootstrapped with an oauth token that authenticates outbound requests.

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, uri string, body, out interface{}) error

Do sends an HTTP request to the given URI. If the body parameter is non-nil, it is JSON marshalled and used as the request body. If the out parameter is non-nil, the API response is JSON unmarshalled into it.

Jump to

Keyboard shortcuts

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