Skip to main content

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

1// Generated from definition io.k8s.api.resource.v1beta2.NetworkDeviceData
2
3/// NetworkDeviceData provides network-related details for the allocated device. This information may be filled by drivers or other components to configure or identify the device within a network context.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct NetworkDeviceData {
6    /// HardwareAddress represents the hardware address (e.g. MAC Address) of the device's network interface.
7    ///
8    /// Must not be longer than 128 bytes.
9    pub hardware_address: Option<std::string::String>,
10
11    /// InterfaceName specifies the name of the network interface associated with the allocated device. This might be the name of a physical or virtual network interface being configured in the pod.
12    ///
13    /// Must not be longer than 256 bytes.
14    pub interface_name: Option<std::string::String>,
15
16    /// IPs lists the network addresses assigned to the device's network interface. This can include both IPv4 and IPv6 addresses. The IPs are in the CIDR notation, which includes both the address and the associated subnet mask. e.g.: "192.0.2.5/24" for IPv4 and "2001:db8::5/64" for IPv6.
17    pub ips: Option<std::vec::Vec<std::string::String>>,
18}
19
20impl crate::DeepMerge for NetworkDeviceData {
21    fn merge_from(&mut self, other: Self) {
22        crate::DeepMerge::merge_from(&mut self.hardware_address, other.hardware_address);
23        crate::DeepMerge::merge_from(&mut self.interface_name, other.interface_name);
24        crate::merge_strategies::list::atomic(&mut self.ips, other.ips);
25    }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for NetworkDeviceData {
29    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30        #[allow(non_camel_case_types)]
31        enum Field {
32            Key_hardware_address,
33            Key_interface_name,
34            Key_ips,
35            Other,
36        }
37
38        impl<'de> crate::serde::Deserialize<'de> for Field {
39            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
40                struct Visitor;
41
42                impl crate::serde::de::Visitor<'_> for Visitor {
43                    type Value = Field;
44
45                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
46                        f.write_str("field identifier")
47                    }
48
49                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
50                        Ok(match v {
51                            "hardwareAddress" => Field::Key_hardware_address,
52                            "interfaceName" => Field::Key_interface_name,
53                            "ips" => Field::Key_ips,
54                            _ => Field::Other,
55                        })
56                    }
57                }
58
59                deserializer.deserialize_identifier(Visitor)
60            }
61        }
62
63        struct Visitor;
64
65        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
66            type Value = NetworkDeviceData;
67
68            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
69                f.write_str("NetworkDeviceData")
70            }
71
72            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
73                let mut value_hardware_address: Option<std::string::String> = None;
74                let mut value_interface_name: Option<std::string::String> = None;
75                let mut value_ips: Option<std::vec::Vec<std::string::String>> = None;
76
77                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
78                    match key {
79                        Field::Key_hardware_address => value_hardware_address = crate::serde::de::MapAccess::next_value(&mut map)?,
80                        Field::Key_interface_name => value_interface_name = crate::serde::de::MapAccess::next_value(&mut map)?,
81                        Field::Key_ips => value_ips = crate::serde::de::MapAccess::next_value(&mut map)?,
82                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
83                    }
84                }
85
86                Ok(NetworkDeviceData {
87                    hardware_address: value_hardware_address,
88                    interface_name: value_interface_name,
89                    ips: value_ips,
90                })
91            }
92        }
93
94        deserializer.deserialize_struct(
95            "NetworkDeviceData",
96            &[
97                "hardwareAddress",
98                "interfaceName",
99                "ips",
100            ],
101            Visitor,
102        )
103    }
104}
105
106impl crate::serde::Serialize for NetworkDeviceData {
107    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
108        let mut state = serializer.serialize_struct(
109            "NetworkDeviceData",
110            self.hardware_address.as_ref().map_or(0, |_| 1) +
111            self.interface_name.as_ref().map_or(0, |_| 1) +
112            self.ips.as_ref().map_or(0, |_| 1),
113        )?;
114        if let Some(value) = &self.hardware_address {
115            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hardwareAddress", value)?;
116        }
117        if let Some(value) = &self.interface_name {
118            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "interfaceName", value)?;
119        }
120        if let Some(value) = &self.ips {
121            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ips", value)?;
122        }
123        crate::serde::ser::SerializeStruct::end(state)
124    }
125}
126
127#[cfg(feature = "schemars")]
128impl crate::schemars::JsonSchema for NetworkDeviceData {
129    fn schema_name() -> std::borrow::Cow<'static, str> {
130        "io.k8s.api.resource.v1beta2.NetworkDeviceData".into()
131    }
132
133    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
134        crate::schemars::json_schema!({
135            "description": "NetworkDeviceData provides network-related details for the allocated device. This information may be filled by drivers or other components to configure or identify the device within a network context.",
136            "type": "object",
137            "properties": {
138                "hardwareAddress": {
139                    "description": "HardwareAddress represents the hardware address (e.g. MAC Address) of the device's network interface.\n\nMust not be longer than 128 bytes.",
140                    "type": "string",
141                },
142                "interfaceName": {
143                    "description": "InterfaceName specifies the name of the network interface associated with the allocated device. This might be the name of a physical or virtual network interface being configured in the pod.\n\nMust not be longer than 256 bytes.",
144                    "type": "string",
145                },
146                "ips": {
147                    "description": "IPs lists the network addresses assigned to the device's network interface. This can include both IPv4 and IPv6 addresses. The IPs are in the CIDR notation, which includes both the address and the associated subnet mask. e.g.: \"192.0.2.5/24\" for IPv4 and \"2001:db8::5/64\" for IPv6.",
148                    "type": "array",
149                    "items": {
150                        "type": "string",
151                    },
152                },
153            },
154        })
155    }
156}
157
158#[cfg(feature = "schemars08")]
159impl crate::schemars08::JsonSchema for NetworkDeviceData {
160    fn schema_name() -> std::string::String {
161        "io.k8s.api.resource.v1beta2.NetworkDeviceData".into()
162    }
163
164    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
165        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
166            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
167                description: Some("NetworkDeviceData provides network-related details for the allocated device. This information may be filled by drivers or other components to configure or identify the device within a network context.".into()),
168                ..Default::default()
169            })),
170            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
171            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
172                properties: [
173                    (
174                        "hardwareAddress".into(),
175                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
176                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
177                                description: Some("HardwareAddress represents the hardware address (e.g. MAC Address) of the device's network interface.\n\nMust not be longer than 128 bytes.".into()),
178                                ..Default::default()
179                            })),
180                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
181                            ..Default::default()
182                        }),
183                    ),
184                    (
185                        "interfaceName".into(),
186                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
187                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
188                                description: Some("InterfaceName specifies the name of the network interface associated with the allocated device. This might be the name of a physical or virtual network interface being configured in the pod.\n\nMust not be longer than 256 bytes.".into()),
189                                ..Default::default()
190                            })),
191                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
192                            ..Default::default()
193                        }),
194                    ),
195                    (
196                        "ips".into(),
197                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
198                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
199                                description: Some("IPs lists the network addresses assigned to the device's network interface. This can include both IPv4 and IPv6 addresses. The IPs are in the CIDR notation, which includes both the address and the associated subnet mask. e.g.: \"192.0.2.5/24\" for IPv4 and \"2001:db8::5/64\" for IPv6.".into()),
200                                ..Default::default()
201                            })),
202                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
203                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
204                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
205                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
206                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
207                                        ..Default::default()
208                                    })
209                                ))),
210                                ..Default::default()
211                            })),
212                            ..Default::default()
213                        }),
214                    ),
215                ].into(),
216                ..Default::default()
217            })),
218            ..Default::default()
219        })
220    }
221}