@truenas/api-client 3.0.1 → 3.0.2
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/dist/index.cjs +63 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -2
- package/dist/index.d.ts +54 -2
- package/dist/index.js +63 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -13015,6 +13015,33 @@ interface ContainerStopOptions$1 {
|
|
|
13015
13015
|
timeout?: number;
|
|
13016
13016
|
force: boolean;
|
|
13017
13017
|
}
|
|
13018
|
+
/**
|
|
13019
|
+
* Options for deleting a container (unified interface)
|
|
13020
|
+
*
|
|
13021
|
+
* Both are optional and both default to off, matching middleware. Neither has a
|
|
13022
|
+
* counterpart on v25.10 — `virt.instance.delete` takes an id and nothing else —
|
|
13023
|
+
* so the v25.10 client cannot honour them; it says so rather than dropping them
|
|
13024
|
+
* quietly, because `recursive` in particular destroys data.
|
|
13025
|
+
*/
|
|
13026
|
+
interface ContainerDeleteOptions$1 {
|
|
13027
|
+
/**
|
|
13028
|
+
* Stop the container first if it is not already stopped. Without it, v26+
|
|
13029
|
+
* refuses to delete a running or suspended container rather than tearing it
|
|
13030
|
+
* down underneath itself.
|
|
13031
|
+
*/
|
|
13032
|
+
force?: boolean;
|
|
13033
|
+
/**
|
|
13034
|
+
* Destroy the container's dataset together with its child datasets and
|
|
13035
|
+
* snapshots, any clones of those snapshots wherever they live in the pool,
|
|
13036
|
+
* and any holds on them.
|
|
13037
|
+
*
|
|
13038
|
+
* Releasing a hold can break a replication task that depends on it, and none
|
|
13039
|
+
* of what this destroys is recoverable. Without it, v26+ refuses to delete a
|
|
13040
|
+
* container whose dataset has children or snapshots — which is the refusal
|
|
13041
|
+
* this option exists to override, deliberately.
|
|
13042
|
+
*/
|
|
13043
|
+
recursive?: boolean;
|
|
13044
|
+
}
|
|
13018
13045
|
/**
|
|
13019
13046
|
* Options for restarting a container (unified interface)
|
|
13020
13047
|
*/
|
|
@@ -13058,8 +13085,14 @@ interface ContainerRestartOptions {
|
|
|
13058
13085
|
*
|
|
13059
13086
|
* To add new operations:
|
|
13060
13087
|
* 1. Add the method signature here
|
|
13061
|
-
* 2. Implement in
|
|
13062
|
-
*
|
|
13088
|
+
* 2. Implement it in every client's `createOperations()` —
|
|
13089
|
+
* `TrueNasApiClientV2510`, `TrueNasApiClientV26`, `TrueNasApiClientV27`
|
|
13090
|
+
*
|
|
13091
|
+
* This list used to name only v25.10 and v26, which is how a new operation
|
|
13092
|
+
* would have quietly missed v27. It is not the real safety net either: adding a
|
|
13093
|
+
* member here fails to compile in every client that has not implemented it, and
|
|
13094
|
+
* that is what actually enumerates them. Keep the list current, but trust the
|
|
13095
|
+
* compiler.
|
|
13063
13096
|
*/
|
|
13064
13097
|
interface OperationMappings {
|
|
13065
13098
|
/**
|
|
@@ -13086,6 +13119,22 @@ interface OperationMappings {
|
|
|
13086
13119
|
* - v26+: Emits Job updates (stop phase), then null (sync start)
|
|
13087
13120
|
*/
|
|
13088
13121
|
containerRestart: (id: string, options: ContainerRestartOptions) => Observable<Job | null>;
|
|
13122
|
+
/**
|
|
13123
|
+
* Delete a container
|
|
13124
|
+
* - v25.10: `virt.instance.delete`, already a job — emits Job updates
|
|
13125
|
+
* - v26+: `container.delete`, made a job in v26.0.0 — emits Job updates
|
|
13126
|
+
*
|
|
13127
|
+
* A job on every supported version, so unlike `containerStart` this one does
|
|
13128
|
+
* not change shape across them. It is exposed here because the alternative is
|
|
13129
|
+
* a caller reaching for `api.call('container.delete', …)`, which is the wrong
|
|
13130
|
+
* verb: the method moved out of the call directory when middleware made it a
|
|
13131
|
+
* job, so that does not compile on v26+ and would not track the job if it did.
|
|
13132
|
+
*
|
|
13133
|
+
* `options` are honoured on v26+ only. v25.10's `virt.instance.delete` takes
|
|
13134
|
+
* an id and nothing else; passing them there is logged rather than silently
|
|
13135
|
+
* ignored, because `recursive` destroys data that cannot be recovered.
|
|
13136
|
+
*/
|
|
13137
|
+
containerDelete: (id: string, options?: ContainerDeleteOptions$1) => Observable<Job | null>;
|
|
13089
13138
|
}
|
|
13090
13139
|
|
|
13091
13140
|
/**
|
|
@@ -27608,6 +27657,7 @@ declare function createTrueNasClient<D extends ApiDirectoryShape = DefaultApiDir
|
|
|
27608
27657
|
* - containerStart → virt.instance.start (emits Job updates)
|
|
27609
27658
|
* - containerStop → virt.instance.stop (emits Job updates)
|
|
27610
27659
|
* - containerRestart → virt.instance.restart (emits Job updates)
|
|
27660
|
+
* - containerDelete → virt.instance.delete (already a job; takes no options)
|
|
27611
27661
|
*/
|
|
27612
27662
|
declare class TrueNasApiClientV2510 extends TrueNasApiClient<ApiDirectory$7> {
|
|
27613
27663
|
/**
|
|
@@ -27645,6 +27695,7 @@ declare class TrueNasApiClientV2510 extends TrueNasApiClient<ApiDirectory$7> {
|
|
|
27645
27695
|
* - containerStart → container.start (synchronous, emits null)
|
|
27646
27696
|
* - containerStop → container.stop (emits Job updates)
|
|
27647
27697
|
* - containerRestart → container.stop + container.start (emits Job, then null)
|
|
27698
|
+
* - containerDelete → container.delete (a job since v26.0.0; force/recursive)
|
|
27648
27699
|
*/
|
|
27649
27700
|
declare class TrueNasApiClientV26 extends TrueNasApiClient<ApiDirectory$1> {
|
|
27650
27701
|
/**
|
|
@@ -27692,6 +27743,7 @@ declare class TrueNasApiClientV26 extends TrueNasApiClient<ApiDirectory$1> {
|
|
|
27692
27743
|
* - containerStart → container.start (synchronous, emits null)
|
|
27693
27744
|
* - containerStop → container.stop (emits Job updates)
|
|
27694
27745
|
* - containerRestart → container.stop + container.start (emits Job, then null)
|
|
27746
|
+
* - containerDelete → container.delete (a job since v26.0.0; force/recursive)
|
|
27695
27747
|
*
|
|
27696
27748
|
* Those four are currently identical to v26's, because v27 inherits all three
|
|
27697
27749
|
* container entries the facade touches rather than re-declaring them. Asserted
|
package/dist/index.d.ts
CHANGED
|
@@ -13015,6 +13015,33 @@ interface ContainerStopOptions$1 {
|
|
|
13015
13015
|
timeout?: number;
|
|
13016
13016
|
force: boolean;
|
|
13017
13017
|
}
|
|
13018
|
+
/**
|
|
13019
|
+
* Options for deleting a container (unified interface)
|
|
13020
|
+
*
|
|
13021
|
+
* Both are optional and both default to off, matching middleware. Neither has a
|
|
13022
|
+
* counterpart on v25.10 — `virt.instance.delete` takes an id and nothing else —
|
|
13023
|
+
* so the v25.10 client cannot honour them; it says so rather than dropping them
|
|
13024
|
+
* quietly, because `recursive` in particular destroys data.
|
|
13025
|
+
*/
|
|
13026
|
+
interface ContainerDeleteOptions$1 {
|
|
13027
|
+
/**
|
|
13028
|
+
* Stop the container first if it is not already stopped. Without it, v26+
|
|
13029
|
+
* refuses to delete a running or suspended container rather than tearing it
|
|
13030
|
+
* down underneath itself.
|
|
13031
|
+
*/
|
|
13032
|
+
force?: boolean;
|
|
13033
|
+
/**
|
|
13034
|
+
* Destroy the container's dataset together with its child datasets and
|
|
13035
|
+
* snapshots, any clones of those snapshots wherever they live in the pool,
|
|
13036
|
+
* and any holds on them.
|
|
13037
|
+
*
|
|
13038
|
+
* Releasing a hold can break a replication task that depends on it, and none
|
|
13039
|
+
* of what this destroys is recoverable. Without it, v26+ refuses to delete a
|
|
13040
|
+
* container whose dataset has children or snapshots — which is the refusal
|
|
13041
|
+
* this option exists to override, deliberately.
|
|
13042
|
+
*/
|
|
13043
|
+
recursive?: boolean;
|
|
13044
|
+
}
|
|
13018
13045
|
/**
|
|
13019
13046
|
* Options for restarting a container (unified interface)
|
|
13020
13047
|
*/
|
|
@@ -13058,8 +13085,14 @@ interface ContainerRestartOptions {
|
|
|
13058
13085
|
*
|
|
13059
13086
|
* To add new operations:
|
|
13060
13087
|
* 1. Add the method signature here
|
|
13061
|
-
* 2. Implement in
|
|
13062
|
-
*
|
|
13088
|
+
* 2. Implement it in every client's `createOperations()` —
|
|
13089
|
+
* `TrueNasApiClientV2510`, `TrueNasApiClientV26`, `TrueNasApiClientV27`
|
|
13090
|
+
*
|
|
13091
|
+
* This list used to name only v25.10 and v26, which is how a new operation
|
|
13092
|
+
* would have quietly missed v27. It is not the real safety net either: adding a
|
|
13093
|
+
* member here fails to compile in every client that has not implemented it, and
|
|
13094
|
+
* that is what actually enumerates them. Keep the list current, but trust the
|
|
13095
|
+
* compiler.
|
|
13063
13096
|
*/
|
|
13064
13097
|
interface OperationMappings {
|
|
13065
13098
|
/**
|
|
@@ -13086,6 +13119,22 @@ interface OperationMappings {
|
|
|
13086
13119
|
* - v26+: Emits Job updates (stop phase), then null (sync start)
|
|
13087
13120
|
*/
|
|
13088
13121
|
containerRestart: (id: string, options: ContainerRestartOptions) => Observable<Job | null>;
|
|
13122
|
+
/**
|
|
13123
|
+
* Delete a container
|
|
13124
|
+
* - v25.10: `virt.instance.delete`, already a job — emits Job updates
|
|
13125
|
+
* - v26+: `container.delete`, made a job in v26.0.0 — emits Job updates
|
|
13126
|
+
*
|
|
13127
|
+
* A job on every supported version, so unlike `containerStart` this one does
|
|
13128
|
+
* not change shape across them. It is exposed here because the alternative is
|
|
13129
|
+
* a caller reaching for `api.call('container.delete', …)`, which is the wrong
|
|
13130
|
+
* verb: the method moved out of the call directory when middleware made it a
|
|
13131
|
+
* job, so that does not compile on v26+ and would not track the job if it did.
|
|
13132
|
+
*
|
|
13133
|
+
* `options` are honoured on v26+ only. v25.10's `virt.instance.delete` takes
|
|
13134
|
+
* an id and nothing else; passing them there is logged rather than silently
|
|
13135
|
+
* ignored, because `recursive` destroys data that cannot be recovered.
|
|
13136
|
+
*/
|
|
13137
|
+
containerDelete: (id: string, options?: ContainerDeleteOptions$1) => Observable<Job | null>;
|
|
13089
13138
|
}
|
|
13090
13139
|
|
|
13091
13140
|
/**
|
|
@@ -27608,6 +27657,7 @@ declare function createTrueNasClient<D extends ApiDirectoryShape = DefaultApiDir
|
|
|
27608
27657
|
* - containerStart → virt.instance.start (emits Job updates)
|
|
27609
27658
|
* - containerStop → virt.instance.stop (emits Job updates)
|
|
27610
27659
|
* - containerRestart → virt.instance.restart (emits Job updates)
|
|
27660
|
+
* - containerDelete → virt.instance.delete (already a job; takes no options)
|
|
27611
27661
|
*/
|
|
27612
27662
|
declare class TrueNasApiClientV2510 extends TrueNasApiClient<ApiDirectory$7> {
|
|
27613
27663
|
/**
|
|
@@ -27645,6 +27695,7 @@ declare class TrueNasApiClientV2510 extends TrueNasApiClient<ApiDirectory$7> {
|
|
|
27645
27695
|
* - containerStart → container.start (synchronous, emits null)
|
|
27646
27696
|
* - containerStop → container.stop (emits Job updates)
|
|
27647
27697
|
* - containerRestart → container.stop + container.start (emits Job, then null)
|
|
27698
|
+
* - containerDelete → container.delete (a job since v26.0.0; force/recursive)
|
|
27648
27699
|
*/
|
|
27649
27700
|
declare class TrueNasApiClientV26 extends TrueNasApiClient<ApiDirectory$1> {
|
|
27650
27701
|
/**
|
|
@@ -27692,6 +27743,7 @@ declare class TrueNasApiClientV26 extends TrueNasApiClient<ApiDirectory$1> {
|
|
|
27692
27743
|
* - containerStart → container.start (synchronous, emits null)
|
|
27693
27744
|
* - containerStop → container.stop (emits Job updates)
|
|
27694
27745
|
* - containerRestart → container.stop + container.start (emits Job, then null)
|
|
27746
|
+
* - containerDelete → container.delete (a job since v26.0.0; force/recursive)
|
|
27695
27747
|
*
|
|
27696
27748
|
* Those four are currently identical to v26's, because v27 inherits all three
|
|
27697
27749
|
* container entries the facade touches rather than re-declaring them. Asserted
|
package/dist/index.js
CHANGED
|
@@ -3148,7 +3148,29 @@ var TrueNasApiClientV2510 = class extends TrueNasApiClient {
|
|
|
3148
3148
|
containerQuery: () => this.api.query("virt.instance.query", [["type", "=", "CONTAINER"]]).pipe(map((instances) => instances.map(toContainer))),
|
|
3149
3149
|
containerStart: (id) => this.api.job("virt.instance.start", [id]),
|
|
3150
3150
|
containerStop: (id, options) => this.api.job("virt.instance.stop", [id, options]),
|
|
3151
|
-
containerRestart: (id, options) => this.api.job("virt.instance.restart", [id, options])
|
|
3151
|
+
containerRestart: (id, options) => this.api.job("virt.instance.restart", [id, options]),
|
|
3152
|
+
// Already a job here — `virt.instance.delete` has been one since
|
|
3153
|
+
// v25.10.0 — so this needs no synthesis, only the id. It takes nothing
|
|
3154
|
+
// else: there is no `force` and no `recursive` on this version.
|
|
3155
|
+
//
|
|
3156
|
+
// Unsupported options are reported rather than dropped. `recursive`
|
|
3157
|
+
// destroys child datasets, snapshots and clones irrecoverably, so a
|
|
3158
|
+
// caller who asked for it and silently did not get it has been told
|
|
3159
|
+
// something false about what just happened to their data. Reporting is
|
|
3160
|
+
// all this layer can do — refusing outright would make `ops.containerDelete`
|
|
3161
|
+
// unusable on v25.10 for the ordinary case, which is the case that works.
|
|
3162
|
+
containerDelete: (id, options) => {
|
|
3163
|
+
const unsupported = ["force", "recursive"].filter(
|
|
3164
|
+
(key) => options?.[key]
|
|
3165
|
+
);
|
|
3166
|
+
if (unsupported.length > 0) {
|
|
3167
|
+
this.logger.warn(
|
|
3168
|
+
"containerDelete: v25.10 has no counterpart for these options and will delete without them",
|
|
3169
|
+
{ ignored: unsupported, id, method: "virt.instance.delete" }
|
|
3170
|
+
);
|
|
3171
|
+
}
|
|
3172
|
+
return this.api.job("virt.instance.delete", [id]);
|
|
3173
|
+
}
|
|
3152
3174
|
};
|
|
3153
3175
|
}
|
|
3154
3176
|
};
|
|
@@ -3216,7 +3238,26 @@ var TrueNasApiClientV26 = class extends TrueNasApiClient {
|
|
|
3216
3238
|
)
|
|
3217
3239
|
)
|
|
3218
3240
|
);
|
|
3219
|
-
}
|
|
3241
|
+
},
|
|
3242
|
+
// A job since v26.0.0 — middleware made deletion long-running (it stops
|
|
3243
|
+
// the container when asked, tears down the libvirt domain and destroys
|
|
3244
|
+
// the dataset), and the generated directory moved it out of `call`
|
|
3245
|
+
// accordingly. `api.job` is what tracks it; `api.call` would not compile.
|
|
3246
|
+
//
|
|
3247
|
+
// Options pass straight through when given: the unified
|
|
3248
|
+
// `ContainerDeleteOptions` is `force`/`recursive`, exactly what the
|
|
3249
|
+
// generated params take.
|
|
3250
|
+
//
|
|
3251
|
+
// When they are not given the argument is *omitted* rather than passed as
|
|
3252
|
+
// `undefined`. `JSON.stringify` renders a trailing `undefined` array
|
|
3253
|
+
// element as `null`, and middleware declares `options: ContainerDeleteOptions`
|
|
3254
|
+
// with a model default and no `| None` — so `[id, null]` is a validation
|
|
3255
|
+
// error rather than "use the defaults", which is the one thing a caller
|
|
3256
|
+
// passing nothing is asking for.
|
|
3257
|
+
containerDelete: (id, options) => this.api.job(
|
|
3258
|
+
"container.delete",
|
|
3259
|
+
options ? [parseInt(id, 10), options] : [parseInt(id, 10)]
|
|
3260
|
+
)
|
|
3220
3261
|
};
|
|
3221
3262
|
}
|
|
3222
3263
|
};
|
|
@@ -3278,7 +3319,26 @@ var TrueNasApiClientV27 = class extends TrueNasApiClient {
|
|
|
3278
3319
|
)
|
|
3279
3320
|
)
|
|
3280
3321
|
);
|
|
3281
|
-
}
|
|
3322
|
+
},
|
|
3323
|
+
// A job since v26.0.0 — middleware made deletion long-running (it stops
|
|
3324
|
+
// the container when asked, tears down the libvirt domain and destroys
|
|
3325
|
+
// the dataset), and the generated directory moved it out of `call`
|
|
3326
|
+
// accordingly. `api.job` is what tracks it; `api.call` would not compile.
|
|
3327
|
+
//
|
|
3328
|
+
// Options pass straight through when given: the unified
|
|
3329
|
+
// `ContainerDeleteOptions` is `force`/`recursive`, exactly what the
|
|
3330
|
+
// generated params take.
|
|
3331
|
+
//
|
|
3332
|
+
// When they are not given the argument is *omitted* rather than passed as
|
|
3333
|
+
// `undefined`. `JSON.stringify` renders a trailing `undefined` array
|
|
3334
|
+
// element as `null`, and middleware declares `options: ContainerDeleteOptions`
|
|
3335
|
+
// with a model default and no `| None` — so `[id, null]` is a validation
|
|
3336
|
+
// error rather than "use the defaults", which is the one thing a caller
|
|
3337
|
+
// passing nothing is asking for.
|
|
3338
|
+
containerDelete: (id, options) => this.api.job(
|
|
3339
|
+
"container.delete",
|
|
3340
|
+
options ? [parseInt(id, 10), options] : [parseInt(id, 10)]
|
|
3341
|
+
)
|
|
3282
3342
|
};
|
|
3283
3343
|
}
|
|
3284
3344
|
};
|