Skip to main content

k8s_openapi/v1_37/api/storage/v1/
csi_node_status.rs

1// Generated from definition io.k8s.api.storage.v1.CSINodeStatus
2
3/// CSINodeStatus contains health and status information for storage on a node.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct CSINodeStatus {
6    /// storageHealth contains backend health reports for CSI drivers registered on the node.
7    pub storage_health: Option<std::vec::Vec<crate::api::storage::v1::StorageHealth>>,
8}
9
10impl crate::DeepMerge for CSINodeStatus {
11    fn merge_from(&mut self, other: Self) {
12        crate::merge_strategies::list::map(
13            &mut self.storage_health,
14            other.storage_health,
15            &[|lhs, rhs| lhs.name == rhs.name],
16            |current_item, other_item| {
17                crate::DeepMerge::merge_from(current_item, other_item);
18            },
19        );
20    }
21}
22
23impl<'de> crate::serde::Deserialize<'de> for CSINodeStatus {
24    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
25        #[allow(non_camel_case_types)]
26        enum Field {
27            Key_storage_health,
28            Other,
29        }
30
31        impl<'de> crate::serde::Deserialize<'de> for Field {
32            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
33                struct Visitor;
34
35                impl crate::serde::de::Visitor<'_> for Visitor {
36                    type Value = Field;
37
38                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
39                        f.write_str("field identifier")
40                    }
41
42                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
43                        Ok(match v {
44                            "storageHealth" => Field::Key_storage_health,
45                            _ => Field::Other,
46                        })
47                    }
48                }
49
50                deserializer.deserialize_identifier(Visitor)
51            }
52        }
53
54        struct Visitor;
55
56        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
57            type Value = CSINodeStatus;
58
59            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
60                f.write_str("CSINodeStatus")
61            }
62
63            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
64                let mut value_storage_health: Option<std::vec::Vec<crate::api::storage::v1::StorageHealth>> = None;
65
66                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
67                    match key {
68                        Field::Key_storage_health => value_storage_health = crate::serde::de::MapAccess::next_value(&mut map)?,
69                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
70                    }
71                }
72
73                Ok(CSINodeStatus {
74                    storage_health: value_storage_health,
75                })
76            }
77        }
78
79        deserializer.deserialize_struct(
80            "CSINodeStatus",
81            &[
82                "storageHealth",
83            ],
84            Visitor,
85        )
86    }
87}
88
89impl crate::serde::Serialize for CSINodeStatus {
90    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
91        let mut state = serializer.serialize_struct(
92            "CSINodeStatus",
93            self.storage_health.as_ref().map_or(0, |_| 1),
94        )?;
95        if let Some(value) = &self.storage_health {
96            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "storageHealth", value)?;
97        }
98        crate::serde::ser::SerializeStruct::end(state)
99    }
100}
101
102#[cfg(feature = "schemars")]
103impl crate::schemars::JsonSchema for CSINodeStatus {
104    fn schema_name() -> std::borrow::Cow<'static, str> {
105        "io.k8s.api.storage.v1.CSINodeStatus".into()
106    }
107
108    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
109        crate::schemars::json_schema!({
110            "description": "CSINodeStatus contains health and status information for storage on a node.",
111            "type": "object",
112            "properties": {
113                "storageHealth": {
114                    "description": "storageHealth contains backend health reports for CSI drivers registered on the node.",
115                    "type": "array",
116                    "items": (__gen.subschema_for::<crate::api::storage::v1::StorageHealth>()),
117                },
118            },
119        })
120    }
121}