-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsnapshots.ts
More file actions
102 lines (91 loc) · 2.64 KB
/
Copy pathsnapshots.ts
File metadata and controls
102 lines (91 loc) · 2.64 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
// 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 SnapshotsAPI from '../snapshots';
import * as InstancesAPI from './instances';
import { APIPromise } from '../../core/api-promise';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class Snapshots extends APIResource {
/**
* Create a snapshot for an instance
*
* @example
* ```ts
* const snapshot = await client.instances.snapshots.create(
* 'id',
* { kind: 'Standby' },
* );
* ```
*/
create(
id: string,
body: SnapshotCreateParams,
options?: RequestOptions,
): APIPromise<SnapshotsAPI.Snapshot> {
return this._client.post(path`/instances/${id}/snapshots`, { body, ...options });
}
/**
* Restore an instance from a snapshot in-place
*
* @example
* ```ts
* const instance = await client.instances.snapshots.restore(
* 'snapshotId',
* { id: 'id' },
* );
* ```
*/
restore(
snapshotID: string,
params: SnapshotRestoreParams,
options?: RequestOptions,
): APIPromise<InstancesAPI.Instance> {
const { id, ...body } = params;
return this._client.post(path`/instances/${id}/snapshots/${snapshotID}/restore`, { body, ...options });
}
}
export interface SnapshotCreateParams {
/**
* Snapshot capture kind
*/
kind: SnapshotsAPI.SnapshotKind;
/**
* Compression settings to use for this snapshot. Overrides instance and server
* defaults.
*/
compression?: Shared.SnapshotCompressionConfig;
/**
* Optional snapshot name (lowercase letters, digits, and dashes only; cannot start
* or end with a dash)
*/
name?: string;
/**
* User-defined key-value tags.
*/
tags?: { [key: string]: string };
}
export interface SnapshotRestoreParams {
/**
* Path param: Source instance ID or name
*/
id: string;
/**
* Body param: Optional hypervisor override. Allowed only when restoring from a
* Stopped snapshot. Standby snapshots must restore with their original hypervisor.
*/
target_hypervisor?: 'cloud-hypervisor' | 'firecracker' | 'qemu' | 'qemu-microvm' | 'vz';
/**
* Body param: Optional final state after restore. Defaults by snapshot kind:
*
* - Standby snapshot defaults to Running
* - Stopped snapshot defaults to Stopped
*/
target_state?: 'Stopped' | 'Standby' | 'Running';
}
export declare namespace Snapshots {
export {
type SnapshotCreateParams as SnapshotCreateParams,
type SnapshotRestoreParams as SnapshotRestoreParams,
};
}