Skip to content

Commit 0d2d340

Browse files
add example 2
1 parent c3fbd13 commit 0d2d340

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
# Pause a running workflow instance
3+
#
4+
# Check that we're in a bash shell
5+
if [[ $SHELL != *"bash"* ]]; then
6+
echo "PROBLEM: Run these scripts from within the bash shell."
7+
fi
8+
9+
# Check that there is a workflow
10+
workflow_id=$(cat config/WORKFLOW_ID)
11+
if [ -z "$workflow_id" ]; then
12+
echo "Please run example 1 to create and trigger a worklow before running this example."
13+
exit 0
14+
fi
15+
16+
# Obtain your OAuth token
17+
# Note: Substitute these values with your own
18+
ACCESS_TOKEN=$(cat config/ds_access_token.txt)
19+
20+
21+
# Set up variables for full code example
22+
# Note: Substitute these values with your own
23+
ACCOUNT_ID=$(cat config/API_ACCOUNT_ID)
24+
25+
base_path="https://api-d.docusign.com/v1"
26+
27+
# Construct your API headers
28+
#ds-snippet-start:Maestro2Step2
29+
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}" \
30+
'--header' "Accept: application/json" \
31+
'--header' "Content-Type: application/json")
32+
#ds-snippet-end:Maestro2Step2
33+
echo ""
34+
echo "Attempting to pause the Workflow.."
35+
echo ""
36+
37+
#ds-snippet-start:Maestro2Step3
38+
response=$(mktemp /tmp/response-wftmp.XXXXXX)
39+
Status=$(
40+
curl -w '%{http_code}' --request POST "${base_path}/accounts/${ACCOUNT_ID}/workflows/${workflow_id}/actions/pause" \
41+
"${Headers[@]}" \
42+
--output ${response}
43+
)
44+
# If the status code returned is greater than 201 (OK / Accepted), display an error message with the API response.
45+
if [[ "$Status" -gt "201" ]]; then
46+
echo ""
47+
echo "Unable to retrieve workflow instance: ${WORKFLOW_INSTANCE_ID}"
48+
echo ""
49+
cat $response
50+
exit 0
51+
fi
52+
53+
echo ""
54+
echo "Workflow has been paused."
55+
echo ""
56+
echo ""
57+
echo "Response:"
58+
cat $response
59+
echo ""
60+
echo ""
61+
#ds-snippet-end:Maestro2Step3
62+
63+
# Remove the temporary files
64+
rm "$response"

launcher.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ function startMaestro() {
968968
PS3='Select the action : '
969969
select CHOICE in \
970970
"Trigger_Workflow" \
971+
"Pause_Workflow" \
971972
"Cancel_Workflow" \
972973
"Home"; do
973974
case "$CHOICE" in
@@ -979,6 +980,10 @@ function startMaestro() {
979980
bash examples/Maestro/eg001TriggerWorkflow.sh
980981
startMaestro
981982
;;
983+
Pause_Workflow)
984+
bash examples/Maestro/eg002PauseWorkflow.sh
985+
startMaestro
986+
;;
982987
Cancel_Workflow)
983988
bash examples/Maestro/eg004CancelWorkflow.sh
984989
startMaestro

0 commit comments

Comments
 (0)