diff --git a/pymisp/api.py b/pymisp/api.py index d462c56..6149a71 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -1935,6 +1935,25 @@ class PyMISP: s.from_dict(**sharing_group_j) 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: """Delete a sharing group diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index 633afed..a102a79 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -2077,6 +2077,10 @@ class TestComprehensive(unittest.TestCase): sharing_group = self.admin_misp_connector.add_sharing_group(sg, pythonify=True) self.assertEqual(sharing_group.name, 'Testcases SG') 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 r = self.admin_misp_connector.add_org_to_sharing_group(sharing_group, self.test_org, extend=True)