1// Generated from definition io.k8s.api.discovery.v1.EndpointSlice
23/// EndpointSlice represents a set of service endpoints. Most EndpointSlices are created by the EndpointSlice controller to represent the Pods selected by Service objects. For a given service there may be multiple EndpointSlice objects which must be joined to produce the full set of endpoints; you can find all of the slices for a given service by listing EndpointSlices in the service's namespace whose `kubernetes.io/service-name` label contains the service's name.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct EndpointSlice {
6/// addressType specifies the type of address carried by this EndpointSlice. All addresses in this slice must be the same type. This field is immutable after creation. The following address types are currently supported: * IPv4: Represents an IPv4 Address. * IPv6: Represents an IPv6 Address. * FQDN: Represents a Fully Qualified Domain Name. (Deprecated) The EndpointSlice controller only generates, and kube-proxy only processes, slices of addressType "IPv4" and "IPv6". No semantics are defined for the "FQDN" type.
7pub address_type: std::string::String,
89/// endpoints is a list of unique endpoints in this slice. Each slice may include a maximum of 1000 endpoints.
10pub endpoints: std::vec::Vec<crate::api::discovery::v1::Endpoint>,
1112/// Standard object's metadata.
13pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
1415/// ports specifies the list of network ports exposed by each endpoint in this slice. Each port must have a unique name. Each slice may include a maximum of 100 ports. Services always have at least 1 port, so EndpointSlices generated by the EndpointSlice controller will likewise always have at least 1 port. EndpointSlices used for other purposes may have an empty ports list.
16pub ports: Option<std::vec::Vec<crate::api::discovery::v1::EndpointPort>>,
17}
1819impl crate::Resource for EndpointSlice {
20const API_VERSION: &'static str = "discovery.k8s.io/v1";
21const GROUP: &'static str = "discovery.k8s.io";
22const KIND: &'static str = "EndpointSlice";
23const VERSION: &'static str = "v1";
24const URL_PATH_SEGMENT: &'static str = "endpointslices";
25type Scope = crate::NamespaceResourceScope;
26}
2728impl crate::ListableResource for EndpointSlice {
29const LIST_KIND: &'static str = "EndpointSliceList";
30}
3132impl crate::Metadata for EndpointSlice {
33type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
3435fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
36&self.metadata
37 }
3839fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
40&mut self.metadata
41 }
42}
4344impl crate::DeepMerge for EndpointSlice {
45fn merge_from(&mut self, other: Self) {
46crate::DeepMerge::merge_from(&mut self.address_type, other.address_type);
47crate::merge_strategies::list::atomic(&mut self.endpoints, other.endpoints);
48crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
49crate::merge_strategies::list::atomic(&mut self.ports, other.ports);
50 }
51}
5253impl<'de> crate::serde::Deserialize<'de> for EndpointSlice {
54fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
55#[allow(non_camel_case_types)]
56enum Field {
57 Key_api_version,
58 Key_kind,
59 Key_address_type,
60 Key_endpoints,
61 Key_metadata,
62 Key_ports,
63 Other,
64 }
6566impl<'de> crate::serde::Deserialize<'de> for Field {
67fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
68struct Visitor;
6970impl crate::serde::de::Visitor<'_> for Visitor {
71type Value = Field;
7273fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
74 f.write_str("field identifier")
75 }
7677fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
78Ok(match v {
79"apiVersion" => Field::Key_api_version,
80"kind" => Field::Key_kind,
81"addressType" => Field::Key_address_type,
82"endpoints" => Field::Key_endpoints,
83"metadata" => Field::Key_metadata,
84"ports" => Field::Key_ports,
85_ => Field::Other,
86 })
87 }
88 }
8990 deserializer.deserialize_identifier(Visitor)
91 }
92 }
9394struct Visitor;
9596impl<'de> crate::serde::de::Visitor<'de> for Visitor {
97type Value = EndpointSlice;
9899fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
100 f.write_str(<Self::Value as crate::Resource>::KIND)
101 }
102103fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
104let mut value_address_type: Option<std::string::String> = None;
105let mut value_endpoints: Option<std::vec::Vec<crate::api::discovery::v1::Endpoint>> = None;
106let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
107let mut value_ports: Option<std::vec::Vec<crate::api::discovery::v1::EndpointPort>> = None;
108109while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
110match key {
111 Field::Key_api_version => {
112let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
113if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
114return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
115 }
116 },
117 Field::Key_kind => {
118let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
119if value_kind != <Self::Value as crate::Resource>::KIND {
120return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
121 }
122 },
123 Field::Key_address_type => value_address_type = crate::serde::de::MapAccess::next_value(&mut map)?,
124 Field::Key_endpoints => value_endpoints = crate::serde::de::MapAccess::next_value(&mut map)?,
125 Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
126 Field::Key_ports => value_ports = 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(EndpointSlice {
132 address_type: value_address_type.unwrap_or_default(),
133 endpoints: value_endpoints.unwrap_or_default(),
134 metadata: value_metadata.unwrap_or_default(),
135 ports: value_ports,
136 })
137 }
138 }
139140 deserializer.deserialize_struct(
141 <Self as crate::Resource>::KIND,
142&[
143"apiVersion",
144"kind",
145"addressType",
146"endpoints",
147"metadata",
148"ports",
149 ],
150 Visitor,
151 )
152 }
153}
154155impl crate::serde::Serialize for EndpointSlice {
156fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
157let mut state = serializer.serialize_struct(
158 <Self as crate::Resource>::KIND,
1595 +
160self.ports.as_ref().map_or(0, |_| 1),
161 )?;
162crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
163crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
164crate::serde::ser::SerializeStruct::serialize_field(&mut state, "addressType", &self.address_type)?;
165crate::serde::ser::SerializeStruct::serialize_field(&mut state, "endpoints", &self.endpoints)?;
166crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
167if let Some(value) = &self.ports {
168crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ports", value)?;
169 }
170crate::serde::ser::SerializeStruct::end(state)
171 }
172}
173174#[cfg(feature = "schemars")]
175impl crate::schemars::JsonSchema for EndpointSlice {
176fn schema_name() -> std::string::String {
177"io.k8s.api.discovery.v1.EndpointSlice".into()
178 }
179180fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
181crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
182 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
183 description: Some("EndpointSlice represents a set of service endpoints. Most EndpointSlices are created by the EndpointSlice controller to represent the Pods selected by Service objects. For a given service there may be multiple EndpointSlice objects which must be joined to produce the full set of endpoints; you can find all of the slices for a given service by listing EndpointSlices in the service's namespace whose `kubernetes.io/service-name` label contains the service's name.".into()),
184 ..Default::default()
185 })),
186 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
187 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
188 properties: [
189 (
190"addressType".into(),
191crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
192 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
193 description: Some("addressType specifies the type of address carried by this EndpointSlice. All addresses in this slice must be the same type. This field is immutable after creation. The following address types are currently supported: * IPv4: Represents an IPv4 Address. * IPv6: Represents an IPv6 Address. * FQDN: Represents a Fully Qualified Domain Name. (Deprecated) The EndpointSlice controller only generates, and kube-proxy only processes, slices of addressType \"IPv4\" and \"IPv6\". No semantics are defined for the \"FQDN\" type.".into()),
194 ..Default::default()
195 })),
196 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
197 ..Default::default()
198 }),
199 ),
200 (
201"apiVersion".into(),
202crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
203 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
204 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()),
205 ..Default::default()
206 })),
207 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
208 ..Default::default()
209 }),
210 ),
211 (
212"endpoints".into(),
213crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
214 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
215 description: Some("endpoints is a list of unique endpoints in this slice. Each slice may include a maximum of 1000 endpoints.".into()),
216 ..Default::default()
217 })),
218 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
219 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
220 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::discovery::v1::Endpoint>()))),
221 ..Default::default()
222 })),
223 ..Default::default()
224 }),
225 ),
226 (
227"kind".into(),
228crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
229 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
230 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()),
231 ..Default::default()
232 })),
233 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
234 ..Default::default()
235 }),
236 ),
237 (
238"metadata".into(),
239 {
240let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>().into_object();
241 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
242 description: Some("Standard object's metadata.".into()),
243 ..Default::default()
244 }));
245crate::schemars::schema::Schema::Object(schema_obj)
246 },
247 ),
248 (
249"ports".into(),
250crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
251 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
252 description: Some("ports specifies the list of network ports exposed by each endpoint in this slice. Each port must have a unique name. Each slice may include a maximum of 100 ports. Services always have at least 1 port, so EndpointSlices generated by the EndpointSlice controller will likewise always have at least 1 port. EndpointSlices used for other purposes may have an empty ports list.".into()),
253 ..Default::default()
254 })),
255 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
256 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
257 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::discovery::v1::EndpointPort>()))),
258 ..Default::default()
259 })),
260 ..Default::default()
261 }),
262 ),
263 ].into(),
264 required: [
265"addressType".into(),
266"endpoints".into(),
267"metadata".into(),
268 ].into(),
269 ..Default::default()
270 })),
271 ..Default::default()
272 })
273 }
274}