@daocloud-proto/virtnest 0.1.0-cr1

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.
package/fetch.pb.ts ADDED
@@ -0,0 +1,341 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ /*
4
+ * This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
5
+ */
6
+
7
+ /**
8
+ * base64 encoder and decoder
9
+ * Copied and adapted from https://github.com/protobufjs/protobuf.js/blob/master/lib/base64/index.js
10
+ */
11
+ // Base64 encoding table
12
+ const b64 = new Array(64);
13
+
14
+ // Base64 decoding table
15
+ const s64 = new Array(123);
16
+
17
+ // 65..90, 97..122, 48..57, 43, 47
18
+ for (let i = 0; i < 64;)
19
+ s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
20
+
21
+ export function b64Encode(buffer: Uint8Array, start: number, end: number): string {
22
+ let parts: string[] = null;
23
+ const chunk = [];
24
+ let i = 0, // output index
25
+ j = 0, // goto index
26
+ t; // temporary
27
+ while (start < end) {
28
+ const b = buffer[start++];
29
+ switch (j) {
30
+ case 0:
31
+ chunk[i++] = b64[b >> 2];
32
+ t = (b & 3) << 4;
33
+ j = 1;
34
+ break;
35
+ case 1:
36
+ chunk[i++] = b64[t | b >> 4];
37
+ t = (b & 15) << 2;
38
+ j = 2;
39
+ break;
40
+ case 2:
41
+ chunk[i++] = b64[t | b >> 6];
42
+ chunk[i++] = b64[b & 63];
43
+ j = 0;
44
+ break;
45
+ }
46
+ if (i > 8191) {
47
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
48
+ i = 0;
49
+ }
50
+ }
51
+ if (j) {
52
+ chunk[i++] = b64[t];
53
+ chunk[i++] = 61;
54
+ if (j === 1)
55
+ chunk[i++] = 61;
56
+ }
57
+ if (parts) {
58
+ if (i)
59
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
60
+ return parts.join("");
61
+ }
62
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
63
+ }
64
+
65
+ const invalidEncoding = "invalid encoding";
66
+
67
+ export function b64Decode(s: string): Uint8Array {
68
+ const buffer = [];
69
+ let offset = 0;
70
+ let j = 0, // goto index
71
+ t; // temporary
72
+ for (let i = 0; i < s.length;) {
73
+ let c = s.charCodeAt(i++);
74
+ if (c === 61 && j > 1)
75
+ break;
76
+ if ((c = s64[c]) === undefined)
77
+ throw Error(invalidEncoding);
78
+ switch (j) {
79
+ case 0:
80
+ t = c;
81
+ j = 1;
82
+ break;
83
+ case 1:
84
+ buffer[offset++] = t << 2 | (c & 48) >> 4;
85
+ t = c;
86
+ j = 2;
87
+ break;
88
+ case 2:
89
+ buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
90
+ t = c;
91
+ j = 3;
92
+ break;
93
+ case 3:
94
+ buffer[offset++] = (t & 3) << 6 | c;
95
+ j = 0;
96
+ break;
97
+ }
98
+ }
99
+ if (j === 1)
100
+ throw Error(invalidEncoding);
101
+ return new Uint8Array(buffer);
102
+ }
103
+
104
+ function b64Test(s: string): boolean {
105
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s);
106
+ }
107
+
108
+ export interface InitReq extends RequestInit {
109
+ pathPrefix?: string
110
+ }
111
+
112
+ export function replacer(key: any, value: any): any {
113
+ if(value && value.constructor === Uint8Array) {
114
+ return b64Encode(value, 0, value.length);
115
+ }
116
+
117
+ return value;
118
+ }
119
+
120
+ export function fetchReq<I, O>(path: string, init?: InitReq): Promise<O> {
121
+ const {pathPrefix, ...req} = init || {}
122
+
123
+ const url = pathPrefix ? `${pathPrefix}${path}` : path
124
+
125
+ return fetch(url, req).then(r => r.json().then((body: O) => {
126
+ if (!r.ok) { throw body; }
127
+ return body;
128
+ })) as Promise<O>
129
+ }
130
+
131
+ // NotifyStreamEntityArrival is a callback that will be called on streaming entity arrival
132
+ export type NotifyStreamEntityArrival<T> = (resp: T) => void
133
+
134
+ /**
135
+ * fetchStreamingRequest is able to handle grpc-gateway server side streaming call
136
+ * it takes NotifyStreamEntityArrival that lets users respond to entity arrival during the call
137
+ * all entities will be returned as an array after the call finishes.
138
+ **/
139
+ export async function fetchStreamingRequest<S, R>(path: string, callback?: NotifyStreamEntityArrival<R>, init?: InitReq) {
140
+ const {pathPrefix, ...req} = init || {}
141
+ const url = pathPrefix ?`${pathPrefix}${path}` : path
142
+ const result = await fetch(url, req)
143
+ // needs to use the .ok to check the status of HTTP status code
144
+ // http other than 200 will not throw an error, instead the .ok will become false.
145
+ // see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#
146
+ if (!result.ok) {
147
+ const resp = await result.json()
148
+ const errMsg = resp.error && resp.error.message ? resp.error.message : ""
149
+ throw new Error(errMsg)
150
+ }
151
+
152
+ if (!result.body) {
153
+ throw new Error("response doesnt have a body")
154
+ }
155
+
156
+ await result.body
157
+ .pipeThrough(new TextDecoderStream())
158
+ .pipeThrough<R>(getNewLineDelimitedJSONDecodingStream<R>())
159
+ .pipeTo(getNotifyEntityArrivalSink((e: R) => {
160
+ if (callback) {
161
+ callback(e)
162
+ }
163
+ }))
164
+
165
+ // wait for the streaming to finish and return the success respond
166
+ return
167
+ }
168
+
169
+ /**
170
+ * JSONStringStreamController represents the transform controller that's able to transform the incoming
171
+ * new line delimited json content stream into entities and able to push the entity to the down stream
172
+ */
173
+ interface JSONStringStreamController<T> extends TransformStreamDefaultController {
174
+ buf?: string
175
+ pos?: number
176
+ enqueue: (s: T) => void
177
+ }
178
+
179
+ /**
180
+ * getNewLineDelimitedJSONDecodingStream returns a TransformStream that's able to handle new line delimited json stream content into parsed entities
181
+ */
182
+ function getNewLineDelimitedJSONDecodingStream<T>(): TransformStream<string, T> {
183
+ return new TransformStream({
184
+ start(controller: JSONStringStreamController<T>) {
185
+ controller.buf = ''
186
+ controller.pos = 0
187
+ },
188
+
189
+ transform(chunk: string, controller: JSONStringStreamController<T>) {
190
+ if (controller.buf === undefined) {
191
+ controller.buf = ''
192
+ }
193
+ if (controller.pos === undefined) {
194
+ controller.pos = 0
195
+ }
196
+ controller.buf += chunk
197
+ while (controller.pos < controller.buf.length) {
198
+ if (controller.buf[controller.pos] === '\n') {
199
+ const line = controller.buf.substring(0, controller.pos)
200
+ const response = JSON.parse(line)
201
+ controller.enqueue(response.result)
202
+ controller.buf = controller.buf.substring(controller.pos + 1)
203
+ controller.pos = 0
204
+ } else {
205
+ ++controller.pos
206
+ }
207
+ }
208
+ }
209
+ })
210
+
211
+ }
212
+
213
+ /**
214
+ * getNotifyEntityArrivalSink takes the NotifyStreamEntityArrival callback and return
215
+ * a sink that will call the callback on entity arrival
216
+ * @param notifyCallback
217
+ */
218
+ function getNotifyEntityArrivalSink<T>(notifyCallback: NotifyStreamEntityArrival<T>) {
219
+ return new WritableStream<T>({
220
+ write(entity: T) {
221
+ notifyCallback(entity)
222
+ }
223
+ })
224
+ }
225
+
226
+ type Primitive = string | boolean | number;
227
+ type RequestPayload = Record<string, unknown>;
228
+ type FlattenedRequestPayload = Record<string, Primitive | Array<Primitive>>;
229
+
230
+ /**
231
+ * Checks if given value is a plain object
232
+ * Logic copied and adapted from below source:
233
+ * https://github.com/char0n/ramda-adjunct/blob/master/src/isPlainObj.js
234
+ * @param {unknown} value
235
+ * @return {boolean}
236
+ */
237
+ function isPlainObject(value: unknown): boolean {
238
+ const isObject =
239
+ Object.prototype.toString.call(value).slice(8, -1) === "Object";
240
+ const isObjLike = value !== null && isObject;
241
+
242
+ if (!isObjLike || !isObject) {
243
+ return false;
244
+ }
245
+
246
+ const proto = Object.getPrototypeOf(value);
247
+
248
+ const hasObjectConstructor =
249
+ typeof proto === "object" &&
250
+ proto.constructor === Object.prototype.constructor;
251
+
252
+ return hasObjectConstructor;
253
+ }
254
+
255
+ /**
256
+ * Checks if given value is of a primitive type
257
+ * @param {unknown} value
258
+ * @return {boolean}
259
+ */
260
+ function isPrimitive(value: unknown): boolean {
261
+ return ["string", "number", "boolean"].some(t => typeof value === t);
262
+ }
263
+
264
+ /**
265
+ * Checks if given primitive is zero-value
266
+ * @param {Primitive} value
267
+ * @return {boolean}
268
+ */
269
+ function isZeroValuePrimitive(value: Primitive): boolean {
270
+ return value === false || value === 0 || value === "";
271
+ }
272
+
273
+ /**
274
+ * Flattens a deeply nested request payload and returns an object
275
+ * with only primitive values and non-empty array of primitive values
276
+ * as per https://github.com/googleapis/googleapis/blob/master/google/api/http.proto
277
+ * @param {RequestPayload} requestPayload
278
+ * @param {String} path
279
+ * @return {FlattenedRequestPayload>}
280
+ */
281
+ function flattenRequestPayload<T extends RequestPayload>(
282
+ requestPayload: T,
283
+ path: string = ""
284
+ ): FlattenedRequestPayload {
285
+ return Object.keys(requestPayload).reduce(
286
+ (acc: T, key: string): T => {
287
+ const value = requestPayload[key];
288
+ const newPath = path ? [path, key].join(".") : key;
289
+
290
+ const isNonEmptyPrimitiveArray =
291
+ Array.isArray(value) &&
292
+ value.every(v => isPrimitive(v)) &&
293
+ value.length > 0;
294
+
295
+ const isNonZeroValuePrimitive =
296
+ isPrimitive(value) && !isZeroValuePrimitive(value as Primitive);
297
+
298
+ let objectToMerge = {};
299
+
300
+ if (isPlainObject(value)) {
301
+ objectToMerge = flattenRequestPayload(value as RequestPayload, newPath);
302
+ } else if (isNonZeroValuePrimitive || isNonEmptyPrimitiveArray) {
303
+ objectToMerge = { [newPath]: value };
304
+ }
305
+
306
+ return { ...acc, ...objectToMerge };
307
+ },
308
+ {} as T
309
+ ) as FlattenedRequestPayload;
310
+ }
311
+
312
+ /**
313
+ * Renders a deeply nested request payload into a string of URL search
314
+ * parameters by first flattening the request payload and then removing keys
315
+ * which are already present in the URL path.
316
+ * @param {RequestPayload} requestPayload
317
+ * @param {string[]} urlPathParams
318
+ * @return {string}
319
+ */
320
+ export function renderURLSearchParams<T extends RequestPayload>(
321
+ requestPayload: T,
322
+ urlPathParams: string[] = []
323
+ ): string {
324
+ const flattenedRequestPayload = flattenRequestPayload(requestPayload);
325
+
326
+ const urlSearchParams = Object.keys(flattenedRequestPayload).reduce(
327
+ (acc: string[][], key: string): string[][] => {
328
+ // key should not be present in the url path as a parameter
329
+ const value = flattenedRequestPayload[key];
330
+ if (urlPathParams.find(f => f === key)) {
331
+ return acc;
332
+ }
333
+ return Array.isArray(value)
334
+ ? [...acc, ...value.map(m => [key, m.toString()])]
335
+ : (acc = [...acc, [key, value.toString()]]);
336
+ },
337
+ [] as string[][]
338
+ );
339
+
340
+ return new URLSearchParams(urlSearchParams).toString();
341
+ }
package/package.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@daocloud-proto/virtnest",
3
+ "version":"0.1.0-cr1",
4
+ "description": "",
5
+ "author": "",
6
+ "license": "ISC"
7
+ }
@@ -0,0 +1,54 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ /*
4
+ * This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
5
+ */
6
+
7
+ import * as fm from "../fetch.pb"
8
+
9
+ export enum Status {
10
+ running = "running",
11
+ failed = "failed",
12
+ }
13
+
14
+ export type ClusterInfo = {
15
+ name?: string
16
+ status?: Status
17
+ isKubevirtInstalled?: boolean
18
+ }
19
+
20
+ export type ListClustersRequest = {
21
+ search?: string
22
+ }
23
+
24
+ export type ListClustersResponse = {
25
+ items?: ClusterInfo[]
26
+ }
27
+
28
+ export type ListClusterNamespacesRequest = {
29
+ cluster?: string
30
+ }
31
+
32
+ export type ListClusterNamespacesResponse = {
33
+ items?: string[]
34
+ }
35
+
36
+ export type ListClusterStorageClassesRequest = {
37
+ cluster?: string
38
+ }
39
+
40
+ export type ListClusterStorageClassesResponse = {
41
+ items?: string[]
42
+ }
43
+
44
+ export class Cluster {
45
+ static ListClusters(req: ListClustersRequest, initReq?: fm.InitReq): Promise<ListClustersResponse> {
46
+ return fm.fetchReq<ListClustersRequest, ListClustersResponse>(`/apis/virtnest.io/v1alpha1/clusters?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
47
+ }
48
+ static ListClusterNamespaces(req: ListClusterNamespacesRequest, initReq?: fm.InitReq): Promise<ListClusterNamespacesResponse> {
49
+ return fm.fetchReq<ListClusterNamespacesRequest, ListClusterNamespacesResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces?${fm.renderURLSearchParams(req, ["cluster"])}`, {...initReq, method: "GET"})
50
+ }
51
+ static ListClusterStorageClasses(req: ListClusterStorageClassesRequest, initReq?: fm.InitReq): Promise<ListClusterStorageClassesResponse> {
52
+ return fm.fetchReq<ListClusterStorageClassesRequest, ListClusterStorageClassesResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/storageclasses?${fm.renderURLSearchParams(req, ["cluster"])}`, {...initReq, method: "GET"})
53
+ }
54
+ }
@@ -0,0 +1,40 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ /*
4
+ * This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
5
+ */
6
+
7
+ import * as fm from "../fetch.pb"
8
+
9
+ export enum RoleEnum {
10
+ admin = "admin",
11
+ cluster_admin = "cluster_admin",
12
+ cluster_edit = "cluster_edit",
13
+ cluster_view = "cluster_view",
14
+ ns_admin = "ns_admin",
15
+ ns_edit = "ns_edit",
16
+ ns_view = "ns_view",
17
+ }
18
+
19
+ export type GetUserRolesRequest = {
20
+ }
21
+
22
+ export type GetUserRolesResponse = {
23
+ platformRoles?: RoleEnum[]
24
+ clusterRoles?: {[key: string]: ClusterRoles}
25
+ }
26
+
27
+ export type ClusterRoles = {
28
+ roles?: RoleEnum[]
29
+ nsRoles?: {[key: string]: NSRoles}
30
+ }
31
+
32
+ export type NSRoles = {
33
+ roles?: RoleEnum[]
34
+ }
35
+
36
+ export class Role {
37
+ static GetUserRoles(req: GetUserRolesRequest, initReq?: fm.InitReq): Promise<GetUserRolesResponse> {
38
+ return fm.fetchReq<GetUserRolesRequest, GetUserRolesResponse>(`/apis/virtnest.io/v1alpha1/roles?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
39
+ }
40
+ }
@@ -0,0 +1,416 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ /*
4
+ * This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
5
+ */
6
+
7
+ import * as fm from "../fetch.pb"
8
+
9
+ export enum OSFamily {
10
+ Unknown = "Unknown",
11
+ Debian = "Debian",
12
+ CentOS = "CentOS",
13
+ Ubuntu = "Ubuntu",
14
+ }
15
+
16
+ export enum ImageSource {
17
+ docker = "docker",
18
+ http = "http",
19
+ s3 = "s3",
20
+ }
21
+
22
+ export enum VMOperation {
23
+ start = "start",
24
+ stop = "stop",
25
+ restart = "restart",
26
+ }
27
+
28
+ export enum VMStatus {
29
+ running = "running",
30
+ processing = "processing",
31
+ error = "error",
32
+ poweroff = "poweroff",
33
+ }
34
+
35
+ export enum StorageStatus {
36
+ storage_processing = "storage_processing",
37
+ storage_ready = "storage_ready",
38
+ storage_failed = "storage_failed",
39
+ }
40
+
41
+ export enum StorageType {
42
+ system = "system",
43
+ data = "data",
44
+ }
45
+
46
+ export enum SnapshotStatus {
47
+ snapshot_succeeded = "snapshot_succeeded",
48
+ snapshot_failed = "snapshot_failed",
49
+ snapshot_deleting = "snapshot_deleting",
50
+ snapshot_processing = "snapshot_processing",
51
+ snapshot_unknown = "snapshot_unknown",
52
+ }
53
+
54
+ export type Pagination = {
55
+ page?: number
56
+ pageSize?: number
57
+ total?: number
58
+ }
59
+
60
+ export type VmErrorMessage = {
61
+ message?: string
62
+ reason?: string
63
+ }
64
+
65
+ export type ListClusterVmsInfo = {
66
+ name?: string
67
+ status?: VMStatus
68
+ namespace?: string
69
+ ips?: string[]
70
+ cpu?: string
71
+ memory?: string
72
+ createdAt?: string
73
+ osFamily?: OSFamily
74
+ vmErrorMessage?: VmErrorMessage
75
+ }
76
+
77
+ export type ListClusterVMsRequest = {
78
+ pageSize?: number
79
+ page?: number
80
+ cluster?: string
81
+ search?: string
82
+ }
83
+
84
+ export type ListClusterVmsResponse = {
85
+ items?: ListClusterVmsInfo[]
86
+ pagination?: Pagination
87
+ }
88
+
89
+ export type CreateVMRequest = {
90
+ cluster?: string
91
+ namespace?: string
92
+ name?: string
93
+ aliasName?: string
94
+ labels?: {[key: string]: string}
95
+ annotations?: {[key: string]: string}
96
+ imageSource?: ImageSource
97
+ imageUrl?: string
98
+ systemDisk?: string
99
+ cpu?: Item
100
+ memory?: Item
101
+ ssh?: SSH
102
+ osFamily?: OSFamily
103
+ osVersion?: string
104
+ }
105
+
106
+ export type SSH = {
107
+ username?: string
108
+ password?: string
109
+ sshKey?: string
110
+ }
111
+
112
+ export type Item = {
113
+ request?: string
114
+ limit?: string
115
+ }
116
+
117
+ export type Network = {
118
+ name?: string
119
+ subnet?: string
120
+ default?: boolean
121
+ }
122
+
123
+ export type CreateVMResponse = {
124
+ }
125
+
126
+ export type DeleteVMRequest = {
127
+ cluster?: string
128
+ namespace?: string
129
+ name?: string
130
+ }
131
+
132
+ export type DeleteVMResponse = {
133
+ }
134
+
135
+ export type UpdateVMRequest = {
136
+ cluster?: string
137
+ namespace?: string
138
+ name?: string
139
+ aliasName?: string
140
+ labels?: {[key: string]: string}
141
+ annotations?: {[key: string]: string}
142
+ cpu?: Item
143
+ memory?: Item
144
+ }
145
+
146
+ export type UpdateVMResponse = {
147
+ }
148
+
149
+ export type UpdateVMRunningStatusRequest = {
150
+ cluster?: string
151
+ namespace?: string
152
+ name?: string
153
+ vmOperation?: VMOperation
154
+ }
155
+
156
+ export type UpdateVMRunningStatusResponse = {
157
+ }
158
+
159
+ export type GetVMRequest = {
160
+ cluster?: string
161
+ namespace?: string
162
+ name?: string
163
+ }
164
+
165
+ export type GetVMResponse = {
166
+ cluster?: string
167
+ namespace?: string
168
+ name?: string
169
+ aliasName?: string
170
+ describe?: string
171
+ labels?: {[key: string]: string}
172
+ annotations?: {[key: string]: string}
173
+ ips?: string[]
174
+ status?: VMStatus
175
+ createdAt?: string
176
+ username?: string
177
+ password?: string
178
+ sshKey?: string
179
+ cpu?: Item
180
+ memory?: Item
181
+ }
182
+
183
+ export type VMNetwork = {
184
+ name?: string
185
+ type?: string
186
+ ip?: string
187
+ }
188
+
189
+ export type ListVMNetworksRequest = {
190
+ cluster?: string
191
+ namespace?: string
192
+ name?: string
193
+ }
194
+
195
+ export type ListVMNetworksResponse = {
196
+ items?: VMNetwork[]
197
+ }
198
+
199
+ export type VMStorage = {
200
+ name?: string
201
+ type?: StorageType
202
+ capacity?: string
203
+ status?: StorageStatus
204
+ storageClass?: string
205
+ }
206
+
207
+ export type ListVMStoragesRequest = {
208
+ pageSize?: number
209
+ page?: number
210
+ cluster?: string
211
+ namespace?: string
212
+ name?: string
213
+ search?: string
214
+ }
215
+
216
+ export type ListVMStoragesResponse = {
217
+ items?: VMStorage[]
218
+ pagination?: Pagination
219
+ }
220
+
221
+ export type ListVMSnapshotsRequest = {
222
+ pageSize?: number
223
+ page?: number
224
+ cluster?: string
225
+ namespace?: string
226
+ name?: string
227
+ search?: string
228
+ }
229
+
230
+ export type VMSnapshot = {
231
+ name?: string
232
+ description?: string
233
+ createdAt?: string
234
+ status?: SnapshotStatus
235
+ }
236
+
237
+ export type ListVMSnapshotsResponse = {
238
+ items?: VMSnapshot[]
239
+ pagination?: Pagination
240
+ }
241
+
242
+ export type CreateCustomResourceRequest = {
243
+ cluster?: string
244
+ data?: string[]
245
+ }
246
+
247
+ export type CreateCustomResourceResponse = {
248
+ }
249
+
250
+ export type CreateVMSnapshotRequest = {
251
+ cluster?: string
252
+ namespace?: string
253
+ name?: string
254
+ snapshotName?: string
255
+ snapshotDescription?: string
256
+ }
257
+
258
+ export type CreateVMSnapshotResponse = {
259
+ }
260
+
261
+ export type RestoreVMSnapshotRequest = {
262
+ cluster?: string
263
+ namespace?: string
264
+ name?: string
265
+ snapshotName?: string
266
+ }
267
+
268
+ export type RestoreVMSnapshotResponse = {
269
+ }
270
+
271
+ export type DeleteVMSnapshotRequest = {
272
+ cluster?: string
273
+ namespace?: string
274
+ name?: string
275
+ snapshotName?: string
276
+ }
277
+
278
+ export type DeleteVMSnapshotResponse = {
279
+ }
280
+
281
+ export type UpdateVMSnapshotRequest = {
282
+ cluster?: string
283
+ namespace?: string
284
+ name?: string
285
+ snapshotName?: string
286
+ snapshotDescription?: string
287
+ }
288
+
289
+ export type UpdateVMSnapshotResponse = {
290
+ }
291
+
292
+ export type CloneVMRequest = {
293
+ cluster?: string
294
+ namespace?: string
295
+ name?: string
296
+ cloneName?: string
297
+ description?: string
298
+ }
299
+
300
+ export type CloneVMResponse = {
301
+ }
302
+
303
+ export type ListSystemImagesRequest = {
304
+ cluster?: string
305
+ }
306
+
307
+ export type ListSystemImagesResponse = {
308
+ items?: SystemImage[]
309
+ }
310
+
311
+ export type SystemImage = {
312
+ osFamily?: OSFamily
313
+ version?: SystemImageVersion[]
314
+ }
315
+
316
+ export type SystemImageVersion = {
317
+ version?: string
318
+ url?: string
319
+ }
320
+
321
+ export type DiskVolume = {
322
+ storageClass?: string
323
+ storage?: string
324
+ }
325
+
326
+ export type AddDiskVolumeToVMRequest = {
327
+ cluster?: string
328
+ namespace?: string
329
+ name?: string
330
+ diskVolumes?: DiskVolume
331
+ hotplug?: boolean
332
+ }
333
+
334
+ export type AddDiskVolumeToVMResponse = {
335
+ }
336
+
337
+ export type RemoveVMDiskVolumeRequest = {
338
+ cluster?: string
339
+ namespace?: string
340
+ name?: string
341
+ diskName?: string
342
+ }
343
+
344
+ export type RemoveVMDiskVolumeResponse = {
345
+ }
346
+
347
+ export type ExpandVMDiskCapacityRequest = {
348
+ cluster?: string
349
+ namespace?: string
350
+ name?: string
351
+ diskName?: string
352
+ capacity?: string
353
+ }
354
+
355
+ export type ExpandVMDiskCapacityResponse = {
356
+ }
357
+
358
+ export class VM {
359
+ static ListClusterVMs(req: ListClusterVMsRequest, initReq?: fm.InitReq): Promise<ListClusterVmsResponse> {
360
+ return fm.fetchReq<ListClusterVMsRequest, ListClusterVmsResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/vms?${fm.renderURLSearchParams(req, ["cluster"])}`, {...initReq, method: "GET"})
361
+ }
362
+ static CreateVM(req: CreateVMRequest, initReq?: fm.InitReq): Promise<CreateVMResponse> {
363
+ return fm.fetchReq<CreateVMRequest, CreateVMResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vm`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
364
+ }
365
+ static CreateCustomResource(req: CreateCustomResourceRequest, initReq?: fm.InitReq): Promise<CreateCustomResourceResponse> {
366
+ return fm.fetchReq<CreateCustomResourceRequest, CreateCustomResourceResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/custom-resource`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
367
+ }
368
+ static DeleteVM(req: DeleteVMRequest, initReq?: fm.InitReq): Promise<DeleteVMResponse> {
369
+ return fm.fetchReq<DeleteVMRequest, DeleteVMResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}`, {...initReq, method: "DELETE"})
370
+ }
371
+ static UpdateVM(req: UpdateVMRequest, initReq?: fm.InitReq): Promise<UpdateVMResponse> {
372
+ return fm.fetchReq<UpdateVMRequest, UpdateVMResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}`, {...initReq, method: "PUT", body: JSON.stringify(req, fm.replacer)})
373
+ }
374
+ static UpdateVMRunningStatus(req: UpdateVMRunningStatusRequest, initReq?: fm.InitReq): Promise<UpdateVMRunningStatusResponse> {
375
+ return fm.fetchReq<UpdateVMRunningStatusRequest, UpdateVMRunningStatusResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/running-status`, {...initReq, method: "PUT", body: JSON.stringify(req, fm.replacer)})
376
+ }
377
+ static GetVM(req: GetVMRequest, initReq?: fm.InitReq): Promise<GetVMResponse> {
378
+ return fm.fetchReq<GetVMRequest, GetVMResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}?${fm.renderURLSearchParams(req, ["cluster", "namespace", "name"])}`, {...initReq, method: "GET"})
379
+ }
380
+ static ListVMNetworks(req: ListVMNetworksRequest, initReq?: fm.InitReq): Promise<ListVMNetworksResponse> {
381
+ return fm.fetchReq<ListVMNetworksRequest, ListVMNetworksResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/networks?${fm.renderURLSearchParams(req, ["cluster", "namespace", "name"])}`, {...initReq, method: "GET"})
382
+ }
383
+ static ListVMStorages(req: ListVMStoragesRequest, initReq?: fm.InitReq): Promise<ListVMStoragesResponse> {
384
+ return fm.fetchReq<ListVMStoragesRequest, ListVMStoragesResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/storages?${fm.renderURLSearchParams(req, ["cluster", "namespace", "name"])}`, {...initReq, method: "GET"})
385
+ }
386
+ static ListVMSnapshots(req: ListVMSnapshotsRequest, initReq?: fm.InitReq): Promise<ListVMSnapshotsResponse> {
387
+ return fm.fetchReq<ListVMSnapshotsRequest, ListVMSnapshotsResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/snapshots?${fm.renderURLSearchParams(req, ["cluster", "namespace", "name"])}`, {...initReq, method: "GET"})
388
+ }
389
+ static CreateVMSnapshot(req: CreateVMSnapshotRequest, initReq?: fm.InitReq): Promise<CreateVMSnapshotResponse> {
390
+ return fm.fetchReq<CreateVMSnapshotRequest, CreateVMSnapshotResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/snapshot`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
391
+ }
392
+ static RestoreVMSnapshot(req: RestoreVMSnapshotRequest, initReq?: fm.InitReq): Promise<RestoreVMSnapshotResponse> {
393
+ return fm.fetchReq<RestoreVMSnapshotRequest, RestoreVMSnapshotResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/restore`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
394
+ }
395
+ static DeleteVMSnapshot(req: DeleteVMSnapshotRequest, initReq?: fm.InitReq): Promise<DeleteVMSnapshotResponse> {
396
+ return fm.fetchReq<DeleteVMSnapshotRequest, DeleteVMSnapshotResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/snapshots/${req["snapshotName"]}`, {...initReq, method: "DELETE"})
397
+ }
398
+ static UpdateVMSnapshot(req: UpdateVMSnapshotRequest, initReq?: fm.InitReq): Promise<UpdateVMSnapshotResponse> {
399
+ return fm.fetchReq<UpdateVMSnapshotRequest, UpdateVMSnapshotResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/snapshots/${req["snapshotName"]}`, {...initReq, method: "PUT", body: JSON.stringify(req, fm.replacer)})
400
+ }
401
+ static CloneVM(req: CloneVMRequest, initReq?: fm.InitReq): Promise<CloneVMResponse> {
402
+ return fm.fetchReq<CloneVMRequest, CloneVMResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/clone`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
403
+ }
404
+ static ListSystemImages(req: ListSystemImagesRequest, initReq?: fm.InitReq): Promise<ListSystemImagesResponse> {
405
+ return fm.fetchReq<ListSystemImagesRequest, ListSystemImagesResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/system-images?${fm.renderURLSearchParams(req, ["cluster"])}`, {...initReq, method: "GET"})
406
+ }
407
+ static AddDiskVolumeToVM(req: AddDiskVolumeToVMRequest, initReq?: fm.InitReq): Promise<AddDiskVolumeToVMResponse> {
408
+ return fm.fetchReq<AddDiskVolumeToVMRequest, AddDiskVolumeToVMResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/disk-volume`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
409
+ }
410
+ static RemoveVMDiskVolume(req: RemoveVMDiskVolumeRequest, initReq?: fm.InitReq): Promise<RemoveVMDiskVolumeResponse> {
411
+ return fm.fetchReq<RemoveVMDiskVolumeRequest, RemoveVMDiskVolumeResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/disk-volume/${req["diskName"]}`, {...initReq, method: "DELETE"})
412
+ }
413
+ static ExpandVMDiskCapacity(req: ExpandVMDiskCapacityRequest, initReq?: fm.InitReq): Promise<ExpandVMDiskCapacityResponse> {
414
+ return fm.fetchReq<ExpandVMDiskCapacityRequest, ExpandVMDiskCapacityResponse>(`/apis/virtnest.io/v1alpha1/clusters/${req["cluster"]}/namespaces/${req["namespace"]}/vms/${req["name"]}/disk-volume/${req["diskName"]}/expand-capacity`, {...initReq, method: "PUT", body: JSON.stringify(req, fm.replacer)})
415
+ }
416
+ }