-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestUpdateLibraryMetadata.sh
More file actions
executable file
·38 lines (32 loc) · 1.29 KB
/
testUpdateLibraryMetadata.sh
File metadata and controls
executable file
·38 lines (32 loc) · 1.29 KB
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
32
33
34
35
36
37
38
#!/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 "Updating metadata for library $LIBRARY_ID"
ATTEMPTS=3
for ((i=1; i<=ATTEMPTS; i++)); do
RESPONSE=$(curl -v -X PUT "http://10.10.10.129:8000/libraries/$LIBRARY_ID" \
-H "Content-Type: application/json" \
-d '{"name": "Updated Library Name 4"}' \
-w "\nHTTP_STATUS:%{http_code}" 2>&1)
HTTP_STATUS=$(echo "$RESPONSE" | grep -o 'HTTP_STATUS:[0-9]\+' | cut -d':' -f2)
RESPONSE=$(echo "$RESPONSE" | sed '/HTTP_STATUS:/d')
if [ -n "$HTTP_STATUS" ] && [ $HTTP_STATUS -eq 200 ]; then
echo "JSON Response:"
echo "$RESPONSE" | jq . 2>/dev/null || echo "$RESPONSE"
echo "testUpdateLibraryMetadata.sh: Successfully updated metadata for library $LIBRARY_ID"
exit 0
fi
echo "Attempt $i/$ATTEMPTS failed. Retrying..." >&2
sleep 2
done
echo "Error Response:"
echo "$RESPONSE"
echo "HTTP Status: ${HTTP_STATUS:-Unknown}"
echo "testUpdateLibraryMetadata.sh: Failed to update metadata for library $LIBRARY_ID"
exit 1