#
k8s_openapi/v1_35/apiextensions_apiserver/pkg/apis/apiextensions/v1/
custom_resource_definition_condition.rs

    1// Generated from definition io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinitionCondition
    2
    3/// CustomResourceDefinitionCondition contains details for the current condition of this pod.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct CustomResourceDefinitionCondition {
    6    /// lastTransitionTime 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    /// message is a human-readable message indicating details about last transition.
    10    pub message: Option<std::string::String>,
    11
    12    /// observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions\[x\].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.
    13    pub observed_generation: Option<i64>,
    14
    15    /// reason is a unique, one-word, CamelCase reason for the condition's last transition.
    16    pub reason: Option<std::string::String>,
    17
    18    /// status is the status of the condition. Can be True, False, Unknown.
    19    pub status: std::string::String,
    20
    21    /// type is the type of the condition. Types include Established, NamesAccepted and Terminating.
    22    pub type_: std::string::String,
    23}
    24
    25impl crate::DeepMerge for CustomResourceDefinitionCondition {
    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.message, other.message);
    29        crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
    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 CustomResourceDefinitionCondition {
    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_message,
    42            Key_observed_generation,
    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                            "message" => Field::Key_message,
    64                            "observedGeneration" => Field::Key_observed_generation,
    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 = CustomResourceDefinitionCondition;
    81
    82            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    83                f.write_str("CustomResourceDefinitionCondition")
    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_message: Option<std::string::String> = None;
    89                let mut value_observed_generation: Option<i64> = 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_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
    98                        Field::Key_observed_generation => value_observed_generation = 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(CustomResourceDefinitionCondition {
    107                    last_transition_time: value_last_transition_time,
    108                    message: value_message,
    109                    observed_generation: value_observed_generation,
    110                    reason: value_reason,
    111                    status: value_status.unwrap_or_default(),
    112                    type_: value_type_.unwrap_or_default(),
    113                })
    114            }
    115        }
    116
    117        deserializer.deserialize_struct(
    118            "CustomResourceDefinitionCondition",
    119            &[
    120                "lastTransitionTime",
    121                "message",
    122                "observedGeneration",
    123                "reason",
    124                "status",
    125                "type",
    126            ],
    127            Visitor,
    128        )
    129    }
    130}
    131
    132impl crate::serde::Serialize for CustomResourceDefinitionCondition {
    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            "CustomResourceDefinitionCondition",
    136            2 +
    137            self.last_transition_time.as_ref().map_or(0, |_| 1) +
    138            self.message.as_ref().map_or(0, |_| 1) +
    139            self.observed_generation.as_ref().map_or(0, |_| 1) +
    140            self.reason.as_ref().map_or(0, |_| 1),
    141        )?;
    142        if let Some(value) = &self.last_transition_time {
    143            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lastTransitionTime", value)?;
    144        }
    145        if let Some(value) = &self.message {
    146            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
    147        }
    148        if let Some(value) = &self.observed_generation {
    149            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
    150        }
    151        if let Some(value) = &self.reason {
    152            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
    153        }
    154        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "status", &self.status)?;
    155        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "type", &self.type_)?;
    156        crate::serde::ser::SerializeStruct::end(state)
    157    }
    158}
    159
    160#[cfg(feature = "schemars")]
    161impl crate::schemars::JsonSchema for CustomResourceDefinitionCondition {
    162    fn schema_name() -> std::borrow::Cow<'static, str> {
    163        "io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinitionCondition".into()
    164    }
    165
    166    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    167        crate::schemars::json_schema!({
    168            "description": "CustomResourceDefinitionCondition contains details for the current condition of this pod.",
    169            "type": "object",
    170            "properties": {
    171                "lastTransitionTime": ({
    172                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
    173                    schema_obj.ensure_object().insert("description".into(), "lastTransitionTime last time the condition transitioned from one status to another.".into());
    174                    schema_obj
    175                }),
    176                "message": {
    177                    "description": "message is a human-readable message indicating details about last transition.",
    178                    "type": "string",
    179                },
    180                "observedGeneration": {
    181                    "description": "observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.",
    182                    "type": "integer",
    183                    "format": "int64",
    184                },
    185                "reason": {
    186                    "description": "reason is a unique, one-word, CamelCase reason for the condition's last transition.",
    187                    "type": "string",
    188                },
    189                "status": {
    190                    "description": "status is the status of the condition. Can be True, False, Unknown.",
    191                    "type": "string",
    192                },
    193                "type": {
    194                    "description": "type is the type of the condition. Types include Established, NamesAccepted and Terminating.",
    195                    "type": "string",
    196                },
    197            },
    198            "required": [
    199                "status",
    200                "type",
    201            ],
    202        })
    203    }
    204}