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

    1// Generated from definition io.k8s.api.core.v1.ReplicationControllerStatus
    2
    3/// ReplicationControllerStatus represents the current status of a replication controller.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct ReplicationControllerStatus {
    6    /// The number of available replicas (ready for at least minReadySeconds) for this replication controller.
    7    pub available_replicas: Option<i32>,
    8
    9    /// Represents the latest available observations of a replication controller's current state.
    10    pub conditions: Option<std::vec::Vec<crate::api::core::v1::ReplicationControllerCondition>>,
    11
    12    /// The number of pods that have labels matching the labels of the pod template of the replication controller.
    13    pub fully_labeled_replicas: Option<i32>,
    14
    15    /// ObservedGeneration reflects the generation of the most recently observed replication controller.
    16    pub observed_generation: Option<i64>,
    17
    18    /// The number of ready replicas for this replication controller.
    19    pub ready_replicas: Option<i32>,
    20
    21    /// Replicas is the most recently observed number of replicas. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller
    22    pub replicas: i32,
    23}
    24
    25impl crate::DeepMerge for ReplicationControllerStatus {
    26    fn merge_from(&mut self, other: Self) {
    27        crate::DeepMerge::merge_from(&mut self.available_replicas, other.available_replicas);
    28        crate::merge_strategies::list::map(
    29            &mut self.conditions,
    30            other.conditions,
    31            &[|lhs, rhs| lhs.type_ == rhs.type_],
    32            |current_item, other_item| {
    33                crate::DeepMerge::merge_from(current_item, other_item);
    34            },
    35        );
    36        crate::DeepMerge::merge_from(&mut self.fully_labeled_replicas, other.fully_labeled_replicas);
    37        crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
    38        crate::DeepMerge::merge_from(&mut self.ready_replicas, other.ready_replicas);
    39        crate::DeepMerge::merge_from(&mut self.replicas, other.replicas);
    40    }
    41}
    42
    43impl<'de> crate::serde::Deserialize<'de> for ReplicationControllerStatus {
    44    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    45        #[allow(non_camel_case_types)]
    46        enum Field {
    47            Key_available_replicas,
    48            Key_conditions,
    49            Key_fully_labeled_replicas,
    50            Key_observed_generation,
    51            Key_ready_replicas,
    52            Key_replicas,
    53            Other,
    54        }
    55
    56        impl<'de> crate::serde::Deserialize<'de> for Field {
    57            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    58                struct Visitor;
    59
    60                impl crate::serde::de::Visitor<'_> for Visitor {
    61                    type Value = Field;
    62
    63                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    64                        f.write_str("field identifier")
    65                    }
    66
    67                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    68                        Ok(match v {
    69                            "availableReplicas" => Field::Key_available_replicas,
    70                            "conditions" => Field::Key_conditions,
    71                            "fullyLabeledReplicas" => Field::Key_fully_labeled_replicas,
    72                            "observedGeneration" => Field::Key_observed_generation,
    73                            "readyReplicas" => Field::Key_ready_replicas,
    74                            "replicas" => Field::Key_replicas,
    75                            _ => Field::Other,
    76                        })
    77                    }
    78                }
    79
    80                deserializer.deserialize_identifier(Visitor)
    81            }
    82        }
    83
    84        struct Visitor;
    85
    86        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    87            type Value = ReplicationControllerStatus;
    88
    89            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    90                f.write_str("ReplicationControllerStatus")
    91            }
    92
    93            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    94                let mut value_available_replicas: Option<i32> = None;
    95                let mut value_conditions: Option<std::vec::Vec<crate::api::core::v1::ReplicationControllerCondition>> = None;
    96                let mut value_fully_labeled_replicas: Option<i32> = None;
    97                let mut value_observed_generation: Option<i64> = None;
    98                let mut value_ready_replicas: Option<i32> = None;
    99                let mut value_replicas: Option<i32> = None;
    100
    101                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    102                    match key {
    103                        Field::Key_available_replicas => value_available_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
    104                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
    105                        Field::Key_fully_labeled_replicas => value_fully_labeled_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
    106                        Field::Key_observed_generation => value_observed_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
    107                        Field::Key_ready_replicas => value_ready_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
    108                        Field::Key_replicas => value_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
    109                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    110                    }
    111                }
    112
    113                Ok(ReplicationControllerStatus {
    114                    available_replicas: value_available_replicas,
    115                    conditions: value_conditions,
    116                    fully_labeled_replicas: value_fully_labeled_replicas,
    117                    observed_generation: value_observed_generation,
    118                    ready_replicas: value_ready_replicas,
    119                    replicas: value_replicas.unwrap_or_default(),
    120                })
    121            }
    122        }
    123
    124        deserializer.deserialize_struct(
    125            "ReplicationControllerStatus",
    126            &[
    127                "availableReplicas",
    128                "conditions",
    129                "fullyLabeledReplicas",
    130                "observedGeneration",
    131                "readyReplicas",
    132                "replicas",
    133            ],
    134            Visitor,
    135        )
    136    }
    137}
    138
    139impl crate::serde::Serialize for ReplicationControllerStatus {
    140    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    141        let mut state = serializer.serialize_struct(
    142            "ReplicationControllerStatus",
    143            1 +
    144            self.available_replicas.as_ref().map_or(0, |_| 1) +
    145            self.conditions.as_ref().map_or(0, |_| 1) +
    146            self.fully_labeled_replicas.as_ref().map_or(0, |_| 1) +
    147            self.observed_generation.as_ref().map_or(0, |_| 1) +
    148            self.ready_replicas.as_ref().map_or(0, |_| 1),
    149        )?;
    150        if let Some(value) = &self.available_replicas {
    151            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "availableReplicas", value)?;
    152        }
    153        if let Some(value) = &self.conditions {
    154            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
    155        }
    156        if let Some(value) = &self.fully_labeled_replicas {
    157            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fullyLabeledReplicas", value)?;
    158        }
    159        if let Some(value) = &self.observed_generation {
    160            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
    161        }
    162        if let Some(value) = &self.ready_replicas {
    163            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readyReplicas", value)?;
    164        }
    165        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "replicas", &self.replicas)?;
    166        crate::serde::ser::SerializeStruct::end(state)
    167    }
    168}
    169
    170#[cfg(feature = "schemars")]
    171impl crate::schemars::JsonSchema for ReplicationControllerStatus {
    172    fn schema_name() -> std::borrow::Cow<'static, str> {
    173        "io.k8s.api.core.v1.ReplicationControllerStatus".into()
    174    }
    175
    176    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    177        crate::schemars::json_schema!({
    178            "description": "ReplicationControllerStatus represents the current status of a replication controller.",
    179            "type": "object",
    180            "properties": {
    181                "availableReplicas": {
    182                    "description": "The number of available replicas (ready for at least minReadySeconds) for this replication controller.",
    183                    "type": "integer",
    184                    "format": "int32",
    185                },
    186                "conditions": {
    187                    "description": "Represents the latest available observations of a replication controller's current state.",
    188                    "type": "array",
    189                    "items": (__gen.subschema_for::<crate::api::core::v1::ReplicationControllerCondition>()),
    190                },
    191                "fullyLabeledReplicas": {
    192                    "description": "The number of pods that have labels matching the labels of the pod template of the replication controller.",
    193                    "type": "integer",
    194                    "format": "int32",
    195                },
    196                "observedGeneration": {
    197                    "description": "ObservedGeneration reflects the generation of the most recently observed replication controller.",
    198                    "type": "integer",
    199                    "format": "int64",
    200                },
    201                "readyReplicas": {
    202                    "description": "The number of ready replicas for this replication controller.",
    203                    "type": "integer",
    204                    "format": "int32",
    205                },
    206                "replicas": {
    207                    "description": "Replicas is the most recently observed number of replicas. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller",
    208                    "type": "integer",
    209                    "format": "int32",
    210                },
    211            },
    212            "required": [
    213                "replicas",
    214            ],
    215        })
    216    }
    217}