def delete(self, request, project, key): """ Remove all occurrences of the given tag key. {method} {path} """ if key in PROTECTED_TAG_KEYS: return Response(status=403) lookup_key = tagstore.prefix_reserved_key(key) try: deleted = tagstore.delete_tag_key(project.id, lookup_key) except tagstore.TagKeyNotFound: raise ResourceDoesNotExist for tagkey in deleted: self.create_audit_entry( request=request, organization=project.organization, target_object=tagkey.id, event=AuditLogEntryEvent.TAGKEY_REMOVE, data=tagkey.get_audit_log_data(), ) return Response(status=204)
def delete(self, request, project, key): """ Remove all occurrences of the given tag key. {method} {path} """ if key in PROTECTED_TAG_KEYS: return Response(status=403) lookup_key = tagstore.prefix_reserved_key(key) try: from sentry import eventstream eventstream_state = eventstream.start_delete_tag(project.id, key) deleted = tagstore.delete_tag_key(project.id, lookup_key) # NOTE: By sending the `end_delete_tag` message here we are making # the assumption that the `tagstore.delete_tag_key` does its work # synchronously. As of this writing the Snuba `delete_tag_key` method # is a no-op and this message itself is what causes the deletion to # be done downstream. eventstream.end_delete_tag(eventstream_state) except tagstore.TagKeyNotFound: raise ResourceDoesNotExist for tagkey in deleted: self.create_audit_entry( request=request, organization=project.organization, target_object=getattr(tagkey, "id", None), event=AuditLogEntryEvent.TAGKEY_REMOVE, data=tagkey.get_audit_log_data(), ) return Response(status=204)