Skip to content

List All Snapshots

client.GPUDroplets.Snapshots.List(ctx, query) (*GPUDropletSnapshotListResponse, error)
get/v2/snapshots

To list all of the snapshots available on your account, send a GET request to /v2/snapshots.

The response will be a JSON object with a key called snapshots. This will be set to an array of snapshot objects, each of which will contain the standard snapshot attributes.

Filtering Results by Resource Type

It's possible to request filtered results by including certain query parameters.

List Droplet Snapshots

To retrieve only snapshots based on Droplets, include the resource_type query parameter set to droplet. For example, /v2/snapshots?resource_type=droplet.

List Volume Snapshots

To retrieve only snapshots based on volumes, include the resource_type query parameter set to volume. For example, /v2/snapshots?resource_type=volume.

ParametersExpand Collapse
query GPUDropletSnapshotListParams
Page param.Field[int64]optional

Which 'page' of paginated results to return.

minimum1
PerPage param.Field[int64]optional

Number of items returned per page

minimum1
maximum200
ResourceType param.Field[GPUDropletSnapshotListParamsResourceType]optional

Used to filter snapshots by a resource type.

const GPUDropletSnapshotListParamsResourceTypeDroplet GPUDropletSnapshotListParamsResourceType = "droplet"
const GPUDropletSnapshotListParamsResourceTypeVolume GPUDropletSnapshotListParamsResourceType = "volume"
ReturnsExpand Collapse
type GPUDropletSnapshotListResponse struct{…}

Information about the response itself.

Total int64optional

Number of objects returned by the request.

Accepts one of the following:
Snapshots []Snapshotsoptional
ID string

The unique identifier for the snapshot.

CreatedAt Time

A time value given in ISO8601 combined date and time format that represents when the snapshot was created.

formatdate-time
MinDiskSize int64

The minimum size in GB required for a volume or Droplet to use this snapshot.

Name string

A human-readable name for the snapshot.

Regions []string

An array of the regions that the snapshot is available in. The regions are represented by their identifying slug values.

ResourceID string

The unique identifier for the resource that the snapshot originated from.

ResourceType SnapshotsResourceType

The type of resource that the snapshot originated from.

Accepts one of the following:
const SnapshotsResourceTypeDroplet SnapshotsResourceType = "droplet"
const SnapshotsResourceTypeVolume SnapshotsResourceType = "volume"
SizeGigabytes float64

The billable size of the snapshot in gigabytes.

formatfloat
Tags []string

An array of Tags the snapshot has been tagged with.

Requires tag:read scope.

List All Snapshots
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/-go"
  "github.com/stainless-sdks/-go/option"
)

func main() {
  client := gradient.NewClient(
    option.WithAccessToken("My Access Token"),
  )
  snapshots, err := client.GPUDroplets.Snapshots.List(context.TODO(), gradient.GPUDropletSnapshotListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", snapshots.Meta)
}
{
  "snapshots": [
    {
      "id": "6372321",
      "name": "web-01-1595954862243",
      "created_at": "2020-07-28T16:47:44Z",
      "regions": [
        "nyc3",
        "sfo3"
      ],
      "resource_id": "200776916",
      "resource_type": "droplet",
      "min_disk_size": 25,
      "size_gigabytes": 2.34,
      "tags": [
        "web",
        "env:prod"
      ]
    },
    {
      "id": "fbe805e8-866b-11e6-96bf-000f53315a41",
      "name": "pvc-01-1595954862243",
      "created_at": "2019-09-28T23:14:30Z",
      "regions": [
        "nyc1"
      ],
      "resource_id": "89bcc42f-85cf-11e6-a004-000f53315871",
      "resource_type": "volume",
      "min_disk_size": 2,
      "size_gigabytes": 0.1008,
      "tags": [
        "k8s"
      ]
    }
  ],
  "links": {},
  "meta": {
    "total": 2
  }
}
Returns Examples
{
  "snapshots": [
    {
      "id": "6372321",
      "name": "web-01-1595954862243",
      "created_at": "2020-07-28T16:47:44Z",
      "regions": [
        "nyc3",
        "sfo3"
      ],
      "resource_id": "200776916",
      "resource_type": "droplet",
      "min_disk_size": 25,
      "size_gigabytes": 2.34,
      "tags": [
        "web",
        "env:prod"
      ]
    },
    {
      "id": "fbe805e8-866b-11e6-96bf-000f53315a41",
      "name": "pvc-01-1595954862243",
      "created_at": "2019-09-28T23:14:30Z",
      "regions": [
        "nyc1"
      ],
      "resource_id": "89bcc42f-85cf-11e6-a004-000f53315871",
      "resource_type": "volume",
      "min_disk_size": 2,
      "size_gigabytes": 0.1008,
      "tags": [
        "k8s"
      ]
    }
  ],
  "links": {},
  "meta": {
    "total": 2
  }
}