Get Operation ID
SAYMON doesn’t have a specific request to get an Operation from an Object, Class, or a Link. Instead, entity’s operations are stored in the operations
field of that entity’s model. You can get this field using different methods.
To get operations of a particular entity, you can use the Get Entity by ID request. This request return the entity data that includes a list of operations in the operations
object. You can then pass the operations.id
field into the request that requires Operation ID (for example, Execute Entity Operation request that executes an operation by its ID).
You can also get operations of all entities in the system. Use the Get All Objects and Get All Links requests to get all respective entities in the system.
These requests don’t return
|
You can use Get All Root Entities to get both objects and links that are children of the root objects. This request returns an operations
field without any additional query parameters.
You can get a list of Class operations in a similar way. You can get operations for a single class with the Get Class by ID request, and operations for all classes in the system with the Get All Classes request. List of operations is stored in the operations
field.
Example
This example shows how to execute all operations in a specified entity.
Example uses the Get Entity by ID request to get the specified entity and then executes its operations with the Execute Entity Operation request.
import requests
import json
# Request settings
login = <...>
password = <...>
saymon_hostname = <...>
entity_id = <...>
# Get the specified entity
get_entity_url = "http://" + saymon_hostname + "/node/api/entities/" + entity_id
response = requests.request("GET", get_entity_url, auth=(login, password))
# Get a list of all entity's operations
entity = json.loads(response.text)
ops = entity['operations']
# Execute all operations of an entity
for operation in ops:
op_id = operation['id']
execute_op_url = "http://" + saymon_hostname + "/node/api/entities/" + entity_id + "/operations/" + op_id + "/execute"
response = requests.request("POST", execute_op_url, auth=(login, password))
print("Executed operation with id " + op_id + "; created job ID: " + response.text)