1// Generated from definition io.k8s.api.resource.v1beta2.AllocatedDeviceStatus
23/// AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct AllocatedDeviceStatus {
6/// 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.
7 ///
8 /// Must not contain more than 8 entries.
9pub conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>>,
1011/// Data contains arbitrary driver-specific data.
12 ///
13 /// The length of the raw data must be smaller or equal to 10 Ki.
14pub data: Option<crate::apimachinery::pkg::runtime::RawExtension>,
1516/// Device references one device instance via its name in the driver's resource pool. It must be a DNS label.
17pub device: std::string::String,
1819/// 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.
20 ///
21 /// Must be a DNS subdomain and should end with a DNS domain owned by the vendor of the driver.
22pub driver: std::string::String,
2324/// NetworkData contains network-related information specific to the device.
25pub network_data: Option<crate::api::resource::v1beta2::NetworkDeviceData>,
2627/// This name together with the driver name and the device name field identify which device was allocated (`\<driver name\>/\<pool name\>/\<device name\>`).
28 ///
29 /// Must not be longer than 253 characters and may contain one or more DNS sub-domains separated by slashes.
30pub pool: std::string::String,
31}
3233impl crate::DeepMerge for AllocatedDeviceStatus {
34fn merge_from(&mut self, other: Self) {
35crate::merge_strategies::list::map(
36&mut self.conditions,
37 other.conditions,
38&[|lhs, rhs| lhs.type_ == rhs.type_],
39 |current_item, other_item| {
40crate::DeepMerge::merge_from(current_item, other_item);
41 },
42 );
43crate::DeepMerge::merge_from(&mut self.data, other.data);
44crate::DeepMerge::merge_from(&mut self.device, other.device);
45crate::DeepMerge::merge_from(&mut self.driver, other.driver);
46crate::DeepMerge::merge_from(&mut self.network_data, other.network_data);
47crate::DeepMerge::merge_from(&mut self.pool, other.pool);
48 }
49}
5051impl<'de> crate::serde::Deserialize<'de> for AllocatedDeviceStatus {
52fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
53#[allow(non_camel_case_types)]
54enum Field {
55 Key_conditions,
56 Key_data,
57 Key_device,
58 Key_driver,
59 Key_network_data,
60 Key_pool,
61 Other,
62 }
6364impl<'de> crate::serde::Deserialize<'de> for Field {
65fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
66struct Visitor;
6768impl crate::serde::de::Visitor<'_> for Visitor {
69type Value = Field;
7071fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
72 f.write_str("field identifier")
73 }
7475fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
76Ok(match v {
77"conditions" => Field::Key_conditions,
78"data" => Field::Key_data,
79"device" => Field::Key_device,
80"driver" => Field::Key_driver,
81"networkData" => Field::Key_network_data,
82"pool" => Field::Key_pool,
83_ => Field::Other,
84 })
85 }
86 }
8788 deserializer.deserialize_identifier(Visitor)
89 }
90 }
9192struct Visitor;
9394impl<'de> crate::serde::de::Visitor<'de> for Visitor {
95type Value = AllocatedDeviceStatus;
9697fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
98 f.write_str("AllocatedDeviceStatus")
99 }
100101fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
102let mut value_conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>> = None;
103let mut value_data: Option<crate::apimachinery::pkg::runtime::RawExtension> = None;
104let mut value_device: Option<std::string::String> = None;
105let mut value_driver: Option<std::string::String> = None;
106let mut value_network_data: Option<crate::api::resource::v1beta2::NetworkDeviceData> = None;
107let mut value_pool: Option<std::string::String> = None;
108109while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
110match key {
111 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
112 Field::Key_data => value_data = crate::serde::de::MapAccess::next_value(&mut map)?,
113 Field::Key_device => value_device = crate::serde::de::MapAccess::next_value(&mut map)?,
114 Field::Key_driver => value_driver = crate::serde::de::MapAccess::next_value(&mut map)?,
115 Field::Key_network_data => value_network_data = crate::serde::de::MapAccess::next_value(&mut map)?,
116 Field::Key_pool => value_pool = crate::serde::de::MapAccess::next_value(&mut map)?,
117 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
118 }
119 }
120121Ok(AllocatedDeviceStatus {
122 conditions: value_conditions,
123 data: value_data,
124 device: value_device.unwrap_or_default(),
125 driver: value_driver.unwrap_or_default(),
126 network_data: value_network_data,
127 pool: value_pool.unwrap_or_default(),
128 })
129 }
130 }
131132 deserializer.deserialize_struct(
133"AllocatedDeviceStatus",
134&[
135"conditions",
136"data",
137"device",
138"driver",
139"networkData",
140"pool",
141 ],
142 Visitor,
143 )
144 }
145}
146147impl crate::serde::Serialize for AllocatedDeviceStatus {
148fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
149let mut state = serializer.serialize_struct(
150"AllocatedDeviceStatus",
1513 +
152self.conditions.as_ref().map_or(0, |_| 1) +
153self.data.as_ref().map_or(0, |_| 1) +
154self.network_data.as_ref().map_or(0, |_| 1),
155 )?;
156if let Some(value) = &self.conditions {
157crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
158 }
159if let Some(value) = &self.data {
160crate::serde::ser::SerializeStruct::serialize_field(&mut state, "data", value)?;
161 }
162crate::serde::ser::SerializeStruct::serialize_field(&mut state, "device", &self.device)?;
163crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driver", &self.driver)?;
164if let Some(value) = &self.network_data {
165crate::serde::ser::SerializeStruct::serialize_field(&mut state, "networkData", value)?;
166 }
167crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pool", &self.pool)?;
168crate::serde::ser::SerializeStruct::end(state)
169 }
170}
171172#[cfg(feature = "schemars")]
173impl crate::schemars::JsonSchema for AllocatedDeviceStatus {
174fn schema_name() -> std::string::String {
175"io.k8s.api.resource.v1beta2.AllocatedDeviceStatus".into()
176 }
177178fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
179crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
180 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
181 description: Some("AllocatedDeviceStatus contains the status of an allocated device, if the driver chooses to report it. This may include driver-specific information.".into()),
182 ..Default::default()
183 })),
184 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
185 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
186 properties: [
187 (
188"conditions".into(),
189crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
190 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
191 description: Some("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.".into()),
192 ..Default::default()
193 })),
194 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
195 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
196 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()))),
197 ..Default::default()
198 })),
199 ..Default::default()
200 }),
201 ),
202 (
203"data".into(),
204 {
205let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::runtime::RawExtension>().into_object();
206 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
207 description: Some("Data contains arbitrary driver-specific data.\n\nThe length of the raw data must be smaller or equal to 10 Ki.".into()),
208 ..Default::default()
209 }));
210crate::schemars::schema::Schema::Object(schema_obj)
211 },
212 ),
213 (
214"device".into(),
215crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
216 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
217 description: Some("Device references one device instance via its name in the driver's resource pool. It must be a DNS label.".into()),
218 ..Default::default()
219 })),
220 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
221 ..Default::default()
222 }),
223 ),
224 (
225"driver".into(),
226crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
227 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
228 description: Some("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.".into()),
229 ..Default::default()
230 })),
231 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
232 ..Default::default()
233 }),
234 ),
235 (
236"networkData".into(),
237 {
238let mut schema_obj = __gen.subschema_for::<crate::api::resource::v1beta2::NetworkDeviceData>().into_object();
239 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
240 description: Some("NetworkData contains network-related information specific to the device.".into()),
241 ..Default::default()
242 }));
243crate::schemars::schema::Schema::Object(schema_obj)
244 },
245 ),
246 (
247"pool".into(),
248crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
249 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
250 description: Some("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.".into()),
251 ..Default::default()
252 })),
253 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
254 ..Default::default()
255 }),
256 ),
257 ].into(),
258 required: [
259"device".into(),
260"driver".into(),
261"pool".into(),
262 ].into(),
263 ..Default::default()
264 })),
265 ..Default::default()
266 })
267 }
268}