k8s_openapi/v1_33/api/storage/v1/
volume_error.rs

1// Generated from definition io.k8s.api.storage.v1.VolumeError
2
3/// VolumeError captures an error encountered during a volume operation.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct VolumeError {
6    /// errorCode is a numeric gRPC code representing the error encountered during Attach or Detach operations.
7    ///
8    /// This is an optional, alpha field that requires the MutableCSINodeAllocatableCount feature gate being enabled to be set.
9    pub error_code: Option<i32>,
10
11    /// message represents the error encountered during Attach or Detach operation. This string may be logged, so it should not contain sensitive information.
12    pub message: Option<std::string::String>,
13
14    /// time represents the time the error was encountered.
15    pub time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
16}
17
18impl crate::DeepMerge for VolumeError {
19    fn merge_from(&mut self, other: Self) {
20        crate::DeepMerge::merge_from(&mut self.error_code, other.error_code);
21        crate::DeepMerge::merge_from(&mut self.message, other.message);
22        crate::DeepMerge::merge_from(&mut self.time, other.time);
23    }
24}
25
26impl<'de> crate::serde::Deserialize<'de> for VolumeError {
27    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
28        #[allow(non_camel_case_types)]
29        enum Field {
30            Key_error_code,
31            Key_message,
32            Key_time,
33            Other,
34        }
35
36        impl<'de> crate::serde::Deserialize<'de> for Field {
37            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
38                struct Visitor;
39
40                impl crate::serde::de::Visitor<'_> for Visitor {
41                    type Value = Field;
42
43                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
44                        f.write_str("field identifier")
45                    }
46
47                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
48                        Ok(match v {
49                            "errorCode" => Field::Key_error_code,
50                            "message" => Field::Key_message,
51                            "time" => Field::Key_time,
52                            _ => Field::Other,
53                        })
54                    }
55                }
56
57                deserializer.deserialize_identifier(Visitor)
58            }
59        }
60
61        struct Visitor;
62
63        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
64            type Value = VolumeError;
65
66            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
67                f.write_str("VolumeError")
68            }
69
70            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
71                let mut value_error_code: Option<i32> = None;
72                let mut value_message: Option<std::string::String> = None;
73                let mut value_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
74
75                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
76                    match key {
77                        Field::Key_error_code => value_error_code = crate::serde::de::MapAccess::next_value(&mut map)?,
78                        Field::Key_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
79                        Field::Key_time => value_time = crate::serde::de::MapAccess::next_value(&mut map)?,
80                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
81                    }
82                }
83
84                Ok(VolumeError {
85                    error_code: value_error_code,
86                    message: value_message,
87                    time: value_time,
88                })
89            }
90        }
91
92        deserializer.deserialize_struct(
93            "VolumeError",
94            &[
95                "errorCode",
96                "message",
97                "time",
98            ],
99            Visitor,
100        )
101    }
102}
103
104impl crate::serde::Serialize for VolumeError {
105    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
106        let mut state = serializer.serialize_struct(
107            "VolumeError",
108            self.error_code.as_ref().map_or(0, |_| 1) +
109            self.message.as_ref().map_or(0, |_| 1) +
110            self.time.as_ref().map_or(0, |_| 1),
111        )?;
112        if let Some(value) = &self.error_code {
113            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "errorCode", value)?;
114        }
115        if let Some(value) = &self.message {
116            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
117        }
118        if let Some(value) = &self.time {
119            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "time", value)?;
120        }
121        crate::serde::ser::SerializeStruct::end(state)
122    }
123}
124
125#[cfg(feature = "schemars")]
126impl crate::schemars::JsonSchema for VolumeError {
127    fn schema_name() -> std::string::String {
128        "io.k8s.api.storage.v1.VolumeError".into()
129    }
130
131    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
132        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
133            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
134                description: Some("VolumeError captures an error encountered during a volume operation.".into()),
135                ..Default::default()
136            })),
137            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
138            object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
139                properties: [
140                    (
141                        "errorCode".into(),
142                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
143                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
144                                description: Some("errorCode is a numeric gRPC code representing the error encountered during Attach or Detach operations.\n\nThis is an optional, alpha field that requires the MutableCSINodeAllocatableCount feature gate being enabled to be set.".into()),
145                                ..Default::default()
146                            })),
147                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
148                            format: Some("int32".into()),
149                            ..Default::default()
150                        }),
151                    ),
152                    (
153                        "message".into(),
154                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
155                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
156                                description: Some("message represents the error encountered during Attach or Detach operation. This string may be logged, so it should not contain sensitive information.".into()),
157                                ..Default::default()
158                            })),
159                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
160                            ..Default::default()
161                        }),
162                    ),
163                    (
164                        "time".into(),
165                        {
166                            let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>().into_object();
167                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
168                                description: Some("time represents the time the error was encountered.".into()),
169                                ..Default::default()
170                            }));
171                            crate::schemars::schema::Schema::Object(schema_obj)
172                        },
173                    ),
174                ].into(),
175                ..Default::default()
176            })),
177            ..Default::default()
178        })
179    }
180}