openapi: 3.0.0
paths:
  /asset/list:
    get:
      operationId: AssetController_getAll
      summary: Get all assets
      description: Get all assets like rooms, floors, buildings etc.
      parameters:
        - name: asNestedObject
          required: false
          in: query
          schema:
            default: true
            type: boolean
        - name: assetType
          required: false
          in: query
          schema:
            enum:
              - Building
              - Floor
              - Area
              - Room
              - Desk
              - Facade
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Asset'
      tags:
        - Asset
      security:
        - api_key: []
        - bearer: []
  /asset/roots:
    get:
      operationId: AssetController_getRoots
      summary: Get all asset roots
      description: Get all assets roots (i.e. the top level assets, usually buildings)
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Asset'
      tags:
        - Asset
      security:
        - api_key: []
        - bearer: []
  /asset/{assetId}:
    get:
      operationId: AssetController_getByAssetId
      summary: Get asset by id
      description: Get assed by id
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            type: string
        - name: include
          required: false
          in: query
          schema:
            type: array
            items:
              type: string
              enum:
                - direct_children
                - all_children
                - sensor
                - drawing_image
                - drawing_elements
                - drawing_layers
                - parameters
        - name: childrenAssetType
          required: false
          in: query
          schema:
            enum:
              - Building
              - Floor
              - Area
              - Room
              - Desk
              - Facade
            type: string
        - name: childrenAsNestedObject
          required: false
          in: query
          schema:
            type: boolean
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Asset'
      tags:
        - Asset
      security:
        - api_key: []
        - bearer: []
    patch:
      operationId: AssetController_updateByAssetId
      summary: Update asset
      description: Update asset based on asset id
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAsset'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Asset'
      tags:
        - Asset
      security:
        - api_key: []
        - bearer: []
    delete:
      operationId: AssetController_deleteByAssetId
      summary: Delete asset
      description: Delete asset based on asset id
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            type: string
      responses:
        '200':
          description: ''
      tags:
        - Asset
      security:
        - api_key: []
        - bearer: []
  /asset:
    post:
      operationId: AssetController_create
      summary: Create asset
      description: Create asset
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAsset'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Asset'
      tags:
        - Asset
      security:
        - api_key: []
        - bearer: []
  /asset/{assetId}/drawing-image:
    post:
      operationId: AssetController_addDrawingImageToAsset
      summary: Add drawing image to asset
      description: >-
        Add drawing image to asset based on asset id (this will override any
        existing drawing image). You still need to upload the image to AWS
        separately.
      parameters:
        - name: assetId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFile'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/File'
      tags:
        - Asset
      security:
        - api_key: []
        - bearer: []
  /asset-param/list:
    get:
      operationId: AssetParamController_getAll
      summary: Get All asset params
      description: Get All assets parameters
      parameters:
        - name: asset_id
          required: false
          in: query
          schema:
            type: string
        - name: name
          required: false
          in: query
          schema:
            type: string
        - name: value
          required: false
          in: query
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AssetParam'
      tags:
        - Asset Param
      security:
        - api_key: []
        - bearer: []
  /measurement-type/list:
    get:
      operationId: MeasurementTypeController_getAll
      summary: Get all measurement types
      description: Get all measurement types
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MeasurementTypeList'
      tags:
        - Measurement Type
      security:
        - api_key: []
        - bearer: []
  /webhooks/list:
    get:
      operationId: WebhooksController_getAll
      summary: Get all webhook congigurations
      description: Get all webhook congigurations
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ReadWebhookConfigDTO'
      tags:
        - Webhooks
      security:
        - api_key: []
        - bearer: []
  /webhooks:
    post:
      operationId: WebhooksController_createWebhookConfiguration
      summary: Create a webhook configuration
      description: Create a webhook configuration
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookConfigDTO'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReadWebhookConfigDTO'
      tags:
        - Webhooks
      security:
        - api_key: []
        - bearer: []
    patch:
      operationId: WebhooksController_updateWebhookConfiguration
      summary: Edit a webhook configuration
      description: Edit a webhook configuration
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateWebhookConfigDTO'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReadWebhookConfigDTO'
      tags:
        - Webhooks
      security:
        - api_key: []
        - bearer: []
  /webhooks/{webhookConfigId}:
    delete:
      operationId: WebhooksController_deleteWebhookConfiguration
      summary: Delete a webhook configuration
      description: Delete a webhook configuration
      parameters:
        - name: webhookConfigId
          required: true
          in: path
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: boolean
      tags:
        - Webhooks
      security:
        - api_key: []
        - bearer: []
  /unit-type/list:
    get:
      operationId: UnitTypeController_getAll
      summary: Get all unit types
      description: Get all unit types
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnitTypeList'
      tags:
        - Unit Type
      security:
        - api_key: []
        - bearer: []
  /query:
    post:
      operationId: QueryController_getQuery
      summary: Query for sensor data
      description: Query for sensor data with filters
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryParameters'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/QueryResponseDataPoint'
      tags:
        - Query
      security:
        - api_key: []
        - bearer: []
info:
  title: Relynk API
  description: Relynk API
  version: '1.0'
  contact: {}
tags: []
servers: []
components:
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: authorization
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http
  schemas:
    AssetParam:
      type: object
      properties:
        name:
          type: string
        value:
          type: string
      required:
        - name
        - value
    XYWHElement:
      type: object
      properties:
        x:
          type: number
        'y':
          type: number
        width:
          type: number
        height:
          type: number
      required:
        - x
        - 'y'
        - width
        - height
    PathElement:
      type: object
      properties:
        points:
          type: array
          items:
            type: number
      required:
        - points
    Integration:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
      required:
        - id
        - name
        - description
    Sensor:
      type: object
      properties:
        id:
          type: string
          example: a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6
        external_id:
          type: string
          example: 3f4e13d4-ede6-gde8-12d0-k1lde23v35p6
        name:
          type: string
          example: sample_sensor_1
        description:
          type: string
          nullable: true
          example: null
        is_setpoint:
          type: boolean
          example: true
        linked_assets:
          example: []
          type: array
          items:
            $ref: '#/components/schemas/Asset'
        integration:
          example: {}
          allOf:
            - $ref: '#/components/schemas/Integration'
      required:
        - id
        - external_id
        - name
        - is_setpoint
    DrawingElement:
      type: object
      properties:
        data:
          oneOf:
            - $ref: '#/components/schemas/XYWHElement'
            - $ref: '#/components/schemas/PathElement'
        id:
          type: string
        type:
          type: string
          enum:
            - path
            - rectangle
            - circle
        original_screen_width:
          type: number
        original_screen_height:
          type: number
        measurement_override:
          type: object
          nullable: true
        value_from_sensor:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/Sensor'
        value_from_asset:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/Asset'
      required:
        - data
        - id
        - type
        - original_screen_width
        - original_screen_height
    DrawingLayer:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        order_index:
          type: number
        show_asset_names:
          type: boolean
        drawing_elements:
          type: array
          items:
            $ref: '#/components/schemas/DrawingElement'
      required:
        - id
        - name
        - order_index
        - show_asset_names
    File:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        type:
          type: string
          enum:
            - Image
        key:
          type: string
      required:
        - id
        - name
        - type
        - key
    Asset:
      type: object
      properties:
        id:
          type: string
          example: a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6
        name:
          type: string
          example: sample_building_1
        number:
          type: string
          nullable: true
          example: null
        type:
          enum:
            - Building
            - Floor
            - Area
            - Room
            - Desk
            - Facade
          type: string
          example: Building
        children:
          example: []
          type: array
          items:
            $ref: '#/components/schemas/Asset'
        parent:
          example: {}
          allOf:
            - $ref: '#/components/schemas/Asset'
        asset_params:
          example: []
          type: array
          items:
            $ref: '#/components/schemas/AssetParam'
        drawing_layers:
          example: []
          type: array
          items:
            $ref: '#/components/schemas/DrawingLayer'
        drawing_image:
          example: {}
          allOf:
            - $ref: '#/components/schemas/File'
        sensors:
          type: array
          items:
            $ref: '#/components/schemas/Sensor'
      required:
        - id
        - name
        - type
    CreateAsset:
      type: object
      properties:
        parent_id:
          type: string
        name:
          type: string
        number:
          type: string
          nullable: true
        type:
          type: string
          enum:
            - Building
            - Floor
            - Area
            - Room
            - Desk
            - Facade
        asset_params:
          type: array
          items:
            $ref: '#/components/schemas/AssetParam'
      required:
        - name
        - type
    CreateFile:
      type: object
      properties:
        name:
          type: string
        type:
          type: string
          enum:
            - Image
        key:
          type: string
      required:
        - name
        - type
        - key
    UpdateAsset:
      type: object
      properties:
        name:
          type: string
        number:
          type: string
          nullable: true
        type:
          type: string
          enum:
            - Building
            - Floor
            - Area
            - Room
            - Desk
            - Facade
        asset_params:
          type: array
          items:
            $ref: '#/components/schemas/AssetParam'
    MeasurementTypeList:
      type: object
      properties:
        measurement_types:
          type: string
          items:
            type: string
            enum:
              - Temperature
              - RelativeHumidity
              - AirQuality
              - SoundLevel
              - Presence
              - PeopleCount
              - Booked
              - BatteryLevel
              - Light
              - SunScreenDown
              - AirFlow
              - AirPressure
              - FluidFlow
              - FluidPressure
              - WindDirection
              - WindSpeed
              - WindGustSpeed
              - PrecipitationRate
              - Power
              - Energy
              - EnergyReactive
              - Voltage
              - Current
              - Frequency
              - Efficiency
              - PowerFactor
              - Gain
              - Ratio
              - Weight
              - Waste_MixedPlastic
              - Waste_Cardboard
              - Waste_Unsorted
              - Waste_MixedWasteForSorting
              - Waste_Organic
              - Waste_ExpandedAndExtrudedPlastic
              - Waste_GlassAndMetal
              - Waste_EWaste
              - Waste_OfficePaper
              - CO2
              - WIFI_Connected_Clients
          enum:
            - Temperature
            - RelativeHumidity
            - AirQuality
            - SoundLevel
            - Presence
            - PeopleCount
            - Booked
            - BatteryLevel
            - Light
            - SunScreenDown
            - AirFlow
            - AirPressure
            - FluidFlow
            - FluidPressure
            - WindDirection
            - WindSpeed
            - WindGustSpeed
            - PrecipitationRate
            - Power
            - Energy
            - EnergyReactive
            - Voltage
            - Current
            - Frequency
            - Efficiency
            - PowerFactor
            - Gain
            - Ratio
            - Weight
            - Waste_MixedPlastic
            - Waste_Cardboard
            - Waste_Unsorted
            - Waste_MixedWasteForSorting
            - Waste_Organic
            - Waste_ExpandedAndExtrudedPlastic
            - Waste_GlassAndMetal
            - Waste_EWaste
            - Waste_OfficePaper
            - CO2
            - WIFI_Connected_Clients
          example:
            - Temperature
            - RelativeHumidity
            - AirQuality
            - SoundLevel
            - Presence
            - PeopleCount
            - Booked
            - BatteryLevel
            - Light
            - SunScreenDown
            - AirFlow
            - AirPressure
            - FluidFlow
            - FluidPressure
            - WindDirection
            - WindSpeed
            - WindGustSpeed
            - PrecipitationRate
            - Power
            - Energy
            - EnergyReactive
            - Voltage
            - Current
            - Frequency
            - Efficiency
            - PowerFactor
            - Gain
            - Ratio
            - Weight
            - Waste_MixedPlastic
            - Waste_Cardboard
            - Waste_Unsorted
            - Waste_MixedWasteForSorting
            - Waste_Organic
            - Waste_ExpandedAndExtrudedPlastic
            - Waste_GlassAndMetal
            - Waste_EWaste
            - Waste_OfficePaper
            - CO2
            - WIFI_Connected_Clients
      required:
        - measurement_types
    RequestHeader:
      type: object
      properties:
        id:
          type: number
        name:
          type: string
        value:
          type: string
      required:
        - id
        - name
        - value
    ReadWebhookConfigDTO:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        endpoint:
          type: string
        method:
          type: number
          enum:
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
          example:
            - GET
            - POST
            - PUT
            - DELETE
            - PATCH
            - ALL
            - OPTIONS
            - HEAD
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
        headers:
          type: array
          items:
            $ref: '#/components/schemas/RequestHeader'
        customerId:
          type: string
        time:
          format: date-time
          type: string
      required:
        - id
        - endpoint
        - method
        - headers
        - customerId
        - time
    WebhookConfigDTO:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        endpoint:
          type: string
        method:
          type: number
          enum:
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
          example:
            - GET
            - POST
            - PUT
            - DELETE
            - PATCH
            - ALL
            - OPTIONS
            - HEAD
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
        headers:
          type: array
          items:
            $ref: '#/components/schemas/RequestHeader'
        customerId:
          type: string
        time:
          format: date-time
          type: string
      required:
        - endpoint
        - method
        - headers
    UpdateWebhookConfigDTO:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        endpoint:
          type: string
        method:
          type: number
          enum:
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
          example:
            - GET
            - POST
            - PUT
            - DELETE
            - PATCH
            - ALL
            - OPTIONS
            - HEAD
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
        headers:
          type: array
          items:
            $ref: '#/components/schemas/RequestHeader'
        customerId:
          type: string
        time:
          format: date-time
          type: string
      required:
        - id
        - endpoint
        - method
        - headers
        - customerId
    UnitTypeList:
      type: object
      properties:
        unit_types:
          type: string
          enum:
            - kilogram
            - dB
            - Percent
            - TVOC
            - Yes / No
            - Number
            - Celcius
            - Farenheit
            - Kelvin
            - Volt
            - Lux
            - PPM
            - PPB
            - m3
            - m3/s
            - m3/min
            - m3/h
            - m3/day
            - Degrees Angular
            - Farad
            - Herzt
            - Horsepower
            - Joul
            - MilliJoul
            - KiloJoul
            - Watt
            - MilliWatt
            - KiloWatt
            - MegaWatt
            - kWh
            - kWh_Reactive
            - Wh
            - Wh_Reactive
            - MWh
            - MWh_Reactive
            - Liter
            - l/s
            - l/min
            - l/h
            - Lumen
            - m/s
            - m/min
            - m/h
            - m/s2
            - MilliAmpere
            - Ampere
            - MilliVolt
            - Newton
            - NewtonMeter
            - NewtonSecond
            - Ohm
            - MilliOhm
            - KiloOhm
            - MegaOhm
            - Pa
            - '%/s'
            - pH
            - PowerFactor
            - Radian
            - Radian/s
            - RPM
            - Siemens
            - SquareMeter
            - m2/Newton
            - Tesla
            - Tonn
            - VoltAmpere
            - VoltAmpere_Reactive
            - VoltAmpereHour
            - VoltAmpereHour_Reactive
          example:
            - kilogram
            - dB
            - Percent
            - TVOC
            - Yes / No
            - Number
            - Celcius
            - Farenheit
            - Kelvin
            - Volt
            - Lux
            - PPM
            - PPB
            - m3
            - m3/s
            - m3/min
            - m3/h
            - m3/day
            - Degrees Angular
            - Farad
            - Herzt
            - Horsepower
            - Joul
            - MilliJoul
            - KiloJoul
            - Watt
            - MilliWatt
            - KiloWatt
            - MegaWatt
            - kWh
            - kWh_Reactive
            - Wh
            - Wh_Reactive
            - MWh
            - MWh_Reactive
            - Liter
            - l/s
            - l/min
            - l/h
            - Lumen
            - m/s
            - m/min
            - m/h
            - m/s2
            - MilliAmpere
            - Ampere
            - MilliVolt
            - Newton
            - NewtonMeter
            - NewtonSecond
            - Ohm
            - MilliOhm
            - KiloOhm
            - MegaOhm
            - Pa
            - '%/s'
            - pH
            - PowerFactor
            - Radian
            - Radian/s
            - RPM
            - Siemens
            - SquareMeter
            - m2/Newton
            - Tesla
            - Tonn
            - VoltAmpere
            - VoltAmpere_Reactive
            - VoltAmpereHour
            - VoltAmpereHour_Reactive
      required:
        - unit_types
    QueryFilter:
      type: object
      properties:
        value:
          oneOf:
            - type: array
              items:
                type: string
            - type: array
              items:
                type: number
          items:
            type: object
        filter_on:
          type: string
          enum:
            - measurement
            - asset_type
            - rule_id
            - sensor_id
            - asset_id
      required:
        - value
        - filter_on
    QueryParameters:
      type: object
      properties:
        filters:
          example:
            - filter_on: measurement
              value:
                - Temperature
          type: array
          items:
            $ref: '#/components/schemas/QueryFilter'
        group_on:
          enum:
            - Desk
            - Room
            - Floor
            - Area
            - Building
            - Facade
            - Sensor
            - None
          type: string
          example: Building
        to:
          format: date-time
          type: string
          example: '2020-01-01T00:00:00.000Z'
        from:
          format: date-time
          type: string
          example: '2020-01-02T00:00:00.000Z'
        resolution:
          type: string
          enum:
            - raw
            - 30 minute
            - 1 hour
            - 1 day
            - 1 week
            - 1 month
            - 1 year
        is_timeseries:
          type: boolean
        only_latest_value:
          type: boolean
        limit:
          type: number
        offset:
          type: number
      required:
        - filters
        - resolution
        - is_timeseries
        - only_latest_value
    QueryResponseDataPoint:
      type: object
      properties:
        measurement_type:
          enum:
            - Temperature
            - RelativeHumidity
            - AirQuality
            - SoundLevel
            - Presence
            - PeopleCount
            - Booked
            - BatteryLevel
            - Light
            - SunScreenDown
            - AirFlow
            - AirPressure
            - FluidFlow
            - FluidPressure
            - WindDirection
            - WindSpeed
            - WindGustSpeed
            - PrecipitationRate
            - Power
            - Energy
            - EnergyReactive
            - Voltage
            - Current
            - Frequency
            - Efficiency
            - PowerFactor
            - Gain
            - Ratio
            - Weight
            - Waste_MixedPlastic
            - Waste_Cardboard
            - Waste_Unsorted
            - Waste_MixedWasteForSorting
            - Waste_Organic
            - Waste_ExpandedAndExtrudedPlastic
            - Waste_GlassAndMetal
            - Waste_EWaste
            - Waste_OfficePaper
            - CO2
            - WIFI_Connected_Clients
          type: string
          example: Temperature
        unit:
          enum:
            - kilogram
            - dB
            - Percent
            - TVOC
            - Yes / No
            - Number
            - Celcius
            - Farenheit
            - Kelvin
            - Volt
            - Lux
            - PPM
            - PPB
            - m3
            - m3/s
            - m3/min
            - m3/h
            - m3/day
            - Degrees Angular
            - Farad
            - Herzt
            - Horsepower
            - Joul
            - MilliJoul
            - KiloJoul
            - Watt
            - MilliWatt
            - KiloWatt
            - MegaWatt
            - kWh
            - kWh_Reactive
            - Wh
            - Wh_Reactive
            - MWh
            - MWh_Reactive
            - Liter
            - l/s
            - l/min
            - l/h
            - Lumen
            - m/s
            - m/min
            - m/h
            - m/s2
            - MilliAmpere
            - Ampere
            - MilliVolt
            - Newton
            - NewtonMeter
            - NewtonSecond
            - Ohm
            - MilliOhm
            - KiloOhm
            - MegaOhm
            - Pa
            - '%/s'
            - pH
            - PowerFactor
            - Radian
            - Radian/s
            - RPM
            - Siemens
            - SquareMeter
            - m2/Newton
            - Tesla
            - Tonn
            - VoltAmpere
            - VoltAmpere_Reactive
            - VoltAmpereHour
            - VoltAmpereHour_Reactive
          type: string
          example: Celcius
        group_asset_id:
          type: string
          example: ''
        group_asset_name:
          type: string
          example: ''
        group_asset_type:
          enum:
            - Building
            - Floor
            - Area
            - Room
            - Desk
            - Facade
          type: string
          example: Building
        group_sensor_id:
          type: string
          example: ''
        group_sensor_name:
          type: string
          example: ''
        value:
          type: number
          example: 24.5
        average_value:
          type: number
          example: 22.5
        count_value:
          type: number
          example: null
        sum_value:
          type: number
          example: null
        min_value:
          type: number
          example: 18.5
        max_value:
          type: number
          example: 24.7
        date_time:
          format: date-time
          type: string
      required:
        - measurement_type
        - unit
        - date_time
