k8s_openapi/v1_30/api/storage/v1/
volume_attachment_status.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct VolumeAttachmentStatus {
6 pub attach_error: Option<crate::api::storage::v1::VolumeError>,
8
9 pub attached: bool,
11
12 pub attachment_metadata: Option<std::collections::BTreeMap<String, String>>,
14
15 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 std::fmt::Formatter<'_>) -> std::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 std::fmt::Formatter<'_>) -> std::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<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() -> String {
140 "io.k8s.api.storage.v1.VolumeAttachmentStatus".to_owned()
141 }
142
143 fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
144 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
145 metadata: Some(Box::new(crate::schemars::schema::Metadata {
146 description: Some("VolumeAttachmentStatus is the status of a VolumeAttachment request.".to_owned()),
147 ..Default::default()
148 })),
149 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
150 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
151 properties: [
152 (
153 "attachError".to_owned(),
154 {
155 let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeError>().into_object();
156 schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
157 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.".to_owned()),
158 ..Default::default()
159 }));
160 crate::schemars::schema::Schema::Object(schema_obj)
161 },
162 ),
163 (
164 "attached".to_owned(),
165 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
166 metadata: Some(Box::new(crate::schemars::schema::Metadata {
167 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.".to_owned()),
168 ..Default::default()
169 })),
170 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Boolean))),
171 ..Default::default()
172 }),
173 ),
174 (
175 "attachmentMetadata".to_owned(),
176 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
177 metadata: Some(Box::new(crate::schemars::schema::Metadata {
178 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.".to_owned()),
179 ..Default::default()
180 })),
181 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
182 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
183 additional_properties: Some(Box::new(
184 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
185 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
186 ..Default::default()
187 })
188 )),
189 ..Default::default()
190 })),
191 ..Default::default()
192 }),
193 ),
194 (
195 "detachError".to_owned(),
196 {
197 let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeError>().into_object();
198 schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
199 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.".to_owned()),
200 ..Default::default()
201 }));
202 crate::schemars::schema::Schema::Object(schema_obj)
203 },
204 ),
205 ].into(),
206 required: [
207 "attached".to_owned(),
208 ].into(),
209 ..Default::default()
210 })),
211 ..Default::default()
212 })
213 }
214}