client

package
v5.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents the client for a draupnir server

func NewClient

func NewClient(url string, token oauth2.Token, insecure bool) Client

NewClient constructs a new draupnir client, pointing at the given endpoint

func (Client) CreateAccessToken

func (c Client) CreateAccessToken(state string) (oauth2.Token, error)

CreateAccessToken creates an oauth access token

func (Client) CreateImage

func (c Client) CreateImage(backedUpAt time.Time, anon []byte) (models.Image, error)

CreateImage creates a new image. This does not complete the process of preparing an image, subsequent upload and finalisation steps are required.

func (Client) CreateInstance

func (c Client) CreateInstance(image models.Image) (models.Instance, error)

CreateInstance creates a new instance

func (Client) DestroyImage

func (c Client) DestroyImage(image models.Image) error

DestroyImage destroys an image

func (Client) DestroyInstance

func (c Client) DestroyInstance(instance models.Instance) error

DestroyInstance destroys an instance

func (Client) FinaliseImage

func (c Client) FinaliseImage(imageID int) (models.Image, error)

FinaliseImage posts to images/id/done, causing draupnir to run the finalisation process to anonymise and prepare the image for usage.

func (Client) GetImage

func (c Client) GetImage(id string) (models.Image, error)

func (Client) GetInstance

func (c Client) GetInstance(id string) (models.Instance, error)

func (Client) GetLatestImage

func (c Client) GetLatestImage() (models.Image, error)

func (Client) ListImages

func (c Client) ListImages() ([]models.Image, error)

ListImages returns a list of all images

func (Client) ListInstances

func (c Client) ListInstances() ([]models.Instance, error)

ListInstances returns a list of all instances

type DraupnirClient

type DraupnirClient interface {
	GetImage(id string) (models.Image, error)
	GetInstance(id string) (models.Instance, error)
	ListImages() ([]models.Image, error)
	ListInstances() ([]models.Instance, error)
	CreateInstance(image models.Image) (models.Instance, error)
	DestroyInstance(instance models.Instance) error
	DestroyImage(image models.Image) error
	CreateAccessToken(string) (string, error)
}

DraupnirClient defines the API that a draupnir client conforms to

Jump to

Keyboard shortcuts

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