Skip to content

Commit 9876642

Browse files
committed
add function to add a subgroup to a parent group
1 parent ba89e64 commit 9876642

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dspace_rest_client/client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,19 @@ def get_subgroups(self, parent_uuid, page=0, size=20):
16661666

16671667
return subgroups
16681668

1669+
def add_subgroup(self, parent_uuid, child_uuid):
1670+
"""
1671+
Add a subgroup to a parent group
1672+
@param parent_uuid: UUID of the parent group
1673+
@param child_uuid: UUID of the subgroup to add
1674+
@return: Boolean indicating success or failure
1675+
"""
1676+
url = f"{self.API_ENDPOINT}/eperson/groups/{parent_uuid}/subgroups"
1677+
headers = {"Content-Type": "text/uri-list"}
1678+
data = f"{self.API_ENDPOINT}/eperson/groups/{child_uuid}"
1679+
response = self.api_post(url, headers=headers, data=data)
1680+
return response.status_code == 204
1681+
16691682
def start_workflow(self, workspace_item):
16701683
url = f"{self.API_ENDPOINT}/workflow/workflowitems"
16711684
res = parse_json(self.api_post_uri(url, params=None, uri_list=workspace_item))

0 commit comments

Comments
 (0)