@origincloud/pvs 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,169 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/pvs/v1beta1/volume.proto
3
+ import { Operation, newRequestId, pathValue, query, } from "@origincloud/core";
4
+ /**
5
+ * Calls VolumeService.
6
+ *
7
+ * Block storage volumes: durable disks in one zone that an instance attaches
8
+ * to read and write.
9
+ */
10
+ export class VolumeClient {
11
+ /**
12
+ * The endpoint the client sends its calls to, which also serves the
13
+ * operations its methods answer with.
14
+ */
15
+ service;
16
+ /** A client of VolumeService that sends its calls through `client`. */
17
+ constructor(client) {
18
+ this.service = client.service("pvs", true);
19
+ }
20
+ /** Returns a volume. */
21
+ async getVolume(request, options) {
22
+ const p0 = pathValue("name", request.name, "projects/*/zones/*/volumes/*");
23
+ return this.service.call({
24
+ method: "GET",
25
+ path: `/v1beta1/${p0}`,
26
+ query: query(request, ["name"]),
27
+ idempotent: true,
28
+ }, options);
29
+ }
30
+ /**
31
+ * Lists the volumes in a zone, oldest first. Deleted volumes aren't
32
+ * listed. For every zone's volumes, list the zones whose `services` name
33
+ * `pvs` with the location service (`location.origincloudapis.eu`), then
34
+ * each zone's volumes.
35
+ */
36
+ async listVolumes(request, options) {
37
+ const p0 = pathValue("parent", request.parent, "projects/*/zones/*");
38
+ return this.service.call({
39
+ method: "GET",
40
+ path: `/v1beta1/${p0}/volumes`,
41
+ query: query(request, ["parent"]),
42
+ idempotent: true,
43
+ }, options);
44
+ }
45
+ /**
46
+ * Iterates over everything listVolumes lists from the request's page on,
47
+ * fetching the next page as the loop reaches it. A page that fails ends
48
+ * the iteration with its error.
49
+ */
50
+ async *allVolumes(request, options) {
51
+ for (let page = request;;) {
52
+ const response = await this.listVolumes(page, options);
53
+ yield* response.volumes ?? [];
54
+ if (!response.nextPageToken)
55
+ return;
56
+ page = { ...page, pageToken: response.nextPageToken };
57
+ }
58
+ }
59
+ /**
60
+ * Creates a volume, empty or as a copy of a snapshot. The operation is
61
+ * done once the volume is `AVAILABLE`, or failed once it is `ERROR`.
62
+ *
63
+ * It answers with an operation to wait on, whose result is the Volume.
64
+ */
65
+ async createVolume(request, options) {
66
+ if (!request.requestId)
67
+ request = { ...request, requestId: newRequestId() };
68
+ const p0 = pathValue("parent", request.parent, "projects/*/zones/*");
69
+ const op = await this.service.call({
70
+ method: "POST",
71
+ path: `/v1beta1/${p0}/volumes`,
72
+ body: request.volume,
73
+ query: query(request, ["parent", "volume"]),
74
+ idempotent: true,
75
+ }, options);
76
+ return new Operation(this.service, op, "origincloud.pvs.v1beta1.Volume");
77
+ }
78
+ /**
79
+ * Creates a volume whose initial content is a disk image the platform
80
+ * downloads. The operation is done once the volume is `AVAILABLE`.
81
+ *
82
+ * It answers with an operation to wait on, whose result is the Volume.
83
+ */
84
+ async importVolume(request, options) {
85
+ if (!request.requestId)
86
+ request = { ...request, requestId: newRequestId() };
87
+ const p0 = pathValue("parent", request.parent, "projects/*/zones/*");
88
+ const op = await this.service.call({
89
+ method: "POST",
90
+ path: `/v1beta1/${p0}/volumes:import`,
91
+ body: request,
92
+ idempotent: true,
93
+ }, options);
94
+ return new Operation(this.service, op, "origincloud.pvs.v1beta1.Volume");
95
+ }
96
+ /**
97
+ * Changes a volume's size or tags. A larger `sizeGib` grows the volume,
98
+ * attached or not; it never shrinks, and the size it already has changes
99
+ * nothing. The operation is done once the volume reports the new size.
100
+ *
101
+ * It answers with an operation to wait on, whose result is the Volume.
102
+ */
103
+ async updateVolume(request, options) {
104
+ if (!request.requestId)
105
+ request = { ...request, requestId: newRequestId() };
106
+ const p0 = pathValue("volume.name", request.volume?.name, "projects/*/zones/*/volumes/*");
107
+ const op = await this.service.call({
108
+ method: "PATCH",
109
+ path: `/v1beta1/${p0}`,
110
+ body: request.volume,
111
+ query: query(request, ["volume.name", "volume"]),
112
+ idempotent: true,
113
+ }, options);
114
+ return new Operation(this.service, op, "origincloud.pvs.v1beta1.Volume");
115
+ }
116
+ /**
117
+ * Deletes a volume. It must not be attached, and none of its snapshots
118
+ * may be left. The operation is done once the volume is `DELETED`.
119
+ *
120
+ * It answers with an operation to wait on, which has no result.
121
+ */
122
+ async deleteVolume(request, options) {
123
+ if (!request.requestId)
124
+ request = { ...request, requestId: newRequestId() };
125
+ const p0 = pathValue("name", request.name, "projects/*/zones/*/volumes/*");
126
+ const op = await this.service.call({
127
+ method: "DELETE",
128
+ path: `/v1beta1/${p0}`,
129
+ query: query(request, ["name"]),
130
+ idempotent: true,
131
+ }, options);
132
+ return new Operation(this.service, op, "google.protobuf.Empty");
133
+ }
134
+ }
135
+ /** Where the volume is in its lifecycle. */
136
+ export const Volume_State = {
137
+ /** Not set. */
138
+ STATE_UNSPECIFIED: "STATE_UNSPECIFIED",
139
+ /** Being created. */
140
+ CREATING: "CREATING",
141
+ /** Ready to attach. */
142
+ AVAILABLE: "AVAILABLE",
143
+ /** Attached to an instance. */
144
+ IN_USE: "IN_USE",
145
+ /** Being deleted. */
146
+ DELETING: "DELETING",
147
+ /** Deleted. Readable by name for a day, never listed. */
148
+ DELETED: "DELETED",
149
+ /**
150
+ * Its storage couldn't be created or removed; `stateReason` says
151
+ * which. It can be deleted again.
152
+ */
153
+ ERROR: "ERROR",
154
+ };
155
+ /** Where a resize is. */
156
+ export const Volume_ResizeState = {
157
+ /** Not set. */
158
+ RESIZE_STATE_UNSPECIFIED: "RESIZE_STATE_UNSPECIFIED",
159
+ /** No resize is under way; the last one, if any, finished. */
160
+ RESIZE_COMPLETED: "RESIZE_COMPLETED",
161
+ /** Growing to `pendingSizeGib`. */
162
+ RESIZING: "RESIZING",
163
+ /**
164
+ * The last resize failed; `resizeReason` says why. The volume and its
165
+ * data are unaffected.
166
+ */
167
+ RESIZE_FAILED: "RESIZE_FAILED",
168
+ };
169
+ //# sourceMappingURL=volume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,8BAA8B,CAAC,CAAC;QAC3E,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAChC;YACE,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,YAAY,EAAE,EAAE;YACtB,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;YAC/B,UAAU,EAAE,IAAI;SACjB,EACD,OAAO,CACR,CAAC;QACF,OAAO,IAAI,SAAS,CAA2B,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,uBAAuB,CAAC,CAAC;IAC5F,CAAC;CACF;AAsED,4CAA4C;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,eAAe;IACf,iBAAiB,EAAE,mBAAmB;IACtC,qBAAqB;IACrB,QAAQ,EAAE,UAAU;IACpB,uBAAuB;IACvB,SAAS,EAAE,WAAW;IACtB,+BAA+B;IAC/B,MAAM,EAAE,QAAQ;IAChB,qBAAqB;IACrB,QAAQ,EAAE,UAAU;IACpB,yDAAyD;IACzD,OAAO,EAAE,SAAS;IAClB;;;OAGG;IACH,KAAK,EAAE,OAAO;CACN,CAAC;AAKX,yBAAyB;AACzB,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,eAAe;IACf,wBAAwB,EAAE,0BAA0B;IACpD,8DAA8D;IAC9D,gBAAgB,EAAE,kBAAkB;IACpC,mCAAmC;IACnC,QAAQ,EAAE,UAAU;IACpB;;;OAGG;IACH,aAAa,EAAE,eAAe;CACtB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@origincloud/pvs",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Origin Cloud's persistent volume service (PVS): volumes, snapshots and storage classes.",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://github.com/origincloudhq/sdk-typescript#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/origincloudhq/sdk-typescript.git",
10
+ "directory": "packages/pvs"
11
+ },
12
+ "bugs": "https://github.com/origincloudhq/sdk-typescript/issues",
13
+ "keywords": [
14
+ "origincloud",
15
+ "origin-cloud",
16
+ "sdk",
17
+ "pvs",
18
+ "volumes"
19
+ ],
20
+ "type": "module",
21
+ "sideEffects": false,
22
+ "engines": {
23
+ "node": ">=20"
24
+ },
25
+ "exports": {
26
+ "./*": {
27
+ "types": "./dist/*/index.d.ts",
28
+ "default": "./dist/*/index.js"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "src",
35
+ "!dist/**/*.tsbuildinfo"
36
+ ],
37
+ "peerDependencies": {
38
+ "@origincloud/core": "^0.1.0"
39
+ },
40
+ "devDependencies": {
41
+ "@origincloud/core": "^0.1.0"
42
+ }
43
+ }
@@ -0,0 +1,3 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+
3
+ export * from "./operations.js";
@@ -0,0 +1,101 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/longrunning/v1beta1/operations.proto
3
+
4
+ import {
5
+ type CallOptions,
6
+ type Client,
7
+ type LongrunningOperation,
8
+ type Service,
9
+ pathValue,
10
+ query,
11
+ } from "@origincloud/core";
12
+
13
+ /**
14
+ * Calls OperationService.
15
+ *
16
+ * The long-running operations of a service: what its creates, updates and
17
+ * deletes answer with, until their resource settles. Every service serves
18
+ * this at its own host, for the operations its own methods return.
19
+ *
20
+ * An operation is done when its resource reaches the state its method
21
+ * promises, or failed when it can't get there; that outcome never changes
22
+ * afterwards, whatever later happens to the resource. It can be read for a
23
+ * day after it is done.
24
+ */
25
+ export class OperationClient {
26
+ /**
27
+ * The endpoint the client sends its calls to, which also serves the
28
+ * operations its methods answer with.
29
+ */
30
+ readonly service: Service;
31
+
32
+ /**
33
+ * A client of OperationService at the pvs host, which serves the
34
+ * operations the pvs methods answer with.
35
+ */
36
+ constructor(client: Client) {
37
+ this.service = client.service("pvs", true);
38
+ }
39
+
40
+ /** Returns an operation as it is now. */
41
+ async getOperation(request: GetOperationRequest, options?: CallOptions): Promise<LongrunningOperation> {
42
+ const p0 = pathValue("name", request.name, "projects/*/zones/*/operations/*");
43
+ return this.service.call<LongrunningOperation>(
44
+ {
45
+ method: "GET",
46
+ path: `/v1beta1/${p0}`,
47
+ query: query(request, ["name"]),
48
+ idempotent: true,
49
+ },
50
+ options,
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Waits until an operation is done or `timeout` has passed, whichever
56
+ * comes first, and returns it as it is then.
57
+ */
58
+ async waitOperation(request: WaitOperationRequest, options?: CallOptions): Promise<LongrunningOperation> {
59
+ const p0 = pathValue("name", request.name, "projects/*/zones/*/operations/*");
60
+ return this.service.call<LongrunningOperation>(
61
+ {
62
+ method: "POST",
63
+ path: `/v1beta1/${p0}:wait`,
64
+ body: request,
65
+ },
66
+ options,
67
+ );
68
+ }
69
+ }
70
+
71
+ /** The request for GetOperation. */
72
+ export interface GetOperationRequest {
73
+ /**
74
+ * The operation to return, `projects/{project}/zones/{zone}/operations/{operation}`,
75
+ * exactly as a method returned it.
76
+ */
77
+ name?: string;
78
+ }
79
+
80
+ /** The request for WaitOperation. */
81
+ export interface WaitOperationRequest {
82
+ /** The operation to wait for, exactly as a method returned it. */
83
+ name?: string;
84
+ /** The longest to wait, at most a minute; a minute when not set. */
85
+ timeout?: string;
86
+ }
87
+
88
+ /** What an operation is about. */
89
+ export interface OperationMetadata {
90
+ /** The resource the operation acts on. */
91
+ target?: string;
92
+ /**
93
+ * What it does, as the method that started it names it: for example
94
+ * `create`, `update` or `delete`.
95
+ */
96
+ verb?: string;
97
+ /** When it was accepted. */
98
+ createTime?: string;
99
+ /** When it finished; empty while it hasn't. */
100
+ endTime?: string;
101
+ }
@@ -0,0 +1,5 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+
3
+ export * from "./snapshot.js";
4
+ export * from "./storage_class.js";
5
+ export * from "./volume.js";
@@ -0,0 +1,352 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/pvs/v1beta1/snapshot.proto
3
+
4
+ import {
5
+ type CallOptions,
6
+ type Client,
7
+ type Empty,
8
+ type LongrunningOperation,
9
+ Operation,
10
+ type Service,
11
+ newRequestId,
12
+ pathValue,
13
+ query,
14
+ } from "@origincloud/core";
15
+ import type { OperationMetadata } from "../longrunning/v1beta1/operations.js";
16
+
17
+ /**
18
+ * Calls SnapshotService.
19
+ *
20
+ * Snapshots: point-in-time copies of a volume, in the volume's zone. A
21
+ * protected, completed snapshot is the source of new volumes and images.
22
+ */
23
+ export class SnapshotClient {
24
+ /**
25
+ * The endpoint the client sends its calls to, which also serves the
26
+ * operations its methods answer with.
27
+ */
28
+ readonly service: Service;
29
+
30
+ /** A client of SnapshotService that sends its calls through `client`. */
31
+ constructor(client: Client) {
32
+ this.service = client.service("pvs", true);
33
+ }
34
+
35
+ /** Returns a snapshot. */
36
+ async getSnapshot(request: GetSnapshotRequest, options?: CallOptions): Promise<Snapshot> {
37
+ const p0 = pathValue("name", request.name, "projects/*/zones/*/snapshots/*");
38
+ return this.service.call<Snapshot>(
39
+ {
40
+ method: "GET",
41
+ path: `/v1beta1/${p0}`,
42
+ query: query(request, ["name"]),
43
+ idempotent: true,
44
+ },
45
+ options,
46
+ );
47
+ }
48
+
49
+ /**
50
+ * Lists the snapshots in a zone, oldest first. Deleted snapshots aren't
51
+ * listed. For every zone's snapshots, list the zones whose `services` name
52
+ * `pvs` with the location service (`location.origincloudapis.eu`), then
53
+ * each zone's snapshots.
54
+ */
55
+ async listSnapshots(request: ListSnapshotsRequest, options?: CallOptions): Promise<ListSnapshotsResponse> {
56
+ const p0 = pathValue("parent", request.parent, "projects/*/zones/*");
57
+ return this.service.call<ListSnapshotsResponse>(
58
+ {
59
+ method: "GET",
60
+ path: `/v1beta1/${p0}/snapshots`,
61
+ query: query(request, ["parent"]),
62
+ idempotent: true,
63
+ },
64
+ options,
65
+ );
66
+ }
67
+
68
+ /**
69
+ * Iterates over everything listSnapshots lists from the request's page on,
70
+ * fetching the next page as the loop reaches it. A page that fails ends
71
+ * the iteration with its error.
72
+ */
73
+ async *allSnapshots(request: ListSnapshotsRequest, options?: CallOptions): AsyncGenerator<Snapshot, void, undefined> {
74
+ for (let page = request; ; ) {
75
+ const response = await this.listSnapshots(page, options);
76
+ yield* response.snapshots ?? [];
77
+ if (!response.nextPageToken) return;
78
+ page = { ...page, pageToken: response.nextPageToken };
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Takes a snapshot of a volume. The operation is done once the copy is
84
+ * `COMPLETED`, or failed once it is `ERROR`.
85
+ *
86
+ * It answers with an operation to wait on, whose result is the Snapshot.
87
+ */
88
+ async createSnapshot(request: CreateSnapshotRequest, options?: CallOptions): Promise<Operation<Snapshot, OperationMetadata>> {
89
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
90
+ const p0 = pathValue("parent", request.parent, "projects/*/zones/*");
91
+ const op = await this.service.call<LongrunningOperation>(
92
+ {
93
+ method: "POST",
94
+ path: `/v1beta1/${p0}/snapshots`,
95
+ body: request.snapshot,
96
+ query: query(request, ["parent", "snapshot"]),
97
+ idempotent: true,
98
+ },
99
+ options,
100
+ );
101
+ return new Operation<Snapshot, OperationMetadata>(this.service, op, "origincloud.pvs.v1beta1.Snapshot");
102
+ }
103
+
104
+ /** Changes a snapshot's tags. */
105
+ async updateSnapshot(request: UpdateSnapshotRequest, options?: CallOptions): Promise<Snapshot> {
106
+ const p0 = pathValue("snapshot.name", request.snapshot?.name, "projects/*/zones/*/snapshots/*");
107
+ return this.service.call<Snapshot>(
108
+ {
109
+ method: "PATCH",
110
+ path: `/v1beta1/${p0}`,
111
+ body: request.snapshot,
112
+ query: query(request, ["snapshot.name", "snapshot"]),
113
+ },
114
+ options,
115
+ );
116
+ }
117
+
118
+ /**
119
+ * Deletes a snapshot. It must be `COMPLETED` or `ERROR`, and unprotected.
120
+ * The operation is done once the snapshot is `DELETED`.
121
+ *
122
+ * It answers with an operation to wait on, which has no result.
123
+ */
124
+ async deleteSnapshot(request: DeleteSnapshotRequest, options?: CallOptions): Promise<Operation<Empty, OperationMetadata>> {
125
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
126
+ const p0 = pathValue("name", request.name, "projects/*/zones/*/snapshots/*");
127
+ const op = await this.service.call<LongrunningOperation>(
128
+ {
129
+ method: "DELETE",
130
+ path: `/v1beta1/${p0}`,
131
+ query: query(request, ["name"]),
132
+ idempotent: true,
133
+ },
134
+ options,
135
+ );
136
+ return new Operation<Empty, OperationMetadata>(this.service, op, "google.protobuf.Empty");
137
+ }
138
+
139
+ /**
140
+ * Protects a snapshot, so it can be the source of volumes and images and
141
+ * can't be deleted. The operation is done once it is `PROTECTED`.
142
+ *
143
+ * It answers with an operation to wait on, whose result is the Snapshot.
144
+ */
145
+ async protectSnapshot(request: ProtectSnapshotRequest, options?: CallOptions): Promise<Operation<Snapshot, OperationMetadata>> {
146
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
147
+ const p0 = pathValue("name", request.name, "projects/*/zones/*/snapshots/*");
148
+ const op = await this.service.call<LongrunningOperation>(
149
+ {
150
+ method: "POST",
151
+ path: `/v1beta1/${p0}:protect`,
152
+ body: request,
153
+ idempotent: true,
154
+ },
155
+ options,
156
+ );
157
+ return new Operation<Snapshot, OperationMetadata>(this.service, op, "origincloud.pvs.v1beta1.Snapshot");
158
+ }
159
+
160
+ /**
161
+ * Unprotects a snapshot, so it can be deleted. Refused with
162
+ * `FAILED_PRECONDITION` while an image is built from it or a volume not
163
+ * `DELETED` was created from it; delete those first. The operation is
164
+ * done once it is `UNPROTECTED`.
165
+ *
166
+ * It answers with an operation to wait on, whose result is the Snapshot.
167
+ */
168
+ async unprotectSnapshot(request: UnprotectSnapshotRequest, options?: CallOptions): Promise<Operation<Snapshot, OperationMetadata>> {
169
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
170
+ const p0 = pathValue("name", request.name, "projects/*/zones/*/snapshots/*");
171
+ const op = await this.service.call<LongrunningOperation>(
172
+ {
173
+ method: "POST",
174
+ path: `/v1beta1/${p0}:unprotect`,
175
+ body: request,
176
+ idempotent: true,
177
+ },
178
+ options,
179
+ );
180
+ return new Operation<Snapshot, OperationMetadata>(this.service, op, "origincloud.pvs.v1beta1.Snapshot");
181
+ }
182
+ }
183
+
184
+ /** A point-in-time copy of a volume. */
185
+ export interface Snapshot {
186
+ /** The snapshot's resource name. */
187
+ name?: string;
188
+ /**
189
+ * The snapshot's URN, the identifier access policies and the audit log
190
+ * use.
191
+ */
192
+ urn?: string;
193
+ /** The volume copied, in the same project and zone. */
194
+ sourceVolume?: string;
195
+ /**
196
+ * The source volume's size in GiB when it was copied: the least a volume
197
+ * created from the snapshot holds.
198
+ */
199
+ sourceSizeGib?: number;
200
+ /** Where the copy is. */
201
+ state?: Snapshot_State;
202
+ /** Why the snapshot is in `ERROR`; empty otherwise. */
203
+ stateReason?: string;
204
+ /** Whether it is protected. */
205
+ protectionState?: Snapshot_ProtectionState;
206
+ /**
207
+ * Why the last protection change failed, when `protectionState` is
208
+ * `PROTECTION_FAILED`.
209
+ */
210
+ protectionReason?: string;
211
+ /**
212
+ * The principal that took the snapshot, such as `user:<id>` or
213
+ * `service_account:<id>`.
214
+ */
215
+ creator?: string;
216
+ /**
217
+ * Labels of your own, at most 50. The `origin:name` tag is the name the
218
+ * console shows.
219
+ */
220
+ tags?: Record<string, string>;
221
+ }
222
+
223
+ /** Where the copy is. */
224
+ export const Snapshot_State = {
225
+ /** Not set. */
226
+ STATE_UNSPECIFIED: "STATE_UNSPECIFIED",
227
+ /** Being copied. */
228
+ PENDING: "PENDING",
229
+ /** Copied. */
230
+ COMPLETED: "COMPLETED",
231
+ /** Being deleted. */
232
+ DELETING: "DELETING",
233
+ /** Deleted. Readable by name for a day, never listed. */
234
+ DELETED: "DELETED",
235
+ /**
236
+ * The copy or its removal failed; `stateReason` says which. There is
237
+ * no usable copy behind it: delete it.
238
+ */
239
+ ERROR: "ERROR",
240
+ } as const;
241
+
242
+ /** Where the copy is. */
243
+ export type Snapshot_State = (typeof Snapshot_State)[keyof typeof Snapshot_State];
244
+
245
+ /** Whether the snapshot is protected, independently of `state`. */
246
+ export const Snapshot_ProtectionState = {
247
+ /** Not set. */
248
+ PROTECTION_STATE_UNSPECIFIED: "PROTECTION_STATE_UNSPECIFIED",
249
+ /** Not protected: it can be deleted, and is no source. */
250
+ UNPROTECTED: "UNPROTECTED",
251
+ /** Becoming protected. */
252
+ PROTECTING: "PROTECTING",
253
+ /** Protected: a source of volumes and images, and can't be deleted. */
254
+ PROTECTED: "PROTECTED",
255
+ /** Becoming unprotected. */
256
+ UNPROTECTING: "UNPROTECTING",
257
+ /**
258
+ * The last change couldn't be applied; `protectionReason` says why.
259
+ * Protect or unprotect it again.
260
+ */
261
+ PROTECTION_FAILED: "PROTECTION_FAILED",
262
+ } as const;
263
+
264
+ /** Whether the snapshot is protected, independently of `state`. */
265
+ export type Snapshot_ProtectionState = (typeof Snapshot_ProtectionState)[keyof typeof Snapshot_ProtectionState];
266
+
267
+ /** The request for GetSnapshot. */
268
+ export interface GetSnapshotRequest {
269
+ /** The snapshot to return. */
270
+ name?: string;
271
+ }
272
+
273
+ /** The request for ListSnapshots. */
274
+ export interface ListSnapshotsRequest {
275
+ /** The zone whose snapshots to list, `projects/{project}/zones/{zone}`. */
276
+ parent?: string;
277
+ /**
278
+ * The most snapshots to return; the server clamps it, and 0 means its
279
+ * default.
280
+ */
281
+ pageSize?: number;
282
+ /** A previous response's `nextPageToken`, for the page after it. */
283
+ pageToken?: string;
284
+ }
285
+
286
+ /** The response for ListSnapshots. */
287
+ export interface ListSnapshotsResponse {
288
+ /** The snapshots on this page. */
289
+ snapshots?: Snapshot[];
290
+ /** The token for the next page; empty on the last one. */
291
+ nextPageToken?: string;
292
+ }
293
+
294
+ /** The request for CreateSnapshot. */
295
+ export interface CreateSnapshotRequest {
296
+ /** The zone of the volume to copy, `projects/{project}/zones/{zone}`. */
297
+ parent?: string;
298
+ /** The snapshot to take: its source volume, and optionally its tags. */
299
+ snapshot?: Snapshot;
300
+ /**
301
+ * A UUID; a repeat with the same id returns the first request's
302
+ * operation instead of taking a second snapshot.
303
+ */
304
+ requestId?: string;
305
+ }
306
+
307
+ /** The request for UpdateSnapshot. */
308
+ export interface UpdateSnapshotRequest {
309
+ /** The snapshot, by its name, with the tags to set. */
310
+ snapshot?: Snapshot;
311
+ /**
312
+ * The fields to change: `tags`, the only field that changes. `*` is the
313
+ * same.
314
+ */
315
+ updateMask?: string;
316
+ }
317
+
318
+ /** The request for DeleteSnapshot. */
319
+ export interface DeleteSnapshotRequest {
320
+ /** The snapshot to delete. */
321
+ name?: string;
322
+ /**
323
+ * A UUID; a repeat with the same id returns the first request's
324
+ * operation.
325
+ */
326
+ requestId?: string;
327
+ }
328
+
329
+ /** The request for ProtectSnapshot. */
330
+ export interface ProtectSnapshotRequest {
331
+ /** The snapshot to protect; it must be `COMPLETED`. */
332
+ name?: string;
333
+ /**
334
+ * A UUID; a repeat with the same id returns the first request's
335
+ * operation.
336
+ */
337
+ requestId?: string;
338
+ }
339
+
340
+ /** The request for UnprotectSnapshot. */
341
+ export interface UnprotectSnapshotRequest {
342
+ /**
343
+ * The snapshot to unprotect; it must be `COMPLETED`, or `ERROR` so that
344
+ * it can then be deleted.
345
+ */
346
+ name?: string;
347
+ /**
348
+ * A UUID; a repeat with the same id returns the first request's
349
+ * operation.
350
+ */
351
+ requestId?: string;
352
+ }