1// Generated from definition io.k8s.api.discovery.v1.EndpointConditions
23/// EndpointConditions represents the current condition of an endpoint.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct EndpointConditions {
6/// 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.
7pub ready: Option<bool>,
89/// 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".
10pub serving: Option<bool>,
1112/// terminating indicates that this endpoint is terminating. A nil value should be interpreted as "false".
13pub terminating: Option<bool>,
14}
1516impl crate::DeepMerge for EndpointConditions {
17fn merge_from(&mut self, other: Self) {
18crate::DeepMerge::merge_from(&mut self.ready, other.ready);
19crate::DeepMerge::merge_from(&mut self.serving, other.serving);
20crate::DeepMerge::merge_from(&mut self.terminating, other.terminating);
21 }
22}
2324impl<'de> crate::serde::Deserialize<'de> for EndpointConditions {
25fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26#[allow(non_camel_case_types)]
27enum Field {
28 Key_ready,
29 Key_serving,
30 Key_terminating,
31 Other,
32 }
3334impl<'de> crate::serde::Deserialize<'de> for Field {
35fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36struct Visitor;
3738impl crate::serde::de::Visitor<'_> for Visitor {
39type Value = Field;
4041fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
42 f.write_str("field identifier")
43 }
4445fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
46Ok(match v {
47"ready" => Field::Key_ready,
48"serving" => Field::Key_serving,
49"terminating" => Field::Key_terminating,
50_ => Field::Other,
51 })
52 }
53 }
5455 deserializer.deserialize_identifier(Visitor)
56 }
57 }
5859struct Visitor;
6061impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62type Value = EndpointConditions;
6364fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65 f.write_str("EndpointConditions")
66 }
6768fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69let mut value_ready: Option<bool> = None;
70let mut value_serving: Option<bool> = None;
71let mut value_terminating: Option<bool> = None;
7273while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
74match 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 }
8182Ok(EndpointConditions {
83 ready: value_ready,
84 serving: value_serving,
85 terminating: value_terminating,
86 })
87 }
88 }
8990 deserializer.deserialize_struct(
91"EndpointConditions",
92&[
93"ready",
94"serving",
95"terminating",
96 ],
97 Visitor,
98 )
99 }
100}
101102impl crate::serde::Serialize for EndpointConditions {
103fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
104let mut state = serializer.serialize_struct(
105"EndpointConditions",
106self.ready.as_ref().map_or(0, |_| 1) +
107self.serving.as_ref().map_or(0, |_| 1) +
108self.terminating.as_ref().map_or(0, |_| 1),
109 )?;
110if let Some(value) = &self.ready {
111crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ready", value)?;
112 }
113if let Some(value) = &self.serving {
114crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serving", value)?;
115 }
116if let Some(value) = &self.terminating {
117crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminating", value)?;
118 }
119crate::serde::ser::SerializeStruct::end(state)
120 }
121}
122123#[cfg(feature = "schemars")]
124impl crate::schemars::JsonSchema for EndpointConditions {
125fn schema_name() -> std::string::String {
126"io.k8s.api.discovery.v1.EndpointConditions".into()
127 }
128129fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
130crate::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(),
140crate::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(),
151crate::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(),
162crate::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}