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