示例#1
0
    def delete(self, request, group):
        """
        Remove an Issue
        ```````````````

        Removes an individual issue.

        :pparam string issue_id: the ID of the issue to delete.
        :auth: required
        """
        from sentry.tasks.deletion import delete_group

        updated = Group.objects.filter(
            id=group.id,
        ).exclude(
            status__in=[
                GroupStatus.PENDING_DELETION,
                GroupStatus.DELETION_IN_PROGRESS,
            ]
        ).update(status=GroupStatus.PENDING_DELETION)
        if updated:
            GroupHash.objects.filter(group=group).delete()
            delete_group.apply_async(
                kwargs={'object_id': group.id},
                countdown=3600,
            )

        return Response(status=202)
示例#2
0
    def _delete_groups(self, request, project, group_list):
        group_ids = [g.id for g in group_list]

        Group.objects.filter(id__in=group_ids, ).exclude(status__in=[
            GroupStatus.PENDING_DELETION,
            GroupStatus.DELETION_IN_PROGRESS,
        ]).update(status=GroupStatus.PENDING_DELETION)
        GroupHash.objects.filter(group__id__in=group_ids).delete()

        transaction_id = uuid4().hex

        for group in group_list:
            delete_group.apply_async(
                kwargs={
                    'object_id': group.id,
                    'transaction_id': transaction_id,
                },
                countdown=3600,
            )

            self.create_audit_entry(
                request=request,
                organization_id=project.organization_id,
                target_object=group.id,
                transaction_id=transaction_id,
            )

            delete_logger.info('object.delete.queued',
                               extra={
                                   'object_id': group.id,
                                   'transaction_id': transaction_id,
                                   'model': type(group).__name__,
                               })
示例#3
0
    def delete(self, request, project):
        """
        Bulk Remove a List of Issues
        ````````````````````````````

        Permanently remove the given issues. The list of issues to
        modify is given through the `id` query parameter.  It is repeated
        for each issue that should be removed.

        Only queries by 'id' are accepted.

        If any ids are out of scope this operation will succeed without
        any data mutation.

        :qparam int id: a list of IDs of the issues to be removed.  This
                        parameter shall be repeated for each issue.
        :pparam string organization_slug: the slug of the organization the
                                          issues belong to.
        :pparam string project_slug: the slug of the project the issues
                                     belong to.
        :auth: required
        """
        group_ids = request.GET.getlist('id')
        if group_ids:
            group_list = list(Group.objects.filter(
                project=project,
                id__in=set(group_ids),
            ).exclude(
                status__in=[
                    GroupStatus.PENDING_DELETION,
                    GroupStatus.DELETION_IN_PROGRESS,
                ]
            ))
            # filter down group ids to only valid matches
            group_ids = [g.id for g in group_list]
        else:
            # missing any kind of filter
            return Response('{"detail": "You must specify a list of IDs for this operation"}', status=400)

        if not group_ids:
            return Response(status=204)

        Group.objects.filter(
            id__in=group_ids,
        ).exclude(
            status__in=[
                GroupStatus.PENDING_DELETION,
                GroupStatus.DELETION_IN_PROGRESS,
            ]
        ).update(status=GroupStatus.PENDING_DELETION)
        GroupHash.objects.filter(group__id__in=group_ids).delete()
        for group in group_list:
            delete_group.apply_async(
                kwargs={'object_id': group.id},
                countdown=3600,
            )

        return Response(status=204)
示例#4
0
    def delete(self, request, group):
        """
        Remove an Issue
        ```````````````

        Removes an individual issue.

        :pparam string issue_id: the ID of the issue to delete.
        :auth: required
        """
        from sentry.tasks.deletion import delete_group

        updated = Group.objects.filter(
            id=group.id,
        ).exclude(status__in=[
            GroupStatus.PENDING_DELETION,
            GroupStatus.DELETION_IN_PROGRESS,
        ]).update(status=GroupStatus.PENDING_DELETION)
        if updated:
            project = group.project
            GroupHashTombstone.tombstone_groups(
                project_id=project.id,
                group_ids=[group.id],
            )

            transaction_id = uuid4().hex

            delete_group.apply_async(
                kwargs={
                    'object_id': group.id,
                    'transaction_id': transaction_id,
                },
                countdown=3600,
            )

            self.create_audit_entry(
                request=request,
                organization_id=project.organization_id if project else None,
                target_object=group.id,
                transaction_id=transaction_id,
            )

            delete_logger.info(
                'object.delete.queued',
                extra={
                    'object_id': group.id,
                    'transaction_id': transaction_id,
                    'model': type(group).__name__,
                }
            )

            issue_deleted.send_robust(
                group=group,
                user=request.user,
                delete_type='delete',
                sender=self.__class__)

        return Response(status=202)
示例#5
0
    def delete(self, request, project):
        """
        Bulk Remove a List of Aggregates
        ````````````````````````````````

        Permanently remove the given aggregates. The list of groups to
        modify is given through the `id` query parameter.  It is repeated
        for each group that should be removed.

        Only queries by 'id' are accepted.

        If any ids are out of scope this operation will succeed without
        any data mutation.

        :qparam int id: a list of IDs of the groups to be removed.  This
                        parameter shall be repeated for each group.
        :pparam string organization_slug: the slug of the organization the
                                          groups belong to.
        :pparam string project_slug: the slug of the project the groups
                                     belong to.
        :auth: required
        """
        group_ids = request.GET.getlist('id')
        if group_ids:
            group_list = list(Group.objects.filter(
                project=project,
                id__in=set(group_ids),
            ).exclude(
                status__in=[
                    GroupStatus.PENDING_DELETION,
                    GroupStatus.DELETION_IN_PROGRESS,
                ]
            ))
            # filter down group ids to only valid matches
            group_ids = [g.id for g in group_list]
        else:
            # missing any kind of filter
            return Response('{"detail": "You must specify a list of IDs for this operation"}', status=400)

        if not group_ids:
            return Response(status=204)

        Group.objects.filter(
            id__in=group_ids,
        ).exclude(
            status__in=[
                GroupStatus.PENDING_DELETION,
                GroupStatus.DELETION_IN_PROGRESS,
            ]
        ).update(status=GroupStatus.PENDING_DELETION)
        for group in group_list:
            delete_group.apply_async(
                kwargs={'object_id': group.id},
                countdown=3600,
            )

        return Response(status=204)
示例#6
0
    def delete(self, request, group):
        """
        Remove an Issue
        ```````````````

        Removes an individual issue.

        :pparam string issue_id: the ID of the issue to delete.
        :auth: required
        """
        from sentry.tasks.deletion import delete_group

        updated = Group.objects.filter(id=group.id, ).exclude(status__in=[
            GroupStatus.PENDING_DELETION,
            GroupStatus.DELETION_IN_PROGRESS,
        ]).update(status=GroupStatus.PENDING_DELETION)
        if updated:
            project = group.project

            eventstream.delete_groups(group.project_id, [group.id])

            GroupHashTombstone.tombstone_groups(
                project_id=project.id,
                group_ids=[group.id],
            )

            transaction_id = uuid4().hex

            delete_group.apply_async(
                kwargs={
                    'object_id': group.id,
                    'transaction_id': transaction_id,
                },
                countdown=3600,
            )

            self.create_audit_entry(
                request=request,
                organization_id=project.organization_id if project else None,
                target_object=group.id,
                transaction_id=transaction_id,
            )

            delete_logger.info('object.delete.queued',
                               extra={
                                   'object_id': group.id,
                                   'transaction_id': transaction_id,
                                   'model': type(group).__name__,
                               })

            issue_deleted.send_robust(group=group,
                                      user=request.user,
                                      delete_type='delete',
                                      sender=self.__class__)

        return Response(status=202)
示例#7
0
    def _delete_groups(self, request, project, group_list, delete_type):
        group_ids = [g.id for g in group_list]

        Group.objects.filter(
            id__in=group_ids,
        ).exclude(status__in=[
            GroupStatus.PENDING_DELETION,
            GroupStatus.DELETION_IN_PROGRESS,
        ]).update(status=GroupStatus.PENDING_DELETION)

        eventstream.delete_groups(project.id, group_ids)

        GroupHashTombstone.tombstone_groups(
            project_id=project.id,
            group_ids=group_ids,
        )

        transaction_id = uuid4().hex

        for group in group_list:
            delete_group.apply_async(
                kwargs={
                    'object_id': group.id,
                    'transaction_id': transaction_id,
                },
                countdown=3600,
            )

            self.create_audit_entry(
                request=request,
                organization_id=project.organization_id,
                target_object=group.id,
                transaction_id=transaction_id,
            )

            delete_logger.info(
                'object.delete.queued',
                extra={
                    'object_id': group.id,
                    'transaction_id': transaction_id,
                    'model': type(group).__name__,
                }
            )

            issue_deleted.send_robust(
                group=group,
                user=request.user,
                delete_type=delete_type,
                sender=self.__class__)
    def _delete_groups(self, request, project, group_list, delete_type):
        group_ids = [g.id for g in group_list]

        Group.objects.filter(
            id__in=group_ids,
        ).exclude(status__in=[
            GroupStatus.PENDING_DELETION,
            GroupStatus.DELETION_IN_PROGRESS,
        ]).update(status=GroupStatus.PENDING_DELETION)

        GroupHashTombstone.tombstone_groups(
            project_id=project.id,
            group_ids=group_ids,
        )

        transaction_id = uuid4().hex

        for group in group_list:
            delete_group.apply_async(
                kwargs={
                    'object_id': group.id,
                    'transaction_id': transaction_id,
                },
                countdown=3600,
            )

            self.create_audit_entry(
                request=request,
                organization_id=project.organization_id,
                target_object=group.id,
                transaction_id=transaction_id,
            )

            delete_logger.info(
                'object.delete.queued',
                extra={
                    'object_id': group.id,
                    'transaction_id': transaction_id,
                    'model': type(group).__name__,
                }
            )

            issue_deleted.send_robust(
                group=group,
                user=request.user,
                delete_type=delete_type,
                sender=self.__class__)
示例#9
0
    def delete(self, request, project):
        """
        Bulk Remove a List of Issues
        ````````````````````````````

        Permanently remove the given issues. The list of issues to
        modify is given through the `id` query parameter.  It is repeated
        for each issue that should be removed.

        Only queries by 'id' are accepted.

        If any ids are out of scope this operation will succeed without
        any data mutation.

        :qparam int id: a list of IDs of the issues to be removed.  This
                        parameter shall be repeated for each issue.
        :pparam string organization_slug: the slug of the organization the
                                          issues belong to.
        :pparam string project_slug: the slug of the project the issues
                                     belong to.
        :auth: required
        """
        group_ids = request.GET.getlist('id')
        if group_ids:
            group_list = list(Group.objects.filter(
                project=project,
                id__in=set(group_ids),
            ).exclude(
                status__in=[
                    GroupStatus.PENDING_DELETION,
                    GroupStatus.DELETION_IN_PROGRESS,
                ]
            ))
            # filter down group ids to only valid matches
            group_ids = [g.id for g in group_list]
        else:
            # missing any kind of filter
            return Response('{"detail": "You must specify a list of IDs for this operation"}', status=400)

        if not group_ids:
            return Response(status=204)

        Group.objects.filter(
            id__in=group_ids,
        ).exclude(
            status__in=[
                GroupStatus.PENDING_DELETION,
                GroupStatus.DELETION_IN_PROGRESS,
            ]
        ).update(status=GroupStatus.PENDING_DELETION)
        GroupHash.objects.filter(group__id__in=group_ids).delete()

        transaction_id = uuid4().hex

        for group in group_list:
            delete_group.apply_async(
                kwargs={
                    'object_id': group.id,
                    'transaction_id': transaction_id,
                },
                countdown=3600,
            )

            self.create_audit_entry(
                request=request,
                organization_id=project.organization_id,
                target_object=group.id,
                transaction_id=transaction_id,
            )

            delete_logger.info('object.delete.queued', extra={
                'object_id': group.id,
                'transaction_id': transaction_id,
                'model': type(group).__name__,
            })

        return Response(status=204)