Skip to main content

k8s_openapi/v1_36/api/apps/v1/
stateful_set_status.rs

1// Generated from definition io.k8s.api.apps.v1.StatefulSetStatus
2
3/// StatefulSetStatus represents the current state of a StatefulSet.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct StatefulSetStatus {
6    /// Total number of available pods (ready for at least minReadySeconds) targeted by this statefulset.
7    pub available_replicas: Option<i32>,
8
9    /// collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.
10    pub collision_count: Option<i32>,
11
12    /// Represents the latest available observations of a statefulset's current state.
13    pub conditions: Option<std::vec::Vec<crate::api::apps::v1::StatefulSetCondition>>,
14
15    /// currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.
16    pub current_replicas: Option<i32>,
17
18    /// currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence \[0,currentReplicas).
19    pub current_revision: Option<std::string::String>,
20
21    /// observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the StatefulSet's generation, which is updated on mutation by the API Server.
22    pub observed_generation: Option<i64>,
23
24    /// readyReplicas is the number of pods created for this StatefulSet with a Ready Condition.
25    pub ready_replicas: Option<i32>,
26
27    /// replicas is the number of Pods created by the StatefulSet controller.
28    pub replicas: i32,
29
30    /// updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence \[replicas-updatedReplicas,replicas)
31    pub update_revision: Option<std::string::String>,
32
33    /// updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.
34    pub updated_replicas: Option<i32>,
35}
36
37impl crate::DeepMerge for StatefulSetStatus {
38    fn merge_from(&mut self, other: Self) {
39        crate::DeepMerge::merge_from(&mut self.available_replicas, other.available_replicas);
40        crate::DeepMerge::merge_from(&mut self.collision_count, other.collision_count);
41        crate::merge_strategies::list::map(
42            &mut self.conditions,
43            other.conditions,
44            &[|lhs, rhs| lhs.type_ == rhs.type_],
45            |current_item, other_item| {
46                crate::DeepMerge::merge_from(current_item, other_item);
47            },
48        );
49        crate::DeepMerge::merge_from(&mut self.current_replicas, other.current_replicas);
50        crate::DeepMerge::merge_from(&mut self.current_revision, other.current_revision);
51        crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
52        crate::DeepMerge::merge_from(&mut self.ready_replicas, other.ready_replicas);
53        crate::DeepMerge::merge_from(&mut self.replicas, other.replicas);
54        crate::DeepMerge::merge_from(&mut self.update_revision, other.update_revision);
55        crate::DeepMerge::merge_from(&mut self.updated_replicas, other.updated_replicas);
56    }
57}
58
59impl<'de> crate::serde::Deserialize<'de> for StatefulSetStatus {
60    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
61        #[allow(non_camel_case_types)]
62        enum Field {
63            Key_available_replicas,
64            Key_collision_count,
65            Key_conditions,
66            Key_current_replicas,
67            Key_current_revision,
68            Key_observed_generation,
69            Key_ready_replicas,
70            Key_replicas,
71            Key_update_revision,
72            Key_updated_replicas,
73            Other,
74        }
75
76        impl<'de> crate::serde::Deserialize<'de> for Field {
77            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
78                struct Visitor;
79
80                impl crate::serde::de::Visitor<'_> for Visitor {
81                    type Value = Field;
82
83                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
84                        f.write_str("field identifier")
85                    }
86
87                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
88                        Ok(match v {
89                            "availableReplicas" => Field::Key_available_replicas,
90                            "collisionCount" => Field::Key_collision_count,
91                            "conditions" => Field::Key_conditions,
92                            "currentReplicas" => Field::Key_current_replicas,
93                            "currentRevision" => Field::Key_current_revision,
94                            "observedGeneration" => Field::Key_observed_generation,
95                            "readyReplicas" => Field::Key_ready_replicas,
96                            "replicas" => Field::Key_replicas,
97                            "updateRevision" => Field::Key_update_revision,
98                            "updatedReplicas" => Field::Key_updated_replicas,
99                            _ => Field::Other,
100                        })
101                    }
102                }
103
104                deserializer.deserialize_identifier(Visitor)
105            }
106        }
107
108        struct Visitor;
109
110        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
111            type Value = StatefulSetStatus;
112
113            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
114                f.write_str("StatefulSetStatus")
115            }
116
117            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
118                let mut value_available_replicas: Option<i32> = None;
119                let mut value_collision_count: Option<i32> = None;
120                let mut value_conditions: Option<std::vec::Vec<crate::api::apps::v1::StatefulSetCondition>> = None;
121                let mut value_current_replicas: Option<i32> = None;
122                let mut value_current_revision: Option<std::string::String> = None;
123                let mut value_observed_generation: Option<i64> = None;
124                let mut value_ready_replicas: Option<i32> = None;
125                let mut value_replicas: Option<i32> = None;
126                let mut value_update_revision: Option<std::string::String> = None;
127                let mut value_updated_replicas: Option<i32> = None;
128
129                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
130                    match key {
131                        Field::Key_available_replicas => value_available_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
132                        Field::Key_collision_count => value_collision_count = crate::serde::de::MapAccess::next_value(&mut map)?,
133                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
134                        Field::Key_current_replicas => value_current_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
135                        Field::Key_current_revision => value_current_revision = crate::serde::de::MapAccess::next_value(&mut map)?,
136                        Field::Key_observed_generation => value_observed_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
137                        Field::Key_ready_replicas => value_ready_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
138                        Field::Key_replicas => value_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
139                        Field::Key_update_revision => value_update_revision = crate::serde::de::MapAccess::next_value(&mut map)?,
140                        Field::Key_updated_replicas => value_updated_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
141                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
142                    }
143                }
144
145                Ok(StatefulSetStatus {
146                    available_replicas: value_available_replicas,
147                    collision_count: value_collision_count,
148                    conditions: value_conditions,
149                    current_replicas: value_current_replicas,
150                    current_revision: value_current_revision,
151                    observed_generation: value_observed_generation,
152                    ready_replicas: value_ready_replicas,
153                    replicas: value_replicas.unwrap_or_default(),
154                    update_revision: value_update_revision,
155                    updated_replicas: value_updated_replicas,
156                })
157            }
158        }
159
160        deserializer.deserialize_struct(
161            "StatefulSetStatus",
162            &[
163                "availableReplicas",
164                "collisionCount",
165                "conditions",
166                "currentReplicas",
167                "currentRevision",
168                "observedGeneration",
169                "readyReplicas",
170                "replicas",
171                "updateRevision",
172                "updatedReplicas",
173            ],
174            Visitor,
175        )
176    }
177}
178
179impl crate::serde::Serialize for StatefulSetStatus {
180    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
181        let mut state = serializer.serialize_struct(
182            "StatefulSetStatus",
183            1 +
184            self.available_replicas.as_ref().map_or(0, |_| 1) +
185            self.collision_count.as_ref().map_or(0, |_| 1) +
186            self.conditions.as_ref().map_or(0, |_| 1) +
187            self.current_replicas.as_ref().map_or(0, |_| 1) +
188            self.current_revision.as_ref().map_or(0, |_| 1) +
189            self.observed_generation.as_ref().map_or(0, |_| 1) +
190            self.ready_replicas.as_ref().map_or(0, |_| 1) +
191            self.update_revision.as_ref().map_or(0, |_| 1) +
192            self.updated_replicas.as_ref().map_or(0, |_| 1),
193        )?;
194        if let Some(value) = &self.available_replicas {
195            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "availableReplicas", value)?;
196        }
197        if let Some(value) = &self.collision_count {
198            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "collisionCount", value)?;
199        }
200        if let Some(value) = &self.conditions {
201            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
202        }
203        if let Some(value) = &self.current_replicas {
204            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "currentReplicas", value)?;
205        }
206        if let Some(value) = &self.current_revision {
207            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "currentRevision", value)?;
208        }
209        if let Some(value) = &self.observed_generation {
210            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
211        }
212        if let Some(value) = &self.ready_replicas {
213            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readyReplicas", value)?;
214        }
215        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "replicas", &self.replicas)?;
216        if let Some(value) = &self.update_revision {
217            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "updateRevision", value)?;
218        }
219        if let Some(value) = &self.updated_replicas {
220            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "updatedReplicas", value)?;
221        }
222        crate::serde::ser::SerializeStruct::end(state)
223    }
224}
225
226#[cfg(feature = "schemars")]
227impl crate::schemars::JsonSchema for StatefulSetStatus {
228    fn schema_name() -> std::borrow::Cow<'static, str> {
229        "io.k8s.api.apps.v1.StatefulSetStatus".into()
230    }
231
232    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
233        crate::schemars::json_schema!({
234            "description": "StatefulSetStatus represents the current state of a StatefulSet.",
235            "type": "object",
236            "properties": {
237                "availableReplicas": {
238                    "description": "Total number of available pods (ready for at least minReadySeconds) targeted by this statefulset.",
239                    "type": "integer",
240                    "format": "int32",
241                },
242                "collisionCount": {
243                    "description": "collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.",
244                    "type": "integer",
245                    "format": "int32",
246                },
247                "conditions": {
248                    "description": "Represents the latest available observations of a statefulset's current state.",
249                    "type": "array",
250                    "items": (__gen.subschema_for::<crate::api::apps::v1::StatefulSetCondition>()),
251                },
252                "currentReplicas": {
253                    "description": "currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.",
254                    "type": "integer",
255                    "format": "int32",
256                },
257                "currentRevision": {
258                    "description": "currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).",
259                    "type": "string",
260                },
261                "observedGeneration": {
262                    "description": "observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the StatefulSet's generation, which is updated on mutation by the API Server.",
263                    "type": "integer",
264                    "format": "int64",
265                },
266                "readyReplicas": {
267                    "description": "readyReplicas is the number of pods created for this StatefulSet with a Ready Condition.",
268                    "type": "integer",
269                    "format": "int32",
270                },
271                "replicas": {
272                    "description": "replicas is the number of Pods created by the StatefulSet controller.",
273                    "type": "integer",
274                    "format": "int32",
275                },
276                "updateRevision": {
277                    "description": "updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)",
278                    "type": "string",
279                },
280                "updatedReplicas": {
281                    "description": "updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.",
282                    "type": "integer",
283                    "format": "int32",
284                },
285            },
286            "required": [
287                "replicas",
288            ],
289        })
290    }
291}
292
293#[cfg(feature = "schemars08")]
294impl crate::schemars08::JsonSchema for StatefulSetStatus {
295    fn schema_name() -> std::string::String {
296        "io.k8s.api.apps.v1.StatefulSetStatus".into()
297    }
298
299    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
300        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
301            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
302                description: Some("StatefulSetStatus represents the current state of a StatefulSet.".into()),
303                ..Default::default()
304            })),
305            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
306            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
307                properties: [
308                    (
309                        "availableReplicas".into(),
310                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
311                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
312                                description: Some("Total number of available pods (ready for at least minReadySeconds) targeted by this statefulset.".into()),
313                                ..Default::default()
314                            })),
315                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
316                            format: Some("int32".into()),
317                            ..Default::default()
318                        }),
319                    ),
320                    (
321                        "collisionCount".into(),
322                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
323                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
324                                description: Some("collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.".into()),
325                                ..Default::default()
326                            })),
327                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
328                            format: Some("int32".into()),
329                            ..Default::default()
330                        }),
331                    ),
332                    (
333                        "conditions".into(),
334                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
335                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
336                                description: Some("Represents the latest available observations of a statefulset's current state.".into()),
337                                ..Default::default()
338                            })),
339                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
340                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
341                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::apps::v1::StatefulSetCondition>()))),
342                                ..Default::default()
343                            })),
344                            ..Default::default()
345                        }),
346                    ),
347                    (
348                        "currentReplicas".into(),
349                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
350                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
351                                description: Some("currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.".into()),
352                                ..Default::default()
353                            })),
354                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
355                            format: Some("int32".into()),
356                            ..Default::default()
357                        }),
358                    ),
359                    (
360                        "currentRevision".into(),
361                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
362                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
363                                description: Some("currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).".into()),
364                                ..Default::default()
365                            })),
366                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
367                            ..Default::default()
368                        }),
369                    ),
370                    (
371                        "observedGeneration".into(),
372                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
373                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
374                                description: Some("observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the StatefulSet's generation, which is updated on mutation by the API Server.".into()),
375                                ..Default::default()
376                            })),
377                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
378                            format: Some("int64".into()),
379                            ..Default::default()
380                        }),
381                    ),
382                    (
383                        "readyReplicas".into(),
384                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
385                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
386                                description: Some("readyReplicas is the number of pods created for this StatefulSet with a Ready Condition.".into()),
387                                ..Default::default()
388                            })),
389                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
390                            format: Some("int32".into()),
391                            ..Default::default()
392                        }),
393                    ),
394                    (
395                        "replicas".into(),
396                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
397                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
398                                description: Some("replicas is the number of Pods created by the StatefulSet controller.".into()),
399                                ..Default::default()
400                            })),
401                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
402                            format: Some("int32".into()),
403                            ..Default::default()
404                        }),
405                    ),
406                    (
407                        "updateRevision".into(),
408                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
409                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
410                                description: Some("updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)".into()),
411                                ..Default::default()
412                            })),
413                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
414                            ..Default::default()
415                        }),
416                    ),
417                    (
418                        "updatedReplicas".into(),
419                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
420                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
421                                description: Some("updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.".into()),
422                                ..Default::default()
423                            })),
424                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
425                            format: Some("int32".into()),
426                            ..Default::default()
427                        }),
428                    ),
429                ].into(),
430                required: [
431                    "replicas".into(),
432                ].into(),
433                ..Default::default()
434            })),
435            ..Default::default()
436        })
437    }
438}