def post(self, request, path): """ Queues a task that creates a new Collection from an uploaded artifact. """ distro = get_object_or_404(AnsibleDistribution, base_path=path) serializer = GalaxyCollectionUploadSerializer( data=request.data, context={"request": request}) serializer.is_valid(raise_exception=True) expected_digests = {"sha256": serializer.validated_data["sha256"]} artifact = Artifact.init_and_validate( serializer.validated_data["file"], expected_digests=expected_digests) artifact.save() locks = [str(artifact.pk)] kwargs = {"artifact_pk": artifact.pk} if distro.repository: locks.append(distro.repository) kwargs["repository_pk"] = distro.repository.pk async_result = enqueue_with_reservation(import_collection, locks, kwargs=kwargs) return OperationPostponedResponse(async_result, request)
def post(self, request, *args, **kwargs): """ Queues a task that creates a new Collection from an uploaded artifact. """ serializer = GalaxyCollectionUploadSerializer( data=request.data, context={'request': request}) serializer.is_valid(raise_exception=True) expected_digests = {'sha256': serializer.validated_data['sha256']} artifact = Artifact.init_and_validate( serializer.validated_data['file'], expected_digests=expected_digests) artifact.save() async_result = enqueue_with_reservation(import_collection, [str(artifact.pk)], kwargs={ 'artifact_pk': artifact.pk, }) return OperationPostponedResponse(async_result, request)