schemas.py 1023 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. rsv = "RANDOMSTREETVIEW"
  8. urban = "URBAN"
  9. class RuleSetEnum(str, Enum):
  10. normal = "NORMAL"
  11. time_bank = "TIMEBANK"
  12. frozen = "FROZEN"
  13. race = "RACE"
  14. country_race = "COUNTRYRACE"
  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. class CacheInfo(CamelModel):
  28. cache_name: str
  29. size: int
  30. class GeneratorInfo(CamelModel):
  31. generation_method: GenMethodEnum
  32. country_locks: List[CountryCode]