Skip to content

Commit

Permalink
add get_job_status method (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfernandezvalero authored Mar 27, 2022
1 parent 02417d3 commit 9cd129f
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions thehive4py/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import json
import sys

import magic
import os
import warnings
import json
Expand Down Expand Up @@ -1152,6 +1151,28 @@ def run_analyzer(self, cortex_id, artifact_id, analyzer_id):
except requests.exceptions.RequestException as e:
raise TheHiveException("Analyzer run error: {}".format(e))

def get_job_status(self, job_id):
"""
Get the job status previously launched
Arguments:
job_id: Analysis job ID
Returns:
response (requests.Response): Response object including a JSON representation of the analysis job
Raises:
TheHiveException: An error occured during job fetch
"""

req = self.url + "/api/connector/cortex/job/{job_id}?nstats=true".format(job_id = job_id)

try:
return requests.get(req, headers={'Content-Type': 'application/json'}, proxies=self.proxies, auth=self.auth, verify=self.cert)
except requests.exceptions.RequestException as e:
raise TheHiveException("Analyzer run error: {}".format(e))

def find_tasks(self, **attributes):
"""
Find case tasks using sort, pagination and a query
Expand Down Expand Up @@ -1406,4 +1427,4 @@ def update_alert_artifact(self, artifact_id, alert_artifact, fields=[]):
try:
return requests.patch(req, headers={'Content-Type': 'application/json'}, json=data, proxies=self.proxies, auth=self.auth, verify=self.cert)
except requests.exceptions.RequestException as e:
raise CaseObservableException("Case observable update error: {}".format(e))
raise CaseObservableException("Case observable update error: {}".format(e))

0 comments on commit 9cd129f

Please sign in to comment.