k8s_openapi/v1_36/apimachinery/pkg/apis/meta/v1/
api_versions.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct APIVersions {
6 pub server_address_by_client_cidrs: std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::ServerAddressByClientCIDR>,
8
9 pub versions: std::vec::Vec<std::string::String>,
11}
12
13impl crate::Resource for APIVersions {
14 const API_VERSION: &'static str = "v1";
15 const GROUP: &'static str = "";
16 const KIND: &'static str = "APIVersions";
17 const VERSION: &'static str = "v1";
18 const URL_PATH_SEGMENT: &'static str = "";
19 type Scope = crate::ClusterResourceScope;
20}
21
22impl crate::DeepMerge for APIVersions {
23 fn merge_from(&mut self, other: Self) {
24 crate::merge_strategies::list::atomic(&mut self.server_address_by_client_cidrs, other.server_address_by_client_cidrs);
25 crate::merge_strategies::list::atomic(&mut self.versions, other.versions);
26 }
27}
28
29impl<'de> crate::serde::Deserialize<'de> for APIVersions {
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_server_address_by_client_cidrs,
36 Key_versions,
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 "serverAddressByClientCIDRs" => Field::Key_server_address_by_client_cidrs,
56 "versions" => Field::Key_versions,
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 = APIVersions;
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_server_address_by_client_cidrs: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::ServerAddressByClientCIDR>> = None;
77 let mut value_versions: Option<std::vec::Vec<std::string::String>> = 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_server_address_by_client_cidrs => value_server_address_by_client_cidrs = crate::serde::de::MapAccess::next_value(&mut map)?,
94 Field::Key_versions => value_versions = 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(APIVersions {
100 server_address_by_client_cidrs: value_server_address_by_client_cidrs.unwrap_or_default(),
101 versions: value_versions.unwrap_or_default(),
102 })
103 }
104 }
105
106 deserializer.deserialize_struct(
107 <Self as crate::Resource>::KIND,
108 &[
109 "apiVersion",
110 "kind",
111 "serverAddressByClientCIDRs",
112 "versions",
113 ],
114 Visitor,
115 )
116 }
117}
118
119impl crate::serde::Serialize for APIVersions {
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, "serverAddressByClientCIDRs", &self.server_address_by_client_cidrs)?;
128 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "versions", &self.versions)?;
129 crate::serde::ser::SerializeStruct::end(state)
130 }
131}
132
133#[cfg(feature = "schemars")]
134impl crate::schemars::JsonSchema for APIVersions {
135 fn schema_name() -> std::borrow::Cow<'static, str> {
136 "io.k8s.apimachinery.pkg.apis.meta.v1.APIVersions".into()
137 }
138
139 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
140 crate::schemars::json_schema!({
141 "description": "APIVersions lists the versions that are available, to allow clients to discover the API at /api, which is the root path of the legacy v1 API.",
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 "kind": {
149 "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",
150 "type": "string",
151 },
152 "serverAddressByClientCIDRs": {
153 "description": "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.",
154 "type": "array",
155 "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ServerAddressByClientCIDR>()),
156 },
157 "versions": {
158 "description": "versions are the api versions that are available.",
159 "type": "array",
160 "items": {
161 "type": "string",
162 },
163 },
164 },
165 "required": [
166 "serverAddressByClientCIDRs",
167 "versions",
168 ],
169 })
170 }
171}
172
173#[cfg(feature = "schemars08")]
174impl crate::schemars08::JsonSchema for APIVersions {
175 fn schema_name() -> std::string::String {
176 "io.k8s.apimachinery.pkg.apis.meta.v1.APIVersions".into()
177 }
178
179 fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
180 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
181 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
182 description: Some("APIVersions lists the versions that are available, to allow clients to discover the API at /api, which is the root path of the legacy v1 API.".into()),
183 ..Default::default()
184 })),
185 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
186 object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
187 properties: [
188 (
189 "apiVersion".into(),
190 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
191 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
192 description: Some("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".into()),
193 ..Default::default()
194 })),
195 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
196 ..Default::default()
197 }),
198 ),
199 (
200 "kind".into(),
201 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
202 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
203 description: Some("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".into()),
204 ..Default::default()
205 })),
206 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
207 ..Default::default()
208 }),
209 ),
210 (
211 "serverAddressByClientCIDRs".into(),
212 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
213 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
214 description: Some("a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.".into()),
215 ..Default::default()
216 })),
217 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
218 array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
219 items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ServerAddressByClientCIDR>()))),
220 ..Default::default()
221 })),
222 ..Default::default()
223 }),
224 ),
225 (
226 "versions".into(),
227 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
228 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
229 description: Some("versions are the api versions that are available.".into()),
230 ..Default::default()
231 })),
232 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
233 array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
234 items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
235 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
236 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
237 ..Default::default()
238 })
239 ))),
240 ..Default::default()
241 })),
242 ..Default::default()
243 }),
244 ),
245 ].into(),
246 required: [
247 "serverAddressByClientCIDRs".into(),
248 "versions".into(),
249 ].into(),
250 ..Default::default()
251 })),
252 ..Default::default()
253 })
254 }
255}