#
k8s_openapi/v1_35/api/core/v1/
namespace_condition.rs

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