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