@@ -446,20 +446,21 @@ def search_objects(self, query=None, scope=None, filters=None, page=0, size=20,
446446 item_constructor = lambda x : SimpleDSpaceObject (x ['_embedded' ]['indexableObject' ]),
447447 embedding = lambda x : x ['_embedded' ]['searchResult' ]
448448 )
449- def search_objects_iter (do_paginate , self , query = None , scope = None , filters = None , dso_type = None , sort = None ):
449+ def search_objects_iter (do_paginate , self , query = None , scope = None , filters = None , dso_type = None , sort = None , embeds = None ):
450450 """
451451 Do a basic search as in search_objects, automatically handling pagination by requesting the next page when all items from one page have been consumed
452452 @param query: query string
453453 @param scope: uuid to limit search scope, eg. owning collection, parent community, etc.
454454 @param filters: discovery filters as dict eg. {'f.entityType': 'Publication,equals', ... }
455455 @param sort: sort eg. 'title,asc'
456456 @param dso_type: DSO type to further filter results
457+ @param embeds: Optional list of embeds to apply to each search object result
457458 @return: Iterator of SimpleDSpaceObject
458459 """
459460 if filters is None :
460461 filters = {}
461462 url = f'{ self .API_ENDPOINT } /discover/search/objects'
462- params = {}
463+ params = parse_params ( embeds = embeds )
463464 if query is not None :
464465 params ['query' ] = query
465466 if scope is not None :
@@ -645,14 +646,15 @@ def get_bundles(self, parent=None, uuid=None, page=0, size=20, sort=None, embeds
645646 return bundles
646647
647648 @paginated ('bundles' , Bundle )
648- def get_bundles_iter (do_paginate , self , parent , sort = None ):
649+ def get_bundles_iter (do_paginate , self , parent , sort = None , embeds = None ):
649650 """
650651 Get bundles for an item, automatically handling pagination by requesting the next page when all items from one page have been consumed
651652 @param parent: python Item object, from which the UUID will be referenced in the URL.
653+ @param embeds: Optional list of resources to embed in response JSON
652654 @return: Iterator of Bundle
653655 """
654656 url = f'{ self .API_ENDPOINT } /core/items/{ parent .uuid } /bundles'
655- params = {}
657+ params = parse_params ( embeds = embeds )
656658 if sort is not None :
657659 params ['sort' ] = sort
658660
@@ -713,18 +715,19 @@ def get_bitstreams(self, uuid=None, bundle=None, page=0, size=20, sort=None, emb
713715 return bitstreams
714716
715717 @paginated ('bitstreams' , Bitstream )
716- def get_bitstreams_iter (do_paginate , self , bundle , sort = None ):
718+ def get_bitstreams_iter (do_paginate , self , bundle , sort = None , embeds = None ):
717719 """
718720 Get all bitstreams for a specific bundle, automatically handling pagination by requesting the next page when all items from one page have been consumed
719721 @param bundle: A python Bundle object to parse for bitstream links to retrieve
722+ @param embeds: Optional list of resources to embed in response JSON
720723 @return: Iterator of Bitstream
721724 """
722725 if 'bitstreams' in bundle .links :
723726 url = bundle .links ['bitstreams' ]['href' ]
724727 else :
725728 url = f'{ self .API_ENDPOINT } /core/bundles/{ bundle .uuid } /bitstreams'
726729 logging .warning (f'Cannot find bundle bitstream links, will try to construct manually: { url } ' )
727- params = {}
730+ params = parse_params ( embeds = embeds )
728731 if sort is not None :
729732 params ['sort' ] = sort
730733
@@ -845,18 +848,19 @@ def get_communities(self, uuid=None, page=0, size=20, sort=None, top=False, embe
845848 return communities
846849
847850 @paginated ('communities' , Community )
848- def get_communities_iter (do_paginate , self , sort = None , top = False ):
851+ def get_communities_iter (do_paginate , self , sort = None , top = False , embeds = None ):
849852 """
850853 Get communities as an iterator, automatically handling pagination by requesting the next page when all items from one page have been consumed
851854 @param top: whether to restrict search to top communities (default: false)
855+ @param embeds: list of resources to embed in response JSON
852856 @return: Iterator of Community
853857 """
854858 if top :
855859 url = f'{ self .API_ENDPOINT } /core/communities/search/top'
856860 else :
857861 url = f'{ self .API_ENDPOINT } /core/communities'
858862
859- params = {}
863+ params = parse_params ( embeds = embeds )
860864 if sort is not None :
861865 params ['sort' ] = sort
862866
@@ -930,19 +934,22 @@ def get_collections(self, uuid=None, community=None, page=0, size=20, sort=None,
930934 return collections
931935
932936 @paginated ('collections' , Collection )
933- def get_collections_iter (do_paginate , self , community = None , sort = None ):
937+ def get_collections_iter (do_paginate , self , community = None , sort = None , embeds = None ):
934938 """
935939 Get collections as an iterator, automatically handling pagination by requesting the next page when all items from one page have been consumed
936940 @param community: Community object. If present, collections for a community
937941 @return: Iterator of Collection
938942 """
939943 url = f'{ self .API_ENDPOINT } /core/collections'
944+ params = parse_params (embeds = embeds )
945+ if sort is not None :
946+ params ['sort' ] = sort
940947
941948 if community is not None :
942949 if 'collections' in community .links and 'href' in community .links ['collections' ]:
943950 url = community .links ['collections' ]['href' ]
944951
945- return do_paginate (url , {} )
952+ return do_paginate (url , params )
946953
947954 def create_collection (self , parent , data , embeds = None ):
948955 """
@@ -1154,13 +1161,15 @@ def get_users(self, page=0, size=20, sort=None, embeds=None):
11541161 return users
11551162
11561163 @paginated ('epersons' , User )
1157- def get_users_iter (do_paginate , self , sort = None ):
1164+ def get_users_iter (do_paginate , self , sort = None , embeds = None ):
11581165 """
11591166 Get an iterator of users (epersons) in the DSpace instance, automatically handling pagination by requesting the next page when all items from one page have been consumed
1167+ @param sort: Optional sort parameter
1168+ @param embeds: Optional list of resources to embed in response JSON
11601169 @return: Iterator of User
11611170 """
11621171 url = f'{ self .API_ENDPOINT } /eperson/epersons'
1163- params = {}
1172+ params = parse_params ( embeds = embeds )
11641173 if sort is not None :
11651174 params ['sort' ] = sort
11661175
0 commit comments