client

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package client provides the interfaces to communicate with the API of Hivelocity. Creating interfaces makes unit testing via mocking possible.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSuchDevice = errors.New("no such device")

ErrNoSuchDevice means that no device was found via the Hivelocity API.

Functions

This section is empty.

Types

type Client

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

Client implements the Interface interface.

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a struct which implements the Client interface.

func (*Client) GetBareMetalDevice

func (c *Client) GetBareMetalDevice(
	ctx context.Context,
	deviceID int32,
) (*hv.BareMetalDevice, error)

GetBareMetalDevice returns the device fetched via the Hivelocity API.

func (*Client) ListDevices

func (c *Client) ListDevices(ctx context.Context) ([]hv.BareMetalDevice, error)

ListDevices lists all devices via Hivelocity API.

type Interface

type Interface interface {
	GetBareMetalDevice(ctx context.Context, deviceID int32) (*hv.BareMetalDevice, error)
	ListDevices(context.Context) ([]hv.BareMetalDevice, error)
}

Interface is a wrapper of hv.APIClient. In this way, mocking (for tests) is easier.

type LoggingTransport

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

LoggingTransport is a struct for creating new logger for Hivelocity API.

func (*LoggingTransport) RoundTrip

func (lt *LoggingTransport) RoundTrip(req *http.Request) (resp *http.Response, err error)

RoundTrip is used for logging api calls to Hivelocity API.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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