# coding: utf-8

"""
    Cloudera AI Inference

    CML Serving :: Install and manage CML Serving workloads.

    The version of the OpenAPI document: v1alpha1
    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 pydantic import BaseModel, ConfigDict, Field
from typing import Any, ClassVar, Dict, List, Optional
from cloudera.ai.inference.models.serving_service_status import ServingServiceStatus
from typing import Optional, Set
from typing_extensions import Self

class ServingDescribeServiceHealthResponse(BaseModel):
    """
    ServingDescribeServiceHealthResponse
    """ # noqa: E501
    cml_serving_api: Optional[ServingServiceStatus] = Field(default=None, alias="cmlServingApi")
    kubernetes: Optional[ServingServiceStatus] = None
    knative: Optional[ServingServiceStatus] = None
    kserve: Optional[ServingServiceStatus] = None
    istio: Optional[ServingServiceStatus] = None
    cml_registry: Optional[ServingServiceStatus] = Field(default=None, alias="cmlRegistry")
    cml_client: Optional[ServingServiceStatus] = Field(default=None, alias="cmlClient")
    archiver_client: Optional[ServingServiceStatus] = Field(default=None, alias="archiverClient")
    usage_reporter_client: Optional[ServingServiceStatus] = Field(default=None, alias="usageReporterClient")
    authorizer_client: Optional[ServingServiceStatus] = Field(default=None, alias="authorizerClient")
    __properties: ClassVar[List[str]] = ["cmlServingApi", "kubernetes", "knative", "kserve", "istio", "cmlRegistry", "cmlClient", "archiverClient", "usageReporterClient", "authorizerClient"]

    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) -> Optional[Self]:
        """Create an instance of ServingDescribeServiceHealthResponse 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 cml_serving_api
        if self.cml_serving_api:
            _dict['cmlServingApi'] = self.cml_serving_api.to_dict()
        # override the default output from pydantic by calling `to_dict()` of kubernetes
        if self.kubernetes:
            _dict['kubernetes'] = self.kubernetes.to_dict()
        # override the default output from pydantic by calling `to_dict()` of knative
        if self.knative:
            _dict['knative'] = self.knative.to_dict()
        # override the default output from pydantic by calling `to_dict()` of kserve
        if self.kserve:
            _dict['kserve'] = self.kserve.to_dict()
        # override the default output from pydantic by calling `to_dict()` of istio
        if self.istio:
            _dict['istio'] = self.istio.to_dict()
        # override the default output from pydantic by calling `to_dict()` of cml_registry
        if self.cml_registry:
            _dict['cmlRegistry'] = self.cml_registry.to_dict()
        # override the default output from pydantic by calling `to_dict()` of cml_client
        if self.cml_client:
            _dict['cmlClient'] = self.cml_client.to_dict()
        # override the default output from pydantic by calling `to_dict()` of archiver_client
        if self.archiver_client:
            _dict['archiverClient'] = self.archiver_client.to_dict()
        # override the default output from pydantic by calling `to_dict()` of usage_reporter_client
        if self.usage_reporter_client:
            _dict['usageReporterClient'] = self.usage_reporter_client.to_dict()
        # override the default output from pydantic by calling `to_dict()` of authorizer_client
        if self.authorizer_client:
            _dict['authorizerClient'] = self.authorizer_client.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "cmlServingApi": ServingServiceStatus.from_dict(obj["cmlServingApi"]) if obj.get("cmlServingApi") is not None else None,
            "kubernetes": ServingServiceStatus.from_dict(obj["kubernetes"]) if obj.get("kubernetes") is not None else None,
            "knative": ServingServiceStatus.from_dict(obj["knative"]) if obj.get("knative") is not None else None,
            "kserve": ServingServiceStatus.from_dict(obj["kserve"]) if obj.get("kserve") is not None else None,
            "istio": ServingServiceStatus.from_dict(obj["istio"]) if obj.get("istio") is not None else None,
            "cmlRegistry": ServingServiceStatus.from_dict(obj["cmlRegistry"]) if obj.get("cmlRegistry") is not None else None,
            "cmlClient": ServingServiceStatus.from_dict(obj["cmlClient"]) if obj.get("cmlClient") is not None else None,
            "archiverClient": ServingServiceStatus.from_dict(obj["archiverClient"]) if obj.get("archiverClient") is not None else None,
            "usageReporterClient": ServingServiceStatus.from_dict(obj["usageReporterClient"]) if obj.get("usageReporterClient") is not None else None,
            "authorizerClient": ServingServiceStatus.from_dict(obj["authorizerClient"]) if obj.get("authorizerClient") is not None else None
        })
        return _obj


