-
Notifications
You must be signed in to change notification settings - Fork 0
/
loaddata.sh
executable file
·42 lines (37 loc) · 1.09 KB
/
loaddata.sh
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
39
40
41
42
export TOKEN=$(gcloud auth print-access-token)
#export GOOGLE_CLOUD_PROJECT=$(gcloud config get project)
export COUNTER=0
while [ $COUNTER -le 10 ]
do
RESULT=$(curl --location --request POST "https://firestore.googleapis.com/v1/projects/$GOOGLE_CLOUD_PROJECT/databases/(default)/documents/notes?documentId=b78dfdb" \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--data-raw "{
'fields': {
'id': {
'stringValue': 'b78dfdb'
},
'name': {
'stringValue': 'Test note'
},
'text': {
'stringValue': 'This is a test note'
},
'location': {
'stringValue': 'Berlin, Germany'
},
'likes': {
'integerValue': 7
}
}
}")
echo $RESULT
if [[ "$RESULT" == *error* ]]
then
COUNTER=$(( $COUNTER + 1 ))
echo "Error detected, waiting 10s and then retry $COUNTER of 10 tries..."
sleep 10s
else
COUNTER=11
fi
done