volume

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package volume represents our SiteHost `/cloud/volume` API endpoint — persistent volumes that can be attached to cloud containers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddOptions

type AddOptions struct {
	ServerName     string
	VolumeName     string
	ContainerNames []string
}

AddOptions describes a new volume to create. ContainerNames is an optional list of container identifiers to attach the volume to at creation time.

type Client

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

Client is a Service to work with the SiteHost Cloud Volume API.

func New

func New(c *api.Client) *Client

New is an initialisation function.

func (*Client) Add

func (s *Client) Add(ctx context.Context, opt AddOptions) (response JobResponse, err error)

Add creates a new volume on the specified server via "cloud/volume/add.json". ServerName and VolumeName are required; ContainerNames optionally attaches the volume to containers at creation time.

The API queues an asynchronous scheduler job; the returned JobResponse carries the job ID for tracking.

func (*Client) Delete

func (s *Client) Delete(ctx context.Context, opt DeleteOptions) (response JobResponse, err error)

Delete removes a volume via "cloud/volume/delete.json". Both Server and Volume are required. Note the parameter names follow the get convention (server / volume) rather than the add convention (server_name / volume_name) — see the DeleteOptions doc comment.

func (*Client) Get

func (s *Client) Get(ctx context.Context, opt GetOptions) (response GetResponse, err error)

Get retrieves the details for a single volume via "cloud/volume/get.json". Both Server and Volume are required.

func (*Client) List

func (s *Client) List(ctx context.Context, opt *ListOptions) (response ListResponse, err error)

List retrieves all volumes for the authenticated client via "cloud/volume/list_all.json", with optional filters.

func (*Client) Mount

func (s *Client) Mount(ctx context.Context, opt MountOptions) (response JobResponse, err error)

Mount attaches a volume to one or more containers via "cloud/volume/mount.json". ServerName, VolumeName, and at least one Container are required.

The API expects a nested form-encoded shape:

containers[<stack_name>][] = <container_name>

repeated for each (StackName, ContainerName) pair. Returned JobResponse carries the scheduler job ID.

func (*Client) UpdateMounts

func (s *Client) UpdateMounts(ctx context.Context, opt UpdateMountsOptions) (response JobResponse, err error)

UpdateMounts incrementally adds or removes container mount targets for a volume via "cloud/volume/update_mounts.json". ServerName and VolumeName are required; at least one of Add or Remove must contain a container.

Wire shape:

containers[add][<stack_name>][] = <container_name>
containers[remove][<stack_name>][] = <container_name>

Returned JobResponse carries the scheduler job ID.

type ContainerMount

type ContainerMount struct {
	StackName     string
	ContainerName string
}

ContainerMount describes a single container target for volume mount / unmount operations: the stack the container belongs to and the container's name.

type DeleteOptions

type DeleteOptions struct {
	Server string `url:"server"`
	Volume string `url:"volume"`
}

DeleteOptions identifies the volume to delete. Same parameter naming as GetOptions.

type GetOptions

type GetOptions struct {
	Server string `url:"server"`
	Volume string `url:"volume"`
}

GetOptions identifies the volume to fetch.

Note: get and delete use the unprefixed parameter names (server / volume) — distinct from add / mount / update_mounts which use server_name / volume_name. This reflects the API's actual surface; tags are explicit.

type GetResponse

type GetResponse struct {
	Return Volume `json:"return"`
	models.APIResponse
}

GetResponse represents the response from get.

type JobResponse

type JobResponse struct {
	Return struct {
		models.Job `json:"job"`
	} `json:"return"`
	models.APIResponse
}

JobResponse is the shared response shape for the write operations (add, delete, mount, update_mounts). Each queues an asynchronous scheduler job; the job ID is returned for tracking.

type ListOptions

type ListOptions struct {
	Name       string `url:"filters[name],omitempty"`
	ServerName string `url:"filters[server_name],omitempty"`
	Container  string `url:"filters[container],omitempty"`
	SortBy     string `url:"filters[sort_by],omitempty"`
	SortDir    string `url:"filters[sort_dir],omitempty"`
	PageSize   int    `url:"filters[page_size],omitempty"`
	PageNumber int    `url:"filters[page_number],omitempty"`
}

ListOptions represents optional filters for the list_all call. All fields are optional.

type ListResponse

type ListResponse struct {
	Return struct {
		models.Pagination
		Data []Volume `json:"data"`
	} `json:"return"`
	models.APIResponse
}

ListResponse represents the response from list_all.

type MountOptions

type MountOptions struct {
	ServerName string
	VolumeName string
	Containers []ContainerMount
}

MountOptions describes a volume to mount and the containers to mount it to.

type UpdateMountsOptions

type UpdateMountsOptions struct {
	ServerName string
	VolumeName string
	Add        []ContainerMount
	Remove     []ContainerMount
}

UpdateMountsOptions describes incremental mount changes — containers to attach (Add) and detach (Remove). Either or both may be set.

type Volume

type Volume struct {
	ID          string   `json:"id"`
	ClientID    string   `json:"client_id"`
	ServerID    string   `json:"server_id"`
	Pending     string   `json:"pending"`
	VolumeName  string   `json:"volume_name"`
	IsMissing   string   `json:"is_missing"`
	DateAdded   string   `json:"date_added"`
	DateUpdated string   `json:"date_updated"`
	ServerName  string   `json:"server_name"`
	ServerLabel string   `json:"server_label"`
	ServerOwner bool     `json:"server_owner"`
	Containers  []string `json:"containers"`
}

Volume describes a single cloud volume.

String-typed boolean fields (IsMissing) reflect the API's actual response shape ("0"/"1"). Pending is non-empty while an operation is in flight (e.g. "adding:29658430"); empty when stable.

Containers is a list of container identifiers the volume is currently attached to; empty when not mounted anywhere.

Jump to

Keyboard shortcuts

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