# 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, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from dupr_backend.models.skill_level_filter import SkillLevelFilter
from typing import Optional, Set
from typing_extensions import Self

class LeagueFilter(BaseModel):
    """
    LeagueFilter
    """ # noqa: E501
    skill_level: Optional[SkillLevelFilter] = Field(default=None, alias="skillLevel")
    elimination: Optional[List[StrictStr]] = None
    event_format: Optional[List[StrictStr]] = Field(default=None, alias="eventFormat")
    player_group: Optional[List[StrictStr]] = Field(default=None, alias="playerGroup")
    city: Optional[List[StrictStr]] = None
    status: Optional[List[StrictStr]] = None
    duration_status: Optional[List[StrictStr]] = Field(default=None, alias="durationStatus")
    registration_status: Optional[List[StrictStr]] = Field(default=None, alias="registrationStatus")
    __properties: ClassVar[List[str]] = ["skillLevel", "elimination", "eventFormat", "playerGroup", "city", "status", "durationStatus", "registrationStatus"]

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

        for i in value:
            if i not in set(['SINGLE', 'DOUBLE', 'DOUBLE_PREVENTED', 'ROUND_ROBIN', 'COMPASS', 'FLEX']):
                raise ValueError("each list item must be one of ('SINGLE', 'DOUBLE', 'DOUBLE_PREVENTED', 'ROUND_ROBIN', 'COMPASS', 'FLEX')")
        return value

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

        for i in value:
            if i not in set(['SINGLES', 'DOUBLES']):
                raise ValueError("each list item must be one of ('SINGLES', 'DOUBLES')")
        return value

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

        for i in value:
            if i not in set(['MEN', 'WOMEN', 'MIXED', 'COED', 'OPEN']):
                raise ValueError("each list item must be one of ('MEN', 'WOMEN', 'MIXED', 'COED', 'OPEN')")
        return value

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

        for i in value:
            if i not in set(['ACTIVE', 'INACTIVE', 'UPCOMING', 'IN_PROGRESS', 'COMPLETE', 'CANCELLED', 'NOT_CONFIRMED', 'INVITED', 'CONFIRMED', 'MATCH_BYE', 'PENDING', 'FORFEITED', 'DELETED', 'ONGOING', 'SUSPENDED_TOS_13']):
                raise ValueError("each list item must be one of ('ACTIVE', 'INACTIVE', 'UPCOMING', 'IN_PROGRESS', 'COMPLETE', 'CANCELLED', 'NOT_CONFIRMED', 'INVITED', 'CONFIRMED', 'MATCH_BYE', 'PENDING', 'FORFEITED', 'DELETED', 'ONGOING', 'SUSPENDED_TOS_13')")
        return value

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

        for i in value:
            if i not in set(['ACTIVE', 'INACTIVE', 'UPCOMING', 'IN_PROGRESS', 'COMPLETE', 'CANCELLED', 'NOT_CONFIRMED', 'INVITED', 'CONFIRMED', 'MATCH_BYE', 'PENDING', 'FORFEITED', 'DELETED', 'ONGOING', 'SUSPENDED_TOS_13']):
                raise ValueError("each list item must be one of ('ACTIVE', 'INACTIVE', 'UPCOMING', 'IN_PROGRESS', 'COMPLETE', 'CANCELLED', 'NOT_CONFIRMED', 'INVITED', 'CONFIRMED', 'MATCH_BYE', 'PENDING', 'FORFEITED', 'DELETED', 'ONGOING', 'SUSPENDED_TOS_13')")
        return value

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

        for i in value:
            if i not in set(['OPEN', 'NOT_STARTED', 'CLOSED']):
                raise ValueError("each list item must be one of ('OPEN', 'NOT_STARTED', 'CLOSED')")
        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 LeagueFilter 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 skill_level
        if self.skill_level:
            _dict['skillLevel'] = self.skill_level.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "skillLevel": SkillLevelFilter.from_dict(obj["skillLevel"]) if obj.get("skillLevel") is not None else None,
            "elimination": obj.get("elimination"),
            "eventFormat": obj.get("eventFormat"),
            "playerGroup": obj.get("playerGroup"),
            "city": obj.get("city"),
            "status": obj.get("status"),
            "durationStatus": obj.get("durationStatus"),
            "registrationStatus": obj.get("registrationStatus")
        })
        return _obj


