mirror of https://github.com/MISP/PyMISP
chg: Support dict in tag/untag
parent
2a2871eced
commit
864d294294
|
@ -2044,10 +2044,12 @@ class PyMISP:
|
||||||
|
|
||||||
raise PyMISPError('The misp_entity must be MISPEvent, MISPObject or MISPAttribute')
|
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"""
|
"""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:
|
if isinstance(misp_entity, AbstractMISP) and 'uuid' in misp_entity:
|
||||||
uuid = misp_entity.uuid
|
uuid = misp_entity.uuid
|
||||||
|
elif isinstance(misp_entity, dict) and 'uuid' in misp_entity:
|
||||||
|
uuid = misp_entity['uuid']
|
||||||
elif isinstance(misp_entity, str):
|
elif isinstance(misp_entity, str):
|
||||||
uuid = misp_entity
|
uuid = misp_entity
|
||||||
if isinstance(tag, MISPTag):
|
if isinstance(tag, MISPTag):
|
||||||
|
@ -2056,10 +2058,12 @@ class PyMISP:
|
||||||
response = self._prepare_request('POST', 'tags/attachTagToObject', data=to_post)
|
response = self._prepare_request('POST', 'tags/attachTagToObject', data=to_post)
|
||||||
return self._check_json_response(response)
|
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"""
|
"""Untag an event or an attribute. misp_entity can be a UUID"""
|
||||||
if isinstance(misp_entity, AbstractMISP) and 'uuid' in misp_entity:
|
if isinstance(misp_entity, AbstractMISP) and 'uuid' in misp_entity:
|
||||||
uuid = misp_entity.uuid
|
uuid = misp_entity.uuid
|
||||||
|
elif isinstance(misp_entity, dict) and 'uuid' in misp_entity:
|
||||||
|
uuid = misp_entity['uuid']
|
||||||
elif isinstance(misp_entity, str):
|
elif isinstance(misp_entity, str):
|
||||||
uuid = misp_entity
|
uuid = misp_entity
|
||||||
if isinstance(tag, MISPTag):
|
if isinstance(tag, MISPTag):
|
||||||
|
|
Loading…
Reference in New Issue