k8s_openapi/v1_34/api/discovery/v1/
endpoint.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct Endpoint {
6 pub addresses: std::vec::Vec<std::string::String>,
8
9 pub conditions: Option<crate::api::discovery::v1::EndpointConditions>,
11
12 pub deprecated_topology: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
14
15 pub hints: Option<crate::api::discovery::v1::EndpointHints>,
17
18 pub hostname: Option<std::string::String>,
20
21 pub node_name: Option<std::string::String>,
23
24 pub target_ref: Option<crate::api::core::v1::ObjectReference>,
26
27 pub zone: Option<std::string::String>,
29}
30
31impl crate::DeepMerge for Endpoint {
32 fn merge_from(&mut self, other: Self) {
33 crate::merge_strategies::list::set(&mut self.addresses, other.addresses);
34 crate::DeepMerge::merge_from(&mut self.conditions, other.conditions);
35 crate::merge_strategies::map::granular(&mut self.deprecated_topology, other.deprecated_topology, |current_item, other_item| {
36 crate::DeepMerge::merge_from(current_item, other_item);
37 });
38 crate::DeepMerge::merge_from(&mut self.hints, other.hints);
39 crate::DeepMerge::merge_from(&mut self.hostname, other.hostname);
40 crate::DeepMerge::merge_from(&mut self.node_name, other.node_name);
41 crate::DeepMerge::merge_from(&mut self.target_ref, other.target_ref);
42 crate::DeepMerge::merge_from(&mut self.zone, other.zone);
43 }
44}
45
46impl<'de> crate::serde::Deserialize<'de> for Endpoint {
47 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
48 #[allow(non_camel_case_types)]
49 enum Field {
50 Key_addresses,
51 Key_conditions,
52 Key_deprecated_topology,
53 Key_hints,
54 Key_hostname,
55 Key_node_name,
56 Key_target_ref,
57 Key_zone,
58 Other,
59 }
60
61 impl<'de> crate::serde::Deserialize<'de> for Field {
62 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
63 struct Visitor;
64
65 impl crate::serde::de::Visitor<'_> for Visitor {
66 type Value = Field;
67
68 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
69 f.write_str("field identifier")
70 }
71
72 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
73 Ok(match v {
74 "addresses" => Field::Key_addresses,
75 "conditions" => Field::Key_conditions,
76 "deprecatedTopology" => Field::Key_deprecated_topology,
77 "hints" => Field::Key_hints,
78 "hostname" => Field::Key_hostname,
79 "nodeName" => Field::Key_node_name,
80 "targetRef" => Field::Key_target_ref,
81 "zone" => Field::Key_zone,
82 _ => Field::Other,
83 })
84 }
85 }
86
87 deserializer.deserialize_identifier(Visitor)
88 }
89 }
90
91 struct Visitor;
92
93 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
94 type Value = Endpoint;
95
96 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
97 f.write_str("Endpoint")
98 }
99
100 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
101 let mut value_addresses: Option<std::vec::Vec<std::string::String>> = None;
102 let mut value_conditions: Option<crate::api::discovery::v1::EndpointConditions> = None;
103 let mut value_deprecated_topology: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
104 let mut value_hints: Option<crate::api::discovery::v1::EndpointHints> = None;
105 let mut value_hostname: Option<std::string::String> = None;
106 let mut value_node_name: Option<std::string::String> = None;
107 let mut value_target_ref: Option<crate::api::core::v1::ObjectReference> = None;
108 let mut value_zone: Option<std::string::String> = None;
109
110 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
111 match key {
112 Field::Key_addresses => value_addresses = crate::serde::de::MapAccess::next_value(&mut map)?,
113 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
114 Field::Key_deprecated_topology => value_deprecated_topology = crate::serde::de::MapAccess::next_value(&mut map)?,
115 Field::Key_hints => value_hints = crate::serde::de::MapAccess::next_value(&mut map)?,
116 Field::Key_hostname => value_hostname = crate::serde::de::MapAccess::next_value(&mut map)?,
117 Field::Key_node_name => value_node_name = crate::serde::de::MapAccess::next_value(&mut map)?,
118 Field::Key_target_ref => value_target_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
119 Field::Key_zone => value_zone = crate::serde::de::MapAccess::next_value(&mut map)?,
120 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
121 }
122 }
123
124 Ok(Endpoint {
125 addresses: value_addresses.unwrap_or_default(),
126 conditions: value_conditions,
127 deprecated_topology: value_deprecated_topology,
128 hints: value_hints,
129 hostname: value_hostname,
130 node_name: value_node_name,
131 target_ref: value_target_ref,
132 zone: value_zone,
133 })
134 }
135 }
136
137 deserializer.deserialize_struct(
138 "Endpoint",
139 &[
140 "addresses",
141 "conditions",
142 "deprecatedTopology",
143 "hints",
144 "hostname",
145 "nodeName",
146 "targetRef",
147 "zone",
148 ],
149 Visitor,
150 )
151 }
152}
153
154impl crate::serde::Serialize for Endpoint {
155 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
156 let mut state = serializer.serialize_struct(
157 "Endpoint",
158 1 +
159 self.conditions.as_ref().map_or(0, |_| 1) +
160 self.deprecated_topology.as_ref().map_or(0, |_| 1) +
161 self.hints.as_ref().map_or(0, |_| 1) +
162 self.hostname.as_ref().map_or(0, |_| 1) +
163 self.node_name.as_ref().map_or(0, |_| 1) +
164 self.target_ref.as_ref().map_or(0, |_| 1) +
165 self.zone.as_ref().map_or(0, |_| 1),
166 )?;
167 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "addresses", &self.addresses)?;
168 if let Some(value) = &self.conditions {
169 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
170 }
171 if let Some(value) = &self.deprecated_topology {
172 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "deprecatedTopology", value)?;
173 }
174 if let Some(value) = &self.hints {
175 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hints", value)?;
176 }
177 if let Some(value) = &self.hostname {
178 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostname", value)?;
179 }
180 if let Some(value) = &self.node_name {
181 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeName", value)?;
182 }
183 if let Some(value) = &self.target_ref {
184 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "targetRef", value)?;
185 }
186 if let Some(value) = &self.zone {
187 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "zone", value)?;
188 }
189 crate::serde::ser::SerializeStruct::end(state)
190 }
191}
192
193#[cfg(feature = "schemars")]
194impl crate::schemars::JsonSchema for Endpoint {
195 fn schema_name() -> std::borrow::Cow<'static, str> {
196 "io.k8s.api.discovery.v1.Endpoint".into()
197 }
198
199 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
200 crate::schemars::json_schema!({
201 "description": "Endpoint represents a single logical \"backend\" implementing a service.",
202 "type": "object",
203 "properties": {
204 "addresses": {
205 "description": "addresses of this endpoint. For EndpointSlices of addressType \"IPv4\" or \"IPv6\", the values are IP addresses in canonical form. The syntax and semantics of other addressType values are not defined. This must contain at least one address but no more than 100. EndpointSlices generated by the EndpointSlice controller will always have exactly 1 address. No semantics are defined for additional addresses beyond the first, and kube-proxy does not look at them.",
206 "type": "array",
207 "items": {
208 "type": "string",
209 },
210 },
211 "conditions": ({
212 let mut schema_obj = __gen.subschema_for::<crate::api::discovery::v1::EndpointConditions>();
213 schema_obj.ensure_object().insert("description".into(), "conditions contains information about the current status of the endpoint.".into());
214 schema_obj
215 }),
216 "deprecatedTopology": {
217 "description": "deprecatedTopology contains topology information part of the v1beta1 API. This field is deprecated, and will be removed when the v1beta1 API is removed (no sooner than kubernetes v1.24). While this field can hold values, it is not writable through the v1 API, and any attempts to write to it will be silently ignored. Topology information can be found in the zone and nodeName fields instead.",
218 "type": "object",
219 "additionalProperties": {
220 "type": "string",
221 },
222 },
223 "hints": ({
224 let mut schema_obj = __gen.subschema_for::<crate::api::discovery::v1::EndpointHints>();
225 schema_obj.ensure_object().insert("description".into(), "hints contains information associated with how an endpoint should be consumed.".into());
226 schema_obj
227 }),
228 "hostname": {
229 "description": "hostname of this endpoint. This field may be used by consumers of endpoints to distinguish endpoints from each other (e.g. in DNS names). Multiple endpoints which use the same hostname should be considered fungible (e.g. multiple A values in DNS). Must be lowercase and pass DNS Label (RFC 1123) validation.",
230 "type": "string",
231 },
232 "nodeName": {
233 "description": "nodeName represents the name of the Node hosting this endpoint. This can be used to determine endpoints local to a Node.",
234 "type": "string",
235 },
236 "targetRef": ({
237 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ObjectReference>();
238 schema_obj.ensure_object().insert("description".into(), "targetRef is a reference to a Kubernetes object that represents this endpoint.".into());
239 schema_obj
240 }),
241 "zone": {
242 "description": "zone is the name of the Zone this endpoint exists in.",
243 "type": "string",
244 },
245 },
246 "required": [
247 "addresses",
248 ],
249 })
250 }
251}