Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 7 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
print('Error logging in! Giving up.')
sys.exit(1)

# An example of searching for workflow items (any search configuration from discovery.xml can be used)
# note that the results here depend on the workflow role / access of the logged in user
search_results = d.search_objects(query='*:*', dso_type='item', configuration='workflow')
for result in search_results:
print(f'{result.name} ({result.uuid})')

# Put together some basic Community data.
# See https://github.com/DSpace/RestContract/blob/main/communities.md
community_data = {
Expand Down Expand Up @@ -214,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