schemas.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from enum import Enum
  2. from typing import Union, List
  3. from fastapi_camelcase import CamelModel
  4. from pydantic import conint, confloat, constr
  5. CountryCode = constr(to_lower=True, min_length=2, max_length=2)
  6. class GenMethodEnum(str, Enum):
  7. # map_crunch = "MAPCRUNCH"
  8. rsv = "RANDOMSTREETVIEW"
  9. urban = "URBAN"
  10. class RuleSetEnum(str, Enum):
  11. normal = "NORMAL"
  12. time_bank = "TIMEBANK"
  13. frozen = "FROZEN"
  14. race = "RACE"
  15. country_race = "COUNTRYRACE"
  16. class GameConfig(CamelModel):
  17. timer: conint(gt=0)
  18. rounds: conint(gt=0)
  19. country_lock: Union[CountryCode, None] = None
  20. generation_method: GenMethodEnum = GenMethodEnum.rsv
  21. rule_set: RuleSetEnum = RuleSetEnum.normal
  22. class Config:
  23. orm_mode = True
  24. class Guess(CamelModel):
  25. lat: confloat(ge=-90.0, le=90.0)
  26. lng: confloat(ge=-180.0, le=180.0)
  27. time_remaining: int
  28. country: Union[CountryCode, None] = None
  29. class CacheInfo(CamelModel):
  30. cache_name: str
  31. size: int
  32. class GeneratorInfo(CamelModel):
  33. generation_method: GenMethodEnum
  34. country_locks: List[CountryCode]