openshift_openapi/v4_5/api/apps/v1/
deployment_config_status.rs

1// Generated from definition com.github.openshift.api.apps.v1.DeploymentConfigStatus
2
3/// DeploymentConfigStatus represents the current deployment state.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeploymentConfigStatus {
6    /// AvailableReplicas is the total number of available pods targeted by this deployment config.
7    pub available_replicas: i32,
8
9    /// Conditions represents the latest available observations of a deployment config's current state.
10    pub conditions: Option<Vec<crate::api::apps::v1::DeploymentCondition>>,
11
12    /// Details are the reasons for the update to this deployment config. This could be based on a change made by the user or caused by an automatic trigger
13    pub details: Option<crate::api::apps::v1::DeploymentDetails>,
14
15    /// LatestVersion is used to determine whether the current deployment associated with a deployment config is out of sync.
16    pub latest_version: i64,
17
18    /// ObservedGeneration is the most recent generation observed by the deployment config controller.
19    pub observed_generation: i64,
20
21    /// Total number of ready pods targeted by this deployment.
22    pub ready_replicas: Option<i32>,
23
24    /// Replicas is the total number of pods targeted by this deployment config.
25    pub replicas: i32,
26
27    /// UnavailableReplicas is the total number of unavailable pods targeted by this deployment config.
28    pub unavailable_replicas: i32,
29
30    /// UpdatedReplicas is the total number of non-terminated pods targeted by this deployment config that have the desired template spec.
31    pub updated_replicas: i32,
32}
33
34impl<'de> serde::Deserialize<'de> for DeploymentConfigStatus {
35    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
36        #[allow(non_camel_case_types)]
37        enum Field {
38            Key_available_replicas,
39            Key_conditions,
40            Key_details,
41            Key_latest_version,
42            Key_observed_generation,
43            Key_ready_replicas,
44            Key_replicas,
45            Key_unavailable_replicas,
46            Key_updated_replicas,
47            Other,
48        }
49
50        impl<'de> serde::Deserialize<'de> for Field {
51            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
52                struct Visitor;
53
54                impl<'de> serde::de::Visitor<'de> for Visitor {
55                    type Value = Field;
56
57                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
58                        f.write_str("field identifier")
59                    }
60
61                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
62                        Ok(match v {
63                            "availableReplicas" => Field::Key_available_replicas,
64                            "conditions" => Field::Key_conditions,
65                            "details" => Field::Key_details,
66                            "latestVersion" => Field::Key_latest_version,
67                            "observedGeneration" => Field::Key_observed_generation,
68                            "readyReplicas" => Field::Key_ready_replicas,
69                            "replicas" => Field::Key_replicas,
70                            "unavailableReplicas" => Field::Key_unavailable_replicas,
71                            "updatedReplicas" => Field::Key_updated_replicas,
72                            _ => Field::Other,
73                        })
74                    }
75                }
76
77                deserializer.deserialize_identifier(Visitor)
78            }
79        }
80
81        struct Visitor;
82
83        impl<'de> serde::de::Visitor<'de> for Visitor {
84            type Value = DeploymentConfigStatus;
85
86            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
87                f.write_str("DeploymentConfigStatus")
88            }
89
90            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
91                let mut value_available_replicas: Option<i32> = None;
92                let mut value_conditions: Option<Vec<crate::api::apps::v1::DeploymentCondition>> = None;
93                let mut value_details: Option<crate::api::apps::v1::DeploymentDetails> = None;
94                let mut value_latest_version: Option<i64> = None;
95                let mut value_observed_generation: Option<i64> = None;
96                let mut value_ready_replicas: Option<i32> = None;
97                let mut value_replicas: Option<i32> = None;
98                let mut value_unavailable_replicas: Option<i32> = None;
99                let mut value_updated_replicas: Option<i32> = None;
100
101                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
102                    match key {
103                        Field::Key_available_replicas => value_available_replicas = Some(serde::de::MapAccess::next_value(&mut map)?),
104                        Field::Key_conditions => value_conditions = serde::de::MapAccess::next_value(&mut map)?,
105                        Field::Key_details => value_details = serde::de::MapAccess::next_value(&mut map)?,
106                        Field::Key_latest_version => value_latest_version = Some(serde::de::MapAccess::next_value(&mut map)?),
107                        Field::Key_observed_generation => value_observed_generation = Some(serde::de::MapAccess::next_value(&mut map)?),
108                        Field::Key_ready_replicas => value_ready_replicas = serde::de::MapAccess::next_value(&mut map)?,
109                        Field::Key_replicas => value_replicas = Some(serde::de::MapAccess::next_value(&mut map)?),
110                        Field::Key_unavailable_replicas => value_unavailable_replicas = Some(serde::de::MapAccess::next_value(&mut map)?),
111                        Field::Key_updated_replicas => value_updated_replicas = Some(serde::de::MapAccess::next_value(&mut map)?),
112                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
113                    }
114                }
115
116                Ok(DeploymentConfigStatus {
117                    available_replicas: value_available_replicas.ok_or_else(|| serde::de::Error::missing_field("availableReplicas"))?,
118                    conditions: value_conditions,
119                    details: value_details,
120                    latest_version: value_latest_version.ok_or_else(|| serde::de::Error::missing_field("latestVersion"))?,
121                    observed_generation: value_observed_generation.ok_or_else(|| serde::de::Error::missing_field("observedGeneration"))?,
122                    ready_replicas: value_ready_replicas,
123                    replicas: value_replicas.ok_or_else(|| serde::de::Error::missing_field("replicas"))?,
124                    unavailable_replicas: value_unavailable_replicas.ok_or_else(|| serde::de::Error::missing_field("unavailableReplicas"))?,
125                    updated_replicas: value_updated_replicas.ok_or_else(|| serde::de::Error::missing_field("updatedReplicas"))?,
126                })
127            }
128        }
129
130        deserializer.deserialize_struct(
131            "DeploymentConfigStatus",
132            &[
133                "availableReplicas",
134                "conditions",
135                "details",
136                "latestVersion",
137                "observedGeneration",
138                "readyReplicas",
139                "replicas",
140                "unavailableReplicas",
141                "updatedReplicas",
142            ],
143            Visitor,
144        )
145    }
146}
147
148impl serde::Serialize for DeploymentConfigStatus {
149    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
150        let mut state = serializer.serialize_struct(
151            "DeploymentConfigStatus",
152            6 +
153            self.conditions.as_ref().map_or(0, |_| 1) +
154            self.details.as_ref().map_or(0, |_| 1) +
155            self.ready_replicas.as_ref().map_or(0, |_| 1),
156        )?;
157        serde::ser::SerializeStruct::serialize_field(&mut state, "availableReplicas", &self.available_replicas)?;
158        if let Some(value) = &self.conditions {
159            serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
160        }
161        if let Some(value) = &self.details {
162            serde::ser::SerializeStruct::serialize_field(&mut state, "details", value)?;
163        }
164        serde::ser::SerializeStruct::serialize_field(&mut state, "latestVersion", &self.latest_version)?;
165        serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", &self.observed_generation)?;
166        if let Some(value) = &self.ready_replicas {
167            serde::ser::SerializeStruct::serialize_field(&mut state, "readyReplicas", value)?;
168        }
169        serde::ser::SerializeStruct::serialize_field(&mut state, "replicas", &self.replicas)?;
170        serde::ser::SerializeStruct::serialize_field(&mut state, "unavailableReplicas", &self.unavailable_replicas)?;
171        serde::ser::SerializeStruct::serialize_field(&mut state, "updatedReplicas", &self.updated_replicas)?;
172        serde::ser::SerializeStruct::end(state)
173    }
174}