openapi: 3.2.0
info:
  title: UltraAPI
  description: OpenAPI for Abelko IMSE Ultra
  version: 1.0.0
  contact:
    name: Abelko Innovation
    url: https://abelko.se
    email: support@abelko.se
servers:
  - url: /api
tags:
  - name: alarm
    description: Alarm operations
  - name: application
    description: Application operations
  - name: channel
    description: Channel operations
  - name: iochannel
    description: I/O channel operations
  - name: iounit
    description: I/O unit operations
  - name: parameter
    description: Parameter operations
paths:
  /v1/alarm:
    get:
      tags:
        - alarm
      summary: Get alarms
      description: Returns all alarms
      operationId: getAlarm
      responses:
        '200':
          $ref: '#/components/responses/listAlarm'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/alarm/{i}:
    get:
      tags:
        - alarm
      summary: Get alarms by ID
      description: Returns alarms matching the requested IDs
      operationId: getAlarmById
      parameters:
        - $ref: '#/components/parameters/getId'
      responses:
        '200':
          $ref: '#/components/responses/listAlarm'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/application:
    get:
      tags:
        - application
      summary: Get applications
      description: Returns all applications
      operationId: getApplication
      responses:
        '200':
          $ref: '#/components/responses/listApplication'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/application/{i}:
    get:
      tags:
        - application
      summary: Get applications by ID
      description: Returns applications matching the requested IDs
      operationId: getApplicationById
      parameters:
        - $ref: '#/components/parameters/getId'
      responses:
        '200':
          $ref: '#/components/responses/listApplication'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/channel:
    get:
      tags:
        - channel
      summary: Get channels
      description: Returns all channels
      operationId: getChannel
      responses:
        '200':
          $ref: '#/components/responses/listChannel'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/channel/{i}:
    get:
      tags:
        - channel
      summary: Get channels by ID
      description: Returns channels matching the requested IDs
      operationId: getChannelById
      parameters:
        - $ref: '#/components/parameters/getId'
      responses:
        '200':
          $ref: '#/components/responses/listChannel'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
    patch:
      tags:
        - channel
      summary: Update channel
      description: Updates the channel with the requested ID
      operationId: patchChannel
      parameters:
        - $ref: '#/components/parameters/patchId'
      requestBody:
        $ref: '#/components/requestBodies/payloadChannel'
      responses:
        '204':
          $ref: '#/components/responses/204NoContent'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '404':
          $ref: '#/components/responses/404NotFound'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/iochannel:
    get:
      tags:
        - iochannel
      summary: Get I/O channels
      description: Returns all I/O channels
      operationId: getIOChannel
      responses:
        '200':
          $ref: '#/components/responses/listIOChannel'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/iochannel/{i}:
    get:
      tags:
        - iochannel
      summary: Get I/O channels by ID
      description: Returns I/O channels matching the requested IDs
      operationId: getIOChannelById
      parameters:
        - $ref: '#/components/parameters/getId'
      responses:
        '200':
          $ref: '#/components/responses/listIOChannel'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
    patch:
      tags:
        - iochannel
      summary: Update I/O channel
      description: Updates the I/O channel with the requested ID
      operationId: patchIOChannel
      parameters:
        - $ref: '#/components/parameters/patchId'
      requestBody:
        $ref: '#/components/requestBodies/payloadIOChannel'
      responses:
        '204':
          $ref: '#/components/responses/204NoContent'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '404':
          $ref: '#/components/responses/404NotFound'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/iounit:
    get:
      tags:
        - iounit
      summary: Get I/O units
      description: Returns all I/O units
      operationId: getIOUnit
      responses:
        '200':
          $ref: '#/components/responses/listIOUnit'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/iounit/{i}:
    get:
      tags:
        - iounit
      summary: Get I/O units by ID
      description: Returns I/O units matching the requested IDs
      operationId: getIOUnitById
      parameters:
        - $ref: '#/components/parameters/getId'
      responses:
        '200':
          $ref: '#/components/responses/listIOUnit'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/parameter:
    get:
      tags:
        - parameter
      summary: Get parameters
      description: Returns all parameters
      operationId: getParameter
      responses:
        '200':
          $ref: '#/components/responses/listParameter'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
  /v1/parameter/{i}:
    get:
      tags:
        - parameter
      summary: Get parameters by ID
      description: Returns parameters matching the requested IDs
      operationId: getParameterById
      parameters:
        - $ref: '#/components/parameters/getId'
      responses:
        '200':
          $ref: '#/components/responses/listParameter'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
    patch:
      tags:
        - parameter
      summary: Update parameter
      description: Updates the parameter with the requested ID
      operationId: patchParameter
      parameters:
        - $ref: '#/components/parameters/patchId'
      requestBody:
        $ref: '#/components/requestBodies/payloadParameter'
      responses:
        '204':
          $ref: '#/components/responses/204NoContent'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '403':
          $ref: '#/components/responses/403Forbidden'
        '404':
          $ref: '#/components/responses/404NotFound'
        '408':
          $ref: '#/components/responses/408RequestTimeout'
        '500':
          $ref: '#/components/responses/500InternalServerError'
security:
  - apiKey: []
components:
  parameters:
    getId:
      in: path
      name: i
      description: IDs to get
      required: true
      schema:
        type: array
        items:
          type: integer
          format: int64
        minItems: 1
        maxItems: 100
      style: simple
    patchId:
      in: path
      name: i
      description: ID to update
      required: true
      schema:
        type: integer
        format: int64
  requestBodies:
    payloadChannel:
      description: Channel object payload
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/channelObject'
    payloadIOChannel:
      description: I/O channel object payload
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/iochannelObject'
    payloadParameter:
      description: Parameter object payload
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/parameterObject'
  responses:
    listAlarm:
      description: List of alarm objects
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/alarmObject'
    listApplication:
      description: List of application objects
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/applicationObject'
    listChannel:
      description: List of channel objects
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/channelObject'
    listIOChannel:
      description: List of I/O channel objects
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/iochannelObject'
    listIOUnit:
      description: List of I/O unit objects
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/iounitObject'
    listParameter:
      description: List of parameter objects
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/parameterObject'
    204NoContent:
      description: No Content
    400BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            type: string
    401Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            type: string
    403Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            type: string
    404NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            type: string
    408RequestTimeout:
      description: Request Timeout
      content:
        application/json:
          schema:
            type: string
    500InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            type: string
  schemas:
    alarmObject:
      description: Alarm object
      properties:
        i:
          readOnly: true
          type: integer
          format: int64
          description: Alarm ID
        AppIndex:
          readOnly: true
          type: integer
          format: int64
          description: Application ID
        ParentChn:
          readOnly: true
          type: integer
          format: int64
          description: Parent channel ID
        Identifier:
          readOnly: true
          type: string
          description: Alarm identifier
        Name:
          readOnly: true
          type: string
          description: Alarm name
        Message:
          readOnly: true
          type: string
          description: Alarm message
        Value:
          readOnly: true
          type: number
          format: double
          description: Non-zero values mean that the alarm is active
        AlarmType:
          readOnly: true
          type: integer
          format: int64
          description: |
            Automatic reset, no acknowledgement `0` and `3`.
            Reset when acknowledged `1` and `4`.
            Automatic reset, with acknowledgement `2` and `5`.
        AlarmTime:
          readOnly: true
          type: integer
          format: int64
          description: POSIX timestamp in seconds indicating when the alarm became active
        AlarmPrio:
          readOnly: true
          type: integer
          format: int64
          description: |
            `1` is priority A, ..., `26` is priority Z.
            `27` is event.
            `28` is error event.
    applicationObject:
      description: Application object
      properties:
        i:
          readOnly: true
          type: integer
          format: int64
          description: Application ID
        Identifier:
          readOnly: true
          type: string
          description: Application identifier
        ParentApp:
          readOnly: true
          type: integer
          format: int64
          description: Parent application ID
        Name:
          readOnly: true
          type: string
          description: Application name
        Description:
          readOnly: true
          type: string
          description: Application description
        RunStatus:
          readOnly: true
          type: integer
          format: int64
          description: |
            Stopped `0`.
            Paused `1`.
            Running `2`.
    channelObject:
      description: Channel object
      properties:
        i:
          readOnly: true
          type: integer
          format: int64
          description: Channel ID
        AppIndex:
          readOnly: true
          type: integer
          format: int64
          description: Application ID
        Identifier:
          readOnly: true
          type: string
          description: Channel identifier
        Type:
          readOnly: true
          type: integer
          format: int64
          description: |
            Normal `0`.
            Persistent `1`.
            Input `3`.
            Output `4`.
        Name:
          readOnly: true
          type: string
          description: Channel name
        Unit:
          readOnly: true
          type: string
          description: Unit of channel value
        Value:
          readOnly: true
          type: number
          format: double
          description: Channel value
        MOAllowed:
          readOnly: true
          type: integer
          format: int64
          description: |
            Manual override not allowed `0`.
            Manual override allowed `1`.
            Manual override blocked by script `2`.
            Manual override allowed but blocked by script `3`.
        MOActive:
          type: integer
          format: int64
          description: |
            Manual override inactive `0`.
            Manual override active `1`.
            When active `Value` is replaced by `MOValue`.
        MOValue:
          type: number
          format: double
          description: |
            Manual override value.
            When manual override is active `Value` is replaced by `MOValue`.
        MODuration:
          readOnly: true
          type: integer
          format: int64
          description: |
            Manual override duration in seconds.
            `2147483647` runs until next restart.
        MOTimer:
          readOnly: true
          type: integer
          format: int64
          description: Seconds remaining of the active manual override
    iochannelObject:
      description: I/O channel object
      properties:
        i:
          readOnly: true
          type: integer
          format: int64
          description: I/O channel ID
        Identifier:
          readOnly: true
          type: string
          description: I/O channel identifier
        Name:
          readOnly: true
          type: string
          description: I/O channel name
        Value:
          readOnly: true
          type: number
          format: double
          description: I/O channel value
        Unit:
          readOnly: true
          type: string
          description: Unit of I/O channel value
        ParentIOUnit:
          readOnly: true
          type: integer
          format: int64
          description: Parent I/O unit ID
        Direction:
          readOnly: true
          type: integer
          format: int64
          description: |
            Output `0`.
            Input `1`.
            Register `2`.
        RawValue:
          readOnly: true
          type: number
          format: double
          description: Raw I/O channel value
        MOAllowed:
          readOnly: true
          type: integer
          format: int64
          description: |
            Manual override not allowed `0`.
            Manual override allowed `1`.
        MOActive:
          type: integer
          format: int64
          description: |
            Manual override inactive `0`.
            Manual override active `1`.
            When active `Value` is replaced by `MOValue`.
        MODuration:
          readOnly: true
          type: integer
          format: int64
          description: |
            Manual override duration in seconds.
            `2147483647` runs until next restart.
        MOValue:
          type: number
          format: double
          description: |
            Manual override value.
            When manual override is active `Value` is replaced by `MOValue`.
        MOTimer:
          readOnly: true
          type: integer
          format: int64
          description: Seconds remaining of the active manual override
    iounitObject:
      description: I/O unit object
      properties:
        i:
          readOnly: true
          type: integer
          format: int64
          description: I/O unit ID
        Identifier:
          readOnly: true
          type: string
          description: I/O unit identifier
        RowNr:
          readOnly: true
          type: integer
          format: int64
          description: I/O unit row index
        Name:
          readOnly: true
          type: string
          description: I/O unit name
        Active:
          readOnly: true
          type: integer
          format: int64
          description: |
            Off `0`.
            On `1`.
        ErrorState:
          readOnly: true
          type: integer
          format: int64
          description: |
            OK `0`.
            Error `1`.
        AlarmStatus:
          readOnly: true
          type: integer
          format: int64
          description: |
            OK `0`.
            Trying `1`.
            Failed `2`.
            Disabled `3`.
    parameterObject:
      description: Parameter object
      properties:
        i:
          readOnly: true
          type: integer
          format: int64
          description: Parameter ID
        AppIndex:
          readOnly: true
          type: integer
          format: int64
          description: Application ID
        Identifier:
          readOnly: true
          type: string
          description: Parameter identifier
        Name:
          readOnly: true
          type: string
          description: Parameter name
        Unit:
          readOnly: true
          type: string
          description: Unit of parameter value
        Value:
          type: number
          format: double
          description: Parameter value
  securitySchemes:
    apiKey:
      type: apiKey
      name: Ultra-Api-Key
      in: header
      description: Ultra API key to authenticate the request
