k8s_openapi/v1_32/api/resource/v1beta1/
allocated_device_status.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct AllocatedDeviceStatus {
6 pub conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>>,
8
9 pub data: Option<crate::apimachinery::pkg::runtime::RawExtension>,
13
14 pub device: std::string::String,
16
17 pub driver: std::string::String,
21
22 pub network_data: Option<crate::api::resource::v1beta1::NetworkDeviceData>,
24
25 pub pool: std::string::String,
29}
30
31impl crate::DeepMerge for AllocatedDeviceStatus {
32 fn merge_from(&mut self, other: Self) {
33 crate::merge_strategies::list::map(
34 &mut self.conditions,
35 other.conditions,
36 &[|lhs, rhs| lhs.type_ == rhs.type_],
37 |current_item, other_item| {
38 crate::DeepMerge::merge_from(current_item, other_item);
39 },
40 );
41 crate::DeepMerge::merge_from(&mut self.data, other.data);
42 crate::DeepMerge::merge_from(&mut self.device, other.device);
43 crate::DeepMerge::merge_from(&mut self.driver, other.driver);
44 crate::DeepMerge::merge_from(&mut self.network_data, other.network_data);
45 crate::DeepMerge::merge_from(&mut self.pool, other.pool);
46 }
47}
48
49impl<'de> crate::serde::Deserialize<'de> for AllocatedDeviceStatus {
50 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
51 #[allow(non_camel_case_types)]
52 enum Field {
53 Key_conditions,
54 Key_data,
55 Key_device,
56 Key_driver,
57 Key_network_data,
58 Key_pool,
59 Other,
60 }
61
62 impl<'de> crate::serde::Deserialize<'de> for Field {
63 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
64 struct Visitor;
65
66 impl crate::serde::de::Visitor<'_> for Visitor {
67 type Value = Field;
68
69 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
70 f.write_str("field identifier")
71 }
72
73 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
74 Ok(match v {
75 "conditions" => Field::Key_conditions,
76 "data" => Field::Key_data,
77 "device" => Field::Key_device,
78 "driver" => Field::Key_driver,
79 "networkData" => Field::Key_network_data,
80 "pool" => Field::Key_pool,
81 _ => Field::Other,
82 })
83 }
84 }
85
86 deserializer.deserialize_identifier(Visitor)
87 }
88 }
89
90 struct Visitor;
91
92 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
93 type Value = AllocatedDeviceStatus;
94
95 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
96 f.write_str("AllocatedDeviceStatus")
97 }
98
99 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
100 let mut value_conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>> = None;
101 let mut value_data: Option<crate::apimachinery::pkg::runtime::RawExtension> = None;
102 let mut value_device: Option<std::string::String> = None;
103 let mut value_driver: Option<std::string::String> = None;
104 let mut value_network_data: Option<crate::api::resource::v1beta1::NetworkDeviceData> = None;
105 let mut value_pool: Option<std::string::String> = None;
106
107 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
108 match key {
109 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
110 Field::Key_data => value_data = crate::serde::de::MapAccess::next_value(&mut map)?,
111 Field::Key_device => value_device = crate::serde::de::MapAccess::next_value(&mut map)?,
112 Field::Key_driver => value_driver = crate::serde::de::MapAccess::next_value(&mut map)?,
113 Field::Key_network_data => value_network_data = crate::serde::de::MapAccess::next_value(&mut map)?,
114 Field::Key_pool => value_pool = crate::serde::de::MapAccess::next_value(&mut map)?,
115 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
116 }
117 }
118
119 Ok(AllocatedDeviceStatus {
120 conditions: value_conditions,
121 data: value_data,
122 device: value_device.unwrap_or_default(),
123 driver: value_driver.unwrap_or_default(),
124 network_data: value_network_data,
125 pool: value_pool.unwrap_or_default(),
126 })
127 }
128 }
129
130 deserializer.deserialize_struct(
131 "AllocatedDeviceStatus",
132 &[
133 "conditions",
134 "data",
135 "device",
136 "driver",
137 "networkData",
138 "pool",
139 ],
140 Visitor,
141 )
142 }
143}
144
145impl crate::serde::Serialize for AllocatedDeviceStatus {
146 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
147 let mut state = serializer.serialize_struct(
148 "AllocatedDeviceStatus",
149 3 +
150 self.conditions.as_ref().map_or(0, |_| 1) +
151 self.data.as_ref().map_or(0, |_| 1) +
152 self.network_data.as_ref().map_or(0, |_| 1),
153 )?;
154 if let Some(value) = &self.conditions {
155 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
156 }
157 if let Some(value) = &self.data {
158 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "data", value)?;
159 }
160 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "device", &self.device)?;
161 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driver", &self.driver)?;
162 if let Some(value) = &self.network_data {
163 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "networkData", value)?;
164 }
165 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pool", &self.pool)?;
166 crate::serde::ser::SerializeStruct::end(state)
167 }
168}
169
170#[cfg(feature = "schemars")]
171impl crate::schemars::JsonSchema for AllocatedDeviceStatus {
172 fn schema_name() -> std::borrow::Cow<'static, str> {
173 "io.k8s.api.resource.v1beta1.AllocatedDeviceStatus".into()
174 }
175
176 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
177 crate::schemars::json_schema!({
178 "description": "AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information.",
179 "type": "object",
180 "properties": {
181 "conditions": {
182 "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.",
183 "type": "array",
184 "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()),
185 },
186 "data": ({
187 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::runtime::RawExtension>();
188 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());
189 schema_obj
190 }),
191 "device": {
192 "description": "Device references one device instance via its name in the driver's resource pool. It must be a DNS label.",
193 "type": "string",
194 },
195 "driver": {
196 "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.",
197 "type": "string",
198 },
199 "networkData": ({
200 let mut schema_obj = __gen.subschema_for::<crate::api::resource::v1beta1::NetworkDeviceData>();
201 schema_obj.ensure_object().insert("description".into(), "NetworkData contains network-related information specific to the device.".into());
202 schema_obj
203 }),
204 "pool": {
205 "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.",
206 "type": "string",
207 },
208 },
209 "required": [
210 "device",
211 "driver",
212 "pool",
213 ],
214 })
215 }
216}