Ok To Run¶
The OkToRun endpoint is used for checking if it is ok for the Mate to start work in the given Process.
Details¶
OkToRun is designed to be a lightweight and easy to use endpoint, for the Mate to quickly peek at the Process and see whether it should start working or not.
The endpoint returns a OkToRun object which looks like this:
{
"gateOpen" : true,
"tasksAvailable" : true,
"notBlockedDate" : true,
"okToRun" : true
}
OkToRun is the main boolean returned. Simply put, if it is true then the Mate should start working. In order to allow for most possible flexibility and transparancy, we have included 3 other booleans in the object. These three bools combined is how OkToRun is calculated.
TasksAvailable is true if there is any Tasks in the Ready queue. If Tasks are not enabled on the Process, or the queue is empty then TasksAvailable is false. If Tasks are not enabled on the Process then the boolean is still included in OkToRun but will not be taken in to account when calculating OkToRun.
GateOpen is true if the Process is not stopped and NotBlockedDate is true if the date is not blocked in the calendar. Click here to learn more about Stopping the Process.
If OkToRun is false, it is ofcourse possible to ignore it and have the Mate start up work regardless. In this case, TakeNext will behave as if the queue is empty and not return any Tasks. StartRun is not affected by OkToRun - Anymate is a flexible tool, and it is up to the Developer to decide in the given situation.
Example¶
The endpoint is found at https://{ClientId}.anymate.app/api/OkToRun/{ProcessKey} The http-request must be submitted as a GET with JSON encoded data.
curl --request GET \
--url https://{ClientId}.anymate.app/api/OkToRun/{ProcessKey} \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjgyQ0JGNDY3NEMyMUExRjBCMjhFNzlBNTk5MzAwQjdBIiwid.....'
Using the Anymate .NET SDK, you call the OkToRun
function in IAnymateService.
The default overload takes a ProcessKey as a parameter, and returns an AnymateOkToRun object.
using Anymate;
//Code omitted
//Created AnymateService object
var anymateService = new AnymateService(client_id, client_secret, username, password);
//Call OkToRun endpoint - the default endpoint returns an AnymateOkToRun object.
var okToRunResponse = anymateService.OkToRun(processKey);
//You can use the OkToRun attribute to check if the Mate should start working
if (!okToRunResponse.OkToRun)
{
//If its not ok to run, then return and do nothing
return;
}
//Code omitted
Using the Anymate Python SDK, simply invoke the 'OkToRun' function on the client class.
import anymate
# code omitted
# Initialize the client
client = anymate.client(client_id, api_secret, username, password)
# Check if the script should start work
is_ok_to_run = client.OkToRun(myProcessKey)
if not is_ok_to_run.okToRun:
# If there is nothing to do, then stop the script here
return
# Business logic not included. We assume that "new_tasks" is an array with objects ready for anymate.
OkToRun
takes a ProcessKey string as input.
The function returns a OkToRun object.
Using the Anymate UiPath SDK, simply invoke the Ok To Run
activity. Ok To Run
returns a single boolean, which is equal to the OkToRun boolean from the response object.