Skip to main content

k8s_openapi/v1_36/api/storage/v1/
volume_attachment_status.rs

1// Generated from definition io.k8s.api.storage.v1.VolumeAttachmentStatus
2
3/// VolumeAttachmentStatus is the status of a VolumeAttachment request.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct VolumeAttachmentStatus {
6    /// attachError represents the last error encountered during attach operation, if any. This field must only be set by the entity completing the attach operation, i.e. the external-attacher.
7    pub attach_error: Option<crate::api::storage::v1::VolumeError>,
8
9    /// attached indicates the volume is successfully attached. This field must only be set by the entity completing the attach operation, i.e. the external-attacher.
10    pub attached: bool,
11
12    /// attachmentMetadata is populated with any information returned by the attach operation, upon successful attach, that must be passed into subsequent WaitForAttach or Mount calls. This field must only be set by the entity completing the attach operation, i.e. the external-attacher.
13    pub attachment_metadata: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
14
15    /// detachError represents the last error encountered during detach operation, if any. This field must only be set by the entity completing the detach operation, i.e. the external-attacher.
16    pub detach_error: Option<crate::api::storage::v1::VolumeError>,
17}
18
19impl crate::DeepMerge for VolumeAttachmentStatus {
20    fn merge_from(&mut self, other: Self) {
21        crate::DeepMerge::merge_from(&mut self.attach_error, other.attach_error);
22        crate::DeepMerge::merge_from(&mut self.attached, other.attached);
23        crate::merge_strategies::map::granular(&mut self.attachment_metadata, other.attachment_metadata, |current_item, other_item| {
24            crate::DeepMerge::merge_from(current_item, other_item);
25        });
26        crate::DeepMerge::merge_from(&mut self.detach_error, other.detach_error);
27    }
28}
29
30impl<'de> crate::serde::Deserialize<'de> for VolumeAttachmentStatus {
31    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
32        #[allow(non_camel_case_types)]
33        enum Field {
34            Key_attach_error,
35            Key_attached,
36            Key_attachment_metadata,
37            Key_detach_error,
38            Other,
39        }
40
41        impl<'de> crate::serde::Deserialize<'de> for Field {
42            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
43                struct Visitor;
44
45                impl crate::serde::de::Visitor<'_> for Visitor {
46                    type Value = Field;
47
48                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
49                        f.write_str("field identifier")
50                    }
51
52                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
53                        Ok(match v {
54                            "attachError" => Field::Key_attach_error,
55                            "attached" => Field::Key_attached,
56                            "attachmentMetadata" => Field::Key_attachment_metadata,
57                            "detachError" => Field::Key_detach_error,
58                            _ => Field::Other,
59                        })
60                    }
61                }
62
63                deserializer.deserialize_identifier(Visitor)
64            }
65        }
66
67        struct Visitor;
68
69        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
70            type Value = VolumeAttachmentStatus;
71
72            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
73                f.write_str("VolumeAttachmentStatus")
74            }
75
76            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
77                let mut value_attach_error: Option<crate::api::storage::v1::VolumeError> = None;
78                let mut value_attached: Option<bool> = None;
79                let mut value_attachment_metadata: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
80                let mut value_detach_error: Option<crate::api::storage::v1::VolumeError> = None;
81
82                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
83                    match key {
84                        Field::Key_attach_error => value_attach_error = crate::serde::de::MapAccess::next_value(&mut map)?,
85                        Field::Key_attached => value_attached = crate::serde::de::MapAccess::next_value(&mut map)?,
86                        Field::Key_attachment_metadata => value_attachment_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
87                        Field::Key_detach_error => value_detach_error = crate::serde::de::MapAccess::next_value(&mut map)?,
88                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
89                    }
90                }
91
92                Ok(VolumeAttachmentStatus {
93                    attach_error: value_attach_error,
94                    attached: value_attached.unwrap_or_default(),
95                    attachment_metadata: value_attachment_metadata,
96                    detach_error: value_detach_error,
97                })
98            }
99        }
100
101        deserializer.deserialize_struct(
102            "VolumeAttachmentStatus",
103            &[
104                "attachError",
105                "attached",
106                "attachmentMetadata",
107                "detachError",
108            ],
109            Visitor,
110        )
111    }
112}
113
114impl crate::serde::Serialize for VolumeAttachmentStatus {
115    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
116        let mut state = serializer.serialize_struct(
117            "VolumeAttachmentStatus",
118            1 +
119            self.attach_error.as_ref().map_or(0, |_| 1) +
120            self.attachment_metadata.as_ref().map_or(0, |_| 1) +
121            self.detach_error.as_ref().map_or(0, |_| 1),
122        )?;
123        if let Some(value) = &self.attach_error {
124            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "attachError", value)?;
125        }
126        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "attached", &self.attached)?;
127        if let Some(value) = &self.attachment_metadata {
128            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "attachmentMetadata", value)?;
129        }
130        if let Some(value) = &self.detach_error {
131            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "detachError", value)?;
132        }
133        crate::serde::ser::SerializeStruct::end(state)
134    }
135}
136
137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for VolumeAttachmentStatus {
139    fn schema_name() -> std::borrow::Cow<'static, str> {
140        "io.k8s.api.storage.v1.VolumeAttachmentStatus".into()
141    }
142
143    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
144        crate::schemars::json_schema!({
145            "description": "VolumeAttachmentStatus is the status of a VolumeAttachment request.",
146            "type": "object",
147            "properties": {
148                "attachError": ({
149                    let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeError>();
150                    schema_obj.ensure_object().insert("description".into(), "attachError represents the last error encountered during attach operation, if any. This field must only be set by the entity completing the attach operation, i.e. the external-attacher.".into());
151                    schema_obj
152                }),
153                "attached": {
154                    "description": "attached indicates the volume is successfully attached. This field must only be set by the entity completing the attach operation, i.e. the external-attacher.",
155                    "type": "boolean",
156                },
157                "attachmentMetadata": {
158                    "description": "attachmentMetadata is populated with any information returned by the attach operation, upon successful attach, that must be passed into subsequent WaitForAttach or Mount calls. This field must only be set by the entity completing the attach operation, i.e. the external-attacher.",
159                    "type": "object",
160                    "additionalProperties": {
161                        "type": "string",
162                    },
163                },
164                "detachError": ({
165                    let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeError>();
166                    schema_obj.ensure_object().insert("description".into(), "detachError represents the last error encountered during detach operation, if any. This field must only be set by the entity completing the detach operation, i.e. the external-attacher.".into());
167                    schema_obj
168                }),
169            },
170            "required": [
171                "attached",
172            ],
173        })
174    }
175}
176
177#[cfg(feature = "schemars08")]
178impl crate::schemars08::JsonSchema for VolumeAttachmentStatus {
179    fn schema_name() -> std::string::String {
180        "io.k8s.api.storage.v1.VolumeAttachmentStatus".into()
181    }
182
183    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
184        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
185            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
186                description: Some("VolumeAttachmentStatus is the status of a VolumeAttachment request.".into()),
187                ..Default::default()
188            })),
189            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
190            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
191                properties: [
192                    (
193                        "attachError".into(),
194                        {
195                            let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeError>().into_object();
196                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
197                                description: Some("attachError represents the last error encountered during attach operation, if any. This field must only be set by the entity completing the attach operation, i.e. the external-attacher.".into()),
198                                ..Default::default()
199                            }));
200                            crate::schemars08::schema::Schema::Object(schema_obj)
201                        },
202                    ),
203                    (
204                        "attached".into(),
205                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
206                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
207                                description: Some("attached indicates the volume is successfully attached. This field must only be set by the entity completing the attach operation, i.e. the external-attacher.".into()),
208                                ..Default::default()
209                            })),
210                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Boolean))),
211                            ..Default::default()
212                        }),
213                    ),
214                    (
215                        "attachmentMetadata".into(),
216                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
217                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
218                                description: Some("attachmentMetadata is populated with any information returned by the attach operation, upon successful attach, that must be passed into subsequent WaitForAttach or Mount calls. This field must only be set by the entity completing the attach operation, i.e. the external-attacher.".into()),
219                                ..Default::default()
220                            })),
221                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
222                            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
223                                additional_properties: Some(std::boxed::Box::new(
224                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
225                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
226                                        ..Default::default()
227                                    })
228                                )),
229                                ..Default::default()
230                            })),
231                            ..Default::default()
232                        }),
233                    ),
234                    (
235                        "detachError".into(),
236                        {
237                            let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeError>().into_object();
238                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
239                                description: Some("detachError represents the last error encountered during detach operation, if any. This field must only be set by the entity completing the detach operation, i.e. the external-attacher.".into()),
240                                ..Default::default()
241                            }));
242                            crate::schemars08::schema::Schema::Object(schema_obj)
243                        },
244                    ),
245                ].into(),
246                required: [
247                    "attached".into(),
248                ].into(),
249                ..Default::default()
250            })),
251            ..Default::default()
252        })
253    }
254}