redfish/types/
bios.rs

1use serde::{Deserialize, Serialize};
2use serde_json::{Map, Value};
3
4use super::{Resource, ResourceStatus};
5
6/// ComputerSystem BIOS resource.
7///
8/// Typical path: `GET /redfish/v1/Systems/{id}/Bios`
9#[derive(Debug, Clone, Deserialize)]
10pub struct Bios {
11    #[serde(flatten)]
12    pub resource: Resource,
13
14    /// BIOS settings/attributes exposed by the implementation.
15    #[serde(rename = "Attributes", default)]
16    pub attributes: Map<String, Value>,
17
18    #[serde(rename = "Status", default)]
19    pub status: Option<ResourceStatus>,
20}
21
22/// BIOS settings resource (pending/desired settings).
23///
24/// Typical path: `GET /redfish/v1/Systems/{id}/Bios/Settings`
25#[derive(Debug, Clone, Deserialize)]
26pub struct BiosSettings {
27    #[serde(flatten)]
28    pub resource: Resource,
29
30    #[serde(rename = "Attributes", default)]
31    pub attributes: Map<String, Value>,
32
33    #[serde(rename = "Status", default)]
34    pub status: Option<ResourceStatus>,
35}
36
37/// Patch payload for BIOS settings.
38///
39/// Typical operation: `PATCH /redfish/v1/Systems/{id}/Bios/Settings`
40#[derive(Debug, Clone, Serialize, Default)]
41pub struct BiosSettingsUpdateRequest {
42    #[serde(rename = "Attributes", default)]
43    pub attributes: Map<String, Value>,
44
45    /// Optional vendor extensions.
46    #[serde(flatten, skip_serializing_if = "Map::is_empty")]
47    pub extra: Map<String, Value>,
48}
49
50impl BiosSettingsUpdateRequest {
51    /// Create an empty update request.
52    pub fn new() -> Self {
53        Self::default()
54    }
55
56    /// Add/override a BIOS attribute.
57    pub fn with_attribute(mut self, key: impl Into<String>, value: impl Into<Value>) -> Self {
58        self.attributes.insert(key.into(), value.into());
59        self
60    }
61
62    /// Add an OEM/vendor-specific key/value to the top-level payload.
63    pub fn with_extra(mut self, key: impl Into<String>, value: impl Into<Value>) -> Self {
64        self.extra.insert(key.into(), value.into());
65        self
66    }
67}