1// Generated from definition io.k8s.api.storage.v1.VolumeAttachmentStatus
23/// 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.
7pub attach_error: Option<crate::api::storage::v1::VolumeError>,
89/// 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.
10pub attached: bool,
1112/// 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.
13pub attachment_metadata: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
1415/// 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.
16pub detach_error: Option<crate::api::storage::v1::VolumeError>,
17}
1819impl crate::DeepMerge for VolumeAttachmentStatus {
20fn merge_from(&mut self, other: Self) {
21crate::DeepMerge::merge_from(&mut self.attach_error, other.attach_error);
22crate::DeepMerge::merge_from(&mut self.attached, other.attached);
23crate::merge_strategies::map::granular(&mut self.attachment_metadata, other.attachment_metadata, |current_item, other_item| {
24crate::DeepMerge::merge_from(current_item, other_item);
25 });
26crate::DeepMerge::merge_from(&mut self.detach_error, other.detach_error);
27 }
28}
2930impl<'de> crate::serde::Deserialize<'de> for VolumeAttachmentStatus {
31fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
32#[allow(non_camel_case_types)]
33enum Field {
34 Key_attach_error,
35 Key_attached,
36 Key_attachment_metadata,
37 Key_detach_error,
38 Other,
39 }
4041impl<'de> crate::serde::Deserialize<'de> for Field {
42fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
43struct Visitor;
4445impl crate::serde::de::Visitor<'_> for Visitor {
46type Value = Field;
4748fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
49 f.write_str("field identifier")
50 }
5152fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
53Ok(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 }
6263 deserializer.deserialize_identifier(Visitor)
64 }
65 }
6667struct Visitor;
6869impl<'de> crate::serde::de::Visitor<'de> for Visitor {
70type Value = VolumeAttachmentStatus;
7172fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
73 f.write_str("VolumeAttachmentStatus")
74 }
7576fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
77let mut value_attach_error: Option<crate::api::storage::v1::VolumeError> = None;
78let mut value_attached: Option<bool> = None;
79let mut value_attachment_metadata: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
80let mut value_detach_error: Option<crate::api::storage::v1::VolumeError> = None;
8182while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
83match 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 }
9192Ok(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 }
100101 deserializer.deserialize_struct(
102"VolumeAttachmentStatus",
103&[
104"attachError",
105"attached",
106"attachmentMetadata",
107"detachError",
108 ],
109 Visitor,
110 )
111 }
112}
113114impl crate::serde::Serialize for VolumeAttachmentStatus {
115fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
116let mut state = serializer.serialize_struct(
117"VolumeAttachmentStatus",
1181 +
119self.attach_error.as_ref().map_or(0, |_| 1) +
120self.attachment_metadata.as_ref().map_or(0, |_| 1) +
121self.detach_error.as_ref().map_or(0, |_| 1),
122 )?;
123if let Some(value) = &self.attach_error {
124crate::serde::ser::SerializeStruct::serialize_field(&mut state, "attachError", value)?;
125 }
126crate::serde::ser::SerializeStruct::serialize_field(&mut state, "attached", &self.attached)?;
127if let Some(value) = &self.attachment_metadata {
128crate::serde::ser::SerializeStruct::serialize_field(&mut state, "attachmentMetadata", value)?;
129 }
130if let Some(value) = &self.detach_error {
131crate::serde::ser::SerializeStruct::serialize_field(&mut state, "detachError", value)?;
132 }
133crate::serde::ser::SerializeStruct::end(state)
134 }
135}
136137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for VolumeAttachmentStatus {
139fn schema_name() -> std::string::String {
140"io.k8s.api.storage.v1.VolumeAttachmentStatus".into()
141 }
142143fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
144crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
145 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
146 description: Some("VolumeAttachmentStatus is the status of a VolumeAttachment request.".into()),
147 ..Default::default()
148 })),
149 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
150 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
151 properties: [
152 (
153"attachError".into(),
154 {
155let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeError>().into_object();
156 schema_obj.metadata = Some(std::boxed::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.".into()),
158 ..Default::default()
159 }));
160crate::schemars::schema::Schema::Object(schema_obj)
161 },
162 ),
163 (
164"attached".into(),
165crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
166 metadata: Some(std::boxed::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.".into()),
168 ..Default::default()
169 })),
170 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Boolean))),
171 ..Default::default()
172 }),
173 ),
174 (
175"attachmentMetadata".into(),
176crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
177 metadata: Some(std::boxed::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.".into()),
179 ..Default::default()
180 })),
181 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
182 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
183 additional_properties: Some(std::boxed::Box::new(
184crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
185 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
186 ..Default::default()
187 })
188 )),
189 ..Default::default()
190 })),
191 ..Default::default()
192 }),
193 ),
194 (
195"detachError".into(),
196 {
197let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeError>().into_object();
198 schema_obj.metadata = Some(std::boxed::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.".into()),
200 ..Default::default()
201 }));
202crate::schemars::schema::Schema::Object(schema_obj)
203 },
204 ),
205 ].into(),
206 required: [
207"attached".into(),
208 ].into(),
209 ..Default::default()
210 })),
211 ..Default::default()
212 })
213 }
214}