# coding: utf-8

"""
    Generated by: https://openapi-generator.tech
"""

from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictBool
from typing import Any, ClassVar, Dict, List, Optional
from regula.facesdk.webclient.gen.models.face_quality_scenarios import FaceQualityScenarios
from regula.facesdk.webclient.gen.models.output_image_params import OutputImageParams
from regula.facesdk.webclient.gen.models.process_param_attributes import ProcessParamAttributes
from regula.facesdk.webclient.gen.models.quality_request import QualityRequest
from typing import Optional, Set
from typing_extensions import Self
from pydantic import SkipValidation, Field

class ProcessParam(BaseModel):
    """
    The processing parameters.
    """ # noqa: E501
    scenario: SkipValidation[Optional[FaceQualityScenarios]] = Field(alias="scenario", default=None)
    only_central_face: SkipValidation[Optional[bool]] = Field(alias="onlyCentralFace", default=None, description="Whether to process only the central face in the image. If set to `false`, all the faces are processed.")
    output_image_params: SkipValidation[Optional[OutputImageParams]] = Field(alias="outputImageParams", default=None)
    quality: SkipValidation[Optional[QualityRequest]] = Field(alias="quality", default=None)
    attributes: SkipValidation[Optional[ProcessParamAttributes]] = Field(alias="attributes", default=None)
    __properties: ClassVar[List[str]] = ["scenario", "onlyCentralFace", "outputImageParams", "quality", "attributes"]

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


    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 ProcessParam 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 output_image_params
        if self.output_image_params:
            _dict['outputImageParams'] = self.output_image_params.to_dict()
        # override the default output from pydantic by calling `to_dict()` of quality
        if self.quality:
            _dict['quality'] = self.quality.to_dict()
        # override the default output from pydantic by calling `to_dict()` of attributes
        if self.attributes:
            _dict['attributes'] = self.attributes.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "scenario": obj.get("scenario"),
            "onlyCentralFace": obj.get("onlyCentralFace"),
            "outputImageParams": OutputImageParams.from_dict(obj["outputImageParams"]) if obj.get("outputImageParams") is not None else None,
            "quality": QualityRequest.from_dict(obj["quality"]) if obj.get("quality") is not None else None,
            "attributes": ProcessParamAttributes.from_dict(obj["attributes"]) if obj.get("attributes") is not None else None
        })
        return _obj


