#
k8s_openapi/v1_35/api/storage/v1/
volume_attributes_class.rs

    1// Generated from definition io.k8s.api.storage.v1.VolumeAttributesClass
    2
    3/// 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.
    7    pub driver_name: std::string::String,
    8
    9    /// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    10    pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
    11
    12    /// 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.
    15    pub parameters: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
    16}
    17
    18impl crate::Resource for VolumeAttributesClass {
    19    const API_VERSION: &'static str = "storage.k8s.io/v1";
    20    const GROUP: &'static str = "storage.k8s.io";
    21    const KIND: &'static str = "VolumeAttributesClass";
    22    const VERSION: &'static str = "v1";
    23    const URL_PATH_SEGMENT: &'static str = "volumeattributesclasses";
    24    type Scope = crate::ClusterResourceScope;
    25}
    26
    27impl crate::ListableResource for VolumeAttributesClass {
    28    const LIST_KIND: &'static str = "VolumeAttributesClassList";
    29}
    30
    31impl crate::Metadata for VolumeAttributesClass {
    32    type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
    33
    34    fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
    35        &self.metadata
    36    }
    37
    38    fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
    39        &mut self.metadata
    40    }
    41}
    42
    43impl crate::DeepMerge for VolumeAttributesClass {
    44    fn merge_from(&mut self, other: Self) {
    45        crate::DeepMerge::merge_from(&mut self.driver_name, other.driver_name);
    46        crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
    47        crate::merge_strategies::map::granular(&mut self.parameters, other.parameters, |current_item, other_item| {
    48            crate::DeepMerge::merge_from(current_item, other_item);
    49        });
    50    }
    51}
    52
    53impl<'de> crate::serde::Deserialize<'de> for VolumeAttributesClass {
    54    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    55        #[allow(non_camel_case_types)]
    56        enum Field {
    57            Key_api_version,
    58            Key_kind,
    59            Key_driver_name,
    60            Key_metadata,
    61            Key_parameters,
    62            Other,
    63        }
    64
    65        impl<'de> crate::serde::Deserialize<'de> for Field {
    66            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    67                struct Visitor;
    68
    69                impl crate::serde::de::Visitor<'_> for Visitor {
    70                    type Value = Field;
    71
    72                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    73                        f.write_str("field identifier")
    74                    }
    75
    76                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    77                        Ok(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                }
    87
    88                deserializer.deserialize_identifier(Visitor)
    89            }
    90        }
    91
    92        struct Visitor;
    93
    94        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    95            type Value = VolumeAttributesClass;
    96
    97            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    98                f.write_str(<Self::Value as crate::Resource>::KIND)
    99            }
    100
    101            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    102                let mut value_driver_name: Option<std::string::String> = None;
    103                let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
    104                let mut value_parameters: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
    105
    106                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    107                    match key {
    108                        Field::Key_api_version => {
    109                            let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    110                            if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
    111                                return 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 => {
    115                            let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    116                            if value_kind != <Self::Value as crate::Resource>::KIND {
    117                                return 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                }
    126
    127                Ok(VolumeAttributesClass {
    128                    driver_name: value_driver_name.unwrap_or_default(),
    129                    metadata: value_metadata.unwrap_or_default(),
    130                    parameters: value_parameters,
    131                })
    132            }
    133        }
    134
    135        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}
    148
    149impl crate::serde::Serialize for VolumeAttributesClass {
    150    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    151        let mut state = serializer.serialize_struct(
    152            <Self as crate::Resource>::KIND,
    153            4 +
    154            self.parameters.as_ref().map_or(0, |_| 1),
    155        )?;
    156        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
    157        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
    158        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driverName", &self.driver_name)?;
    159        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
    160        if let Some(value) = &self.parameters {
    161            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "parameters", value)?;
    162        }
    163        crate::serde::ser::SerializeStruct::end(state)
    164    }
    165}
    166
    167#[cfg(feature = "schemars")]
    168impl crate::schemars::JsonSchema for VolumeAttributesClass {
    169    fn schema_name() -> std::borrow::Cow<'static, str> {
    170        "io.k8s.api.storage.v1.VolumeAttributesClass".into()
    171    }
    172
    173    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    174        crate::schemars::json_schema!({
    175            "description": "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.",
    176            "type": "object",
    177            "properties": {
    178                "apiVersion": {
    179                    "description": "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",
    180                    "type": "string",
    181                },
    182                "driverName": {
    183                    "description": "Name of the CSI driver This field is immutable.",
    184                    "type": "string",
    185                },
    186                "kind": {
    187                    "description": "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",
    188                    "type": "string",
    189                },
    190                "metadata": ({
    191                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>();
    192                    schema_obj.ensure_object().insert("description".into(), "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata".into());
    193                    schema_obj
    194                }),
    195                "parameters": {
    196                    "description": "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.",
    197                    "type": "object",
    198                    "additionalProperties": {
    199                        "type": "string",
    200                    },
    201                },
    202            },
    203            "required": [
    204                "driverName",
    205                "metadata",
    206            ],
    207        })
    208    }
    209}