Skip to content

Commit 0d644df

Browse files
committed
add delete_item function
1 parent 2f99ee1 commit 0d644df

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

dspace_rest_client/client.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,11 +1280,11 @@ def patch_item(
12801280
if not item_uuid:
12811281
logging.error("Item UUID is required")
12821282
return None
1283-
1283+
12841284
if not field or not value:
12851285
logging.error("Field and value are required")
12861286
return None
1287-
1287+
12881288
if not operation or operation not in [
12891289
self.PatchOperation.ADD,
12901290
self.PatchOperation.REPLACE,
@@ -1391,6 +1391,19 @@ def add_metadata(
13911391

13921392
return dso_type(api_resource=parse_json(r))
13931393

1394+
def delete_item(self, item_uuid):
1395+
"""
1396+
Delete an item, given its UUID
1397+
@param item_uuid: the UUID of the item
1398+
@return: the raw API response
1399+
"""
1400+
try:
1401+
url = f"{self.API_ENDPOINT}/core/items/{item_uuid}"
1402+
return self.api_delete(url)
1403+
except ValueError:
1404+
logging.error("Invalid item UUID: %s", item_uuid)
1405+
return None
1406+
13941407
def create_user(self, user, token=None, embeds=None):
13951408
"""
13961409
Create a user

0 commit comments

Comments
 (0)