From 065c1889c894245223e3e63b8164f7e57903619f Mon Sep 17 00:00:00 2001 From: 3c7 <3c7@posteo.de> Date: Sun, 9 Jul 2017 11:44:00 +0200 Subject: [PATCH] Added wrapper for find_cases that returns first case of result set based on query. --- thehive4py/api.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/thehive4py/api.py b/thehive4py/api.py index 8b6a2d7f..08b13ae4 100644 --- a/thehive4py/api.py +++ b/thehive4py/api.py @@ -140,7 +140,7 @@ def find_cases(self, **attributes): """ :return: list of observables - ;rtype: json + :rtype: json """ req = self.url + "/api/case/_search" @@ -155,13 +155,18 @@ def find_cases(self, **attributes): "query": attributes.get("query", "any") } - print(data) - try: return requests.post(req, json=data, proxies=self.proxies, auth=self.auth, params=params) except requests.exceptions.RequestException as e: sys.exit("Error: {}".format(e)) + def find_first(self, **attributes): + """ + :return: first case of result set given by query + :rtype: dict + """ + return self.find_cases(**attributes).json()[0] + def get_case_observables(self, caseId): """