snapshot

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: 7 Imported by: 0

Documentation

Overview

Package snapshot represents our SiteHost `/server/snapshot` API endpoint — server-level disk snapshot management (list, create, delete, restore, lifetime).

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 is a Service to work with the SiteHost server snapshot API.

func New

func New(c *api.Client) *Client

New is an initialisation function.

func (*Client) Create

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

Create takes a new snapshot of a server's disk via "server/snapshot/create.json". Name (the server), Partition (disk slot, e.g. "scsi0"), and Lifetime (hours) are all required. Returned JobResponse carries the scheduler job ID.

func (*Client) Delete

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

Delete removes a snapshot via "server/snapshot/delete.json". Both Name (the server) and Snapshot (the snapshot ID) are required.

func (*Client) List

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

List retrieves all snapshots for the specified server via "server/snapshot/list_all.json". Name is required.

func (*Client) Restore

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

Restore restores a server to a previous snapshot via "server/snapshot/restore.json". Both Name (the server) and Snapshot (the snapshot ID) are required.

**This is destructive.** The server's disk state is reverted to the snapshot's contents. Any data written since the snapshot was taken will be lost. Treat as a write-mode operation requiring deliberate caller intent.

func (*Client) SetLifetime

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

SetLifetime adjusts the retention period of an existing snapshot via "server/snapshot/set_lifetime.json". All three fields are required: Name (the server), Snapshot (the snapshot ID), Lifetime (hours).

type CreateOptions

type CreateOptions struct {
	Name      string `url:"name"`
	Partition string `url:"partition"`
	Lifetime  int    `url:"lifetime"`
}

CreateOptions describes a new snapshot to take. All fields are required: Name (the server), Partition (disk slot, e.g. "scsi0"), and Lifetime (in hours).

type JobResponse

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

JobResponse is the shared response shape for write operations (create, delete, restore, set_lifetime). Each queues an asynchronous scheduler job.

type ListOptions

type ListOptions struct {
	Name string `url:"name"`
}

ListOptions identifies the server whose snapshots to list. Note the API uses the unprefixed parameter name "name" for the server identifier (not "server_name").

type ListResponse

type ListResponse struct {
	Return []Snapshot `json:"return"`
	models.APIResponse
}

ListResponse represents the response from list_all.

type SetLifetimeOptions

type SetLifetimeOptions struct {
	Name     string `url:"name"`
	Snapshot string `url:"snapshot"`
	Lifetime int    `url:"lifetime"`
}

SetLifetimeOptions describes a lifetime adjustment for an existing snapshot. Lifetime is in hours.

type Snapshot

type Snapshot struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Device       string `json:"device"`
	MountPoint   string `json:"mountpoint"`
	Size         int64  `json:"size"`
	FSType       string `json:"fstype"`
	DRBD         string `json:"drbd"`
	Parent       string `json:"parent"`
	Pending      string `json:"pending"`
	Created      string `json:"created"`
	Backup       string `json:"backup"`
	DiskTotal    string `json:"disk_total"`
	DiskUsed     string `json:"disk_used"`
	InodesTotal  string `json:"inodes_total"`
	InodesUsed   string `json:"inodes_used"`
	StatsUpdated string `json:"stats_updated"`
	DiskWarn     string `json:"disk_warn"`
	IsMissing    bool   `json:"is_missing"`
	Expires      string `json:"expires"`
}

Snapshot describes a single server snapshot.

Mixed value types reflect the API's actual response shape: most numeric / boolean fields are returned as strings ("0", "1") while Size is a JSON number and IsMissing is a real JSON bool. Pending is "1" while a job is in flight and "0" when stable.

type SnapshotOptions

type SnapshotOptions struct {
	Name     string `url:"name"`
	Snapshot string `url:"snapshot"`
}

SnapshotOptions identifies a snapshot for the operations that act on a single snapshot (delete, restore). The server is identified by Name; the snapshot by Snapshot.

Jump to

Keyboard shortcuts

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