diff --git a/bin/bgeti b/bin/bgeti new file mode 100755 index 00000000..e373d73d --- /dev/null +++ b/bin/bgeti @@ -0,0 +1,35 @@ +#!/bin/bash +# +# Run an HTTP GET against the API, then print out the "uuid" attribute only +# +# Usage: +# +# bgetn path [options] +# +# path : an API path +# options : bscript options, see bubble.main.BubbleScriptOptions (and parent classes) for more info +# +# Environment variables +# +# BUBBLE_API : which API to use. Default is local (http://127.0.0.1:PORT, where PORT is found in .bubble.env) +# BUBBLE_USER : account to use. Default is root +# BUBBLE_PASS : password for account. Default is root +# BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from +# bubble repo, bubble-models repo, or bubble-client and use include files from minimal model. +# +SCRIPT="${0}" +SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd) +. ${SCRIPT_DIR}/bubble_common + +URL="${1:?no URL provided}" +shift + +JSON="$(BUBBLE_QUIET=1 ${SCRIPT_DIR}/bubble get -U ${URL} ${@})" +if [[ ${JSON} = \{* ]] ; then + echo "${JSON}" | jq -r .uuid +elif [[ "${JSON}" = \[* ]] ; then + echo "${JSON}" | jq -r .[].uuid +else + echo "not sure what to do with JSON:" + echo "${JSON}" +fi