k8s_openapi/v1_34/api/certificates/v1/
certificate_signing_request_condition.rs

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