schemas.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. class GenMethodEnum(str, Enum):
  6. # map_crunch = "MAPCRUNCH"
  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. class GameConfig(CamelModel):
  15. timer: conint(gt=0)
  16. rounds: conint(gt=0)
  17. country_lock: Union[constr(to_lower=True, min_length=2, max_length=2), None] = None
  18. generation_method: GenMethodEnum = GenMethodEnum.rsv
  19. rule_set: RuleSetEnum = RuleSetEnum.normal
  20. class Config:
  21. orm_mode = True
  22. class Guess(CamelModel):
  23. lat: confloat(ge=-90.0, le=90.0)
  24. lng: confloat(ge=-180.0, le=180.0)
  25. time_remaining: int
  26. class CacheInfo(CamelModel):
  27. cache_name: str
  28. size: int
  29. class GeneratorInfo(CamelModel):
  30. generation_method: GenMethodEnum
  31. country_locks: List[constr(to_lower=True, min_length=2, max_length=2)]