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

    1// Generated from definition io.k8s.api.core.v1.NodeCondition
    2
    3/// NodeCondition contains condition information for a node.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct NodeCondition {
    6    /// Last time we got an update on a given condition.
    7    pub last_heartbeat_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
    8
    9    /// Last time the condition transit from one status to another.
    10    pub last_transition_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
    11
    12    /// Human readable message indicating details about last transition.
    13    pub message: Option<std::string::String>,
    14
    15    /// (brief) 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: std::string::String,
    20
    21    /// Type of node condition.
    22    pub type_: std::string::String,
    23}
    24
    25impl crate::DeepMerge for NodeCondition {
    26    fn merge_from(&mut self, other: Self) {
    27        crate::DeepMerge::merge_from(&mut self.last_heartbeat_time, other.last_heartbeat_time);
    28        crate::DeepMerge::merge_from(&mut self.last_transition_time, other.last_transition_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 NodeCondition {
    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_heartbeat_time,
    41            Key_last_transition_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                            "lastHeartbeatTime" => Field::Key_last_heartbeat_time,
    63                            "lastTransitionTime" => Field::Key_last_transition_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 = NodeCondition;
    81
    82            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    83                f.write_str("NodeCondition")
    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_heartbeat_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
    88                let mut value_last_transition_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_heartbeat_time => value_last_heartbeat_time = crate::serde::de::MapAccess::next_value(&mut map)?,
    97                        Field::Key_last_transition_time => value_last_transition_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(NodeCondition {
    107                    last_heartbeat_time: value_last_heartbeat_time,
    108                    last_transition_time: value_last_transition_time,
    109                    message: value_message,
    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            "NodeCondition",
    119            &[
    120                "lastHeartbeatTime",
    121                "lastTransitionTime",
    122                "message",
    123                "reason",
    124                "status",
    125                "type",
    126            ],
    127            Visitor,
    128        )
    129    }
    130}
    131
    132impl crate::serde::Serialize for NodeCondition {
    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            "NodeCondition",
    136            2 +
    137            self.last_heartbeat_time.as_ref().map_or(0, |_| 1) +
    138            self.last_transition_time.as_ref().map_or(0, |_| 1) +
    139            self.message.as_ref().map_or(0, |_| 1) +
    140            self.reason.as_ref().map_or(0, |_| 1),
    141        )?;
    142        if let Some(value) = &self.last_heartbeat_time {
    143            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lastHeartbeatTime", value)?;
    144        }
    145        if let Some(value) = &self.last_transition_time {
    146            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lastTransitionTime", value)?;
    147        }
    148        if let Some(value) = &self.message {
    149            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", 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 NodeCondition {
    162    fn schema_name() -> std::borrow::Cow<'static, str> {
    163        "io.k8s.api.core.v1.NodeCondition".into()
    164    }
    165
    166    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    167        crate::schemars::json_schema!({
    168            "description": "NodeCondition contains condition information for a node.",
    169            "type": "object",
    170            "properties": {
    171                "lastHeartbeatTime": ({
    172                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
    173                    schema_obj.ensure_object().insert("description".into(), "Last time we got an update on a given condition.".into());
    174                    schema_obj
    175                }),
    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 transit from one status to another.".into());
    179                    schema_obj
    180                }),
    181                "message": {
    182                    "description": "Human readable message indicating details about last transition.",
    183                    "type": "string",
    184                },
    185                "reason": {
    186                    "description": "(brief) reason for the condition's last transition.",
    187                    "type": "string",
    188                },
    189                "status": {
    190                    "description": "Status of the condition, one of True, False, Unknown.",
    191                    "type": "string",
    192                },
    193                "type": {
    194                    "description": "Type of node condition.",
    195                    "type": "string",
    196                },
    197            },
    198            "required": [
    199                "status",
    200                "type",
    201            ],
    202        })
    203    }
    204}