snapshots
Creates, updates, deletes, gets or lists a snapshots
resource.
Overview
Name | snapshots |
Type | Resource |
Id | digitalocean.compute.snapshots |
Fields
The following fields are returned by SELECT
queries:
- snapshots_get
- snapshots_list
A JSON object with a key called snapshot
.
Name | Datatype | Description |
---|---|---|
id | string | The unique identifier for the snapshot. (example: 6372321) |
name | string | A human-readable name for the snapshot. (example: web-01-1595954862243) |
resource_id | string | The unique identifier for the resource that the snapshot originated from. (example: 200776916) |
created_at | string (date-time) | A time value given in ISO8601 combined date and time format that represents when the snapshot was created. (example: 2020-07-28T16:47:44Z) |
min_disk_size | integer | The minimum size in GB required for a volume or Droplet to use this snapshot. |
regions | array | An array of the regions that the snapshot is available in. The regions are represented by their identifying slug values. |
resource_type | string | The type of resource that the snapshot originated from. (example: droplet) |
size_gigabytes | number (float) | The billable size of the snapshot in gigabytes. |
tags | array | An array of Tags the snapshot has been tagged with. Requires tag:read scope. |
A JSON object with a key of snapshots
.
Name | Datatype | Description |
---|---|---|
id | string | The unique identifier for the snapshot. (example: 6372321) |
name | string | A human-readable name for the snapshot. (example: web-01-1595954862243) |
resource_id | string | The unique identifier for the resource that the snapshot originated from. (example: 200776916) |
created_at | string (date-time) | A time value given in ISO8601 combined date and time format that represents when the snapshot was created. (example: 2020-07-28T16:47:44Z) |
min_disk_size | integer | The minimum size in GB required for a volume or Droplet to use this snapshot. |
regions | array | An array of the regions that the snapshot is available in. The regions are represented by their identifying slug values. |
resource_type | string | The type of resource that the snapshot originated from. (example: droplet) |
size_gigabytes | number (float) | The billable size of the snapshot in gigabytes. |
tags | array | An array of Tags the snapshot has been tagged with. Requires tag:read scope. |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
snapshots_get | select | snapshot_id | To retrieve information about a snapshot, send a GET request to/v2/snapshots/$SNAPSHOT_ID .The response will be a JSON object with a key called snapshot . The value ofthis will be an snapshot object containing the standard snapshot attributes. | |
snapshots_list | select | per_page , page , resource_type | 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 beset to an array of snapshot objects, each of which will contain the standardsnapshot 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 . | |
snapshots_delete | delete | snapshot_id | Both Droplet and volume snapshots are managed through the /v2/snapshots/ endpoint. To delete a snapshot, send a DELETE request to /v2/snapshots/$SNAPSHOT_ID .A status of 204 will be given. This indicates that the request was processed successfully, but that no response body is needed. |
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
snapshot_id |
| Either the ID of an existing snapshot. This will be an integer for a Droplet snapshot or a string for a volume snapshot. (example: 6372321) |
page | integer | Which 'page' of paginated results to return. (example: 1) |
per_page | integer | Number of items returned per page (example: 2) |
resource_type | string | Used to filter snapshots by a resource type. (example: droplet) |
SELECT
examples
- snapshots_get
- snapshots_list
To retrieve information about a snapshot, send a GET request to/v2/snapshots/$SNAPSHOT_ID
.
The response will be a JSON object with a key called snapshot
. The value of
this will be an snapshot object containing the standard snapshot attributes.
SELECT
id,
name,
resource_id,
created_at,
min_disk_size,
regions,
resource_type,
size_gigabytes,
tags
FROM digitalocean.compute.snapshots
WHERE snapshot_id = '{{ snapshot_id }}' -- required;
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
.
SELECT
id,
name,
resource_id,
created_at,
min_disk_size,
regions,
resource_type,
size_gigabytes,
tags
FROM digitalocean.compute.snapshots
WHERE per_page = '{{ per_page }}'
AND page = '{{ page }}'
AND resource_type = '{{ resource_type }}';
DELETE
examples
- snapshots_delete
Both Droplet and volume snapshots are managed through the /v2/snapshots/
endpoint. To delete a snapshot, send a DELETE request to/v2/snapshots/$SNAPSHOT_ID
.
A status of 204 will be given. This indicates that the request was processed
successfully, but that no response body is needed.
DELETE FROM digitalocean.compute.snapshots
WHERE snapshot_id = '{{ snapshot_id }}' --required;