Toolbox.Scenario.OutputAction (toolbox v1.1.0)
Struct representing side effects produced by run. There are several constructor functions to simplify and standardize side effect definition.
Instances of this struct are being parsed and then passed to output server.
Link to this section Summary
Functions
Constructor for calling SQL query.
Constructor for create new asset side effect.
Constructor for create edge between assets side effect.
Constructor for delete asset side effect.
Constructor for event side effect.
Constructor for new incident (add_asset) action
Constructor for notification side effect.
Constructor for update existing asset side effect.
Constructor for upsert asset side effect.
Constructor for upsert edge between assets side effect.
Link to this section Types
@type t() :: %Toolbox.Scenario.OutputAction{ body: map() | Toolbox.Scenario.OutputAction.Asset.t() | Toolbox.Scenario.OutputAction.Edge.t() | Toolbox.Scenario.OutputAction.AssetPatch.t(), svector: [any()], timestamp: integer(), type: type() }
type()
@type type() ::
:notify
| :create_event
| :add_asset
| :edit_asset
| :upsert_asset
| :delete_asset
| :add_edge
| :upsert_edge
| :delete_edge
| :execute_sql
| :bad_output_action
Link to this section Functions
body(output_action)
execute_sql_action(timestamp, params)
@spec execute_sql_action(non_neg_integer(), map()) :: t()
Constructor for calling SQL query.
First argument is unix timestamp
and second is body
, which is map with 4 required keys:
db_connection
, sql_query
, data
and type
.
db_connection
- map with database connection info (hostname
,username
,password
,database
)sql_query
- SQL query.data
- list of parameterized data.type
- database type, right now only PostgreSQL is supported. It's checked inOutputProcessor
and the value must be:postgresql
.
If :run_id
is present in data
, it's replaced with actual run_id in AssetMap.Api.SqlExecutor
.
new(type, body)
new_create_asset_action(id, timestamp, attributes)
@spec new_create_asset_action(binary(), non_neg_integer(), map()) :: t()
Constructor for create new asset side effect.
new_create_edge_action(id, timestamp, from_id, to_id, type)
Constructor for create edge between assets side effect.
new_delete_asset_action(id, timestamp)
@spec new_delete_asset_action(binary(), non_neg_integer()) :: t()
Constructor for delete asset side effect.
new_delete_edge_action(id, timestamp, from_id, to_id, type)
new_event_action(timestamp, params)
@spec new_event_action(non_neg_integer(), map()) :: t()
Constructor for event side effect.
First argument is unix timestamp
and second is body
, which is map with 3 required keys:
actors
, type
and template
.
actors
- map of actors which are interpolated in the template.params
- map of template params that are interpolated in the template.origin_messages
- list of raw messages linked with the event itself.template
- event's template. SeeAssetMap.Events.Template
.type
- type of the event. It's declared in Scenario's Manifest.
new_incident_action(id, attributes)
@spec new_incident_action(binary(), Toolbox.Scenario.OutputAction.Incident.t()) :: t()
Constructor for new incident (add_asset) action
new_notification_action(timestamp, params)
@spec new_notification_action(timestamp :: non_neg_integer(), params :: map()) :: t()
Constructor for notification side effect.
Params describe the notification to be created. It has the following keys
:type
- string, type of the notification:data
- map, data for the template evaluation:primary_asset
- string, optional, id of an asset that corresponds to this notification:ids
- list of asset ids, optional, to filter recipients, each recipient must have sufficient privileges to see all listed IDs:aqls
- map, AQLs which are evaluated, provide further context to the templates, and also can serve the same purpose asids
- filter recipients to only those who can see the whole result of the query. Key is the name of the AQL which can be used in the template. Value is a map withaql
(the AQL query) andprimary
(whether the AQL should also be used to filter recipients) keys.:priority
- optional, defaults to:medium
, can be:low
,:medium
,:high
, only applicable to some channels:metadata
- map, optional, additional metadata which can be used in notification group subscriptions. Should adhere to the format specified innotification/spec.exs
.:direct_subscriptions
- list of maps, subscriptions to be used additionally to the usual routing. Each map should have the following.:user
- map, user object to be used instead of Altworx object, should havenotification.email
and optionally evennotification.language
.:templates
- list of ids, which templates should be used:channels
- list of ids, which channels should be used
:attachments
- list of maps, optional, attachments that should be sent with the notification. Each map has the following keys.data
- binary, content of the attachmentfilename
- string, name of the filecontent_type
- string, optional, MIME type of the datatype
- whether the attachment is to inlined in the template (:inline
) or not (:attachment
, this is the default)
new_update_asset_action(id, timestamp, update, delete \\ nil)
@spec new_update_asset_action(binary(), non_neg_integer(), map() | nil, map() | nil) :: t()
Constructor for update existing asset side effect.
new_upsert_asset_action(id, timestamp, attributes)
@spec new_upsert_asset_action(binary(), non_neg_integer(), map()) :: t()
Constructor for upsert asset side effect.
new_upsert_edge_action(id, timestamp, from_id, to_id, type)
Constructor for upsert edge between assets side effect.