From 36e7e5aeddb5dee6fba763005de8ced2e66cebce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sat, 21 Apr 2018 16:29:38 +0200 Subject: [PATCH] new: Add update_attribute method --- pymisp/api.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pymisp/api.py b/pymisp/api.py index 0adda79..f3278a2 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -330,6 +330,20 @@ class PyMISP(object): response = self.__prepare_request('POST', url, event) return self._check_response(response) + def update_attribute(self, attribute_id, attribute): + """Update an attribute + + :param attribute_id: Attribute id/uuid to update + :param attribute: Attribute as JSON object / string to add + """ + url = urljoin(self.root_url, 'attributes/{}'.format(attribute_id)) + if isinstance(attribute, MISPAttribute): + attribute = attribute.to_json() + elif not isinstance(attribute, basestring): + attribute = json.dumps(attribute) + response = self.__prepare_request('POST', url, attribute) + return self._check_response(response) + def update_event(self, event_id, event): """Update an event