k8s_openapi/v1_30/api/networking/v1/
ingress_load_balancer_ingress.rs

1// Generated from definition io.k8s.api.networking.v1.IngressLoadBalancerIngress
2
3/// IngressLoadBalancerIngress represents the status of a load-balancer ingress point.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct IngressLoadBalancerIngress {
6    /// hostname is set for load-balancer ingress points that are DNS based.
7    pub hostname: Option<std::string::String>,
8
9    /// ip is set for load-balancer ingress points that are IP based.
10    pub ip: Option<std::string::String>,
11
12    /// ports provides information about the ports exposed by this LoadBalancer.
13    pub ports: Option<std::vec::Vec<crate::api::networking::v1::IngressPortStatus>>,
14}
15
16impl crate::DeepMerge for IngressLoadBalancerIngress {
17    fn merge_from(&mut self, other: Self) {
18        crate::DeepMerge::merge_from(&mut self.hostname, other.hostname);
19        crate::DeepMerge::merge_from(&mut self.ip, other.ip);
20        crate::merge_strategies::list::atomic(&mut self.ports, other.ports);
21    }
22}
23
24impl<'de> crate::serde::Deserialize<'de> for IngressLoadBalancerIngress {
25    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26        #[allow(non_camel_case_types)]
27        enum Field {
28            Key_hostname,
29            Key_ip,
30            Key_ports,
31            Other,
32        }
33
34        impl<'de> crate::serde::Deserialize<'de> for Field {
35            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36                struct Visitor;
37
38                impl crate::serde::de::Visitor<'_> for Visitor {
39                    type Value = Field;
40
41                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
42                        f.write_str("field identifier")
43                    }
44
45                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
46                        Ok(match v {
47                            "hostname" => Field::Key_hostname,
48                            "ip" => Field::Key_ip,
49                            "ports" => Field::Key_ports,
50                            _ => Field::Other,
51                        })
52                    }
53                }
54
55                deserializer.deserialize_identifier(Visitor)
56            }
57        }
58
59        struct Visitor;
60
61        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62            type Value = IngressLoadBalancerIngress;
63
64            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65                f.write_str("IngressLoadBalancerIngress")
66            }
67
68            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69                let mut value_hostname: Option<std::string::String> = None;
70                let mut value_ip: Option<std::string::String> = None;
71                let mut value_ports: Option<std::vec::Vec<crate::api::networking::v1::IngressPortStatus>> = None;
72
73                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
74                    match key {
75                        Field::Key_hostname => value_hostname = crate::serde::de::MapAccess::next_value(&mut map)?,
76                        Field::Key_ip => value_ip = crate::serde::de::MapAccess::next_value(&mut map)?,
77                        Field::Key_ports => value_ports = crate::serde::de::MapAccess::next_value(&mut map)?,
78                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
79                    }
80                }
81
82                Ok(IngressLoadBalancerIngress {
83                    hostname: value_hostname,
84                    ip: value_ip,
85                    ports: value_ports,
86                })
87            }
88        }
89
90        deserializer.deserialize_struct(
91            "IngressLoadBalancerIngress",
92            &[
93                "hostname",
94                "ip",
95                "ports",
96            ],
97            Visitor,
98        )
99    }
100}
101
102impl crate::serde::Serialize for IngressLoadBalancerIngress {
103    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
104        let mut state = serializer.serialize_struct(
105            "IngressLoadBalancerIngress",
106            self.hostname.as_ref().map_or(0, |_| 1) +
107            self.ip.as_ref().map_or(0, |_| 1) +
108            self.ports.as_ref().map_or(0, |_| 1),
109        )?;
110        if let Some(value) = &self.hostname {
111            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostname", value)?;
112        }
113        if let Some(value) = &self.ip {
114            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ip", value)?;
115        }
116        if let Some(value) = &self.ports {
117            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ports", value)?;
118        }
119        crate::serde::ser::SerializeStruct::end(state)
120    }
121}
122
123#[cfg(feature = "schemars")]
124impl crate::schemars::JsonSchema for IngressLoadBalancerIngress {
125    fn schema_name() -> std::borrow::Cow<'static, str> {
126        "io.k8s.api.networking.v1.IngressLoadBalancerIngress".into()
127    }
128
129    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
130        crate::schemars::json_schema!({
131            "description": "IngressLoadBalancerIngress represents the status of a load-balancer ingress point.",
132            "type": "object",
133            "properties": {
134                "hostname": {
135                    "description": "hostname is set for load-balancer ingress points that are DNS based.",
136                    "type": "string",
137                },
138                "ip": {
139                    "description": "ip is set for load-balancer ingress points that are IP based.",
140                    "type": "string",
141                },
142                "ports": {
143                    "description": "ports provides information about the ports exposed by this LoadBalancer.",
144                    "type": "array",
145                    "items": (__gen.subschema_for::<crate::api::networking::v1::IngressPortStatus>()),
146                },
147            },
148        })
149    }
150}