k8s_openapi/v1_35/api/core/v1/
persistent_volume_status.rs

1// Generated from definition io.k8s.api.core.v1.PersistentVolumeStatus
2
3/// PersistentVolumeStatus is the current status of a persistent volume.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PersistentVolumeStatus {
6    /// lastPhaseTransitionTime is the time the phase transitioned from one to another and automatically resets to current time everytime a volume phase transitions.
7    pub last_phase_transition_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
8
9    /// message is a human-readable message indicating details about why the volume is in this state.
10    pub message: Option<std::string::String>,
11
12    /// phase indicates if a volume is available, bound to a claim, or released by a claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#phase
13    pub phase: Option<std::string::String>,
14
15    /// reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.
16    pub reason: Option<std::string::String>,
17}
18
19impl crate::DeepMerge for PersistentVolumeStatus {
20    fn merge_from(&mut self, other: Self) {
21        crate::DeepMerge::merge_from(&mut self.last_phase_transition_time, other.last_phase_transition_time);
22        crate::DeepMerge::merge_from(&mut self.message, other.message);
23        crate::DeepMerge::merge_from(&mut self.phase, other.phase);
24        crate::DeepMerge::merge_from(&mut self.reason, other.reason);
25    }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for PersistentVolumeStatus {
29    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30        #[allow(non_camel_case_types)]
31        enum Field {
32            Key_last_phase_transition_time,
33            Key_message,
34            Key_phase,
35            Key_reason,
36            Other,
37        }
38
39        impl<'de> crate::serde::Deserialize<'de> for Field {
40            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
41                struct Visitor;
42
43                impl crate::serde::de::Visitor<'_> for Visitor {
44                    type Value = Field;
45
46                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
47                        f.write_str("field identifier")
48                    }
49
50                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
51                        Ok(match v {
52                            "lastPhaseTransitionTime" => Field::Key_last_phase_transition_time,
53                            "message" => Field::Key_message,
54                            "phase" => Field::Key_phase,
55                            "reason" => Field::Key_reason,
56                            _ => Field::Other,
57                        })
58                    }
59                }
60
61                deserializer.deserialize_identifier(Visitor)
62            }
63        }
64
65        struct Visitor;
66
67        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
68            type Value = PersistentVolumeStatus;
69
70            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71                f.write_str("PersistentVolumeStatus")
72            }
73
74            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
75                let mut value_last_phase_transition_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
76                let mut value_message: Option<std::string::String> = None;
77                let mut value_phase: Option<std::string::String> = None;
78                let mut value_reason: Option<std::string::String> = None;
79
80                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81                    match key {
82                        Field::Key_last_phase_transition_time => value_last_phase_transition_time = crate::serde::de::MapAccess::next_value(&mut map)?,
83                        Field::Key_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
84                        Field::Key_phase => value_phase = crate::serde::de::MapAccess::next_value(&mut map)?,
85                        Field::Key_reason => value_reason = crate::serde::de::MapAccess::next_value(&mut map)?,
86                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
87                    }
88                }
89
90                Ok(PersistentVolumeStatus {
91                    last_phase_transition_time: value_last_phase_transition_time,
92                    message: value_message,
93                    phase: value_phase,
94                    reason: value_reason,
95                })
96            }
97        }
98
99        deserializer.deserialize_struct(
100            "PersistentVolumeStatus",
101            &[
102                "lastPhaseTransitionTime",
103                "message",
104                "phase",
105                "reason",
106            ],
107            Visitor,
108        )
109    }
110}
111
112impl crate::serde::Serialize for PersistentVolumeStatus {
113    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
114        let mut state = serializer.serialize_struct(
115            "PersistentVolumeStatus",
116            self.last_phase_transition_time.as_ref().map_or(0, |_| 1) +
117            self.message.as_ref().map_or(0, |_| 1) +
118            self.phase.as_ref().map_or(0, |_| 1) +
119            self.reason.as_ref().map_or(0, |_| 1),
120        )?;
121        if let Some(value) = &self.last_phase_transition_time {
122            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lastPhaseTransitionTime", value)?;
123        }
124        if let Some(value) = &self.message {
125            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
126        }
127        if let Some(value) = &self.phase {
128            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "phase", value)?;
129        }
130        if let Some(value) = &self.reason {
131            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
132        }
133        crate::serde::ser::SerializeStruct::end(state)
134    }
135}
136
137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for PersistentVolumeStatus {
139    fn schema_name() -> std::borrow::Cow<'static, str> {
140        "io.k8s.api.core.v1.PersistentVolumeStatus".into()
141    }
142
143    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
144        crate::schemars::json_schema!({
145            "description": "PersistentVolumeStatus is the current status of a persistent volume.",
146            "type": "object",
147            "properties": {
148                "lastPhaseTransitionTime": ({
149                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
150                    schema_obj.ensure_object().insert("description".into(), "lastPhaseTransitionTime is the time the phase transitioned from one to another and automatically resets to current time everytime a volume phase transitions.".into());
151                    schema_obj
152                }),
153                "message": {
154                    "description": "message is a human-readable message indicating details about why the volume is in this state.",
155                    "type": "string",
156                },
157                "phase": {
158                    "description": "phase indicates if a volume is available, bound to a claim, or released by a claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#phase",
159                    "type": "string",
160                },
161                "reason": {
162                    "description": "reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.",
163                    "type": "string",
164                },
165            },
166        })
167    }
168}