Hi there! We’ve been working behind the scenes to migrate the API endpoints for volumes to our Machines API.
This is better for you because our GraphQL API is only hosted in iad
region; and when you create a volume in syd
region while already nearby (say, deploying a new side project to production from your holiday in Bondi Beach), you shouldn’t need to make a request all the way to iad
if it’s just going to come back to a server near you.
It’s faster and more reliable, and it’s already how creating a Machine works today!
If you’re not already familiar with the Machines API, take a look at the guide on our docs.
We’ve also just released a flyctl prerelease version (v0.1.66-pre-1
) with these changes included. Install it with: curl -L https://fly.io/install.sh | sh -s pre
.
Endpoints
- List Volumes:
GET /v1/apps/{app_name}/volumes
→ returns[]Volume
- Create Volume:
POST /v1/apps/{app_name}/volumes
→ returnsVolume
- Get Volume:
GET /v1/apps/{app_name}/volumes/{volume_id}
→ returnsVolume
- Get Volume Snapshots:
GET /v1/apps/{app_name}/volumes/{volume_id}/snapshots
→ returns[]VolumeSnapshot
- Extend Volume:
PUT /v1/apps/{app_name}/volumes/{volume_id}/extend
→ returnsExtendVolumeResponse
- Delete Volume:
DELETE /v1/apps/{app_name}/volumes/{volume_id}
→ returnsVolume
Types
These types should be equivalent to the ones from our GraphQL API.
type Volume struct {
Id string `json:"id"`
Name string `json:"name"`
State string `json:"state"`
SizeGB int `json:"size_gb"`
Region string `json:"region"`
Zone string `json:"zone"`
Encrypted bool `json:"encrypted"`
AttachedMachine *string `json:"attached_machine_id"`
AttachedAlloc *string `json:"attached_alloc_id"`
CreatedAt time.Time `json:"created_at"`
Blocks int `json:"blocks"`
BlockSize int `json:"block_size"`
BlocksFree int `json:"blocks_free"`
BlocksAvail int `json:"blocks_avail"`
}
type VolumeSnapshot struct {
Id string `json:"id"`
Size int `json:"size"`
Digest string `json:"digest"`
CreatedAt string `json:"created_at"`
}
type CreateVolumeRequest struct {
Name string `json:"name"`
Region string `json:"region"`
SizeGB *int `json:"size_gb"`
Encrypted *bool `json:"encrypted"`
RequireUniqueZone *bool `json:"require_unique_zone"`
MachinesOnly *bool `json:"machines_only"`
// restore from snapshot
SnapshotID *string `json:"snapshot_id"`
// fork from remote volume
SourceVolumeId *string `json:"source_volume_id"`
ComputeRequirements *api.MachineGuest `json:"compute"`
}
type ExtendVolumeRequest struct {
SizeGB int `json:"size_gb"`
}
type ExtendVolumeResponse struct {
Volume Volume `json:"volume"`
NeedsRestart bool `json:"needs_restart"`
}
Please let us know if you find any bugs with these new endpoints.
A technical note you might find interesting: our API has internal numerical IDs for volumes, and up until today our GraphQL API was using an auto-incrementing ID generated by its PostgreSQL database. To create internal volume IDs without going all the way to iad
and back, each flyd
has a Snowflake ID generator that can mint you a new volume ID without talking to anyone else - much less a database on the other side of the world!