# 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 datetime import date, datetime
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from dupr_backend.models.league_content_request import LeagueContentRequest
from typing import Optional, Set
from typing_extensions import Self

class DraftBracketRequest(BaseModel):
    """
    DraftBracketRequest
    """ # noqa: E501
    custom_code: Optional[StrictStr] = Field(default=None, alias="customCode")
    duration: Optional[List[date]] = None
    format: Optional[StrictStr] = None
    elimination: Optional[StrictStr] = None
    player_group: Optional[StrictStr] = Field(default=None, alias="playerGroup")
    rating_bracket: Optional[List[Union[StrictFloat, StrictInt]]] = Field(default=None, alias="ratingBracket")
    age_bracket: Optional[List[StrictInt]] = Field(default=None, alias="ageBracket")
    description: Optional[LeagueContentRequest] = None
    match_bonus_points: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="matchBonusPoints")
    registration_date: Optional[List[date]] = Field(default=None, alias="registrationDate")
    score_format: Optional[StrictInt] = Field(default=None, alias="scoreFormat")
    member_fee: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="memberFee")
    non_member_fee: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="nonMemberFee")
    max_team: Optional[StrictInt] = Field(default=None, alias="maxTeam")
    wait_list: Optional[StrictInt] = Field(default=None, alias="waitList")
    league_id: Optional[StrictInt] = Field(default=None, alias="leagueId")
    name: Optional[StrictStr] = None
    courts: Optional[StrictInt] = None
    bracket_id: StrictInt = Field(alias="bracketId")
    registration_date_time: Optional[List[datetime]] = Field(default=None, alias="registrationDateTime")
    duration_date_time: Optional[List[datetime]] = Field(default=None, alias="durationDateTime")
    time_zone: Optional[StrictStr] = Field(default=None, alias="timeZone")
    zone_name: Optional[StrictStr] = Field(default=None, alias="zoneName")
    __properties: ClassVar[List[str]] = ["customCode", "duration", "format", "elimination", "playerGroup", "ratingBracket", "ageBracket", "description", "matchBonusPoints", "registrationDate", "scoreFormat", "memberFee", "nonMemberFee", "maxTeam", "waitList", "leagueId", "name", "courts", "bracketId", "registrationDateTime", "durationDateTime", "timeZone", "zoneName"]

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

        if value not in set(['SINGLES', 'DOUBLES']):
            raise ValueError("must be one of enum values ('SINGLES', 'DOUBLES')")
        return value

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

        if value not in set(['SINGLE', 'DOUBLE', 'DOUBLE_PREVENTED', 'ROUND_ROBIN', 'COMPASS', 'FLEX']):
            raise ValueError("must be one of enum values ('SINGLE', 'DOUBLE', 'DOUBLE_PREVENTED', 'ROUND_ROBIN', 'COMPASS', 'FLEX')")
        return value

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

        if value not in set(['MEN', 'WOMEN', 'MIXED', 'COED', 'OPEN']):
            raise ValueError("must be one of enum values ('MEN', 'WOMEN', 'MIXED', 'COED', 'OPEN')")
        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 DraftBracketRequest 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 description
        if self.description:
            _dict['description'] = self.description.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "customCode": obj.get("customCode"),
            "duration": obj.get("duration"),
            "format": obj.get("format"),
            "elimination": obj.get("elimination"),
            "playerGroup": obj.get("playerGroup"),
            "ratingBracket": obj.get("ratingBracket"),
            "ageBracket": obj.get("ageBracket"),
            "description": LeagueContentRequest.from_dict(obj["description"]) if obj.get("description") is not None else None,
            "matchBonusPoints": obj.get("matchBonusPoints"),
            "registrationDate": obj.get("registrationDate"),
            "scoreFormat": obj.get("scoreFormat"),
            "memberFee": obj.get("memberFee"),
            "nonMemberFee": obj.get("nonMemberFee"),
            "maxTeam": obj.get("maxTeam"),
            "waitList": obj.get("waitList"),
            "leagueId": obj.get("leagueId"),
            "name": obj.get("name"),
            "courts": obj.get("courts"),
            "bracketId": obj.get("bracketId"),
            "registrationDateTime": obj.get("registrationDateTime"),
            "durationDateTime": obj.get("durationDateTime"),
            "timeZone": obj.get("timeZone"),
            "zoneName": obj.get("zoneName")
        })
        return _obj


