The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

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