#
k8s_openapi/v1_35/api/flowcontrol/v1/
flow_schema_condition.rs

    1// Generated from definition io.k8s.api.flowcontrol.v1.FlowSchemaCondition
    2
    3/// FlowSchemaCondition describes conditions for a FlowSchema.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct FlowSchemaCondition {
    6    /// `lastTransitionTime` is the 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    /// `reason` is a unique, one-word, CamelCase reason for the condition's last transition.
    13    pub reason: Option<std::string::String>,
    14
    15    /// `status` is the status of the condition. Can be True, False, Unknown. Required.
    16    pub status: Option<std::string::String>,
    17
    18    /// `type` is the type of the condition. Required.
    19    pub type_: Option<std::string::String>,
    20}
    21
    22impl crate::DeepMerge for FlowSchemaCondition {
    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 FlowSchemaCondition {
    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 = FlowSchemaCondition;
    75
    76            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    77                f.write_str("FlowSchemaCondition")
    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(FlowSchemaCondition {
    99                    last_transition_time: value_last_transition_time,
    100                    message: value_message,
    101                    reason: value_reason,
    102                    status: value_status,
    103                    type_: value_type_,
    104                })
    105            }
    106        }
    107
    108        deserializer.deserialize_struct(
    109            "FlowSchemaCondition",
    110            &[
    111                "lastTransitionTime",
    112                "message",
    113                "reason",
    114                "status",
    115                "type",
    116            ],
    117            Visitor,
    118        )
    119    }
    120}
    121
    122impl crate::serde::Serialize for FlowSchemaCondition {
    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            "FlowSchemaCondition",
    126            self.last_transition_time.as_ref().map_or(0, |_| 1) +
    127            self.message.as_ref().map_or(0, |_| 1) +
    128            self.reason.as_ref().map_or(0, |_| 1) +
    129            self.status.as_ref().map_or(0, |_| 1) +
    130            self.type_.as_ref().map_or(0, |_| 1),
    131        )?;
    132        if let Some(value) = &self.last_transition_time {
    133            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lastTransitionTime", value)?;
    134        }
    135        if let Some(value) = &self.message {
    136            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
    137        }
    138        if let Some(value) = &self.reason {
    139            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
    140        }
    141        if let Some(value) = &self.status {
    142            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "status", value)?;
    143        }
    144        if let Some(value) = &self.type_ {
    145            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "type", value)?;
    146        }
    147        crate::serde::ser::SerializeStruct::end(state)
    148    }
    149}
    150
    151#[cfg(feature = "schemars")]
    152impl crate::schemars::JsonSchema for FlowSchemaCondition {
    153    fn schema_name() -> std::borrow::Cow<'static, str> {
    154        "io.k8s.api.flowcontrol.v1.FlowSchemaCondition".into()
    155    }
    156
    157    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    158        crate::schemars::json_schema!({
    159            "description": "FlowSchemaCondition describes conditions for a FlowSchema.",
    160            "type": "object",
    161            "properties": {
    162                "lastTransitionTime": ({
    163                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
    164                    schema_obj.ensure_object().insert("description".into(), "`lastTransitionTime` is the last time the condition transitioned from one status to another.".into());
    165                    schema_obj
    166                }),
    167                "message": {
    168                    "description": "`message` is a human-readable message indicating details about last transition.",
    169                    "type": "string",
    170                },
    171                "reason": {
    172                    "description": "`reason` is a unique, one-word, CamelCase reason for the condition's last transition.",
    173                    "type": "string",
    174                },
    175                "status": {
    176                    "description": "`status` is the status of the condition. Can be True, False, Unknown. Required.",
    177                    "type": "string",
    178                },
    179                "type": {
    180                    "description": "`type` is the type of the condition. Required.",
    181                    "type": "string",
    182                },
    183            },
    184        })
    185    }
    186}