#
k8s_openapi/v1_35/api/core/v1/
vsphere_virtual_disk_volume_source.rs

    1// Generated from definition io.k8s.api.core.v1.VsphereVirtualDiskVolumeSource
    2
    3/// Represents a vSphere volume resource.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct VsphereVirtualDiskVolumeSource {
    6    /// fsType is filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
    7    pub fs_type: Option<std::string::String>,
    8
    9    /// storagePolicyID is the storage Policy Based Management (SPBM) profile ID associated with the StoragePolicyName.
    10    pub storage_policy_id: Option<std::string::String>,
    11
    12    /// storagePolicyName is the storage Policy Based Management (SPBM) profile name.
    13    pub storage_policy_name: Option<std::string::String>,
    14
    15    /// volumePath is the path that identifies vSphere volume vmdk
    16    pub volume_path: std::string::String,
    17}
    18
    19impl crate::DeepMerge for VsphereVirtualDiskVolumeSource {
    20    fn merge_from(&mut self, other: Self) {
    21        crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
    22        crate::DeepMerge::merge_from(&mut self.storage_policy_id, other.storage_policy_id);
    23        crate::DeepMerge::merge_from(&mut self.storage_policy_name, other.storage_policy_name);
    24        crate::DeepMerge::merge_from(&mut self.volume_path, other.volume_path);
    25    }
    26}
    27
    28impl<'de> crate::serde::Deserialize<'de> for VsphereVirtualDiskVolumeSource {
    29    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    30        #[allow(non_camel_case_types)]
    31        enum Field {
    32            Key_fs_type,
    33            Key_storage_policy_id,
    34            Key_storage_policy_name,
    35            Key_volume_path,
    36            Other,
    37        }
    38
    39        impl<'de> crate::serde::Deserialize<'de> for Field {
    40            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    41                struct Visitor;
    42
    43                impl crate::serde::de::Visitor<'_> for Visitor {
    44                    type Value = Field;
    45
    46                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    47                        f.write_str("field identifier")
    48                    }
    49
    50                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    51                        Ok(match v {
    52                            "fsType" => Field::Key_fs_type,
    53                            "storagePolicyID" => Field::Key_storage_policy_id,
    54                            "storagePolicyName" => Field::Key_storage_policy_name,
    55                            "volumePath" => Field::Key_volume_path,
    56                            _ => Field::Other,
    57                        })
    58                    }
    59                }
    60
    61                deserializer.deserialize_identifier(Visitor)
    62            }
    63        }
    64
    65        struct Visitor;
    66
    67        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    68            type Value = VsphereVirtualDiskVolumeSource;
    69
    70            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    71                f.write_str("VsphereVirtualDiskVolumeSource")
    72            }
    73
    74            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    75                let mut value_fs_type: Option<std::string::String> = None;
    76                let mut value_storage_policy_id: Option<std::string::String> = None;
    77                let mut value_storage_policy_name: Option<std::string::String> = None;
    78                let mut value_volume_path: Option<std::string::String> = None;
    79
    80                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    81                    match key {
    82                        Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
    83                        Field::Key_storage_policy_id => value_storage_policy_id = crate::serde::de::MapAccess::next_value(&mut map)?,
    84                        Field::Key_storage_policy_name => value_storage_policy_name = crate::serde::de::MapAccess::next_value(&mut map)?,
    85                        Field::Key_volume_path => value_volume_path = crate::serde::de::MapAccess::next_value(&mut map)?,
    86                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    87                    }
    88                }
    89
    90                Ok(VsphereVirtualDiskVolumeSource {
    91                    fs_type: value_fs_type,
    92                    storage_policy_id: value_storage_policy_id,
    93                    storage_policy_name: value_storage_policy_name,
    94                    volume_path: value_volume_path.unwrap_or_default(),
    95                })
    96            }
    97        }
    98
    99        deserializer.deserialize_struct(
    100            "VsphereVirtualDiskVolumeSource",
    101            &[
    102                "fsType",
    103                "storagePolicyID",
    104                "storagePolicyName",
    105                "volumePath",
    106            ],
    107            Visitor,
    108        )
    109    }
    110}
    111
    112impl crate::serde::Serialize for VsphereVirtualDiskVolumeSource {
    113    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    114        let mut state = serializer.serialize_struct(
    115            "VsphereVirtualDiskVolumeSource",
    116            1 +
    117            self.fs_type.as_ref().map_or(0, |_| 1) +
    118            self.storage_policy_id.as_ref().map_or(0, |_| 1) +
    119            self.storage_policy_name.as_ref().map_or(0, |_| 1),
    120        )?;
    121        if let Some(value) = &self.fs_type {
    122            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
    123        }
    124        if let Some(value) = &self.storage_policy_id {
    125            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "storagePolicyID", value)?;
    126        }
    127        if let Some(value) = &self.storage_policy_name {
    128            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "storagePolicyName", value)?;
    129        }
    130        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumePath", &self.volume_path)?;
    131        crate::serde::ser::SerializeStruct::end(state)
    132    }
    133}
    134
    135#[cfg(feature = "schemars")]
    136impl crate::schemars::JsonSchema for VsphereVirtualDiskVolumeSource {
    137    fn schema_name() -> std::borrow::Cow<'static, str> {
    138        "io.k8s.api.core.v1.VsphereVirtualDiskVolumeSource".into()
    139    }
    140
    141    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    142        crate::schemars::json_schema!({
    143            "description": "Represents a vSphere volume resource.",
    144            "type": "object",
    145            "properties": {
    146                "fsType": {
    147                    "description": "fsType is filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.",
    148                    "type": "string",
    149                },
    150                "storagePolicyID": {
    151                    "description": "storagePolicyID is the storage Policy Based Management (SPBM) profile ID associated with the StoragePolicyName.",
    152                    "type": "string",
    153                },
    154                "storagePolicyName": {
    155                    "description": "storagePolicyName is the storage Policy Based Management (SPBM) profile name.",
    156                    "type": "string",
    157                },
    158                "volumePath": {
    159                    "description": "volumePath is the path that identifies vSphere volume vmdk",
    160                    "type": "string",
    161                },
    162            },
    163            "required": [
    164                "volumePath",
    165            ],
    166        })
    167    }
    168}