publichttp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthTokenTransport

func NewAuthTokenTransport(t http.RoundTripper, token string) http.RoundTripper

Types

type AuthTokenTransport

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

func (*AuthTokenTransport) RoundTrip

func (t *AuthTokenTransport) RoundTrip(req *http.Request) (*http.Response, error)

type Client

type Client struct {

	// Services used for talking to different parts of the Enapter API.
	Commands CommandsAPI
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

func NewClientWithURL

func NewClientWithURL(httpClient *http.Client, baseURL string) (*Client, error)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body io.Reader) (*http.Request, error)

func (*Client) NewRequestWithContext

func (c *Client) NewRequestWithContext(
	ctx context.Context, method, path string, body io.Reader,
) (*http.Request, error)

type CommandProgress

type CommandProgress struct {
	CommandResponse
	Error error
}

type CommandQuery

type CommandQuery struct {
	HardwareID  string                 `json:"hardware_id"`
	CommandName string                 `json:"command_name"`
	Arguments   map[string]interface{} `json:"arguments"`
}

type CommandResponse

type CommandResponse struct {
	State   CommandState           `json:"state"`
	Payload map[string]interface{} `json:"payload,omitempty"`
}

type CommandState

type CommandState string
const (
	CommandSucceeded     CommandState = "succeeded"
	CommandError         CommandState = "error"
	CommandPlatformError CommandState = "platform_error"
	CommandStarted       CommandState = "started"
	CommandInProgress    CommandState = "device_in_progress"
)

type CommandsAPI

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

func (*CommandsAPI) Execute

func (c *CommandsAPI) Execute(
	ctx context.Context, query CommandQuery,
) (CommandResponse, error)

func (*CommandsAPI) ExecuteWithProgress

func (c *CommandsAPI) ExecuteWithProgress(
	ctx context.Context, query CommandQuery,
) (<-chan CommandProgress, error)

type Error

type Error struct {
	Code    string                 `json:"code"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details,omitempty"`
}

type ResponseError

type ResponseError struct {
	Errors     []Error       `json:"errors"`
	StatusCode int           `json:"-"`
	RetryAfter time.Duration `json:"-"`
}

func (ResponseError) Error

func (r ResponseError) Error() string

Jump to

Keyboard shortcuts

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