From 37c12b1f44f74f84bd852d5a4fc48949ef1babe8 Mon Sep 17 00:00:00 2001 From: Johannes Burk Date: Fri, 14 Sep 2018 14:57:43 +0200 Subject: [PATCH] Add delete_case function --- thehive4py/api.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/thehive4py/api.py b/thehive4py/api.py index a67e3aa6..f04dc299 100644 --- a/thehive4py/api.py +++ b/thehive4py/api.py @@ -234,6 +234,20 @@ def get_case(self, case_id): def find_cases(self, **attributes): return self.__find_rows("/api/case/_search", **attributes) + def delete_case(self, case_id, force=False): + """ + Deletes a TheHive case. Unless force is set to True the case is 'soft deleted' (status set to deleted). + :param case_id: Case identifier + :return: A requests response object. + """ + req = self.url + "/api/case/{}".format(case_id) + if force: + req += '/force' + try: + return requests.delete(req, proxies=self.proxies, auth=self.auth, verify=self.cert) + except requests.exceptions.RequestException as e: + raise CaseException("Case deletion error: {}".format(e)) + def find_first(self, **attributes): """ :return: first case of result set given by query