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.
 
 
 
 

46 rivejä
1.5 KiB

  1. #!/bin/bash
  2. #
  3. # Run an HTTP POST against the API
  4. #
  5. # Usage:
  6. #
  7. # bpost path [file] [options]
  8. #
  9. # path : an API path
  10. # file : a JSON file to POST. To read from stdin, specify the file as -
  11. # options : bscript options, see bubble.main.BubbleScriptOptions (and parent classes) for more info
  12. #
  13. # Environment variables
  14. #
  15. # BUBBLE_ENTITY : the filename that contains the JSON to send in the POST. If empty, entity is read from stdin
  16. # BUBBLE_API : which API to use. Default is local (http://127.0.0.1:PORT, where PORT is found in .bubble.env)
  17. # BUBBLE_USER : account to use. Default is root
  18. # BUBBLE_PASS : password for account. Default is root
  19. # BUBBLE_INCLUDE : path to look for JSON include files. default value is to assume we are being run from
  20. # bubble repo, bubble-models repo, or bubble-client and use include files from minimal model.
  21. #
  22. SCRIPT="${0}"
  23. SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd)
  24. . ${SCRIPT_DIR}/bubble_common
  25. URL="${1:?no URL provided}"
  26. shift
  27. REQUEST_JSON="${1}"
  28. if [[ -z "${REQUEST_JSON}" ]] ; then
  29. die "No request JSON file specified. Use - to read from stdin"
  30. fi
  31. if [[ "${REQUEST_JSON}" == "-" ]] ; then
  32. echo 1>&2 "Reading request JSON from stdin"
  33. elif [[ ! -f "${REQUEST_JSON}" && "${REQUEST_JSON}" != /dev/null ]] ; then
  34. die "Request JSON file does not exist: ${REQUEST_JSON}"
  35. fi
  36. shift
  37. if [[ "${REQUEST_JSON}" == "-" ]] ; then
  38. exec ${SCRIPT_DIR}/bubble post -U ${URL} ${@}
  39. else
  40. cat ${REQUEST_JSON} | exec ${SCRIPT_DIR}/bubble post -U ${URL} ${@}
  41. fi