# 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, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from cloudera.ai.inference.models.serving_abs_inference_logging_config import ServingABSInferenceLoggingConfig
from cloudera.ai.inference.models.serving_data_lake_logging_config import ServingDataLakeLoggingConfig
from cloudera.ai.inference.models.serving_gcs_inference_logging_config import ServingGCSInferenceLoggingConfig
from cloudera.ai.inference.models.serving_s3_inference_logging_config import ServingS3InferenceLoggingConfig
from typing import Optional, Set
from typing_extensions import Self

class ServingInferenceLoggingConfig(BaseModel):
    """
    ServingInferenceLoggingConfig
    """ # noqa: E501
    enabled: Optional[StrictBool] = None
    explainer_s3_config: Optional[ServingS3InferenceLoggingConfig] = None
    explainer_abs_config: Optional[ServingABSInferenceLoggingConfig] = None
    explainer_gcs_config: Optional[ServingGCSInferenceLoggingConfig] = None
    explainer_datalake_config: Optional[ServingDataLakeLoggingConfig] = None
    predictor_s3_config: Optional[ServingS3InferenceLoggingConfig] = None
    predictor_abs_config: Optional[ServingABSInferenceLoggingConfig] = None
    predictor_gcs_config: Optional[ServingGCSInferenceLoggingConfig] = None
    predictor_datalake_config: Optional[ServingDataLakeLoggingConfig] = None
    transformer_s3_config: Optional[ServingS3InferenceLoggingConfig] = None
    transformer_abs_config: Optional[ServingABSInferenceLoggingConfig] = None
    transformer_gcs_config: Optional[ServingGCSInferenceLoggingConfig] = None
    transformer_datalake_config: Optional[ServingDataLakeLoggingConfig] = None
    format: Optional[StrictStr] = None
    batch_size: Optional[StrictInt] = Field(default=None, description="Number of inference records buffered into a single log object before flush.  Zero or unset means \"use the API default\" (1 for json, larger for parquet).")
    rollover_frequency: Optional[StrictStr] = Field(default=None, description="Wall-clock cadence at which a partial batch is flushed to storage even if  batch_size has not been reached. Unset means flush only on batch_size.")
    __properties: ClassVar[List[str]] = ["enabled", "explainer_s3_config", "explainer_abs_config", "explainer_gcs_config", "explainer_datalake_config", "predictor_s3_config", "predictor_abs_config", "predictor_gcs_config", "predictor_datalake_config", "transformer_s3_config", "transformer_abs_config", "transformer_gcs_config", "transformer_datalake_config", "format", "batch_size", "rollover_frequency"]

    @field_validator('format')
    def format_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['LOGGING_FORMAT_UNKNOWN', 'LOGGING_FORMAT_JSON', 'LOGGING_FORMAT_PARQUET']):
            raise ValueError("must be one of enum values ('LOGGING_FORMAT_UNKNOWN', 'LOGGING_FORMAT_JSON', 'LOGGING_FORMAT_PARQUET')")
        return value

    @field_validator('rollover_frequency')
    def rollover_frequency_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['ROLLOVER_FREQUENCY_UNKNOWN', 'ROLLOVER_FREQUENCY_FIVE_MINUTES', 'ROLLOVER_FREQUENCY_FIFTEEN_MINUTES', 'ROLLOVER_FREQUENCY_THIRTY_MINUTES', 'ROLLOVER_FREQUENCY_HOURLY', 'ROLLOVER_FREQUENCY_DAILY', 'ROLLOVER_FREQUENCY_WEEKLY']):
            raise ValueError("must be one of enum values ('ROLLOVER_FREQUENCY_UNKNOWN', 'ROLLOVER_FREQUENCY_FIVE_MINUTES', 'ROLLOVER_FREQUENCY_FIFTEEN_MINUTES', 'ROLLOVER_FREQUENCY_THIRTY_MINUTES', 'ROLLOVER_FREQUENCY_HOURLY', 'ROLLOVER_FREQUENCY_DAILY', 'ROLLOVER_FREQUENCY_WEEKLY')")
        return value

    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 ServingInferenceLoggingConfig 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 explainer_s3_config
        if self.explainer_s3_config:
            _dict['explainer_s3_config'] = self.explainer_s3_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of explainer_abs_config
        if self.explainer_abs_config:
            _dict['explainer_abs_config'] = self.explainer_abs_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of explainer_gcs_config
        if self.explainer_gcs_config:
            _dict['explainer_gcs_config'] = self.explainer_gcs_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of explainer_datalake_config
        if self.explainer_datalake_config:
            _dict['explainer_datalake_config'] = self.explainer_datalake_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of predictor_s3_config
        if self.predictor_s3_config:
            _dict['predictor_s3_config'] = self.predictor_s3_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of predictor_abs_config
        if self.predictor_abs_config:
            _dict['predictor_abs_config'] = self.predictor_abs_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of predictor_gcs_config
        if self.predictor_gcs_config:
            _dict['predictor_gcs_config'] = self.predictor_gcs_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of predictor_datalake_config
        if self.predictor_datalake_config:
            _dict['predictor_datalake_config'] = self.predictor_datalake_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of transformer_s3_config
        if self.transformer_s3_config:
            _dict['transformer_s3_config'] = self.transformer_s3_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of transformer_abs_config
        if self.transformer_abs_config:
            _dict['transformer_abs_config'] = self.transformer_abs_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of transformer_gcs_config
        if self.transformer_gcs_config:
            _dict['transformer_gcs_config'] = self.transformer_gcs_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of transformer_datalake_config
        if self.transformer_datalake_config:
            _dict['transformer_datalake_config'] = self.transformer_datalake_config.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "enabled": obj.get("enabled"),
            "explainer_s3_config": ServingS3InferenceLoggingConfig.from_dict(obj["explainer_s3_config"]) if obj.get("explainer_s3_config") is not None else None,
            "explainer_abs_config": ServingABSInferenceLoggingConfig.from_dict(obj["explainer_abs_config"]) if obj.get("explainer_abs_config") is not None else None,
            "explainer_gcs_config": ServingGCSInferenceLoggingConfig.from_dict(obj["explainer_gcs_config"]) if obj.get("explainer_gcs_config") is not None else None,
            "explainer_datalake_config": ServingDataLakeLoggingConfig.from_dict(obj["explainer_datalake_config"]) if obj.get("explainer_datalake_config") is not None else None,
            "predictor_s3_config": ServingS3InferenceLoggingConfig.from_dict(obj["predictor_s3_config"]) if obj.get("predictor_s3_config") is not None else None,
            "predictor_abs_config": ServingABSInferenceLoggingConfig.from_dict(obj["predictor_abs_config"]) if obj.get("predictor_abs_config") is not None else None,
            "predictor_gcs_config": ServingGCSInferenceLoggingConfig.from_dict(obj["predictor_gcs_config"]) if obj.get("predictor_gcs_config") is not None else None,
            "predictor_datalake_config": ServingDataLakeLoggingConfig.from_dict(obj["predictor_datalake_config"]) if obj.get("predictor_datalake_config") is not None else None,
            "transformer_s3_config": ServingS3InferenceLoggingConfig.from_dict(obj["transformer_s3_config"]) if obj.get("transformer_s3_config") is not None else None,
            "transformer_abs_config": ServingABSInferenceLoggingConfig.from_dict(obj["transformer_abs_config"]) if obj.get("transformer_abs_config") is not None else None,
            "transformer_gcs_config": ServingGCSInferenceLoggingConfig.from_dict(obj["transformer_gcs_config"]) if obj.get("transformer_gcs_config") is not None else None,
            "transformer_datalake_config": ServingDataLakeLoggingConfig.from_dict(obj["transformer_datalake_config"]) if obj.get("transformer_datalake_config") is not None else None,
            "format": obj.get("format"),
            "batch_size": obj.get("batch_size"),
            "rollover_frequency": obj.get("rollover_frequency")
        })
        return _obj


