schema.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from datetime import datetime
  2. from typing import Optional
  3. from ninja import Field, ModelSchema
  4. from glitchtip.schema import CamelSchema
  5. from .models import Project
  6. class NameSlugProjectSchema(CamelSchema, ModelSchema):
  7. class Meta:
  8. model = Project
  9. fields = [
  10. "name",
  11. "slug",
  12. ]
  13. class ProjectSchema(NameSlugProjectSchema):
  14. avatar: dict[str, Optional[str]] = {"avatarType": "", "avatarUuid": None}
  15. color: str = ""
  16. features: list = []
  17. has_access: bool = True
  18. is_bookmarked: bool = False
  19. is_internal: bool = False
  20. is_member: bool
  21. is_public: bool = False
  22. scrub_ip_addresses: bool = Field(serialization_alias="scrubIPAddresses")
  23. created: datetime = Field(serialization_alias="dateCreated")
  24. class Meta:
  25. model = Project
  26. fields = [
  27. "first_event",
  28. "id",
  29. "name",
  30. "scrub_ip_addresses",
  31. "slug",
  32. "created",
  33. "platform",
  34. "event_throttle_rate", # Not in Sentry OSS
  35. ]
  36. class Config(CamelSchema.Config):
  37. pass