update_workflow_stages
imerit_ango.sdk.SDK.
update_workflow_stages(project_id, stages)
Update the workflow of your project.
Parameters
project_id: string
The unique identifier for the project. You can find the project ID in the user interface or retrieve it using the
list_projects
function.
stages: List[dict]
The workflow of the project, in JSON format.
Stage types and their required fields:
Note: To get an idea of what you can pass as input in Stages, you may create a workflow in a project, then run:
ango_sdk.get_project(<PROJECT ID>).get("data").get("project").get("stages")
As the returned JSON, you'll get the JSON representation of the project's workflow, which you can use as a skeleton to create your own workflow JSONs.
Returns:
output: dict
A dictionary containing the result of the operation.
Example
Create a workflow from scratch
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')
ango_sdk = SDK(api_key)
start_stage = {"id": "Start",
"type": "Start",
"name": "Start",
"next": ["Label"],
"autoForward": False,
"position": {"x": 0, "y": 0}}
label_stage = {"id": "Label",
"type": "Label",
"name": "Label",
"next": ["Review"],
"assignedTo": [],
"position": {"x": 400, "y": 0}}
review_stage = {"id": "Review",
"type": "Review",
"name": "Review",
"next": ["Complete", "Label"],
"assignedTo": [],
"position": {"x": 800, "y": 0}}
complete_stage = {"id": "Complete",
"type": "Complete",
"name": "Complete",
"next": [],
"position": {"x": 1200, "y": 0},
"preventRequeue": False}
stages = [start_stage, label_stage, review_stage, complete_stage]
sdk_response = ango_sdk.update_workflow_stages(project_id=project_id, stages=stages)
Disable the "Auto Forward on Upload" option on the Start stage
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')
ango_sdk = SDK(api_key)
stages = ango_sdk.get_project(project_id=project_id).get("data").get("project").get("stages")
new_stages = []
for stage in stages:
new_stage = stage.copy()
if stage["id"] == "Start":
new_stage["autoForward"] = False
new_stages.append(new_stage)
sdk_response = ango_sdk.update_workflow_stages(project_id=project_id, stages=new_stages)
Prevent requeueing to Complete stage
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')
ango_sdk = SDK(api_key)
stages = ango_sdk.get_project(project_id=project_id).get("data").get("project").get("stages")
new_stages = []
for stage in stages:
new_stage = stage.copy()
if stage["id"] == "Complete":
new_stage["preventRequeue"] = True
new_stages.append(new_stage)
sdk_response = ango_sdk.update_workflow_stages(project_id=project_id, stages=new_stages)
Last updated