# 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.29
    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 typing import Optional
from pydantic import BaseModel, Field
from .v1_cluster_trust_bundle_projection import V1ClusterTrustBundleProjection
from .v1_config_map_projection import V1ConfigMapProjection
from .v1_downward_api_projection import V1DownwardAPIProjection
from .v1_secret_projection import V1SecretProjection
from .v1_service_account_token_projection import V1ServiceAccountTokenProjection

class V1VolumeProjection(BaseModel):
    """
    Projection that may be projected along with other supported volume types  # noqa: E501
    """
    cluster_trust_bundle: Optional[V1ClusterTrustBundleProjection] = Field(None, alias="clusterTrustBundle")
    config_map: Optional[V1ConfigMapProjection] = Field(None, alias="configMap")
    downward_api: Optional[V1DownwardAPIProjection] = Field(None, alias="downwardAPI")
    secret: Optional[V1SecretProjection] = None
    service_account_token: Optional[V1ServiceAccountTokenProjection] = Field(None, alias="serviceAccountToken")
    __properties = ["clusterTrustBundle", "configMap", "downwardAPI", "secret", "serviceAccountToken"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

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

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of cluster_trust_bundle
        if self.cluster_trust_bundle:
            _dict['clusterTrustBundle'] = self.cluster_trust_bundle.to_dict()
        # override the default output from pydantic by calling `to_dict()` of config_map
        if self.config_map:
            _dict['configMap'] = self.config_map.to_dict()
        # override the default output from pydantic by calling `to_dict()` of downward_api
        if self.downward_api:
            _dict['downwardAPI'] = self.downward_api.to_dict()
        # override the default output from pydantic by calling `to_dict()` of secret
        if self.secret:
            _dict['secret'] = self.secret.to_dict()
        # override the default output from pydantic by calling `to_dict()` of service_account_token
        if self.service_account_token:
            _dict['serviceAccountToken'] = self.service_account_token.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> V1VolumeProjection:
        """Create an instance of V1VolumeProjection from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return V1VolumeProjection.parse_obj(obj)

        _obj = V1VolumeProjection.parse_obj({
            "cluster_trust_bundle": V1ClusterTrustBundleProjection.from_dict(obj.get("clusterTrustBundle")) if obj.get("clusterTrustBundle") is not None else None,
            "config_map": V1ConfigMapProjection.from_dict(obj.get("configMap")) if obj.get("configMap") is not None else None,
            "downward_api": V1DownwardAPIProjection.from_dict(obj.get("downwardAPI")) if obj.get("downwardAPI") is not None else None,
            "secret": V1SecretProjection.from_dict(obj.get("secret")) if obj.get("secret") is not None else None,
            "service_account_token": V1ServiceAccountTokenProjection.from_dict(obj.get("serviceAccountToken")) if obj.get("serviceAccountToken") is not None else None
        })
        return _obj


