-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathbackups.ts
More file actions
283 lines (245 loc) · 7.32 KB
/
backups.ts
File metadata and controls
283 lines (245 loc) · 7.32 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as Shared from '../shared';
import * as GPUDropletsAPI from './gpu-droplets';
import { APIPromise } from '../../core/api-promise';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class Backups extends APIResource {
/**
* To retrieve any backups associated with a Droplet, send a GET request to
* `/v2/droplets/$DROPLET_ID/backups`.
*
* You will get back a JSON object that has a `backups` key. This will be set to an
* array of backup objects, each of which contain the standard Droplet backup
* attributes.
*
* @example
* ```ts
* const backups = await client.gpuDroplets.backups.list(
* 3164444,
* );
* ```
*/
list(
dropletID: number,
query: BackupListParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<BackupListResponse> {
return this._client.get(path`/v2/droplets/${dropletID}/backups`, {
query,
defaultBaseURL: 'https://api.digitalocean.com',
...options,
});
}
/**
* To list information about the backup policies for all Droplets in the account,
* send a GET request to `/v2/droplets/backups/policies`.
*
* @example
* ```ts
* const response =
* await client.gpuDroplets.backups.listPolicies();
* ```
*/
listPolicies(
query: BackupListPoliciesParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<BackupListPoliciesResponse> {
return this._client.get('/v2/droplets/backups/policies', {
query,
defaultBaseURL: 'https://api.digitalocean.com',
...options,
});
}
/**
* To retrieve a list of all supported Droplet backup policies, send a GET request
* to `/v2/droplets/backups/supported_policies`.
*
* @example
* ```ts
* const response =
* await client.gpuDroplets.backups.listSupportedPolicies();
* ```
*/
listSupportedPolicies(options?: RequestOptions): APIPromise<BackupListSupportedPoliciesResponse> {
return this._client.get('/v2/droplets/backups/supported_policies', {
defaultBaseURL: 'https://api.digitalocean.com',
...options,
});
}
/**
* To show information about an individual Droplet's backup policy, send a GET
* request to `/v2/droplets/$DROPLET_ID/backups/policy`.
*
* @example
* ```ts
* const response =
* await client.gpuDroplets.backups.retrievePolicy(3164444);
* ```
*/
retrievePolicy(dropletID: number, options?: RequestOptions): APIPromise<BackupRetrievePolicyResponse> {
return this._client.get(path`/v2/droplets/${dropletID}/backups/policy`, {
defaultBaseURL: 'https://api.digitalocean.com',
...options,
});
}
}
export interface BackupListResponse {
/**
* Information about the response itself.
*/
meta: Shared.MetaProperties;
backups?: Array<BackupListResponse.Backup>;
links?: Shared.PageLinks;
}
export namespace BackupListResponse {
export interface Backup {
/**
* The unique identifier for the snapshot or backup.
*/
id: number;
/**
* A time value given in ISO8601 combined date and time format that represents when
* the snapshot was created.
*/
created_at: string;
/**
* The minimum size in GB required for a volume or Droplet to use this snapshot.
*/
min_disk_size: number;
/**
* A human-readable name for the snapshot.
*/
name: string;
/**
* An array of the regions that the snapshot is available in. The regions are
* represented by their identifying slug values.
*/
regions: Array<string>;
/**
* The billable size of the snapshot in gigabytes.
*/
size_gigabytes: number;
/**
* Describes the kind of image. It may be one of `snapshot` or `backup`. This
* specifies whether an image is a user-generated Droplet snapshot or automatically
* created Droplet backup.
*/
type: 'snapshot' | 'backup';
}
}
export interface BackupListPoliciesResponse {
/**
* Information about the response itself.
*/
meta: Shared.MetaProperties;
links?: Shared.PageLinks;
/**
* A map where the keys are the Droplet IDs and the values are objects containing
* the backup policy information for each Droplet.
*/
policies?: { [key: string]: BackupListPoliciesResponse.Policies };
}
export namespace BackupListPoliciesResponse {
export interface Policies {
/**
* A boolean value indicating whether backups are enabled for the Droplet.
*/
backup_enabled?: boolean;
/**
* An object specifying the backup policy for the Droplet.
*/
backup_policy?: GPUDropletsAPI.DropletBackupPolicy;
/**
* The unique identifier for the Droplet.
*/
droplet_id?: number;
/**
* An object containing keys with the start and end times of the window during
* which the backup will occur.
*/
next_backup_window?: Shared.DropletNextBackupWindow | null;
}
}
export interface BackupListSupportedPoliciesResponse {
supported_policies?: Array<BackupListSupportedPoliciesResponse.SupportedPolicy>;
}
export namespace BackupListSupportedPoliciesResponse {
export interface SupportedPolicy {
/**
* The name of the Droplet backup plan.
*/
name?: string;
/**
* The day of the week the backup will occur.
*/
possible_days?: Array<string>;
/**
* An array of integers representing the hours of the day that a backup can start.
*/
possible_window_starts?: Array<number>;
/**
* The number of days that a backup will be kept.
*/
retention_period_days?: number;
/**
* The number of hours that a backup window is open.
*/
window_length_hours?: number;
}
}
export interface BackupRetrievePolicyResponse {
policy?: BackupRetrievePolicyResponse.Policy;
}
export namespace BackupRetrievePolicyResponse {
export interface Policy {
/**
* A boolean value indicating whether backups are enabled for the Droplet.
*/
backup_enabled?: boolean;
/**
* An object specifying the backup policy for the Droplet.
*/
backup_policy?: GPUDropletsAPI.DropletBackupPolicy;
/**
* The unique identifier for the Droplet.
*/
droplet_id?: number;
/**
* An object containing keys with the start and end times of the window during
* which the backup will occur.
*/
next_backup_window?: Shared.DropletNextBackupWindow | null;
}
}
export interface BackupListParams {
/**
* Which 'page' of paginated results to return.
*/
page?: number;
/**
* Number of items returned per page
*/
per_page?: number;
}
export interface BackupListPoliciesParams {
/**
* Which 'page' of paginated results to return.
*/
page?: number;
/**
* Number of items returned per page
*/
per_page?: number;
}
export declare namespace Backups {
export {
type BackupListResponse as BackupListResponse,
type BackupListPoliciesResponse as BackupListPoliciesResponse,
type BackupListSupportedPoliciesResponse as BackupListSupportedPoliciesResponse,
type BackupRetrievePolicyResponse as BackupRetrievePolicyResponse,
type BackupListParams as BackupListParams,
type BackupListPoliciesParams as BackupListPoliciesParams,
};
}