mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-03-01 09:30:46 +00:00
added script to demonstrate how to use message start events w/ burnettk
This commit is contained in:
parent
868f2b312c
commit
90abf11d35
43
spiffworkflow-backend/bin/run_message_start_event_with_api
Executable file
43
spiffworkflow-backend/bin/run_message_start_event_with_api
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function error_handler() {
|
||||||
|
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
|
||||||
|
exit "$2"
|
||||||
|
}
|
||||||
|
trap 'error_handler ${LINENO} $?' ERR
|
||||||
|
set -o errtrace -o errexit -o nounset -o pipefail
|
||||||
|
|
||||||
|
script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||||
|
|
||||||
|
if [[ -z "${KEYCLOAK_BASE_URL:-}" ]]; then
|
||||||
|
# export KEYCLOAK_BASE_URL=https://keycloak.dev.spiffworkflow.org
|
||||||
|
export KEYCLOAK_BASE_URL=http://localhost:7002
|
||||||
|
fi
|
||||||
|
if [[ -z "${BACKEND_BASE_URL:-}" ]]; then
|
||||||
|
# export BACKEND_BASE_URL=https://api.dev.spiffworkflow.org
|
||||||
|
export BACKEND_BASE_URL=http://localhost:7000
|
||||||
|
fi
|
||||||
|
|
||||||
|
message_identifier="${1:-start_test}"
|
||||||
|
username="${2:-admin}"
|
||||||
|
password="${3:-admin}"
|
||||||
|
realm_name="${4:-spiffworkflow}"
|
||||||
|
if [[ -z "${message_identifier}" ]]; then
|
||||||
|
>&2 echo "usage: $(basename "$0") [message_identifier] [username: OPTONAL] [password: OPTONAL] [realm_name: OPTONAL]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
function check_result_for_error() {
|
||||||
|
local result="$1"
|
||||||
|
error_code=$(jq '.error_code' <<<"$result")
|
||||||
|
if [[ -n "$error_code" && "$error_code" != "null" ]]; then
|
||||||
|
>&2 echo "ERROR: Failed to run process instance. Received error: $result"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
access_token=$("${script_dir}/get_token" "$username" "$password" "$realm_name")
|
||||||
|
curl --silent -X POST "${BACKEND_BASE_URL}/v1.0/login_with_access_token?access_token=${access_token}" -H "Authorization: Bearer $access_token" >/dev/null
|
||||||
|
result=$(curl --silent -X POST "${BACKEND_BASE_URL}/v1.0/messages/${message_identifier}" -H "Authorization: Bearer $access_token" -d '{"payload": {"email": "HEY@example.com"}}' -H 'Content-type: application/json')
|
||||||
|
check_result_for_error "$result"
|
||||||
|
echo "$result"
|
@ -69,7 +69,6 @@ def message_send(
|
|||||||
message_name: str,
|
message_name: str,
|
||||||
body: Dict[str, Any],
|
body: Dict[str, Any],
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
"""Message_start."""
|
|
||||||
if "payload" not in body:
|
if "payload" not in body:
|
||||||
raise (
|
raise (
|
||||||
ApiError(
|
ApiError(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user