---
# ----------------------------------------------------------------------------
# Service Commissioning File
# ----------------------------------------------------------------------------
# Copyright: Cybus GmbH
# Contact: support@cybus.io
# ----------------------------------------------------------------------------
# Heisenware Integration (Example)
# ----------------------------------------------------------------------------

description: >
  Service commissioning file for the integration between Connectware and the
  Heisenware low-code platform (Example)

metadata:
  name: Heisenware Integration
  provider: cybus
  homepage: https://www.cybus.io
  version: 1.0.0

parameters:
  heisenwarePassword:
    description: Password of the MQTT user that Heisenware uses to authenticate
    type: string

  topicRoot:
    description: Root of the UNS topic hierarchy
    type: string
    default: enterprise

resources:
  # Limits Heisenware to reading the UNS hierarchy and writing to its
  # own namespace
  heisenwareRole:
    type: Cybus::Role
    properties:
      permissions:
        - resource: !sub '${topicRoot}/#'
          operation: read
          context: mqtt
        - resource: heisenware/#
          operation: write
          context: mqtt

  # MQTT user for the Heisenware MQTT Client connector. The username is
  # prefixed with the service ID, for example heisenware.app
  app:
    type: Cybus::User
    properties:
      password: !ref heisenwarePassword
      roles:
        - !ref heisenwareRole

  # Routes operator inputs from the Heisenware namespace into the UNS
  operatorInputMapping:
    type: Cybus::Mapping
    properties:
      mappings:
        - subscribe:
            topic: 'heisenware/#topic'
          publish:
            topic: !sub '${topicRoot}/$topic'
