volumes

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Endpoint = "/volumes"

Endpoint is the public path for the volumes service.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttachResponseItem added in v0.5.0

type AttachResponseItem struct {
	Status string `json:"status"`
	UUID   string `json:"uuid"`
	Name   string `json:"name"`

	kcclient.APIResponseCommon
}

AttachResponseItem is a data item from a response to a PUT /volumes/attach request. https://docs.kraft.cloud/api/v1/volumes/#attaching-a-volume-to-an-instance

type CreateResponseItem added in v0.5.0

type CreateResponseItem struct {
	Status string `json:"status"`
	UUID   string `json:"uuid"`
	Name   string `json:"name"`

	kcclient.APIResponseCommon
}

CreateResponseItem is a data item from a response to a POST /volumes request. https://docs.kraft.cloud/api/v1/volumes/#creating-volumes

type DeleteResponseItem added in v0.5.0

type DeleteResponseItem struct {
	Status string `json:"status"`
	UUID   string `json:"uuid"`
	Name   string `json:"name"`

	kcclient.APIResponseCommon
}

DeleteResponseItem is a data item from a response to a DELETE /volumes request. https://docs.kraft.cloud/api/v1/volumes/#deleting-a-volume

type DetachResponseItem added in v0.5.0

type DetachResponseItem struct {
	Status string `json:"status"`
	UUID   string `json:"uuid"`
	Name   string `json:"name"`

	kcclient.APIResponseCommon
}

DetachResponseItem is a data item from a response to a PUT /volumes/detach request. https://docs.kraft.cloud/api/v1/volumes/#detaching-a-volume-from-an-instance

type GetResponseItem added in v0.5.0

type GetResponseItem struct {
	Status     string               `json:"status"`
	State      string               `json:"state"`
	UUID       string               `json:"uuid"`
	Name       string               `json:"name"`
	SizeMB     int                  `json:"size_mb"`
	AttachedTo []InstanceAttachment `json:"attached_to"`
	Persistent bool                 `json:"persistent"`
	CreatedAt  string               `json:"created_at"`

	kcclient.APIResponseCommon
}

GetResponseItem is a data item from a response to a GET /volumes request. https://docs.kraft.cloud/api/v1/volumes/#getting-the-status-of-a-volume

type InstanceAttachment added in v0.5.0

type InstanceAttachment struct {
	UUID string `json:"uuid"`
	Name string `json:"name"`
}

type ListResponseItem added in v0.5.0

type ListResponseItem struct {
	UUID string `json:"uuid"`
	Name string `json:"name"`

	kcclient.APIResponseCommon
}

ListResponseItem is a data item from a response to a GET /volumes/list request. https://docs.kraft.cloud/api/v1/volumes/#list-existing-volumes

type State

type State string

A volume can be in one of the following states.

const (
	// The volume is scheduled to be created.
	StateUninitialized State = "uninitialized"

	// The volume is currently created and formatted.
	StateInitializing State = "initializing"

	// The volume is healthy and available to be attached to an instance.
	StateAvailable State = "available"

	// The volume is healthy and attached to an instance. It is possible to detach
	// detach it in this state.
	StateIdle State = "idle"

	// The volume is currently mounted in a running unikernel.
	StateMounted State = "mounted"

	// There are maintenance tasks running on the volume.
	StateBusy State = "busy"
)

type VolumesService

type VolumesService interface {
	kcclient.ServiceClient[VolumesService]

	// Creates one or more volumes with the given configuration. The volumes are
	// automatically initialized with an empty file system. After initialization
	// completed the volumes are in the available state and can be attached to an
	// instance with the attach endpoint. Note that, the size of a volume cannot
	// be changed after creation.
	//
	// See: https://docs.kraft.cloud/api/v1/volumes/#creating-volumes
	Create(ctx context.Context, name string, sizeMB int) (*kcclient.ServiceResponse[CreateResponseItem], error)

	// Get returns the current state and the configuration of volumes.
	//
	// See: https://docs.kraft.cloud/api/v1/volumes/#getting-the-status-of-a-volume
	Get(ctx context.Context, ids ...string) (*kcclient.ServiceResponse[GetResponseItem], error)

	// Attach attaches a volume to an instance so that the volume is mounted
	// when the instance starts using the volume and instance name.  The volume
	// needs to be in available state and the instance must in stopped state.
	// Currently, each instance can have only one volume attached at most.
	//
	// See: https://docs.kraft.cloud/api/v1/volumes/#attaching-a-volume-to-an-instance
	Attach(ctx context.Context, volID, instanceUUID, at string, readOnly bool) (*kcclient.ServiceResponse[AttachResponseItem], error)

	// Detach detaches a volume from an instance.
	// The instance from which to detach must in stopped state. If the volume
	// has been created together with an instance, detaching the volume will
	// make it persistent (i.e., it survives the deletion of the instance).
	//
	// See: https://docs.kraft.cloud/api/v1/volumes/#detaching-a-volume-from-an-instance
	Detach(ctx context.Context, id string) (*kcclient.ServiceResponse[DetachResponseItem], error)

	// Delete deletes the specified volume(s).
	// Fails if any of the specified volumes is still attached to an instance.
	// After this call the UUID of the volumes is no longer valid.
	//
	// See: https://docs.kraft.cloud/api/v1/volumes/#deleting-a-volume
	Delete(ctx context.Context, ids ...string) (*kcclient.ServiceResponse[DeleteResponseItem], error)

	// Lists all existing volumes. You can filter by persistence and volume
	// state. The returned volumes fulfill all provided filter criteria. No
	// particular value is assumed if a filter is not part of the request.
	//
	// See: https://docs.kraft.cloud/api/v1/volumes/#list-existing-volumes
	List(ctx context.Context) (*kcclient.ServiceResponse[GetResponseItem], error)
}

func NewVolumesClientFromOptions

func NewVolumesClientFromOptions(opts *options.Options) VolumesService

NewVolumesClientFromOptions instantiates a new users services client based on the provided pre-existing options.

Jump to

Keyboard shortcuts

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