def bulk_delete(self, query, **kwargs):
response = self._new_response()<EOL>if self._check_supported_op('<STR_LIT>', response):<EOL><INDENT>n = <NUM_LIT:0><EOL>pe = '<STR_LIT:id>'<EOL>response = self.search(query, projection_expression=pe, **kwargs)<EOL>while response.status == '<STR_LIT:success>' and response.data:<EOL><INDENT>for item in response.data:<EOL><INDENT>delete_response = self.delete(item['<STR_LIT:id>'])<EOL>if response.status != '<STR_LIT:success>':<EOL><INDENT>response = delete_response<EOL>break<EOL><DEDENT>n += <NUM_LIT:1><EOL><DEDENT>response = self.search(<EOL>query, projection_expression=pe, **kwargs)<EOL><DEDENT>if response.status == '<STR_LIT:success>':<EOL><INDENT>response.data = {'<STR_LIT>': n}<EOL><DEDENT><DEDENT>return response<EOL>
Perform a search and delete all items that match.