# coding: utf-8

"""
    Kubernetes

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: release-1.37
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from collections.abc import Mapping as _Mapping
from pydantic import AliasChoices, BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, cast as _cast
from kubernetes.aio.client.models.v1_aws_elastic_block_store_volume_source import V1AWSElasticBlockStoreVolumeSource
from kubernetes.aio.client.models.v1_azure_disk_volume_source import V1AzureDiskVolumeSource
from kubernetes.aio.client.models.v1_azure_file_volume_source import V1AzureFileVolumeSource
from kubernetes.aio.client.models.v1_ceph_fs_volume_source import V1CephFSVolumeSource
from kubernetes.aio.client.models.v1_cinder_volume_source import V1CinderVolumeSource
from kubernetes.aio.client.models.v1_config_map_volume_source import V1ConfigMapVolumeSource
from kubernetes.aio.client.models.v1_csi_volume_source import V1CSIVolumeSource
from kubernetes.aio.client.models.v1_downward_api_volume_source import V1DownwardAPIVolumeSource
from kubernetes.aio.client.models.v1_empty_dir_volume_source import V1EmptyDirVolumeSource
from kubernetes.aio.client.models.v1_ephemeral_volume_source import V1EphemeralVolumeSource
from kubernetes.aio.client.models.v1_fc_volume_source import V1FCVolumeSource
from kubernetes.aio.client.models.v1_flex_volume_source import V1FlexVolumeSource
from kubernetes.aio.client.models.v1_flocker_volume_source import V1FlockerVolumeSource
from kubernetes.aio.client.models.v1_gce_persistent_disk_volume_source import V1GCEPersistentDiskVolumeSource
from kubernetes.aio.client.models.v1_git_repo_volume_source import V1GitRepoVolumeSource
from kubernetes.aio.client.models.v1_glusterfs_volume_source import V1GlusterfsVolumeSource
from kubernetes.aio.client.models.v1_host_path_volume_source import V1HostPathVolumeSource
from kubernetes.aio.client.models.v1_image_volume_source import V1ImageVolumeSource
from kubernetes.aio.client.models.v1_iscsi_volume_source import V1ISCSIVolumeSource
from kubernetes.aio.client.models.v1_nfs_volume_source import V1NFSVolumeSource
from kubernetes.aio.client.models.v1_persistent_volume_claim_volume_source import V1PersistentVolumeClaimVolumeSource
from kubernetes.aio.client.models.v1_photon_persistent_disk_volume_source import V1PhotonPersistentDiskVolumeSource
from kubernetes.aio.client.models.v1_portworx_volume_source import V1PortworxVolumeSource
from kubernetes.aio.client.models.v1_projected_volume_source import V1ProjectedVolumeSource
from kubernetes.aio.client.models.v1_quobyte_volume_source import V1QuobyteVolumeSource
from kubernetes.aio.client.models.v1_rbd_volume_source import V1RBDVolumeSource
from kubernetes.aio.client.models.v1_scale_io_volume_source import V1ScaleIOVolumeSource
from kubernetes.aio.client.models.v1_secret_volume_source import V1SecretVolumeSource
from kubernetes.aio.client.models.v1_storage_os_volume_source import V1StorageOSVolumeSource
from kubernetes.aio.client.models.v1_vsphere_virtual_disk_volume_source import V1VsphereVirtualDiskVolumeSource
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python


_OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict"


def _get_openapi_to_dict(value: Any) -> Any:
    # Reciprocal function references preserve inherited generated methods
    # without reserving model member names. Checking both directions also
    # rejects overrides whose decorators copy function attributes.
    to_dict = getattr(value, "to_dict", None)
    type_to_dict = getattr(type(value), "to_dict", None)
    if (
        not callable(to_dict)
        or getattr(to_dict, "__func__", None) is not type_to_dict
    ):
        return None

    openapi_to_dict = getattr(
        type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None
    )
    if (
        not callable(openapi_to_dict)
        or getattr(
            openapi_to_dict,
            _OPENAPI_GENERATOR_TO_DICT,
            None,
        ) is not type_to_dict
    ):
        return None
    return openapi_to_dict


def _to_legacy_item(value: Any, serialize: bool) -> Any:
    to_dict = getattr(value, "to_dict", None)
    if _get_openapi_to_dict(value) is not None and callable(to_dict):
        return to_dict(serialize=serialize)
    if callable(to_dict):
        return to_dict()
    return value


def _to_legacy_value(value: Any, serialize: bool) -> Any:
    # python-legacy converted only immediate list elements or dictionary values:
    # https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb49b45c940c2f694/modules/openapi-generator/src/main/resources/python-legacy/model.mustache#L203-L231
    if isinstance(value, list):
        return [_to_legacy_item(item, serialize) for item in value]
    if isinstance(value, dict):
        return {
            key: _to_legacy_item(item, serialize)
            for key, item in value.items()
        }
    return _to_legacy_item(value, serialize)


def _to_openapi_value(value: Any) -> Any:
    if isinstance(value, list):
        return [_to_openapi_value(item) for item in value]
    if isinstance(value, dict):
        return {key: _to_openapi_value(item) for key, item in value.items()}

    to_openapi_dict = _get_openapi_to_dict(value)
    if to_openapi_dict is not None:
        return to_openapi_dict(value)

    to_dict = getattr(value, "to_dict", None)
    if callable(to_dict):
        return to_dict()
    return value


class V1Volume(BaseModel):
    """
    Volume represents a named volume in a pod that may be accessed by any container in the pod.

    Attributes:
      openapi_types (dict): The key is attribute name
                            and the value is attribute type.
      attribute_map (dict): The key is attribute name
                            and the value is json key in definition.
    """ # noqa: E501
    aws_elastic_block_store: Optional[V1AWSElasticBlockStoreVolumeSource] = Field(default=None, validation_alias=AliasChoices("awsElasticBlockStore", "aws_elastic_block_store"), serialization_alias="awsElasticBlockStore")
    azure_disk: Optional[V1AzureDiskVolumeSource] = Field(default=None, validation_alias=AliasChoices("azureDisk", "azure_disk"), serialization_alias="azureDisk")
    azure_file: Optional[V1AzureFileVolumeSource] = Field(default=None, validation_alias=AliasChoices("azureFile", "azure_file"), serialization_alias="azureFile")
    cephfs: Optional[V1CephFSVolumeSource] = None
    cinder: Optional[V1CinderVolumeSource] = None
    config_map: Optional[V1ConfigMapVolumeSource] = Field(default=None, validation_alias=AliasChoices("configMap", "config_map"), serialization_alias="configMap")
    csi: Optional[V1CSIVolumeSource] = None
    downward_api: Optional[V1DownwardAPIVolumeSource] = Field(default=None, validation_alias=AliasChoices("downwardAPI", "downward_api"), serialization_alias="downwardAPI")
    empty_dir: Optional[V1EmptyDirVolumeSource] = Field(default=None, validation_alias=AliasChoices("emptyDir", "empty_dir"), serialization_alias="emptyDir")
    ephemeral: Optional[V1EphemeralVolumeSource] = None
    fc: Optional[V1FCVolumeSource] = None
    flex_volume: Optional[V1FlexVolumeSource] = Field(default=None, validation_alias=AliasChoices("flexVolume", "flex_volume"), serialization_alias="flexVolume")
    flocker: Optional[V1FlockerVolumeSource] = None
    gce_persistent_disk: Optional[V1GCEPersistentDiskVolumeSource] = Field(default=None, validation_alias=AliasChoices("gcePersistentDisk", "gce_persistent_disk"), serialization_alias="gcePersistentDisk")
    git_repo: Optional[V1GitRepoVolumeSource] = Field(default=None, validation_alias=AliasChoices("gitRepo", "git_repo"), serialization_alias="gitRepo")
    glusterfs: Optional[V1GlusterfsVolumeSource] = None
    host_path: Optional[V1HostPathVolumeSource] = Field(default=None, validation_alias=AliasChoices("hostPath", "host_path"), serialization_alias="hostPath")
    image: Optional[V1ImageVolumeSource] = None
    iscsi: Optional[V1ISCSIVolumeSource] = None
    name: StrictStr = Field(description="name of the volume. Must be a DNS_LABEL and unique within the pod. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names")
    nfs: Optional[V1NFSVolumeSource] = None
    persistent_volume_claim: Optional[V1PersistentVolumeClaimVolumeSource] = Field(default=None, validation_alias=AliasChoices("persistentVolumeClaim", "persistent_volume_claim"), serialization_alias="persistentVolumeClaim")
    photon_persistent_disk: Optional[V1PhotonPersistentDiskVolumeSource] = Field(default=None, validation_alias=AliasChoices("photonPersistentDisk", "photon_persistent_disk"), serialization_alias="photonPersistentDisk")
    portworx_volume: Optional[V1PortworxVolumeSource] = Field(default=None, validation_alias=AliasChoices("portworxVolume", "portworx_volume"), serialization_alias="portworxVolume")
    projected: Optional[V1ProjectedVolumeSource] = None
    quobyte: Optional[V1QuobyteVolumeSource] = None
    rbd: Optional[V1RBDVolumeSource] = None
    scale_io: Optional[V1ScaleIOVolumeSource] = Field(default=None, validation_alias=AliasChoices("scaleIO", "scale_io"), serialization_alias="scaleIO")
    secret: Optional[V1SecretVolumeSource] = None
    storageos: Optional[V1StorageOSVolumeSource] = None
    vsphere_volume: Optional[V1VsphereVirtualDiskVolumeSource] = Field(default=None, validation_alias=AliasChoices("vsphereVolume", "vsphere_volume"), serialization_alias="vsphereVolume")
    openapi_types: ClassVar[Dict[str, str]] = {
        "aws_elastic_block_store": "V1AWSElasticBlockStoreVolumeSource",
        "azure_disk": "V1AzureDiskVolumeSource",
        "azure_file": "V1AzureFileVolumeSource",
        "cephfs": "V1CephFSVolumeSource",
        "cinder": "V1CinderVolumeSource",
        "config_map": "V1ConfigMapVolumeSource",
        "csi": "V1CSIVolumeSource",
        "downward_api": "V1DownwardAPIVolumeSource",
        "empty_dir": "V1EmptyDirVolumeSource",
        "ephemeral": "V1EphemeralVolumeSource",
        "fc": "V1FCVolumeSource",
        "flex_volume": "V1FlexVolumeSource",
        "flocker": "V1FlockerVolumeSource",
        "gce_persistent_disk": "V1GCEPersistentDiskVolumeSource",
        "git_repo": "V1GitRepoVolumeSource",
        "glusterfs": "V1GlusterfsVolumeSource",
        "host_path": "V1HostPathVolumeSource",
        "image": "V1ImageVolumeSource",
        "iscsi": "V1ISCSIVolumeSource",
        "name": "str",
        "nfs": "V1NFSVolumeSource",
        "persistent_volume_claim": "V1PersistentVolumeClaimVolumeSource",
        "photon_persistent_disk": "V1PhotonPersistentDiskVolumeSource",
        "portworx_volume": "V1PortworxVolumeSource",
        "projected": "V1ProjectedVolumeSource",
        "quobyte": "V1QuobyteVolumeSource",
        "rbd": "V1RBDVolumeSource",
        "scale_io": "V1ScaleIOVolumeSource",
        "secret": "V1SecretVolumeSource",
        "storageos": "V1StorageOSVolumeSource",
        "vsphere_volume": "V1VsphereVirtualDiskVolumeSource"
    }

    attribute_map: ClassVar[Dict[str, str]] = {
        "aws_elastic_block_store": "awsElasticBlockStore",
        "azure_disk": "azureDisk",
        "azure_file": "azureFile",
        "cephfs": "cephfs",
        "cinder": "cinder",
        "config_map": "configMap",
        "csi": "csi",
        "downward_api": "downwardAPI",
        "empty_dir": "emptyDir",
        "ephemeral": "ephemeral",
        "fc": "fc",
        "flex_volume": "flexVolume",
        "flocker": "flocker",
        "gce_persistent_disk": "gcePersistentDisk",
        "git_repo": "gitRepo",
        "glusterfs": "glusterfs",
        "host_path": "hostPath",
        "image": "image",
        "iscsi": "iscsi",
        "name": "name",
        "nfs": "nfs",
        "persistent_volume_claim": "persistentVolumeClaim",
        "photon_persistent_disk": "photonPersistentDisk",
        "portworx_volume": "portworxVolume",
        "projected": "projected",
        "quobyte": "quobyte",
        "rbd": "rbd",
        "scale_io": "scaleIO",
        "secret": "secret",
        "storageos": "storageos",
        "vsphere_volume": "vsphereVolume"
    }
    __properties: ClassVar[List[str]] = ["awsElasticBlockStore", "azureDisk", "azureFile", "cephfs", "cinder", "configMap", "csi", "downwardAPI", "emptyDir", "ephemeral", "fc", "flexVolume", "flocker", "gcePersistentDisk", "gitRepo", "glusterfs", "hostPath", "image", "iscsi", "name", "nfs", "persistentVolumeClaim", "photonPersistentDisk", "portworxVolume", "projected", "quobyte", "rbd", "scaleIO", "secret", "storageos", "vsphereVolume"]

    @classmethod
    def __preprocess_input_names(
        cls,
        obj: Any,
        remove_hidden_storage_names: bool = True,
    ) -> Any:
        if not isinstance(obj, _Mapping):
            return obj
        obj = dict(obj)
        if "awsElasticBlockStore" not in obj and "aws_elastic_block_store" in obj:
            obj["awsElasticBlockStore"] = obj["aws_elastic_block_store"]
        obj.pop("aws_elastic_block_store", None)
        if "azureDisk" not in obj and "azure_disk" in obj:
            obj["azureDisk"] = obj["azure_disk"]
        obj.pop("azure_disk", None)
        if "azureFile" not in obj and "azure_file" in obj:
            obj["azureFile"] = obj["azure_file"]
        obj.pop("azure_file", None)
        if "configMap" not in obj and "config_map" in obj:
            obj["configMap"] = obj["config_map"]
        obj.pop("config_map", None)
        if "downwardAPI" not in obj and "downward_api" in obj:
            obj["downwardAPI"] = obj["downward_api"]
        obj.pop("downward_api", None)
        if "emptyDir" not in obj and "empty_dir" in obj:
            obj["emptyDir"] = obj["empty_dir"]
        obj.pop("empty_dir", None)
        if "flexVolume" not in obj and "flex_volume" in obj:
            obj["flexVolume"] = obj["flex_volume"]
        obj.pop("flex_volume", None)
        if "gcePersistentDisk" not in obj and "gce_persistent_disk" in obj:
            obj["gcePersistentDisk"] = obj["gce_persistent_disk"]
        obj.pop("gce_persistent_disk", None)
        if "gitRepo" not in obj and "git_repo" in obj:
            obj["gitRepo"] = obj["git_repo"]
        obj.pop("git_repo", None)
        if "hostPath" not in obj and "host_path" in obj:
            obj["hostPath"] = obj["host_path"]
        obj.pop("host_path", None)
        if "persistentVolumeClaim" not in obj and "persistent_volume_claim" in obj:
            obj["persistentVolumeClaim"] = obj["persistent_volume_claim"]
        obj.pop("persistent_volume_claim", None)
        if "photonPersistentDisk" not in obj and "photon_persistent_disk" in obj:
            obj["photonPersistentDisk"] = obj["photon_persistent_disk"]
        obj.pop("photon_persistent_disk", None)
        if "portworxVolume" not in obj and "portworx_volume" in obj:
            obj["portworxVolume"] = obj["portworx_volume"]
        obj.pop("portworx_volume", None)
        if "scaleIO" not in obj and "scale_io" in obj:
            obj["scaleIO"] = obj["scale_io"]
        obj.pop("scale_io", None)
        if "vsphereVolume" not in obj and "vsphere_volume" in obj:
            obj["vsphereVolume"] = obj["vsphere_volume"]
        obj.pop("vsphere_volume", None)
        return obj

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=True,
        validate_assignment=True,
        extra="forbid",
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model"""
        return pprint.pformat(self.to_dict())

    def __repr__(self) -> str:
        """For print and pprint"""
        return self.to_str()

    def __eq__(self, other: object) -> bool:
        """Returns true if both objects are equal"""
        if not isinstance(other, V1Volume):
            return False

        return self.to_dict() == other.to_dict()

    def __ne__(self, other: object) -> bool:
        """Returns true if both objects are not equal"""
        if not isinstance(other, V1Volume):
            return True

        return not (self == other)


    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        to_openapi_dict = _get_openapi_to_dict(self)
        if to_openapi_dict is not None:
            return json.dumps(to_jsonable_python(to_openapi_dict(self)))
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of V1Volume from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self, serialize: bool = False) -> Dict[str, Any]:
        """Return all declared model fields using public or wire names."""
        return {
            ("awsElasticBlockStore" if serialize else "aws_elastic_block_store"): _to_legacy_value(getattr(self, "aws_elastic_block_store", None), serialize),
            ("azureDisk" if serialize else "azure_disk"): _to_legacy_value(getattr(self, "azure_disk", None), serialize),
            ("azureFile" if serialize else "azure_file"): _to_legacy_value(getattr(self, "azure_file", None), serialize),
            ("cephfs" if serialize else "cephfs"): _to_legacy_value(getattr(self, "cephfs", None), serialize),
            ("cinder" if serialize else "cinder"): _to_legacy_value(getattr(self, "cinder", None), serialize),
            ("configMap" if serialize else "config_map"): _to_legacy_value(getattr(self, "config_map", None), serialize),
            ("csi" if serialize else "csi"): _to_legacy_value(getattr(self, "csi", None), serialize),
            ("downwardAPI" if serialize else "downward_api"): _to_legacy_value(getattr(self, "downward_api", None), serialize),
            ("emptyDir" if serialize else "empty_dir"): _to_legacy_value(getattr(self, "empty_dir", None), serialize),
            ("ephemeral" if serialize else "ephemeral"): _to_legacy_value(getattr(self, "ephemeral", None), serialize),
            ("fc" if serialize else "fc"): _to_legacy_value(getattr(self, "fc", None), serialize),
            ("flexVolume" if serialize else "flex_volume"): _to_legacy_value(getattr(self, "flex_volume", None), serialize),
            ("flocker" if serialize else "flocker"): _to_legacy_value(getattr(self, "flocker", None), serialize),
            ("gcePersistentDisk" if serialize else "gce_persistent_disk"): _to_legacy_value(getattr(self, "gce_persistent_disk", None), serialize),
            ("gitRepo" if serialize else "git_repo"): _to_legacy_value(getattr(self, "git_repo", None), serialize),
            ("glusterfs" if serialize else "glusterfs"): _to_legacy_value(getattr(self, "glusterfs", None), serialize),
            ("hostPath" if serialize else "host_path"): _to_legacy_value(getattr(self, "host_path", None), serialize),
            ("image" if serialize else "image"): _to_legacy_value(getattr(self, "image", None), serialize),
            ("iscsi" if serialize else "iscsi"): _to_legacy_value(getattr(self, "iscsi", None), serialize),
            ("name" if serialize else "name"): _to_legacy_value(getattr(self, "name", None), serialize),
            ("nfs" if serialize else "nfs"): _to_legacy_value(getattr(self, "nfs", None), serialize),
            ("persistentVolumeClaim" if serialize else "persistent_volume_claim"): _to_legacy_value(getattr(self, "persistent_volume_claim", None), serialize),
            ("photonPersistentDisk" if serialize else "photon_persistent_disk"): _to_legacy_value(getattr(self, "photon_persistent_disk", None), serialize),
            ("portworxVolume" if serialize else "portworx_volume"): _to_legacy_value(getattr(self, "portworx_volume", None), serialize),
            ("projected" if serialize else "projected"): _to_legacy_value(getattr(self, "projected", None), serialize),
            ("quobyte" if serialize else "quobyte"): _to_legacy_value(getattr(self, "quobyte", None), serialize),
            ("rbd" if serialize else "rbd"): _to_legacy_value(getattr(self, "rbd", None), serialize),
            ("scaleIO" if serialize else "scale_io"): _to_legacy_value(getattr(self, "scale_io", None), serialize),
            ("secret" if serialize else "secret"): _to_legacy_value(getattr(self, "secret", None), serialize),
            ("storageos" if serialize else "storageos"): _to_legacy_value(getattr(self, "storageos", None), serialize),
            ("vsphereVolume" if serialize else "vsphere_volume"): _to_legacy_value(getattr(self, "vsphere_volume", None), serialize),
        }

    def __openapi_generator_modern_projection(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of aws_elastic_block_store
        if self.aws_elastic_block_store:
            _dict['awsElasticBlockStore'] = _to_openapi_value(self.aws_elastic_block_store)
        # override the default output from pydantic by calling `to_dict()` of azure_disk
        if self.azure_disk:
            _dict['azureDisk'] = _to_openapi_value(self.azure_disk)
        # override the default output from pydantic by calling `to_dict()` of azure_file
        if self.azure_file:
            _dict['azureFile'] = _to_openapi_value(self.azure_file)
        # override the default output from pydantic by calling `to_dict()` of cephfs
        if self.cephfs:
            _dict['cephfs'] = _to_openapi_value(self.cephfs)
        # override the default output from pydantic by calling `to_dict()` of cinder
        if self.cinder:
            _dict['cinder'] = _to_openapi_value(self.cinder)
        # override the default output from pydantic by calling `to_dict()` of config_map
        if self.config_map:
            _dict['configMap'] = _to_openapi_value(self.config_map)
        # override the default output from pydantic by calling `to_dict()` of csi
        if self.csi:
            _dict['csi'] = _to_openapi_value(self.csi)
        # override the default output from pydantic by calling `to_dict()` of downward_api
        if self.downward_api:
            _dict['downwardAPI'] = _to_openapi_value(self.downward_api)
        # override the default output from pydantic by calling `to_dict()` of empty_dir
        if self.empty_dir:
            _dict['emptyDir'] = _to_openapi_value(self.empty_dir)
        # override the default output from pydantic by calling `to_dict()` of ephemeral
        if self.ephemeral:
            _dict['ephemeral'] = _to_openapi_value(self.ephemeral)
        # override the default output from pydantic by calling `to_dict()` of fc
        if self.fc:
            _dict['fc'] = _to_openapi_value(self.fc)
        # override the default output from pydantic by calling `to_dict()` of flex_volume
        if self.flex_volume:
            _dict['flexVolume'] = _to_openapi_value(self.flex_volume)
        # override the default output from pydantic by calling `to_dict()` of flocker
        if self.flocker:
            _dict['flocker'] = _to_openapi_value(self.flocker)
        # override the default output from pydantic by calling `to_dict()` of gce_persistent_disk
        if self.gce_persistent_disk:
            _dict['gcePersistentDisk'] = _to_openapi_value(self.gce_persistent_disk)
        # override the default output from pydantic by calling `to_dict()` of git_repo
        if self.git_repo:
            _dict['gitRepo'] = _to_openapi_value(self.git_repo)
        # override the default output from pydantic by calling `to_dict()` of glusterfs
        if self.glusterfs:
            _dict['glusterfs'] = _to_openapi_value(self.glusterfs)
        # override the default output from pydantic by calling `to_dict()` of host_path
        if self.host_path:
            _dict['hostPath'] = _to_openapi_value(self.host_path)
        # override the default output from pydantic by calling `to_dict()` of image
        if self.image:
            _dict['image'] = _to_openapi_value(self.image)
        # override the default output from pydantic by calling `to_dict()` of iscsi
        if self.iscsi:
            _dict['iscsi'] = _to_openapi_value(self.iscsi)
        # override the default output from pydantic by calling `to_dict()` of nfs
        if self.nfs:
            _dict['nfs'] = _to_openapi_value(self.nfs)
        # override the default output from pydantic by calling `to_dict()` of persistent_volume_claim
        if self.persistent_volume_claim:
            _dict['persistentVolumeClaim'] = _to_openapi_value(self.persistent_volume_claim)
        # override the default output from pydantic by calling `to_dict()` of photon_persistent_disk
        if self.photon_persistent_disk:
            _dict['photonPersistentDisk'] = _to_openapi_value(self.photon_persistent_disk)
        # override the default output from pydantic by calling `to_dict()` of portworx_volume
        if self.portworx_volume:
            _dict['portworxVolume'] = _to_openapi_value(self.portworx_volume)
        # override the default output from pydantic by calling `to_dict()` of projected
        if self.projected:
            _dict['projected'] = _to_openapi_value(self.projected)
        # override the default output from pydantic by calling `to_dict()` of quobyte
        if self.quobyte:
            _dict['quobyte'] = _to_openapi_value(self.quobyte)
        # override the default output from pydantic by calling `to_dict()` of rbd
        if self.rbd:
            _dict['rbd'] = _to_openapi_value(self.rbd)
        # override the default output from pydantic by calling `to_dict()` of scale_io
        if self.scale_io:
            _dict['scaleIO'] = _to_openapi_value(self.scale_io)
        # override the default output from pydantic by calling `to_dict()` of secret
        if self.secret:
            _dict['secret'] = _to_openapi_value(self.secret)
        # override the default output from pydantic by calling `to_dict()` of storageos
        if self.storageos:
            _dict['storageos'] = _to_openapi_value(self.storageos)
        # override the default output from pydantic by calling `to_dict()` of vsphere_volume
        if self.vsphere_volume:
            _dict['vsphereVolume'] = _to_openapi_value(self.vsphere_volume)
        return _dict

    setattr(
        to_dict,
        _OPENAPI_GENERATOR_TO_DICT,
        __openapi_generator_modern_projection,
    )
    setattr(
        __openapi_generator_modern_projection,
        _OPENAPI_GENERATOR_TO_DICT,
        to_dict,
    )
    del __openapi_generator_modern_projection

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of V1Volume from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        obj = _cast(
            Dict[str, Any],
            cls.__preprocess_input_names(
                obj,
                remove_hidden_storage_names=True,
            ),
        )

        _obj = cls.model_validate({
            "awsElasticBlockStore": V1AWSElasticBlockStoreVolumeSource.from_dict(obj["awsElasticBlockStore"]) if obj.get("awsElasticBlockStore") is not None else None,
            "azureDisk": V1AzureDiskVolumeSource.from_dict(obj["azureDisk"]) if obj.get("azureDisk") is not None else None,
            "azureFile": V1AzureFileVolumeSource.from_dict(obj["azureFile"]) if obj.get("azureFile") is not None else None,
            "cephfs": V1CephFSVolumeSource.from_dict(obj["cephfs"]) if obj.get("cephfs") is not None else None,
            "cinder": V1CinderVolumeSource.from_dict(obj["cinder"]) if obj.get("cinder") is not None else None,
            "configMap": V1ConfigMapVolumeSource.from_dict(obj["configMap"]) if obj.get("configMap") is not None else None,
            "csi": V1CSIVolumeSource.from_dict(obj["csi"]) if obj.get("csi") is not None else None,
            "downwardAPI": V1DownwardAPIVolumeSource.from_dict(obj["downwardAPI"]) if obj.get("downwardAPI") is not None else None,
            "emptyDir": V1EmptyDirVolumeSource.from_dict(obj["emptyDir"]) if obj.get("emptyDir") is not None else None,
            "ephemeral": V1EphemeralVolumeSource.from_dict(obj["ephemeral"]) if obj.get("ephemeral") is not None else None,
            "fc": V1FCVolumeSource.from_dict(obj["fc"]) if obj.get("fc") is not None else None,
            "flexVolume": V1FlexVolumeSource.from_dict(obj["flexVolume"]) if obj.get("flexVolume") is not None else None,
            "flocker": V1FlockerVolumeSource.from_dict(obj["flocker"]) if obj.get("flocker") is not None else None,
            "gcePersistentDisk": V1GCEPersistentDiskVolumeSource.from_dict(obj["gcePersistentDisk"]) if obj.get("gcePersistentDisk") is not None else None,
            "gitRepo": V1GitRepoVolumeSource.from_dict(obj["gitRepo"]) if obj.get("gitRepo") is not None else None,
            "glusterfs": V1GlusterfsVolumeSource.from_dict(obj["glusterfs"]) if obj.get("glusterfs") is not None else None,
            "hostPath": V1HostPathVolumeSource.from_dict(obj["hostPath"]) if obj.get("hostPath") is not None else None,
            "image": V1ImageVolumeSource.from_dict(obj["image"]) if obj.get("image") is not None else None,
            "iscsi": V1ISCSIVolumeSource.from_dict(obj["iscsi"]) if obj.get("iscsi") is not None else None,
            "name": obj.get("name"),
            "nfs": V1NFSVolumeSource.from_dict(obj["nfs"]) if obj.get("nfs") is not None else None,
            "persistentVolumeClaim": V1PersistentVolumeClaimVolumeSource.from_dict(obj["persistentVolumeClaim"]) if obj.get("persistentVolumeClaim") is not None else None,
            "photonPersistentDisk": V1PhotonPersistentDiskVolumeSource.from_dict(obj["photonPersistentDisk"]) if obj.get("photonPersistentDisk") is not None else None,
            "portworxVolume": V1PortworxVolumeSource.from_dict(obj["portworxVolume"]) if obj.get("portworxVolume") is not None else None,
            "projected": V1ProjectedVolumeSource.from_dict(obj["projected"]) if obj.get("projected") is not None else None,
            "quobyte": V1QuobyteVolumeSource.from_dict(obj["quobyte"]) if obj.get("quobyte") is not None else None,
            "rbd": V1RBDVolumeSource.from_dict(obj["rbd"]) if obj.get("rbd") is not None else None,
            "scaleIO": V1ScaleIOVolumeSource.from_dict(obj["scaleIO"]) if obj.get("scaleIO") is not None else None,
            "secret": V1SecretVolumeSource.from_dict(obj["secret"]) if obj.get("secret") is not None else None,
            "storageos": V1StorageOSVolumeSource.from_dict(obj["storageos"]) if obj.get("storageos") is not None else None,
            "vsphereVolume": V1VsphereVirtualDiskVolumeSource.from_dict(obj["vsphereVolume"]) if obj.get("vsphereVolume") is not None else None
        })
        return _obj
