
"""
ARL Infrastructure API

OpenAPI specification for ARL (Agentic RL) Infrastructure custom resources. This SDK provides models for WarmPool, Sandbox, and Task Kubernetes custom resources.

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

Do not edit the class manually.
"""

from __future__ import annotations

import json
import pprint
import re  # noqa: F401
from typing import Any, ClassVar

from pydantic import BaseModel, ConfigDict, Field
from typing_extensions import Self

from .models.warm_pool_spec_template_spec_volumes_inner_projected_sources_inner_cluster_trust_bundle import (
    WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerClusterTrustBundle,
)
from .models.warm_pool_spec_template_spec_volumes_inner_projected_sources_inner_config_map import (
    WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerConfigMap,
)
from .models.warm_pool_spec_template_spec_volumes_inner_projected_sources_inner_downward_api import (
    WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerDownwardAPI,
)
from .models.warm_pool_spec_template_spec_volumes_inner_projected_sources_inner_pod_certificate import (
    WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerPodCertificate,
)
from .models.warm_pool_spec_template_spec_volumes_inner_projected_sources_inner_service_account_token import (
    WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerServiceAccountToken,
)


class WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInner(BaseModel):
    """
    WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInner
    """

    cluster_trust_bundle: WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerClusterTrustBundle | None = Field(default=None, alias="clusterTrustBundle")
    config_map: WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerConfigMap | None = (
        Field(default=None, alias="configMap")
    )
    downward_api: WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerDownwardAPI | None = (
        Field(default=None, alias="downwardAPI")
    )
    pod_certificate: WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerPodCertificate | None = Field(default=None, alias="podCertificate")
    secret: WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerConfigMap | None = None
    service_account_token: WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerServiceAccountToken | None = Field(default=None, alias="serviceAccountToken")
    __properties: ClassVar[list[str]] = [
        "clusterTrustBundle",
        "configMap",
        "downwardAPI",
        "podCertificate",
        "secret",
        "serviceAccountToken",
    ]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )

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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

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

    def to_dict(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 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 pod_certificate
        if self.pod_certificate:
            _dict["podCertificate"] = self.pod_certificate.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[str, Any] | None) -> Self | None:
        """Create an instance of WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInner from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate(
            {
                "clusterTrustBundle": WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerClusterTrustBundle.from_dict(
                    obj["clusterTrustBundle"]
                )
                if obj.get("clusterTrustBundle") is not None
                else None,
                "configMap": WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerConfigMap.from_dict(
                    obj["configMap"]
                )
                if obj.get("configMap") is not None
                else None,
                "downwardAPI": WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerDownwardAPI.from_dict(
                    obj["downwardAPI"]
                )
                if obj.get("downwardAPI") is not None
                else None,
                "podCertificate": WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerPodCertificate.from_dict(
                    obj["podCertificate"]
                )
                if obj.get("podCertificate") is not None
                else None,
                "secret": WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerConfigMap.from_dict(
                    obj["secret"]
                )
                if obj.get("secret") is not None
                else None,
                "serviceAccountToken": WarmPoolSpecTemplateSpecVolumesInnerProjectedSourcesInnerServiceAccountToken.from_dict(
                    obj["serviceAccountToken"]
                )
                if obj.get("serviceAccountToken") is not None
                else None,
            }
        )
        return _obj
