k8s_openapi/v1_34/api/resource/v1/
allocated_device_status.rs

1// Generated from definition io.k8s.api.resource.v1.AllocatedDeviceStatus
2
3/// AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information.
4///
5/// The combination of Driver, Pool, Device, and ShareID must match the corresponding key in Status.Allocation.Devices.
6#[derive(Clone, Debug, Default, PartialEq)]
7pub struct AllocatedDeviceStatus {
8    /// Conditions contains the latest observation of the device's state. If the device has been configured according to the class and claim config references, the `Ready` condition should be True.
9    ///
10    /// Must not contain more than 8 entries.
11    pub conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>>,
12
13    /// Data contains arbitrary driver-specific data.
14    ///
15    /// The length of the raw data must be smaller or equal to 10 Ki.
16    pub data: Option<crate::apimachinery::pkg::runtime::RawExtension>,
17
18    /// Device references one device instance via its name in the driver's resource pool. It must be a DNS label.
19    pub device: std::string::String,
20
21    /// Driver specifies the name of the DRA driver whose kubelet plugin should be invoked to process the allocation once the claim is needed on a node.
22    ///
23    /// Must be a DNS subdomain and should end with a DNS domain owned by the vendor of the driver.
24    pub driver: std::string::String,
25
26    /// NetworkData contains network-related information specific to the device.
27    pub network_data: Option<crate::api::resource::v1::NetworkDeviceData>,
28
29    /// This name together with the driver name and the device name field identify which device was allocated (`\<driver name\>/\<pool name\>/\<device name\>`).
30    ///
31    /// Must not be longer than 253 characters and may contain one or more DNS sub-domains separated by slashes.
32    pub pool: std::string::String,
33
34    /// ShareID uniquely identifies an individual allocation share of the device.
35    pub share_id: Option<std::string::String>,
36}
37
38impl crate::DeepMerge for AllocatedDeviceStatus {
39    fn merge_from(&mut self, other: Self) {
40        crate::merge_strategies::list::map(
41            &mut self.conditions,
42            other.conditions,
43            &[|lhs, rhs| lhs.type_ == rhs.type_],
44            |current_item, other_item| {
45                crate::DeepMerge::merge_from(current_item, other_item);
46            },
47        );
48        crate::DeepMerge::merge_from(&mut self.data, other.data);
49        crate::DeepMerge::merge_from(&mut self.device, other.device);
50        crate::DeepMerge::merge_from(&mut self.driver, other.driver);
51        crate::DeepMerge::merge_from(&mut self.network_data, other.network_data);
52        crate::DeepMerge::merge_from(&mut self.pool, other.pool);
53        crate::DeepMerge::merge_from(&mut self.share_id, other.share_id);
54    }
55}
56
57impl<'de> crate::serde::Deserialize<'de> for AllocatedDeviceStatus {
58    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
59        #[allow(non_camel_case_types)]
60        enum Field {
61            Key_conditions,
62            Key_data,
63            Key_device,
64            Key_driver,
65            Key_network_data,
66            Key_pool,
67            Key_share_id,
68            Other,
69        }
70
71        impl<'de> crate::serde::Deserialize<'de> for Field {
72            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
73                struct Visitor;
74
75                impl crate::serde::de::Visitor<'_> for Visitor {
76                    type Value = Field;
77
78                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
79                        f.write_str("field identifier")
80                    }
81
82                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
83                        Ok(match v {
84                            "conditions" => Field::Key_conditions,
85                            "data" => Field::Key_data,
86                            "device" => Field::Key_device,
87                            "driver" => Field::Key_driver,
88                            "networkData" => Field::Key_network_data,
89                            "pool" => Field::Key_pool,
90                            "shareID" => Field::Key_share_id,
91                            _ => Field::Other,
92                        })
93                    }
94                }
95
96                deserializer.deserialize_identifier(Visitor)
97            }
98        }
99
100        struct Visitor;
101
102        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
103            type Value = AllocatedDeviceStatus;
104
105            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
106                f.write_str("AllocatedDeviceStatus")
107            }
108
109            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
110                let mut value_conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>> = None;
111                let mut value_data: Option<crate::apimachinery::pkg::runtime::RawExtension> = None;
112                let mut value_device: Option<std::string::String> = None;
113                let mut value_driver: Option<std::string::String> = None;
114                let mut value_network_data: Option<crate::api::resource::v1::NetworkDeviceData> = None;
115                let mut value_pool: Option<std::string::String> = None;
116                let mut value_share_id: Option<std::string::String> = None;
117
118                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
119                    match key {
120                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
121                        Field::Key_data => value_data = crate::serde::de::MapAccess::next_value(&mut map)?,
122                        Field::Key_device => value_device = crate::serde::de::MapAccess::next_value(&mut map)?,
123                        Field::Key_driver => value_driver = crate::serde::de::MapAccess::next_value(&mut map)?,
124                        Field::Key_network_data => value_network_data = crate::serde::de::MapAccess::next_value(&mut map)?,
125                        Field::Key_pool => value_pool = crate::serde::de::MapAccess::next_value(&mut map)?,
126                        Field::Key_share_id => value_share_id = crate::serde::de::MapAccess::next_value(&mut map)?,
127                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
128                    }
129                }
130
131                Ok(AllocatedDeviceStatus {
132                    conditions: value_conditions,
133                    data: value_data,
134                    device: value_device.unwrap_or_default(),
135                    driver: value_driver.unwrap_or_default(),
136                    network_data: value_network_data,
137                    pool: value_pool.unwrap_or_default(),
138                    share_id: value_share_id,
139                })
140            }
141        }
142
143        deserializer.deserialize_struct(
144            "AllocatedDeviceStatus",
145            &[
146                "conditions",
147                "data",
148                "device",
149                "driver",
150                "networkData",
151                "pool",
152                "shareID",
153            ],
154            Visitor,
155        )
156    }
157}
158
159impl crate::serde::Serialize for AllocatedDeviceStatus {
160    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
161        let mut state = serializer.serialize_struct(
162            "AllocatedDeviceStatus",
163            3 +
164            self.conditions.as_ref().map_or(0, |_| 1) +
165            self.data.as_ref().map_or(0, |_| 1) +
166            self.network_data.as_ref().map_or(0, |_| 1) +
167            self.share_id.as_ref().map_or(0, |_| 1),
168        )?;
169        if let Some(value) = &self.conditions {
170            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
171        }
172        if let Some(value) = &self.data {
173            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "data", value)?;
174        }
175        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "device", &self.device)?;
176        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driver", &self.driver)?;
177        if let Some(value) = &self.network_data {
178            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "networkData", value)?;
179        }
180        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pool", &self.pool)?;
181        if let Some(value) = &self.share_id {
182            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "shareID", value)?;
183        }
184        crate::serde::ser::SerializeStruct::end(state)
185    }
186}
187
188#[cfg(feature = "schemars")]
189impl crate::schemars::JsonSchema for AllocatedDeviceStatus {
190    fn schema_name() -> std::borrow::Cow<'static, str> {
191        "io.k8s.api.resource.v1.AllocatedDeviceStatus".into()
192    }
193
194    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
195        crate::schemars::json_schema!({
196            "description": "AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information.\n\nThe combination of Driver, Pool, Device, and ShareID must match the corresponding key in Status.Allocation.Devices.",
197            "type": "object",
198            "properties": {
199                "conditions": {
200                    "description": "Conditions contains the latest observation of the device's state. If the device has been configured according to the class and claim config references, the `Ready` condition should be True.\n\nMust not contain more than 8 entries.",
201                    "type": "array",
202                    "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()),
203                },
204                "data": ({
205                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::runtime::RawExtension>();
206                    schema_obj.ensure_object().insert("description".into(), "Data contains arbitrary driver-specific data.\n\nThe length of the raw data must be smaller or equal to 10 Ki.".into());
207                    schema_obj
208                }),
209                "device": {
210                    "description": "Device references one device instance via its name in the driver's resource pool. It must be a DNS label.",
211                    "type": "string",
212                },
213                "driver": {
214                    "description": "Driver specifies the name of the DRA driver whose kubelet plugin should be invoked to process the allocation once the claim is needed on a node.\n\nMust be a DNS subdomain and should end with a DNS domain owned by the vendor of the driver.",
215                    "type": "string",
216                },
217                "networkData": ({
218                    let mut schema_obj = __gen.subschema_for::<crate::api::resource::v1::NetworkDeviceData>();
219                    schema_obj.ensure_object().insert("description".into(), "NetworkData contains network-related information specific to the device.".into());
220                    schema_obj
221                }),
222                "pool": {
223                    "description": "This name together with the driver name and the device name field identify which device was allocated (`<driver name>/<pool name>/<device name>`).\n\nMust not be longer than 253 characters and may contain one or more DNS sub-domains separated by slashes.",
224                    "type": "string",
225                },
226                "shareID": {
227                    "description": "ShareID uniquely identifies an individual allocation share of the device.",
228                    "type": "string",
229                },
230            },
231            "required": [
232                "device",
233                "driver",
234                "pool",
235            ],
236        })
237    }
238}