rufish 0.3.0

An asynchronous Redfish client library for BMC/server management in Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
use serde::{Deserialize, Serialize};
use serde_json::Value;

/// Common Redfish resource status.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "PascalCase")]
pub struct Status {
    pub state: Option<String>,
    pub health: Option<String>,
    pub health_rollup: Option<String>,
}

/// Service Root (/redfish/v1/)
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct ServiceRoot {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub redfish_version: Option<String>,
    pub systems: Option<OdataLink>,
    pub chassis: Option<OdataLink>,
    pub managers: Option<OdataLink>,
    pub session_service: Option<OdataLink>,
    pub account_service: Option<OdataLink>,
    pub update_service: Option<OdataLink>,
    pub event_service: Option<OdataLink>,
}

/// OData link reference.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OdataLink {
    #[serde(rename = "@odata.id")]
    pub odata_id: String,
}

/// Collection of resources.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Collection {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub name: Option<String>,
    #[serde(rename = "Members@odata.count")]
    pub members_count: Option<u32>,
    #[serde(rename = "Members")]
    pub members: Option<Vec<OdataLink>>,
}

/// Computer System resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct ComputerSystem {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub manufacturer: Option<String>,
    pub model: Option<String>,
    pub serial_number: Option<String>,
    pub uuid: Option<String>,
    pub host_name: Option<String>,
    pub power_state: Option<String>,
    pub bios_version: Option<String>,
    pub status: Option<Status>,
    pub boot: Option<Boot>,
    pub processor_summary: Option<ProcessorSummary>,
    pub memory_summary: Option<MemorySummary>,
    pub processors: Option<OdataLink>,
    pub memory: Option<OdataLink>,
    pub storage: Option<OdataLink>,
    pub ethernet_interfaces: Option<OdataLink>,
    pub network_interfaces: Option<OdataLink>,
    pub bios: Option<OdataLink>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Boot {
    pub boot_source_override_target: Option<String>,
    pub boot_source_override_enabled: Option<String>,
    pub boot_source_override_mode: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct ProcessorSummary {
    pub count: Option<u32>,
    pub model: Option<String>,
    pub status: Option<Status>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct MemorySummary {
    pub total_system_memory_gi_b: Option<f64>,
    pub status: Option<Status>,
}

/// Chassis resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Chassis {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub chassis_type: Option<String>,
    pub manufacturer: Option<String>,
    pub model: Option<String>,
    pub serial_number: Option<String>,
    pub part_number: Option<String>,
    pub power_state: Option<String>,
    pub status: Option<Status>,
    pub thermal: Option<OdataLink>,
    pub power: Option<OdataLink>,
}

/// Manager (BMC) resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Manager {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub manager_type: Option<String>,
    pub firmware_version: Option<String>,
    pub status: Option<Status>,
    pub ethernet_interfaces: Option<OdataLink>,
    pub network_protocol: Option<OdataLink>,
    pub log_services: Option<OdataLink>,
}

/// Power resource (legacy schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Power {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub power_control: Option<Vec<PowerControl>>,
    pub power_supplies: Option<Vec<PowerSupply>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct PowerControl {
    pub name: Option<String>,
    pub power_consumed_watts: Option<f64>,
    pub power_capacity_watts: Option<f64>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct PowerSupply {
    pub name: Option<String>,
    pub power_capacity_watts: Option<f64>,
    pub model: Option<String>,
    pub serial_number: Option<String>,
    pub status: Option<Status>,
}

/// Thermal resource (legacy schema).
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Thermal {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub temperatures: Option<Vec<Temperature>>,
    pub fans: Option<Vec<Fan>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Temperature {
    pub name: Option<String>,
    pub reading_celsius: Option<f64>,
    pub upper_threshold_critical: Option<f64>,
    pub upper_threshold_fatal: Option<f64>,
    pub status: Option<Status>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Fan {
    pub name: Option<String>,
    pub reading: Option<f64>,
    pub reading_units: Option<String>,
    pub status: Option<Status>,
}

/// Processor resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Processor {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub manufacturer: Option<String>,
    pub model: Option<String>,
    pub total_cores: Option<u32>,
    pub total_threads: Option<u32>,
    pub max_speed_m_hz: Option<u32>,
    pub status: Option<Status>,
}

/// Memory resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Memory {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub memory_device_type: Option<String>,
    pub capacity_mi_b: Option<u64>,
    pub operating_speed_mhz: Option<u32>,
    pub manufacturer: Option<String>,
    pub serial_number: Option<String>,
    pub status: Option<Status>,
}

/// Storage resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Storage {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub drives: Option<Vec<OdataLink>>,
    pub storage_controllers: Option<Vec<StorageController>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct StorageController {
    pub member_id: Option<String>,
    pub name: Option<String>,
    pub manufacturer: Option<String>,
    pub model: Option<String>,
    pub firmware_version: Option<String>,
    pub status: Option<Status>,
}

/// Drive resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Drive {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub manufacturer: Option<String>,
    pub model: Option<String>,
    pub serial_number: Option<String>,
    pub capacity_bytes: Option<u64>,
    pub media_type: Option<String>,
    pub protocol: Option<String>,
    pub status: Option<Status>,
}

/// EthernetInterface resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct EthernetInterface {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    #[serde(rename = "MACAddress")]
    pub mac_address: Option<String>,
    pub speed_mbps: Option<u32>,
    pub status: Option<Status>,
    #[serde(rename = "IPv4Addresses")]
    pub ipv4_addresses: Option<Vec<Value>>,
    #[serde(rename = "IPv6Addresses")]
    pub ipv6_addresses: Option<Vec<Value>>,
}

/// Account Service resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct AccountService {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub accounts: Option<OdataLink>,
    pub roles: Option<OdataLink>,
}

/// User Account resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Account {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub user_name: Option<String>,
    pub role_id: Option<String>,
    pub enabled: Option<bool>,
    pub locked: Option<bool>,
}

/// Update Service resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct UpdateService {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub firmware_inventory: Option<OdataLink>,
    pub software_inventory: Option<OdataLink>,
    pub service_enabled: Option<bool>,
}

/// Event Service resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct EventService {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub service_enabled: Option<bool>,
    pub subscriptions: Option<OdataLink>,
}

/// Log Entry resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct LogEntry {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub created: Option<String>,
    pub entry_type: Option<String>,
    pub severity: Option<String>,
    pub message: Option<String>,
    pub message_id: Option<String>,
}

/// Task resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Task {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub task_state: Option<String>,
    pub start_time: Option<String>,
    pub end_time: Option<String>,
    pub task_status: Option<String>,
}

/// Session creation request body.
#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct SessionCreate {
    pub user_name: String,
    pub password: String,
}

/// Reset request body.
#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct ResetRequest {
    pub reset_type: String,
}

/// Boot override request body.
#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct BootOverride {
    pub boot: BootOverrideInner,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct BootOverrideInner {
    pub boot_source_override_target: String,
    pub boot_source_override_enabled: Option<String>,
}

/// Virtual Media resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct VirtualMedia {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub media_types: Option<Vec<String>>,
    pub image: Option<String>,
    pub image_name: Option<String>,
    pub inserted: Option<bool>,
    pub connected_via: Option<String>,
    pub write_protected: Option<bool>,
}

/// BIOS resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Bios {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub attributes: Option<serde_json::Value>,
}

/// Network Protocol resource (BMC network services).
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct NetworkProtocol {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub host_name: Option<String>,
    #[serde(rename = "FQDN")]
    pub fqdn: Option<String>,
    #[serde(rename = "HTTP")]
    pub http: Option<ProtocolEnabled>,
    #[serde(rename = "HTTPS")]
    pub https: Option<ProtocolEnabled>,
    #[serde(rename = "SSH")]
    pub ssh: Option<ProtocolEnabled>,
    #[serde(rename = "IPMI")]
    pub ipmi: Option<ProtocolEnabled>,
    #[serde(rename = "KVMIP")]
    pub kvmip: Option<ProtocolEnabled>,
    #[serde(rename = "NTP")]
    pub ntp: Option<NtpProtocol>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct ProtocolEnabled {
    pub protocol_enabled: Option<bool>,
    pub port: Option<u16>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct NtpProtocol {
    pub protocol_enabled: Option<bool>,
    #[serde(rename = "NTPServers")]
    pub ntp_servers: Option<Vec<String>>,
}

/// Secure Boot resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct SecureBoot {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub secure_boot_enable: Option<bool>,
    pub secure_boot_current_boot: Option<String>,
    pub secure_boot_mode: Option<String>,
}

/// Volume resource (RAID).
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Volume {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub capacity_bytes: Option<u64>,
    pub volume_type: Option<String>,
    #[serde(rename = "RAIDType")]
    pub raid_type: Option<String>,
    pub status: Option<Status>,
    pub drives: Option<Vec<OdataLink>>,
}

/// Certificate resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct Certificate {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub certificate_string: Option<String>,
    pub certificate_type: Option<String>,
    pub issuer: Option<serde_json::Value>,
    pub subject: Option<serde_json::Value>,
    pub valid_not_before: Option<String>,
    pub valid_not_after: Option<String>,
}

/// Event Destination (subscription).
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct EventDestination {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub destination: Option<String>,
    pub protocol: Option<String>,
    pub event_types: Option<Vec<String>>,
    pub context: Option<String>,
}

/// Serial Interface resource.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct SerialInterface {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub bit_rate: Option<String>,
    pub data_bits: Option<String>,
    pub parity: Option<String>,
    pub stop_bits: Option<String>,
    pub flow_control: Option<String>,
    pub interface_enabled: Option<bool>,
}

/// Software/Firmware Inventory item.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct SoftwareInventory {
    #[serde(rename = "@odata.id")]
    pub odata_id: Option<String>,
    pub id: Option<String>,
    pub name: Option<String>,
    pub version: Option<String>,
    pub updateable: Option<bool>,
    pub status: Option<Status>,
}