# coding: utf-8

"""
    FlowHunt

    FlowHunt API

    The version of the OpenAPI document: 2.0.0
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from flowhunt.models.aspec_ratio import AspecRatio
from flowhunt.models.base_foundation_model import BaseFoundationModel
from typing import Optional, Set
from typing_extensions import Self

class InferenceHistorySearchRequest(BaseModel):
    """
    InferenceHistorySearchRequest
    """ # noqa: E501
    from_date: Optional[datetime] = None
    to_date: Optional[datetime] = None
    limit: Optional[StrictInt] = Field(default=10, description="The number of results to return")
    search_after: Optional[List[Any]] = None
    base_model: Optional[BaseFoundationModel] = None
    style: Optional[StrictStr] = None
    effect: Optional[StrictStr] = None
    aspect_ratio: Optional[AspecRatio] = None
    __properties: ClassVar[List[str]] = ["from_date", "to_date", "limit", "search_after", "base_model", "style", "effect", "aspect_ratio"]

    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 InferenceHistorySearchRequest 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,
        )
        # set to None if from_date (nullable) is None
        # and model_fields_set contains the field
        if self.from_date is None and "from_date" in self.model_fields_set:
            _dict['from_date'] = None

        # set to None if to_date (nullable) is None
        # and model_fields_set contains the field
        if self.to_date is None and "to_date" in self.model_fields_set:
            _dict['to_date'] = None

        # set to None if search_after (nullable) is None
        # and model_fields_set contains the field
        if self.search_after is None and "search_after" in self.model_fields_set:
            _dict['search_after'] = None

        # set to None if base_model (nullable) is None
        # and model_fields_set contains the field
        if self.base_model is None and "base_model" in self.model_fields_set:
            _dict['base_model'] = None

        # set to None if style (nullable) is None
        # and model_fields_set contains the field
        if self.style is None and "style" in self.model_fields_set:
            _dict['style'] = None

        # set to None if effect (nullable) is None
        # and model_fields_set contains the field
        if self.effect is None and "effect" in self.model_fields_set:
            _dict['effect'] = None

        # set to None if aspect_ratio (nullable) is None
        # and model_fields_set contains the field
        if self.aspect_ratio is None and "aspect_ratio" in self.model_fields_set:
            _dict['aspect_ratio'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "from_date": obj.get("from_date"),
            "to_date": obj.get("to_date"),
            "limit": obj.get("limit") if obj.get("limit") is not None else 10,
            "search_after": obj.get("search_after"),
            "base_model": obj.get("base_model"),
            "style": obj.get("style"),
            "effect": obj.get("effect"),
            "aspect_ratio": obj.get("aspect_ratio")
        })
        return _obj


