Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add get_job_status method #223

Merged
merged 1 commit into from
Mar 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))