openshift_openapi/v4_5/api/network/v1/
host_subnet.rs

1// Generated from definition com.github.openshift.api.network.v1.HostSubnet
2
3/// HostSubnet describes the container subnet network on a node. The HostSubnet object must have the same name as the Node object it corresponds to.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct HostSubnet {
6    /// EgressCIDRs is the list of CIDR ranges available for automatically assigning egress IPs to this node from. If this field is set then EgressIPs should be treated as read-only.
7    pub egress_cid_rs: Option<Vec<String>>,
8
9    /// EgressIPs is the list of automatic egress IP addresses currently hosted by this node. If EgressCIDRs is empty, this can be set by hand; if EgressCIDRs is set then the master will overwrite the value here with its own allocation of egress IPs.
10    pub egress_i_ps: Option<Vec<String>>,
11
12    /// Host is the name of the node. (This is the same as the object's name, but both fields must be set.)
13    pub host: String,
14
15    /// HostIP is the IP address to be used as a VTEP by other nodes in the overlay network
16    pub host_ip: String,
17
18    /// Standard object's metadata.
19    pub metadata: k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta,
20
21    /// Subnet is the CIDR range of the overlay network assigned to the node for its pods
22    pub subnet: String,
23}
24
25// Begin network.openshift.io/v1/HostSubnet
26
27// Generated from operation createNetworkOpenshiftIoV1HostSubnet
28
29impl HostSubnet {
30    /// create a HostSubnet
31    ///
32    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::CreateResponse`]`<Self>>` constructor, or [`k8s_openapi::CreateResponse`]`<Self>` directly, to parse the HTTP response.
33    ///
34    /// # Arguments
35    ///
36    /// * `body`
37    ///
38    /// * `optional`
39    ///
40    ///     Optional parameters. Use `Default::default()` to not pass any.
41    #[cfg(feature = "api")]
42    pub fn create_host_subnet(
43        body: &crate::api::network::v1::HostSubnet,
44        optional: k8s_openapi::CreateOptional<'_>,
45    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::CreateResponse<Self>>), k8s_openapi::RequestError> {
46        let __url = "/apis/network.openshift.io/v1/hostsubnets?".to_owned();
47        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
48        optional.__serialize(&mut __query_pairs);
49        let __url = __query_pairs.finish();
50
51        let __request = http::Request::post(__url);
52        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
53        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
54        match __request.body(__body) {
55            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
56            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
57        }
58    }
59}
60
61// Generated from operation deleteNetworkOpenshiftIoV1CollectionHostSubnet
62
63impl HostSubnet {
64    /// delete collection of HostSubnet
65    ///
66    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::DeleteResponse`]`<`[`k8s_openapi::List`]`<Self>>>` constructor, or [`k8s_openapi::DeleteResponse`]`<`[`k8s_openapi::List`]`<Self>>` directly, to parse the HTTP response.
67    ///
68    /// # Arguments
69    ///
70    /// * `delete_optional`
71    ///
72    ///     Delete options. Use `Default::default()` to not pass any.
73    ///
74    /// * `list_optional`
75    ///
76    ///     List options. Use `Default::default()` to not pass any.
77    #[cfg(feature = "api")]
78    pub fn delete_collection_host_subnet(
79        delete_optional: k8s_openapi::DeleteOptional<'_>,
80        list_optional: k8s_openapi::ListOptional<'_>,
81    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::DeleteResponse<k8s_openapi::List<Self>>>), k8s_openapi::RequestError> {
82        let __url = "/apis/network.openshift.io/v1/hostsubnets?".to_owned();
83        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
84        list_optional.__serialize(&mut __query_pairs);
85        let __url = __query_pairs.finish();
86
87        let __request = http::Request::delete(__url);
88        let __body = serde_json::to_vec(&delete_optional).map_err(k8s_openapi::RequestError::Json)?;
89        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
90        match __request.body(__body) {
91            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
92            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
93        }
94    }
95}
96
97// Generated from operation deleteNetworkOpenshiftIoV1HostSubnet
98
99impl HostSubnet {
100    /// delete a HostSubnet
101    ///
102    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::DeleteResponse`]`<Self>>` constructor, or [`k8s_openapi::DeleteResponse`]`<Self>` directly, to parse the HTTP response.
103    ///
104    /// # Arguments
105    ///
106    /// * `name`
107    ///
108    ///     name of the HostSubnet
109    ///
110    /// * `optional`
111    ///
112    ///     Optional parameters. Use `Default::default()` to not pass any.
113    #[cfg(feature = "api")]
114    pub fn delete_host_subnet(
115        name: &str,
116        optional: k8s_openapi::DeleteOptional<'_>,
117    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::DeleteResponse<Self>>), k8s_openapi::RequestError> {
118        let __url = format!("/apis/network.openshift.io/v1/hostsubnets/{name}",
119            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
120        );
121
122        let __request = http::Request::delete(__url);
123        let __body = serde_json::to_vec(&optional).map_err(k8s_openapi::RequestError::Json)?;
124        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
125        match __request.body(__body) {
126            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
127            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
128        }
129    }
130}
131
132// Generated from operation listNetworkOpenshiftIoV1HostSubnet
133
134impl HostSubnet {
135    /// list or watch objects of kind HostSubnet
136    ///
137    /// This operation only supports listing all items of this type.
138    ///
139    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::ListResponse`]`<Self>>` constructor, or [`k8s_openapi::ListResponse`]`<Self>` directly, to parse the HTTP response.
140    ///
141    /// # Arguments
142    ///
143    /// * `optional`
144    ///
145    ///     Optional parameters. Use `Default::default()` to not pass any.
146    #[cfg(feature = "api")]
147    pub fn list_host_subnet(
148        optional: k8s_openapi::ListOptional<'_>,
149    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ListResponse<Self>>), k8s_openapi::RequestError> {
150        let __url = "/apis/network.openshift.io/v1/hostsubnets?".to_owned();
151        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
152        optional.__serialize(&mut __query_pairs);
153        let __url = __query_pairs.finish();
154
155        let __request = http::Request::get(__url);
156        let __body = vec![];
157        match __request.body(__body) {
158            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
159            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
160        }
161    }
162}
163
164// Generated from operation patchNetworkOpenshiftIoV1HostSubnet
165
166impl HostSubnet {
167    /// partially update the specified HostSubnet
168    ///
169    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::PatchResponse`]`<Self>>` constructor, or [`k8s_openapi::PatchResponse`]`<Self>` directly, to parse the HTTP response.
170    ///
171    /// # Arguments
172    ///
173    /// * `name`
174    ///
175    ///     name of the HostSubnet
176    ///
177    /// * `body`
178    ///
179    /// * `optional`
180    ///
181    ///     Optional parameters. Use `Default::default()` to not pass any.
182    #[cfg(feature = "api")]
183    pub fn patch_host_subnet(
184        name: &str,
185        body: &k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch,
186        optional: k8s_openapi::PatchOptional<'_>,
187    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::PatchResponse<Self>>), k8s_openapi::RequestError> {
188        let __url = format!("/apis/network.openshift.io/v1/hostsubnets/{name}?",
189            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
190        );
191        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
192        optional.__serialize(&mut __query_pairs);
193        let __url = __query_pairs.finish();
194
195        let __request = http::Request::patch(__url);
196        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
197        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static(match body {
198            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Json(_) => "application/json-patch+json",
199            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Merge(_) => "application/merge-patch+json",
200            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::StrategicMerge(_) => "application/strategic-merge-patch+json",
201        }));
202        match __request.body(__body) {
203            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
204            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
205        }
206    }
207}
208
209// Generated from operation readNetworkOpenshiftIoV1HostSubnet
210
211impl HostSubnet {
212    /// read the specified HostSubnet
213    ///
214    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`ReadHostSubnetResponse`]`>` constructor, or [`ReadHostSubnetResponse`] directly, to parse the HTTP response.
215    ///
216    /// # Arguments
217    ///
218    /// * `name`
219    ///
220    ///     name of the HostSubnet
221    ///
222    /// * `optional`
223    ///
224    ///     Optional parameters. Use `Default::default()` to not pass any.
225    #[cfg(feature = "api")]
226    pub fn read_host_subnet(
227        name: &str,
228        optional: ReadHostSubnetOptional<'_>,
229    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<ReadHostSubnetResponse>), k8s_openapi::RequestError> {
230        let ReadHostSubnetOptional {
231            exact,
232            export,
233            pretty,
234        } = optional;
235        let __url = format!("/apis/network.openshift.io/v1/hostsubnets/{name}?",
236            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
237        );
238        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
239        if let Some(exact) = exact {
240            __query_pairs.append_pair("exact", &exact.to_string());
241        }
242        if let Some(export) = export {
243            __query_pairs.append_pair("export", &export.to_string());
244        }
245        if let Some(pretty) = pretty {
246            __query_pairs.append_pair("pretty", pretty);
247        }
248        let __url = __query_pairs.finish();
249
250        let __request = http::Request::get(__url);
251        let __body = vec![];
252        match __request.body(__body) {
253            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
254            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
255        }
256    }
257}
258
259/// Optional parameters of [`HostSubnet::read_host_subnet`]
260#[cfg(feature = "api")]
261#[derive(Clone, Copy, Debug, Default)]
262pub struct ReadHostSubnetOptional<'a> {
263    /// Should the export be exact.  Exact export maintains cluster-specific fields like 'Namespace'.
264    pub exact: Option<bool>,
265    /// Should this value be exported.  Export strips fields that a user can not specify.
266    pub export: Option<bool>,
267    /// If 'true', then the output is pretty printed.
268    pub pretty: Option<&'a str>,
269}
270
271/// Use `<ReadHostSubnetResponse as Response>::try_from_parts` to parse the HTTP response body of [`HostSubnet::read_host_subnet`]
272#[cfg(feature = "api")]
273#[derive(Debug)]
274pub enum ReadHostSubnetResponse {
275    Ok(crate::api::network::v1::HostSubnet),
276    Other(Result<Option<serde_json::Value>, serde_json::Error>),
277}
278
279#[cfg(feature = "api")]
280impl k8s_openapi::Response for ReadHostSubnetResponse {
281    fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), k8s_openapi::ResponseError> {
282        match status_code {
283            http::StatusCode::OK => {
284                let result = match serde_json::from_slice(buf) {
285                    Ok(value) => value,
286                    Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
287                    Err(err) => return Err(k8s_openapi::ResponseError::Json(err)),
288                };
289                Ok((ReadHostSubnetResponse::Ok(result), buf.len()))
290            },
291            _ => {
292                let (result, read) =
293                    if buf.is_empty() {
294                        (Ok(None), 0)
295                    }
296                    else {
297                        match serde_json::from_slice(buf) {
298                            Ok(value) => (Ok(Some(value)), buf.len()),
299                            Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
300                            Err(err) => (Err(err), 0),
301                        }
302                    };
303                Ok((ReadHostSubnetResponse::Other(result), read))
304            },
305        }
306    }
307}
308
309// Generated from operation replaceNetworkOpenshiftIoV1HostSubnet
310
311impl HostSubnet {
312    /// replace the specified HostSubnet
313    ///
314    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::ReplaceResponse`]`<Self>>` constructor, or [`k8s_openapi::ReplaceResponse`]`<Self>` directly, to parse the HTTP response.
315    ///
316    /// # Arguments
317    ///
318    /// * `name`
319    ///
320    ///     name of the HostSubnet
321    ///
322    /// * `body`
323    ///
324    /// * `optional`
325    ///
326    ///     Optional parameters. Use `Default::default()` to not pass any.
327    #[cfg(feature = "api")]
328    pub fn replace_host_subnet(
329        name: &str,
330        body: &crate::api::network::v1::HostSubnet,
331        optional: k8s_openapi::ReplaceOptional<'_>,
332    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ReplaceResponse<Self>>), k8s_openapi::RequestError> {
333        let __url = format!("/apis/network.openshift.io/v1/hostsubnets/{name}?",
334            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
335        );
336        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
337        optional.__serialize(&mut __query_pairs);
338        let __url = __query_pairs.finish();
339
340        let __request = http::Request::put(__url);
341        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
342        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
343        match __request.body(__body) {
344            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
345            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
346        }
347    }
348}
349
350// Generated from operation watchNetworkOpenshiftIoV1HostSubnet
351
352impl HostSubnet {
353    /// list or watch objects of kind HostSubnet
354    ///
355    /// This operation only supports watching one item, or a list of items, of this type for changes.
356    ///
357    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::WatchResponse`]`<Self>>` constructor, or [`k8s_openapi::WatchResponse`]`<Self>` directly, to parse the HTTP response.
358    ///
359    /// # Arguments
360    ///
361    /// * `optional`
362    ///
363    ///     Optional parameters. Use `Default::default()` to not pass any.
364    #[cfg(feature = "api")]
365    pub fn watch_host_subnet(
366        optional: k8s_openapi::WatchOptional<'_>,
367    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::WatchResponse<Self>>), k8s_openapi::RequestError> {
368        let __url = "/apis/network.openshift.io/v1/hostsubnets?".to_owned();
369        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
370        optional.__serialize(&mut __query_pairs);
371        let __url = __query_pairs.finish();
372
373        let __request = http::Request::get(__url);
374        let __body = vec![];
375        match __request.body(__body) {
376            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
377            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
378        }
379    }
380}
381
382// End network.openshift.io/v1/HostSubnet
383
384impl k8s_openapi::Resource for HostSubnet {
385    const API_VERSION: &'static str = "network.openshift.io/v1";
386    const GROUP: &'static str = "network.openshift.io";
387    const KIND: &'static str = "HostSubnet";
388    const VERSION: &'static str = "v1";
389}
390
391impl k8s_openapi::ListableResource for HostSubnet {
392    const LIST_KIND: &'static str = concat!("HostSubnet", "List");
393}
394
395impl k8s_openapi::Metadata for HostSubnet {
396    type Ty = k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
397
398    fn metadata(&self) -> &<Self as k8s_openapi::Metadata>::Ty {
399        &self.metadata
400    }
401
402    fn metadata_mut(&mut self) -> &mut<Self as k8s_openapi::Metadata>::Ty {
403        &mut self.metadata
404    }
405}
406
407impl<'de> serde::Deserialize<'de> for HostSubnet {
408    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
409        #[allow(non_camel_case_types)]
410        enum Field {
411            Key_api_version,
412            Key_kind,
413            Key_egress_cid_rs,
414            Key_egress_i_ps,
415            Key_host,
416            Key_host_ip,
417            Key_metadata,
418            Key_subnet,
419            Other,
420        }
421
422        impl<'de> serde::Deserialize<'de> for Field {
423            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
424                struct Visitor;
425
426                impl<'de> serde::de::Visitor<'de> for Visitor {
427                    type Value = Field;
428
429                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
430                        f.write_str("field identifier")
431                    }
432
433                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
434                        Ok(match v {
435                            "apiVersion" => Field::Key_api_version,
436                            "kind" => Field::Key_kind,
437                            "egressCIDRs" => Field::Key_egress_cid_rs,
438                            "egressIPs" => Field::Key_egress_i_ps,
439                            "host" => Field::Key_host,
440                            "hostIP" => Field::Key_host_ip,
441                            "metadata" => Field::Key_metadata,
442                            "subnet" => Field::Key_subnet,
443                            _ => Field::Other,
444                        })
445                    }
446                }
447
448                deserializer.deserialize_identifier(Visitor)
449            }
450        }
451
452        struct Visitor;
453
454        impl<'de> serde::de::Visitor<'de> for Visitor {
455            type Value = HostSubnet;
456
457            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
458                f.write_str(<Self::Value as k8s_openapi::Resource>::KIND)
459            }
460
461            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
462                let mut value_egress_cid_rs: Option<Vec<String>> = None;
463                let mut value_egress_i_ps: Option<Vec<String>> = None;
464                let mut value_host: Option<String> = None;
465                let mut value_host_ip: Option<String> = None;
466                let mut value_metadata: Option<k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
467                let mut value_subnet: Option<String> = None;
468
469                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
470                    match key {
471                        Field::Key_api_version => {
472                            let value_api_version: String = serde::de::MapAccess::next_value(&mut map)?;
473                            if value_api_version != <Self::Value as k8s_openapi::Resource>::API_VERSION {
474                                return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_api_version), &<Self::Value as k8s_openapi::Resource>::API_VERSION));
475                            }
476                        },
477                        Field::Key_kind => {
478                            let value_kind: String = serde::de::MapAccess::next_value(&mut map)?;
479                            if value_kind != <Self::Value as k8s_openapi::Resource>::KIND {
480                                return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_kind), &<Self::Value as k8s_openapi::Resource>::KIND));
481                            }
482                        },
483                        Field::Key_egress_cid_rs => value_egress_cid_rs = serde::de::MapAccess::next_value(&mut map)?,
484                        Field::Key_egress_i_ps => value_egress_i_ps = serde::de::MapAccess::next_value(&mut map)?,
485                        Field::Key_host => value_host = Some(serde::de::MapAccess::next_value(&mut map)?),
486                        Field::Key_host_ip => value_host_ip = Some(serde::de::MapAccess::next_value(&mut map)?),
487                        Field::Key_metadata => value_metadata = Some(serde::de::MapAccess::next_value(&mut map)?),
488                        Field::Key_subnet => value_subnet = Some(serde::de::MapAccess::next_value(&mut map)?),
489                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
490                    }
491                }
492
493                Ok(HostSubnet {
494                    egress_cid_rs: value_egress_cid_rs,
495                    egress_i_ps: value_egress_i_ps,
496                    host: value_host.ok_or_else(|| serde::de::Error::missing_field("host"))?,
497                    host_ip: value_host_ip.ok_or_else(|| serde::de::Error::missing_field("hostIP"))?,
498                    metadata: value_metadata.ok_or_else(|| serde::de::Error::missing_field("metadata"))?,
499                    subnet: value_subnet.ok_or_else(|| serde::de::Error::missing_field("subnet"))?,
500                })
501            }
502        }
503
504        deserializer.deserialize_struct(
505            <Self as k8s_openapi::Resource>::KIND,
506            &[
507                "apiVersion",
508                "kind",
509                "egressCIDRs",
510                "egressIPs",
511                "host",
512                "hostIP",
513                "metadata",
514                "subnet",
515            ],
516            Visitor,
517        )
518    }
519}
520
521impl serde::Serialize for HostSubnet {
522    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
523        let mut state = serializer.serialize_struct(
524            <Self as k8s_openapi::Resource>::KIND,
525            6 +
526            self.egress_cid_rs.as_ref().map_or(0, |_| 1) +
527            self.egress_i_ps.as_ref().map_or(0, |_| 1),
528        )?;
529        serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as k8s_openapi::Resource>::API_VERSION)?;
530        serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as k8s_openapi::Resource>::KIND)?;
531        if let Some(value) = &self.egress_cid_rs {
532            serde::ser::SerializeStruct::serialize_field(&mut state, "egressCIDRs", value)?;
533        }
534        if let Some(value) = &self.egress_i_ps {
535            serde::ser::SerializeStruct::serialize_field(&mut state, "egressIPs", value)?;
536        }
537        serde::ser::SerializeStruct::serialize_field(&mut state, "host", &self.host)?;
538        serde::ser::SerializeStruct::serialize_field(&mut state, "hostIP", &self.host_ip)?;
539        serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
540        serde::ser::SerializeStruct::serialize_field(&mut state, "subnet", &self.subnet)?;
541        serde::ser::SerializeStruct::end(state)
542    }
543}