mirror of https://github.com/MISP/PyMISP
fix: handle list responses properly
parent
8fb34a2892
commit
c3a3868f42
|
@ -718,10 +718,10 @@ class PyMISP:
|
||||||
r = self._prepare_request('GET', f'objectTemplates/getRaw/{uuid_or_name}')
|
r = self._prepare_request('GET', f'objectTemplates/getRaw/{uuid_or_name}')
|
||||||
return self._check_json_response(r)
|
return self._check_json_response(r)
|
||||||
|
|
||||||
def update_object_templates(self) -> dict[str, Any]:
|
def update_object_templates(self) -> dict[str, Any] | list[dict[str, Any]]:
|
||||||
"""Trigger an update of the object templates"""
|
"""Trigger an update of the object templates"""
|
||||||
response = self._prepare_request('POST', 'objectTemplates/update')
|
response = self._prepare_request('POST', 'objectTemplates/update')
|
||||||
return self._check_json_response(response)
|
return self._check_json_response_list(response)
|
||||||
|
|
||||||
# ## END Object ###
|
# ## END Object ###
|
||||||
|
|
||||||
|
@ -1202,7 +1202,7 @@ class PyMISP:
|
||||||
response = self._prepare_request('POST', f'taxonomies/enable/{taxonomy_id}')
|
response = self._prepare_request('POST', f'taxonomies/enable/{taxonomy_id}')
|
||||||
return self._check_json_response(response)
|
return self._check_json_response(response)
|
||||||
|
|
||||||
def disable_taxonomy(self, taxonomy: MISPTaxonomy | int | str | UUID) -> dict[str, Any]:
|
def disable_taxonomy(self, taxonomy: MISPTaxonomy | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]:
|
||||||
"""Disable a taxonomy: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/disableTaxonomy
|
"""Disable a taxonomy: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/disableTaxonomy
|
||||||
|
|
||||||
:param taxonomy: taxonomy to disable
|
:param taxonomy: taxonomy to disable
|
||||||
|
@ -1238,10 +1238,10 @@ class PyMISP:
|
||||||
response = self._prepare_request('POST', url)
|
response = self._prepare_request('POST', url)
|
||||||
return self._check_json_response(response)
|
return self._check_json_response(response)
|
||||||
|
|
||||||
def update_taxonomies(self) -> dict[str, Any]:
|
def update_taxonomies(self) -> dict[str, Any] | list[dict[str, Any]]:
|
||||||
"""Update all the taxonomies: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/updateTaxonomies"""
|
"""Update all the taxonomies: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/updateTaxonomies"""
|
||||||
response = self._prepare_request('POST', 'taxonomies/update')
|
response = self._prepare_request('POST', 'taxonomies/update')
|
||||||
return self._check_json_response(response)
|
return self._check_json_response_list(response)
|
||||||
|
|
||||||
def set_taxonomy_required(self, taxonomy: MISPTaxonomy | int | str, required: bool = False) -> dict[str, Any]:
|
def set_taxonomy_required(self, taxonomy: MISPTaxonomy | int | str, required: bool = False) -> dict[str, Any]:
|
||||||
taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy)
|
taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy)
|
||||||
|
@ -1330,18 +1330,18 @@ class PyMISP:
|
||||||
warninglist_id = get_uuid_or_id_from_abstract_misp(warninglist)
|
warninglist_id = get_uuid_or_id_from_abstract_misp(warninglist)
|
||||||
return self.toggle_warninglist(warninglist_id=warninglist_id, force_enable=False)
|
return self.toggle_warninglist(warninglist_id=warninglist_id, force_enable=False)
|
||||||
|
|
||||||
def values_in_warninglist(self, value: Iterable[str]) -> dict[str, Any]:
|
def values_in_warninglist(self, value: Iterable[str]) -> dict[str, Any] | list[dict[str, Any]]:
|
||||||
"""Check if IOC values are in warninglist
|
"""Check if IOC values are in warninglist
|
||||||
|
|
||||||
:param value: iterator with values to check
|
:param value: iterator with values to check
|
||||||
"""
|
"""
|
||||||
response = self._prepare_request('POST', 'warninglists/checkValue', data=value)
|
response = self._prepare_request('POST', 'warninglists/checkValue', data=value)
|
||||||
return self._check_json_response(response)
|
return self._check_json_response_list(response)
|
||||||
|
|
||||||
def update_warninglists(self) -> dict[str, Any]:
|
def update_warninglists(self) -> dict[str, Any] | list[dict[str, Any]]:
|
||||||
"""Update all the warninglists: https://www.misp-project.org/openapi/#tag/Warninglists/operation/updateWarninglists"""
|
"""Update all the warninglists: https://www.misp-project.org/openapi/#tag/Warninglists/operation/updateWarninglists"""
|
||||||
response = self._prepare_request('POST', 'warninglists/update')
|
response = self._prepare_request('POST', 'warninglists/update')
|
||||||
return self._check_json_response(response)
|
return self._check_json_response_list(response)
|
||||||
|
|
||||||
# ## END Warninglists ###
|
# ## END Warninglists ###
|
||||||
|
|
||||||
|
@ -1400,10 +1400,10 @@ class PyMISP:
|
||||||
response = self._prepare_request('POST', f'noticelists/enableNoticelist/{noticelist_id}')
|
response = self._prepare_request('POST', f'noticelists/enableNoticelist/{noticelist_id}')
|
||||||
return self._check_json_response(response)
|
return self._check_json_response(response)
|
||||||
|
|
||||||
def update_noticelists(self) -> dict[str, Any]:
|
def update_noticelists(self) -> dict[str, Any] | list[dict[str, Any]]:
|
||||||
"""Update all the noticelists: https://www.misp-project.org/openapi/#tag/Noticelists/operation/updateNoticelists"""
|
"""Update all the noticelists: https://www.misp-project.org/openapi/#tag/Noticelists/operation/updateNoticelists"""
|
||||||
response = self._prepare_request('POST', 'noticelists/update')
|
response = self._prepare_request('POST', 'noticelists/update')
|
||||||
return self._check_json_response(response)
|
return self._check_json_response_list(response)
|
||||||
|
|
||||||
# ## END Noticelist ###
|
# ## END Noticelist ###
|
||||||
|
|
||||||
|
@ -1553,10 +1553,10 @@ class PyMISP:
|
||||||
response.append(c)
|
response.append(c)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def update_galaxies(self) -> dict[str, Any]:
|
def update_galaxies(self) -> dict[str, Any] | list[dict[str, Any]]:
|
||||||
"""Update all the galaxies: https://www.misp-project.org/openapi/#tag/Galaxies/operation/updateGalaxies"""
|
"""Update all the galaxies: https://www.misp-project.org/openapi/#tag/Galaxies/operation/updateGalaxies"""
|
||||||
response = self._prepare_request('POST', 'galaxies/update')
|
response = self._prepare_request('POST', 'galaxies/update')
|
||||||
return self._check_json_response(response)
|
return self._check_json_response_list(response)
|
||||||
|
|
||||||
def get_galaxy_cluster(self, galaxy_cluster: MISPGalaxyCluster | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPGalaxyCluster:
|
def get_galaxy_cluster(self, galaxy_cluster: MISPGalaxyCluster | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPGalaxyCluster:
|
||||||
"""Gets a specific galaxy cluster
|
"""Gets a specific galaxy cluster
|
||||||
|
@ -2475,10 +2475,10 @@ class PyMISP:
|
||||||
|
|
||||||
# ## BEGIN Decaying Models ###
|
# ## BEGIN Decaying Models ###
|
||||||
|
|
||||||
def update_decaying_models(self) -> dict[str, Any]:
|
def update_decaying_models(self) -> dict[str, Any] | list[dict[str, Any]]:
|
||||||
"""Update all the Decaying models"""
|
"""Update all the Decaying models"""
|
||||||
response = self._prepare_request('POST', 'decayingModel/update')
|
response = self._prepare_request('POST', 'decayingModel/update')
|
||||||
return self._check_json_response(response)
|
return self._check_json_response_list(response)
|
||||||
|
|
||||||
def decaying_models(self, pythonify: bool = False) -> dict[str, Any] | list[MISPDecayingModel] | list[dict[str, Any]]:
|
def decaying_models(self, pythonify: bool = False) -> dict[str, Any] | list[MISPDecayingModel] | list[dict[str, Any]]:
|
||||||
"""Get all the decaying models
|
"""Get all the decaying models
|
||||||
|
|
Loading…
Reference in New Issue