-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestDeleteLibrary.sh
More file actions
executable file
·31 lines (25 loc) · 986 Bytes
/
testDeleteLibrary.sh
File metadata and controls
executable file
·31 lines (25 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Run testLibrList.sh and capture output
LIBRARIES=$(./testLibrList.sh)
# Extract the first library_id using jq
LIBRARY_ID=$(echo "$LIBRARIES" | jq -r '.[0].id' 2>/dev/null)
if [ -z "$LIBRARY_ID" ] || [ "$LIBRARY_ID" = "null" ]; then
echo "Error: No libraries found or invalid library_id" >&2
exit 1
fi
echo "Deleting library $LIBRARY_ID"
RESPONSE=$(curl -s -X DELETE "http://10.10.10.129:8000/libraries/$LIBRARY_ID" \
-w "\nHTTP_STATUS:%{http_code}")
HTTP_STATUS=$(echo "$RESPONSE" | grep -o 'HTTP_STATUS:[0-9]\+' | cut -d':' -f2)
RESPONSE=$(echo "$RESPONSE" | sed '/HTTP_STATUS:/d')
if [ "$HTTP_STATUS" -eq 200 ]; then
echo "JSON Response:"
echo "$RESPONSE" | jq . 2>/dev/null || echo "$RESPONSE"
echo "testDeleteLibrary.sh: Successfully deleted library $LIBRARY_ID"
else
echo "Error Response:"
echo "$RESPONSE"
echo "HTTP Status: $HTTP_STATUS"
echo "testDeleteLibrary.sh: Failed to delete library $LIBRARY_ID"
exit 1
fi