Skip to content

Commit

Permalink
search_objects accepts configuration param
Browse files Browse the repository at this point in the history
reimplemented after resolving pylint
conflicts
  • Loading branch information
kshepherd committed Dec 11, 2024
1 parent 2321e51 commit 7fcb83d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions dspace_rest_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ def search_objects(
size=20,
sort=None,
dso_type=None,
configuration='default',
embeds=None,
):
"""
Expand All @@ -498,6 +499,7 @@ def search_objects(
@param size: size of page (aka. 'rows'), affects the page parameter above
@param sort: sort eg. 'title,asc'
@param dso_type: DSO type to further filter results
@param configuration: Search (discovery) configuration to apply to the query
@param embeds: Optional list of embeds to apply to each search object result
@return: list of DspaceObject objects constructed from API resources
"""
Expand All @@ -518,6 +520,8 @@ def search_objects(
params["page"] = page
if sort is not None:
params["sort"] = sort
if configuration is not None:
params['configuration'] = configuration

r_json = self.fetch_resource(url=url, params={**params, **filters})

Expand Down Expand Up @@ -548,6 +552,7 @@ def search_objects_iter(
filters=None,
dso_type=None,
sort=None,
configuration='default',
embeds=None,
):
"""
Expand All @@ -557,6 +562,7 @@ def search_objects_iter(
@param filters: discovery filters as dict eg. {'f.entityType': 'Publication,equals', ... }
@param sort: sort eg. 'title,asc'
@param dso_type: DSO type to further filter results
@param configuration: Search (discovery) configuration to apply to the query
@param embeds: Optional list of embeds to apply to each search object result
@return: Iterator of SimpleDSpaceObject
"""
Expand All @@ -572,6 +578,8 @@ def search_objects_iter(
params["dsoType"] = dso_type
if sort is not None:
params["sort"] = sort
if configuration is not None:
params['configuration'] = configuration

return do_paginate(url, {**params, **filters})

Expand Down
2 changes: 1 addition & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
# scoped to this collection
# (there is no collection/items endpoint, though there is a /mappedItems endpoint,
# not yet implemented here)
items = d.search_objects(query='*:*', scope=collection.uuid, dso_type='item')
items = d.search_objects(query='*:*', scope=collection.uuid, dso_type='item', configuration='default')
for item in items:
print(f'{item.name} ({item.uuid})')
# Get all bundles in this item
Expand Down

0 comments on commit 7fcb83d

Please sign in to comment.