<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def bulk_delete(self, query, **kwargs):
 """ Perform a search and delete all items that match. """

        response = self._new_response()
        if self._check_supported_op('search', response):
            n = 0
            pe = 'id'
            response = self.search(query, projection_expression=pe, **kwargs)
            while response.status == 'success' and response.data:
                for item in response.data:
                    delete_response = self.delete(item['id'])
                    if response.status != 'success':
                        response = delete_response
                        break
                    n += 1
                response = self.search(
                    query, projection_expression=pe, **kwargs)
            if response.status == 'success':
                response.data = {'deleted': n}
        return response