swagger: '2.0'
info:
  title: Protocol Mapper API
  version: 0.1.0
basePath: /api
schemes:
  - https
produces:
  - application/json
consumes:
  - application/json
paths:
  /api/connections/schema:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - connections
      summary: Get all connection schemas
      operationId: getConnectionSchemas
      responses:
        '200':
          description: Connection schemas
          schema:
            type: object
  /api/connections:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - connections
      summary: Get all connections
      operationId: getConnections
      responses:
        '200':
          description: Array of connections
          schema:
            type: array
            items:
              $ref: '#/definitions/Connection'
        '500':
          description: Failed to list all connections
  /api/connections/{id}:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - connections
      summary: Get one connection by id
      operationId: getConnection
      responses:
        '200':
          description: Sucessfully got a connection
          schema:
            $ref: '#/definitions/Connection'
        '500':
          description: Failed to get connection
  /api/connections/{id}/operation:
    put:
      security:
        - ApiKeyHeader: []
      tags:
        - connections
      summary: Update an existing connection
      operationId: updateConnection
      parameters:
        - in: body
          name: body
          description: Operation to perform on the connection
          required: true
          schema:
            type: object
            required:
              - operation
            properties:
              operation:
                type: string
                enum:
                  - connect
                  - disconnect
      responses:
        '200':
          description: Updated connection
          schema:
            $ref: '#/definitions/Connection'
        '500':
          description: Failed to update the connection
  /api/endpoints/schema:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - endpoints
      summary: Get all endpoint schemas
      operationId: getEndpointSchemas
      responses:
        '200':
          description: Endpoint schemas
          schema:
            type: object
  /api/endpoints:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - endpoints
      summary: Get all endpoints
      operationId: getEndpoints
      responses:
        '200':
          description: Array of endpoints
          schema:
            type: array
            items:
              $ref: '#/definitions/Endpoint'
        '500':
          description: Failed to list all endpoints
  /api/endpoints/{id}:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - endpoints
      summary: Get one endpoint by id
      operationId: getEndpoint
      responses:
        '200':
          description: Sucessfully got an Endpoint
          schema:
            $ref: '#/definitions/Endpoint'
        '500':
          description: Failed to get endpoint
  /api/endpoints/{id}/topics:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - endpoints
      summary: Get one endpoint topics by id
      operationId: getEndpointTopics
      responses:
        '200':
          description: Sucessfully got an Endpoint topics
          schema:
            type: array
            items:
              type: string
        '500':
          description: Failed to get endpoint topics
  /api/endpoints/{id}/state:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - endpoints
      summary: Get one endpoint state by id
      operationId: getEndpointState
      responses:
        '200':
          description: Sucessfully got an Endpoint state
          schema:
            type: string
        '500':
          description: Failed to get endpoint state
  /api/endpoints/{id}/operation:
    put:
      security:
        - ApiKeyHeader: []
      tags:
        - endpoints
      summary: Update an existing endpoint
      operationId: updateEndpoint
      parameters:
        - in: body
          name: body
          description: Operation to perform on the endpoint
          required: true
          schema:
            type: object
            required:
              - operation
            properties:
              operation:
                type: string
                enum:
                  - enable
                  - disable
      responses:
        '200':
          description: Updated endpoint
          schema:
            $ref: '#/definitions/Endpoint'
        '500':
          description: Failed to update the endpoint
  /api/mappings/schema:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - mappings
      summary: Get all mapping schemas
      operationId: getMappingSchemas
      responses:
        '200':
          description: Mapping schemas
          schema:
            type: object
  /api/mappings:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - mappings
      summary: Get all mappings
      operationId: getMappings
      responses:
        '200':
          description: Array of mappings
          schema:
            type: array
            items:
              $ref: '#/definitions/Mapping'
        '500':
          description: Failed to list all mappings
  /api/mappings/{id}:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - mappings
      summary: Get one mapping by id
      operationId: getMapping
      responses:
        '200':
          description: Sucessfully got an Mapping
          schema:
            $ref: '#/definitions/Mapping'
        '500':
          description: Failed to get mapping
  /api/mappings/{id}/operation:
    put:
      security:
        - ApiKeyHeader: []
      tags:
        - mappings
      summary: Update an existing mapping
      operationId: updateMapping
      parameters:
        - in: body
          name: body
          description: Operation to perform on the mapping
          required: true
          schema:
            type: object
            required:
              - operation
            properties:
              operation:
                type: string
                enum:
                  - enable
                  - disable
      responses:
        '200':
          description: Updated mapping
          schema:
            $ref: '#/definitions/Mapping'
        '500':
          description: Failed to update the mapping
  /api/mappings/{id}/endpoint-topics:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - mappings
      summary: Get endpoint topics for a given mapping
      operationId: getMappingEndpointTopics
      responses:
        '200':
          description: Sucessfully got the Mapping endpoint topics
          schema:
            type: object
            additionalProperties:
              type: array
              items:
                type: string
        '500':
          description: Failed to get mapping endpoint topics
  /api/mappings/{id}/state:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - mappings
      summary: Get one mapping state by id
      operationId: getMappingState
      responses:
        '200':
          description: Sucessfully got an Mapping state
          schema:
            type: string
        '500':
          description: Failed to get mapping state
  /api/servers/schema:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - servers
      summary: Get all server schemas
      operationId: getServerSchemas
      responses:
        '200':
          description: Server schemas
          schema:
            type: object
  /api/servers:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - servers
      summary: Get all servers
      operationId: getServers
      responses:
        '200':
          description: Array of servers
          schema:
            type: array
            items:
              $ref: '#/definitions/Server'
        '500':
          description: Failed to list all servers
  /api/servers/{id}:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - servers
      summary: Get one server by id
      operationId: getServer
      responses:
        '200':
          description: Sucessfully got a Server
          schema:
            $ref: '#/definitions/Server'
        '404':
          description: Server not found
        '500':
          description: Failed to get server
  /api/servers/{id}/operation:
    put:
      security:
        - ApiKeyHeader: []
      tags:
        - servers
      summary: Update an existing servers
      operationId: updateServer
      parameters:
        - in: body
          name: body
          description: Operation to perform on the server
          required: true
          schema:
            type: object
            required:
              - operation
            properties:
              operation:
                type: string
                enum:
                  - enable
                  - disable
      responses:
        '200':
          description: Updated server
          schema:
            $ref: '#/definitions/Server'
        '500':
          description: Failed to update the server
  /api/servers/{id}/state:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - servers
      summary: Get one server state by id
      operationId: getServerState
      responses:
        '200':
          description: Sucessfully got a Server state
          schema:
            type: string
        '500':
          description: Failed to get server state
  /api/nodes:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - nodes
      summary: Get all nodes
      operationId: getNodes
      responses:
        '200':
          description: Array of nodes
          schema:
            type: array
            items:
              $ref: '#/definitions/Node'
        '500':
          description: Failed to list all nodes
  /api/nodes/{id}/state:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - nodes
      summary: Get one node state by id
      operationId: getNodeState
      responses:
        '200':
          description: Sucessfully got an Node state
          schema:
            type: string
        '500':
          description: Failed to get node state
  /api/topics:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - topics
      summary: Get all available topics
      operationId: getAvailableTopics
      responses:
        '200':
          description: Topics organized by their associated resources
          schema:
            type: object
            properties:
              endpoints:
                type: array
                items:
                  type: object
              mappings:
                type: array
                items:
                  type: object
              nodes:
                type: array
                items:
                  type: object
        '500':
          description: Failed to list all available topics
  /api/rule-engine/transform:
    post:
      security:
        - ApiKeyHeader: []
      tags:
        - rule-engine
        - transform
      summary: Execute rule engine transformation
      operationId: ruleEngineTransform
      parameters:
        - in: body
          name: body
          required: true
          schema:
            type: object
            properties:
              input:
                type: object
                description: The body being inputted for transformation
              transformation:
                type: object
                description: The transformation expression
                properties:
                  output:
                    type: object
                  error:
                    type: object
            required:
              - input
              - transformation
      responses:
        '200':
          description: Transformed output
          schema:
            type: object
        '500':
          description: Failed to transform input
definitions:
  Connection:
    type: object
    required:
      - id
      - currentState
      - targetState
      - connection
    properties:
      id:
        type: string
      currentState:
        type: string
        enum:
          - connecting
          - connected
          - disconnecting
          - disconnected
      targetState:
        type: string
        enum:
          - connected
          - disconnected
      connection:
        type: object
  Endpoint:
    type: object
    required:
      - id
      - currentState
      - targetState
      - connectionId
      - operation
      - address
    properties:
      id:
        type: string
      currentState:
        type: string
        enum:
          - enabling
          - enabled
          - disabling
          - disabled
      targetState:
        type: string
        enum:
          - enabled
          - disabled
      connectionId:
        type: string
      operation:
        type: string
      address:
        type: object
  Mapping:
    type: object
    properties:
      id:
        type: string
      currentState:
        type: string
        enum:
          - enabling
          - enabled
          - disabling
          - disabled
      targetState:
        type: string
        enum:
          - enabled
          - disabled
      mappings:
        type: array
        items:
          type: object
  Server:
    type: object
    required:
      - id
      - options
      - currentState
      - targetState
      - protocol
    properties:
      id:
        type: string
      options:
        type: object
      currentState:
        type: string
        enum:
          - enabling
          - enabled
          - disabling
          - disabled
      targetState:
        type: string
        enum:
          - enabled
          - disabled
      protocol:
        type: string
        enum:
          - Opcua
          - Http
  Node:
    type: object
    properties:
      id:
        type: string
      currentState:
        type: string
        enum:
          - enabling
          - enabled
          - disabling
          - disabled
      targetState:
        type: string
        enum:
          - enabled
          - disabled
      nodes:
        type: array
        items:
          type: object
