update_workflow_stages

imerit_ango.sdk.SDK.

update_workflow_stages(project_id, stages)

Update the workflow of your project.

Parameters

  • project_id: string

  • stages: List[dict]

    • The workflow of the project, in JSON format.

    • Stage types and their required fields:

Start Stage
  • "id": "Start"

  • "type": "Start"

  • "name": "Start"

  • "position": {"x": 10, "y": 20}

  • "next": ["<NEXT STAGE ID>"]

  • "autoForward": true or false

Complete Stage
  • "id": "Complete"

  • "type": "Complete"

  • "name": "Complete"

  • "position": {"x": 10, "y": 20}

Label Stage
  • "id": "<STAGE ID>"

  • "type": "Label"

  • "name": "Label"

  • "position": {"x": 10, "y": 20}

  • "next": ["<NEXT STAGE ID>"]

  • "assignedTo": ["user_1@imerit.net", "user_2@imerit.net"]

Consensus Stage
  • "id": "<CONSENSUS STAGE ID>"

  • "type": "Consensus"

  • "name": "Consensus"

  • "position": {"x": 10, "y": 20}

  • "next": ["<NEXT STAGE ID AGREEMENT>", "<NEXT STAGE ID DISAGREEMENT>"]

Two types of stages, “Label” and “Plugin”, can be added to a consensus stage. They should adhere to the following format:

Label Stage:

  • "id": "<STAGE ID>"

  • "type": "Label"

  • "name": "Consensus_1"

  • "position": {"x": 0, "y": 0}

  • "next": ["<CONSENSUS STAGE ID>"]

  • "assignedTo": ["user_1@imerit.net", "user_2@imerit.net"]

  • "consensusId": "<CONSENSUS STAGE ID>"

Plugin Stage:

  • "id": "<STAGE ID>"

  • "type": "Plugin"

  • "name": "Consensus_2"

  • "position": {"x": 0, "y": 0}

  • "next": ["<CONSENSUS STAGE ID>"]

  • "pluginId": "<PLUGIN ID>"

  • "consensusId": "<CONSENSUS STAGE ID>"

Review Stage
  • "id": "<STAGE ID>"

  • "type": "Review"

  • "name": "Review"

  • "position": {"x": 10, "y": 20}

  • "next": ["<NEXT STAGE ID ACCEPTED>", "<NEXT STAGE ID REJECTED>"]

  • "assignedTo": ["user_1@imerit.net", "user_2@imerit.net"]

  • "readOnly": true or false

Hold Stage
  • "id": "<STAGE ID>"

  • "type": "Hold"

  • "name": "Hold"

  • "position": {"x": 10, "y": 20}

  • "next": ["<NEXT STAGE ID>"]

Logic Stage
  • "id": "<STAGE ID>"

  • "type": "Logic"

  • "name": "Logic"

  • "position": {"x": 10, "y": 20}

  • "next": ["<NEXT STAGE ID IF CONDITION>", "<NEXT STAGE ID ELSE CONDITION>"]

  • "logic": {"conditions": ["index": 0, "type": "RandomSample", "value": 0.100"]}

  • "logic": -- other conditions: TODO

Plugin Stage
  • "id": "<STAGE ID>"

  • "type": "Plugin"

  • "name": "Plugin"

  • "position": {"x": 10, "y": 20}

  • "next": ["<NEXT STAGE ID>"]

  • "pluginId": "<PLUGIN ID>"

Webhook Stage
  • "id": "<STAGE ID>"

  • "type": "Webhook"

  • "name": "Webhook"

  • "position": {"x": 10, "y": 20}

  • "next": ["<NEXT STAGE ID>"]

  • "webhook": {"secret": "<SECRET>", "url": "<URL>"}

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

Example

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}}

stages = [start_stage, label_stage, review_stage, complete_stage]

sdk_response = ango_sdk.update_workflow_stages(project_id, stages)

See also

get_project

Last updated