k8s_openapi/v1_33/api/certificates/v1/
certificate_signing_request_status.rs

1// Generated from definition io.k8s.api.certificates.v1.CertificateSigningRequestStatus
2
3/// CertificateSigningRequestStatus contains conditions used to indicate approved/denied/failed status of the request, and the issued certificate.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct CertificateSigningRequestStatus {
6    /// certificate is populated with an issued certificate by the signer after an Approved condition is present. This field is set via the /status subresource. Once populated, this field is immutable.
7    ///
8    /// If the certificate signing request is denied, a condition of type "Denied" is added and this field remains empty. If the signer cannot issue the certificate, a condition of type "Failed" is added and this field remains empty.
9    ///
10    /// Validation requirements:
11    ///  1. certificate must contain one or more PEM blocks.
12    ///  2. All PEM blocks must have the "CERTIFICATE" label, contain no headers, and the encoded data
13    ///   must be a BER-encoded ASN.1 Certificate structure as described in section 4 of RFC5280.
14    ///  3. Non-PEM content may appear before or after the "CERTIFICATE" PEM blocks and is unvalidated,
15    ///   to allow for explanatory text as described in section 5.2 of RFC7468.
16    ///
17    /// If more than one PEM block is present, and the definition of the requested spec.signerName does not indicate otherwise, the first block is the issued certificate, and subsequent blocks should be treated as intermediate certificates and presented in TLS handshakes.
18    ///
19    /// The certificate is encoded in PEM format.
20    ///
21    /// When serialized as JSON or YAML, the data is additionally base64-encoded, so it consists of:
22    ///
23    ///   base64(
24    ///     -----BEGIN CERTIFICATE-----
25    ///     ...
26    ///     -----END CERTIFICATE-----
27    ///     )
28    pub certificate: Option<crate::ByteString>,
29
30    /// conditions applied to the request. Known conditions are "Approved", "Denied", and "Failed".
31    pub conditions: Option<std::vec::Vec<crate::api::certificates::v1::CertificateSigningRequestCondition>>,
32}
33
34impl crate::DeepMerge for CertificateSigningRequestStatus {
35    fn merge_from(&mut self, other: Self) {
36        crate::DeepMerge::merge_from(&mut self.certificate, other.certificate);
37        crate::merge_strategies::list::map(
38            &mut self.conditions,
39            other.conditions,
40            &[|lhs, rhs| lhs.type_ == rhs.type_],
41            |current_item, other_item| {
42                crate::DeepMerge::merge_from(current_item, other_item);
43            },
44        );
45    }
46}
47
48impl<'de> crate::serde::Deserialize<'de> for CertificateSigningRequestStatus {
49    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
50        #[allow(non_camel_case_types)]
51        enum Field {
52            Key_certificate,
53            Key_conditions,
54            Other,
55        }
56
57        impl<'de> crate::serde::Deserialize<'de> for Field {
58            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
59                struct Visitor;
60
61                impl crate::serde::de::Visitor<'_> for Visitor {
62                    type Value = Field;
63
64                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65                        f.write_str("field identifier")
66                    }
67
68                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
69                        Ok(match v {
70                            "certificate" => Field::Key_certificate,
71                            "conditions" => Field::Key_conditions,
72                            _ => Field::Other,
73                        })
74                    }
75                }
76
77                deserializer.deserialize_identifier(Visitor)
78            }
79        }
80
81        struct Visitor;
82
83        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
84            type Value = CertificateSigningRequestStatus;
85
86            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
87                f.write_str("CertificateSigningRequestStatus")
88            }
89
90            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
91                let mut value_certificate: Option<crate::ByteString> = None;
92                let mut value_conditions: Option<std::vec::Vec<crate::api::certificates::v1::CertificateSigningRequestCondition>> = None;
93
94                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
95                    match key {
96                        Field::Key_certificate => value_certificate = crate::serde::de::MapAccess::next_value(&mut map)?,
97                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
98                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
99                    }
100                }
101
102                Ok(CertificateSigningRequestStatus {
103                    certificate: value_certificate,
104                    conditions: value_conditions,
105                })
106            }
107        }
108
109        deserializer.deserialize_struct(
110            "CertificateSigningRequestStatus",
111            &[
112                "certificate",
113                "conditions",
114            ],
115            Visitor,
116        )
117    }
118}
119
120impl crate::serde::Serialize for CertificateSigningRequestStatus {
121    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
122        let mut state = serializer.serialize_struct(
123            "CertificateSigningRequestStatus",
124            self.certificate.as_ref().map_or(0, |_| 1) +
125            self.conditions.as_ref().map_or(0, |_| 1),
126        )?;
127        if let Some(value) = &self.certificate {
128            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "certificate", value)?;
129        }
130        if let Some(value) = &self.conditions {
131            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
132        }
133        crate::serde::ser::SerializeStruct::end(state)
134    }
135}
136
137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for CertificateSigningRequestStatus {
139    fn schema_name() -> std::string::String {
140        "io.k8s.api.certificates.v1.CertificateSigningRequestStatus".into()
141    }
142
143    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
144        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
145            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
146                description: Some("CertificateSigningRequestStatus contains conditions used to indicate approved/denied/failed status of the request, and the issued certificate.".into()),
147                ..Default::default()
148            })),
149            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
150            object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
151                properties: [
152                    (
153                        "certificate".into(),
154                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
155                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
156                                description: Some("certificate is populated with an issued certificate by the signer after an Approved condition is present. This field is set via the /status subresource. Once populated, this field is immutable.\n\nIf the certificate signing request is denied, a condition of type \"Denied\" is added and this field remains empty. If the signer cannot issue the certificate, a condition of type \"Failed\" is added and this field remains empty.\n\nValidation requirements:\n 1. certificate must contain one or more PEM blocks.\n 2. All PEM blocks must have the \"CERTIFICATE\" label, contain no headers, and the encoded data\n  must be a BER-encoded ASN.1 Certificate structure as described in section 4 of RFC5280.\n 3. Non-PEM content may appear before or after the \"CERTIFICATE\" PEM blocks and is unvalidated,\n  to allow for explanatory text as described in section 5.2 of RFC7468.\n\nIf more than one PEM block is present, and the definition of the requested spec.signerName does not indicate otherwise, the first block is the issued certificate, and subsequent blocks should be treated as intermediate certificates and presented in TLS handshakes.\n\nThe certificate is encoded in PEM format.\n\nWhen serialized as JSON or YAML, the data is additionally base64-encoded, so it consists of:\n\n    base64(\n    -----BEGIN CERTIFICATE-----\n    ...\n    -----END CERTIFICATE-----\n    )".into()),
157                                ..Default::default()
158                            })),
159                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
160                            format: Some("byte".into()),
161                            ..Default::default()
162                        }),
163                    ),
164                    (
165                        "conditions".into(),
166                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
167                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
168                                description: Some("conditions applied to the request. Known conditions are \"Approved\", \"Denied\", and \"Failed\".".into()),
169                                ..Default::default()
170                            })),
171                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
172                            array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
173                                items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::certificates::v1::CertificateSigningRequestCondition>()))),
174                                ..Default::default()
175                            })),
176                            ..Default::default()
177                        }),
178                    ),
179                ].into(),
180                ..Default::default()
181            })),
182            ..Default::default()
183        })
184    }
185}