---
openapi: 3.0.0
info:
  title: Process Assurance Runtime API
  description: Test
  version: 0.0.1
servers:
  - url: http://localhost:8082/api

# Paths supported by the server application
paths:

  /metadata:
    get:
      operationId: po_runtime.compute_unit_manager.get_metadata
      tags:
        - Metadata
      description: returns the metadata that explains how to consume the compute unit
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Metadata'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                example:
                  message: The number of inputs to the prediction model doesn't match with n_parameters
                properties:
                  message:
                    type: string
                    description: Contains the message that clarifies the error

  /result:
    post:
      operationId: po_runtime.compute_unit_manager.resolve
      tags:
        - Technique
      summary: request for running a runtime component passing a configuration body
      description: request for running a runtime component passing a configuration body
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Config'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                example:
                  message: successfully executed the model
                properties:
                  message:
                    type: string
                    description: Contains the success message
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                example:
                  message: The number of inputs to the prediction model doesn't match with n_parameters
                properties:
                  message:
                    type: string
                    description: Contains the message that clarifies the error
                    

  /get_subscriptions:
    get:
      operationId: po_runtime.subscription_manager.get_subscriptions
      summary: returns all message-bus subscriptions for the current user
      description: returns subscription configuration
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
                example: {"todo"}
                properties:
                    optimum_parameters:
                        type: array
                        description: returns uri of all connected po-runtimes
        400:
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                example: {message: "URI not valid"}
                properties:
                    message:
                        type: string
                        description: Contains the message that clarifies the error                   

  /delete_subscription/{idx}:
    get:
      operationId: po_runtime.subscription_manager.delete_subscription
      summary: removes subscription
      description: removes subscription 
      parameters:
        - in: path 
          name: idx 
          schema:
            type: string
            example: 5f23e89c58c8f61b47767708 
          required: true
          description: ID of the subscription to be removed
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
                example: {"todo"}
                properties:
                    optimum_parameters:
                        type: array
                        description: returns remaining subscriptions
        400:
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                example: {message: "ID not valid"}
                properties:
                    message:
                        type: string
                        description: Contains the message that clarifies the error                   

  /add_subscription:
    post:
      operationId: po_runtime.subscription_manager.add_subscription
      summary: add subscription
      description: todo
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Config'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                example:
                  message: successfully executed the model
                properties:
                  message:
                    type: string
                    description: Contains the success message
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                example:
                  message: The number of inputs to the prediction model doesn't match with n_parameters
                properties:
                  message:
                    type: string
                    description: Contains the message that clarifies the error


components:
  schemas:
    InputOuput:
      required:
      - id
      - format
      type: object
      properties:
        id:
          type: string
          description: Identifier of the input or output parameter, specified in the metadata of the component
        format:
          type: string
          description: specifies the format of the input or output data parameter. Accepted formats are collection, file/csv and database/mongo
        filename:
          type: string
          description: for file formatted parameters, specifies the file name of the file containing the input data
        mongo-collection:
          type: string
          description: for database/mongo inputs, specifies the collection used to fetch the data
        collection:
          type: object
          description: Collection of data items for data parameters of type collection
        indices:
          type: string
          description: object that maps the names of fields and name of indices in the model
        message-topic:
          type: string
          description: string that specifies the topic to subscribe or publish on message bus
    Metadata:
      required:
        - id
        - name
      type: object
      properties:
        id:
          type: integer
          description: the unique identifier for algorithm
          format: int32
        name:
          type: string
          description: name of the technique
        description:
          type: string
          description: description of the technique
        technique:
          type: string
          enum:
            - prediction
            - optimisation
            - simulation
        module_name:
          type: string
          description: name of the module into the layer

        complexity:
          type: string
          default: medium
          enum:
            - low
            - medium
            - high
        accuracy:
          type: string
          default: medium
          enum:
            - low
            - medium
            - high
        interpretability:
          type: string
          default: medium
          enum:
            - low
            - medium
            - high
        inputs:
          type: array
          items:
            $ref: '#/components/schemas/IO_Metadata'
        outputs:
          type: array
          items:
            $ref: '#/components/schemas/IO_Metadata'
        module_params:
          type: array
          description: parameters used to configure the model execution
          items:
            $ref: '#/components/schemas/IO_Metadata'
        taxonomyCategory:
          type: array
          description: array of entries that classify the model into de ZDMP taxonomy
          items:
            $ref: '#/components/schemas/TaxonomyEntry'
      description: algorithms in the repository that can be used in a ZDM solution
    Config:
      required:
        - inputs
        - outputs
      type: object
      properties:
        module_parameters:
          type: array
          items:
            $ref: '#/components/schemas/InputOuput'
        inputs:
          type: array
          items:
            $ref: '#/components/schemas/InputOuput'
        outputs:
          type: array
          items:
            $ref: '#/components/schemas/InputOuput'
    IO_Metadata:
      required:
        - id
        - name
        - type
      type: object
      properties:
        id:
          type: integer
          description: the unique identifier for ZDM table (input or output)
          format: int32
        name:
          type: string
        type:
          type: string
          default: double
          enum:
            - int
            - string
            - float
            - double
            - boolean
      description: zdm table attribute (input or output)
    TaxonomyEntry:
      required:
        - type
        - id
        - name
      type: object
      properties:
        id:
          type: integer
          description: the unique identifier for taxonomy entry
          format: int32
        name:
          type: string
        type:
          type: string
          default: Domain
          enum:
            - Domain
            - Solution
            - Problem
            - Technique
        children:
          type: array
          items:
            $ref: '#/components/schemas/TaxonomyEntry'
      description: taxonomy entries to categorize ZDM solutions