schema.py 944 B

123456789101112131415161718192021222324252627282930313233343536
  1. from datetime import datetime
  2. from typing import Annotated, Literal
  3. from ninja import Schema
  4. from pydantic import Field
  5. from glitchtip.schema import CamelSchema
  6. HexField = Annotated[str, Field(pattern=r"^[0-9a-fA-F]{40}$")]
  7. class ArtifactBundleAssembleIn(Schema):
  8. checksum: HexField
  9. chunks: list[HexField]
  10. projects: list[str]
  11. version: str | None = None
  12. AssembleState = Literal["created", "error", "not_found", "assembling", "ok"]
  13. class AssembleResponse(Schema):
  14. state: AssembleState
  15. class DebugSymbolBundleSchema(CamelSchema):
  16. id: str
  17. created: datetime = Field(serialization_alias="dateCreated")
  18. sha1: str | None = Field(validation_alias="file.checksum", default=None)
  19. headers: dict[str, str] | None = Field(
  20. validation_alias="file.headers", default=None
  21. )
  22. name: str = Field(validation_alias="file.name")
  23. class Config(CamelSchema.Config):
  24. coerce_numbers_to_str = True