Skip to content

Instantly share code, notes, and snippets.

@vjrj
Created November 25, 2019 10:26
Show Gist options
  • Save vjrj/ae539c08ee04350a43e2bc2bbe7b5b6b to your computer and use it in GitHub Desktop.
Save vjrj/ae539c08ee04350a43e2bc2bbe7b5b6b to your computer and use it in GitHub Desktop.
Basic LA record consumers test
#!/bin/bash
# Usage "check-dr-linked-record-consumers.sh dr225 dr226"
#
ERRORS=0
DEBUG=1
drs=$1
for dr in $(echo $drs | tr "," "\n")
do
EXIST=$(curl -s https://colecciones.gbif.es/ws/eml/$dr)
if [[ $EXIST == "no such entity $dr" ]]
then
echo "ERROR: No such resource $dr"
ERRORS=$[ERRORS + 1]
else
REC=$(curl -s https://colecciones.gbif.es/ws/dataResource/$dr | jq .linkedRecordConsumers)
if [[ $REC == "null" ]]
then
echo "WARN: Incorrect linked record consumers for $dr"
echo "https://colecciones.gbif.es/ws/dataResource/$dr"
ERRORS=$[ERRORS + 1]
else
if [[ $DEBUG -eq 1 ]] ; then echo "INFO: Linked record consumers for $dr: $REC"; fi
fi
fi
done
if [[ $ERRORS -gt 0 ]]
then
exit 1
else
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment