k8s_openapi/v1_33/api/apps/v1/
replica_set_status.rs

1// Generated from definition io.k8s.api.apps.v1.ReplicaSetStatus
2
3/// ReplicaSetStatus represents the current status of a ReplicaSet.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ReplicaSetStatus {
6    /// The number of available non-terminating pods (ready for at least minReadySeconds) for this replica set.
7    pub available_replicas: Option<i32>,
8
9    /// Represents the latest available observations of a replica set's current state.
10    pub conditions: Option<std::vec::Vec<crate::api::apps::v1::ReplicaSetCondition>>,
11
12    /// The number of non-terminating pods that have labels matching the labels of the pod template of the replicaset.
13    pub fully_labeled_replicas: Option<i32>,
14
15    /// ObservedGeneration reflects the generation of the most recently observed ReplicaSet.
16    pub observed_generation: Option<i64>,
17
18    /// The number of non-terminating pods targeted by this ReplicaSet with a Ready Condition.
19    pub ready_replicas: Option<i32>,
20
21    /// Replicas is the most recently observed number of non-terminating pods. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset
22    pub replicas: i32,
23
24    /// The number of terminating pods for this replica set. Terminating pods have a non-null .metadata.deletionTimestamp and have not yet reached the Failed or Succeeded .status.phase.
25    ///
26    /// This is an alpha field. Enable DeploymentReplicaSetTerminatingReplicas to be able to use this field.
27    pub terminating_replicas: Option<i32>,
28}
29
30impl crate::DeepMerge for ReplicaSetStatus {
31    fn merge_from(&mut self, other: Self) {
32        crate::DeepMerge::merge_from(&mut self.available_replicas, other.available_replicas);
33        crate::merge_strategies::list::map(
34            &mut self.conditions,
35            other.conditions,
36            &[|lhs, rhs| lhs.type_ == rhs.type_],
37            |current_item, other_item| {
38                crate::DeepMerge::merge_from(current_item, other_item);
39            },
40        );
41        crate::DeepMerge::merge_from(&mut self.fully_labeled_replicas, other.fully_labeled_replicas);
42        crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
43        crate::DeepMerge::merge_from(&mut self.ready_replicas, other.ready_replicas);
44        crate::DeepMerge::merge_from(&mut self.replicas, other.replicas);
45        crate::DeepMerge::merge_from(&mut self.terminating_replicas, other.terminating_replicas);
46    }
47}
48
49impl<'de> crate::serde::Deserialize<'de> for ReplicaSetStatus {
50    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
51        #[allow(non_camel_case_types)]
52        enum Field {
53            Key_available_replicas,
54            Key_conditions,
55            Key_fully_labeled_replicas,
56            Key_observed_generation,
57            Key_ready_replicas,
58            Key_replicas,
59            Key_terminating_replicas,
60            Other,
61        }
62
63        impl<'de> crate::serde::Deserialize<'de> for Field {
64            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
65                struct Visitor;
66
67                impl crate::serde::de::Visitor<'_> for Visitor {
68                    type Value = Field;
69
70                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71                        f.write_str("field identifier")
72                    }
73
74                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
75                        Ok(match v {
76                            "availableReplicas" => Field::Key_available_replicas,
77                            "conditions" => Field::Key_conditions,
78                            "fullyLabeledReplicas" => Field::Key_fully_labeled_replicas,
79                            "observedGeneration" => Field::Key_observed_generation,
80                            "readyReplicas" => Field::Key_ready_replicas,
81                            "replicas" => Field::Key_replicas,
82                            "terminatingReplicas" => Field::Key_terminating_replicas,
83                            _ => Field::Other,
84                        })
85                    }
86                }
87
88                deserializer.deserialize_identifier(Visitor)
89            }
90        }
91
92        struct Visitor;
93
94        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
95            type Value = ReplicaSetStatus;
96
97            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
98                f.write_str("ReplicaSetStatus")
99            }
100
101            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
102                let mut value_available_replicas: Option<i32> = None;
103                let mut value_conditions: Option<std::vec::Vec<crate::api::apps::v1::ReplicaSetCondition>> = None;
104                let mut value_fully_labeled_replicas: Option<i32> = None;
105                let mut value_observed_generation: Option<i64> = None;
106                let mut value_ready_replicas: Option<i32> = None;
107                let mut value_replicas: Option<i32> = None;
108                let mut value_terminating_replicas: Option<i32> = None;
109
110                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
111                    match key {
112                        Field::Key_available_replicas => value_available_replicas = 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_fully_labeled_replicas => value_fully_labeled_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
115                        Field::Key_observed_generation => value_observed_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
116                        Field::Key_ready_replicas => value_ready_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
117                        Field::Key_replicas => value_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
118                        Field::Key_terminating_replicas => value_terminating_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
119                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
120                    }
121                }
122
123                Ok(ReplicaSetStatus {
124                    available_replicas: value_available_replicas,
125                    conditions: value_conditions,
126                    fully_labeled_replicas: value_fully_labeled_replicas,
127                    observed_generation: value_observed_generation,
128                    ready_replicas: value_ready_replicas,
129                    replicas: value_replicas.unwrap_or_default(),
130                    terminating_replicas: value_terminating_replicas,
131                })
132            }
133        }
134
135        deserializer.deserialize_struct(
136            "ReplicaSetStatus",
137            &[
138                "availableReplicas",
139                "conditions",
140                "fullyLabeledReplicas",
141                "observedGeneration",
142                "readyReplicas",
143                "replicas",
144                "terminatingReplicas",
145            ],
146            Visitor,
147        )
148    }
149}
150
151impl crate::serde::Serialize for ReplicaSetStatus {
152    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
153        let mut state = serializer.serialize_struct(
154            "ReplicaSetStatus",
155            1 +
156            self.available_replicas.as_ref().map_or(0, |_| 1) +
157            self.conditions.as_ref().map_or(0, |_| 1) +
158            self.fully_labeled_replicas.as_ref().map_or(0, |_| 1) +
159            self.observed_generation.as_ref().map_or(0, |_| 1) +
160            self.ready_replicas.as_ref().map_or(0, |_| 1) +
161            self.terminating_replicas.as_ref().map_or(0, |_| 1),
162        )?;
163        if let Some(value) = &self.available_replicas {
164            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "availableReplicas", value)?;
165        }
166        if let Some(value) = &self.conditions {
167            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
168        }
169        if let Some(value) = &self.fully_labeled_replicas {
170            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fullyLabeledReplicas", value)?;
171        }
172        if let Some(value) = &self.observed_generation {
173            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
174        }
175        if let Some(value) = &self.ready_replicas {
176            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readyReplicas", value)?;
177        }
178        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "replicas", &self.replicas)?;
179        if let Some(value) = &self.terminating_replicas {
180            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminatingReplicas", value)?;
181        }
182        crate::serde::ser::SerializeStruct::end(state)
183    }
184}
185
186#[cfg(feature = "schemars")]
187impl crate::schemars::JsonSchema for ReplicaSetStatus {
188    fn schema_name() -> std::string::String {
189        "io.k8s.api.apps.v1.ReplicaSetStatus".into()
190    }
191
192    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
193        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
194            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
195                description: Some("ReplicaSetStatus represents the current status of a ReplicaSet.".into()),
196                ..Default::default()
197            })),
198            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
199            object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
200                properties: [
201                    (
202                        "availableReplicas".into(),
203                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
204                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
205                                description: Some("The number of available non-terminating pods (ready for at least minReadySeconds) for this replica set.".into()),
206                                ..Default::default()
207                            })),
208                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
209                            format: Some("int32".into()),
210                            ..Default::default()
211                        }),
212                    ),
213                    (
214                        "conditions".into(),
215                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
216                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
217                                description: Some("Represents the latest available observations of a replica set's current state.".into()),
218                                ..Default::default()
219                            })),
220                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
221                            array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
222                                items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::apps::v1::ReplicaSetCondition>()))),
223                                ..Default::default()
224                            })),
225                            ..Default::default()
226                        }),
227                    ),
228                    (
229                        "fullyLabeledReplicas".into(),
230                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
231                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
232                                description: Some("The number of non-terminating pods that have labels matching the labels of the pod template of the replicaset.".into()),
233                                ..Default::default()
234                            })),
235                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
236                            format: Some("int32".into()),
237                            ..Default::default()
238                        }),
239                    ),
240                    (
241                        "observedGeneration".into(),
242                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
243                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
244                                description: Some("ObservedGeneration reflects the generation of the most recently observed ReplicaSet.".into()),
245                                ..Default::default()
246                            })),
247                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
248                            format: Some("int64".into()),
249                            ..Default::default()
250                        }),
251                    ),
252                    (
253                        "readyReplicas".into(),
254                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
255                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
256                                description: Some("The number of non-terminating pods targeted by this ReplicaSet with a Ready Condition.".into()),
257                                ..Default::default()
258                            })),
259                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
260                            format: Some("int32".into()),
261                            ..Default::default()
262                        }),
263                    ),
264                    (
265                        "replicas".into(),
266                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
267                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
268                                description: Some("Replicas is the most recently observed number of non-terminating pods. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset".into()),
269                                ..Default::default()
270                            })),
271                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
272                            format: Some("int32".into()),
273                            ..Default::default()
274                        }),
275                    ),
276                    (
277                        "terminatingReplicas".into(),
278                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
279                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
280                                description: Some("The number of terminating pods for this replica set. Terminating pods have a non-null .metadata.deletionTimestamp and have not yet reached the Failed or Succeeded .status.phase.\n\nThis is an alpha field. Enable DeploymentReplicaSetTerminatingReplicas to be able to use this field.".into()),
281                                ..Default::default()
282                            })),
283                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
284                            format: Some("int32".into()),
285                            ..Default::default()
286                        }),
287                    ),
288                ].into(),
289                required: [
290                    "replicas".into(),
291                ].into(),
292                ..Default::default()
293            })),
294            ..Default::default()
295        })
296    }
297}