1// Generated from definition io.k8s.api.storage.v1alpha1.VolumeAttributesClass
23/// VolumeAttributesClass represents a specification of mutable volume attributes defined by the CSI driver. The class can be specified during dynamic provisioning of PersistentVolumeClaims, and changed in the PersistentVolumeClaim spec after provisioning.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct VolumeAttributesClass {
6/// Name of the CSI driver This field is immutable.
7pub driver_name: std::string::String,
89/// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
10pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
1112/// parameters hold volume attributes defined by the CSI driver. These values are opaque to the Kubernetes and are passed directly to the CSI driver. The underlying storage provider supports changing these attributes on an existing volume, however the parameters field itself is immutable. To invoke a volume update, a new VolumeAttributesClass should be created with new parameters, and the PersistentVolumeClaim should be updated to reference the new VolumeAttributesClass.
13 ///
14 /// This field is required and must contain at least one key/value pair. The keys cannot be empty, and the maximum number of parameters is 512, with a cumulative max size of 256K. If the CSI driver rejects invalid parameters, the target PersistentVolumeClaim will be set to an "Infeasible" state in the modifyVolumeStatus field.
15pub parameters: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
16}
1718impl crate::Resource for VolumeAttributesClass {
19const API_VERSION: &'static str = "storage.k8s.io/v1alpha1";
20const GROUP: &'static str = "storage.k8s.io";
21const KIND: &'static str = "VolumeAttributesClass";
22const VERSION: &'static str = "v1alpha1";
23const URL_PATH_SEGMENT: &'static str = "volumeattributesclasses";
24type Scope = crate::ClusterResourceScope;
25}
2627impl crate::ListableResource for VolumeAttributesClass {
28const LIST_KIND: &'static str = "VolumeAttributesClassList";
29}
3031impl crate::Metadata for VolumeAttributesClass {
32type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
3334fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
35&self.metadata
36 }
3738fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
39&mut self.metadata
40 }
41}
4243impl crate::DeepMerge for VolumeAttributesClass {
44fn merge_from(&mut self, other: Self) {
45crate::DeepMerge::merge_from(&mut self.driver_name, other.driver_name);
46crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
47crate::merge_strategies::map::granular(&mut self.parameters, other.parameters, |current_item, other_item| {
48crate::DeepMerge::merge_from(current_item, other_item);
49 });
50 }
51}
5253impl<'de> crate::serde::Deserialize<'de> for VolumeAttributesClass {
54fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
55#[allow(non_camel_case_types)]
56enum Field {
57 Key_api_version,
58 Key_kind,
59 Key_driver_name,
60 Key_metadata,
61 Key_parameters,
62 Other,
63 }
6465impl<'de> crate::serde::Deserialize<'de> for Field {
66fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
67struct Visitor;
6869impl crate::serde::de::Visitor<'_> for Visitor {
70type Value = Field;
7172fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
73 f.write_str("field identifier")
74 }
7576fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
77Ok(match v {
78"apiVersion" => Field::Key_api_version,
79"kind" => Field::Key_kind,
80"driverName" => Field::Key_driver_name,
81"metadata" => Field::Key_metadata,
82"parameters" => Field::Key_parameters,
83_ => Field::Other,
84 })
85 }
86 }
8788 deserializer.deserialize_identifier(Visitor)
89 }
90 }
9192struct Visitor;
9394impl<'de> crate::serde::de::Visitor<'de> for Visitor {
95type Value = VolumeAttributesClass;
9697fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
98 f.write_str(<Self::Value as crate::Resource>::KIND)
99 }
100101fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
102let mut value_driver_name: Option<std::string::String> = None;
103let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
104let mut value_parameters: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
105106while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
107match key {
108 Field::Key_api_version => {
109let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
110if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
111return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
112 }
113 },
114 Field::Key_kind => {
115let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
116if value_kind != <Self::Value as crate::Resource>::KIND {
117return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
118 }
119 },
120 Field::Key_driver_name => value_driver_name = crate::serde::de::MapAccess::next_value(&mut map)?,
121 Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
122 Field::Key_parameters => value_parameters = crate::serde::de::MapAccess::next_value(&mut map)?,
123 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
124 }
125 }
126127Ok(VolumeAttributesClass {
128 driver_name: value_driver_name.unwrap_or_default(),
129 metadata: value_metadata.unwrap_or_default(),
130 parameters: value_parameters,
131 })
132 }
133 }
134135 deserializer.deserialize_struct(
136 <Self as crate::Resource>::KIND,
137&[
138"apiVersion",
139"kind",
140"driverName",
141"metadata",
142"parameters",
143 ],
144 Visitor,
145 )
146 }
147}
148149impl crate::serde::Serialize for VolumeAttributesClass {
150fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
151let mut state = serializer.serialize_struct(
152 <Self as crate::Resource>::KIND,
1534 +
154self.parameters.as_ref().map_or(0, |_| 1),
155 )?;
156crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
157crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
158crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driverName", &self.driver_name)?;
159crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
160if let Some(value) = &self.parameters {
161crate::serde::ser::SerializeStruct::serialize_field(&mut state, "parameters", value)?;
162 }
163crate::serde::ser::SerializeStruct::end(state)
164 }
165}
166167#[cfg(feature = "schemars")]
168impl crate::schemars::JsonSchema for VolumeAttributesClass {
169fn schema_name() -> std::string::String {
170"io.k8s.api.storage.v1alpha1.VolumeAttributesClass".into()
171 }
172173fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
174crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
175 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
176 description: Some("VolumeAttributesClass represents a specification of mutable volume attributes defined by the CSI driver. The class can be specified during dynamic provisioning of PersistentVolumeClaims, and changed in the PersistentVolumeClaim spec after provisioning.".into()),
177 ..Default::default()
178 })),
179 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
180 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
181 properties: [
182 (
183"apiVersion".into(),
184crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
185 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
186 description: Some("APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources".into()),
187 ..Default::default()
188 })),
189 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
190 ..Default::default()
191 }),
192 ),
193 (
194"driverName".into(),
195crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
196 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
197 description: Some("Name of the CSI driver This field is immutable.".into()),
198 ..Default::default()
199 })),
200 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
201 ..Default::default()
202 }),
203 ),
204 (
205"kind".into(),
206crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
207 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
208 description: Some("Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds".into()),
209 ..Default::default()
210 })),
211 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
212 ..Default::default()
213 }),
214 ),
215 (
216"metadata".into(),
217 {
218let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>().into_object();
219 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
220 description: Some("Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata".into()),
221 ..Default::default()
222 }));
223crate::schemars::schema::Schema::Object(schema_obj)
224 },
225 ),
226 (
227"parameters".into(),
228crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
229 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
230 description: Some("parameters hold volume attributes defined by the CSI driver. These values are opaque to the Kubernetes and are passed directly to the CSI driver. The underlying storage provider supports changing these attributes on an existing volume, however the parameters field itself is immutable. To invoke a volume update, a new VolumeAttributesClass should be created with new parameters, and the PersistentVolumeClaim should be updated to reference the new VolumeAttributesClass.\n\nThis field is required and must contain at least one key/value pair. The keys cannot be empty, and the maximum number of parameters is 512, with a cumulative max size of 256K. If the CSI driver rejects invalid parameters, the target PersistentVolumeClaim will be set to an \"Infeasible\" state in the modifyVolumeStatus field.".into()),
231 ..Default::default()
232 })),
233 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
234 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
235 additional_properties: Some(std::boxed::Box::new(
236crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
237 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
238 ..Default::default()
239 })
240 )),
241 ..Default::default()
242 })),
243 ..Default::default()
244 }),
245 ),
246 ].into(),
247 required: [
248"driverName".into(),
249"metadata".into(),
250 ].into(),
251 ..Default::default()
252 })),
253 ..Default::default()
254 })
255 }
256}