@truenas/api-client 1.0.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.
- package/README.md +38 -0
- package/dist/index.cjs +1561 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2627 -0
- package/dist/index.d.ts +2627 -0
- package/dist/index.js +1538 -0
- package/dist/index.js.map +1 -0
- package/package.json +75 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2627 @@
|
|
|
1
|
+
import * as rxjs from 'rxjs';
|
|
2
|
+
import { BehaviorSubject, Subject, Observable } from 'rxjs';
|
|
3
|
+
import * as rxjs_webSocket from 'rxjs/webSocket';
|
|
4
|
+
import { WebSocketSubjectConfig } from 'rxjs/webSocket';
|
|
5
|
+
|
|
6
|
+
interface TrueNasMessage {
|
|
7
|
+
id?: string;
|
|
8
|
+
/** JSON-RPC 2.0 protocol version, e.g. '2.0' (present on versioned-API messages). */
|
|
9
|
+
jsonrpc?: string;
|
|
10
|
+
msg?: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
support?: string[];
|
|
13
|
+
method?: string;
|
|
14
|
+
result?: unknown;
|
|
15
|
+
params?: unknown;
|
|
16
|
+
name?: string;
|
|
17
|
+
collection?: string;
|
|
18
|
+
fields?: unknown;
|
|
19
|
+
subs?: string[];
|
|
20
|
+
error?: {
|
|
21
|
+
error: number;
|
|
22
|
+
errname: string;
|
|
23
|
+
extra: (string | number)[];
|
|
24
|
+
reason: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare enum TrueNasAuthMechanism {
|
|
29
|
+
ApiKey = "API_KEY_PLAIN",
|
|
30
|
+
Password = "PASSWORD_PLAIN",
|
|
31
|
+
Otp = "OTP_TOKEN",
|
|
32
|
+
Token = "TOKEN_PLAIN"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare enum ProductType {
|
|
36
|
+
Community = "COMMUNITY_EDITION",
|
|
37
|
+
Enterprise = "ENTERPRISE"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare enum TrueNasEndpoint {
|
|
41
|
+
UpdateStatus = "update.status",
|
|
42
|
+
AppQuery = "app.query",
|
|
43
|
+
AppStart = "app.start",
|
|
44
|
+
AppStop = "app.stop",
|
|
45
|
+
AppRedeploy = "app.redeploy",
|
|
46
|
+
AppUpgrade = "app.upgrade",
|
|
47
|
+
CoreSubscribe = "core.subscribe",
|
|
48
|
+
ReplicationQuery = "replication.query",
|
|
49
|
+
ReplicationRun = "replication.run",
|
|
50
|
+
InterfaceQuery = "interface.query",
|
|
51
|
+
CloudBackupQuery = "cloud_backup.query",
|
|
52
|
+
CloudSyncQuery = "cloudsync.query",
|
|
53
|
+
VirtualInstanceQuery = "virt.instance.query",
|
|
54
|
+
VirtualInstanceStop = "virt.instance.stop",
|
|
55
|
+
VirtualInstanceStart = "virt.instance.start",
|
|
56
|
+
VirtualInstanceRestart = "virt.instance.restart",
|
|
57
|
+
ContainerQuery = "container.query",
|
|
58
|
+
ContainerStart = "container.start",
|
|
59
|
+
ContainerStop = "container.stop",
|
|
60
|
+
VmQuery = "vm.query",
|
|
61
|
+
VmStart = "vm.start",
|
|
62
|
+
VmStop = "vm.stop",
|
|
63
|
+
VmRestart = "vm.restart",
|
|
64
|
+
CoreDownload = "core.download",
|
|
65
|
+
CoreGetJobs = "core.get_jobs",
|
|
66
|
+
SystemInfo = "system.info",
|
|
67
|
+
SystemProductType = "system.product_type",
|
|
68
|
+
ExtendedSystemInfo = "webui.main.dashboard.sys_info",
|
|
69
|
+
DiskQuery = "disk.query",
|
|
70
|
+
DeviceGetInfo = "device.get_info",
|
|
71
|
+
CorePing = "core.ping",
|
|
72
|
+
GenerateToken = "auth.generate_token",
|
|
73
|
+
AlertList = "alert.list",
|
|
74
|
+
AuthLogin = "auth.login_ex",
|
|
75
|
+
AuthLogout = "auth.logout",
|
|
76
|
+
ApiKeyQuery = "api_key.query",
|
|
77
|
+
ApiKeyCreate = "api_key.create",
|
|
78
|
+
ApiKeyDelete = "api_key.delete",
|
|
79
|
+
FailOverStatus = "failover.status",
|
|
80
|
+
FailOverNode = "failover.node",
|
|
81
|
+
FailOverDisabledReasons = "failover.disabled.reasons",
|
|
82
|
+
PoolQuery = "pool.query",
|
|
83
|
+
DatasetQuery = "pool.dataset.query",
|
|
84
|
+
DatasetCreate = "pool.dataset.create",
|
|
85
|
+
DatasetDelete = "pool.dataset.delete",
|
|
86
|
+
SnapshotTaskCreate = "pool.snapshottask.create",
|
|
87
|
+
SnapshotTaskQuery = "pool.snapshottask.query",
|
|
88
|
+
SnapshotTaskDelete = "pool.snapshottask.delete",
|
|
89
|
+
SnapshotCreate = "pool.snapshot.create",
|
|
90
|
+
SnapshotDelete = "pool.snapshot.delete",
|
|
91
|
+
ReplicationCountEligibleSnapshots = "replication.count_eligible_manual_snapshots",
|
|
92
|
+
BootGetState = "boot.get_state",
|
|
93
|
+
TnConnectUpdate = "tn_connect.update",
|
|
94
|
+
HardwareVirtualizationVariant = "hardware.virtualization.variant",
|
|
95
|
+
KeychainCredentialGenerateSshKeyPair = "keychaincredential.generate_ssh_key_pair",
|
|
96
|
+
KeychainCredentialCreate = "keychaincredential.create",
|
|
97
|
+
KeychainCredentialRemoteSshHostKeyScan = "keychaincredential.remote_ssh_host_key_scan",
|
|
98
|
+
KeychainCredentialDelete = "keychaincredential.delete",
|
|
99
|
+
ReplicationCreate = "replication.create",
|
|
100
|
+
UserQuery = "user.query",
|
|
101
|
+
UserUpdate = "user.update",
|
|
102
|
+
NetworkConfiguration = "network.configuration.config",
|
|
103
|
+
ServiceQuery = "service.query",
|
|
104
|
+
ServiceUpdate = "service.update",
|
|
105
|
+
ServiceControl = "service.control"
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare enum VirtVariant {
|
|
109
|
+
Amazon = "amazon",
|
|
110
|
+
Bhyve = "bhyve",
|
|
111
|
+
Docker = "docker",
|
|
112
|
+
Kvm = "kvm",
|
|
113
|
+
Lxc = "lxc",
|
|
114
|
+
Microsoft = "microsoft",
|
|
115
|
+
None = "none",
|
|
116
|
+
Oracle = "oracle",
|
|
117
|
+
Parallels = "parallels",
|
|
118
|
+
Qemu = "qemu",
|
|
119
|
+
Rkt = "rkt",
|
|
120
|
+
SystemdNspawn = "systemd-nspawn",
|
|
121
|
+
Uml = "uml",
|
|
122
|
+
Vmware = "vmware",
|
|
123
|
+
Xen = "xen"
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare enum FailoverStatus {
|
|
127
|
+
Master = "MASTER",
|
|
128
|
+
Backup = "BACKUP",
|
|
129
|
+
Electing = "ELECTING",
|
|
130
|
+
Importing = "IMPORTING",
|
|
131
|
+
Error = "ERROR",
|
|
132
|
+
Single = "SINGLE"
|
|
133
|
+
}
|
|
134
|
+
type FailoverNode = 'A' | 'B' | 'MANUAL';
|
|
135
|
+
|
|
136
|
+
interface VirtualizationStopParams {
|
|
137
|
+
timeout?: number;
|
|
138
|
+
force: boolean;
|
|
139
|
+
force_after_timeout?: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
type TrueNasDate = {
|
|
143
|
+
$date: number;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* alert level corresponds directly with IETF RFC 5424 minus the debug level.
|
|
148
|
+
* see https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
|
|
149
|
+
* for levels and their descriptions.
|
|
150
|
+
*
|
|
151
|
+
* `AlertLevel` values are always CAPITALIZED.
|
|
152
|
+
*/
|
|
153
|
+
declare enum AlertLevel {
|
|
154
|
+
Emergency = "EMERGENCY",
|
|
155
|
+
Alert = "ALERT",
|
|
156
|
+
Critical = "CRITICAL",
|
|
157
|
+
Error = "ERROR",
|
|
158
|
+
Warning = "WARNING",
|
|
159
|
+
Notice = "NOTICE",
|
|
160
|
+
Info = "INFO"
|
|
161
|
+
}
|
|
162
|
+
interface Alert {
|
|
163
|
+
uuid: string;
|
|
164
|
+
source: string;
|
|
165
|
+
args: string;
|
|
166
|
+
node: string;
|
|
167
|
+
datetime: TrueNasDate;
|
|
168
|
+
last_occurrence: TrueNasDate;
|
|
169
|
+
dismissed: boolean;
|
|
170
|
+
text: string;
|
|
171
|
+
id: string;
|
|
172
|
+
level: AlertLevel;
|
|
173
|
+
formatted: string;
|
|
174
|
+
one_shot: boolean;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
interface ApiKeyCreate {
|
|
178
|
+
id: number;
|
|
179
|
+
key: string;
|
|
180
|
+
name: string;
|
|
181
|
+
username: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface AppQuery {
|
|
185
|
+
id: string;
|
|
186
|
+
name: string;
|
|
187
|
+
state: AppState;
|
|
188
|
+
version: string;
|
|
189
|
+
upgrade_available: boolean;
|
|
190
|
+
metadata: {
|
|
191
|
+
version: string;
|
|
192
|
+
app_version: string;
|
|
193
|
+
train: string;
|
|
194
|
+
home: string;
|
|
195
|
+
icon: string;
|
|
196
|
+
};
|
|
197
|
+
portals: Record<string, string>;
|
|
198
|
+
}
|
|
199
|
+
declare enum AppState {
|
|
200
|
+
Running = "RUNNING",
|
|
201
|
+
Stopped = "STOPPED",
|
|
202
|
+
Stopping = "STOPPING",
|
|
203
|
+
Deploying = "DEPLOYING"
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
interface AppUpgradeParams {
|
|
207
|
+
app_version: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
declare enum UserRole {
|
|
211
|
+
FullAdmin = "FULL_ADMIN"
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
interface UserPreferences {
|
|
215
|
+
language: string;
|
|
216
|
+
lifetime: number;
|
|
217
|
+
}
|
|
218
|
+
declare enum AuthResponseType {
|
|
219
|
+
Success = "SUCCESS",
|
|
220
|
+
OtpRequired = "OTP_REQUIRED",
|
|
221
|
+
AuthErr = "AUTH_ERR",
|
|
222
|
+
Expired = "EXPIRED",
|
|
223
|
+
Redirect = "REDIRECT"
|
|
224
|
+
}
|
|
225
|
+
interface AuthResponse {
|
|
226
|
+
response_type: AuthResponseType;
|
|
227
|
+
username?: string;
|
|
228
|
+
authenticator?: 'LEVEL_1' | 'LEVEL_2' | 'LEVEL_3';
|
|
229
|
+
max_session_age?: number;
|
|
230
|
+
max_inactivity?: number;
|
|
231
|
+
urls?: string[];
|
|
232
|
+
user_info?: {
|
|
233
|
+
username: string;
|
|
234
|
+
fullname: string;
|
|
235
|
+
builtin: boolean;
|
|
236
|
+
email: string | null;
|
|
237
|
+
groups: number[];
|
|
238
|
+
privilege: {
|
|
239
|
+
roles: {
|
|
240
|
+
$set: UserRole[];
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
two_factor_auth_configured: boolean;
|
|
244
|
+
immutable: boolean;
|
|
245
|
+
sid: string;
|
|
246
|
+
id: number;
|
|
247
|
+
uid: number;
|
|
248
|
+
gid: number;
|
|
249
|
+
shell: string;
|
|
250
|
+
home: string;
|
|
251
|
+
locked: boolean;
|
|
252
|
+
sudo: boolean;
|
|
253
|
+
sudo_nopasswd: boolean;
|
|
254
|
+
sudo_commands: string[];
|
|
255
|
+
smb: boolean;
|
|
256
|
+
group: {
|
|
257
|
+
id: number;
|
|
258
|
+
bsdgrp_builtin: boolean;
|
|
259
|
+
bsdgrp_gid: number;
|
|
260
|
+
bsdgrp_group: string;
|
|
261
|
+
bsdgrp_sudo: boolean;
|
|
262
|
+
bsdgrp_sudo_nopasswd: boolean;
|
|
263
|
+
bsdgrp_sudo_commands: string[];
|
|
264
|
+
bsdgrp_smb: boolean;
|
|
265
|
+
bsdgrp_users: number[];
|
|
266
|
+
};
|
|
267
|
+
sshpubkey: string | null;
|
|
268
|
+
attributes: {
|
|
269
|
+
[key: string]: unknown;
|
|
270
|
+
preferences: UserPreferences;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
interface Job {
|
|
276
|
+
id: number;
|
|
277
|
+
method: string;
|
|
278
|
+
arguments: string[];
|
|
279
|
+
description: string | null;
|
|
280
|
+
abortable: boolean;
|
|
281
|
+
logs_path: string | null;
|
|
282
|
+
logs_excerpt: string | null;
|
|
283
|
+
progress: JobProgress;
|
|
284
|
+
error: string | null;
|
|
285
|
+
time_started: TrueNasDate;
|
|
286
|
+
time_finished: TrueNasDate | null;
|
|
287
|
+
state: JobState;
|
|
288
|
+
/**
|
|
289
|
+
* Array of JSON-RPC request IDs that triggered this job.
|
|
290
|
+
* Used in v26+ to correlate API calls with their jobs.
|
|
291
|
+
*/
|
|
292
|
+
message_ids?: string[];
|
|
293
|
+
}
|
|
294
|
+
interface JobProgress {
|
|
295
|
+
percent: number;
|
|
296
|
+
description: string;
|
|
297
|
+
}
|
|
298
|
+
declare enum JobState {
|
|
299
|
+
Pending = "PENDING",
|
|
300
|
+
Running = "RUNNING",
|
|
301
|
+
Hold = "HOLD",
|
|
302
|
+
Error = "ERROR",
|
|
303
|
+
Failed = "FAILED",
|
|
304
|
+
Aborted = "ABORTED",
|
|
305
|
+
Success = "SUCCESS",
|
|
306
|
+
Finished = "FINISHED",
|
|
307
|
+
Locked = "LOCKED",
|
|
308
|
+
Waiting = "WAITING"
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
interface Schedule {
|
|
312
|
+
minute?: string;
|
|
313
|
+
hour?: string;
|
|
314
|
+
dom?: string;
|
|
315
|
+
month?: string;
|
|
316
|
+
dow?: string;
|
|
317
|
+
begin?: string;
|
|
318
|
+
end?: string;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
interface CloudBackupQuery {
|
|
322
|
+
id: number;
|
|
323
|
+
description: string;
|
|
324
|
+
enabled: boolean;
|
|
325
|
+
schedule: Schedule;
|
|
326
|
+
job?: Job;
|
|
327
|
+
name?: string;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
interface CloudSyncQuery {
|
|
331
|
+
id: number;
|
|
332
|
+
description: string;
|
|
333
|
+
path: string;
|
|
334
|
+
attributes: {
|
|
335
|
+
folder: string;
|
|
336
|
+
fast_list: boolean;
|
|
337
|
+
acknowledge_abuse: boolean;
|
|
338
|
+
};
|
|
339
|
+
snapshot: boolean;
|
|
340
|
+
include: string[];
|
|
341
|
+
exclude: string[];
|
|
342
|
+
transfers: number;
|
|
343
|
+
enabled: boolean;
|
|
344
|
+
job?: Job;
|
|
345
|
+
direction: 'PUSH' | 'PULL';
|
|
346
|
+
transfer_mode: 'COPY' | 'SYNC' | 'MOVE';
|
|
347
|
+
encryption: boolean;
|
|
348
|
+
filename_encryption: boolean;
|
|
349
|
+
follow_symlinks: boolean;
|
|
350
|
+
schedule: {
|
|
351
|
+
minute: string;
|
|
352
|
+
hour: string;
|
|
353
|
+
dom: string;
|
|
354
|
+
month: string;
|
|
355
|
+
dow: string;
|
|
356
|
+
};
|
|
357
|
+
locked: boolean;
|
|
358
|
+
name?: string;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Unified Container type
|
|
363
|
+
*
|
|
364
|
+
* This interface provides a version-agnostic representation of a container.
|
|
365
|
+
* It normalizes the response from different API versions:
|
|
366
|
+
* - v25.10: virt.instance.query (filtered by type=CONTAINER)
|
|
367
|
+
* - v26+: container.query
|
|
368
|
+
*
|
|
369
|
+
* Components should use this type instead of version-specific response types.
|
|
370
|
+
*/
|
|
371
|
+
interface Container {
|
|
372
|
+
id: string;
|
|
373
|
+
name: string;
|
|
374
|
+
status: AppState;
|
|
375
|
+
autostart: boolean;
|
|
376
|
+
description?: string;
|
|
377
|
+
cpu?: string;
|
|
378
|
+
memory?: number;
|
|
379
|
+
image?: {
|
|
380
|
+
description: string;
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Options for stopping a container (unified interface)
|
|
385
|
+
*/
|
|
386
|
+
interface ContainerStopOptions {
|
|
387
|
+
timeout?: number;
|
|
388
|
+
force: boolean;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Options for restarting a container (unified interface)
|
|
392
|
+
*/
|
|
393
|
+
interface ContainerRestartOptions {
|
|
394
|
+
timeout?: number;
|
|
395
|
+
force: boolean;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* v26+ container.stop options format
|
|
399
|
+
*/
|
|
400
|
+
interface ContainerStopOptionsV26 {
|
|
401
|
+
force: boolean;
|
|
402
|
+
force_after_timeout: boolean;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* v26+ container.query response structure
|
|
406
|
+
* Used internally for transformation to unified Container type
|
|
407
|
+
*/
|
|
408
|
+
interface ContainerQueryV26 {
|
|
409
|
+
id: number;
|
|
410
|
+
uuid: string;
|
|
411
|
+
name: string;
|
|
412
|
+
description: string;
|
|
413
|
+
autostart: boolean;
|
|
414
|
+
status: {
|
|
415
|
+
state: string;
|
|
416
|
+
pid: number | null;
|
|
417
|
+
domain_state: string | null;
|
|
418
|
+
};
|
|
419
|
+
cpuset: string | null;
|
|
420
|
+
dataset: string;
|
|
421
|
+
devices: ContainerDeviceV26[];
|
|
422
|
+
time: string;
|
|
423
|
+
shutdown_timeout: number;
|
|
424
|
+
init: string;
|
|
425
|
+
initdir: string | null;
|
|
426
|
+
initenv: Record<string, string>;
|
|
427
|
+
inituser: string | null;
|
|
428
|
+
initgroup: string | null;
|
|
429
|
+
idmap: {
|
|
430
|
+
type: string;
|
|
431
|
+
};
|
|
432
|
+
capabilities_policy: string;
|
|
433
|
+
capabilities_state: Record<string, unknown>;
|
|
434
|
+
}
|
|
435
|
+
interface ContainerDeviceV26 {
|
|
436
|
+
id: number;
|
|
437
|
+
attributes: {
|
|
438
|
+
dtype: string;
|
|
439
|
+
usb?: {
|
|
440
|
+
vendor_id: string;
|
|
441
|
+
product_id: string;
|
|
442
|
+
};
|
|
443
|
+
device: string | null;
|
|
444
|
+
};
|
|
445
|
+
container: number;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
type CoreDownload = [jobId: number, url: string];
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Dataset type values for ZFS filesystem and volume datasets.
|
|
452
|
+
* Matches TrueNAS middleware API dataset types.
|
|
453
|
+
*/
|
|
454
|
+
declare enum DatasetType {
|
|
455
|
+
Filesystem = "FILESYSTEM",
|
|
456
|
+
Volume = "VOLUME"
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
interface DatasetProperty {
|
|
460
|
+
parsed: string | number | boolean;
|
|
461
|
+
rawvalue: string;
|
|
462
|
+
source: string;
|
|
463
|
+
source_info: string;
|
|
464
|
+
value: string;
|
|
465
|
+
}
|
|
466
|
+
interface Dataset {
|
|
467
|
+
aclmode: DatasetProperty;
|
|
468
|
+
acltype: DatasetProperty;
|
|
469
|
+
atime: DatasetProperty;
|
|
470
|
+
available: DatasetProperty;
|
|
471
|
+
casesensitivity: DatasetProperty;
|
|
472
|
+
children: Dataset[];
|
|
473
|
+
compression: DatasetProperty;
|
|
474
|
+
compressratio: DatasetProperty;
|
|
475
|
+
copies: DatasetProperty;
|
|
476
|
+
creation: DatasetProperty;
|
|
477
|
+
deduplication: DatasetProperty;
|
|
478
|
+
encryption_algorithm: DatasetProperty;
|
|
479
|
+
exec: DatasetProperty;
|
|
480
|
+
key_format: DatasetProperty;
|
|
481
|
+
origin: DatasetProperty;
|
|
482
|
+
pbkdf2iters: DatasetProperty;
|
|
483
|
+
quota: DatasetProperty;
|
|
484
|
+
readonly: DatasetProperty;
|
|
485
|
+
checksum: DatasetProperty;
|
|
486
|
+
recordsize: DatasetProperty;
|
|
487
|
+
refquota: DatasetProperty;
|
|
488
|
+
refreservation: DatasetProperty;
|
|
489
|
+
reservation: DatasetProperty;
|
|
490
|
+
snapdev: DatasetProperty;
|
|
491
|
+
snapdir: DatasetProperty;
|
|
492
|
+
special_small_block_size: DatasetProperty;
|
|
493
|
+
sync: DatasetProperty;
|
|
494
|
+
used: DatasetProperty;
|
|
495
|
+
usedbychildren: DatasetProperty;
|
|
496
|
+
usedbydataset: DatasetProperty;
|
|
497
|
+
usedbyrefreservation: DatasetProperty;
|
|
498
|
+
usedbysnapshots: DatasetProperty;
|
|
499
|
+
xattr: DatasetProperty;
|
|
500
|
+
encrypted: boolean;
|
|
501
|
+
key_loaded: boolean;
|
|
502
|
+
locked: boolean;
|
|
503
|
+
mountpoint: string;
|
|
504
|
+
name: string;
|
|
505
|
+
pool: string;
|
|
506
|
+
type: DatasetType;
|
|
507
|
+
id: string;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
declare enum DeviceType {
|
|
511
|
+
Gpu = "GPU",
|
|
512
|
+
Disk = "DISK",
|
|
513
|
+
Serial = "SERIAL"
|
|
514
|
+
}
|
|
515
|
+
interface GpuDevice {
|
|
516
|
+
addr: {
|
|
517
|
+
pci_slot: string;
|
|
518
|
+
domain: string;
|
|
519
|
+
bus: string;
|
|
520
|
+
slot: string;
|
|
521
|
+
};
|
|
522
|
+
description: string;
|
|
523
|
+
devices: {
|
|
524
|
+
pci_id: string;
|
|
525
|
+
pci_slot: string;
|
|
526
|
+
vm_pci_slot: string;
|
|
527
|
+
}[];
|
|
528
|
+
vendor: string | null;
|
|
529
|
+
uses_system_critical_devices: boolean;
|
|
530
|
+
critical_reason: string;
|
|
531
|
+
available_to_host: boolean;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
interface DiskQuery {
|
|
535
|
+
identifier: string;
|
|
536
|
+
name: string;
|
|
537
|
+
subsystem: string;
|
|
538
|
+
number: number;
|
|
539
|
+
serial: string;
|
|
540
|
+
lunid: string | null;
|
|
541
|
+
size: number;
|
|
542
|
+
description: string;
|
|
543
|
+
transfermode: string;
|
|
544
|
+
hddstandby: string;
|
|
545
|
+
advpowermgmt: string;
|
|
546
|
+
togglesmart: boolean;
|
|
547
|
+
model: string;
|
|
548
|
+
rotationrate: number | null;
|
|
549
|
+
type: 'SSD' | 'HDD';
|
|
550
|
+
devname: string;
|
|
551
|
+
pool: string | null;
|
|
552
|
+
enclosure: string | null;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Address family types for network interface aliases.
|
|
557
|
+
* Corresponds to middleware's AddressFamily enum.
|
|
558
|
+
*
|
|
559
|
+
* These values indicate the type of address contained in an interface alias.
|
|
560
|
+
*/
|
|
561
|
+
declare enum InterfaceAddressFamily {
|
|
562
|
+
/**
|
|
563
|
+
* Unix domain socket address (rarely used in network interfaces)
|
|
564
|
+
*/
|
|
565
|
+
Unix = "UNIX",
|
|
566
|
+
/**
|
|
567
|
+
* IPv4 address (Internet Protocol version 4)
|
|
568
|
+
*/
|
|
569
|
+
Inet = "INET",
|
|
570
|
+
/**
|
|
571
|
+
* IPv6 address (Internet Protocol version 6)
|
|
572
|
+
*/
|
|
573
|
+
Inet6 = "INET6",
|
|
574
|
+
/**
|
|
575
|
+
* Link layer address (MAC address)
|
|
576
|
+
*/
|
|
577
|
+
Link = "LINK"
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* LACP data unit transmission rate.
|
|
582
|
+
* Corresponds to middleware's lacpdu_rate field values.
|
|
583
|
+
*
|
|
584
|
+
* Controls how frequently LACP packets are exchanged between bonded interfaces
|
|
585
|
+
* for monitoring link health and detecting failures.
|
|
586
|
+
*/
|
|
587
|
+
declare enum InterfaceLacpRate {
|
|
588
|
+
/**
|
|
589
|
+
* Send LACP packets every 30 seconds
|
|
590
|
+
* Standard link monitoring interval, suitable for most deployments
|
|
591
|
+
*/
|
|
592
|
+
Slow = "SLOW",
|
|
593
|
+
/**
|
|
594
|
+
* Send LACP packets every 1 second
|
|
595
|
+
* Rapid link failure detection for mission-critical applications
|
|
596
|
+
*/
|
|
597
|
+
Fast = "FAST"
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Link aggregation protocols for bonding network interfaces.
|
|
602
|
+
* Corresponds to middleware's lag_protocol field values.
|
|
603
|
+
*
|
|
604
|
+
* These protocols determine how multiple physical interfaces are combined
|
|
605
|
+
* into a single logical interface for redundancy and/or increased bandwidth.
|
|
606
|
+
*/
|
|
607
|
+
declare enum InterfaceLagProtocol {
|
|
608
|
+
/**
|
|
609
|
+
* LACP (Link Aggregation Control Protocol) - IEEE 802.3ad
|
|
610
|
+
* Dynamic link aggregation with automatic failover and load balancing
|
|
611
|
+
*/
|
|
612
|
+
Lacp = "LACP",
|
|
613
|
+
/**
|
|
614
|
+
* Active-backup failover
|
|
615
|
+
* One interface active, others standby. Provides redundancy but not load balancing.
|
|
616
|
+
*/
|
|
617
|
+
Failover = "FAILOVER",
|
|
618
|
+
/**
|
|
619
|
+
* Load balancing across all bonded interfaces
|
|
620
|
+
* Distributes traffic based on configured hash policy
|
|
621
|
+
*/
|
|
622
|
+
LoadBalance = "LOADBALANCE",
|
|
623
|
+
/**
|
|
624
|
+
* Round-robin distribution
|
|
625
|
+
* Distributes packets across interfaces in sequential order
|
|
626
|
+
*/
|
|
627
|
+
RoundRobin = "ROUNDROBIN",
|
|
628
|
+
/**
|
|
629
|
+
* No aggregation protocol configured
|
|
630
|
+
*/
|
|
631
|
+
None = "NONE"
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Interface link state values.
|
|
636
|
+
* Corresponds to middleware's InterfaceLinkState enum.
|
|
637
|
+
*
|
|
638
|
+
* These values indicate the operational state of a network interface's link.
|
|
639
|
+
*/
|
|
640
|
+
declare enum InterfaceLinkState {
|
|
641
|
+
/**
|
|
642
|
+
* Link state is unknown or not applicable
|
|
643
|
+
*/
|
|
644
|
+
Unknown = "LINK_STATE_UNKNOWN",
|
|
645
|
+
/**
|
|
646
|
+
* Link is down - no carrier signal detected
|
|
647
|
+
*/
|
|
648
|
+
Down = "LINK_STATE_DOWN",
|
|
649
|
+
/**
|
|
650
|
+
* Link is up - carrier signal is active and operational
|
|
651
|
+
*/
|
|
652
|
+
Up = "LINK_STATE_UP"
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Network interface types.
|
|
657
|
+
* Corresponds to middleware's InterfaceType enum.
|
|
658
|
+
*
|
|
659
|
+
* These values classify the type/role of a network interface.
|
|
660
|
+
*/
|
|
661
|
+
declare enum InterfaceType {
|
|
662
|
+
/**
|
|
663
|
+
* Bridge interface - software bridge connecting multiple network segments
|
|
664
|
+
*/
|
|
665
|
+
Bridge = "BRIDGE",
|
|
666
|
+
/**
|
|
667
|
+
* Link aggregation (bonding) interface - combines multiple physical interfaces
|
|
668
|
+
*/
|
|
669
|
+
LinkAggregation = "LINK_AGGREGATION",
|
|
670
|
+
/**
|
|
671
|
+
* Physical network interface - actual hardware NIC
|
|
672
|
+
*/
|
|
673
|
+
Physical = "PHYSICAL",
|
|
674
|
+
/**
|
|
675
|
+
* Unknown interface type
|
|
676
|
+
*/
|
|
677
|
+
Unknown = "UNKNOWN",
|
|
678
|
+
/**
|
|
679
|
+
* VLAN (Virtual LAN) interface - 802.1Q tagged virtual interface
|
|
680
|
+
*/
|
|
681
|
+
Vlan = "VLAN"
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Transmit hash policy for link aggregation load balancing.
|
|
686
|
+
* Corresponds to middleware's xmit_hash_policy field values.
|
|
687
|
+
*
|
|
688
|
+
* Determines which packet header fields are used to calculate the hash
|
|
689
|
+
* for distributing traffic across bonded interfaces.
|
|
690
|
+
*/
|
|
691
|
+
declare enum InterfaceXmitHashPolicy {
|
|
692
|
+
/**
|
|
693
|
+
* Layer 2 hashing - uses source and destination MAC addresses
|
|
694
|
+
* Best for simple scenarios where traffic patterns are consistent
|
|
695
|
+
*/
|
|
696
|
+
Layer2 = "LAYER2",
|
|
697
|
+
/**
|
|
698
|
+
* Layer 2+3 hashing - uses MAC addresses and IP addresses
|
|
699
|
+
* Better distribution for multi-subnet environments
|
|
700
|
+
*/
|
|
701
|
+
Layer2Plus3 = "LAYER2+3",
|
|
702
|
+
/**
|
|
703
|
+
* Layer 3+4 hashing - uses MAC, IP, and TCP/UDP port information
|
|
704
|
+
* Optimal distribution for diverse traffic patterns and multiple connections
|
|
705
|
+
*/
|
|
706
|
+
Layer3Plus4 = "LAYER3+4"
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* VRRP (Virtual Router Redundancy Protocol) state values.
|
|
711
|
+
* Used in High Availability configurations to indicate controller state.
|
|
712
|
+
*/
|
|
713
|
+
declare enum VrrpState {
|
|
714
|
+
Master = "MASTER",
|
|
715
|
+
Backup = "BACKUP",
|
|
716
|
+
Fault = "FAULT"
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
interface InterfaceEntryAlias {
|
|
720
|
+
type: InterfaceAddressFamily;
|
|
721
|
+
/** The type of IP address (INET for IPv4, INET6 for IPv6). */
|
|
722
|
+
address: string;
|
|
723
|
+
/** The IP address value. */
|
|
724
|
+
netmask: string | number;
|
|
725
|
+
}
|
|
726
|
+
interface InterfaceEntryStateAlias extends Omit<InterfaceEntryAlias, 'netmask'> {
|
|
727
|
+
netmask?: string | number;
|
|
728
|
+
broadcast?: string;
|
|
729
|
+
}
|
|
730
|
+
interface InterfaceVrrpConfig {
|
|
731
|
+
address: string;
|
|
732
|
+
/** Virtual IP address managed by VRRP. */
|
|
733
|
+
state: VrrpState;
|
|
734
|
+
}
|
|
735
|
+
interface InterfaceEntryStatePort {
|
|
736
|
+
name: string;
|
|
737
|
+
/** The name of the port interface. */
|
|
738
|
+
flags: string[];
|
|
739
|
+
}
|
|
740
|
+
interface InterfaceEntryState {
|
|
741
|
+
name: string;
|
|
742
|
+
/** Current name of the network interface. */
|
|
743
|
+
orig_name: string;
|
|
744
|
+
/** Original name of the network interface before any renaming. */
|
|
745
|
+
description: string;
|
|
746
|
+
/** Human-readable description of the network interface. */
|
|
747
|
+
mtu: number;
|
|
748
|
+
/** Maximum transmission unit size for the interface. */
|
|
749
|
+
cloned: boolean;
|
|
750
|
+
/** Whether the interface is a cloned/virtual interface. */
|
|
751
|
+
flags: string[];
|
|
752
|
+
/** List of interface flags indicating various states and capabilities. */
|
|
753
|
+
nd6_flags: unknown[];
|
|
754
|
+
/** IPv6 neighbor discovery flags. */
|
|
755
|
+
capabilities: string[];
|
|
756
|
+
/** List of hardware capabilities supported by the interface. */
|
|
757
|
+
link_state: InterfaceLinkState;
|
|
758
|
+
/** Current link state of the interface (up, down, etc.). */
|
|
759
|
+
media_type: string;
|
|
760
|
+
/** Type of media/connection for the interface. */
|
|
761
|
+
media_subtype: string;
|
|
762
|
+
/** Subtype of media/connection for the interface. */
|
|
763
|
+
active_media_type: string;
|
|
764
|
+
/** Currently active media type. */
|
|
765
|
+
active_media_subtype: string;
|
|
766
|
+
/** Currently active media subtype. */
|
|
767
|
+
supported_media: string[];
|
|
768
|
+
/** List of supported media types for the interface. */
|
|
769
|
+
media_options?: string[] | null;
|
|
770
|
+
/** Available media options for the interface. */
|
|
771
|
+
link_address: string;
|
|
772
|
+
/** MAC address of the interface. */
|
|
773
|
+
permanent_link_address?: string | null;
|
|
774
|
+
/** Permanent MAC address of the interface if different from current. */
|
|
775
|
+
hardware_link_address: string;
|
|
776
|
+
/** Hardware MAC address of the interface. */
|
|
777
|
+
rx_queues?: number;
|
|
778
|
+
/** Number of receive queues configured for the interface. */
|
|
779
|
+
tx_queues?: number;
|
|
780
|
+
/** Number of transmit queues configured for the interface. */
|
|
781
|
+
aliases: InterfaceEntryStateAlias[];
|
|
782
|
+
/** List of IP address aliases configured on the interface. */
|
|
783
|
+
vrrp_config?: InterfaceVrrpConfig[] | null;
|
|
784
|
+
/** VRRP (Virtual Router Redundancy Protocol) configuration for the interface. */
|
|
785
|
+
protocol?: InterfaceLagProtocol | null;
|
|
786
|
+
/** Link aggregation protocol used (LACP, FAILOVER, etc.). */
|
|
787
|
+
ports?: InterfaceEntryStatePort[];
|
|
788
|
+
/** List of ports that are members of this link aggregation group. */
|
|
789
|
+
xmit_hash_policy?: InterfaceXmitHashPolicy | null;
|
|
790
|
+
/** Transmit hash policy for load balancing in link aggregation. */
|
|
791
|
+
lacpdu_rate?: InterfaceLacpRate | null;
|
|
792
|
+
/** LACP data unit transmission rate. */
|
|
793
|
+
parent?: string | null;
|
|
794
|
+
/** Parent interface for VLAN configuration. */
|
|
795
|
+
tag?: number | null;
|
|
796
|
+
/** VLAN tag number. */
|
|
797
|
+
pcp?: number | null;
|
|
798
|
+
}
|
|
799
|
+
interface InterfaceEntry {
|
|
800
|
+
id: string;
|
|
801
|
+
/** Unique identifier for the network interface. */
|
|
802
|
+
name: string;
|
|
803
|
+
/** Name of the network interface. */
|
|
804
|
+
fake: boolean;
|
|
805
|
+
/** Whether this is a fake/simulated interface for testing purposes. */
|
|
806
|
+
type: InterfaceType;
|
|
807
|
+
/** Type of interface (PHYSICAL, BRIDGE, LINK_AGGREGATION, VLAN, etc.). */
|
|
808
|
+
state: InterfaceEntryState;
|
|
809
|
+
/** Current runtime state information for the interface. */
|
|
810
|
+
aliases: InterfaceEntryAlias[];
|
|
811
|
+
/** List of IP address aliases configured on the interface. */
|
|
812
|
+
ipv4_dhcp: boolean;
|
|
813
|
+
/** Whether IPv4 DHCP is enabled for automatic IP address assignment. */
|
|
814
|
+
ipv6_auto: boolean;
|
|
815
|
+
/** Whether IPv6 autoconfiguration is enabled. */
|
|
816
|
+
description: string;
|
|
817
|
+
/** Human-readable description of the interface. */
|
|
818
|
+
mtu?: number | null;
|
|
819
|
+
/** Maximum transmission unit size for the interface. */
|
|
820
|
+
vlan_parent_interface?: string | null;
|
|
821
|
+
/** Parent interface for VLAN configuration. */
|
|
822
|
+
vlan_tag?: number | null;
|
|
823
|
+
/** VLAN tag number for VLAN interfaces. */
|
|
824
|
+
vlan_pcp?: number | null;
|
|
825
|
+
/** Priority Code Point for VLAN traffic prioritization. */
|
|
826
|
+
lag_protocol?: InterfaceLagProtocol;
|
|
827
|
+
/** Link aggregation protocol. */
|
|
828
|
+
lag_ports?: string[];
|
|
829
|
+
/** List of ports in the link aggregation group. */
|
|
830
|
+
xmit_hash_policy?: InterfaceXmitHashPolicy | null;
|
|
831
|
+
/** Transmit hash policy for link aggregation. */
|
|
832
|
+
lacpdu_rate?: InterfaceLacpRate | null;
|
|
833
|
+
/** LACP data unit transmission rate. */
|
|
834
|
+
disable_offload_capabilities?: boolean;
|
|
835
|
+
/** Whether to disable hardware offload capabilities. */
|
|
836
|
+
mtu_configured?: number | null;
|
|
837
|
+
/** Configured MTU size (may differ from actual). */
|
|
838
|
+
enabled: boolean;
|
|
839
|
+
/** Whether the interface is enabled. */
|
|
840
|
+
failover_critical?: boolean;
|
|
841
|
+
/** Whether this interface is critical for High Availability failover. */
|
|
842
|
+
failover_vhid?: number | null;
|
|
843
|
+
/** Virtual Host ID for CARP-based failover (FreeBSD). */
|
|
844
|
+
failover_group?: number;
|
|
845
|
+
/** Failover group number for organizing interfaces in HA configurations. */
|
|
846
|
+
failover_aliases?: InterfaceEntryAlias[];
|
|
847
|
+
/** List of IP aliases for the standby/backup controller in HA configurations. */
|
|
848
|
+
failover_virtual_aliases?: InterfaceEntryAlias[];
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
interface SSHKeyPair {
|
|
852
|
+
/** SSH private key in OpenSSH format. `null` if only public key is provided. */
|
|
853
|
+
private_key: string | null;
|
|
854
|
+
/** Can be omitted and automatically derived from the private key. */
|
|
855
|
+
public_key: string | null;
|
|
856
|
+
}
|
|
857
|
+
interface SSHCredentials {
|
|
858
|
+
/** SSH server hostname or IP address. */
|
|
859
|
+
host: string;
|
|
860
|
+
/** SSH server port number. */
|
|
861
|
+
port: number;
|
|
862
|
+
/** SSH username for authentication. */
|
|
863
|
+
username: string;
|
|
864
|
+
/** Keychain Credential ID. */
|
|
865
|
+
private_key: number;
|
|
866
|
+
/** Can be discovered with keychaincredential.remote_ssh_host_key_scan. */
|
|
867
|
+
remote_host_key: string;
|
|
868
|
+
/** Connection timeout in seconds for SSH connections. */
|
|
869
|
+
connect_timeout: number;
|
|
870
|
+
}
|
|
871
|
+
/** Minimal SSH credentials containing only the host information needed for target system identification */
|
|
872
|
+
interface MinimalSshCredentials {
|
|
873
|
+
/** SSH server hostname or IP address. */
|
|
874
|
+
host: string;
|
|
875
|
+
}
|
|
876
|
+
interface KeychainCredentialEntry {
|
|
877
|
+
/** Unique identifier for this keychain credential. */
|
|
878
|
+
id: number;
|
|
879
|
+
/** Distinguishes this Keychain Credential from others. */
|
|
880
|
+
name: string;
|
|
881
|
+
/** Type of credential stored in the keychain. */
|
|
882
|
+
type: 'SSH_KEY_PAIR' | 'SSH_CREDENTIALS';
|
|
883
|
+
/** Credential-specific configuration and authentication data. */
|
|
884
|
+
attributes: SSHKeyPair | SSHCredentials;
|
|
885
|
+
}
|
|
886
|
+
interface SSHKeyPairEntry extends KeychainCredentialEntry {
|
|
887
|
+
/** Keychain credential type identifier for SSH key pairs. */
|
|
888
|
+
type: 'SSH_KEY_PAIR';
|
|
889
|
+
/** SSH key pair attributes including public and private keys. */
|
|
890
|
+
attributes: SSHKeyPair;
|
|
891
|
+
}
|
|
892
|
+
interface SSHCredentialsEntry extends KeychainCredentialEntry {
|
|
893
|
+
/** Keychain credential type identifier for SSH connection credentials. */
|
|
894
|
+
type: 'SSH_CREDENTIALS';
|
|
895
|
+
/** SSH connection attributes including host, authentication, and connection settings. */
|
|
896
|
+
attributes: SSHCredentials;
|
|
897
|
+
}
|
|
898
|
+
/** Minimal keychain credential entry containing only host information for target system identification */
|
|
899
|
+
interface MinimalKeychainCredentialEntry {
|
|
900
|
+
/** Unique identifier for this keychain credential. */
|
|
901
|
+
id: number;
|
|
902
|
+
/** Type of credential stored in the keychain. */
|
|
903
|
+
type: 'SSH_KEY_PAIR' | 'SSH_CREDENTIALS';
|
|
904
|
+
/** Minimal credential attributes containing only the host information. */
|
|
905
|
+
attributes: MinimalSshCredentials;
|
|
906
|
+
}
|
|
907
|
+
/** Parameters for scanning remote SSH host key */
|
|
908
|
+
interface RemoteSshHostKeyScanParams {
|
|
909
|
+
/** SSH server hostname or IP address */
|
|
910
|
+
host: string;
|
|
911
|
+
/** SSH server port number (default: 22) */
|
|
912
|
+
port?: number;
|
|
913
|
+
/** Connection timeout in seconds (default: 10) */
|
|
914
|
+
connect_timeout?: number;
|
|
915
|
+
}
|
|
916
|
+
/** Parameters for creating a keychain credential */
|
|
917
|
+
interface KeychainCredentialCreate {
|
|
918
|
+
/** Credential name */
|
|
919
|
+
name: string;
|
|
920
|
+
/** Credential type */
|
|
921
|
+
type: 'SSH_KEY_PAIR' | 'SSH_CREDENTIALS';
|
|
922
|
+
/** Credential attributes (varies by type) */
|
|
923
|
+
attributes: SSHKeyPair | SSHCredentials;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* TrueNAS Network Configuration
|
|
928
|
+
* Response from network.configuration.config middleware endpoint
|
|
929
|
+
*/
|
|
930
|
+
interface NetworkConfiguration {
|
|
931
|
+
/** Unique identifier for the network configuration */
|
|
932
|
+
id: number;
|
|
933
|
+
/** System hostname (short name without domain) */
|
|
934
|
+
hostname: string;
|
|
935
|
+
/** DNS domain name */
|
|
936
|
+
domain: string;
|
|
937
|
+
/** IPv4 default gateway address */
|
|
938
|
+
ipv4gateway: string;
|
|
939
|
+
/** IPv6 default gateway address */
|
|
940
|
+
ipv6gateway: string;
|
|
941
|
+
/** Primary DNS nameserver */
|
|
942
|
+
nameserver1: string;
|
|
943
|
+
/** Secondary DNS nameserver */
|
|
944
|
+
nameserver2: string;
|
|
945
|
+
/** Tertiary DNS nameserver */
|
|
946
|
+
nameserver3: string;
|
|
947
|
+
/** HTTP proxy server URL */
|
|
948
|
+
httpproxy: string;
|
|
949
|
+
/** Custom hostname to IP mappings (hosts file entries) */
|
|
950
|
+
hosts: string;
|
|
951
|
+
/** Additional domain search paths */
|
|
952
|
+
domains: string[];
|
|
953
|
+
/** Service announcement configuration */
|
|
954
|
+
service_announcement: {
|
|
955
|
+
/** Enable NetBIOS name service */
|
|
956
|
+
netbios: boolean;
|
|
957
|
+
/** Enable multicast DNS (Bonjour) */
|
|
958
|
+
mdns: boolean;
|
|
959
|
+
/** Enable Web Services Discovery */
|
|
960
|
+
wsd: boolean;
|
|
961
|
+
};
|
|
962
|
+
/** Network activity restrictions */
|
|
963
|
+
activity: {
|
|
964
|
+
/** Activity restriction type (ALLOW or DENY) */
|
|
965
|
+
type: string;
|
|
966
|
+
/** List of restricted network activities */
|
|
967
|
+
activities: string[];
|
|
968
|
+
};
|
|
969
|
+
/** Hostname with .local suffix for mDNS */
|
|
970
|
+
hostname_local: string;
|
|
971
|
+
/** Runtime network state (may differ from configured values) */
|
|
972
|
+
state: {
|
|
973
|
+
/** Active IPv4 gateway */
|
|
974
|
+
ipv4gateway: string;
|
|
975
|
+
/** Active IPv6 gateway */
|
|
976
|
+
ipv6gateway: string;
|
|
977
|
+
/** Active primary nameserver */
|
|
978
|
+
nameserver1: string;
|
|
979
|
+
/** Active secondary nameserver */
|
|
980
|
+
nameserver2: string;
|
|
981
|
+
/** Active tertiary nameserver */
|
|
982
|
+
nameserver3: string;
|
|
983
|
+
/** Active custom host mappings */
|
|
984
|
+
hosts: string;
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
interface PeriodicSnapshotTask {
|
|
989
|
+
id: number;
|
|
990
|
+
dataset: string;
|
|
991
|
+
recursive: boolean;
|
|
992
|
+
lifetime_value: number;
|
|
993
|
+
lifetime_unit: string;
|
|
994
|
+
enabled: boolean;
|
|
995
|
+
exclude: string[];
|
|
996
|
+
naming_schema: string;
|
|
997
|
+
allow_empty: boolean;
|
|
998
|
+
schedule: {
|
|
999
|
+
minute: string;
|
|
1000
|
+
hour: string;
|
|
1001
|
+
dom: string;
|
|
1002
|
+
month: string;
|
|
1003
|
+
dow: string;
|
|
1004
|
+
begin: string;
|
|
1005
|
+
end: string;
|
|
1006
|
+
};
|
|
1007
|
+
state: string;
|
|
1008
|
+
}
|
|
1009
|
+
interface PeriodicSnapshotTaskCreate {
|
|
1010
|
+
dataset: string;
|
|
1011
|
+
recursive: boolean;
|
|
1012
|
+
lifetime_value: number;
|
|
1013
|
+
lifetime_unit: string;
|
|
1014
|
+
naming_schema: string;
|
|
1015
|
+
schedule: {
|
|
1016
|
+
minute: string;
|
|
1017
|
+
hour: string;
|
|
1018
|
+
dom: string;
|
|
1019
|
+
month: string;
|
|
1020
|
+
dow: string;
|
|
1021
|
+
};
|
|
1022
|
+
enabled: boolean;
|
|
1023
|
+
exclude?: string[];
|
|
1024
|
+
allow_empty?: boolean;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
interface PoolQuery {
|
|
1028
|
+
id: number;
|
|
1029
|
+
guid: string;
|
|
1030
|
+
name: string;
|
|
1031
|
+
healthy: boolean;
|
|
1032
|
+
path: string;
|
|
1033
|
+
status: PoolStatus;
|
|
1034
|
+
size: number;
|
|
1035
|
+
allocated: number;
|
|
1036
|
+
free: number;
|
|
1037
|
+
used: PoolProperty;
|
|
1038
|
+
encryption_algorithm: PoolProperty;
|
|
1039
|
+
compression: PoolProperty;
|
|
1040
|
+
compressratio: PoolProperty;
|
|
1041
|
+
recordsize: PoolProperty;
|
|
1042
|
+
topology: {
|
|
1043
|
+
[T in PoolVdevCategory]: PoolVdev[];
|
|
1044
|
+
} | null;
|
|
1045
|
+
}
|
|
1046
|
+
declare enum PoolVdevCategory {
|
|
1047
|
+
Data = "data",
|
|
1048
|
+
Log = "log",
|
|
1049
|
+
Cache = "cache",
|
|
1050
|
+
Spare = "spare",
|
|
1051
|
+
Special = "special",
|
|
1052
|
+
Dedup = "dedup"
|
|
1053
|
+
}
|
|
1054
|
+
interface PoolProperty {
|
|
1055
|
+
value: string;
|
|
1056
|
+
}
|
|
1057
|
+
declare enum PoolStatus {
|
|
1058
|
+
Offline = "OFFLINE",
|
|
1059
|
+
Online = "ONLINE",
|
|
1060
|
+
Degraded = "DEGRADED",
|
|
1061
|
+
Unknown = "UNKNOWN",
|
|
1062
|
+
Faulted = "FAULTED",
|
|
1063
|
+
Unavailable = "UNAVAILABLE",
|
|
1064
|
+
Removed = "REMOVED",
|
|
1065
|
+
Split = "SPLIT"
|
|
1066
|
+
}
|
|
1067
|
+
declare enum PoolVdevType {
|
|
1068
|
+
Stripe = "STRIPE",
|
|
1069
|
+
Mirror = "MIRROR",
|
|
1070
|
+
RaidZ1 = "RAIDZ1",
|
|
1071
|
+
RaidZ2 = "RAIDZ2",
|
|
1072
|
+
RaidZ3 = "RAIDZ3",
|
|
1073
|
+
Disk = "DISK"
|
|
1074
|
+
}
|
|
1075
|
+
interface PoolVdev {
|
|
1076
|
+
name: string;
|
|
1077
|
+
type: PoolVdevType;
|
|
1078
|
+
path: string | null;
|
|
1079
|
+
guid: string;
|
|
1080
|
+
status: PoolStatus;
|
|
1081
|
+
stats: {
|
|
1082
|
+
size: number;
|
|
1083
|
+
allocated: number;
|
|
1084
|
+
checksum_errors: number;
|
|
1085
|
+
read_errors: number;
|
|
1086
|
+
write_errors: number;
|
|
1087
|
+
};
|
|
1088
|
+
unavail_disk: DiskQuery | null;
|
|
1089
|
+
children: PoolVdev[];
|
|
1090
|
+
disk?: string;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
declare enum ReplicationDirection {
|
|
1094
|
+
Push = "PUSH",
|
|
1095
|
+
Pull = "PULL"
|
|
1096
|
+
}
|
|
1097
|
+
declare enum ReplicationTransport$1 {
|
|
1098
|
+
Ssh = "SSH",
|
|
1099
|
+
SshNetcat = "SSH+NETCAT",
|
|
1100
|
+
Local = "LOCAL"
|
|
1101
|
+
}
|
|
1102
|
+
type ReplicationReadonly = 'SET' | 'REQUIRE' | 'IGNORE';
|
|
1103
|
+
type ReplicationRetentionPolicy$1 = 'SOURCE' | 'CUSTOM' | 'NONE';
|
|
1104
|
+
type ReplicationCompression = 'LZ4' | 'PIGZ' | 'PLZIP';
|
|
1105
|
+
type ReplicationEncryptionKeyFormat = 'HEX' | 'PASSPHRASE';
|
|
1106
|
+
type ReplicationLifetimeUnit$1 = 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
|
|
1107
|
+
type ReplicationLogLevel = 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR';
|
|
1108
|
+
type ReplicationNetcatActiveSide = 'LOCAL' | 'REMOTE';
|
|
1109
|
+
interface ReplicationSchedule {
|
|
1110
|
+
minute: string;
|
|
1111
|
+
hour: string;
|
|
1112
|
+
dom: string;
|
|
1113
|
+
month: string;
|
|
1114
|
+
dow: string;
|
|
1115
|
+
}
|
|
1116
|
+
interface ReplicationLifetime {
|
|
1117
|
+
schedule: {
|
|
1118
|
+
minute: string;
|
|
1119
|
+
hour: string;
|
|
1120
|
+
dom: string;
|
|
1121
|
+
month: string;
|
|
1122
|
+
dow: string;
|
|
1123
|
+
};
|
|
1124
|
+
lifetime_value: number;
|
|
1125
|
+
lifetime_unit: ReplicationLifetimeUnit$1;
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Complete ReplicationQuery interface matching backend API response.
|
|
1129
|
+
* Represents all fields that the backend CAN return from replication.query endpoint.
|
|
1130
|
+
*
|
|
1131
|
+
* Note: Frontend typically uses a subset via `select` parameter - see SystemReplicationQuery.
|
|
1132
|
+
*/
|
|
1133
|
+
interface ReplicationQuery {
|
|
1134
|
+
id: number;
|
|
1135
|
+
name: string;
|
|
1136
|
+
direction: ReplicationDirection;
|
|
1137
|
+
transport: ReplicationTransport$1;
|
|
1138
|
+
enabled: boolean;
|
|
1139
|
+
ssh_credentials: MinimalKeychainCredentialEntry | null;
|
|
1140
|
+
netcat_active_side: ReplicationNetcatActiveSide | null;
|
|
1141
|
+
netcat_active_side_listen_address: string | null;
|
|
1142
|
+
netcat_active_side_port_min: number | null;
|
|
1143
|
+
netcat_active_side_port_max: number | null;
|
|
1144
|
+
netcat_passive_side_connect_address: string | null;
|
|
1145
|
+
sudo: boolean;
|
|
1146
|
+
source_datasets: string[];
|
|
1147
|
+
target_dataset: string;
|
|
1148
|
+
recursive: boolean;
|
|
1149
|
+
exclude: string[];
|
|
1150
|
+
properties: boolean;
|
|
1151
|
+
properties_exclude: string[];
|
|
1152
|
+
properties_override: Record<string, string>;
|
|
1153
|
+
replicate: boolean;
|
|
1154
|
+
encryption: boolean;
|
|
1155
|
+
encryption_inherit: boolean | null;
|
|
1156
|
+
encryption_key: string | null;
|
|
1157
|
+
encryption_key_format: ReplicationEncryptionKeyFormat | null;
|
|
1158
|
+
encryption_key_location: string | null;
|
|
1159
|
+
has_encrypted_dataset_keys: boolean;
|
|
1160
|
+
periodic_snapshot_tasks: PeriodicSnapshotTask[];
|
|
1161
|
+
naming_schema: string[];
|
|
1162
|
+
also_include_naming_schema: string[];
|
|
1163
|
+
name_regex: string | null;
|
|
1164
|
+
auto: boolean;
|
|
1165
|
+
schedule: ReplicationSchedule | null;
|
|
1166
|
+
restrict_schedule: ReplicationSchedule | null;
|
|
1167
|
+
only_matching_schedule: boolean;
|
|
1168
|
+
allow_from_scratch: boolean;
|
|
1169
|
+
readonly: ReplicationReadonly;
|
|
1170
|
+
hold_pending_snapshots: boolean;
|
|
1171
|
+
retention_policy: ReplicationRetentionPolicy$1;
|
|
1172
|
+
lifetime_value: number | null;
|
|
1173
|
+
lifetime_unit: ReplicationLifetimeUnit$1 | null;
|
|
1174
|
+
lifetimes: ReplicationLifetime[];
|
|
1175
|
+
compression: ReplicationCompression | null;
|
|
1176
|
+
speed_limit: number | null;
|
|
1177
|
+
large_block: boolean;
|
|
1178
|
+
embed: boolean;
|
|
1179
|
+
compressed: boolean;
|
|
1180
|
+
retries: number;
|
|
1181
|
+
logging_level: ReplicationLogLevel | null;
|
|
1182
|
+
state: {
|
|
1183
|
+
state: string;
|
|
1184
|
+
datetime: TrueNasDate;
|
|
1185
|
+
};
|
|
1186
|
+
job: Job | null;
|
|
1187
|
+
description?: string;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/** Replication transport type */
|
|
1191
|
+
declare enum ReplicationTransport {
|
|
1192
|
+
Ssh = "SSH",
|
|
1193
|
+
Local = "LOCAL",
|
|
1194
|
+
Legacy = "LEGACY"
|
|
1195
|
+
}
|
|
1196
|
+
/** Replication retention policy */
|
|
1197
|
+
declare enum ReplicationRetentionPolicy {
|
|
1198
|
+
Source = "SOURCE",
|
|
1199
|
+
Custom = "CUSTOM",
|
|
1200
|
+
None = "NONE"
|
|
1201
|
+
}
|
|
1202
|
+
/** Replication lifetime unit */
|
|
1203
|
+
declare enum ReplicationLifetimeUnit {
|
|
1204
|
+
Hour = "HOUR",
|
|
1205
|
+
Day = "DAY",
|
|
1206
|
+
Week = "WEEK",
|
|
1207
|
+
Month = "MONTH",
|
|
1208
|
+
Year = "YEAR"
|
|
1209
|
+
}
|
|
1210
|
+
/** Configuration for creating a replication task */
|
|
1211
|
+
interface ReplicationCreateConfig {
|
|
1212
|
+
/** Name of the replication task */
|
|
1213
|
+
name: string;
|
|
1214
|
+
/** Direction of replication (PUSH or PULL) */
|
|
1215
|
+
direction: string;
|
|
1216
|
+
/** Transport method */
|
|
1217
|
+
transport: ReplicationTransport;
|
|
1218
|
+
/** SSH credentials ID for SSH transport */
|
|
1219
|
+
ssh_credentials: number;
|
|
1220
|
+
/** IDs of periodic snapshot tasks to bind (PUSH direction only) */
|
|
1221
|
+
periodic_snapshot_tasks?: number[];
|
|
1222
|
+
/** Source datasets to replicate */
|
|
1223
|
+
source_datasets: string[];
|
|
1224
|
+
/** Target dataset path */
|
|
1225
|
+
target_dataset: string;
|
|
1226
|
+
/** Whether to replicate child datasets recursively */
|
|
1227
|
+
recursive: boolean;
|
|
1228
|
+
/** Whether to automatically create snapshots */
|
|
1229
|
+
auto: boolean;
|
|
1230
|
+
/** Snapshot retention policy */
|
|
1231
|
+
retention_policy: ReplicationRetentionPolicy;
|
|
1232
|
+
/** Retention lifetime value */
|
|
1233
|
+
lifetime_value: number;
|
|
1234
|
+
/** Retention lifetime unit */
|
|
1235
|
+
lifetime_unit: ReplicationLifetimeUnit;
|
|
1236
|
+
/** Cron schedule for the replication task */
|
|
1237
|
+
schedule: {
|
|
1238
|
+
/** Minute (0-59 or *) */
|
|
1239
|
+
minute: string;
|
|
1240
|
+
/** Hour (0-23 or *) */
|
|
1241
|
+
hour: string;
|
|
1242
|
+
/** Day of month (1-31 or *) */
|
|
1243
|
+
dom: string;
|
|
1244
|
+
/** Month (1-12 or *) */
|
|
1245
|
+
month: string;
|
|
1246
|
+
/** Day of week (0-6 or *) */
|
|
1247
|
+
dow: string;
|
|
1248
|
+
};
|
|
1249
|
+
/** Whether to allow replication from scratch */
|
|
1250
|
+
allow_from_scratch: boolean;
|
|
1251
|
+
/** Naming schema for snapshots */
|
|
1252
|
+
naming_schema: string[];
|
|
1253
|
+
/** Additional naming schemas to include */
|
|
1254
|
+
also_include_naming_schema: string[];
|
|
1255
|
+
/** Whether the task is enabled */
|
|
1256
|
+
enabled: boolean;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* Service management types for TrueNAS service control API
|
|
1261
|
+
*/
|
|
1262
|
+
/**
|
|
1263
|
+
* Service state enumeration
|
|
1264
|
+
*/
|
|
1265
|
+
declare enum ServiceState {
|
|
1266
|
+
Running = "RUNNING",
|
|
1267
|
+
Stopped = "STOPPED",
|
|
1268
|
+
Unknown = "UNKNOWN"
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Service control action enumeration
|
|
1272
|
+
*/
|
|
1273
|
+
declare enum ServiceControlAction {
|
|
1274
|
+
Start = "START",
|
|
1275
|
+
Stop = "STOP",
|
|
1276
|
+
Restart = "RESTART",
|
|
1277
|
+
Reload = "RELOAD"
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Service entry returned by service.query
|
|
1281
|
+
*/
|
|
1282
|
+
interface ServiceEntry {
|
|
1283
|
+
/** Unique identifier for the service */
|
|
1284
|
+
id: number;
|
|
1285
|
+
/** Name of the system service */
|
|
1286
|
+
service: string;
|
|
1287
|
+
/** Whether the service is enabled to start on boot */
|
|
1288
|
+
enable: boolean;
|
|
1289
|
+
/** Current state of the service */
|
|
1290
|
+
state: ServiceState;
|
|
1291
|
+
/** Array of process IDs associated with this service */
|
|
1292
|
+
pids: number[];
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Options for service control operations
|
|
1296
|
+
*/
|
|
1297
|
+
interface ServiceOptions {
|
|
1298
|
+
/** Whether to propagate the service operation to the HA peer in a high-availability setup */
|
|
1299
|
+
ha_propagate?: boolean;
|
|
1300
|
+
/** Return false instead of an error if the operation fails */
|
|
1301
|
+
silent?: boolean;
|
|
1302
|
+
/** Maximum time in seconds to wait for the service operation to complete. null for no timeout */
|
|
1303
|
+
timeout?: number | null;
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* Service update configuration
|
|
1307
|
+
*/
|
|
1308
|
+
interface ServiceUpdate {
|
|
1309
|
+
/** Whether the service should start on boot */
|
|
1310
|
+
enable: boolean;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
interface SystemInfo {
|
|
1314
|
+
version: string;
|
|
1315
|
+
buildtime: TrueNasDate;
|
|
1316
|
+
hostname: string;
|
|
1317
|
+
physmem: number;
|
|
1318
|
+
model: string;
|
|
1319
|
+
cores: number;
|
|
1320
|
+
physical_cores: number;
|
|
1321
|
+
loadavg: number[];
|
|
1322
|
+
uptime: string;
|
|
1323
|
+
uptime_seconds: number;
|
|
1324
|
+
system_serial: string;
|
|
1325
|
+
system_product: string;
|
|
1326
|
+
system_product_version: string;
|
|
1327
|
+
license: string;
|
|
1328
|
+
boottime: TrueNasDate;
|
|
1329
|
+
datetime: TrueNasDate;
|
|
1330
|
+
birthday: TrueNasDate;
|
|
1331
|
+
timezone: string;
|
|
1332
|
+
system_manufacturer: string;
|
|
1333
|
+
ecc_memory: boolean;
|
|
1334
|
+
remote_info?: SystemInfo;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
declare enum UpdateStatusCode {
|
|
1338
|
+
Normal = "NORMAL",
|
|
1339
|
+
Error = "ERROR"
|
|
1340
|
+
}
|
|
1341
|
+
interface UpdateManifest {
|
|
1342
|
+
filename: string;
|
|
1343
|
+
version: string;
|
|
1344
|
+
date: string;
|
|
1345
|
+
changelog: string;
|
|
1346
|
+
checksum: string;
|
|
1347
|
+
filesize: number;
|
|
1348
|
+
profile: string;
|
|
1349
|
+
train: string;
|
|
1350
|
+
}
|
|
1351
|
+
interface CurrentVersion {
|
|
1352
|
+
train: string;
|
|
1353
|
+
profile: string;
|
|
1354
|
+
matches_profile: boolean;
|
|
1355
|
+
}
|
|
1356
|
+
interface NewVersion {
|
|
1357
|
+
version: string;
|
|
1358
|
+
manifest: UpdateManifest;
|
|
1359
|
+
release_notes: string | null;
|
|
1360
|
+
release_notes_url: string;
|
|
1361
|
+
}
|
|
1362
|
+
interface UpdateStatusResult {
|
|
1363
|
+
current_version?: CurrentVersion;
|
|
1364
|
+
new_version?: NewVersion;
|
|
1365
|
+
}
|
|
1366
|
+
interface UpdateStatusResponse {
|
|
1367
|
+
code: UpdateStatusCode;
|
|
1368
|
+
status: UpdateStatusResult | null;
|
|
1369
|
+
error: string | null;
|
|
1370
|
+
update_download_progress: unknown;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
/**
|
|
1374
|
+
* TrueNAS System User Account (from TrueNAS middleware)
|
|
1375
|
+
*/
|
|
1376
|
+
interface TrueNasUser {
|
|
1377
|
+
/** User ID */
|
|
1378
|
+
id: number;
|
|
1379
|
+
/** User ID number */
|
|
1380
|
+
uid: number;
|
|
1381
|
+
/** Username */
|
|
1382
|
+
username: string;
|
|
1383
|
+
/** User's full name */
|
|
1384
|
+
full_name: string;
|
|
1385
|
+
/** Home directory path */
|
|
1386
|
+
home: string;
|
|
1387
|
+
/** Login shell */
|
|
1388
|
+
shell: string;
|
|
1389
|
+
/** Primary group ID */
|
|
1390
|
+
group: {
|
|
1391
|
+
id: number;
|
|
1392
|
+
bsdgrp_gid: number;
|
|
1393
|
+
bsdgrp_group: string;
|
|
1394
|
+
};
|
|
1395
|
+
/** Additional group memberships */
|
|
1396
|
+
groups: number[];
|
|
1397
|
+
/** Email address */
|
|
1398
|
+
email: string | null;
|
|
1399
|
+
/** Password disabled flag */
|
|
1400
|
+
password_disabled: boolean;
|
|
1401
|
+
/** Locked account flag */
|
|
1402
|
+
locked: boolean;
|
|
1403
|
+
/** Microsoft account flag */
|
|
1404
|
+
microsoft_account: boolean;
|
|
1405
|
+
/** Sudo access without password */
|
|
1406
|
+
sudo_nopasswd: boolean;
|
|
1407
|
+
/** Sudo commands allowed */
|
|
1408
|
+
sudo_commands: string[];
|
|
1409
|
+
/** SSH public key for authorized_keys */
|
|
1410
|
+
sshpubkey: string | null;
|
|
1411
|
+
/** Account attributes */
|
|
1412
|
+
attributes: Record<string, unknown>;
|
|
1413
|
+
/** Immutable account (cannot be modified) */
|
|
1414
|
+
immutable: boolean;
|
|
1415
|
+
/** Built-in system user */
|
|
1416
|
+
builtin: boolean;
|
|
1417
|
+
/** SMB hash */
|
|
1418
|
+
smb: boolean;
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* TrueNAS System User update parameters
|
|
1422
|
+
*/
|
|
1423
|
+
interface TrueNasUserUpdate {
|
|
1424
|
+
/** User ID number (cannot be changed for existing users) */
|
|
1425
|
+
uid?: number;
|
|
1426
|
+
/** Username (cannot be changed for built-in users) */
|
|
1427
|
+
username?: string;
|
|
1428
|
+
/** User's full name */
|
|
1429
|
+
full_name?: string;
|
|
1430
|
+
/** Home directory path */
|
|
1431
|
+
home?: string;
|
|
1432
|
+
/** Login shell */
|
|
1433
|
+
shell?: string;
|
|
1434
|
+
/** Primary group ID */
|
|
1435
|
+
group?: number;
|
|
1436
|
+
/** Additional group memberships */
|
|
1437
|
+
groups?: number[];
|
|
1438
|
+
/** Email address */
|
|
1439
|
+
email?: string | null;
|
|
1440
|
+
/** Password (plain text, will be hashed) */
|
|
1441
|
+
password?: string;
|
|
1442
|
+
/** Password disabled flag */
|
|
1443
|
+
password_disabled?: boolean;
|
|
1444
|
+
/** Locked account flag */
|
|
1445
|
+
locked?: boolean;
|
|
1446
|
+
/** Microsoft account flag */
|
|
1447
|
+
microsoft_account?: boolean;
|
|
1448
|
+
/** Sudo access without password */
|
|
1449
|
+
sudo_nopasswd?: boolean;
|
|
1450
|
+
/** Sudo commands allowed */
|
|
1451
|
+
sudo_commands?: string[];
|
|
1452
|
+
/** SSH public key for authorized_keys */
|
|
1453
|
+
sshpubkey?: string | null;
|
|
1454
|
+
/** SMB hash */
|
|
1455
|
+
smb?: boolean;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
interface VirtualInstanceQuery {
|
|
1459
|
+
id: string;
|
|
1460
|
+
name: string;
|
|
1461
|
+
type: VirtualInstanceType;
|
|
1462
|
+
status: AppState;
|
|
1463
|
+
autostart: boolean;
|
|
1464
|
+
cpu: string;
|
|
1465
|
+
memory: number;
|
|
1466
|
+
image: {
|
|
1467
|
+
description: string;
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1470
|
+
declare enum VirtualInstanceType {
|
|
1471
|
+
Container = "CONTAINER",
|
|
1472
|
+
Vm = "VM"
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
declare enum VmState {
|
|
1476
|
+
Running = "RUNNING",
|
|
1477
|
+
Stopped = "STOPPED",
|
|
1478
|
+
Suspended = "SUSPENDED",
|
|
1479
|
+
Error = "ERROR"
|
|
1480
|
+
}
|
|
1481
|
+
declare enum VmDomainState {
|
|
1482
|
+
NoState = "NOSTATE",
|
|
1483
|
+
Running = "RUNNING",
|
|
1484
|
+
Blocked = "BLOCKED",
|
|
1485
|
+
Paused = "PAUSED",
|
|
1486
|
+
Shutdown = "SHUTDOWN",
|
|
1487
|
+
Shutoff = "SHUTOFF",
|
|
1488
|
+
Crashed = "CRASHED",
|
|
1489
|
+
PmSuspended = "PMSUSPENDED"
|
|
1490
|
+
}
|
|
1491
|
+
interface VMStatus {
|
|
1492
|
+
state: VmState;
|
|
1493
|
+
pid: number | null;
|
|
1494
|
+
domain_state: VmDomainState;
|
|
1495
|
+
}
|
|
1496
|
+
interface VMQuery {
|
|
1497
|
+
id: number;
|
|
1498
|
+
name: string;
|
|
1499
|
+
description: string;
|
|
1500
|
+
vcpus: number;
|
|
1501
|
+
cores: number;
|
|
1502
|
+
threads: number;
|
|
1503
|
+
/** memory usage in mebibytes (MiB) */
|
|
1504
|
+
memory: number;
|
|
1505
|
+
min_memory: number | null;
|
|
1506
|
+
autostart: boolean;
|
|
1507
|
+
cpu_mode: 'CUSTOM' | 'HOST-MODEL' | 'HOST-PASSTHROUGH';
|
|
1508
|
+
cpu_model: string | null;
|
|
1509
|
+
cpuset: string | null;
|
|
1510
|
+
nodeset: string | null;
|
|
1511
|
+
enable_cpu_topology_extension: boolean;
|
|
1512
|
+
pin_vcpus: boolean;
|
|
1513
|
+
suspend_on_snapshot: boolean;
|
|
1514
|
+
trusted_platform_module: boolean;
|
|
1515
|
+
hyperv_enlightenments: boolean;
|
|
1516
|
+
bootloader: 'UEFI_CSM' | 'UEFI';
|
|
1517
|
+
bootloader_ovmf: string;
|
|
1518
|
+
hide_from_msr: boolean;
|
|
1519
|
+
ensure_display_device: boolean;
|
|
1520
|
+
time: 'LOCAL' | 'UTC';
|
|
1521
|
+
shutdown_timeout: number;
|
|
1522
|
+
arch_type: string | null;
|
|
1523
|
+
machine_type: string | null;
|
|
1524
|
+
uuid: string | null;
|
|
1525
|
+
command_line_args: string;
|
|
1526
|
+
enable_secure_boot: boolean;
|
|
1527
|
+
devices: unknown[];
|
|
1528
|
+
display_available: boolean;
|
|
1529
|
+
status: VMStatus;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
interface ZfsSnapshot {
|
|
1533
|
+
/** Full snapshot name including dataset (e.g., pool/dataset@snapshot) */
|
|
1534
|
+
name: string;
|
|
1535
|
+
/** Dataset name */
|
|
1536
|
+
dataset: string;
|
|
1537
|
+
/** Snapshot name without dataset prefix */
|
|
1538
|
+
snapshot_name: string;
|
|
1539
|
+
}
|
|
1540
|
+
interface CreateZfsSnapshot {
|
|
1541
|
+
/** Dataset to snapshot */
|
|
1542
|
+
dataset: string;
|
|
1543
|
+
/** Optional: Pattern to generate snapshot name (e.g., auto-%Y%m%d.%H%M%S) */
|
|
1544
|
+
naming_schema?: string;
|
|
1545
|
+
/** Optional: Explicit snapshot name */
|
|
1546
|
+
name?: string;
|
|
1547
|
+
/** Optional: Snapshot children recursively */
|
|
1548
|
+
recursive?: boolean;
|
|
1549
|
+
/** Optional: Sync VMware VMs before snapshot */
|
|
1550
|
+
vmware_sync?: boolean;
|
|
1551
|
+
/** Optional: ZFS properties to set on snapshot */
|
|
1552
|
+
properties?: Record<string, unknown>;
|
|
1553
|
+
}
|
|
1554
|
+
interface EligibleSnapshotsCount {
|
|
1555
|
+
/** Total number of snapshots */
|
|
1556
|
+
total: number;
|
|
1557
|
+
/** Number of snapshots matching the naming schema/regex */
|
|
1558
|
+
eligible: number;
|
|
1559
|
+
}
|
|
1560
|
+
interface CountEligibleSnapshotsParams {
|
|
1561
|
+
/** Source datasets to check */
|
|
1562
|
+
datasets: string[];
|
|
1563
|
+
/** Transport method */
|
|
1564
|
+
transport: string;
|
|
1565
|
+
/** SSH credentials ID (for SSH transport) */
|
|
1566
|
+
ssh_credentials?: number;
|
|
1567
|
+
/** Naming schema pattern to match */
|
|
1568
|
+
naming_schema?: string[];
|
|
1569
|
+
/** Name regex pattern to match */
|
|
1570
|
+
name_regex?: string;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
interface ApiCallDirectory {
|
|
1574
|
+
[TrueNasEndpoint.CoreDownload]: {
|
|
1575
|
+
params: [
|
|
1576
|
+
method: 'config.save' | 'debug.save' | 'system.debug',
|
|
1577
|
+
params: {
|
|
1578
|
+
secretseed?: boolean;
|
|
1579
|
+
}[] | [],
|
|
1580
|
+
filename: string,
|
|
1581
|
+
buffered: boolean
|
|
1582
|
+
];
|
|
1583
|
+
response: CoreDownload;
|
|
1584
|
+
};
|
|
1585
|
+
[TrueNasEndpoint.CoreGetJobs]: {
|
|
1586
|
+
params: [[[string, string, number]]];
|
|
1587
|
+
response: Job[];
|
|
1588
|
+
};
|
|
1589
|
+
[TrueNasEndpoint.CorePing]: {
|
|
1590
|
+
params: undefined;
|
|
1591
|
+
response: undefined;
|
|
1592
|
+
};
|
|
1593
|
+
[TrueNasEndpoint.UpdateStatus]: {
|
|
1594
|
+
params: undefined;
|
|
1595
|
+
response: UpdateStatusResponse;
|
|
1596
|
+
};
|
|
1597
|
+
[TrueNasEndpoint.AppQuery]: {
|
|
1598
|
+
params: undefined;
|
|
1599
|
+
response: AppQuery[];
|
|
1600
|
+
};
|
|
1601
|
+
[TrueNasEndpoint.AppStart]: {
|
|
1602
|
+
params: string[];
|
|
1603
|
+
response: number;
|
|
1604
|
+
};
|
|
1605
|
+
[TrueNasEndpoint.AppStop]: {
|
|
1606
|
+
params: string[];
|
|
1607
|
+
response: number;
|
|
1608
|
+
};
|
|
1609
|
+
[TrueNasEndpoint.AppRedeploy]: {
|
|
1610
|
+
params: string[];
|
|
1611
|
+
response: number;
|
|
1612
|
+
};
|
|
1613
|
+
[TrueNasEndpoint.AppUpgrade]: {
|
|
1614
|
+
params: [string, AppUpgradeParams];
|
|
1615
|
+
response: number;
|
|
1616
|
+
};
|
|
1617
|
+
[TrueNasEndpoint.ReplicationQuery]: {
|
|
1618
|
+
params: [[], {
|
|
1619
|
+
select: string[];
|
|
1620
|
+
}];
|
|
1621
|
+
response: ReplicationQuery[];
|
|
1622
|
+
};
|
|
1623
|
+
[TrueNasEndpoint.ReplicationRun]: {
|
|
1624
|
+
params: [number];
|
|
1625
|
+
response: number;
|
|
1626
|
+
};
|
|
1627
|
+
[TrueNasEndpoint.ReplicationCreate]: {
|
|
1628
|
+
params: [ReplicationCreateConfig];
|
|
1629
|
+
response: ReplicationQuery;
|
|
1630
|
+
};
|
|
1631
|
+
[TrueNasEndpoint.InterfaceQuery]: {
|
|
1632
|
+
params: undefined;
|
|
1633
|
+
response: InterfaceEntry[];
|
|
1634
|
+
};
|
|
1635
|
+
[TrueNasEndpoint.NetworkConfiguration]: {
|
|
1636
|
+
params: undefined;
|
|
1637
|
+
response: NetworkConfiguration;
|
|
1638
|
+
};
|
|
1639
|
+
[TrueNasEndpoint.CloudBackupQuery]: {
|
|
1640
|
+
params: [[], {
|
|
1641
|
+
select: string[];
|
|
1642
|
+
}];
|
|
1643
|
+
response: CloudBackupQuery[];
|
|
1644
|
+
};
|
|
1645
|
+
[TrueNasEndpoint.CloudSyncQuery]: {
|
|
1646
|
+
params: [[], {
|
|
1647
|
+
select: string[];
|
|
1648
|
+
}];
|
|
1649
|
+
response: CloudSyncQuery[];
|
|
1650
|
+
};
|
|
1651
|
+
[TrueNasEndpoint.SystemInfo]: {
|
|
1652
|
+
params: undefined;
|
|
1653
|
+
response: SystemInfo;
|
|
1654
|
+
};
|
|
1655
|
+
[TrueNasEndpoint.SystemProductType]: {
|
|
1656
|
+
params: undefined;
|
|
1657
|
+
response: ProductType;
|
|
1658
|
+
};
|
|
1659
|
+
[TrueNasEndpoint.ExtendedSystemInfo]: {
|
|
1660
|
+
params: undefined;
|
|
1661
|
+
response: SystemInfo;
|
|
1662
|
+
};
|
|
1663
|
+
[TrueNasEndpoint.DiskQuery]: {
|
|
1664
|
+
params: [[], {
|
|
1665
|
+
extra: {
|
|
1666
|
+
pools: boolean;
|
|
1667
|
+
passwords: boolean;
|
|
1668
|
+
};
|
|
1669
|
+
}];
|
|
1670
|
+
response: DiskQuery[];
|
|
1671
|
+
};
|
|
1672
|
+
[TrueNasEndpoint.DeviceGetInfo]: {
|
|
1673
|
+
params: [{
|
|
1674
|
+
type: DeviceType;
|
|
1675
|
+
}];
|
|
1676
|
+
response: GpuDevice[];
|
|
1677
|
+
};
|
|
1678
|
+
[TrueNasEndpoint.GenerateToken]: {
|
|
1679
|
+
params: [number, Record<string, unknown>, boolean, boolean];
|
|
1680
|
+
response: string;
|
|
1681
|
+
};
|
|
1682
|
+
[TrueNasEndpoint.AlertList]: {
|
|
1683
|
+
params: string[];
|
|
1684
|
+
response: Alert[];
|
|
1685
|
+
};
|
|
1686
|
+
[TrueNasEndpoint.UserQuery]: {
|
|
1687
|
+
params: [ApiQueryFilter[]];
|
|
1688
|
+
response: TrueNasUser[];
|
|
1689
|
+
};
|
|
1690
|
+
[TrueNasEndpoint.UserUpdate]: {
|
|
1691
|
+
params: [number, TrueNasUserUpdate];
|
|
1692
|
+
response: TrueNasUser;
|
|
1693
|
+
};
|
|
1694
|
+
[TrueNasEndpoint.ServiceQuery]: {
|
|
1695
|
+
params: [ApiQueryFilter[]];
|
|
1696
|
+
response: ServiceEntry[];
|
|
1697
|
+
};
|
|
1698
|
+
[TrueNasEndpoint.ServiceUpdate]: {
|
|
1699
|
+
params: [string | number, ServiceUpdate];
|
|
1700
|
+
response: number;
|
|
1701
|
+
};
|
|
1702
|
+
[TrueNasEndpoint.ServiceControl]: {
|
|
1703
|
+
params: [ServiceControlAction, string, ServiceOptions?];
|
|
1704
|
+
response: boolean;
|
|
1705
|
+
};
|
|
1706
|
+
[TrueNasEndpoint.AuthLogin]: {
|
|
1707
|
+
params: {
|
|
1708
|
+
mechanism: TrueNasAuthMechanism;
|
|
1709
|
+
username: string;
|
|
1710
|
+
api_key: string;
|
|
1711
|
+
};
|
|
1712
|
+
response: AuthResponse;
|
|
1713
|
+
};
|
|
1714
|
+
[TrueNasEndpoint.AuthLogout]: {
|
|
1715
|
+
params: undefined;
|
|
1716
|
+
response: boolean;
|
|
1717
|
+
};
|
|
1718
|
+
[TrueNasEndpoint.ApiKeyCreate]: {
|
|
1719
|
+
params: [{
|
|
1720
|
+
name: string;
|
|
1721
|
+
username: string;
|
|
1722
|
+
}];
|
|
1723
|
+
response: ApiKeyCreate;
|
|
1724
|
+
};
|
|
1725
|
+
[TrueNasEndpoint.ApiKeyDelete]: {
|
|
1726
|
+
params: [number];
|
|
1727
|
+
response: boolean;
|
|
1728
|
+
};
|
|
1729
|
+
[TrueNasEndpoint.KeychainCredentialGenerateSshKeyPair]: {
|
|
1730
|
+
params: [];
|
|
1731
|
+
response: SSHKeyPair;
|
|
1732
|
+
};
|
|
1733
|
+
[TrueNasEndpoint.KeychainCredentialCreate]: {
|
|
1734
|
+
params: [KeychainCredentialCreate];
|
|
1735
|
+
response: SSHKeyPairEntry | SSHCredentialsEntry;
|
|
1736
|
+
};
|
|
1737
|
+
[TrueNasEndpoint.KeychainCredentialRemoteSshHostKeyScan]: {
|
|
1738
|
+
params: [RemoteSshHostKeyScanParams];
|
|
1739
|
+
response: string;
|
|
1740
|
+
};
|
|
1741
|
+
[TrueNasEndpoint.KeychainCredentialDelete]: {
|
|
1742
|
+
params: [number];
|
|
1743
|
+
response: null;
|
|
1744
|
+
};
|
|
1745
|
+
[TrueNasEndpoint.FailOverStatus]: {
|
|
1746
|
+
params: undefined;
|
|
1747
|
+
response: FailoverStatus;
|
|
1748
|
+
};
|
|
1749
|
+
[TrueNasEndpoint.FailOverNode]: {
|
|
1750
|
+
params: undefined;
|
|
1751
|
+
response: FailoverNode;
|
|
1752
|
+
};
|
|
1753
|
+
[TrueNasEndpoint.FailOverDisabledReasons]: {
|
|
1754
|
+
params: undefined;
|
|
1755
|
+
response: string[];
|
|
1756
|
+
};
|
|
1757
|
+
[TrueNasEndpoint.PoolQuery]: {
|
|
1758
|
+
params: undefined;
|
|
1759
|
+
response: PoolQuery[];
|
|
1760
|
+
};
|
|
1761
|
+
[TrueNasEndpoint.BootGetState]: {
|
|
1762
|
+
params: undefined;
|
|
1763
|
+
response: PoolQuery;
|
|
1764
|
+
};
|
|
1765
|
+
[TrueNasEndpoint.DatasetQuery]: {
|
|
1766
|
+
params: [
|
|
1767
|
+
ApiQueryFilter[],
|
|
1768
|
+
{
|
|
1769
|
+
extra: {
|
|
1770
|
+
retrieve_children: boolean;
|
|
1771
|
+
properties?: string[];
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
];
|
|
1775
|
+
response: Dataset[];
|
|
1776
|
+
};
|
|
1777
|
+
[TrueNasEndpoint.DatasetCreate]: {
|
|
1778
|
+
params: [{
|
|
1779
|
+
name: string;
|
|
1780
|
+
type: string;
|
|
1781
|
+
}];
|
|
1782
|
+
response: Dataset;
|
|
1783
|
+
};
|
|
1784
|
+
[TrueNasEndpoint.DatasetDelete]: {
|
|
1785
|
+
params: [string, {
|
|
1786
|
+
recursive: boolean;
|
|
1787
|
+
}];
|
|
1788
|
+
response: boolean | null;
|
|
1789
|
+
};
|
|
1790
|
+
[TrueNasEndpoint.SnapshotTaskCreate]: {
|
|
1791
|
+
params: [PeriodicSnapshotTaskCreate];
|
|
1792
|
+
response: PeriodicSnapshotTask;
|
|
1793
|
+
};
|
|
1794
|
+
[TrueNasEndpoint.SnapshotTaskQuery]: {
|
|
1795
|
+
params: [ApiQueryFilter[]];
|
|
1796
|
+
response: PeriodicSnapshotTask[];
|
|
1797
|
+
};
|
|
1798
|
+
[TrueNasEndpoint.SnapshotTaskDelete]: {
|
|
1799
|
+
params: [number];
|
|
1800
|
+
response: boolean;
|
|
1801
|
+
};
|
|
1802
|
+
[TrueNasEndpoint.SnapshotCreate]: {
|
|
1803
|
+
params: [CreateZfsSnapshot];
|
|
1804
|
+
response: ZfsSnapshot;
|
|
1805
|
+
};
|
|
1806
|
+
[TrueNasEndpoint.SnapshotDelete]: {
|
|
1807
|
+
params: [string];
|
|
1808
|
+
response: boolean;
|
|
1809
|
+
};
|
|
1810
|
+
[TrueNasEndpoint.ReplicationCountEligibleSnapshots]: {
|
|
1811
|
+
params: [CountEligibleSnapshotsParams];
|
|
1812
|
+
response: EligibleSnapshotsCount;
|
|
1813
|
+
};
|
|
1814
|
+
[TrueNasEndpoint.VirtualInstanceQuery]: {
|
|
1815
|
+
params: [ApiQueryFilter[]];
|
|
1816
|
+
response: VirtualInstanceQuery[];
|
|
1817
|
+
};
|
|
1818
|
+
[TrueNasEndpoint.VirtualInstanceStart]: {
|
|
1819
|
+
params: string[];
|
|
1820
|
+
response: number;
|
|
1821
|
+
};
|
|
1822
|
+
[TrueNasEndpoint.VirtualInstanceStop]: {
|
|
1823
|
+
params: [string, Omit<VirtualizationStopParams, 'force_after_timeout'>];
|
|
1824
|
+
response: number;
|
|
1825
|
+
};
|
|
1826
|
+
[TrueNasEndpoint.VirtualInstanceRestart]: {
|
|
1827
|
+
params: [string, Omit<VirtualizationStopParams, 'force_after_timeout'>];
|
|
1828
|
+
response: number;
|
|
1829
|
+
};
|
|
1830
|
+
[TrueNasEndpoint.ContainerQuery]: {
|
|
1831
|
+
params: [ApiQueryFilter[]];
|
|
1832
|
+
response: ContainerQueryV26[];
|
|
1833
|
+
};
|
|
1834
|
+
[TrueNasEndpoint.ContainerStart]: {
|
|
1835
|
+
params: [number];
|
|
1836
|
+
response: number;
|
|
1837
|
+
};
|
|
1838
|
+
[TrueNasEndpoint.ContainerStop]: {
|
|
1839
|
+
params: [number, ContainerStopOptionsV26];
|
|
1840
|
+
response: number;
|
|
1841
|
+
};
|
|
1842
|
+
[TrueNasEndpoint.VmQuery]: {
|
|
1843
|
+
params: [ApiQueryFilter[]];
|
|
1844
|
+
response: VMQuery[];
|
|
1845
|
+
};
|
|
1846
|
+
[TrueNasEndpoint.VmStart]: {
|
|
1847
|
+
params: [number, {
|
|
1848
|
+
overcommit?: boolean;
|
|
1849
|
+
}];
|
|
1850
|
+
response: number;
|
|
1851
|
+
};
|
|
1852
|
+
[TrueNasEndpoint.VmStop]: {
|
|
1853
|
+
params: [number, {
|
|
1854
|
+
force?: boolean;
|
|
1855
|
+
force_after_timeout?: boolean;
|
|
1856
|
+
}];
|
|
1857
|
+
response: number;
|
|
1858
|
+
};
|
|
1859
|
+
[TrueNasEndpoint.VmRestart]: {
|
|
1860
|
+
params: [number];
|
|
1861
|
+
response: number;
|
|
1862
|
+
};
|
|
1863
|
+
[TrueNasEndpoint.CoreSubscribe]: {
|
|
1864
|
+
params: string[];
|
|
1865
|
+
response: unknown;
|
|
1866
|
+
};
|
|
1867
|
+
[TrueNasEndpoint.HardwareVirtualizationVariant]: {
|
|
1868
|
+
params: undefined;
|
|
1869
|
+
response: VirtVariant;
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
type ApiQueryFilter = [string, string, string | number | boolean];
|
|
1873
|
+
type ApiCallMethod = keyof ApiCallDirectory;
|
|
1874
|
+
type ApiCallParams<T extends ApiCallMethod> = ApiCallDirectory[T]['params'];
|
|
1875
|
+
type ApiCallResponse<T extends ApiCallMethod> = ApiCallDirectory[T]['response'];
|
|
1876
|
+
|
|
1877
|
+
/**
|
|
1878
|
+
* Minimal logging surface the client writes to. Consumers inject their own
|
|
1879
|
+
* implementation; the package never depends on a concrete logging library.
|
|
1880
|
+
* Method signatures mirror the TrueNAS Connect UI `Log` service so call sites
|
|
1881
|
+
* port unchanged.
|
|
1882
|
+
*/
|
|
1883
|
+
interface Logger {
|
|
1884
|
+
trace(message: string, ...args: unknown[]): void;
|
|
1885
|
+
debug(message: string, ...args: unknown[]): void;
|
|
1886
|
+
info(message: string, ...args: unknown[]): void;
|
|
1887
|
+
warn(message: string, ...args: unknown[]): void;
|
|
1888
|
+
error(message: string, ...args: unknown[]): void;
|
|
1889
|
+
}
|
|
1890
|
+
/** Logger that forwards to the global `console`. */
|
|
1891
|
+
declare const consoleLogger: Logger;
|
|
1892
|
+
/** Logger that discards everything. The default when no logger is provided. */
|
|
1893
|
+
declare const noopLogger: Logger;
|
|
1894
|
+
|
|
1895
|
+
declare class TrueNasSocket {
|
|
1896
|
+
config: WebSocketSubjectConfig<TrueNasMessage>;
|
|
1897
|
+
socket: rxjs_webSocket.WebSocketSubject<TrueNasMessage>;
|
|
1898
|
+
constructor(config: WebSocketSubjectConfig<TrueNasMessage>);
|
|
1899
|
+
messages(): rxjs_webSocket.WebSocketSubject<TrueNasMessage>;
|
|
1900
|
+
next(msg: TrueNasMessage): void;
|
|
1901
|
+
complete(): void;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
interface ActiveConnection {
|
|
1905
|
+
ws: TrueNasSocket;
|
|
1906
|
+
hostname: string;
|
|
1907
|
+
}
|
|
1908
|
+
interface ConnectionError extends Error {
|
|
1909
|
+
hostname?: string;
|
|
1910
|
+
}
|
|
1911
|
+
type Connection = ActiveConnection & {
|
|
1912
|
+
state: 'active';
|
|
1913
|
+
} | ConnectionError & {
|
|
1914
|
+
state: 'error';
|
|
1915
|
+
} | {
|
|
1916
|
+
state: 'closed';
|
|
1917
|
+
};
|
|
1918
|
+
declare class TrueNasConnection {
|
|
1919
|
+
private readonly hostnames;
|
|
1920
|
+
readonly systemUuid: string;
|
|
1921
|
+
readonly websocketPath: string;
|
|
1922
|
+
readonly systemName?: string | undefined;
|
|
1923
|
+
readonly retryDelay: number;
|
|
1924
|
+
readonly maxRetry: number;
|
|
1925
|
+
readonly logger: Logger;
|
|
1926
|
+
opened: BehaviorSubject<boolean>;
|
|
1927
|
+
closed: Subject<void>;
|
|
1928
|
+
hostname: BehaviorSubject<string>;
|
|
1929
|
+
ws: TrueNasSocket;
|
|
1930
|
+
connectionAttempts: BehaviorSubject<number>;
|
|
1931
|
+
lastErrorMessage: BehaviorSubject<string | null>;
|
|
1932
|
+
/**
|
|
1933
|
+
* emits when the connection is manually closed.
|
|
1934
|
+
*/
|
|
1935
|
+
closeConnection: Subject<void>;
|
|
1936
|
+
/**
|
|
1937
|
+
* the connection only establishes a socket while this gate is `true`. consumers
|
|
1938
|
+
* flip it via `setEnabled()` (the app maps `SystemState.Active -> true`).
|
|
1939
|
+
*/
|
|
1940
|
+
private enabled$;
|
|
1941
|
+
/**
|
|
1942
|
+
* observable which emits the current gate value and only emits again when it changes.
|
|
1943
|
+
*/
|
|
1944
|
+
enabledChange$: Observable<boolean>;
|
|
1945
|
+
/**
|
|
1946
|
+
* observable that handles the entire connection lifecycle.
|
|
1947
|
+
*/
|
|
1948
|
+
connection$: Observable<Connection>;
|
|
1949
|
+
/**
|
|
1950
|
+
* observable which is either an instance of the current `TrueNasSocket` used for the connection
|
|
1951
|
+
* or `null` if the connection is closed or errored for any reason.
|
|
1952
|
+
*/
|
|
1953
|
+
ws$: Observable<TrueNasSocket | null>;
|
|
1954
|
+
/**
|
|
1955
|
+
* current hostname we used to build the URL for this connection.
|
|
1956
|
+
*/
|
|
1957
|
+
hostname$: Observable<string | null>;
|
|
1958
|
+
/**
|
|
1959
|
+
* emits error messages from the connection pipeline. this is used to derive the
|
|
1960
|
+
* corresponding compatibility property.
|
|
1961
|
+
*/
|
|
1962
|
+
lastErrorMessage$: Observable<string | null>;
|
|
1963
|
+
/**
|
|
1964
|
+
* emits when the connection state *changes*, so it'll never emit `true` twice
|
|
1965
|
+
* in a row nor `false` twice in a row.
|
|
1966
|
+
*/
|
|
1967
|
+
opened$: Observable<boolean>;
|
|
1968
|
+
/**
|
|
1969
|
+
* emits when the connection state goes from open to closed.
|
|
1970
|
+
*/
|
|
1971
|
+
closed$: Observable<void>;
|
|
1972
|
+
/**
|
|
1973
|
+
* whether to display a connection error to the user — the **live** signal.
|
|
1974
|
+
*
|
|
1975
|
+
* `true` only while `connection$` is currently a `ConnectionError`, meaning the entire race +
|
|
1976
|
+
* retry cycle has been exhausted for all hostnames right now; it flips back to `false` once a
|
|
1977
|
+
* connection is re-established. individual socket losses during a race are expected and not surfaced.
|
|
1978
|
+
*
|
|
1979
|
+
* NOTE: this is NOT the same as the `hasExhaustedRetries()` method, which is a **cumulative**
|
|
1980
|
+
* snapshot (see there). The two can disagree — prefer this observable for "is the connection
|
|
1981
|
+
* errored right now?".
|
|
1982
|
+
*/
|
|
1983
|
+
hasConnectionError$: Observable<boolean>;
|
|
1984
|
+
/**
|
|
1985
|
+
* observable which always emits messages from the current socket.
|
|
1986
|
+
*/
|
|
1987
|
+
messages$: Observable<TrueNasMessage>;
|
|
1988
|
+
constructor(initialEnabled: boolean, hostnames: string[], systemUuid: string, websocketPath: string, systemName?: string | undefined, retryDelay?: number, maxRetry?: number, logger?: Logger);
|
|
1989
|
+
/**
|
|
1990
|
+
* whether the connection has exhausted its retries — the **cumulative** snapshot, read
|
|
1991
|
+
* synchronously. (Formerly `hasConnectionError()`; renamed to disambiguate it from the
|
|
1992
|
+
* live `hasConnectionError$` observable, with which it can disagree.)
|
|
1993
|
+
*
|
|
1994
|
+
* `true` when the lifetime `connectionAttempts` count exceeds `hostnames.length * maxRetry`,
|
|
1995
|
+
* OR when an error message is currently set. Ported from the source (tncui) behavior.
|
|
1996
|
+
*
|
|
1997
|
+
* CAVEAT (pre-existing tncui behavior, preserved here): `connectionAttempts` only ever grows —
|
|
1998
|
+
* it is never reset on a successful (re)connection — so over a long-lived connection with
|
|
1999
|
+
* reconnect churn this can latch to `true` even while the connection is currently healthy. For
|
|
2000
|
+
* "is it errored right now?" use the live `hasConnectionError$` observable instead.
|
|
2001
|
+
*/
|
|
2002
|
+
hasExhaustedRetries(): boolean;
|
|
2003
|
+
/**
|
|
2004
|
+
* enables or disables the connection gate. the app calls this when its `SystemState`
|
|
2005
|
+
* changes (mapping `SystemState.Active -> true`, everything else -> `false`).
|
|
2006
|
+
*/
|
|
2007
|
+
setEnabled(enabled: boolean): void;
|
|
2008
|
+
/**
|
|
2009
|
+
* compatibility method which just returns the public `messages$` observable.
|
|
2010
|
+
* this is used in a few places in the codebase that relied upon the old implementation.
|
|
2011
|
+
*/
|
|
2012
|
+
messages(): Observable<TrueNasMessage>;
|
|
2013
|
+
/**
|
|
2014
|
+
* sends a message over the current websocket OR queues it to send once
|
|
2015
|
+
* the next websocket is opened. messages sent via `send` will not be lost until after
|
|
2016
|
+
* the next `closed$` emission.
|
|
2017
|
+
*/
|
|
2018
|
+
send(message: TrueNasMessage): rxjs.Subscription;
|
|
2019
|
+
/**
|
|
2020
|
+
* manually closes this connection and prevents it from retrying/opening any more.
|
|
2021
|
+
*/
|
|
2022
|
+
close(): void;
|
|
2023
|
+
/**
|
|
2024
|
+
* helper method which creates an `Observable` which emits an `ActiveConnection`
|
|
2025
|
+
* after it establishes a connection to the given hostname. the observable will emit an
|
|
2026
|
+
* error if the connection is never established and will not complete until unsubscribed from or closed.
|
|
2027
|
+
*/
|
|
2028
|
+
private createSocket;
|
|
2029
|
+
/**
|
|
2030
|
+
* helper function which actually performs the parallel connection `race`.
|
|
2031
|
+
*/
|
|
2032
|
+
private connect;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
/**
|
|
2036
|
+
* TrueNAS API handler using the JSON-RPC 2.0 protocol.
|
|
2037
|
+
*
|
|
2038
|
+
* It handles:
|
|
2039
|
+
* - JSON-RPC 2.0 request formatting
|
|
2040
|
+
* - JSON-RPC 2.0 response parsing (result/error)
|
|
2041
|
+
* - Event subscriptions
|
|
2042
|
+
* - Job tracking
|
|
2043
|
+
*/
|
|
2044
|
+
declare class TrueNasApi {
|
|
2045
|
+
authenticated: BehaviorSubject<boolean>;
|
|
2046
|
+
connection: TrueNasConnection;
|
|
2047
|
+
/**
|
|
2048
|
+
* Stream of job events from websocket.
|
|
2049
|
+
* JSON-RPC 2.0 events have structure: { method: 'collection_update', params: { collection, fields, ... } }
|
|
2050
|
+
*/
|
|
2051
|
+
private jobEvents;
|
|
2052
|
+
constructor(authenticated: BehaviorSubject<boolean>, connection: TrueNasConnection);
|
|
2053
|
+
call<M extends ApiCallMethod>(method: M, params?: ApiCallParams<M>): Observable<ApiCallResponse<M>>;
|
|
2054
|
+
/**
|
|
2055
|
+
* Makes an API call and returns the job ID from the websocket event.
|
|
2056
|
+
* Used for v26 where API calls return null but job events contain the job ID.
|
|
2057
|
+
*
|
|
2058
|
+
* The job ID is extracted from the first job event where message_ids contains
|
|
2059
|
+
* the original request ID.
|
|
2060
|
+
*
|
|
2061
|
+
* @param method The API method to call
|
|
2062
|
+
* @param params The parameters for the API call
|
|
2063
|
+
* @returns Observable that emits the job ID when received from websocket events
|
|
2064
|
+
*/
|
|
2065
|
+
callAndGetJobId<M extends ApiCallMethod>(method: M, params?: ApiCallParams<M>): Observable<number>;
|
|
2066
|
+
events(eventName: string): Observable<TrueNasMessage>;
|
|
2067
|
+
/**
|
|
2068
|
+
* Convenience wrapper for auth.generate_token API call.
|
|
2069
|
+
*/
|
|
2070
|
+
generateToken(ttl?: number, matchOrigin?: boolean, singleUse?: boolean): Observable<string>;
|
|
2071
|
+
trackJob(jobId: number): Observable<Job>;
|
|
2072
|
+
private initializeJobEventsSubscription;
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
/**
|
|
2076
|
+
* TrueNAS authenticator using the JSON-RPC 2.0 protocol.
|
|
2077
|
+
*
|
|
2078
|
+
* It handles authentication using the JSON-RPC 2.0 message format.
|
|
2079
|
+
*/
|
|
2080
|
+
declare class TrueNasAuthenticator {
|
|
2081
|
+
private connection;
|
|
2082
|
+
static readonly DefaultSessionLifetime = 300;
|
|
2083
|
+
/**
|
|
2084
|
+
* whether or not the system is currently authenticated and accessible.
|
|
2085
|
+
* this is a `BehaviorSubject` instead of a signal, since we use its `getValue` method
|
|
2086
|
+
* throughout a lot of the codebase.
|
|
2087
|
+
*/
|
|
2088
|
+
authenticated$: BehaviorSubject<boolean>;
|
|
2089
|
+
/**
|
|
2090
|
+
* `true` when the system is currently being authenticated to, and `false` otherwise.
|
|
2091
|
+
* does not indicate whatsoever if authentication is successful or not, just whether the process
|
|
2092
|
+
* is ongoing.
|
|
2093
|
+
*/
|
|
2094
|
+
authenticating$: BehaviorSubject<boolean>;
|
|
2095
|
+
credentials: {
|
|
2096
|
+
username: string;
|
|
2097
|
+
password: string;
|
|
2098
|
+
key: string;
|
|
2099
|
+
};
|
|
2100
|
+
sessionLifetime: number;
|
|
2101
|
+
constructor(connection: TrueNasConnection);
|
|
2102
|
+
loginWithUserPass(username: string, password: string): rxjs.Observable<AuthResponse>;
|
|
2103
|
+
loginWithOtp(code: string): rxjs.Observable<AuthResponse>;
|
|
2104
|
+
loginWithApiKey(credentials: {
|
|
2105
|
+
username: string;
|
|
2106
|
+
key: string;
|
|
2107
|
+
}): rxjs.Observable<AuthResponse>;
|
|
2108
|
+
newApiKey(username: string): rxjs.Observable<ApiKeyCreate>;
|
|
2109
|
+
logout(): rxjs.Observable<boolean>;
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
/**
|
|
2113
|
+
* Response from the /api/versions endpoint
|
|
2114
|
+
* Returns an array of version strings directly
|
|
2115
|
+
* Example: ["v25.10.0", "v25.10.1", "v26.0.0"]
|
|
2116
|
+
*/
|
|
2117
|
+
type ApiVersionResponse = string[];
|
|
2118
|
+
/**
|
|
2119
|
+
* Parsed API version information
|
|
2120
|
+
*
|
|
2121
|
+
* Version format:
|
|
2122
|
+
* - Legacy (v25.x): vYY.MM.PATCH (e.g., v25.10.0 = October 2025, patch 0)
|
|
2123
|
+
* - New (v26+): vYY.MINOR.PATCH (e.g., v26.0.0 = 2026, minor 0, patch 0)
|
|
2124
|
+
*
|
|
2125
|
+
* Note: The second segment has different semantics based on the year:
|
|
2126
|
+
* - Year 25: month (1-12)
|
|
2127
|
+
* - Year 26+: minor version (0-99)
|
|
2128
|
+
*/
|
|
2129
|
+
interface ApiVersion {
|
|
2130
|
+
/** Full version string (e.g., "v26.0.0") */
|
|
2131
|
+
version: string;
|
|
2132
|
+
/** Two-digit year (e.g., 26 = 2026) */
|
|
2133
|
+
year: number;
|
|
2134
|
+
/**
|
|
2135
|
+
* Second version segment (semantics depend on year):
|
|
2136
|
+
* - For v25.x: month (1-12, e.g., 10 = October)
|
|
2137
|
+
* - For v26+: minor version (0-99)
|
|
2138
|
+
*/
|
|
2139
|
+
minor: number;
|
|
2140
|
+
/** Patch version number (e.g., 0, 1, 2) */
|
|
2141
|
+
patch: number;
|
|
2142
|
+
/** WebSocket path for this version (e.g., "/api/v26.0.0") */
|
|
2143
|
+
websocketPath: string;
|
|
2144
|
+
}
|
|
2145
|
+
/**
|
|
2146
|
+
* Version compatibility status
|
|
2147
|
+
*/
|
|
2148
|
+
declare enum VersionCompatibility {
|
|
2149
|
+
Compatible = "compatible",
|
|
2150
|
+
TooOld = "too-old",
|
|
2151
|
+
TooNew = "too-new",
|
|
2152
|
+
Invalid = "invalid"
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
/**
|
|
2156
|
+
* OperationMappings Interface
|
|
2157
|
+
*
|
|
2158
|
+
* Defines version-agnostic operations that abstract away API differences
|
|
2159
|
+
* between TrueNAS versions. Each API client version implements this interface
|
|
2160
|
+
* with its specific endpoint calls and response transformations.
|
|
2161
|
+
*
|
|
2162
|
+
* Operations return Observable<Job | null> that:
|
|
2163
|
+
* - For async operations: emits Job updates until complete, then completes
|
|
2164
|
+
* - For sync operations: emits null once, then completes
|
|
2165
|
+
*
|
|
2166
|
+
* Usage in components:
|
|
2167
|
+
* ```typescript
|
|
2168
|
+
* const truenas = this.truenasService.get(systemId);
|
|
2169
|
+
* truenas.ops.containerQuery().subscribe(containers => ...);
|
|
2170
|
+
*
|
|
2171
|
+
* // With progress dialog (recommended)
|
|
2172
|
+
* this.truenasService.trackWithDialog(
|
|
2173
|
+
* truenas.ops.containerStart(id),
|
|
2174
|
+
* 'Starting container'
|
|
2175
|
+
* ).subscribe(() => console.log('Started'));
|
|
2176
|
+
*
|
|
2177
|
+
* // Without progress dialog
|
|
2178
|
+
* truenas.ops.containerStart(id).subscribe({
|
|
2179
|
+
* next: (job) => job && console.log(job.progress),
|
|
2180
|
+
* complete: () => console.log('Started')
|
|
2181
|
+
* });
|
|
2182
|
+
* ```
|
|
2183
|
+
*
|
|
2184
|
+
* Version mappings:
|
|
2185
|
+
* - v25.10: Uses virt.instance.* APIs (emits Job updates)
|
|
2186
|
+
* - v26+: Uses container.* APIs (some emit Job, some emit null)
|
|
2187
|
+
*
|
|
2188
|
+
* To add new operations:
|
|
2189
|
+
* 1. Add the method signature here
|
|
2190
|
+
* 2. Implement in TrueNasApiClientV2510.createOperations()
|
|
2191
|
+
* 3. Implement in TrueNasApiClientV26.createOperations()
|
|
2192
|
+
*/
|
|
2193
|
+
interface OperationMappings {
|
|
2194
|
+
/**
|
|
2195
|
+
* Query all containers
|
|
2196
|
+
* - v25.10: virt.instance.query with type=CONTAINER filter
|
|
2197
|
+
* - v26+: container.query
|
|
2198
|
+
*/
|
|
2199
|
+
containerQuery: () => Observable<Container[]>;
|
|
2200
|
+
/**
|
|
2201
|
+
* Start a container
|
|
2202
|
+
* - v25.10: Emits Job updates until started
|
|
2203
|
+
* - v26+: Emits null (synchronous operation)
|
|
2204
|
+
*/
|
|
2205
|
+
containerStart: (id: string) => Observable<Job | null>;
|
|
2206
|
+
/**
|
|
2207
|
+
* Stop a container
|
|
2208
|
+
* - v25.10: Emits Job updates until stopped
|
|
2209
|
+
* - v26+: Emits Job updates until stopped
|
|
2210
|
+
*/
|
|
2211
|
+
containerStop: (id: string, options: ContainerStopOptions) => Observable<Job | null>;
|
|
2212
|
+
/**
|
|
2213
|
+
* Restart a container
|
|
2214
|
+
* - v25.10: Emits Job updates until restarted
|
|
2215
|
+
* - v26+: Emits Job updates (stop phase), then null (sync start)
|
|
2216
|
+
*/
|
|
2217
|
+
containerRestart: (id: string, options: ContainerRestartOptions) => Observable<Job | null>;
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
/**
|
|
2221
|
+
* Abstract base class for TrueNAS API clients
|
|
2222
|
+
*
|
|
2223
|
+
* Provides common implementation for all API versions. Version-specific clients
|
|
2224
|
+
* extend this class and override factory methods to provide custom implementations
|
|
2225
|
+
* when needed.
|
|
2226
|
+
*
|
|
2227
|
+
* This class manages the lifecycle of all TrueNAS connection components:
|
|
2228
|
+
* - TrueNasConnection (WebSocket connection management)
|
|
2229
|
+
* - TrueNasApi (API call handling)
|
|
2230
|
+
* - TrueNasAuthenticator (authentication)
|
|
2231
|
+
*/
|
|
2232
|
+
|
|
2233
|
+
declare abstract class TrueNasApiClient {
|
|
2234
|
+
/** API version information for this client */
|
|
2235
|
+
readonly version: ApiVersion;
|
|
2236
|
+
/** WebSocket connection manager */
|
|
2237
|
+
readonly connection: TrueNasConnection;
|
|
2238
|
+
/** Authentication manager */
|
|
2239
|
+
readonly authenticator: TrueNasAuthenticator;
|
|
2240
|
+
/** API call handler */
|
|
2241
|
+
readonly api: TrueNasApi;
|
|
2242
|
+
/**
|
|
2243
|
+
* Version-agnostic operation mappings
|
|
2244
|
+
*
|
|
2245
|
+
* Provides a unified interface for operations that differ between API versions.
|
|
2246
|
+
* Each version-specific client implements these operations using its own endpoints.
|
|
2247
|
+
*
|
|
2248
|
+
* Usage:
|
|
2249
|
+
* ```typescript
|
|
2250
|
+
* truenas.ops.containerQuery().subscribe(containers => ...);
|
|
2251
|
+
* truenas.ops.containerStart(id).subscribe(jobId => ...);
|
|
2252
|
+
* ```
|
|
2253
|
+
*/
|
|
2254
|
+
readonly ops: OperationMappings;
|
|
2255
|
+
/** System UUID */
|
|
2256
|
+
protected readonly uuid: string;
|
|
2257
|
+
/** System hostnames (primary and fallback) */
|
|
2258
|
+
protected readonly hostnames: string[];
|
|
2259
|
+
/**
|
|
2260
|
+
* Initial connection gate, forwarded to the connection. The app flips it later
|
|
2261
|
+
* via `connection.setEnabled()` (mapping its `SystemState.Active -> true`).
|
|
2262
|
+
*/
|
|
2263
|
+
protected readonly enabled: boolean;
|
|
2264
|
+
/** System name (optional) */
|
|
2265
|
+
protected readonly systemName: string | undefined;
|
|
2266
|
+
/** Logger forwarded to the connection (defaults to a no-op). */
|
|
2267
|
+
protected readonly logger: Logger;
|
|
2268
|
+
constructor(uuid: string, hostnames: string[], version: ApiVersion, enabled: boolean, systemName?: string, logger?: Logger);
|
|
2269
|
+
/**
|
|
2270
|
+
* Get current connection status.
|
|
2271
|
+
* @returns true if WebSocket is connected
|
|
2272
|
+
*/
|
|
2273
|
+
get connected(): boolean;
|
|
2274
|
+
/**
|
|
2275
|
+
* Get current authentication status.
|
|
2276
|
+
* @returns true if authenticated with the system
|
|
2277
|
+
*/
|
|
2278
|
+
get authenticated(): boolean;
|
|
2279
|
+
/**
|
|
2280
|
+
* Close the WebSocket connection.
|
|
2281
|
+
* Connection will automatically retry if retry is enabled.
|
|
2282
|
+
*/
|
|
2283
|
+
close(): void;
|
|
2284
|
+
/**
|
|
2285
|
+
* Factory method to create the WebSocket connection.
|
|
2286
|
+
* Override in subclasses to provide version-specific connection handling.
|
|
2287
|
+
*/
|
|
2288
|
+
protected createConnection(): TrueNasConnection;
|
|
2289
|
+
/**
|
|
2290
|
+
* Factory method to create the API handler.
|
|
2291
|
+
* Override in subclasses to provide version-specific API implementations.
|
|
2292
|
+
*/
|
|
2293
|
+
protected createApi(): TrueNasApi;
|
|
2294
|
+
/**
|
|
2295
|
+
* Factory method to create the authenticator.
|
|
2296
|
+
* Override in subclasses to provide version-specific authentication.
|
|
2297
|
+
*/
|
|
2298
|
+
protected createAuthenticator(): TrueNasAuthenticator;
|
|
2299
|
+
/**
|
|
2300
|
+
* Factory method to create version-specific operation mappings.
|
|
2301
|
+
* Must be implemented by subclasses to provide version-specific implementations.
|
|
2302
|
+
*
|
|
2303
|
+
* This is the primary extension point for handling API differences between versions.
|
|
2304
|
+
*/
|
|
2305
|
+
protected abstract createOperations(): OperationMappings;
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2308
|
+
/** Options for {@link createTrueNasClient}. */
|
|
2309
|
+
interface CreateClientOptions {
|
|
2310
|
+
/** System UUID. */
|
|
2311
|
+
uuid: string;
|
|
2312
|
+
/** Hostnames to connect to — primary first, then fallbacks. */
|
|
2313
|
+
hostnames: string[];
|
|
2314
|
+
/**
|
|
2315
|
+
* Initial connection gate. The client only opens a socket while this is `true`;
|
|
2316
|
+
* flip it later via `client.connection.setEnabled()`. (The app maps its
|
|
2317
|
+
* `SystemState.Active -> true`.)
|
|
2318
|
+
*/
|
|
2319
|
+
enabled: boolean;
|
|
2320
|
+
/** Optional system name (used only for log context). */
|
|
2321
|
+
systemName?: string;
|
|
2322
|
+
/**
|
|
2323
|
+
* Optional logger; defaults to a no-op. Forwarded to version discovery and,
|
|
2324
|
+
* through the client, to the connection.
|
|
2325
|
+
*/
|
|
2326
|
+
logger?: Logger;
|
|
2327
|
+
}
|
|
2328
|
+
/**
|
|
2329
|
+
* Creates a version-specific TrueNAS API client.
|
|
2330
|
+
*
|
|
2331
|
+
* 1. Discovers the API version from the primary hostname (`GET /api/versions`).
|
|
2332
|
+
* 2. Selects the matching client implementation (`v25.10.x` -> `TrueNasApiClientV2510`,
|
|
2333
|
+
* `v26.x.y` -> `TrueNasApiClientV26`).
|
|
2334
|
+
* 3. Instantiates and returns it.
|
|
2335
|
+
*
|
|
2336
|
+
* Resolves exactly once with a single client instance — dispose of it with
|
|
2337
|
+
* `client.close()` when done.
|
|
2338
|
+
*
|
|
2339
|
+
* @returns a Promise that resolves with the created client, or rejects with a
|
|
2340
|
+
* {@link VersionDiscoveryError} subclass (or a client-selection error).
|
|
2341
|
+
* Rejects if `hostnames` is empty.
|
|
2342
|
+
*/
|
|
2343
|
+
declare function createTrueNasClient(opts: CreateClientOptions): Promise<TrueNasApiClient>;
|
|
2344
|
+
|
|
2345
|
+
/**
|
|
2346
|
+
* TrueNAS API Client for v25.10.x
|
|
2347
|
+
*
|
|
2348
|
+
* Handles all v25.10 patch versions (v25.10.0, v25.10.1, v25.10.2, etc.).
|
|
2349
|
+
* Patch versions are backward compatible, so one client implementation
|
|
2350
|
+
* handles all patches within the v25.10.x series.
|
|
2351
|
+
*
|
|
2352
|
+
* To add version-specific behavior, override the factory methods:
|
|
2353
|
+
* - createConnection() - for connection-specific changes
|
|
2354
|
+
* - createApi() - for API method changes
|
|
2355
|
+
* - createAuthenticator() - for authentication changes
|
|
2356
|
+
* - createOperations() - for version-specific operation mappings
|
|
2357
|
+
*/
|
|
2358
|
+
|
|
2359
|
+
/**
|
|
2360
|
+
* API client for TrueNAS API v25.10.x
|
|
2361
|
+
*
|
|
2362
|
+
* Protocol: JSON-RPC 2.0
|
|
2363
|
+
* WebSocket Path: /api/v25.10.{patch}
|
|
2364
|
+
*
|
|
2365
|
+
* Container operations use virt.instance.* APIs:
|
|
2366
|
+
* - containerQuery → virt.instance.query (filtered by type=CONTAINER)
|
|
2367
|
+
* - containerStart → virt.instance.start (emits Job updates)
|
|
2368
|
+
* - containerStop → virt.instance.stop (emits Job updates)
|
|
2369
|
+
* - containerRestart → virt.instance.restart (emits Job updates)
|
|
2370
|
+
*/
|
|
2371
|
+
declare class TrueNasApiClientV2510 extends TrueNasApiClient {
|
|
2372
|
+
/**
|
|
2373
|
+
* Create v25.10-specific operation mappings
|
|
2374
|
+
*
|
|
2375
|
+
* virt.instance.* APIs return boolean (true) but emit job events via websocket.
|
|
2376
|
+
* We use callAndGetJobId to capture the job ID, then track the job.
|
|
2377
|
+
* All operations emit Job updates until the operation completes.
|
|
2378
|
+
*/
|
|
2379
|
+
protected createOperations(): OperationMappings;
|
|
2380
|
+
/**
|
|
2381
|
+
* Transform VirtualInstanceQuery to unified Container type
|
|
2382
|
+
*/
|
|
2383
|
+
private toContainer;
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
/**
|
|
2387
|
+
* TrueNAS API Client for v26.X.Y
|
|
2388
|
+
*
|
|
2389
|
+
* Handles all v26 versions (v26.0.0, v26.0.1, v26.1.2, etc.).
|
|
2390
|
+
* Minor AND patch versions are backward compatible, so one client implementation
|
|
2391
|
+
* handles all patches within the v26 series.
|
|
2392
|
+
*
|
|
2393
|
+
* To add version-specific behavior, override the factory methods:
|
|
2394
|
+
* - createConnection() - for connection-specific changes
|
|
2395
|
+
* - createApi() - for API method changes
|
|
2396
|
+
* - createAuthenticator() - for authentication changes
|
|
2397
|
+
* - createOperations() - for version-specific operation mappings
|
|
2398
|
+
*/
|
|
2399
|
+
|
|
2400
|
+
/**
|
|
2401
|
+
* API client for TrueNAS API v26
|
|
2402
|
+
*
|
|
2403
|
+
* Protocol: JSON-RPC 2.0
|
|
2404
|
+
* WebSocket Path: /api/v26.{minor}.{patch}
|
|
2405
|
+
*
|
|
2406
|
+
* Container operations use native container.* APIs:
|
|
2407
|
+
* - containerQuery → container.query (with response transformation)
|
|
2408
|
+
* - containerStart → container.start (synchronous, emits null)
|
|
2409
|
+
* - containerStop → container.stop (emits Job updates)
|
|
2410
|
+
* - containerRestart → container.stop + container.start (emits Job, then null)
|
|
2411
|
+
*/
|
|
2412
|
+
declare class TrueNasApiClientV26 extends TrueNasApiClient {
|
|
2413
|
+
/**
|
|
2414
|
+
* Map v26 status state string to AppState enum
|
|
2415
|
+
*/
|
|
2416
|
+
private static mapStatus;
|
|
2417
|
+
/**
|
|
2418
|
+
* Create v26-specific operation mappings
|
|
2419
|
+
*
|
|
2420
|
+
* Operations return Observable<Job | null>:
|
|
2421
|
+
* - Async operations emit Job updates until complete
|
|
2422
|
+
* - Sync operations emit null once
|
|
2423
|
+
*/
|
|
2424
|
+
protected createOperations(): OperationMappings;
|
|
2425
|
+
/**
|
|
2426
|
+
* Transform v26 ContainerQueryV26 to unified Container type
|
|
2427
|
+
*/
|
|
2428
|
+
private toContainer;
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
/**
|
|
2432
|
+
* Discovers available API versions from TrueNAS systems.
|
|
2433
|
+
*
|
|
2434
|
+
* Performs a `fetch` GET to the `/api/versions` endpoint and:
|
|
2435
|
+
* - Parses version strings
|
|
2436
|
+
* - Filters to compatible versions (within MIN/MAX range)
|
|
2437
|
+
* - Selects the latest compatible version
|
|
2438
|
+
* - Caches results per hostname
|
|
2439
|
+
* - Classifies failures into typed {@link VersionDiscoveryError} subclasses
|
|
2440
|
+
*
|
|
2441
|
+
* This is the framework-agnostic replacement for the app's Angular `HttpClient`
|
|
2442
|
+
* service. Because `fetch` resolves (rather than rejects) on non-2xx responses and
|
|
2443
|
+
* throws a `TypeError` on network/CORS/unreachable failures, the error contract
|
|
2444
|
+
* differs from the original: a network/CORS/unreachable failure surfaces as a
|
|
2445
|
+
* {@link VersionDiscoveryNetworkError} — the sentinel the client factory keys on for
|
|
2446
|
+
* its CORS fallback (replacing the old `HttpErrorResponse.status === 0` check).
|
|
2447
|
+
*/
|
|
2448
|
+
declare class VersionDiscovery {
|
|
2449
|
+
private readonly logger;
|
|
2450
|
+
private versionCache;
|
|
2451
|
+
constructor(logger?: Logger);
|
|
2452
|
+
/**
|
|
2453
|
+
* Discovers the API version for a given hostname.
|
|
2454
|
+
*
|
|
2455
|
+
* Makes a GET request to `https://{hostname}/api/versions` and returns the latest
|
|
2456
|
+
* compatible version. Results are cached per hostname; the cache entry is removed
|
|
2457
|
+
* on failure so the next call retries.
|
|
2458
|
+
*
|
|
2459
|
+
* @param hostname - The TrueNAS system hostname (e.g., "truenas.local")
|
|
2460
|
+
* @returns Observable that emits the selected ApiVersion
|
|
2461
|
+
* @throws VersionDiscoveryError subclasses for specific failure scenarios
|
|
2462
|
+
*/
|
|
2463
|
+
discoverVersion(hostname: string): Observable<ApiVersion>;
|
|
2464
|
+
/**
|
|
2465
|
+
* Clears the version cache for a specific hostname or all hostnames.
|
|
2466
|
+
*
|
|
2467
|
+
* @param hostname - Optional hostname to clear. If omitted, clears all cached versions.
|
|
2468
|
+
*/
|
|
2469
|
+
clearCache(hostname?: string): void;
|
|
2470
|
+
/**
|
|
2471
|
+
* Performs the `fetch` with a 5-second `AbortController` timeout and inspects the
|
|
2472
|
+
* *resolved* Response (fetch does not reject on non-2xx). Throws
|
|
2473
|
+
* `VersionEndpointNotFoundError` on 404 and `InvalidVersionResponseError` on any
|
|
2474
|
+
* other non-2xx or a body that is not an array of strings; lets `TypeError`
|
|
2475
|
+
* (network) and `AbortError` (timeout) bubble to `classify`.
|
|
2476
|
+
*
|
|
2477
|
+
* The element-type check matters: a reachable server returning an array of
|
|
2478
|
+
* non-strings (e.g. `[1, 2, 3]`) would otherwise reach `parseApiVersion`, whose
|
|
2479
|
+
* `.match()` throws a `TypeError` on a non-string — which `classify` would then
|
|
2480
|
+
* misfile as a network error. Validating here keeps it an `InvalidVersionResponseError`.
|
|
2481
|
+
*/
|
|
2482
|
+
private fetchVersions;
|
|
2483
|
+
/**
|
|
2484
|
+
* Parses, filters, and selects the latest compatible version from the raw response
|
|
2485
|
+
* array. Throws the appropriate typed error when no valid/compatible version exists.
|
|
2486
|
+
*/
|
|
2487
|
+
private selectVersion;
|
|
2488
|
+
/**
|
|
2489
|
+
* Maps a raw failure to a typed {@link VersionDiscoveryError}. Errors thrown by
|
|
2490
|
+
* `fetchVersions`/`selectVersion` are already typed and pass through unchanged; a
|
|
2491
|
+
* `fetch` `TypeError` becomes {@link VersionDiscoveryNetworkError} (the CORS/network
|
|
2492
|
+
* sentinel), an `AbortError` becomes {@link VersionDiscoveryTimeoutError}, and any
|
|
2493
|
+
* other failure (e.g. an unparseable body's `SyntaxError`) becomes
|
|
2494
|
+
* {@link InvalidVersionResponseError}.
|
|
2495
|
+
*/
|
|
2496
|
+
private classify;
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
/**
|
|
2500
|
+
* Base class for all version discovery errors
|
|
2501
|
+
*/
|
|
2502
|
+
declare abstract class VersionDiscoveryError extends Error {
|
|
2503
|
+
readonly hostname: string;
|
|
2504
|
+
constructor(message: string, hostname: string);
|
|
2505
|
+
}
|
|
2506
|
+
/**
|
|
2507
|
+
* Thrown when all available API versions are older than minimum supported version
|
|
2508
|
+
*/
|
|
2509
|
+
declare class VersionTooOldError extends VersionDiscoveryError {
|
|
2510
|
+
readonly availableVersions: string[];
|
|
2511
|
+
readonly minRequired: string;
|
|
2512
|
+
constructor(hostname: string, availableVersions: string[], minRequired?: string);
|
|
2513
|
+
}
|
|
2514
|
+
/**
|
|
2515
|
+
* Thrown when all available API versions are newer than maximum supported version
|
|
2516
|
+
*/
|
|
2517
|
+
declare class VersionTooNewError extends VersionDiscoveryError {
|
|
2518
|
+
readonly availableVersions: string[];
|
|
2519
|
+
readonly maxSupported: string;
|
|
2520
|
+
constructor(hostname: string, availableVersions: string[], maxSupported?: string);
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* Thrown when the /api/versions endpoint returns 404
|
|
2524
|
+
*/
|
|
2525
|
+
declare class VersionEndpointNotFoundError extends VersionDiscoveryError {
|
|
2526
|
+
readonly statusCode: number;
|
|
2527
|
+
constructor(hostname: string, statusCode?: number);
|
|
2528
|
+
}
|
|
2529
|
+
/**
|
|
2530
|
+
* Thrown when version discovery request times out
|
|
2531
|
+
*/
|
|
2532
|
+
declare class VersionDiscoveryTimeoutError extends VersionDiscoveryError {
|
|
2533
|
+
readonly timeoutMs: number;
|
|
2534
|
+
constructor(hostname: string, timeoutMs?: number);
|
|
2535
|
+
}
|
|
2536
|
+
/**
|
|
2537
|
+
* Thrown when version discovery fails due to network error
|
|
2538
|
+
*/
|
|
2539
|
+
declare class VersionDiscoveryNetworkError extends VersionDiscoveryError {
|
|
2540
|
+
readonly originalError: Error;
|
|
2541
|
+
constructor(hostname: string, originalError: Error);
|
|
2542
|
+
}
|
|
2543
|
+
/**
|
|
2544
|
+
* Thrown when no compatible versions are found in the response
|
|
2545
|
+
*/
|
|
2546
|
+
declare class NoCompatibleVersionsError extends VersionDiscoveryError {
|
|
2547
|
+
readonly availableVersions: string[];
|
|
2548
|
+
readonly supportedRange: {
|
|
2549
|
+
min: string;
|
|
2550
|
+
max: string;
|
|
2551
|
+
};
|
|
2552
|
+
constructor(hostname: string, availableVersions: string[], supportedRange?: {
|
|
2553
|
+
min: string;
|
|
2554
|
+
max: string;
|
|
2555
|
+
});
|
|
2556
|
+
}
|
|
2557
|
+
/**
|
|
2558
|
+
* Thrown when the API response is malformed or invalid
|
|
2559
|
+
*/
|
|
2560
|
+
declare class InvalidVersionResponseError extends VersionDiscoveryError {
|
|
2561
|
+
readonly reason: string;
|
|
2562
|
+
constructor(hostname: string, reason: string);
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
/**
|
|
2566
|
+
* Stable, framework-agnostic authentication error codes. The authenticator throws
|
|
2567
|
+
* `AuthError` with one of these codes; consumers translate the code to a localized
|
|
2568
|
+
* message (the `message` here is a plain-English default / fallback).
|
|
2569
|
+
*/
|
|
2570
|
+
declare enum AuthErrorCode {
|
|
2571
|
+
PasswordAuthFailed = "PASSWORD_AUTH_FAILED",
|
|
2572
|
+
OtpAuthFailed = "OTP_AUTH_FAILED",
|
|
2573
|
+
ApiKeyAuthFailed = "API_KEY_AUTH_FAILED",
|
|
2574
|
+
FullAdminRequired = "FULL_ADMIN_REQUIRED"
|
|
2575
|
+
}
|
|
2576
|
+
declare class AuthError extends Error {
|
|
2577
|
+
readonly code: AuthErrorCode;
|
|
2578
|
+
constructor(code: AuthErrorCode, message: string);
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
/**
|
|
2582
|
+
* API error types for versioned TrueNAS API
|
|
2583
|
+
*
|
|
2584
|
+
* Handles both JSON-RPC 2.0 standard errors and TrueNAS custom error formats.
|
|
2585
|
+
*/
|
|
2586
|
+
/**
|
|
2587
|
+
* JSON-RPC 2.0 standard error format
|
|
2588
|
+
* @see https://www.jsonrpc.org/specification#error_object
|
|
2589
|
+
*/
|
|
2590
|
+
interface JsonRpcError {
|
|
2591
|
+
/** Error code indicating the error type */
|
|
2592
|
+
code: number;
|
|
2593
|
+
/** Human-readable error message */
|
|
2594
|
+
message: string;
|
|
2595
|
+
/** Optional additional error data */
|
|
2596
|
+
data?: unknown;
|
|
2597
|
+
}
|
|
2598
|
+
/**
|
|
2599
|
+
* TrueNAS custom error format
|
|
2600
|
+
* Used in some API responses alongside JSON-RPC errors
|
|
2601
|
+
*/
|
|
2602
|
+
interface TrueNasError {
|
|
2603
|
+
/** Additional error properties */
|
|
2604
|
+
[key: string]: unknown;
|
|
2605
|
+
/** Human-readable error reason (TrueNAS-specific field) */
|
|
2606
|
+
reason: string;
|
|
2607
|
+
}
|
|
2608
|
+
/**
|
|
2609
|
+
* Union type for all possible API error formats
|
|
2610
|
+
*/
|
|
2611
|
+
type ApiError = JsonRpcError | TrueNasError;
|
|
2612
|
+
/**
|
|
2613
|
+
* Extract a human-readable error message from an API error
|
|
2614
|
+
*
|
|
2615
|
+
* Handles multiple error formats:
|
|
2616
|
+
* - JSON-RPC 2.0 with nested TrueNAS data: uses `data.reason` field
|
|
2617
|
+
* - JSON-RPC 2.0 standard: uses `message` field
|
|
2618
|
+
* - TrueNAS custom: uses `reason` field
|
|
2619
|
+
* - Unknown format: returns fallback message
|
|
2620
|
+
*
|
|
2621
|
+
* @param error - The error object from API response
|
|
2622
|
+
* @param fallback - Fallback message if error format is unrecognized
|
|
2623
|
+
* @returns Human-readable error message
|
|
2624
|
+
*/
|
|
2625
|
+
declare function getApiErrorMessage(error: unknown, fallback?: string): string;
|
|
2626
|
+
|
|
2627
|
+
export { type ApiCallDirectory, type ApiCallMethod, type ApiCallParams, type ApiCallResponse, type ApiError, type ApiKeyCreate, type ApiVersion, type ApiVersionResponse, AuthError, AuthErrorCode, type AuthResponse, type Container, type CreateClientOptions, InvalidVersionResponseError, type Job, JobState, type Logger, NoCompatibleVersionsError, type OperationMappings, TrueNasApiClient, TrueNasApiClientV2510, TrueNasApiClientV26, TrueNasAuthMechanism, TrueNasEndpoint, VersionCompatibility, VersionDiscovery, VersionDiscoveryError, VersionDiscoveryNetworkError, VersionDiscoveryTimeoutError, VersionEndpointNotFoundError, VersionTooNewError, VersionTooOldError, consoleLogger, createTrueNasClient, getApiErrorMessage, noopLogger };
|