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

1// Generated from definition io.k8s.api.core.v1.ModifyVolumeStatus
2
3/// ModifyVolumeStatus represents the status object of ControllerModifyVolume operation
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ModifyVolumeStatus {
6    /// status is the status of the ControllerModifyVolume operation. It can be in any of following states:
7    ///  - Pending
8    ///    Pending indicates that the PersistentVolumeClaim cannot be modified due to unmet requirements, such as
9    ///    the specified VolumeAttributesClass not existing.
10    ///  - InProgress
11    ///    InProgress indicates that the volume is being modified.
12    ///  - Infeasible
13    ///   Infeasible indicates that the request has been rejected as invalid by the CSI driver. To
14    ///       resolve the error, a valid VolumeAttributesClass needs to be specified.
15    /// Note: New statuses can be added in the future. Consumers should check for unknown statuses and fail appropriately.
16    pub status: std::string::String,
17
18    /// targetVolumeAttributesClassName is the name of the VolumeAttributesClass the PVC currently being reconciled
19    pub target_volume_attributes_class_name: Option<std::string::String>,
20}
21
22impl crate::DeepMerge for ModifyVolumeStatus {
23    fn merge_from(&mut self, other: Self) {
24        crate::DeepMerge::merge_from(&mut self.status, other.status);
25        crate::DeepMerge::merge_from(&mut self.target_volume_attributes_class_name, other.target_volume_attributes_class_name);
26    }
27}
28
29impl<'de> crate::serde::Deserialize<'de> for ModifyVolumeStatus {
30    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
31        #[allow(non_camel_case_types)]
32        enum Field {
33            Key_status,
34            Key_target_volume_attributes_class_name,
35            Other,
36        }
37
38        impl<'de> crate::serde::Deserialize<'de> for Field {
39            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
40                struct Visitor;
41
42                impl crate::serde::de::Visitor<'_> for Visitor {
43                    type Value = Field;
44
45                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
46                        f.write_str("field identifier")
47                    }
48
49                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
50                        Ok(match v {
51                            "status" => Field::Key_status,
52                            "targetVolumeAttributesClassName" => Field::Key_target_volume_attributes_class_name,
53                            _ => Field::Other,
54                        })
55                    }
56                }
57
58                deserializer.deserialize_identifier(Visitor)
59            }
60        }
61
62        struct Visitor;
63
64        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
65            type Value = ModifyVolumeStatus;
66
67            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
68                f.write_str("ModifyVolumeStatus")
69            }
70
71            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
72                let mut value_status: Option<std::string::String> = None;
73                let mut value_target_volume_attributes_class_name: Option<std::string::String> = None;
74
75                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
76                    match key {
77                        Field::Key_status => value_status = crate::serde::de::MapAccess::next_value(&mut map)?,
78                        Field::Key_target_volume_attributes_class_name => value_target_volume_attributes_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
79                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
80                    }
81                }
82
83                Ok(ModifyVolumeStatus {
84                    status: value_status.unwrap_or_default(),
85                    target_volume_attributes_class_name: value_target_volume_attributes_class_name,
86                })
87            }
88        }
89
90        deserializer.deserialize_struct(
91            "ModifyVolumeStatus",
92            &[
93                "status",
94                "targetVolumeAttributesClassName",
95            ],
96            Visitor,
97        )
98    }
99}
100
101impl crate::serde::Serialize for ModifyVolumeStatus {
102    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
103        let mut state = serializer.serialize_struct(
104            "ModifyVolumeStatus",
105            1 +
106            self.target_volume_attributes_class_name.as_ref().map_or(0, |_| 1),
107        )?;
108        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "status", &self.status)?;
109        if let Some(value) = &self.target_volume_attributes_class_name {
110            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "targetVolumeAttributesClassName", value)?;
111        }
112        crate::serde::ser::SerializeStruct::end(state)
113    }
114}
115
116#[cfg(feature = "schemars")]
117impl crate::schemars::JsonSchema for ModifyVolumeStatus {
118    fn schema_name() -> std::borrow::Cow<'static, str> {
119        "io.k8s.api.core.v1.ModifyVolumeStatus".into()
120    }
121
122    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
123        crate::schemars::json_schema!({
124            "description": "ModifyVolumeStatus represents the status object of ControllerModifyVolume operation",
125            "type": "object",
126            "properties": {
127                "status": {
128                    "description": "status is the status of the ControllerModifyVolume operation. It can be in any of following states:\n - Pending\n   Pending indicates that the PersistentVolumeClaim cannot be modified due to unmet requirements, such as\n   the specified VolumeAttributesClass not existing.\n - InProgress\n   InProgress indicates that the volume is being modified.\n - Infeasible\n  Infeasible indicates that the request has been rejected as invalid by the CSI driver. To\n\t  resolve the error, a valid VolumeAttributesClass needs to be specified.\nNote: New statuses can be added in the future. Consumers should check for unknown statuses and fail appropriately.",
129                    "type": "string",
130                },
131                "targetVolumeAttributesClassName": {
132                    "description": "targetVolumeAttributesClassName is the name of the VolumeAttributesClass the PVC currently being reconciled",
133                    "type": "string",
134                },
135            },
136            "required": [
137                "status",
138            ],
139        })
140    }
141}