-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblocks-get
More file actions
executable file
·39 lines (30 loc) · 976 Bytes
/
blocks-get
File metadata and controls
executable file
·39 lines (30 loc) · 976 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
32
33
34
35
36
37
#!/usr/bin/bash
auth 2>/dev/null || authn 2>/dev/null
tenant=$(cat tenant)
okapi_url=$(cat okapi.url)
okapi_token=$(cat okapi.token)
search_for=$(tr -dc "[0-9a-f\-]" <<< "$1")
barcodefound=0
if [[ ${search_for} =~ ^[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*$ ]];then
endpoint="${okapi_url}/users/${search_for}"
else
endpoint="${okapi_url}/users?query=barcode==${search_for}"
barcodefound=1
fi
apicall=$(curl -s -w '\n' -X GET -D \
-H "Accept: application/json" \
-H "X-Okapi-Tenant: ${tenant}" \
-H "x-okapi-token: ${okapi_token}" \
"${endpoint}")
if [[ ${barcodefound} -eq 1 ]];then
apicall=$(echo $apicall |jq '.users[0]')
user_uuid=$(echo $apicall |jq -r .id)
else
user_uuid=${search_for}
fi
apicall=$(curl -s -w '\n' -X GET -D \
-H "Accept: application/json" \
-H "X-Okapi-Tenant: ${tenant}" \
-H "x-okapi-token: ${okapi_token}" \
${okapi_url}/user-summary/${user_uuid})
echo $apicall |jq .