description: >
    Sample MSSQL service commissioning file

metadata:
  name: MSSQL push service
  icon: https://www.cybus.io/wp-content/uploads/2017/10/for-whom1.svg
  provider: cybus
  homepage: https://www.cybus.io
  version: 1.0.0

parameters:
  mssqlHost:
    type: string
    default: 172.17.0.1

  mssqlPort:
    type: integer
    default: 1433

  mssqlUser:
    type: string
    default: sa

  mssqlPassword:
    type: string
    default: SomeLongSecurePassw0rd

  mssqlDatabase:
    type: string
    default: tempdb

resources:

  mssqlDB:
    type: Cybus::Container
    properties:
      image: mcr.microsoft.com/mssql/server
      ports:
        - 1433:1433/tcp
      environment:
        SA_PASSWORD: 'SomeLongSecurePassw0rd'
        ACCEPT_EULA: 'Y'

  mssqlConnection:
    type: Cybus::Connection
    properties:
      protocol: Mssql
      connection:
        host: !ref mssqlHost
        port: !ref mssqlPort
        username: !ref mssqlUser
        password: !ref mssqlPassword
        database: !ref mssqlDatabase

  mssqlQuery2:
    type: Cybus::Endpoint
    properties:
      protocol: Mssql
      connection: !ref mssqlConnection
      write:
        # Here we use the placeholder @someValue. The protocol driver will insert
        # the value from the input JSON message under the key someValue
        query: 'INSERT INTO machine (powerlevel, state, timestamp) VALUES (@powerlevel, @state, @timestamp)'

  mapping:
    type: Cybus::Mapping
    properties:
      mappings:
        - subscribe:
            topic: 'machine-state'
          publish:
            endpoint: !ref mssqlQuery2
