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 "
0 commit comments