-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathsnapshots.ts
More file actions
129 lines (117 loc) · 3.81 KB
/
snapshots.ts
File metadata and controls
129 lines (117 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as Shared from '../shared';
import { APIPromise } from '../../core/api-promise';
import { buildHeaders } from '../../internal/headers';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class Snapshots extends APIResource {
/**
* 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.
*
* @example
* ```ts
* const snapshot =
* await client.gpuDroplets.snapshots.retrieve(6372321);
* ```
*/
retrieve(snapshotID: number | string, options?: RequestOptions): APIPromise<SnapshotRetrieveResponse> {
return this._client.get(path`/v2/snapshots/${snapshotID}`, {
defaultBaseURL: 'https://api.digitalocean.com',
...options,
});
}
/**
* 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`.
*
* @example
* ```ts
* const snapshots = await client.gpuDroplets.snapshots.list();
* ```
*/
list(
query: SnapshotListParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<SnapshotListResponse> {
return this._client.get('/v2/snapshots', {
query,
defaultBaseURL: 'https://api.digitalocean.com',
...options,
});
}
/**
* 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.
*
* @example
* ```ts
* await client.gpuDroplets.snapshots.delete(6372321);
* ```
*/
delete(snapshotID: number | string, options?: RequestOptions): APIPromise<void> {
return this._client.delete(path`/v2/snapshots/${snapshotID}`, {
defaultBaseURL: 'https://api.digitalocean.com',
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
}
export interface SnapshotRetrieveResponse {
snapshot?: Shared.Snapshots;
}
export interface SnapshotListResponse {
/**
* Information about the response itself.
*/
meta: Shared.MetaProperties;
links?: Shared.PageLinks;
snapshots?: Array<Shared.Snapshots>;
}
export interface SnapshotListParams {
/**
* Which 'page' of paginated results to return.
*/
page?: number;
/**
* Number of items returned per page
*/
per_page?: number;
/**
* Used to filter snapshots by a resource type.
*/
resource_type?: 'droplet' | 'volume';
}
export declare namespace Snapshots {
export {
type SnapshotRetrieveResponse as SnapshotRetrieveResponse,
type SnapshotListResponse as SnapshotListResponse,
type SnapshotListParams as SnapshotListParams,
};
}