sym.sdk.event.Event

class sym.sdk.event.Event(srn: Union[sym.sdk.resource.SRN, str])

Bases: sym.sdk.resource.SymResource

The Event class contains information on an event which has been received by Sym, routed to a Run of a Flow, and is triggering specific user-defined Handlers.

Each Handler will be invoked with a single argument, which is an instance of this class. This Event instance will describe the current execution state, and can be used to dynamically alter the behavior and control flow of Templates.

Read more about Handlers.

Methods

dict()

Represent this resource as a dictionary.

get_actor(event_name)

Retrieve the User who triggered a specific Event.

get_context(event_name)

Retrieve a dict containing the context values attached to a specific Event.

Attributes

channel

A Channel object indicating the channel the current Event instance is coming from.

flow

A Flow object, indicating the Flow that the current Run is an instance of.

meta

An EventMeta object, which contains metadata about the Event instance.

name

The name of the Event.

payload

A Payload object, which contains the primary data of the Event.

run

A Run object, indicating the current Run.

srn

A SRN object that represents the unique identifier for this resource.

template

A Template object, indicating which Template the current Flow inherits from.

user

The User who triggered the Event.

property channel

A Channel object indicating the channel the current Event instance is coming from.

dict()

Represent this resource as a dictionary.

property flow

A Flow object, indicating the Flow that the current Run is an instance of.

get_actor(event_name: str) Optional[sym.sdk.user.User]

Retrieve the User who triggered a specific Event.

For example, for a Run using the ApprovalTemplate, to get the approver:

approver = event.get_actor("approve")

For a list of event names, see the relevant template’s Enum (e.g. ApprovalTemplateStep).

Note that, for the ApprovalTemplate, the escalate and deescalate actors will be the same as the approve actor, because those events are automatically triggered by the approve event.

Parameters

event_name (str) – The name of the Event to retrieve the actor for.

Returns

The User who triggered the Event with the given event_name, if that Event has occurred in the current Run. Otherwise returns None.

get_context(event_name: str) Optional[Dict[str, Any]]

Retrieve a dict containing the context values attached to a specific Event.

For example, for a Run using the ApprovalTemplate, to get the context attached to the initial request Event:

context = event.get_context("request")

For a list of event names, see the relevant template’s Enum (e.g. ApprovalTemplateStep).

Parameters

event_name (str) – The name of the Event to retrieve the actor for.

Returns

A dict representing the context attached to the Event with the given event_name, if that Event has occurred in the current Run. Otherwise returns None.

property meta

An EventMeta object, which contains metadata about the Event instance.

property name

The name of the Event.

property payload

A Payload object, which contains the primary data of the Event.

property run

A Run object, indicating the current Run.

property srn

A SRN object that represents the unique identifier for this resource.

property template

A Template object, indicating which Template the current Flow inherits from.

property user

The User who triggered the Event.