# coding: utf-8

"""
    Search API

    API for search functionality.

    The version of the OpenAPI document: 
    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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from yfkm3_services_search_client.models.document_type import DocumentType
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class TitleContentSearchRequest(BaseModel):
    """
    TitleContentSearchRequest
    """ # noqa: E501
    query: StrictStr
    space_id: StrictInt
    collection_ids: Optional[List[StrictInt]] = None
    page: Optional[Annotated[int, Field(strict=True, ge=1)]] = 1
    page_size: Optional[Annotated[int, Field(strict=True, ge=1)]] = 5
    title_boost: Optional[Union[StrictFloat, StrictInt]] = 4.0
    content_boost: Optional[Union[StrictFloat, StrictInt]] = 1.0
    document_type: Optional[DocumentType] = None
    document_id_list: Optional[List[StrictStr]] = None
    exclude_document_id_list: Optional[List[StrictStr]] = None
    exclude_paragraph_list: Optional[List[StrictStr]] = None
    is_active: Optional[StrictBool] = None
    __properties: ClassVar[List[str]] = ["query", "space_id", "collection_ids", "page", "page_size", "title_boost", "content_boost", "document_type", "document_id_list", "exclude_document_id_list", "exclude_paragraph_list", "is_active"]

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=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"""
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of TitleContentSearchRequest 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 document_type
        if self.document_type:
            _dict['document_type'] = self.document_type.to_dict()
        # set to None if document_type (nullable) is None
        # and model_fields_set contains the field
        if self.document_type is None and "document_type" in self.model_fields_set:
            _dict['document_type'] = None

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "query": obj.get("query"),
            "space_id": obj.get("space_id"),
            "collection_ids": obj.get("collection_ids"),
            "page": obj.get("page") if obj.get("page") is not None else 1,
            "page_size": obj.get("page_size") if obj.get("page_size") is not None else 5,
            "title_boost": obj.get("title_boost") if obj.get("title_boost") is not None else 4.0,
            "content_boost": obj.get("content_boost") if obj.get("content_boost") is not None else 1.0,
            "document_type": DocumentType.from_dict(obj["document_type"]) if obj.get("document_type") is not None else None,
            "document_id_list": obj.get("document_id_list"),
            "exclude_document_id_list": obj.get("exclude_document_id_list"),
            "exclude_paragraph_list": obj.get("exclude_paragraph_list"),
            "is_active": obj.get("is_active")
        })
        return _obj


