In order to use this library, you need to have an Anymate account. Please visit anymate.io for more information.
Anymate Python SDK is written in Python 3.
The SDK is available as open source and can be found on our github page.
You can find the documentation for the SDK as part of the Anymate Developer docs.
We have also published it at pypi.org. Installing the Anymate package is done with the following command:
pip install --upgrade anymate
Once installed, you just need to import anymate in your python program and you are ready to go
import anymate
After anymate has been imported, you have to initialize the client to communicate with Anymate.
The functions exposed in the client mirror the endpoints available in the API. We recommend going to the individual pages to learn more.
The SDK is built to automatically take care of authentication with Anymate as well as refreshing access_tokens as needed. Once the anymate.client is initialized, you don't have to worry about it.
You can see an example of a simple automation based on the Allocator Pattern below, where the automation script is working in one process and creating new tasks in another.
import anymate
client_id = "My client id"
client_secret = "My API secret"
username = "Mate Username"
password = "Mate Password"
myProcessKey = "myProcessKey"
targetProcessKey = "targetProcessKey"
client = anymate.client(client_id, client_secret, username, password)
is_ok_to_run = client.OkToRun(myProcessKey)
if not is_ok_to_run.okToRun:
return
run = client.start_or_get_run(myProcessKey)
for task in new_tasks:
client.create_task(targetProcessKey, task)
client.finish_run(dict(runId=run.runId))
Making a script to take Tasks from the Queue and perform work on them is equally simple.
import anymate
client_id = "My client id"
client_secret = "My API secret"
username = "Mate Username"
password = "Mate Password"
myProcessKey = "myProcessKey"
client = anymate.client(client_id, client_secret, username, password)
is_ok_to_run = client.OkToRun(myProcessKey)
if not is_ok_to_run.okToRun:
return
task = client.take_next(myProcessKey)
while task['taskId'] > 0:
task_is_solved = PerformBusinessLogic(task)
if task_is_solved:
solved_result = client.solved(dict(taskId=task['taskId'], reason='Solved', comment = 'Task was solved'))
else:
manual_result = client.manual(dict(taskId=task['taskId'], reason='Manual', comment='Task was sent to Manual'))
task = client.take_next(myProcessKey)
Enterprise On-Premises
The anymate SDK supports customers who have Anymate installed On-Premises with an Enterprise license out of the box.
In order to let anymate know you are running on a on-premises license, simply initialize the client with On Premises mode enabled.
import anymate
client_id = "My client id"
client_secret = "My API secret"
username = "Mate Username"
password = "Mate Password"
client = anymate.client(client_id, client_secret, username, password)
client_base_uri = "http://localanymate
auth_base_uri = "http://localanymateauth
client.set_on_premises_mode(client_base_uri, auth_base_uri)