Synsation Demo
This story consists of 2 files one containing the definition of assets and locations and one containing a template file from which the eventual story is generated using the Jinja2 templating engine.
---
locations:
- display_name: Cape Town
description: South Africa Office
latitude: -33.92527778
longitude: 18.42388889
attributes:
address: Cape Town Downtown
facility_type: Satellite Office
reception_email: reception_CT@synsation_io
reception_phone: +27 (21) 123-456
- display_name: Asia Regional Sales Office
description: Asia Regional Sales Headquarters
latitude: 18.52027778
longitude: 73.85666667
attributes:
address: "212, Late Govind Rambhau Taru Chowk Road, Shobhapur, Pune 411011"
facility_type: Sales
reception_email: reception_PN@synsation_io
reception_phone: +91 (20) 123-4567
- display_name: Baltimore Regional Sales Office
description: East Coast Regional Sales Headquarters
latitude: 39.28333333
longitude: -76.61666667
attributes:
address: Baltimore 21201, Maryland
facility_type: Sales
reception_email: reception_BLT@synsation_io
reception_phone: +1 (410) 123-4567
- display_name: European Regional Sales Office
description: European Regional Sales Headquarters
latitude: 52.20527778
longitude: 0.11916667
attributes:
address: Cambridge CB1 1BH, England
facility_type: Sales
reception_email: reception_CAM@synsation_io
reception_phone: +44 (1223) 123-456
- display_name: Grayslake HQ
description: Global Headquarters
latitude: 42.34833333
longitude: -88.03250000
attributes:
address: Grayslake 60030, Illinois
facility_type: Headquarters
reception_email: reception_GL@synsation_io
reception_phone: +1 (847) 765-4321
assets:
- asset_label: Multifunction Printer Cape Town
location_label: Cape Town
type: printer
firmware_version: v1.0
serial_number: f867662g.1
filename: multifunction_printer.jpg
- asset_label: Coffee Machine Asia
location_label: Asia Regional Sales Office
type: coffee machine
firmware_version: v1.0
serial_number: f867662g.1
filename: coffee_machine.jpg
- asset_label: Security Camera Baltimore
location_label: Baltimore Regional Sales Office
type: security camera
firmware_version: v1.0
serial_number: f867662g.1
filename: black_cctv.jpg
- asset_label: Multifunction Printer England
location_label: European Regional Sales Office
type: printer
firmware_version: v1.0
serial_number: f867662g.1
filename: multifunction_printer.jpg
---
# The step field is a string that represents the method bound to an endpoint.
#
# Create a number of offices equipped with LOGGER.debugers, coffee machines and security
# cameras
#
steps:
# create locations for all offices - these are created separately as more than one asset
# can be located at an office and we dont want to duplicate code...
# refer to the locations using the location_label...
{% for location in locations %}
- step:
action: LOCATIONS_CREATE_IF_NOT_EXISTS
description: Create {{ location.display_name }} Location
location_label: {{ location.display_name }}
selector:
- display_name
- attributes:
- namespace
display_name: {{ location.display_name }}
description: {{ location.description }}
latitude: {{ location.latitude }}
longitude: {{ location.longitude }}
attributes:
namespace: "{{ env['DATATRAILS_UNIQUE_ID'] or 'namespace' }}"
address: {{ location.attributes.address }}
facility_type: {{ location.attributes.facility_type }}
reception_email: {{ location.attributes.reception_email }}
reception_phone: {{ location.attributes.reception_phone }}
{% endfor %}
- step:
action: LOCATIONS_COUNT
description: Count locations in namespace
LOGGER.debug_response: true
attrs:
namespace: "{{ env['DATATRAILS_UNIQUE_ID'] or 'namespace' }}"
- step:
action: LOCATIONS_LIST
description: List locations in namespace
LOGGER.debug_response: true
attrs:
namespace: "{{ env['DATATRAILS_UNIQUE_ID'] or 'namespace' }}"
{% for asset in assets %}
- step:
action: ASSETS_CREATE_IF_NOT_EXISTS
description: Create a {{ asset.type }} in {{ asset.location_label }}
asset_label: {{ asset.asset_label }}
location_label: {{ asset.location_label }}
selector:
- attributes:
- arc_display_name
- arc_namespace
behaviours:
- RecordEvidence
attributes:
arc_display_name: {{ asset.type }} in {{ asset.location_label }}
arc_namespace: "{{ env['DATATRAILS_UNIQUE_ID'] or 'namespace' }}"
arc_display_type: {{ asset.type }}
arc_firmware_version: {{ asset.firmware_version }}
arc_serial_number: {{ asset.serial_number }}
arc_description: {{ asset.type }} in {{ asset.location_label }}
attachments:
- filename: functests/test_resources/synsation/assets/{{ asset.filename }}
content_type: image/jpg
display_name: {{ asset.type }} in {{ asset.location_label }}
{% endfor %}
# ensure all are confirmed
- step:
action: ASSETS_WAIT_FOR_CONFIRMED
description: Wait for all assets to be confirmed
LOGGER.debug_response: true
attrs:
arc_namespace: "{{ env['DATATRAILS_UNIQUE_ID'] or 'namespace' }}"
- step:
action: ASSETS_LIST
description: List all LOGGER.debugers
LOGGER.debug_response: true
attrs:
arc_display_type: LOGGER.debuger
arc_namespace: "{{ env['DATATRAILS_UNIQUE_ID'] or 'namespace' }}"
- step:
action: ASSETS_LIST
description: List all coffee machines
LOGGER.debug_response: true
attrs:
arc_display_type: coffee machine
arc_namespace: "{{ env['DATATRAILS_UNIQUE_ID'] or 'namespace' }}"
- step:
action: ASSETS_LIST
description: List all security cameras
LOGGER.debug_response: true
attrs:
arc_display_type: security camera
arc_namespace: "{{ env['DATATRAILS_UNIQUE_ID'] or 'namespace' }}"