View Source Runbox.Scenario.Manifest behaviour (runbox v13.0.3)
Behaviour and struct for scenario manifest.
Manifest is the main module of a scenario, each scenario must have a single manifest module and
each manifest defines a scenario. Manifest module provides basic information/metadata about a
scenario. This is returned in a callback get_info/0
which returns the struct defined in this
module.
The struct contains the following information about a scenario:
id
- scenario identification.name
- name of the scenario, should be short.description
- more detailed description of the scenario, should be longer than name and more descriptiveversion
- scenario version, major versions are not compatible, so if you are upgrading to scenario with different major version all runs of the scenario will be stopped and must be recomputed manually.change_log
- information about changes made to the scenario, for users displayed e.g. in Admin UI.type
- type of the scenario, seeRunbox.Scenario.Type
for supported typesincidents
- incidents created by this scenario and some metadata for each incident type. Seet:Incident.t/0
for details.events
- events created by this scenario and some metadata for each event type.groups
- a list of groups this scenario can use and some metadata for each. Seegroup_of_assets/0
for details.required_raw_topics
- list of raw topics required by the scenario. These will be created automatically when the scenario is loaded.notifications
- metadata about notifications generated by this scenario. Seenotification_metadata/0
for details.
See t/0
for type details.
Summary
Types
Assets group attributes metadata.
Metadata (template) of assets group.
Notification specification metadata.
Notification type is an atom uniquely identifying the notification in the scenario
The struct contains information about a scenario.
Types
@type attribute_detail() :: %{ name: String.t(), description: String.t(), path: [String.t()], type: :string | :number }
Assets group attributes metadata.
Metadata helps the UI to render form for the group attributes definition. Attributes of the group are saved in asset attributes in Reality Network if group is materialized as asset in Reality Network.
Properties
:name
- user-friendly attribute name - what is set.:description
- longer attribute description - what the attribute does, the unit, ...:path
- path to attribute in attributes JSON.:type
- type of attribute value (helps the UI to render form input).
@type group_of_assets() :: %{ name: String.t(), description: String.t(), asset_type: String.t(), edge_type: String.t(), edge_direction: boolean(), attributes: [attribute_detail()] }
Metadata (template) of assets group.
The scenario should be able to carry a list of groups it uses. These groups can then be easily created in the UI by the user without having to fill in some information manually. Metadata defines these helpers for the UI.
Properties
:name
- short name of group template for UI.:description
- description of assets group.:asset_type
- asset type of asset created by the group.:edge_type
- edge type for connecting assets in the group.:edge_direction
- edge direction (true = from group asset to assets in group).:attributes
- description of group attributes.
@type notification_metadata() :: %{ name: String.t(), metadata_types: %{ required(type_name :: String.t()) => %{type: :string | :number | :boolean} } }
Notification specification metadata.
Properties
:name
- user-friendly name for the notification type:metadata_types
- describes metadata the notification caries, this information can be used for additional filtering in subscriptions. It can be empty map if no metadata is needed.type_name
- is a binary specifying the name of the notification metadata type:type
- type of notification metadata, can be either a:number
,:string
or:boolean
.
@type notification_type() :: atom()
Notification type is an atom uniquely identifying the notification in the scenario
@type t() :: %Runbox.Scenario.Manifest{ change_log: %{ required(unix_timestamp_in_ms :: non_neg_integer()) => description :: String.t() }, description: String.t(), events: %{ required(type :: String.t()) => %{name: String.t(), description: String.t()} }, groups: %{required(id :: String.t()) => group_of_assets()}, id: String.t(), incidents: %{ required(type :: String.t()) => Runbox.Scenario.Manifest.Incident.t() }, name: String.t(), notifications: %{required(notification_type()) => notification_metadata()}, required_raw_topics: [String.t()], topics: [String.t()], type: Runbox.Scenario.Type.t(), version: String.t() | nil }
The struct contains information about a scenario.
See module documentation for detailed description of the fields.
Callbacks
@callback get_info() :: t()
Invoked to obtain the scenario manifest.
@callback on_start() :: :ok | {:error, term()}
Invoked once when the scenario run starts.
Useful for doing any necessary preparations for scenario run.
Warning: Do not rely on any external resources (e.g. SQL queries) which may change the scenario logic.
This callback is optional. If it is not implemented, no action is performed when starting the scenario run.