#
k8s_openapi/v1_35/api/discovery/v1/
endpoint_conditions.rs

    1// Generated from definition io.k8s.api.discovery.v1.EndpointConditions
    2
    3/// EndpointConditions represents the current condition of an endpoint.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct EndpointConditions {
    6    /// ready indicates that this endpoint is ready to receive traffic, according to whatever system is managing the endpoint. A nil value should be interpreted as "true". In general, an endpoint should be marked ready if it is serving and not terminating, though this can be overridden in some cases, such as when the associated Service has set the publishNotReadyAddresses flag.
    7    pub ready: Option<bool>,
    8
    9    /// serving indicates that this endpoint is able to receive traffic, according to whatever system is managing the endpoint. For endpoints backed by pods, the EndpointSlice controller will mark the endpoint as serving if the pod's Ready condition is True. A nil value should be interpreted as "true".
    10    pub serving: Option<bool>,
    11
    12    /// terminating indicates that this endpoint is terminating. A nil value should be interpreted as "false".
    13    pub terminating: Option<bool>,
    14}
    15
    16impl crate::DeepMerge for EndpointConditions {
    17    fn merge_from(&mut self, other: Self) {
    18        crate::DeepMerge::merge_from(&mut self.ready, other.ready);
    19        crate::DeepMerge::merge_from(&mut self.serving, other.serving);
    20        crate::DeepMerge::merge_from(&mut self.terminating, other.terminating);
    21    }
    22}
    23
    24impl<'de> crate::serde::Deserialize<'de> for EndpointConditions {
    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_ready,
    29            Key_serving,
    30            Key_terminating,
    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                            "ready" => Field::Key_ready,
    48                            "serving" => Field::Key_serving,
    49                            "terminating" => Field::Key_terminating,
    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 = EndpointConditions;
    63
    64            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    65                f.write_str("EndpointConditions")
    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_ready: Option<bool> = None;
    70                let mut value_serving: Option<bool> = None;
    71                let mut value_terminating: Option<bool> = None;
    72
    73                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    74                    match key {
    75                        Field::Key_ready => value_ready = crate::serde::de::MapAccess::next_value(&mut map)?,
    76                        Field::Key_serving => value_serving = crate::serde::de::MapAccess::next_value(&mut map)?,
    77                        Field::Key_terminating => value_terminating = 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(EndpointConditions {
    83                    ready: value_ready,
    84                    serving: value_serving,
    85                    terminating: value_terminating,
    86                })
    87            }
    88        }
    89
    90        deserializer.deserialize_struct(
    91            "EndpointConditions",
    92            &[
    93                "ready",
    94                "serving",
    95                "terminating",
    96            ],
    97            Visitor,
    98        )
    99    }
    100}
    101
    102impl crate::serde::Serialize for EndpointConditions {
    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            "EndpointConditions",
    106            self.ready.as_ref().map_or(0, |_| 1) +
    107            self.serving.as_ref().map_or(0, |_| 1) +
    108            self.terminating.as_ref().map_or(0, |_| 1),
    109        )?;
    110        if let Some(value) = &self.ready {
    111            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ready", value)?;
    112        }
    113        if let Some(value) = &self.serving {
    114            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serving", value)?;
    115        }
    116        if let Some(value) = &self.terminating {
    117            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminating", value)?;
    118        }
    119        crate::serde::ser::SerializeStruct::end(state)
    120    }
    121}
    122
    123#[cfg(feature = "schemars")]
    124impl crate::schemars::JsonSchema for EndpointConditions {
    125    fn schema_name() -> std::borrow::Cow<'static, str> {
    126        "io.k8s.api.discovery.v1.EndpointConditions".into()
    127    }
    128
    129    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    130        crate::schemars::json_schema!({
    131            "description": "EndpointConditions represents the current condition of an endpoint.",
    132            "type": "object",
    133            "properties": {
    134                "ready": {
    135                    "description": "ready indicates that this endpoint is ready to receive traffic, according to whatever system is managing the endpoint. A nil value should be interpreted as \"true\". In general, an endpoint should be marked ready if it is serving and not terminating, though this can be overridden in some cases, such as when the associated Service has set the publishNotReadyAddresses flag.",
    136                    "type": "boolean",
    137                },
    138                "serving": {
    139                    "description": "serving indicates that this endpoint is able to receive traffic, according to whatever system is managing the endpoint. For endpoints backed by pods, the EndpointSlice controller will mark the endpoint as serving if the pod's Ready condition is True. A nil value should be interpreted as \"true\".",
    140                    "type": "boolean",
    141                },
    142                "terminating": {
    143                    "description": "terminating indicates that this endpoint is terminating. A nil value should be interpreted as \"false\".",
    144                    "type": "boolean",
    145                },
    146            },
    147        })
    148    }
    149}