# 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, StrictBool, StrictStr
from .v1_label_selector import V1LabelSelector

class V1ClusterTrustBundleProjection(BaseModel):
    """
    ClusterTrustBundleProjection describes how to select a set of ClusterTrustBundle objects and project their contents into the pod filesystem.  # noqa: E501
    """
    label_selector: Optional[V1LabelSelector] = Field(None, alias="labelSelector")
    name: Optional[StrictStr] = Field(None, description="Select a single ClusterTrustBundle by object name.  Mutually-exclusive with signerName and labelSelector.")
    optional: Optional[StrictBool] = Field(None, description="If true, don't block pod startup if the referenced ClusterTrustBundle(s) aren't available.  If using name, then the named ClusterTrustBundle is allowed not to exist.  If using signerName, then the combination of signerName and labelSelector is allowed to match zero ClusterTrustBundles.")
    path: StrictStr = Field(..., description="Relative path from the volume root to write the bundle.")
    signer_name: Optional[StrictStr] = Field(None, alias="signerName", description="Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name.  The contents of all selected ClusterTrustBundles will be unified and deduplicated.")
    __properties = ["labelSelector", "name", "optional", "path", "signerName"]

    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) -> V1ClusterTrustBundleProjection:
        """Create an instance of V1ClusterTrustBundleProjection 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 label_selector
        if self.label_selector:
            _dict['labelSelector'] = self.label_selector.to_dict()
        return _dict

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

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

        _obj = V1ClusterTrustBundleProjection.parse_obj({
            "label_selector": V1LabelSelector.from_dict(obj.get("labelSelector")) if obj.get("labelSelector") is not None else None,
            "name": obj.get("name"),
            "optional": obj.get("optional"),
            "path": obj.get("path"),
            "signer_name": obj.get("signerName")
        })
        return _obj


