This happened on a VM running 1.16 on Ubuntu 22.04. We wanted to test bulk deleting AIPs using the storage service API, since we recently ran into an issue that caused AIPs to be ingested that weren't up to our specifications on our production instance.
import csv
import requests
import json
from datetime import datetime
def delete_aip_from_csv(csv_file, api_key, base_url, event_reason, pipeline_uuid, user_id, user_email, log_file):
headers = {
"Authorization": f"ApiKey {api_key}",
"Content-Type": "application/json"
}
with open(log_file, "a") as log:
log.write(f"Log started at {datetime.now()}\n")
with open(csv_file, "r") as file:
reader = csv.DictReader(file)
for row in reader:
uuid = row.get("UUID")
if not uuid:
log.write("Skipping row without UUID.\n")
continue
url = f"{base_url}/api/v2/file/{uuid}/delete_aip/"
payload = {
"event_reason": event_reason,
"pipeline": pipeline_uuid,
"user_id": user_id,
"user_email": user_email
}
try:
response =
requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
log.write(f"SUCCESS: Deleted package with UUID: {uuid}\n")
else:
log.write(f"FAILURE: UUID: {uuid}, Status: {response.status_code}, Response: {response.text}\n")
except requests.RequestException as e:
log.write(f"ERROR: UUID: {uuid}, Exception: {e}\n")
log.write(f"Log ended at {datetime.now()}\n")
csv_file = ""
api_key = ""
base_url = ""
event_reason = ""
pipeline_uuid = ""
user_id =
user_email = ""
log_file = ""
delete_aip_from_csv(csv_file, api_key, base_url, event_reason, pipeline_uuid, user_id, user_email, log_file)
The script returned the following message for each package: Status: 202 , Response {"message: "Delete request created successfully." ...}.
However, when I opened the dashboard, this is what Archival Storage looked like:
On the storage service side, the requests showed up and I was able to delete the AIPs. I checked the backend and they were actually deleted as well.
I have restarted a-matica and rebooted the VM to no avail. Any insights are appreciated!
Univ. of Alabama at Birmingham Libraries