-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added examples * updates and fixes * remove redundant scope * update example 1 * adding codeDepot markers --------- Co-authored-by: Paige Rossi <[email protected]>
- Loading branch information
1 parent
a1b98a1
commit 85deeee
Showing
22 changed files
with
1,290 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,3 +123,6 @@ private.key | |
# Current flask session | ||
|
||
flask_session/ | ||
|
||
# Workflow ID file | ||
WORKFLOW_ID.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .views import mseg001 | ||
from .views import mseg002 | ||
from .views import mseg003 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from docusign_maestro import WorkflowManagementApi, WorkflowTriggerApi, TriggerPayload | ||
from flask import session, request | ||
|
||
from app.docusign.utils import get_parameter_value_from_url | ||
from app.ds_config import DS_CONFIG | ||
from app.maestro.utils import create_maestro_api_client | ||
from app.consts import pattern | ||
|
||
|
||
class Eg001TriggerWorkflowController: | ||
@staticmethod | ||
def get_args(): | ||
"""Get request and session arguments""" | ||
return { | ||
"account_id": session["ds_account_id"], | ||
"base_path": DS_CONFIG["maestro_api_client_host"], | ||
"access_token": session["ds_access_token"], | ||
"workflow_id": session["workflow_id"], | ||
"instance_name": pattern.sub("", request.form.get("instance_name")), | ||
"signer_email": pattern.sub("", request.form.get("signer_email")), | ||
"signer_name": pattern.sub("", request.form.get("signer_name")), | ||
"cc_email": pattern.sub("", request.form.get("cc_email")), | ||
"cc_name": pattern.sub("", request.form.get("cc_name")), | ||
} | ||
|
||
@staticmethod | ||
def get_workflow_definitions(args): | ||
api_client = create_maestro_api_client(args["base_path"], args["access_token"]) | ||
workflow_management_api = WorkflowManagementApi(api_client) | ||
workflow_definitions = workflow_management_api.get_workflow_definitions(args["account_id"], status="active") | ||
|
||
return workflow_definitions | ||
|
||
@staticmethod | ||
def get_workflow_definition(args): | ||
#ds-snippet-start:Maestro1Step2 | ||
api_client = create_maestro_api_client(args["base_path"], args["access_token"]) | ||
#ds-snippet-end:Maestro1Step2 | ||
|
||
#ds-snippet-start:Maestro1Step3 | ||
workflow_management_api = WorkflowManagementApi(api_client) | ||
workflow_definition = workflow_management_api.get_workflow_definition(args["account_id"], args["workflow_id"]) | ||
#ds-snippet-end:Maestro1Step3 | ||
|
||
return workflow_definition | ||
|
||
@staticmethod | ||
def trigger_workflow(workflow, args): | ||
api_client = create_maestro_api_client(args["base_path"], args["access_token"]) | ||
|
||
#ds-snippet-start:Maestro1Step4 | ||
trigger_payload = TriggerPayload( | ||
instance_name=args["instance_name"], | ||
participant={}, | ||
payload={ | ||
"signerEmail": args["signer_email"], | ||
"signerName": args["signer_name"], | ||
"ccEmail": args["cc_email"], | ||
"ccName": args["cc_name"] | ||
}, | ||
metadata={} | ||
) | ||
mtid = get_parameter_value_from_url(workflow.trigger_url, "mtid") | ||
mtsec = get_parameter_value_from_url(workflow.trigger_url, "mtsec") | ||
#ds-snippet-end:Maestro1Step4 | ||
|
||
#ds-snippet-start:Maestro1Step5 | ||
workflow_trigger_api = WorkflowTriggerApi(api_client) | ||
trigger_response = workflow_trigger_api.trigger_workflow( | ||
args["account_id"], | ||
trigger_payload, | ||
mtid=mtid, mtsec=mtsec | ||
) | ||
#ds-snippet-end:Maestro1Step5 | ||
return trigger_response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from docusign_maestro import WorkflowInstanceManagementApi | ||
from flask import session | ||
|
||
from app.ds_config import DS_CONFIG | ||
from app.maestro.utils import create_maestro_api_client | ||
|
||
|
||
class Eg002CancelWorkflowController: | ||
@staticmethod | ||
def get_args(): | ||
"""Get request and session arguments""" | ||
return { | ||
"account_id": session["ds_account_id"], | ||
"base_path": DS_CONFIG["maestro_api_client_host"], | ||
"access_token": session["ds_access_token"], | ||
"workflow_id": session["workflow_id"], | ||
"instance_id": session["instance_id"] | ||
} | ||
|
||
@staticmethod | ||
def get_instance_state(args): | ||
api_client = create_maestro_api_client(args["base_path"], args["access_token"]) | ||
workflow_instance_management_api = WorkflowInstanceManagementApi(api_client) | ||
instance = workflow_instance_management_api.get_workflow_instance( | ||
args["account_id"], | ||
args["workflow_id"], | ||
args["instance_id"] | ||
) | ||
|
||
return instance.instance_state | ||
|
||
@staticmethod | ||
def cancel_workflow_instance(args): | ||
#ds-snippet-start:Maestro2Step2 | ||
api_client = create_maestro_api_client(args["base_path"], args["access_token"]) | ||
#ds-snippet-end:Maestro2Step2 | ||
|
||
#ds-snippet-start:Maestro2Step3 | ||
workflow_instance_management_api = WorkflowInstanceManagementApi(api_client) | ||
cancel_result = workflow_instance_management_api.cancel_workflow_instance( | ||
args["account_id"], | ||
args["instance_id"] | ||
) | ||
#ds-snippet-end:Maestro2Step3 | ||
return cancel_result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from docusign_maestro import WorkflowInstanceManagementApi | ||
from flask import session | ||
|
||
from app.ds_config import DS_CONFIG | ||
from app.maestro.utils import create_maestro_api_client | ||
|
||
|
||
class Eg003GetWorkflowStatusController: | ||
@staticmethod | ||
def get_args(): | ||
"""Get request and session arguments""" | ||
return { | ||
"account_id": session["ds_account_id"], | ||
"base_path": DS_CONFIG["maestro_api_client_host"], | ||
"access_token": session["ds_access_token"], | ||
"workflow_id": session["workflow_id"], | ||
"instance_id": session["instance_id"] | ||
} | ||
|
||
@staticmethod | ||
def get_workflow_instance(args): | ||
#ds-snippet-start:Maestro3Step2 | ||
api_client = create_maestro_api_client(args["base_path"], args["access_token"]) | ||
#ds-snippet-end:Maestro3Step2 | ||
|
||
#ds-snippet-start:Maestro3Step3 | ||
workflow_instance_management_api = WorkflowInstanceManagementApi(api_client) | ||
instance = workflow_instance_management_api.get_workflow_instance( | ||
args["account_id"], | ||
args["workflow_id"], | ||
args["instance_id"] | ||
) | ||
#ds-snippet-end:Maestro3Step3 | ||
|
||
return instance |
Oops, something went wrong.