The IONode functions provide getters for the inputs and setters for the outputs of the module.
Import
There is no import line needed to use this library and its functions.
Input data structure
When processing workflow inputs, there are two structures you may encounter depending on the input type.
If the input is from a Tag node (green), it will be of the form:
{
"observed_at": "2015-04-11T21:36:53.832111+00:00",
"event_data": {
"value": 60
},
"tag_name": "raw.bpm"
}
If the input is from another Python Module, it will be of the form:
{
"observed_at": "2015-04-11T21:36:53.832111+00:00",
"event_data": {
"action": "Help Request",
"sensor_id": "Kiosk_3",
"type": "Kiosk"
}
}
Get an input
IONode.get_input(name)
Retrieves the last value for this tag.
Note: If the trigger event does not contain this tag, the last value would be automatically retrieved from historic data.
Credit cost: 0
Parameters
- name:
str
name of input to retrieve
Return Value
dict
input data structure
Example
-
Sample Code:
# note: 'value' is the default name for any Tag input value myvariable = IONode.get_input('in1')['event_data']['value'] myvariable = myvariable * 2
Exceptions
None
Get all inputs
IONode.get_inputs()
Retrieves all of the inputs.
Credit cost: 0
Parameters
None
Return Value
list
all input data structures
Example
-
Sample Code:
inputs = IONode.get_inputs()
myvariable = inputs[0]["event_data"]["value"] myvariable = myvariable * 2
Exceptions
None
Get triggering event
IONode.get_event()
Retrieves the event data from the event that triggered the workflow.
Credit cost: 0
Parameters
None
Return Value
dict
event_data from event that triggered the workflow
Example
- Sample Code:
event = IONode.get_event()
- Return Value:
{ 'trigger': 'data', 'not_trigger': 'data'
}
Exceptions
None
Get triggering event ID
IONode.get_event_id()
Retrieves the event ID from the event that triggered the workflow.
Credit cost: 0
Parameters
None
Return Value
long
event ID from the event that triggered the workflow.
Example
-
Sample Code:
event_id = IONode.get_event_id()
- Return Value:
746741958693904384L
Exceptions
None
Get tag name of input
IONode.tag_name(name)
Retrieves the name of a tag node.
Credit cost: 0
Parameters
- name:
str
name of input from which to retrieve tag name, if it exists
Return Value
str
name of the tag, if the input is from a tag node. Otherwise returns None
Example
-
Sample Code:
tag_name = IONode.get_tag_name("in1")
- Return Value:
"raw.bpm"
Exceptions
None
Check if input triggered workflow
IONode.is_trigger(name)
Checks if an IONode is a trigger.
Note: This function will not return true if the IONode is a timer.
Credit cost: 0
Parameters
- name:
str
name of input to check
Return Value
bool
True
if the input is from a tag node and triggered this workflow. Otherwise False
Example
-
Sample Code:
triggered = IONode.is_trigger("in1")
- Return Value:
True
Exceptions
None
Triggering event timestamp
IONode.event_timestamp
The timestamp from the event that triggered the workflow.
Credit cost: 0
Value
str
ISO 8601 timestamp for the event that triggered the workflow
Example
-
Sample Code:
event = IONode.event_timestamp
- Value:
"2020-02-21T20:05:06.376Z"
Exceptions
None
Output one event
IONode.set_output(name, data, observed_at=None, user=None, event_id=None)
Sets the output data. This is used to output a single event.
This must be used with a "Processed Stream - Single" or "Update Event - Single" output node.
Credit cost: 0
Parameters
- name:
str
output name - data:
dict
output data - observed_at:
str
ISO 8601 time string. Time zone must be specified.- If not specified (or None), the observed_at of the IONode object will be set to the trigger event's observed_at.
- user:
str
user to output the new event to.- If not specified then event will output to the user that triggered the workflow.
- event_id:
long
ID of event to update if using "Update Event - Single" output node.
Return Value
None
Example
-
Sample Code:
IONode.set_output('out1', {"tag1": 1}, user="different_user")
Exceptions
- AssertionError
- Output data is not a dict
- Output value is None or not JSON-serializable
- observed_at is not None or a string
- user is not None or a string
- InvalidUserException
- A non-existent user was specified
Output multiple events
IONode.set_output_list(name, data, observed_at=None, user=None)
Sets the output data as a list. This is used to output multiple events. It is an alternative to using IONode.add_to_output_list.
This must be used with a "Processed Stream - Multiple" output node.
Credit cost: 0
Parameters
- name:
str
output name - data:
list
output data array of event objects - observed_at:
str
ISO 8601 time string. Time zone must be specified.- If not specified (or None), the observed_at of the IONode object will be set to the trigger event's observed_at.
- user:
str
user to output the new event to.- If not specified then event will output to the user that triggered the workflow.
Return Value
None
Example
-
Sample Code:
outputMsgList = [] outputMsgList.append({"tag1":10}) outputMsgList.append({"tag2":10}) outputMsgList.append({"tag3":10}) IONode.set_output_list('out1', outputMsgList)
Exceptions
- AssertionError
- Output data is not a dict
- Output value is None or not JSON-serializable
- observed_at is not None or a string
- user is not None or a string
- InvalidUserException
- A non-existent user was specified
Add event to output list
IONode.add_to_output_list(name, data, observed_at=None, user=None, event_id=None)
Add event to output data for a node. This is used to output multiple events. It is an alternative to using IONode.set_output_list.
This must be used with a "Processed Stream - Multiple" or "Update Event - Multiple" output node.
Credit cost: 0
Parameters
- name:
str
output name - data:
dict
output data - observed_at:
str
ISO 8601 time string. Time zone must be specified.- If not specified (or None), the observed_at of the IONode object will be set to the trigger event's observed_at.
- user:
str
user to output the new event to.- If not specified then event will output to the user that triggered the workflow.
- event_id:
long
ID of event to update if using "Update Event - Multiple" output node.
Return Value
None
Example
-
Sample Code:
IONode.add_to_output_list('out1', {"tag1":10}) IONode.add_to_output_list('out1', {"tag2":10}) IONode.add_to_output_list('out1', {"tag3":10})
Exceptions
- AssertionError
- Output data is not a dict
- Output value is None or not JSON-serializable
- observed_at is not None or a string
- user is not None or a string
- InvalidUserException
- A non-existent user was specified