Skip to main content

k8s_openapi/v1_37/api/apps/v1/
deployment_condition.rs

1// Generated from definition io.k8s.api.apps.v1.DeploymentCondition
2
3/// DeploymentCondition describes the state of a deployment at a certain point.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeploymentCondition {
6    /// Last time the condition transitioned from one status to another.
7    pub last_transition_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
8
9    /// The last time this condition was updated.
10    pub last_update_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
11
12    /// A human readable message indicating details about the transition.
13    pub message: Option<std::string::String>,
14
15    /// The reason for the condition's last transition.
16    pub reason: Option<std::string::String>,
17
18    /// Status of the condition, one of True, False, Unknown.
19    pub status: Option<std::string::String>,
20
21    /// Type of deployment condition.
22    pub type_: Option<std::string::String>,
23}
24
25impl crate::DeepMerge for DeploymentCondition {
26    fn merge_from(&mut self, other: Self) {
27        crate::DeepMerge::merge_from(&mut self.last_transition_time, other.last_transition_time);
28        crate::DeepMerge::merge_from(&mut self.last_update_time, other.last_update_time);
29        crate::DeepMerge::merge_from(&mut self.message, other.message);
30        crate::DeepMerge::merge_from(&mut self.reason, other.reason);
31        crate::DeepMerge::merge_from(&mut self.status, other.status);
32        crate::DeepMerge::merge_from(&mut self.type_, other.type_);
33    }
34}
35
36impl<'de> crate::serde::Deserialize<'de> for DeploymentCondition {
37    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
38        #[allow(non_camel_case_types)]
39        enum Field {
40            Key_last_transition_time,
41            Key_last_update_time,
42            Key_message,
43            Key_reason,
44            Key_status,
45            Key_type_,
46            Other,
47        }
48
49        impl<'de> crate::serde::Deserialize<'de> for Field {
50            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
51                struct Visitor;
52
53                impl crate::serde::de::Visitor<'_> for Visitor {
54                    type Value = Field;
55
56                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
57                        f.write_str("field identifier")
58                    }
59
60                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
61                        Ok(match v {
62                            "lastTransitionTime" => Field::Key_last_transition_time,
63                            "lastUpdateTime" => Field::Key_last_update_time,
64                            "message" => Field::Key_message,
65                            "reason" => Field::Key_reason,
66                            "status" => Field::Key_status,
67                            "type" => Field::Key_type_,
68                            _ => Field::Other,
69                        })
70                    }
71                }
72
73                deserializer.deserialize_identifier(Visitor)
74            }
75        }
76
77        struct Visitor;
78
79        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
80            type Value = DeploymentCondition;
81
82            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
83                f.write_str("DeploymentCondition")
84            }
85
86            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
87                let mut value_last_transition_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
88                let mut value_last_update_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
89                let mut value_message: Option<std::string::String> = None;
90                let mut value_reason: Option<std::string::String> = None;
91                let mut value_status: Option<std::string::String> = None;
92                let mut value_type_: Option<std::string::String> = None;
93
94                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
95                    match key {
96                        Field::Key_last_transition_time => value_last_transition_time = crate::serde::de::MapAccess::next_value(&mut map)?,
97                        Field::Key_last_update_time => value_last_update_time = crate::serde::de::MapAccess::next_value(&mut map)?,
98                        Field::Key_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
99                        Field::Key_reason => value_reason = crate::serde::de::MapAccess::next_value(&mut map)?,
100                        Field::Key_status => value_status = crate::serde::de::MapAccess::next_value(&mut map)?,
101                        Field::Key_type_ => value_type_ = crate::serde::de::MapAccess::next_value(&mut map)?,
102                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
103                    }
104                }
105
106                Ok(DeploymentCondition {
107                    last_transition_time: value_last_transition_time,
108                    last_update_time: value_last_update_time,
109                    message: value_message,
110                    reason: value_reason,
111                    status: value_status,
112                    type_: value_type_,
113                })
114            }
115        }
116
117        deserializer.deserialize_struct(
118            "DeploymentCondition",
119            &[
120                "lastTransitionTime",
121                "lastUpdateTime",
122                "message",
123                "reason",
124                "status",
125                "type",
126            ],
127            Visitor,
128        )
129    }
130}
131
132impl crate::serde::Serialize for DeploymentCondition {
133    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
134        let mut state = serializer.serialize_struct(
135            "DeploymentCondition",
136            self.last_transition_time.as_ref().map_or(0, |_| 1) +
137            self.last_update_time.as_ref().map_or(0, |_| 1) +
138            self.message.as_ref().map_or(0, |_| 1) +
139            self.reason.as_ref().map_or(0, |_| 1) +
140            self.status.as_ref().map_or(0, |_| 1) +
141            self.type_.as_ref().map_or(0, |_| 1),
142        )?;
143        if let Some(value) = &self.last_transition_time {
144            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lastTransitionTime", value)?;
145        }
146        if let Some(value) = &self.last_update_time {
147            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lastUpdateTime", value)?;
148        }
149        if let Some(value) = &self.message {
150            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
151        }
152        if let Some(value) = &self.reason {
153            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
154        }
155        if let Some(value) = &self.status {
156            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "status", value)?;
157        }
158        if let Some(value) = &self.type_ {
159            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "type", value)?;
160        }
161        crate::serde::ser::SerializeStruct::end(state)
162    }
163}
164
165#[cfg(feature = "schemars")]
166impl crate::schemars::JsonSchema for DeploymentCondition {
167    fn schema_name() -> std::borrow::Cow<'static, str> {
168        "io.k8s.api.apps.v1.DeploymentCondition".into()
169    }
170
171    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
172        crate::schemars::json_schema!({
173            "description": "DeploymentCondition describes the state of a deployment at a certain point.",
174            "type": "object",
175            "properties": {
176                "lastTransitionTime": ({
177                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
178                    schema_obj.ensure_object().insert("description".into(), "Last time the condition transitioned from one status to another.".into());
179                    schema_obj
180                }),
181                "lastUpdateTime": ({
182                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
183                    schema_obj.ensure_object().insert("description".into(), "The last time this condition was updated.".into());
184                    schema_obj
185                }),
186                "message": {
187                    "description": "A human readable message indicating details about the transition.",
188                    "type": "string",
189                },
190                "reason": {
191                    "description": "The reason for the condition's last transition.",
192                    "type": "string",
193                },
194                "status": {
195                    "description": "Status of the condition, one of True, False, Unknown.",
196                    "type": "string",
197                },
198                "type": {
199                    "description": "Type of deployment condition.",
200                    "type": "string",
201                },
202            },
203        })
204    }
205}