Skip to content

Commit d572cda

Browse files
committed
add function to search for groups by metadata
1 parent 2136e3b commit d572cda

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
@@ -1734,6 +1734,26 @@ def remove_subgroup(self, parent_uuid, child_uuid):
17341734
)
17351735
return False
17361736

1737+
def search_groups_by_metadata(self, query, page=0, size=20):
1738+
"""
1739+
Search for groups by metadata
1740+
@param query: Search query (UUID or group name)
1741+
@param page: Page number for pagination
1742+
@param size: Number of results per page
1743+
@return: List of Group objects
1744+
"""
1745+
url = f"{self.API_ENDPOINT}/eperson/groups/search/byMetadata"
1746+
params = parse_params(query=query, page=page, size=size)
1747+
response = self.api_get(url, params=params)
1748+
response_json = parse_json(response=response)
1749+
groups = []
1750+
1751+
if "_embedded" in response_json and "groups" in response_json["_embedded"]:
1752+
for group_data in response_json["_embedded"]["groups"]:
1753+
groups.append(Group(group_data))
1754+
1755+
return groups
1756+
17371757
def start_workflow(self, workspace_item):
17381758
url = f"{self.API_ENDPOINT}/workflow/workflowitems"
17391759
res = parse_json(self.api_post_uri(url, params=None, uri_list=workspace_item))

0 commit comments

Comments
 (0)