The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
1.1 KiB

  1. #!/bin/bash
  2. #
  3. # Run an HTTP GET against the API, then print out the "name" attribute only, and only the first one
  4. #
  5. # Usage:
  6. #
  7. # bgetn1 path [options]
  8. #
  9. # path : an API path
  10. # options : bscript options, see bubble.main.BubbleScriptOptions (and parent classes) for more info
  11. #
  12. # Environment variables
  13. #
  14. # BUBBLE_API : which API to use. Default is local (http://127.0.0.1:PORT, where PORT is found in .bubble.env)
  15. # BUBBLE_USER : account to use. Default is root
  16. # BUBBLE_PASS : password for account. Default is root
  17. # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from
  18. # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model.
  19. #
  20. SCRIPT="${0}"
  21. SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd)
  22. . ${SCRIPT_DIR}/bubble_common
  23. URL="${1:?no URL provided}"
  24. shift
  25. JSON="$(BUBBLE_QUIET=1 ${SCRIPT_DIR}/bubble get -U ${URL} ${@})"
  26. if [[ ${JSON} = \{* ]] ; then
  27. echo "${JSON}" | jq -r .name
  28. elif [[ "${JSON}" = \[* ]] ; then
  29. echo "${JSON}" | jq -r .[].name | head -1
  30. else
  31. echo "not sure what to do with JSON:"
  32. echo "${JSON}"
  33. fi