#
k8s_openapi/v1_35/apimachinery/pkg/apis/meta/v1/
api_group_list.rs

    1// Generated from definition io.k8s.apimachinery.pkg.apis.meta.v1.APIGroupList
    2
    3/// APIGroupList is a list of APIGroup, to allow clients to discover the API at /apis.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct APIGroupList {
    6    /// groups is a list of APIGroup.
    7    pub groups: std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::APIGroup>,
    8}
    9
    10impl crate::Resource for APIGroupList {
    11    const API_VERSION: &'static str = "v1";
    12    const GROUP: &'static str = "";
    13    const KIND: &'static str = "APIGroupList";
    14    const VERSION: &'static str = "v1";
    15    const URL_PATH_SEGMENT: &'static str = "";
    16    type Scope = crate::ClusterResourceScope;
    17}
    18
    19impl crate::DeepMerge for APIGroupList {
    20    fn merge_from(&mut self, other: Self) {
    21        crate::merge_strategies::list::atomic(&mut self.groups, other.groups);
    22    }
    23}
    24
    25impl<'de> crate::serde::Deserialize<'de> for APIGroupList {
    26    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    27        #[allow(non_camel_case_types)]
    28        enum Field {
    29            Key_api_version,
    30            Key_kind,
    31            Key_groups,
    32            Other,
    33        }
    34
    35        impl<'de> crate::serde::Deserialize<'de> for Field {
    36            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    37                struct Visitor;
    38
    39                impl crate::serde::de::Visitor<'_> for Visitor {
    40                    type Value = Field;
    41
    42                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    43                        f.write_str("field identifier")
    44                    }
    45
    46                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    47                        Ok(match v {
    48                            "apiVersion" => Field::Key_api_version,
    49                            "kind" => Field::Key_kind,
    50                            "groups" => Field::Key_groups,
    51                            _ => Field::Other,
    52                        })
    53                    }
    54                }
    55
    56                deserializer.deserialize_identifier(Visitor)
    57            }
    58        }
    59
    60        struct Visitor;
    61
    62        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    63            type Value = APIGroupList;
    64
    65            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    66                f.write_str(<Self::Value as crate::Resource>::KIND)
    67            }
    68
    69            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    70                let mut value_groups: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::APIGroup>> = None;
    71
    72                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    73                    match key {
    74                        Field::Key_api_version => {
    75                            let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    76                            if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
    77                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
    78                            }
    79                        },
    80                        Field::Key_kind => {
    81                            let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    82                            if value_kind != <Self::Value as crate::Resource>::KIND {
    83                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
    84                            }
    85                        },
    86                        Field::Key_groups => value_groups = crate::serde::de::MapAccess::next_value(&mut map)?,
    87                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    88                    }
    89                }
    90
    91                Ok(APIGroupList {
    92                    groups: value_groups.unwrap_or_default(),
    93                })
    94            }
    95        }
    96
    97        deserializer.deserialize_struct(
    98            <Self as crate::Resource>::KIND,
    99            &[
    100                "apiVersion",
    101                "kind",
    102                "groups",
    103            ],
    104            Visitor,
    105        )
    106    }
    107}
    108
    109impl crate::serde::Serialize for APIGroupList {
    110    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    111        let mut state = serializer.serialize_struct(
    112            <Self as crate::Resource>::KIND,
    113            3,
    114        )?;
    115        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
    116        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
    117        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "groups", &self.groups)?;
    118        crate::serde::ser::SerializeStruct::end(state)
    119    }
    120}
    121
    122#[cfg(feature = "schemars")]
    123impl crate::schemars::JsonSchema for APIGroupList {
    124    fn schema_name() -> std::borrow::Cow<'static, str> {
    125        "io.k8s.apimachinery.pkg.apis.meta.v1.APIGroupList".into()
    126    }
    127
    128    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    129        crate::schemars::json_schema!({
    130            "description": "APIGroupList is a list of APIGroup, to allow clients to discover the API at /apis.",
    131            "type": "object",
    132            "properties": {
    133                "apiVersion": {
    134                    "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",
    135                    "type": "string",
    136                },
    137                "groups": {
    138                    "description": "groups is a list of APIGroup.",
    139                    "type": "array",
    140                    "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::APIGroup>()),
    141                },
    142                "kind": {
    143                    "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",
    144                    "type": "string",
    145                },
    146            },
    147            "required": [
    148                "groups",
    149            ],
    150        })
    151    }
    152}