Skip to content
Get started

Create volume from archive

client.Volumes.NewFromArchive(ctx, body, body) (*Volume, error)
post/volumes/from-archive

Creates a new volume pre-populated with content from a tar.gz archive. The archive is streamed directly into the volume's root directory.

ParametersExpand Collapse
body Reader
formatbinary
body VolumeNewFromArchiveParams
Name param.Field[string]

Query param: Volume name

SizeGB param.Field[int64]

Query param: Maximum size in GB (extraction fails if content exceeds this)

ID param.Field[string]optional

Query param: Optional custom volume ID (auto-generated if not provided)

ReturnsExpand Collapse
type Volume struct{…}
ID string

Unique identifier

CreatedAt Time

Creation timestamp (RFC3339)

formatdate-time
Name string

Volume name

SizeGB int64

Size in gigabytes

Attachments []VolumeAttachmentoptional

List of current attachments (empty if not attached)

InstanceID string

ID of the instance this volume is attached to

MountPath string

Mount path in the guest

Readonly bool

Whether the attachment is read-only

Create volume from archive
package main

import (
  "bytes"
  "context"
  "fmt"
  "io"

  "github.com/kernel/hypeman-go"
  "github.com/kernel/hypeman-go/option"
)

func main() {
  client := hypeman.NewClient(
    option.WithAPIKey("My API Key"),
  )
  volume, err := client.Volumes.NewFromArchive(
    context.TODO(),
    io.Reader(bytes.NewBuffer([]byte("some file contents"))),
    hypeman.VolumeNewFromArchiveParams{
      Name: "name",
      SizeGB: 0,
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", volume.ID)
}
{
  "id": "vol-data-1",
  "created_at": "2025-01-15T09:00:00Z",
  "name": "my-data-volume",
  "size_gb": 10,
  "attachments": [
    {
      "instance_id": "inst-abc123",
      "mount_path": "/mnt/data",
      "readonly": false
    }
  ]
}
Returns Examples
{
  "id": "vol-data-1",
  "created_at": "2025-01-15T09:00:00Z",
  "name": "my-data-volume",
  "size_gb": 10,
  "attachments": [
    {
      "instance_id": "inst-abc123",
      "mount_path": "/mnt/data",
      "readonly": false
    }
  ]
}