incus-ts 0.1.2 → 0.1.4

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,685 @@
1
+ export type IncusRecord = Record<string, unknown>;
2
+ export type IncusInstanceType = "container" | "virtual-machine" | string;
3
+ export type IncusBinaryInput = Blob | ArrayBuffer | ArrayBufferView | Uint8Array | ReadableStream<Uint8Array>;
4
+ export type IncusProgress = {
5
+ processedBytes?: number;
6
+ totalBytes?: number;
7
+ percent?: number;
8
+ speedBytesPerSecond?: number;
9
+ };
10
+ export type IncusEntity<T = unknown> = {
11
+ value: T;
12
+ etag?: string;
13
+ };
14
+ export type IncusMutationOptions = {
15
+ etag?: string;
16
+ };
17
+ export type IncusListOptions = {
18
+ filter?: string[];
19
+ allProjects?: boolean;
20
+ };
21
+ export type IncusScopeOptions = {
22
+ allProjects?: boolean;
23
+ };
24
+ export type IncusRequestContext = {
25
+ project?: string;
26
+ target?: string;
27
+ requireAuthenticated?: boolean;
28
+ };
29
+ export type IncusConnectionOptions = {
30
+ userAgent?: string;
31
+ authType?: string;
32
+ skipGetEvents?: boolean;
33
+ skipGetServer?: boolean;
34
+ headers?: HeadersInit;
35
+ fetch?: typeof fetch;
36
+ signal?: AbortSignal;
37
+ tempPath?: string;
38
+ tlsServerCert?: string;
39
+ tlsClientCert?: string;
40
+ tlsClientKey?: string;
41
+ tlsCA?: string;
42
+ insecureSkipVerify?: boolean;
43
+ identicalCertificate?: boolean;
44
+ oidcTokens?: {
45
+ accessToken?: string;
46
+ refreshToken?: string;
47
+ expiry?: string;
48
+ };
49
+ };
50
+ export type IncusSimpleStreamsOptions = IncusConnectionOptions & {
51
+ cachePath?: string;
52
+ cacheExpiryMs?: number;
53
+ };
54
+ export type IncusUnixConnectOptions = IncusConnectionOptions & {
55
+ socketPath?: string;
56
+ };
57
+ export type IncusHttpConnectOptions = IncusConnectionOptions & {
58
+ endpoint?: string;
59
+ };
60
+ export type IncusConnectKind = "incus" | "incus-public" | "incus-unix" | "incus-http" | "simple-streams";
61
+ export type IncusConnectionInfo = {
62
+ addresses: string[];
63
+ certificate?: string;
64
+ protocol?: string;
65
+ url?: string;
66
+ socketPath?: string;
67
+ project?: string;
68
+ target?: string;
69
+ };
70
+ export type IncusTransportRequestOptions = {
71
+ query?: Record<string, string | number | boolean | undefined>;
72
+ headers?: HeadersInit;
73
+ body?: unknown;
74
+ signal?: AbortSignal;
75
+ etag?: string;
76
+ context?: IncusRequestContext;
77
+ };
78
+ export type IncusTransportResponse<T = unknown> = {
79
+ status: number;
80
+ etag?: string;
81
+ data: T;
82
+ headers?: Headers;
83
+ };
84
+ export interface IncusTransport {
85
+ request<T = unknown>(method: string, path: string, options?: IncusTransportRequestOptions): Promise<IncusTransportResponse<T>>;
86
+ websocket?(path: string, protocols?: string | string[]): Promise<WebSocket>;
87
+ close?(): void;
88
+ }
89
+ export type IncusOperationWaitOptions = {
90
+ timeoutSeconds?: number;
91
+ signal?: AbortSignal;
92
+ };
93
+ export interface IncusOperation {
94
+ id: string;
95
+ wait(options?: IncusOperationWaitOptions): Promise<IncusRecord>;
96
+ cancel(): Promise<void>;
97
+ refresh(): Promise<IncusRecord>;
98
+ websocket(secret: string): Promise<WebSocket>;
99
+ onUpdate(handler: (operation: IncusRecord) => void): Promise<() => void>;
100
+ }
101
+ export interface IncusAwaitableOperation extends IncusOperation, PromiseLike<IncusRecord> {
102
+ catch<TResult = never>(onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<IncusRecord | TResult>;
103
+ finally(onFinally?: (() => void) | null): Promise<IncusRecord>;
104
+ }
105
+ export interface IncusRemoteOperation {
106
+ wait(options?: IncusOperationWaitOptions): Promise<void>;
107
+ cancelTarget(): Promise<void>;
108
+ target(): Promise<IncusRecord | null>;
109
+ onUpdate(handler: (operation: IncusRecord) => void): Promise<() => void>;
110
+ }
111
+ export type IncusEventStreamOptions = {
112
+ types?: string[];
113
+ allProjects?: boolean;
114
+ signal?: AbortSignal;
115
+ };
116
+ export type IncusEvent = {
117
+ type: string;
118
+ timestamp?: string;
119
+ metadata?: IncusRecord;
120
+ };
121
+ export interface IncusEventListener extends AsyncIterable<IncusEvent> {
122
+ close(): Promise<void>;
123
+ }
124
+ export interface ConnectionApi {
125
+ info(): Promise<IncusConnectionInfo>;
126
+ httpClient(): Promise<unknown>;
127
+ doHttp(request: Request): Promise<Response>;
128
+ disconnect(): void;
129
+ }
130
+ export interface ServerApi {
131
+ metrics(): Promise<string>;
132
+ get(): Promise<IncusEntity<IncusRecord>>;
133
+ resources(): Promise<IncusRecord>;
134
+ update(server: IncusRecord, options?: IncusMutationOptions): Promise<void>;
135
+ applyPreseed(config: IncusRecord): Promise<void>;
136
+ hasExtension(extension: string): Promise<boolean>;
137
+ isClustered(): Promise<boolean>;
138
+ }
139
+ export interface CertificatesApi {
140
+ fingerprints(): Promise<string[]>;
141
+ list(options?: IncusListOptions): Promise<IncusRecord[]>;
142
+ get(fingerprint: string): Promise<IncusEntity<IncusRecord>>;
143
+ create(certificate: IncusRecord): Promise<void>;
144
+ update(fingerprint: string, certificate: IncusRecord, options?: IncusMutationOptions): Promise<void>;
145
+ remove(fingerprint: string): Promise<void>;
146
+ createToken(certificate: IncusRecord): IncusAwaitableOperation;
147
+ }
148
+ export type ImageListOptions = IncusListOptions;
149
+ export type ImageDownloadOptions = {
150
+ signal?: AbortSignal;
151
+ onProgress?: (progress: IncusProgress) => void;
152
+ secret?: string;
153
+ };
154
+ export type ImageDownloadResult = {
155
+ metadataName?: string;
156
+ metadataSize?: number;
157
+ rootfsName?: string;
158
+ rootfsSize?: number;
159
+ };
160
+ export interface ImageAliasesApi {
161
+ list(): Promise<IncusRecord[]>;
162
+ names(): Promise<string[]>;
163
+ get(name: string, options?: {
164
+ imageType?: string;
165
+ }): Promise<IncusEntity<IncusRecord>>;
166
+ getArchitectures(name: string, options?: {
167
+ imageType?: string;
168
+ }): Promise<Record<string, IncusRecord>>;
169
+ create(alias: IncusRecord): Promise<void>;
170
+ update(name: string, alias: IncusRecord, options?: IncusMutationOptions): Promise<void>;
171
+ rename(name: string, alias: IncusRecord): Promise<void>;
172
+ remove(name: string): Promise<void>;
173
+ }
174
+ export interface ImagesApi {
175
+ list(options?: ImageListOptions): Promise<IncusRecord[]>;
176
+ fingerprints(options?: ImageListOptions): Promise<string[]>;
177
+ get(fingerprint: string, options?: {
178
+ secret?: string;
179
+ }): Promise<IncusEntity<IncusRecord>>;
180
+ downloadFile(fingerprint: string, options?: ImageDownloadOptions): Promise<ImageDownloadResult>;
181
+ create(image: IncusRecord, upload?: IncusRecord): IncusAwaitableOperation;
182
+ copyFrom(source: IncusImageClient, image: IncusRecord, options?: IncusRecord): Promise<IncusRemoteOperation>;
183
+ update(fingerprint: string, image: IncusRecord, options?: IncusMutationOptions): Promise<void>;
184
+ remove(fingerprint: string): IncusAwaitableOperation;
185
+ refresh(fingerprint: string): IncusAwaitableOperation;
186
+ createSecret(fingerprint: string): IncusAwaitableOperation;
187
+ export(fingerprint: string, request?: IncusRecord): IncusAwaitableOperation;
188
+ aliases: ImageAliasesApi;
189
+ }
190
+ export type InstanceListOptions = IncusListOptions & {
191
+ type?: IncusInstanceType;
192
+ full?: boolean;
193
+ };
194
+ export type InstanceExecOptions = {
195
+ stdin?: IncusBinaryInput;
196
+ stdout?: "pipe" | WritableStream<Uint8Array>;
197
+ stderr?: "pipe" | WritableStream<Uint8Array>;
198
+ signal?: AbortSignal;
199
+ onControl?: (socket: WebSocket) => void;
200
+ };
201
+ export type InstanceForkOptions = {
202
+ fromSnapshot?: string;
203
+ sourceProject?: string;
204
+ live?: boolean;
205
+ instanceOnly?: boolean;
206
+ refresh?: boolean;
207
+ refreshExcludeOlder?: boolean;
208
+ allowInconsistent?: boolean;
209
+ };
210
+ export type IncusExecOutputChunk = {
211
+ stream: "stdout" | "stderr";
212
+ chunk: Uint8Array;
213
+ };
214
+ export type IncusExecResult = {
215
+ operation: IncusRecord;
216
+ exitCode?: number;
217
+ ok: boolean;
218
+ };
219
+ export interface IncusExecProcess extends IncusOperation, AsyncIterable<Uint8Array>, PromiseLike<IncusExecResult> {
220
+ stdout: AsyncIterable<Uint8Array>;
221
+ stderr: AsyncIterable<Uint8Array>;
222
+ output(): AsyncIterable<IncusExecOutputChunk>;
223
+ waitResult(options?: IncusOperationWaitOptions): Promise<IncusExecResult>;
224
+ catch<TResult = never>(onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<IncusExecResult | TResult>;
225
+ finally(onFinally?: (() => void) | null): Promise<IncusExecResult>;
226
+ }
227
+ export type InstanceConsoleOptions = {
228
+ terminal?: WebSocket;
229
+ signal?: AbortSignal;
230
+ onControl?: (socket: WebSocket) => void;
231
+ };
232
+ export type InstanceConsoleDynamicResult = {
233
+ operation: IncusOperation;
234
+ attach: (terminal: WebSocket) => Promise<void>;
235
+ };
236
+ export type InstanceFilePutOptions = {
237
+ content: IncusBinaryInput;
238
+ uid?: number;
239
+ gid?: number;
240
+ mode?: number;
241
+ type?: "file" | "directory" | string;
242
+ writeMode?: "overwrite" | "append" | string;
243
+ };
244
+ export type InstanceFileResult = {
245
+ stream: ReadableStream<Uint8Array>;
246
+ uid?: number;
247
+ gid?: number;
248
+ mode?: number;
249
+ type?: string;
250
+ entries?: string[];
251
+ };
252
+ export interface InstanceLogsApi {
253
+ list(): Promise<string[]>;
254
+ get(filename: string): Promise<ReadableStream<Uint8Array>>;
255
+ remove(filename: string): Promise<void>;
256
+ getConsole(): Promise<ReadableStream<Uint8Array>>;
257
+ removeConsole(): Promise<void>;
258
+ }
259
+ export interface InstanceFilesApi {
260
+ get(path: string): Promise<InstanceFileResult>;
261
+ put(path: string, options: InstanceFilePutOptions): Promise<void>;
262
+ remove(path: string): Promise<void>;
263
+ sftp(): Promise<unknown>;
264
+ }
265
+ export interface InstanceTemplatesApi {
266
+ list(): Promise<string[]>;
267
+ get(templateName: string): Promise<ReadableStream<Uint8Array>>;
268
+ put(templateName: string, content: IncusBinaryInput): Promise<void>;
269
+ remove(templateName: string): Promise<void>;
270
+ }
271
+ export interface InstanceSnapshotsApi {
272
+ names(): Promise<string[]>;
273
+ list(): Promise<IncusRecord[]>;
274
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
275
+ create(snapshot: IncusRecord): IncusAwaitableOperation;
276
+ copyFrom(source: IncusClient, snapshot: IncusRecord, options?: IncusRecord): Promise<IncusRemoteOperation>;
277
+ rename(name: string, request: IncusRecord): IncusAwaitableOperation;
278
+ migrate(name: string, request: IncusRecord): IncusAwaitableOperation;
279
+ remove(name: string): IncusAwaitableOperation;
280
+ update(name: string, snapshot: IncusRecord, options?: IncusMutationOptions): IncusAwaitableOperation;
281
+ restore(name: string, options?: {
282
+ stateful?: boolean;
283
+ }): IncusAwaitableOperation;
284
+ }
285
+ export interface InstanceBackupsApi {
286
+ names(): Promise<string[]>;
287
+ list(): Promise<IncusRecord[]>;
288
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
289
+ create(backup: IncusRecord): IncusAwaitableOperation;
290
+ rename(name: string, backup: IncusRecord): IncusAwaitableOperation;
291
+ remove(name: string): IncusAwaitableOperation;
292
+ download(name: string): Promise<ReadableStream<Uint8Array>>;
293
+ upload(backup: IncusRecord, body: IncusBinaryInput): Promise<void>;
294
+ }
295
+ export interface InstanceApi {
296
+ readonly name: string;
297
+ get(options?: {
298
+ full?: boolean;
299
+ }): Promise<IncusEntity<IncusRecord>>;
300
+ fork(name: string, options?: InstanceForkOptions): IncusAwaitableOperation;
301
+ update(instance: IncusRecord, options?: IncusMutationOptions): IncusAwaitableOperation;
302
+ rename(request: IncusRecord): IncusAwaitableOperation;
303
+ migrate(request: IncusRecord): IncusAwaitableOperation;
304
+ remove(): IncusAwaitableOperation;
305
+ rebuild(request: IncusRecord): IncusAwaitableOperation;
306
+ rebuildFromImage(source: IncusImageClient, image: IncusRecord, request: IncusRecord): Promise<IncusRemoteOperation>;
307
+ restore(snapshotName: string, options?: {
308
+ stateful?: boolean;
309
+ }): IncusAwaitableOperation;
310
+ state(): Promise<IncusEntity<IncusRecord>>;
311
+ setState(state: IncusRecord, options?: IncusMutationOptions): IncusAwaitableOperation;
312
+ access(): Promise<IncusRecord>;
313
+ exec(request: IncusRecord, options?: InstanceExecOptions): IncusExecProcess;
314
+ console(request: IncusRecord, options?: InstanceConsoleOptions): IncusAwaitableOperation;
315
+ consoleDynamic(request: IncusRecord, options?: InstanceConsoleOptions): Promise<InstanceConsoleDynamicResult>;
316
+ metadata(): Promise<IncusEntity<IncusRecord>>;
317
+ updateMetadata(metadata: IncusRecord, options?: IncusMutationOptions): Promise<void>;
318
+ debugMemory(format?: string): Promise<ReadableStream<Uint8Array>>;
319
+ logs: InstanceLogsApi;
320
+ files: InstanceFilesApi;
321
+ templates: InstanceTemplatesApi;
322
+ snapshots: InstanceSnapshotsApi;
323
+ backups: InstanceBackupsApi;
324
+ }
325
+ export interface InstancesApi {
326
+ names(options?: InstanceListOptions): Promise<string[] | Record<string, string[]>>;
327
+ list(options?: InstanceListOptions): Promise<IncusRecord[]>;
328
+ instance(name: string): InstanceApi;
329
+ create(instance: IncusRecord): IncusAwaitableOperation;
330
+ createFromImage(source: IncusImageClient, image: IncusRecord, request: IncusRecord): Promise<IncusRemoteOperation>;
331
+ createFromBackup(args: IncusRecord): IncusAwaitableOperation;
332
+ copyFrom(source: IncusClient, instance: IncusRecord, options?: IncusRecord): Promise<IncusRemoteOperation>;
333
+ updateMany(state: IncusRecord, options?: IncusMutationOptions): IncusAwaitableOperation;
334
+ }
335
+ export interface EventsApi {
336
+ stream(options?: IncusEventStreamOptions): Promise<IncusEventListener>;
337
+ send(event: IncusEvent): Promise<void>;
338
+ }
339
+ export interface MetadataApi {
340
+ configuration(): Promise<IncusRecord>;
341
+ }
342
+ export interface NetworkForwardsApi {
343
+ addresses(networkName: string): Promise<string[]>;
344
+ list(networkName: string): Promise<IncusRecord[]>;
345
+ get(networkName: string, listenAddress: string): Promise<IncusEntity<IncusRecord>>;
346
+ create(networkName: string, request: IncusRecord): Promise<void>;
347
+ update(networkName: string, listenAddress: string, request: IncusRecord, options?: IncusMutationOptions): Promise<void>;
348
+ remove(networkName: string, listenAddress: string): Promise<void>;
349
+ }
350
+ export interface NetworkLoadBalancersApi {
351
+ addresses(networkName: string): Promise<string[]>;
352
+ list(networkName: string): Promise<IncusRecord[]>;
353
+ get(networkName: string, listenAddress: string): Promise<IncusEntity<IncusRecord>>;
354
+ state(networkName: string, listenAddress: string): Promise<IncusRecord>;
355
+ create(networkName: string, request: IncusRecord): Promise<void>;
356
+ update(networkName: string, listenAddress: string, request: IncusRecord, options?: IncusMutationOptions): Promise<void>;
357
+ remove(networkName: string, listenAddress: string): Promise<void>;
358
+ }
359
+ export interface NetworkPeersApi {
360
+ names(networkName: string): Promise<string[]>;
361
+ list(networkName: string): Promise<IncusRecord[]>;
362
+ get(networkName: string, peerName: string): Promise<IncusEntity<IncusRecord>>;
363
+ create(networkName: string, request: IncusRecord): Promise<void>;
364
+ update(networkName: string, peerName: string, request: IncusRecord, options?: IncusMutationOptions): Promise<void>;
365
+ remove(networkName: string, peerName: string): Promise<void>;
366
+ }
367
+ export interface NetworkAclsApi {
368
+ names(): Promise<string[]>;
369
+ list(options?: IncusScopeOptions): Promise<IncusRecord[]>;
370
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
371
+ getLog(name: string): Promise<ReadableStream<Uint8Array>>;
372
+ create(request: IncusRecord): Promise<void>;
373
+ update(name: string, request: IncusRecord, options?: IncusMutationOptions): Promise<void>;
374
+ rename(name: string, request: IncusRecord): Promise<void>;
375
+ remove(name: string): Promise<void>;
376
+ }
377
+ export interface NetworkAddressSetsApi {
378
+ names(): Promise<string[]>;
379
+ list(options?: IncusScopeOptions): Promise<IncusRecord[]>;
380
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
381
+ create(request: IncusRecord): Promise<void>;
382
+ update(name: string, request: IncusRecord, options?: IncusMutationOptions): Promise<void>;
383
+ rename(name: string, request: IncusRecord): Promise<void>;
384
+ remove(name: string): Promise<void>;
385
+ }
386
+ export interface NetworkZoneRecordsApi {
387
+ names(zone: string): Promise<string[]>;
388
+ list(zone: string): Promise<IncusRecord[]>;
389
+ get(zone: string, name: string): Promise<IncusEntity<IncusRecord>>;
390
+ create(zone: string, request: IncusRecord): Promise<void>;
391
+ update(zone: string, name: string, request: IncusRecord, options?: IncusMutationOptions): Promise<void>;
392
+ remove(zone: string, name: string): Promise<void>;
393
+ }
394
+ export interface NetworkZonesApi {
395
+ names(): Promise<string[]>;
396
+ list(options?: IncusScopeOptions): Promise<IncusRecord[]>;
397
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
398
+ create(request: IncusRecord): Promise<void>;
399
+ update(name: string, request: IncusRecord, options?: IncusMutationOptions): Promise<void>;
400
+ remove(name: string): Promise<void>;
401
+ records: NetworkZoneRecordsApi;
402
+ }
403
+ export interface NetworkIntegrationsApi {
404
+ names(): Promise<string[]>;
405
+ list(): Promise<IncusRecord[]>;
406
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
407
+ create(request: IncusRecord): Promise<void>;
408
+ update(name: string, request: IncusRecord, options?: IncusMutationOptions): Promise<void>;
409
+ rename(name: string, request: IncusRecord): Promise<void>;
410
+ remove(name: string): Promise<void>;
411
+ }
412
+ export interface NetworksApi {
413
+ names(): Promise<string[]>;
414
+ list(options?: IncusListOptions): Promise<IncusRecord[]>;
415
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
416
+ leases(name: string): Promise<IncusRecord[]>;
417
+ state(name: string): Promise<IncusRecord>;
418
+ create(request: IncusRecord): Promise<void>;
419
+ update(name: string, request: IncusRecord, options?: IncusMutationOptions): Promise<void>;
420
+ rename(name: string, request: IncusRecord): Promise<void>;
421
+ remove(name: string): Promise<void>;
422
+ allocations(options?: IncusScopeOptions): Promise<IncusRecord[]>;
423
+ forwards: NetworkForwardsApi;
424
+ loadBalancers: NetworkLoadBalancersApi;
425
+ peers: NetworkPeersApi;
426
+ acls: NetworkAclsApi;
427
+ addressSets: NetworkAddressSetsApi;
428
+ zones: NetworkZonesApi;
429
+ integrations: NetworkIntegrationsApi;
430
+ }
431
+ export interface OperationsApi {
432
+ uuids(): Promise<string[]>;
433
+ list(options?: IncusScopeOptions): Promise<IncusRecord[]>;
434
+ get(uuid: string): Promise<IncusEntity<IncusRecord>>;
435
+ wait(uuid: string, timeoutSeconds?: number): Promise<IncusEntity<IncusRecord>>;
436
+ waitWithSecret(uuid: string, secret: string, timeoutSeconds?: number): Promise<IncusEntity<IncusRecord>>;
437
+ websocket(uuid: string, secret: string): Promise<WebSocket>;
438
+ remove(uuid: string): Promise<void>;
439
+ }
440
+ export interface ProfilesApi {
441
+ names(): Promise<string[]>;
442
+ list(options?: IncusListOptions): Promise<IncusRecord[]>;
443
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
444
+ create(profile: IncusRecord): Promise<void>;
445
+ update(name: string, profile: IncusRecord, options?: IncusMutationOptions): Promise<void>;
446
+ rename(name: string, profile: IncusRecord): Promise<void>;
447
+ remove(name: string): Promise<void>;
448
+ }
449
+ export interface ProjectsApi {
450
+ names(): Promise<string[]>;
451
+ list(options?: IncusListOptions): Promise<IncusRecord[]>;
452
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
453
+ state(name: string): Promise<IncusRecord>;
454
+ access(name: string): Promise<IncusRecord>;
455
+ create(project: IncusRecord): Promise<void>;
456
+ update(name: string, project: IncusRecord, options?: IncusMutationOptions): Promise<void>;
457
+ rename(name: string, project: IncusRecord): IncusAwaitableOperation;
458
+ remove(name: string): Promise<void>;
459
+ removeForce(name: string): Promise<void>;
460
+ }
461
+ export interface StoragePoolsApi {
462
+ names(): Promise<string[]>;
463
+ list(options?: IncusListOptions): Promise<IncusRecord[]>;
464
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
465
+ resources(name: string): Promise<IncusRecord>;
466
+ create(pool: IncusRecord): Promise<void>;
467
+ update(name: string, pool: IncusRecord, options?: IncusMutationOptions): Promise<void>;
468
+ remove(name: string): Promise<void>;
469
+ }
470
+ export interface StorageBucketKeysApi {
471
+ names(poolName: string, bucketName: string): Promise<string[]>;
472
+ list(poolName: string, bucketName: string): Promise<IncusRecord[]>;
473
+ get(poolName: string, bucketName: string, keyName: string): Promise<IncusEntity<IncusRecord>>;
474
+ create(poolName: string, bucketName: string, key: IncusRecord): Promise<IncusRecord>;
475
+ update(poolName: string, bucketName: string, keyName: string, key: IncusRecord, options?: IncusMutationOptions): Promise<void>;
476
+ remove(poolName: string, bucketName: string, keyName: string): Promise<void>;
477
+ }
478
+ export interface StorageBucketBackupsApi {
479
+ create(poolName: string, bucketName: string, backup: IncusRecord): IncusAwaitableOperation;
480
+ remove(poolName: string, bucketName: string, name: string): IncusAwaitableOperation;
481
+ download(poolName: string, bucketName: string, name: string): Promise<ReadableStream<Uint8Array>>;
482
+ upload(poolName: string, bucketName: string, backup: IncusRecord, body: IncusBinaryInput): Promise<void>;
483
+ createFromBackup(poolName: string, args: IncusRecord): IncusAwaitableOperation;
484
+ }
485
+ export interface StorageBucketsApi {
486
+ names(poolName: string): Promise<string[]>;
487
+ list(poolName: string, options?: IncusListOptions & {
488
+ full?: boolean;
489
+ }): Promise<IncusRecord[]>;
490
+ get(poolName: string, bucketName: string, options?: {
491
+ full?: boolean;
492
+ }): Promise<IncusEntity<IncusRecord>>;
493
+ create(poolName: string, bucket: IncusRecord): Promise<IncusRecord>;
494
+ update(poolName: string, bucketName: string, bucket: IncusRecord, options?: IncusMutationOptions): Promise<void>;
495
+ remove(poolName: string, bucketName: string): Promise<void>;
496
+ keys: StorageBucketKeysApi;
497
+ backups: StorageBucketBackupsApi;
498
+ }
499
+ export interface StorageVolumeFilesApi {
500
+ get(poolName: string, volumeType: string, volumeName: string, filePath: string): Promise<InstanceFileResult>;
501
+ put(poolName: string, volumeType: string, volumeName: string, filePath: string, options: InstanceFilePutOptions): Promise<void>;
502
+ remove(poolName: string, volumeType: string, volumeName: string, filePath: string): Promise<void>;
503
+ }
504
+ export interface StorageVolumeSnapshotsApi {
505
+ names(poolName: string, volumeType: string, volumeName: string): Promise<string[]>;
506
+ list(poolName: string, volumeType: string, volumeName: string): Promise<IncusRecord[]>;
507
+ get(poolName: string, volumeType: string, volumeName: string, snapshotName: string): Promise<IncusEntity<IncusRecord>>;
508
+ create(poolName: string, volumeType: string, volumeName: string, request: IncusRecord): IncusAwaitableOperation;
509
+ rename(poolName: string, volumeType: string, volumeName: string, snapshotName: string, request: IncusRecord): IncusAwaitableOperation;
510
+ update(poolName: string, volumeType: string, volumeName: string, snapshotName: string, request: IncusRecord, options?: IncusMutationOptions): Promise<void>;
511
+ remove(poolName: string, volumeType: string, volumeName: string, snapshotName: string): IncusAwaitableOperation;
512
+ }
513
+ export interface StorageVolumeBackupsApi {
514
+ names(poolName: string, volumeName: string): Promise<string[]>;
515
+ list(poolName: string, volumeName: string): Promise<IncusRecord[]>;
516
+ get(poolName: string, volumeName: string, backupName: string): Promise<IncusEntity<IncusRecord>>;
517
+ create(poolName: string, volumeName: string, backup: IncusRecord): IncusAwaitableOperation;
518
+ rename(poolName: string, volumeName: string, backupName: string, request: IncusRecord): IncusAwaitableOperation;
519
+ remove(poolName: string, volumeName: string, backupName: string): IncusAwaitableOperation;
520
+ download(poolName: string, volumeName: string, backupName: string): Promise<ReadableStream<Uint8Array>>;
521
+ upload(poolName: string, volumeName: string, backup: IncusRecord, body: IncusBinaryInput): Promise<void>;
522
+ createFromBackup(poolName: string, args: IncusRecord): IncusAwaitableOperation;
523
+ createFromIso(poolName: string, args: IncusRecord): IncusAwaitableOperation;
524
+ }
525
+ export interface StorageVolumesApi {
526
+ names(poolName: string, options?: IncusScopeOptions): Promise<string[] | Record<string, string[]>>;
527
+ list(poolName: string, options?: IncusListOptions & {
528
+ full?: boolean;
529
+ }): Promise<IncusRecord[]>;
530
+ get(poolName: string, volumeType: string, name: string, options?: {
531
+ full?: boolean;
532
+ }): Promise<IncusEntity<IncusRecord>>;
533
+ state(poolName: string, volumeType: string, name: string): Promise<IncusRecord>;
534
+ create(poolName: string, volume: IncusRecord): Promise<void>;
535
+ update(poolName: string, volumeType: string, name: string, volume: IncusRecord, options?: IncusMutationOptions): Promise<void>;
536
+ remove(poolName: string, volumeType: string, name: string): Promise<void>;
537
+ rename(poolName: string, volumeType: string, name: string, request: IncusRecord): Promise<void>;
538
+ copyFrom(poolName: string, source: IncusClient, sourcePool: string, volume: IncusRecord, options?: IncusRecord): Promise<IncusRemoteOperation>;
539
+ moveFrom(poolName: string, source: IncusClient, sourcePool: string, volume: IncusRecord, options?: IncusRecord): Promise<IncusRemoteOperation>;
540
+ migrate(poolName: string, volume: IncusRecord): IncusAwaitableOperation;
541
+ createFromMigration(poolName: string, volume: IncusRecord): IncusAwaitableOperation;
542
+ snapshots: StorageVolumeSnapshotsApi;
543
+ backups: StorageVolumeBackupsApi;
544
+ files: StorageVolumeFilesApi;
545
+ sftp(poolName: string, volumeType: string, volumeName: string): Promise<unknown>;
546
+ }
547
+ export interface StorageApi {
548
+ pools: StoragePoolsApi;
549
+ buckets: StorageBucketsApi;
550
+ volumes: StorageVolumesApi;
551
+ }
552
+ export interface ClusterMembersApi {
553
+ names(): Promise<string[]>;
554
+ list(options?: IncusListOptions): Promise<IncusRecord[]>;
555
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
556
+ state(name: string): Promise<IncusEntity<IncusRecord>>;
557
+ create(member: IncusRecord): IncusAwaitableOperation;
558
+ update(name: string, member: IncusRecord, options?: IncusMutationOptions): Promise<void>;
559
+ rename(name: string, request: IncusRecord): Promise<void>;
560
+ remove(name: string, options?: {
561
+ force?: boolean;
562
+ pending?: boolean;
563
+ }): Promise<void>;
564
+ updateState(name: string, state: IncusRecord): IncusAwaitableOperation;
565
+ }
566
+ export interface ClusterGroupsApi {
567
+ names(): Promise<string[]>;
568
+ list(): Promise<IncusRecord[]>;
569
+ get(name: string): Promise<IncusEntity<IncusRecord>>;
570
+ create(group: IncusRecord): Promise<void>;
571
+ update(name: string, group: IncusRecord, options?: IncusMutationOptions): Promise<void>;
572
+ rename(name: string, request: IncusRecord): Promise<void>;
573
+ remove(name: string): Promise<void>;
574
+ }
575
+ export interface ClusterApi {
576
+ get(): Promise<IncusEntity<IncusRecord>>;
577
+ update(cluster: IncusRecord, options?: IncusMutationOptions): IncusAwaitableOperation;
578
+ updateCertificate(certificate: IncusRecord, options?: IncusMutationOptions): Promise<void>;
579
+ members: ClusterMembersApi;
580
+ groups: ClusterGroupsApi;
581
+ }
582
+ export interface WarningsApi {
583
+ uuids(): Promise<string[]>;
584
+ list(): Promise<IncusRecord[]>;
585
+ get(uuid: string): Promise<IncusEntity<IncusRecord>>;
586
+ update(uuid: string, warning: IncusRecord, options?: IncusMutationOptions): Promise<void>;
587
+ remove(uuid: string): Promise<void>;
588
+ }
589
+ export interface OidcApi {
590
+ tokens(): Promise<IncusRecord | null>;
591
+ }
592
+ export interface RawApi {
593
+ query<T = IncusRecord>(method: string, path: string, body?: unknown, options?: IncusMutationOptions): Promise<IncusEntity<T>>;
594
+ websocket(path: string): Promise<WebSocket>;
595
+ operation(method: string, path: string, body?: unknown, options?: IncusMutationOptions): IncusAwaitableOperation;
596
+ }
597
+ type InternalRequestOptions = Omit<IncusTransportRequestOptions, "context"> & {
598
+ applyContext?: boolean;
599
+ };
600
+ type IncusEnvelopeResult<T = unknown> = {
601
+ value: T;
602
+ etag?: string;
603
+ operation?: string;
604
+ status: number;
605
+ headers?: Headers;
606
+ };
607
+ export declare class IncusApiError extends Error {
608
+ readonly status: number;
609
+ readonly statusCode?: number;
610
+ readonly errorCode?: number;
611
+ readonly details?: unknown;
612
+ constructor(message: string, status: number, options?: {
613
+ statusCode?: number;
614
+ errorCode?: number;
615
+ details?: unknown;
616
+ });
617
+ }
618
+ export declare class IncusImageClient {
619
+ protected readonly transport: IncusTransport;
620
+ readonly endpoint: string;
621
+ readonly options: Readonly<IncusConnectionOptions>;
622
+ readonly connection: ConnectionApi;
623
+ readonly images: ImagesApi;
624
+ readonly raw: RawApi;
625
+ protected readonly contextState: Readonly<IncusRequestContext>;
626
+ protected readonly kind: IncusConnectKind;
627
+ private serverSnapshot?;
628
+ constructor(transport: IncusTransport, endpoint: string, options?: Readonly<IncusConnectionOptions>, context?: Readonly<IncusRequestContext>, kind?: IncusConnectKind);
629
+ get context(): Readonly<IncusRequestContext>;
630
+ disconnect(): void;
631
+ protected requestTransport(method: string, path: string, options?: InternalRequestOptions): Promise<IncusTransportResponse<unknown>>;
632
+ protected requestEnvelope<T = unknown>(method: string, path: string, options?: InternalRequestOptions): Promise<IncusEnvelopeResult<T>>;
633
+ protected requestBinary(method: string, path: string, options?: InternalRequestOptions): Promise<IncusEnvelopeResult<Uint8Array>>;
634
+ protected createOperationFromRequest(method: string, path: string, options?: InternalRequestOptions): IncusAwaitableOperation;
635
+ protected createOperationFromEnvelopeResult(method: string, path: string, result: IncusEnvelopeResult<unknown>): IncusOperation;
636
+ protected createOperation(id: string): IncusOperation;
637
+ protected openWebsocket(path: string, options?: {
638
+ applyContext?: boolean;
639
+ }): Promise<WebSocket>;
640
+ private getServerSnapshot;
641
+ private createConnectionApi;
642
+ private createRawApi;
643
+ private createImageAliasesApi;
644
+ private createImagesApi;
645
+ }
646
+ export declare class IncusClient extends IncusImageClient {
647
+ readonly server: ServerApi;
648
+ readonly certificates: CertificatesApi;
649
+ readonly instances: InstancesApi;
650
+ readonly events: EventsApi;
651
+ readonly metadata: MetadataApi;
652
+ readonly networks: NetworksApi;
653
+ readonly operations: OperationsApi;
654
+ readonly profiles: ProfilesApi;
655
+ readonly projects: ProjectsApi;
656
+ readonly storage: StorageApi;
657
+ readonly cluster: ClusterApi;
658
+ readonly warnings: WarningsApi;
659
+ readonly oidc: OidcApi;
660
+ constructor(transport: IncusTransport, endpoint: string, options?: Readonly<IncusConnectionOptions>, context?: Readonly<IncusRequestContext>, kind?: IncusConnectKind);
661
+ withContext(contextPatch: Partial<IncusRequestContext>): IncusClient;
662
+ project(name: string): IncusClient;
663
+ target(name: string): IncusClient;
664
+ requireAuthenticated(authenticated?: boolean): IncusClient;
665
+ private createServerApi;
666
+ private createOperationsApi;
667
+ private isPipeTarget;
668
+ private toWritableTarget;
669
+ private shouldAttachExecIO;
670
+ private shouldPipeExecIO;
671
+ private getExecFds;
672
+ private attachExecWebsockets;
673
+ private createInstancesApi;
674
+ }
675
+ export declare class Incus {
676
+ static connect(endpoint: string, options?: IncusConnectionOptions): Promise<IncusClient>;
677
+ static connectHttp(options?: IncusHttpConnectOptions): Promise<IncusClient>;
678
+ static connectUnix(options?: IncusUnixConnectOptions): Promise<IncusClient>;
679
+ static connectPublic(endpoint: string, options?: IncusConnectionOptions): Promise<IncusImageClient>;
680
+ static connectSimpleStreams(endpoint: string, options?: IncusSimpleStreamsOptions): Promise<IncusImageClient>;
681
+ static fromTransport(endpoint: string, transport: IncusTransport, options?: IncusConnectionOptions): IncusClient;
682
+ static fromImageTransport(endpoint: string, transport: IncusTransport, options?: IncusConnectionOptions): IncusImageClient;
683
+ }
684
+ export {};
685
+ //# sourceMappingURL=incus.d.ts.map