Door Entry Demo

---
# The step field is a string that represents the method bound to an endpoint.
#
# NB the assets and events endpoints require all values to be strings. Other values may
# be of the correct type such as confirm which is a boolean.
#
# This story creates a number of doors and access cards. An 'open door' event is then 
# created with attached photo. Finally all doors and cards are listed and all events on 
# the the Courts of Justice Front Door and all events on the Access Card 2 are listed.
#
steps:
  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create a door in Paris at DataTrails offices.
      asset_label: DataTrails Paris Front Door
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: DataTrails Paris Front Door
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_display_type: door
      arc_firmware_version: "1.0"
      arc_serial_number: das-j1-01
      arc_description: Electronic door entry system to DataTrails France
      wavestone_asset_id: paris.france.datatrails.das
    location:
      selector:
        - display_name
        - attributes:
          - namespace
      display_name: DataTrails Paris
      description: Sales and sales support for the French region
      latitude: 48.8339211
      longitude: 2.371345
      attributes:
        namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
        address: 5 Parvis Alan Turing, 75013 Paris, France
        wavestone_ext: managed
    attachments:
      - filename: functests/test_resources/doors/assets/entry_terminal.jpg
        content_type: image/jpg

  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create a door in Paris at City Hall
      asset_label: City Hall Paris Front Door
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: City Hall Paris Front Door
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_display_type: door
      arc_firmware_version: "1.0"
      arc_serial_number: das-x4-01
      arc_description: Electronic door entry system controlling the main staff entrance to Paris City Hall
      wavestone_asset_id: cityhall.paris.wavestonedas
    location:
      selector:
        - display_name
        - attributes:
          - namespace
      display_name: Paris City Hall
      description: Seat of Paris local city adminstration
      latitude: 48.856389
      longitude: 2.352222
      attributes:
        namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
        address: Place de l'Hôtel de Ville, 75004 Paris, France
        wavestone_ext: managed
      attachments:
      - filename: functests/test_resources/doors/assets/cityhall.jpg
        content_type: image/jpg

  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create a door in Paris at Courts of Justice
      LOGGER.debug_response: true
      asset_label: Courts of Justice Paris Front Door
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: Courts of Justice Paris Front Door
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_display_type: door
      arc_firmware_version: "1.0"
      arc_serial_number: das-x4-02
      arc_description: Electronic door entry system controlling the main staff entrance to Paris Courts of Justice
      wavestone_asset_id: courts.paris.wavestonedas
    location:
      selector:
        - display_name
        - attributes:
          - namespace
      display_name: Paris Courts of Justice
      description: Public museum in the former Palais de Justice
      latitude: 48.855722
      longitude: 2.345051
      attributes:
        namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
        address: 10 Boulevard du Palais, 75001 Paris, France
        wavestone_ext: managed
    attachments:
      - filename: functests/test_resources/doors/assets/courts.jpg
        content_type: image/jpg

  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create a door in Paris at Bastille
      asset_label: Bastille Paris Front Door
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: Bastille Paris Front Door
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_display_type: door
      arc_firmware_version: "1.0"
      arc_serial_number: das-x4-03
      arc_description: Electronic door entry system controlling the main staff entrance to Bastille
      wavestone_asset_id: bastille.paris.wavestonedas
    location:
      selector:
        - display_name
        - attributes:
          - namespace
      display_name: Bastille
      description: Medieval fortress, made famous by the French Revolution
      latitude: 48.85333
      longitude: 2.36917
      attributes:
        namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
        address: Place de la Bastille, 75011 Paris, France
        wavestone_ext: managed
    attachments:
      - filename: functests/test_resources/doors/assets/bastille.jpg
        content_type: image/jpg

  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create a front door in Paris at Gare du Nord Apartments
      asset_label: Gare du Nord Apartments Paris Front Door
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: Gare du Nord Apartments Paris Front Door
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_display_type: door
      arc_firmware_version: "1.0"
      arc_serial_number: das-x4-04
      arc_description: Electronic door entry system controlling the front residential entrance to Apartements du Gare du Nord
      wavestone_asset_id: front.gdn.paris.wavestonedas
    location:
      selector:
        - display_name
        - attributes:
          - namespace
      display_name: Apartements du Gare du Nord
      description: Residential apartment building in new complex above GdN station
      latitude: 48.8809
      longitude: 2.3553
      attributes:
        namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
        address: 18 Rue de Dunkerque, 75010 Paris, France
        wavestone_ext: managed
    attachments:
      - filename: functests/test_resources/doors/assets/gdn_front.jpg
        content_type: image/jpg

  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create a side door in Paris at Gare du Nord Apartments
      asset_label: Gare du Nord Apartments Paris Side Door
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: Gare du Nord Apartments Paris Side Door
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_display_type: door
      arc_firmware_version: "1.0"
      arc_serial_number: das-x4-05
      arc_description: Electronic door entry system controlling the side residential entrance to Apartements du Gare du Nord
      wavestone_asset_id: side.gdn.paris.wavestonedas
    location:
      selector:
        - display_name
        - attributes:
          - namespace
      display_name: Apartements du Gare du Nord
      description: Residential apartment building in new complex above GdN station
      latitude: 48.8809
      longitude: 2.3553
      attributes:
        namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
        address: 18 Rue de Dunkerque, 75010 Paris, France
        wavestone_ext: managed
    attachments:
      - filename: functests/test_resources/doors/assets/gdn_side.jpg
        content_type: image/jpg

# We don't create locations for cards - they float free.
# If there's a natural affinity between cards and home
# locations/owners in the real world then of course we
# can add this.
# Similarly there's no real benefit to creating a
# Primary_image for them so leave that empty too
#
  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create Access Card 1
      asset_label: Access Card 1
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: Access Card 1
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_display_type: card
      arc_serial_number: sc-x5-1
      arc_description: Electronic door Access Card 1

  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create Access Card 2
      asset_label: Access Card 2
      LOGGER.debug_response: true
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: Access Card 2
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_display_type: card
      arc_serial_number: sc-x5-2
      arc_description: Electronic door Access Card 2

  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create Access Card 3
      asset_label: Access Card 3
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: Access Card 3
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_serial_number: sc-x5-3
      arc_description: Electronic door Access Card 3

  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create Access Card 4
      asset_label: Access Card 4
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: Access Card 4
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_display_type: card
      arc_serial_number: sc-x5-4
      arc_description: Electronic door Access Card 4

  - step:
      action: ASSETS_CREATE_IF_NOT_EXISTS
      description: Create Access Card 5
      asset_label: Access Card 5
    selector:
      - attributes:
        - arc_display_name
        - arc_namespace
    behaviours:
      - RecordEvidence
    attributes:
      arc_display_name: Access Card 5
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}
      arc_display_type: card
      arc_serial_number: sc-x5-5
      arc_description: Electronic door Access Card 5

  # opening a door requires 2 events to be created with the same
  # correlation value "be5c8061-236d-4400-a625-b74a34e5801b" and the
  # same principal declared..
  - step:
      action: EVENTS_CREATE
      description: Courts of justice front door opened with card 2
      asset_label: Courts of Justice Paris Front Door
      LOGGER.debug_response: true
    operation: Record
    behaviour: RecordEvidence
    principal_declared:
      subject: courts.paris.wavestonedas
      email: courts.paris.wavestonedas@iot.wavestone.com
      display_name: Courts of Justice Paris Front Door machine credential
    event_attributes:
      arc_description: Door opened by authorized key card Access Card 2
      arc_display_type: Door Open
      arc_evidence: ARQC 0x12345678
      arc_correlation_value: be5c8061-236d-4400-a625-b74a34e5801b
      wavestone_card_name: Access Card 2
      wavestone_evt_type: door_open
    attachments:
      - filename: functests/test_resources/doors/events/door_open.png
        content_type: image/png

  - step:
      action: EVENTS_CREATE
      description: Access Card 2 opens Courts of justice front door
      asset_label: Access Card 2
      LOGGER.debug_response: true
    operation: Record
    behaviour: RecordEvidence
    principal_declared:
      subject: courts.paris.wavestonedas
      email: courts.paris.wavestonedas@iot.wavestone.com
      display_name: Courts of Justice Paris Front Door machine credential
    event_attributes:
      arc_description: Opened Courts of Justice Paris Front Door
      arc_display_type: Door Open
      arc_evidence: ARQC 0x12345678
      arc_correlation_value: be5c8061-236d-4400-a625-b74a34e5801b
      wavestone_door_name: Courts of Justice Paris Front Door
      wavestone_evt_type: door_open
    attachments:
      - filename: functests/test_resources/doors/events/door_open.png
        content_type: image/png

  - step:
      action: ASSETS_LIST
      description: List all doors
      LOGGER.debug_response: true
    attrs:
      arc_display_type: door
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}

  - step:
      action: ASSETS_LIST
      description: List all cards
      LOGGER.debug_response: true
    attrs:
      arc_display_type: card
      arc_namespace: !ENV ${DATATRAILS_UNIQUE_ID:namespace}

  - step:
      action: EVENTS_LIST
      description: List all events for Courts of Justice Paris Front Door
      LOGGER.debug_response: true
      asset_label: Courts of Justice Paris Front Door

  - step:
      action: EVENTS_LIST
      description: List all events for Access Card 2
      LOGGER.debug_response: true
      asset_label: Access Card 2