Skip to content

Commit

Permalink
Merge branch 'hotfix/1.4.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jul 2, 2018
2 parents d19f419 + ae57870 commit be80a7d
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,6 +1,8 @@
# Created by .ignore support plugin (hsz.mobi)
.gitignore
.idea/
.vscode/
venv/
tmp/
*.pyc
thehive4py/*.pyc
Expand Down
19 changes: 17 additions & 2 deletions CHANGELOG.md
@@ -1,7 +1,22 @@
# Change Log

## [1.4.3](https://github.com/TheHive-Project/TheHive4py/tree/1.4.3)
## [Unreleased](https://github.com/TheHive-Project/TheHive4py/tree/1.4.4) (2018-07-02)

[Full Changelog](https://github.com/TheHive-Project/TheHive4py/compare/1.4.3...1.4.4)

**Closed issues:**

- Retrieve analyzer report after analysis \[question\] [\#75](https://github.com/TheHive-Project/TheHive4py/issues/75)
- Keep analyzer reports when merging a case [\#73](https://github.com/TheHive-Project/TheHive4py/issues/73)
- Unify the naming of statuses and filters [\#70](https://github.com/TheHive-Project/TheHive4py/issues/70)

**Merged pull requests:**

- Add support for alert markAsRead/Unread [\#74](https://github.com/TheHive-Project/TheHive4py/pull/74) ([itsnotapt](https://github.com/itsnotapt))
- Missing parameter \_field in Between function [\#71](https://github.com/TheHive-Project/TheHive4py/pull/71) ([tagashy](https://github.com/tagashy))
- Add Support for update\_case\_tasks method [\#63](https://github.com/TheHive-Project/TheHive4py/pull/63) ([billmurrin](https://github.com/billmurrin))

## [1.4.3](https://github.com/TheHive-Project/TheHive4py/tree/1.4.3) (2018-02-07)
[Full Changelog](https://github.com/TheHive-Project/TheHive4py/compare/1.4.2...1.4.3)

**Implemented enhancements:**
Expand All @@ -16,8 +31,8 @@

**Merged pull requests:**

- created get\_linked\_cases method in api [\#60](https://github.com/TheHive-Project/TheHive4py/pull/60) ([billmurrin](https://github.com/billmurrin))
- fix spelling of exception [\#58](https://github.com/TheHive-Project/TheHive4py/pull/58) ([billmurrin](https://github.com/billmurrin))
- created get\_linked\_cases method in api [\#60](https://github.com/TheHive-Project/TheHive4py/pull/60) ([billmurrin](https://github.com/billmurrin))

## [1.4.2](https://github.com/TheHive-Project/TheHive4py/tree/1.4.2) (2017-12-27)
[Full Changelog](https://github.com/TheHive-Project/TheHive4py/compare/1.4.1...1.4.2)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -11,7 +11,7 @@

setup(
name='thehive4py',
version='1.4.3',
version='1.4.4',
description='Python API client for TheHive.',
long_description=read_md('README.md'),
author='TheHive-Project',
Expand Down
47 changes: 47 additions & 0 deletions thehive4py/api.py
Expand Up @@ -142,6 +142,27 @@ def create_case_task(self, case_id, case_task):
except requests.exceptions.RequestException as e:
raise CaseTaskException("Case task create error: {}".format(e))

def update_case_task(self, task):
"""
:Updates TheHive Task
:param case: The task to update. The task's `id` determines which Task to update.
:return:
"""
req = self.url + "/api/case/task/{}".format(task.id)

# Choose which attributes to send
update_keys = [
'title', 'description', 'status', 'order', 'user', 'owner', 'flag', 'endDate'
]

data = {k: v for k, v in task.__dict__.items() if k in update_keys}

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 CaseTaskException("Case task update error: {}".format(e))

def create_task_log(self, task_id, case_task_log):

"""
Expand Down Expand Up @@ -350,6 +371,32 @@ def create_alert(self, alert):
except requests.exceptions.RequestException as e:
raise AlertException("Alert create error: {}".format(e))

def mark_alert_as_read(self, alert_id):
"""
Mark an alert as read.
:param alert_id: The ID of the alert to mark as read.
:return:
"""
req = self.url + "/api/alert/{}/markAsRead".format(alert_id)

try:
return requests.post(req, headers={'Content-Type': 'application/json'}, proxies=self.proxies, auth=self.auth, verify=self.cert)
except requests.exceptions.RequestException:
raise AlertException("Mark alert as read error: {}".format(e))

def mark_alert_as_unread(self, alert_id):
"""
Mark an alert as unread.
:param alert_id: The ID of the alert to mark as unread.
:return:
"""
req = self.url + "/api/alert/{}/markAsUnread".format(alert_id)

try:
return requests.post(req, headers={'Content-Type': 'application/json'}, proxies=self.proxies, auth=self.auth, verify=self.cert)
except requests.exceptions.RequestException:
raise AlertException("Mark alert as unread error: {}".format(e))

def update_alert(self, alert_id, alert, fields=[]):
"""
Update an alert.
Expand Down
2 changes: 1 addition & 1 deletion thehive4py/query.py
Expand Up @@ -47,7 +47,7 @@ def Id(id):


def Between(field, from_value, to_value):
return {'_between': {'_from': from_value, '_to': to_value}}
return {'_between': {'_field': field, '_from': from_value, '_to': to_value}}


def ParentId(tpe, id):
Expand Down

0 comments on commit be80a7d

Please sign in to comment.