schemas.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. class GameConfig(CamelModel):
  16. timer: conint(gt=0)
  17. rounds: conint(gt=0)
  18. country_lock: Union[CountryCode, None] = None
  19. generation_method: GenMethodEnum = GenMethodEnum.rsv
  20. rule_set: RuleSetEnum = RuleSetEnum.normal
  21. class Config:
  22. orm_mode = True
  23. class Guess(CamelModel):
  24. lat: confloat(ge=-90.0, le=90.0)
  25. lng: confloat(ge=-180.0, le=180.0)
  26. time_remaining: int
  27. country: Union[CountryCode, None] = None
  28. class CacheInfo(CamelModel):
  29. cache_name: str
  30. size: int
  31. class GeneratorInfo(CamelModel):
  32. generation_method: GenMethodEnum
  33. country_locks: List[CountryCode]