Skip to content

Commit 0f96546

Browse files
committed
add function to fetch all EPersons in a group
1 parent d572cda commit 0f96546

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

dspace_rest_client/client.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,26 @@ def search_groups_by_metadata(self, query, page=0, size=20):
17541754

17551755
return groups
17561756

1757+
def get_epersons_in_group(self, group_uuid, page=0, size=20):
1758+
"""
1759+
Fetch all EPersons in a group
1760+
@param group_uuid: UUID of the group
1761+
@param page: Page number for pagination
1762+
@param size: Number of results per page
1763+
@return: List of User objects
1764+
"""
1765+
url = f"{self.API_ENDPOINT}/eperson/groups/{group_uuid}/epersons"
1766+
params = parse_params(page=page, size=size)
1767+
response = self.api_get(url, params=params)
1768+
response_json = parse_json(response=response)
1769+
epersons = []
1770+
1771+
if "_embedded" in response_json and "epersons" in response_json["_embedded"]:
1772+
for eperson_data in response_json["_embedded"]["epersons"]:
1773+
epersons.append(User(eperson_data))
1774+
1775+
return epersons
1776+
17571777
def start_workflow(self, workspace_item):
17581778
url = f"{self.API_ENDPOINT}/workflow/workflowitems"
17591779
res = parse_json(self.api_post_uri(url, params=None, uri_list=workspace_item))

0 commit comments

Comments
 (0)