1.3.1 Changing the agent of an activity corresponding to a specific step in My Workflow
(1) Obtaining a list of practice-contexts
Obtain the running practice-context using the Execution ID of My Workflow retrieved at <% ctx().st2.action_execution_id %>*. An example of API execution is shown below.
<Example> /api/v1/practice-contexts
# curl -XGET "Ops I URL/api/v1/practice-contexts?filterBy=executionId%3Aeq%3AMy Workflow Execution ID" ¥
-H "X-OpsI-Token: Ops I token"
*For more information, please refer to the official StackStorm page.
https://docs.stackstorm.com/3.7/orquesta/stackstorm.html#stackstorm-context
(2) Obtaining detailed My Workflow information
Use the practice-context ID to get My Workflow details and the schedule id. An example of API execution is shown below.
<Example> api/v1/practice-contexts/{id}
# curl -XGET "Ops I URL/api/v1/practice-contexts/practice-context id" ¥
-H "X-OpsI-Token: Ops I token"
(3) Obtaining schedule information
Use the ID of the schedule to get detailed information about the schedule. An example of API execution is shown below.
This is a schedule tied to my Workflow, called the Parent Activity.
Since the detailed information also includes child schedules corresponding to the activities of each step, we obtain the child schedule that corresponds to the step for which we want to change the agent.
<Example> /api/v1/schedules/{id}
# curl -XGET "Ops I URL/api/v1/schedules/schedule id" ¥
-H "X-OpsI-Token: Ops I token"
(4) Change the agent of My Workflow from the information in the schedule
Change the agent of the activity by setting the user ID in the Agent field of the schedule to be changed. An example of API execution is shown below.
<Example> api/v1/schedules/{id}
# curl -XPUT "Ops I URL/api/v1/schedules/ID of the schedule object to be updated" ¥
-H "X-OpsI-Token: Ops I token" ¥
-H "Content-Type: application/json" -d @sample.json