k8s_openapi/v1_33/api/discovery/v1/
endpoint_conditions.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct EndpointConditions {
6 pub ready: Option<bool>,
8
9 pub serving: Option<bool>,
11
12 pub terminating: Option<bool>,
14}
15
16impl crate::DeepMerge for EndpointConditions {
17 fn merge_from(&mut self, other: Self) {
18 crate::DeepMerge::merge_from(&mut self.ready, other.ready);
19 crate::DeepMerge::merge_from(&mut self.serving, other.serving);
20 crate::DeepMerge::merge_from(&mut self.terminating, other.terminating);
21 }
22}
23
24impl<'de> crate::serde::Deserialize<'de> for EndpointConditions {
25 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26 #[allow(non_camel_case_types)]
27 enum Field {
28 Key_ready,
29 Key_serving,
30 Key_terminating,
31 Other,
32 }
33
34 impl<'de> crate::serde::Deserialize<'de> for Field {
35 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36 struct Visitor;
37
38 impl crate::serde::de::Visitor<'_> for Visitor {
39 type Value = Field;
40
41 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
42 f.write_str("field identifier")
43 }
44
45 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
46 Ok(match v {
47 "ready" => Field::Key_ready,
48 "serving" => Field::Key_serving,
49 "terminating" => Field::Key_terminating,
50 _ => Field::Other,
51 })
52 }
53 }
54
55 deserializer.deserialize_identifier(Visitor)
56 }
57 }
58
59 struct Visitor;
60
61 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62 type Value = EndpointConditions;
63
64 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65 f.write_str("EndpointConditions")
66 }
67
68 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69 let mut value_ready: Option<bool> = None;
70 let mut value_serving: Option<bool> = None;
71 let mut value_terminating: Option<bool> = None;
72
73 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
74 match key {
75 Field::Key_ready => value_ready = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Key_serving => value_serving = crate::serde::de::MapAccess::next_value(&mut map)?,
77 Field::Key_terminating => value_terminating = crate::serde::de::MapAccess::next_value(&mut map)?,
78 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
79 }
80 }
81
82 Ok(EndpointConditions {
83 ready: value_ready,
84 serving: value_serving,
85 terminating: value_terminating,
86 })
87 }
88 }
89
90 deserializer.deserialize_struct(
91 "EndpointConditions",
92 &[
93 "ready",
94 "serving",
95 "terminating",
96 ],
97 Visitor,
98 )
99 }
100}
101
102impl crate::serde::Serialize for EndpointConditions {
103 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
104 let mut state = serializer.serialize_struct(
105 "EndpointConditions",
106 self.ready.as_ref().map_or(0, |_| 1) +
107 self.serving.as_ref().map_or(0, |_| 1) +
108 self.terminating.as_ref().map_or(0, |_| 1),
109 )?;
110 if let Some(value) = &self.ready {
111 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ready", value)?;
112 }
113 if let Some(value) = &self.serving {
114 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serving", value)?;
115 }
116 if let Some(value) = &self.terminating {
117 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminating", value)?;
118 }
119 crate::serde::ser::SerializeStruct::end(state)
120 }
121}
122
123#[cfg(feature = "schemars")]
124impl crate::schemars::JsonSchema for EndpointConditions {
125 fn schema_name() -> std::string::String {
126 "io.k8s.api.discovery.v1.EndpointConditions".into()
127 }
128
129 fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
130 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
131 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
132 description: Some("EndpointConditions represents the current condition of an endpoint.".into()),
133 ..Default::default()
134 })),
135 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
136 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
137 properties: [
138 (
139 "ready".into(),
140 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
141 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
142 description: Some("ready indicates that this endpoint is ready to receive traffic, according to whatever system is managing the endpoint. A nil value should be interpreted as \"true\". In general, an endpoint should be marked ready if it is serving and not terminating, though this can be overridden in some cases, such as when the associated Service has set the publishNotReadyAddresses flag.".into()),
143 ..Default::default()
144 })),
145 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Boolean))),
146 ..Default::default()
147 }),
148 ),
149 (
150 "serving".into(),
151 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
152 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
153 description: Some("serving indicates that this endpoint is able to receive traffic, according to whatever system is managing the endpoint. For endpoints backed by pods, the EndpointSlice controller will mark the endpoint as serving if the pod's Ready condition is True. A nil value should be interpreted as \"true\".".into()),
154 ..Default::default()
155 })),
156 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Boolean))),
157 ..Default::default()
158 }),
159 ),
160 (
161 "terminating".into(),
162 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
163 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
164 description: Some("terminating indicates that this endpoint is terminating. A nil value should be interpreted as \"false\".".into()),
165 ..Default::default()
166 })),
167 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Boolean))),
168 ..Default::default()
169 }),
170 ),
171 ].into(),
172 ..Default::default()
173 })),
174 ..Default::default()
175 })
176 }
177}