k8s_openapi/v1_35/api/core/v1/
endpoint_subset.rs

1// Generated from definition io.k8s.api.core.v1.EndpointSubset
2
3/// EndpointSubset is a group of addresses with a common set of ports. The expanded set of endpoints is the Cartesian product of Addresses x Ports. For example, given:
4///
5///   {
6///       Addresses: \[{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}\],
7///       Ports:     \[{"name": "a", "port": 8675}, {"name": "b", "port": 309}\]
8///     }
9///
10/// The resulting set of endpoints can be viewed as:
11///
12///   a: \[ 10.10.1.1:8675, 10.10.2.2:8675 \],
13///     b: \[ 10.10.1.1:309, 10.10.2.2:309 \]
14///
15/// Deprecated: This API is deprecated in v1.33+.
16#[derive(Clone, Debug, Default, PartialEq)]
17pub struct EndpointSubset {
18    /// IP addresses which offer the related ports that are marked as ready. These endpoints should be considered safe for load balancers and clients to utilize.
19    pub addresses: Option<std::vec::Vec<crate::api::core::v1::EndpointAddress>>,
20
21    /// IP addresses which offer the related ports but are not currently marked as ready because they have not yet finished starting, have recently failed a readiness check, or have recently failed a liveness check.
22    pub not_ready_addresses: Option<std::vec::Vec<crate::api::core::v1::EndpointAddress>>,
23
24    /// Port numbers available on the related IP addresses.
25    pub ports: Option<std::vec::Vec<crate::api::core::v1::EndpointPort>>,
26}
27
28impl crate::DeepMerge for EndpointSubset {
29    fn merge_from(&mut self, other: Self) {
30        crate::merge_strategies::list::atomic(&mut self.addresses, other.addresses);
31        crate::merge_strategies::list::atomic(&mut self.not_ready_addresses, other.not_ready_addresses);
32        crate::merge_strategies::list::atomic(&mut self.ports, other.ports);
33    }
34}
35
36impl<'de> crate::serde::Deserialize<'de> for EndpointSubset {
37    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
38        #[allow(non_camel_case_types)]
39        enum Field {
40            Key_addresses,
41            Key_not_ready_addresses,
42            Key_ports,
43            Other,
44        }
45
46        impl<'de> crate::serde::Deserialize<'de> for Field {
47            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
48                struct Visitor;
49
50                impl crate::serde::de::Visitor<'_> for Visitor {
51                    type Value = Field;
52
53                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
54                        f.write_str("field identifier")
55                    }
56
57                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
58                        Ok(match v {
59                            "addresses" => Field::Key_addresses,
60                            "notReadyAddresses" => Field::Key_not_ready_addresses,
61                            "ports" => Field::Key_ports,
62                            _ => Field::Other,
63                        })
64                    }
65                }
66
67                deserializer.deserialize_identifier(Visitor)
68            }
69        }
70
71        struct Visitor;
72
73        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
74            type Value = EndpointSubset;
75
76            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
77                f.write_str("EndpointSubset")
78            }
79
80            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
81                let mut value_addresses: Option<std::vec::Vec<crate::api::core::v1::EndpointAddress>> = None;
82                let mut value_not_ready_addresses: Option<std::vec::Vec<crate::api::core::v1::EndpointAddress>> = None;
83                let mut value_ports: Option<std::vec::Vec<crate::api::core::v1::EndpointPort>> = None;
84
85                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
86                    match key {
87                        Field::Key_addresses => value_addresses = crate::serde::de::MapAccess::next_value(&mut map)?,
88                        Field::Key_not_ready_addresses => value_not_ready_addresses = crate::serde::de::MapAccess::next_value(&mut map)?,
89                        Field::Key_ports => value_ports = crate::serde::de::MapAccess::next_value(&mut map)?,
90                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
91                    }
92                }
93
94                Ok(EndpointSubset {
95                    addresses: value_addresses,
96                    not_ready_addresses: value_not_ready_addresses,
97                    ports: value_ports,
98                })
99            }
100        }
101
102        deserializer.deserialize_struct(
103            "EndpointSubset",
104            &[
105                "addresses",
106                "notReadyAddresses",
107                "ports",
108            ],
109            Visitor,
110        )
111    }
112}
113
114impl crate::serde::Serialize for EndpointSubset {
115    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
116        let mut state = serializer.serialize_struct(
117            "EndpointSubset",
118            self.addresses.as_ref().map_or(0, |_| 1) +
119            self.not_ready_addresses.as_ref().map_or(0, |_| 1) +
120            self.ports.as_ref().map_or(0, |_| 1),
121        )?;
122        if let Some(value) = &self.addresses {
123            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "addresses", value)?;
124        }
125        if let Some(value) = &self.not_ready_addresses {
126            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "notReadyAddresses", value)?;
127        }
128        if let Some(value) = &self.ports {
129            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ports", value)?;
130        }
131        crate::serde::ser::SerializeStruct::end(state)
132    }
133}
134
135#[cfg(feature = "schemars")]
136impl crate::schemars::JsonSchema for EndpointSubset {
137    fn schema_name() -> std::borrow::Cow<'static, str> {
138        "io.k8s.api.core.v1.EndpointSubset".into()
139    }
140
141    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
142        crate::schemars::json_schema!({
143            "description": "EndpointSubset is a group of addresses with a common set of ports. The expanded set of endpoints is the Cartesian product of Addresses x Ports. For example, given:\n\n\t{\n\t  Addresses: [{\"ip\": \"10.10.1.1\"}, {\"ip\": \"10.10.2.2\"}],\n\t  Ports:     [{\"name\": \"a\", \"port\": 8675}, {\"name\": \"b\", \"port\": 309}]\n\t}\n\nThe resulting set of endpoints can be viewed as:\n\n\ta: [ 10.10.1.1:8675, 10.10.2.2:8675 ],\n\tb: [ 10.10.1.1:309, 10.10.2.2:309 ]\n\nDeprecated: This API is deprecated in v1.33+.",
144            "type": "object",
145            "properties": {
146                "addresses": {
147                    "description": "IP addresses which offer the related ports that are marked as ready. These endpoints should be considered safe for load balancers and clients to utilize.",
148                    "type": "array",
149                    "items": (__gen.subschema_for::<crate::api::core::v1::EndpointAddress>()),
150                },
151                "notReadyAddresses": {
152                    "description": "IP addresses which offer the related ports but are not currently marked as ready because they have not yet finished starting, have recently failed a readiness check, or have recently failed a liveness check.",
153                    "type": "array",
154                    "items": (__gen.subschema_for::<crate::api::core::v1::EndpointAddress>()),
155                },
156                "ports": {
157                    "description": "Port numbers available on the related IP addresses.",
158                    "type": "array",
159                    "items": (__gen.subschema_for::<crate::api::core::v1::EndpointPort>()),
160                },
161            },
162        })
163    }
164}