mirror of https://github.com/MISP/PyMISP
new: Method `update_sharing_group`
parent
d44d3cd0e4
commit
ceb34ecad0
|
@ -1935,6 +1935,25 @@ class PyMISP:
|
||||||
s.from_dict(**sharing_group_j)
|
s.from_dict(**sharing_group_j)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
def update_sharing_group(self, sharing_group: Union[MISPSharingGroup, dict], sharing_group_id: Optional[int] = None, pythonify: bool = False) -> Union[Dict, MISPSharingGroup]:
|
||||||
|
"""Update sharing group parameters
|
||||||
|
|
||||||
|
:param sharing_group: MISP Sharing Group
|
||||||
|
:param sharing_group_id Sharing group ID
|
||||||
|
:param pythonify: Returns a PyMISP Object instead of the plain json output
|
||||||
|
"""
|
||||||
|
if sharing_group_id is None:
|
||||||
|
sid = get_uuid_or_id_from_abstract_misp(sharing_group)
|
||||||
|
else:
|
||||||
|
sid = get_uuid_or_id_from_abstract_misp(sharing_group_id)
|
||||||
|
r = self._prepare_request('POST', f'sharing_groups/edit/{sid}', data=sharing_group)
|
||||||
|
updated_sharing_group = self._check_json_response(r)
|
||||||
|
if not (self.global_pythonify or pythonify) or 'errors' in updated_sharing_group:
|
||||||
|
return updated_sharing_group
|
||||||
|
s = MISPSharingGroup()
|
||||||
|
s.from_dict(**updated_sharing_group)
|
||||||
|
return s
|
||||||
|
|
||||||
def delete_sharing_group(self, sharing_group: Union[MISPSharingGroup, int, str, UUID]) -> Dict:
|
def delete_sharing_group(self, sharing_group: Union[MISPSharingGroup, int, str, UUID]) -> Dict:
|
||||||
"""Delete a sharing group
|
"""Delete a sharing group
|
||||||
|
|
||||||
|
|
|
@ -2077,6 +2077,10 @@ class TestComprehensive(unittest.TestCase):
|
||||||
sharing_group = self.admin_misp_connector.add_sharing_group(sg, pythonify=True)
|
sharing_group = self.admin_misp_connector.add_sharing_group(sg, pythonify=True)
|
||||||
self.assertEqual(sharing_group.name, 'Testcases SG')
|
self.assertEqual(sharing_group.name, 'Testcases SG')
|
||||||
self.assertEqual(sharing_group.releasability, 'Testing')
|
self.assertEqual(sharing_group.releasability, 'Testing')
|
||||||
|
# Change releasability
|
||||||
|
r = self.admin_misp_connector.update_sharing_group({"releasability": "Testing updated"}, sharing_group)
|
||||||
|
self.assertEqual(sharing_group.releasability, 'Testing updated')
|
||||||
|
|
||||||
# add org
|
# add org
|
||||||
r = self.admin_misp_connector.add_org_to_sharing_group(sharing_group,
|
r = self.admin_misp_connector.add_org_to_sharing_group(sharing_group,
|
||||||
self.test_org, extend=True)
|
self.test_org, extend=True)
|
||||||
|
|
Loading…
Reference in New Issue