Skip to content

Commit 7fcb83d

Browse files
committed
search_objects accepts configuration param
reimplemented after resolving pylint conflicts
1 parent 2321e51 commit 7fcb83d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

dspace_rest_client/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ def search_objects(
487487
size=20,
488488
sort=None,
489489
dso_type=None,
490+
configuration='default',
490491
embeds=None,
491492
):
492493
"""
@@ -498,6 +499,7 @@ def search_objects(
498499
@param size: size of page (aka. 'rows'), affects the page parameter above
499500
@param sort: sort eg. 'title,asc'
500501
@param dso_type: DSO type to further filter results
502+
@param configuration: Search (discovery) configuration to apply to the query
501503
@param embeds: Optional list of embeds to apply to each search object result
502504
@return: list of DspaceObject objects constructed from API resources
503505
"""
@@ -518,6 +520,8 @@ def search_objects(
518520
params["page"] = page
519521
if sort is not None:
520522
params["sort"] = sort
523+
if configuration is not None:
524+
params['configuration'] = configuration
521525

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

@@ -548,6 +552,7 @@ def search_objects_iter(
548552
filters=None,
549553
dso_type=None,
550554
sort=None,
555+
configuration='default',
551556
embeds=None,
552557
):
553558
"""
@@ -557,6 +562,7 @@ def search_objects_iter(
557562
@param filters: discovery filters as dict eg. {'f.entityType': 'Publication,equals', ... }
558563
@param sort: sort eg. 'title,asc'
559564
@param dso_type: DSO type to further filter results
565+
@param configuration: Search (discovery) configuration to apply to the query
560566
@param embeds: Optional list of embeds to apply to each search object result
561567
@return: Iterator of SimpleDSpaceObject
562568
"""
@@ -572,6 +578,8 @@ def search_objects_iter(
572578
params["dsoType"] = dso_type
573579
if sort is not None:
574580
params["sort"] = sort
581+
if configuration is not None:
582+
params['configuration'] = configuration
575583

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

example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
# scoped to this collection
221221
# (there is no collection/items endpoint, though there is a /mappedItems endpoint,
222222
# not yet implemented here)
223-
items = d.search_objects(query='*:*', scope=collection.uuid, dso_type='item')
223+
items = d.search_objects(query='*:*', scope=collection.uuid, dso_type='item', configuration='default')
224224
for item in items:
225225
print(f'{item.name} ({item.uuid})')
226226
# Get all bundles in this item

0 commit comments

Comments
 (0)