-
Notifications
You must be signed in to change notification settings - Fork 0
/
nav-test-ingest.sh
executable file
·64 lines (54 loc) · 1.46 KB
/
nav-test-ingest.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
while getopts ":d:e:" OPTION
do
case $OPTION in
d)
# this option specifies the documents csv
export CSV_DOCS="$OPTARG"
;;
e)
# this option specifies the events csv
export CSV_EVENTS="$OPTARG"
;;
?)
echo "Usage: $(basename $0) -d <PATH_TO_DOCS_CSV> -e <PATH_TO_EVENTS_CSV>"
exit 1
;;
esac
done
if [[ -z "$CSV_DOCS" ]]; then
echo "Usage: $(basename $0) -d <PATH_TO_DOCS_CSV> -e <PATH_TO_EVENTS_CSV>"
exit 1
fi
if [[ -z "$CSV_EVENTS" ]]; then
echo "Usage: $(basename $0) -d <PATH_TO_DOCS_CSV> -e <PATH_TO_EVENTS_CSV>"
exit 1
fi
export API_HOST="http://localhost:8888"
export SUPERUSER_EMAIL="[email protected]"
SUPERUSER_PASSWORD="password"
clear
# ---------- Functions ----------
get_token() {
curl -s \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=$SUPERUSER_EMAIL&password=$SUPERUSER_PASSWORD" \
${API_HOST}/api/tokens | \
jq ".access_token" | tr -d '"'
}
upload_csv() {
TOKEN=$(get_token)
URL=${API_HOST}/api/v1/admin/bulk-ingest/cclw/law-policy
echo Uploading to ${URL}
curl -v \
-H "Authorization: Bearer ${TOKEN}" \
-F "law_policy_csv=@${CSV_DOCS}" \
-F "events_csv=@${CSV_EVENTS}" \
${URL}
}
# ---------- Script ----------
echo -n "👉👉👉 Uploading CSV"
set -x
upload_csv
set +x
echo -n "👉👉👉 Now go and check the log output!"