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.
 
 
 
 

49 regels
1.7 KiB

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