#
k8s_openapi/v1_35/api/core/v1/
endpoints.rs

    1// Generated from definition io.k8s.api.core.v1.Endpoints
    2
    3/// Endpoints is a collection of endpoints that implement the actual service. Example:
    4///
    5///   Name: "mysvc",
    6///      Subsets: \[
    7///        {
    8///          Addresses: \[{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}\],
    9///          Ports: \[{"name": "a", "port": 8675}, {"name": "b", "port": 309}\]
    10///        },
    11///        {
    12///          Addresses: \[{"ip": "10.10.3.3"}\],
    13///          Ports: \[{"name": "a", "port": 93}, {"name": "b", "port": 76}\]
    14///        },
    15///     \]
    16///
    17/// Endpoints is a legacy API and does not contain information about all Service features. Use discoveryv1.EndpointSlice for complete information about Service endpoints.
    18///
    19/// Deprecated: This API is deprecated in v1.33+. Use discoveryv1.EndpointSlice.
    20#[derive(Clone, Debug, Default, PartialEq)]
    21pub struct Endpoints {
    22    /// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    23    pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
    24
    25    /// The set of all endpoints is the union of all subsets. Addresses are placed into subsets according to the IPs they share. A single address with multiple ports, some of which are ready and some of which are not (because they come from different containers) will result in the address being displayed in different subsets for the different ports. No address will appear in both Addresses and NotReadyAddresses in the same subset. Sets of addresses and ports that comprise a service.
    26    pub subsets: Option<std::vec::Vec<crate::api::core::v1::EndpointSubset>>,
    27}
    28
    29impl crate::Resource for Endpoints {
    30    const API_VERSION: &'static str = "v1";
    31    const GROUP: &'static str = "";
    32    const KIND: &'static str = "Endpoints";
    33    const VERSION: &'static str = "v1";
    34    const URL_PATH_SEGMENT: &'static str = "endpoints";
    35    type Scope = crate::NamespaceResourceScope;
    36}
    37
    38impl crate::ListableResource for Endpoints {
    39    const LIST_KIND: &'static str = "EndpointsList";
    40}
    41
    42impl crate::Metadata for Endpoints {
    43    type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
    44
    45    fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
    46        &self.metadata
    47    }
    48
    49    fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
    50        &mut self.metadata
    51    }
    52}
    53
    54impl crate::DeepMerge for Endpoints {
    55    fn merge_from(&mut self, other: Self) {
    56        crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
    57        crate::merge_strategies::list::atomic(&mut self.subsets, other.subsets);
    58    }
    59}
    60
    61impl<'de> crate::serde::Deserialize<'de> for Endpoints {
    62    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    63        #[allow(non_camel_case_types)]
    64        enum Field {
    65            Key_api_version,
    66            Key_kind,
    67            Key_metadata,
    68            Key_subsets,
    69            Other,
    70        }
    71
    72        impl<'de> crate::serde::Deserialize<'de> for Field {
    73            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    74                struct Visitor;
    75
    76                impl crate::serde::de::Visitor<'_> for Visitor {
    77                    type Value = Field;
    78
    79                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    80                        f.write_str("field identifier")
    81                    }
    82
    83                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    84                        Ok(match v {
    85                            "apiVersion" => Field::Key_api_version,
    86                            "kind" => Field::Key_kind,
    87                            "metadata" => Field::Key_metadata,
    88                            "subsets" => Field::Key_subsets,
    89                            _ => Field::Other,
    90                        })
    91                    }
    92                }
    93
    94                deserializer.deserialize_identifier(Visitor)
    95            }
    96        }
    97
    98        struct Visitor;
    99
    100        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    101            type Value = Endpoints;
    102
    103            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    104                f.write_str(<Self::Value as crate::Resource>::KIND)
    105            }
    106
    107            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    108                let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
    109                let mut value_subsets: Option<std::vec::Vec<crate::api::core::v1::EndpointSubset>> = None;
    110
    111                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    112                    match key {
    113                        Field::Key_api_version => {
    114                            let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    115                            if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
    116                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
    117                            }
    118                        },
    119                        Field::Key_kind => {
    120                            let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    121                            if value_kind != <Self::Value as crate::Resource>::KIND {
    122                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
    123                            }
    124                        },
    125                        Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
    126                        Field::Key_subsets => value_subsets = crate::serde::de::MapAccess::next_value(&mut map)?,
    127                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    128                    }
    129                }
    130
    131                Ok(Endpoints {
    132                    metadata: value_metadata.unwrap_or_default(),
    133                    subsets: value_subsets,
    134                })
    135            }
    136        }
    137
    138        deserializer.deserialize_struct(
    139            <Self as crate::Resource>::KIND,
    140            &[
    141                "apiVersion",
    142                "kind",
    143                "metadata",
    144                "subsets",
    145            ],
    146            Visitor,
    147        )
    148    }
    149}
    150
    151impl crate::serde::Serialize for Endpoints {
    152    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    153        let mut state = serializer.serialize_struct(
    154            <Self as crate::Resource>::KIND,
    155            3 +
    156            self.subsets.as_ref().map_or(0, |_| 1),
    157        )?;
    158        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
    159        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
    160        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
    161        if let Some(value) = &self.subsets {
    162            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "subsets", value)?;
    163        }
    164        crate::serde::ser::SerializeStruct::end(state)
    165    }
    166}
    167
    168#[cfg(feature = "schemars")]
    169impl crate::schemars::JsonSchema for Endpoints {
    170    fn schema_name() -> std::borrow::Cow<'static, str> {
    171        "io.k8s.api.core.v1.Endpoints".into()
    172    }
    173
    174    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    175        crate::schemars::json_schema!({
    176            "description": "Endpoints is a collection of endpoints that implement the actual service. Example:\n\n\t Name: \"mysvc\",\n\t Subsets: [\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\t   {\n\t     Addresses: [{\"ip\": \"10.10.3.3\"}],\n\t     Ports: [{\"name\": \"a\", \"port\": 93}, {\"name\": \"b\", \"port\": 76}]\n\t   },\n\t]\n\nEndpoints is a legacy API and does not contain information about all Service features. Use discoveryv1.EndpointSlice for complete information about Service endpoints.\n\nDeprecated: This API is deprecated in v1.33+. Use discoveryv1.EndpointSlice.",
    177            "type": "object",
    178            "properties": {
    179                "apiVersion": {
    180                    "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
    181                    "type": "string",
    182                },
    183                "kind": {
    184                    "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
    185                    "type": "string",
    186                },
    187                "metadata": ({
    188                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>();
    189                    schema_obj.ensure_object().insert("description".into(), "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata".into());
    190                    schema_obj
    191                }),
    192                "subsets": {
    193                    "description": "The set of all endpoints is the union of all subsets. Addresses are placed into subsets according to the IPs they share. A single address with multiple ports, some of which are ready and some of which are not (because they come from different containers) will result in the address being displayed in different subsets for the different ports. No address will appear in both Addresses and NotReadyAddresses in the same subset. Sets of addresses and ports that comprise a service.",
    194                    "type": "array",
    195                    "items": (__gen.subschema_for::<crate::api::core::v1::EndpointSubset>()),
    196                },
    197            },
    198            "required": [
    199                "metadata",
    200            ],
    201        })
    202    }
    203}