def delete(self, request, organization): """ Delete an organization Schedules an organization for deletion. {method} {path} **Note:** Deletion happens asynchronously and therefor is not immediate. However once deletion has begun the state of a project changes and will be hidden from most public views. """ if organization.is_default: return Response({'detail': ERR_DEFAULT_ORG}, status=400) updated = Organization.objects.filter( id=organization.id, status=OrganizationStatus.VISIBLE, ).update(status=OrganizationStatus.PENDING_DELETION) if updated: delete_organization.delay( object_id=organization.id, countdown=60 * 5, ) return Response(status=204)
def delete(self, request, organization): """ Delete an Organization `````````````````````` Schedules an organization for deletion. This API endpoint cannot be invoked without a user context for security reasons. This means that at present an organization can only be deleted from the Sentry UI. Deletion happens asynchronously and therefor is not immediate. However once deletion has begun the state of a project changes and will be hidden from most public views. :pparam string organization_slug: the slug of the organization the team should be created for. :auth: required, user-context-needed """ if not request.user.is_authenticated(): return Response({'detail': 'This request requires a user.'}, status=401) if organization.is_default: return Response({'detail': ERR_DEFAULT_ORG}, status=400) logging.getLogger('sentry.deletions').info( 'Organization %s (id=%s) removal requested by user (id=%s)', organization.slug, organization.id, request.user.id) updated = Organization.objects.filter( id=organization.id, status=OrganizationStatus.VISIBLE, ).update(status=OrganizationStatus.PENDING_DELETION) if updated: delete_organization.delay( object_id=organization.id, countdown=86400, ) self.create_audit_entry( request=request, organization=organization, target_object=organization.id, event=AuditLogEntryEvent.ORG_REMOVE, data=organization.get_audit_log_data(), ) return Response(status=204)
def delete(self, request, organization): """ Delete an Organization `````````````````````` Schedules an organization for deletion. This API endpoint cannot be invoked without a user context for security reasons. This means that at present an organization can only be deleted from the Sentry UI. Deletion happens asynchronously and therefor is not immediate. However once deletion has begun the state of a project changes and will be hidden from most public views. :pparam string organization_slug: the slug of the organization the team should be created for. :auth: required, user-context-needed """ if not request.user.is_authenticated(): return Response({'detail': 'This request requires a user.'}, status=401) if organization.is_default: return Response({'detail': ERR_DEFAULT_ORG}, status=400) logging.getLogger('sentry.deletions').info( 'Organization %s (id=%s) removal requested by user (id=%s)', organization.slug, organization.id, request.user.id) updated = Organization.objects.filter( id=organization.id, status=OrganizationStatus.VISIBLE, ).update(status=OrganizationStatus.PENDING_DELETION) if updated: delete_organization.delay( object_id=organization.id, countdown=3600, ) self.create_audit_entry( request=request, organization=organization, target_object=organization.id, event=AuditLogEntryEvent.ORG_REMOVE, data=organization.get_audit_log_data(), ) return Response(status=204)
def delete(self, request, organization): """ Delete an Organization `````````````````````` Schedules an organization for deletion. This API endpoint cannot be invoked without a user context for security reasons. This means that at present an organization can only be deleted from the Sentry UI. Deletion happens asynchronously and therefor is not immediate. However once deletion has begun the state of a project changes and will be hidden from most public views. :pparam string organization_slug: the slug of the organization the team should be created for. :auth: required, user-context-needed """ if not request.user.is_authenticated(): return Response({'detail': 'This request requires a user.'}, status=401) if organization.is_default: return Response({'detail': ERR_DEFAULT_ORG}, status=400) updated = Organization.objects.filter( id=organization.id, status=OrganizationStatus.VISIBLE, ).update(status=OrganizationStatus.PENDING_DELETION) if updated: delete_organization.delay( object_id=organization.id, countdown=60 * 5, ) return Response(status=204)