chg: Support dict in tag/untag

pull/534/head
Raphaël Vinot 2020-01-30 11:07:49 +01:00
parent 2a2871eced
commit 864d294294
1 changed files with 12 additions and 8 deletions

View File

@ -2044,10 +2044,12 @@ class PyMISP:
raise PyMISPError('The misp_entity must be MISPEvent, MISPObject or MISPAttribute')
def tag(self, misp_entity: Union[AbstractMISP, str], tag: Union[MISPTag, str], local: bool=False) -> dict:
def tag(self, misp_entity: Union[AbstractMISP, str, dict], tag: Union[MISPTag, str], local: bool=False) -> dict:
"""Tag an event or an attribute. misp_entity can be a MISPEvent, a MISP Attribute, or a UUID"""
if isinstance(misp_entity, AbstractMISP) and 'uuid' in misp_entity:
uuid = misp_entity.uuid
elif isinstance(misp_entity, dict) and 'uuid' in misp_entity:
uuid = misp_entity['uuid']
elif isinstance(misp_entity, str):
uuid = misp_entity
if isinstance(tag, MISPTag):
@ -2056,10 +2058,12 @@ class PyMISP:
response = self._prepare_request('POST', 'tags/attachTagToObject', data=to_post)
return self._check_json_response(response)
def untag(self, misp_entity: Union[AbstractMISP, str], tag: Union[MISPTag, str]) -> dict:
def untag(self, misp_entity: Union[AbstractMISP, str, dict], tag: Union[MISPTag, str]) -> dict:
"""Untag an event or an attribute. misp_entity can be a UUID"""
if isinstance(misp_entity, AbstractMISP) and 'uuid' in misp_entity:
uuid = misp_entity.uuid
elif isinstance(misp_entity, dict) and 'uuid' in misp_entity:
uuid = misp_entity['uuid']
elif isinstance(misp_entity, str):
uuid = misp_entity
if isinstance(tag, MISPTag):