Skip to content

Commit 434ad28

Browse files
committed
add function to get mapped collections for an item
1 parent 0c9e1ce commit 434ad28

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

dspace_rest_client/client.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,29 @@ def update_item_owning_collection(
15491549
logging.error(f"Error updating owning collection for item {item.uuid}: {e}")
15501550
return False
15511551

1552+
def get_item_mapped_collections(self, item):
1553+
"""
1554+
Get the mapped collections of a given item
1555+
@param item: Item object
1556+
@return: Mapped Collection object
1557+
"""
1558+
if not isinstance(item, Item):
1559+
logging.error("Need a valid item")
1560+
return None
1561+
1562+
url = f"{self.API_ENDPOINT}/core/items/{item.uuid}/mappedCollections"
1563+
try:
1564+
response = self.api_get(url)
1565+
if response.status_code == 200:
1566+
return parse_json(response)
1567+
else:
1568+
return None
1569+
except Exception as e:
1570+
logging.error(
1571+
f"Error retrieving mapped collections for item {item.uuid}: {e}"
1572+
)
1573+
return None
1574+
15521575
def create_user(self, user, token=None, embeds=None):
15531576
"""
15541577
Create a user

0 commit comments

Comments
 (0)