View Source Runbox.Scenario.Manifest behaviour (runbox v10.0.0)

Behaviour and struct for scenario manifest.

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

t()

Callbacks

Invoked to obtain the scenario manifest.

Invoked once when the scenario run starts.

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.
Link to this type

notification_metadata()

View Source
@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: term(),
  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
}

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.