Skip to content

Instantly share code, notes, and snippets.

@gmelodie
Created September 29, 2022 18:51
Show Gist options
  • Save gmelodie/706feaa79c1b76fa66cfa3021b646f1f to your computer and use it in GitHub Desktop.
Save gmelodie/706feaa79c1b76fa66cfa3021b646f1f to your computer and use it in GitHub Desktop.
Estuary bash utilities and shortcuts
estuary_set_auth() {
export APIKEY=$1
}
estuary_create_collection() {
coluuid=$(curl -X POST -H "Authorization: Bearer $APIKEY" "http://localhost:3004/collections/" -d '{ "name": "A new collection", "description": "A new collection test" }' -s | jq | grep uuid | cut -d '"' -f 4)
export LAST_COLLECTION=$coluuid
echo $coluuid
}
# usage: estuary_create_collection | estuary_add_content
estuary_add_content() {
filename=/tmp/dummy_file_$RANDOM
fallocate -l 500K $filename
coluuid=$(read in echo $in)
curl -X POST "http://localhost:3004/content/add?coluuid=$coluuid" -H "Authorization: Bearer $APIKEY" -H "Accept: application/json" -H "Content-Type: multipart/form-data" -F "data=@$filename" -s | jq | grep cid | cut -d '"' -f 4
}
estuary_add_content_to_collection() {
estuary_create_collection | tee /dev/tty | estuary_add_content
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment