api.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. from django.shortcuts import aget_object_or_404
  2. from ninja import Router
  3. from apps.files.tasks import assemble_artifacts_task
  4. from apps.organizations_ext.models import Organization
  5. from glitchtip.api.authentication import AuthHttpRequest
  6. from glitchtip.api.permissions import has_permission
  7. from glitchtip.utils import async_call_celery_task
  8. from .schema import ArtifactBundleAssembleIn
  9. router = Router()
  10. @router.post("organizations/{slug:organization_slug}/artifactbundle/assemble/")
  11. @has_permission(["project:write", "project:admin", "project:releases"])
  12. async def artifact_bundle_assemble(
  13. request: AuthHttpRequest, organization_slug: str, payload: ArtifactBundleAssembleIn
  14. ):
  15. """Associate files with assembly bundle and optionally release"""
  16. user_id = request.auth.user_id
  17. organization = await aget_object_or_404(
  18. Organization, slug=organization_slug, users=user_id
  19. )
  20. await async_call_celery_task(
  21. assemble_artifacts_task,
  22. organization.id,
  23. payload.version,
  24. payload.checksum,
  25. payload.chunks,
  26. )
  27. return {"state": "created", "missingChunks": []}