# coding: utf-8

"""
    DUPR Backend APIs

    Internal RESTful APIs to access DUPR ratings, users and provide matches.

    The version of the OpenAPI document: v1.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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from dupr_backend.models.exclude_club_members import ExcludeClubMembers
from dupr_backend.models.search_filter import SearchFilter
from typing import Optional, Set
from typing_extensions import Self

class SearchRequest(BaseModel):
    """
    SearchRequest
    """ # noqa: E501
    offset: StrictInt
    limit: Annotated[int, Field(le=25, strict=True)]
    query: Optional[Annotated[str, Field(min_length=1, strict=True)]] = None
    exclude: Optional[List[StrictInt]] = None
    filter: SearchFilter
    exclude_club_members: Optional[ExcludeClubMembers] = Field(default=None, alias="excludeClubMembers")
    include_unclaimed_players: StrictBool = Field(alias="includeUnclaimedPlayers")
    bracket_id: Optional[StrictInt] = Field(default=None, alias="bracketId")
    page_source: Optional[StrictStr] = Field(default=None, alias="pageSource")
    verified_email: Optional[StrictBool] = Field(default=None, alias="verifiedEmail")
    __properties: ClassVar[List[str]] = ["offset", "limit", "query", "exclude", "filter", "excludeClubMembers", "includeUnclaimedPlayers", "bracketId", "pageSource", "verifiedEmail"]

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

        if value not in set(['LD_ADD_PARTICIPANT']):
            raise ValueError("must be one of enum values ('LD_ADD_PARTICIPANT')")
        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 SearchRequest 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 filter
        if self.filter:
            _dict['filter'] = self.filter.to_dict()
        # override the default output from pydantic by calling `to_dict()` of exclude_club_members
        if self.exclude_club_members:
            _dict['excludeClubMembers'] = self.exclude_club_members.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "offset": obj.get("offset"),
            "limit": obj.get("limit"),
            "query": obj.get("query"),
            "exclude": obj.get("exclude"),
            "filter": SearchFilter.from_dict(obj["filter"]) if obj.get("filter") is not None else None,
            "excludeClubMembers": ExcludeClubMembers.from_dict(obj["excludeClubMembers"]) if obj.get("excludeClubMembers") is not None else None,
            "includeUnclaimedPlayers": obj.get("includeUnclaimedPlayers"),
            "bracketId": obj.get("bracketId"),
            "pageSource": obj.get("pageSource"),
            "verifiedEmail": obj.get("verifiedEmail")
        })
        return _obj


