Skip to main content

k8s_openapi/v1_36/api/resource/v1beta2/
device_attribute.rs

1// Generated from definition io.k8s.api.resource.v1beta2.DeviceAttribute
2
3/// DeviceAttribute must have exactly one field set.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeviceAttribute {
6    /// BoolValue is a true/false value.
7    pub bool: Option<bool>,
8
9    /// BoolValues is a non-empty list of true/false values.
10    pub bools: Option<std::vec::Vec<bool>>,
11
12    /// IntValue is a number.
13    pub int: Option<i64>,
14
15    /// IntValues is a non-empty list of numbers.
16    ///
17    /// This is an alpha field and requires enabling the DRAListTypeAttributes feature gate.
18    pub ints: Option<std::vec::Vec<i64>>,
19
20    /// StringValue is a string. Must not be longer than 64 characters.
21    pub string: Option<std::string::String>,
22
23    /// StringValues is a non-empty list of strings. Each string must not be longer than 64 characters.
24    ///
25    /// This is an alpha field and requires enabling the DRAListTypeAttributes feature gate.
26    pub strings: Option<std::vec::Vec<std::string::String>>,
27
28    /// VersionValue is a semantic version according to semver.org spec 2.0.0. Must not be longer than 64 characters.
29    pub version: Option<std::string::String>,
30
31    /// VersionValues is a non-empty list of semantic versions according to semver.org spec 2.0.0. Each version string must not be longer than 64 characters.
32    ///
33    /// This is an alpha field and requires enabling the DRAListTypeAttributes feature gate.
34    pub versions: Option<std::vec::Vec<std::string::String>>,
35}
36
37impl crate::DeepMerge for DeviceAttribute {
38    fn merge_from(&mut self, other: Self) {
39        crate::DeepMerge::merge_from(&mut self.bool, other.bool);
40        crate::merge_strategies::list::atomic(&mut self.bools, other.bools);
41        crate::DeepMerge::merge_from(&mut self.int, other.int);
42        crate::merge_strategies::list::atomic(&mut self.ints, other.ints);
43        crate::DeepMerge::merge_from(&mut self.string, other.string);
44        crate::merge_strategies::list::atomic(&mut self.strings, other.strings);
45        crate::DeepMerge::merge_from(&mut self.version, other.version);
46        crate::merge_strategies::list::atomic(&mut self.versions, other.versions);
47    }
48}
49
50impl<'de> crate::serde::Deserialize<'de> for DeviceAttribute {
51    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
52        #[allow(non_camel_case_types)]
53        enum Field {
54            Key_bool,
55            Key_bools,
56            Key_int,
57            Key_ints,
58            Key_string,
59            Key_strings,
60            Key_version,
61            Key_versions,
62            Other,
63        }
64
65        impl<'de> crate::serde::Deserialize<'de> for Field {
66            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
67                struct Visitor;
68
69                impl crate::serde::de::Visitor<'_> for Visitor {
70                    type Value = Field;
71
72                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
73                        f.write_str("field identifier")
74                    }
75
76                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
77                        Ok(match v {
78                            "bool" => Field::Key_bool,
79                            "bools" => Field::Key_bools,
80                            "int" => Field::Key_int,
81                            "ints" => Field::Key_ints,
82                            "string" => Field::Key_string,
83                            "strings" => Field::Key_strings,
84                            "version" => Field::Key_version,
85                            "versions" => Field::Key_versions,
86                            _ => Field::Other,
87                        })
88                    }
89                }
90
91                deserializer.deserialize_identifier(Visitor)
92            }
93        }
94
95        struct Visitor;
96
97        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
98            type Value = DeviceAttribute;
99
100            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
101                f.write_str("DeviceAttribute")
102            }
103
104            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
105                let mut value_bool: Option<bool> = None;
106                let mut value_bools: Option<std::vec::Vec<bool>> = None;
107                let mut value_int: Option<i64> = None;
108                let mut value_ints: Option<std::vec::Vec<i64>> = None;
109                let mut value_string: Option<std::string::String> = None;
110                let mut value_strings: Option<std::vec::Vec<std::string::String>> = None;
111                let mut value_version: Option<std::string::String> = None;
112                let mut value_versions: Option<std::vec::Vec<std::string::String>> = None;
113
114                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
115                    match key {
116                        Field::Key_bool => value_bool = crate::serde::de::MapAccess::next_value(&mut map)?,
117                        Field::Key_bools => value_bools = crate::serde::de::MapAccess::next_value(&mut map)?,
118                        Field::Key_int => value_int = crate::serde::de::MapAccess::next_value(&mut map)?,
119                        Field::Key_ints => value_ints = crate::serde::de::MapAccess::next_value(&mut map)?,
120                        Field::Key_string => value_string = crate::serde::de::MapAccess::next_value(&mut map)?,
121                        Field::Key_strings => value_strings = crate::serde::de::MapAccess::next_value(&mut map)?,
122                        Field::Key_version => value_version = crate::serde::de::MapAccess::next_value(&mut map)?,
123                        Field::Key_versions => value_versions = crate::serde::de::MapAccess::next_value(&mut map)?,
124                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
125                    }
126                }
127
128                Ok(DeviceAttribute {
129                    bool: value_bool,
130                    bools: value_bools,
131                    int: value_int,
132                    ints: value_ints,
133                    string: value_string,
134                    strings: value_strings,
135                    version: value_version,
136                    versions: value_versions,
137                })
138            }
139        }
140
141        deserializer.deserialize_struct(
142            "DeviceAttribute",
143            &[
144                "bool",
145                "bools",
146                "int",
147                "ints",
148                "string",
149                "strings",
150                "version",
151                "versions",
152            ],
153            Visitor,
154        )
155    }
156}
157
158impl crate::serde::Serialize for DeviceAttribute {
159    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
160        let mut state = serializer.serialize_struct(
161            "DeviceAttribute",
162            self.bool.as_ref().map_or(0, |_| 1) +
163            self.bools.as_ref().map_or(0, |_| 1) +
164            self.int.as_ref().map_or(0, |_| 1) +
165            self.ints.as_ref().map_or(0, |_| 1) +
166            self.string.as_ref().map_or(0, |_| 1) +
167            self.strings.as_ref().map_or(0, |_| 1) +
168            self.version.as_ref().map_or(0, |_| 1) +
169            self.versions.as_ref().map_or(0, |_| 1),
170        )?;
171        if let Some(value) = &self.bool {
172            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "bool", value)?;
173        }
174        if let Some(value) = &self.bools {
175            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "bools", value)?;
176        }
177        if let Some(value) = &self.int {
178            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "int", value)?;
179        }
180        if let Some(value) = &self.ints {
181            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ints", value)?;
182        }
183        if let Some(value) = &self.string {
184            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "string", value)?;
185        }
186        if let Some(value) = &self.strings {
187            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "strings", value)?;
188        }
189        if let Some(value) = &self.version {
190            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "version", value)?;
191        }
192        if let Some(value) = &self.versions {
193            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "versions", value)?;
194        }
195        crate::serde::ser::SerializeStruct::end(state)
196    }
197}
198
199#[cfg(feature = "schemars")]
200impl crate::schemars::JsonSchema for DeviceAttribute {
201    fn schema_name() -> std::borrow::Cow<'static, str> {
202        "io.k8s.api.resource.v1beta2.DeviceAttribute".into()
203    }
204
205    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
206        crate::schemars::json_schema!({
207            "description": "DeviceAttribute must have exactly one field set.",
208            "type": "object",
209            "properties": {
210                "bool": {
211                    "description": "BoolValue is a true/false value.",
212                    "type": "boolean",
213                },
214                "bools": {
215                    "description": "BoolValues is a non-empty list of true/false values.",
216                    "type": "array",
217                    "items": {
218                        "type": "boolean",
219                    },
220                },
221                "int": {
222                    "description": "IntValue is a number.",
223                    "type": "integer",
224                    "format": "int64",
225                },
226                "ints": {
227                    "description": "IntValues is a non-empty list of numbers.\n\nThis is an alpha field and requires enabling the DRAListTypeAttributes feature gate.",
228                    "type": "array",
229                    "items": {
230                        "type": "integer",
231                        "format": "int64",
232                    },
233                },
234                "string": {
235                    "description": "StringValue is a string. Must not be longer than 64 characters.",
236                    "type": "string",
237                },
238                "strings": {
239                    "description": "StringValues is a non-empty list of strings. Each string must not be longer than 64 characters.\n\nThis is an alpha field and requires enabling the DRAListTypeAttributes feature gate.",
240                    "type": "array",
241                    "items": {
242                        "type": "string",
243                    },
244                },
245                "version": {
246                    "description": "VersionValue is a semantic version according to semver.org spec 2.0.0. Must not be longer than 64 characters.",
247                    "type": "string",
248                },
249                "versions": {
250                    "description": "VersionValues is a non-empty list of semantic versions according to semver.org spec 2.0.0. Each version string must not be longer than 64 characters.\n\nThis is an alpha field and requires enabling the DRAListTypeAttributes feature gate.",
251                    "type": "array",
252                    "items": {
253                        "type": "string",
254                    },
255                },
256            },
257        })
258    }
259}
260
261#[cfg(feature = "schemars08")]
262impl crate::schemars08::JsonSchema for DeviceAttribute {
263    fn schema_name() -> std::string::String {
264        "io.k8s.api.resource.v1beta2.DeviceAttribute".into()
265    }
266
267    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
268        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
269            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
270                description: Some("DeviceAttribute must have exactly one field set.".into()),
271                ..Default::default()
272            })),
273            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
274            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
275                properties: [
276                    (
277                        "bool".into(),
278                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
279                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
280                                description: Some("BoolValue is a true/false value.".into()),
281                                ..Default::default()
282                            })),
283                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Boolean))),
284                            ..Default::default()
285                        }),
286                    ),
287                    (
288                        "bools".into(),
289                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
290                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
291                                description: Some("BoolValues is a non-empty list of true/false values.".into()),
292                                ..Default::default()
293                            })),
294                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
295                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
296                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
297                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
298                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Boolean))),
299                                        ..Default::default()
300                                    })
301                                ))),
302                                ..Default::default()
303                            })),
304                            ..Default::default()
305                        }),
306                    ),
307                    (
308                        "int".into(),
309                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
310                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
311                                description: Some("IntValue is a number.".into()),
312                                ..Default::default()
313                            })),
314                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
315                            format: Some("int64".into()),
316                            ..Default::default()
317                        }),
318                    ),
319                    (
320                        "ints".into(),
321                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
322                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
323                                description: Some("IntValues is a non-empty list of numbers.\n\nThis is an alpha field and requires enabling the DRAListTypeAttributes feature gate.".into()),
324                                ..Default::default()
325                            })),
326                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
327                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
328                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
329                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
330                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
331                                        format: Some("int64".into()),
332                                        ..Default::default()
333                                    })
334                                ))),
335                                ..Default::default()
336                            })),
337                            ..Default::default()
338                        }),
339                    ),
340                    (
341                        "string".into(),
342                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
343                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
344                                description: Some("StringValue is a string. Must not be longer than 64 characters.".into()),
345                                ..Default::default()
346                            })),
347                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
348                            ..Default::default()
349                        }),
350                    ),
351                    (
352                        "strings".into(),
353                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
354                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
355                                description: Some("StringValues is a non-empty list of strings. Each string must not be longer than 64 characters.\n\nThis is an alpha field and requires enabling the DRAListTypeAttributes feature gate.".into()),
356                                ..Default::default()
357                            })),
358                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
359                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
360                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
361                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
362                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
363                                        ..Default::default()
364                                    })
365                                ))),
366                                ..Default::default()
367                            })),
368                            ..Default::default()
369                        }),
370                    ),
371                    (
372                        "version".into(),
373                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
374                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
375                                description: Some("VersionValue is a semantic version according to semver.org spec 2.0.0. Must not be longer than 64 characters.".into()),
376                                ..Default::default()
377                            })),
378                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
379                            ..Default::default()
380                        }),
381                    ),
382                    (
383                        "versions".into(),
384                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
385                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
386                                description: Some("VersionValues is a non-empty list of semantic versions according to semver.org spec 2.0.0. Each version string must not be longer than 64 characters.\n\nThis is an alpha field and requires enabling the DRAListTypeAttributes feature gate.".into()),
387                                ..Default::default()
388                            })),
389                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
390                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
391                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
392                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
393                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
394                                        ..Default::default()
395                                    })
396                                ))),
397                                ..Default::default()
398                            })),
399                            ..Default::default()
400                        }),
401                    ),
402                ].into(),
403                ..Default::default()
404            })),
405            ..Default::default()
406        })
407    }
408}