-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathagreement-delete
More file actions
executable file
·22 lines (14 loc) · 1.06 KB
/
agreement-delete
File metadata and controls
executable file
·22 lines (14 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/bash
auth 2>/dev/null || authn 2>/dev/null
tenant=$(cat tenant)
okapi_url=$(cat okapi.url)
okapi_token=$(cat okapi.token)
agreement_uuid=$(tr -dc [0-9a-f\-] <<< $1)
if [[ ${agreement_uuid} =~ ^[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*$ ]];then
entitlement_uuid=$(curl -s -w '\n' -X GET -H "Accept: application/json" -H "X-Okapi-Tenant: ${tenant}" -H "x-okapi-token: ${okapi_token}" "${okapi_url}/erm/entitlements?filters=owner==${agreement_uuid}" |jq -r '.[0]?.id')
if [[ ${entitlement_uuid} =~ ^[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*$ ]];then
payload="{\"id\":\"${agreement_uuid}\",\"items\":[{\"id\":\"${entitlement_uuid}\",\"_delete\":true}]}"
curl --http1.1 -s -w '\n' -X PUT -H "Content-type: application/json" -H "Accept: text/plain" -H "X-Okapi-Tenant: ${tenant}" -H "x-okapi-token: ${okapi_token}" -d "${payload}" "${okapi_url}/erm/sas/${agreement_uuid}"
fi
curl -s -w '\n' -X DELETE -D -H "Accept: application/json" -H "X-Okapi-Tenant: ${tenant}" -H "x-okapi-token: ${okapi_token}" "${okapi_url}/erm/sas/${agreement_uuid}"
fi