1// Generated from definition io.k8s.api.core.v1.Endpoints
23/// 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
23pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
2425/// 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.
26pub subsets: Option<std::vec::Vec<crate::api::core::v1::EndpointSubset>>,
27}
2829impl crate::Resource for Endpoints {
30const API_VERSION: &'static str = "v1";
31const GROUP: &'static str = "";
32const KIND: &'static str = "Endpoints";
33const VERSION: &'static str = "v1";
34const URL_PATH_SEGMENT: &'static str = "endpoints";
35type Scope = crate::NamespaceResourceScope;
36}
3738impl crate::ListableResource for Endpoints {
39const LIST_KIND: &'static str = "EndpointsList";
40}
4142impl crate::Metadata for Endpoints {
43type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
4445fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
46&self.metadata
47 }
4849fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
50&mut self.metadata
51 }
52}
5354impl crate::DeepMerge for Endpoints {
55fn merge_from(&mut self, other: Self) {
56crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
57crate::merge_strategies::list::atomic(&mut self.subsets, other.subsets);
58 }
59}
6061impl<'de> crate::serde::Deserialize<'de> for Endpoints {
62fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
63#[allow(non_camel_case_types)]
64enum Field {
65 Key_api_version,
66 Key_kind,
67 Key_metadata,
68 Key_subsets,
69 Other,
70 }
7172impl<'de> crate::serde::Deserialize<'de> for Field {
73fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
74struct Visitor;
7576impl crate::serde::de::Visitor<'_> for Visitor {
77type Value = Field;
7879fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
80 f.write_str("field identifier")
81 }
8283fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
84Ok(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 }
9394 deserializer.deserialize_identifier(Visitor)
95 }
96 }
9798struct Visitor;
99100impl<'de> crate::serde::de::Visitor<'de> for Visitor {
101type Value = Endpoints;
102103fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
104 f.write_str(<Self::Value as crate::Resource>::KIND)
105 }
106107fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
108let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
109let mut value_subsets: Option<std::vec::Vec<crate::api::core::v1::EndpointSubset>> = None;
110111while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
112match key {
113 Field::Key_api_version => {
114let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
115if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
116return 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 => {
120let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
121if value_kind != <Self::Value as crate::Resource>::KIND {
122return 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 }
130131Ok(Endpoints {
132 metadata: value_metadata.unwrap_or_default(),
133 subsets: value_subsets,
134 })
135 }
136 }
137138 deserializer.deserialize_struct(
139 <Self as crate::Resource>::KIND,
140&[
141"apiVersion",
142"kind",
143"metadata",
144"subsets",
145 ],
146 Visitor,
147 )
148 }
149}
150151impl crate::serde::Serialize for Endpoints {
152fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
153let mut state = serializer.serialize_struct(
154 <Self as crate::Resource>::KIND,
1553 +
156self.subsets.as_ref().map_or(0, |_| 1),
157 )?;
158crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
159crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
160crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
161if let Some(value) = &self.subsets {
162crate::serde::ser::SerializeStruct::serialize_field(&mut state, "subsets", value)?;
163 }
164crate::serde::ser::SerializeStruct::end(state)
165 }
166}
167168#[cfg(feature = "schemars")]
169impl crate::schemars::JsonSchema for Endpoints {
170fn schema_name() -> std::string::String {
171"io.k8s.api.core.v1.Endpoints".into()
172 }
173174fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
175crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
176 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
177 description: Some("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.".into()),
178 ..Default::default()
179 })),
180 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
181 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
182 properties: [
183 (
184"apiVersion".into(),
185crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
186 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
187 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()),
188 ..Default::default()
189 })),
190 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
191 ..Default::default()
192 }),
193 ),
194 (
195"kind".into(),
196crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
197 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
198 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()),
199 ..Default::default()
200 })),
201 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
202 ..Default::default()
203 }),
204 ),
205 (
206"metadata".into(),
207 {
208let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>().into_object();
209 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
210 description: Some("Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata".into()),
211 ..Default::default()
212 }));
213crate::schemars::schema::Schema::Object(schema_obj)
214 },
215 ),
216 (
217"subsets".into(),
218crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
219 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
220 description: Some("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.".into()),
221 ..Default::default()
222 })),
223 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
224 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
225 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::core::v1::EndpointSubset>()))),
226 ..Default::default()
227 })),
228 ..Default::default()
229 }),
230 ),
231 ].into(),
232 required: [
233"metadata".into(),
234 ].into(),
235 ..Default::default()
236 })),
237 ..Default::default()
238 })
239 }
240}