def delete(self, request, organization, integration_id):
        # Removing the integration removes the organization
        # integrations and all linked issues.
        org_integration = self.get_organization_integration(
            organization, integration_id)

        updated = OrganizationIntegration.objects.filter(
            id=org_integration.id, status=ObjectStatus.VISIBLE).update(
                status=ObjectStatus.PENDING_DELETION)

        if updated:
            delete_organization_integration.apply_async(
                kwargs={
                    "object_id": org_integration.id,
                    "transaction_id": uuid4().hex,
                    "actor_id": request.user.id,
                },
                countdown=0,
            )
            integration = org_integration.integration
            create_audit_entry(
                request=request,
                organization=organization,
                target_object=integration.id,
                event=AuditLogEntryEvent.INTEGRATION_REMOVE,
                data={
                    "provider": integration.provider,
                    "name": integration.name
                },
            )

        return self.respond(status=204)
    def delete(self, request, organization, integration_id):
        # Removing the integration removes the organization and project
        # integrations and all linked issues.
        try:
            org_integration = OrganizationIntegration.objects.get(
                integration_id=integration_id,
                organization=organization,
            )
        except OrganizationIntegration.DoesNotExist:
            raise Http404

        updated = OrganizationIntegration.objects.filter(
            id=org_integration.id,
            status=ObjectStatus.VISIBLE,
        ).update(status=ObjectStatus.PENDING_DELETION)

        if updated:
            delete_organization_integration.apply_async(
                kwargs={
                    'object_id': org_integration.id,
                    'transaction_id': uuid4().hex,
                    'actor_id': request.user.id,
                },
                countdown=0,
            )

        return self.respond(status=204)