openapi: 3.0.0
info:
  title: External Databus Configuration API
  version: 1.0.0
  description: |
    This API allows for the advanced configuration of the External Databus, including data persistence, user management, topic configuration, SSL/TLS certificates, and broker bridging.
  contact:
    name: Team Abhiyanta
  license:
    name: 'Industrial Edge © 2025, Siemens AG. All rights reserved.'

servers:
  - url: 'https://{IED IP}/externaldatabus-api-server/api/v1/'
    description: Application with network mode host
  - url: 'http://externaldatabus-api-server:8087/api/v1/'
    description: Application with proxy-redirect network
tags:
  - name: Persistency
    description: ""
  - name: Users
    description: ""
  - name: Topics
    description: ""
  - name: Certificates
    description: ""
  - name: Bridge
    description: ""
paths:
  /persistence:
    get:
      summary: Get data persistence configuration
      description: |-
        This endpoint allows you to retrieve the current data persistence configuration.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Persistency
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PersistenceConfig'
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30
    put:
      summary: Update data persistence configuration
      description: |-
        This endpoint allows you to update the data persistence configuration.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Persistency
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PersistenceConfig'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PersistenceConfig'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InvalidParams:
                  $ref: '#/components/examples/InvalidParams'
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30

  /users:
    get:
      summary: List all users
      description: |-
        This endpoint allows you to retrieve a list of all users.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Users
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Users'
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30
  /user:
    post:
      summary: Create a new user
      description: |-
        This endpoint allows you to create a new user.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Users
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewUser'
      responses:
        '201':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InvalidParams:
                  $ref: '#/components/examples/InvalidParams'
        '401':
          $ref: '#/components/responses/401'        
        '404':
          description: User already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                UserExistsError:
                  $ref: '#/components/examples/UserExistsError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30

  /user/{username}:
    get:
      summary: Get user details
      description: |-
        This endpoint allows you to retrieve the details of a specific user.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Users
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
        - in: path
          name: username
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/useravailable'
        '404':
          description: User not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                UserNotFound:
                  $ref: '#/components/examples/UserNotFound'
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30

  /topics:
    get:
      summary: List all topics
      description: |-
        This endpoint allows you to retrieve a list of all topics.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Topics
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Topic'
        '204':
          description: |-
            No Content
            - The query is valid, but there is no data that matches the query.
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30
    post:
      summary: Create a new topic
      description: |-
        This endpoint allows you to create a new topic.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Topics
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewTopic'
      responses:
        '201':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Topic'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InvalidParams:
                  $ref: '#/components/examples/InvalidParams'
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30

  /topic:
    get:
      summary: Get topic details
      description: |-
        This endpoint allows you to retrieve the details of a specific topic.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Topics
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
        - name: topicName
          in: query
          description: Get specific topic details
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Topic'
        '204':
          description: |-
            No Content
            - The query is valid, but there is no data that matches the query.
        '404':
          description: Topic not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30
    put:
      summary: Update topic details
      description: |-
        This endpoint allows you to update the details of a specific topic.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Topics
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
        - name: topicName
          in: query
          description: Update specific topic details
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTopic'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TopicAssociation'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InvalidParams:
                  $ref: '#/components/examples/InvalidParams'
        '401':
          $ref: '#/components/responses/401'        
        '404':
          description: Topic not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/TopicNotFound'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30
    delete:
      summary: Delete a topic
      description: |-
        This endpoint allows you to delete a specific topic.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Topics
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
        - name: topicName
          in: query
          description: Delete specific topic details
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeleteTopic'
      responses:
        '204':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Topic deleted successfully
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InvalidParams:
                  $ref: '#/components/examples/InvalidParams'
        '401':
          $ref: '#/components/responses/401'        
        '404':
          description: Topic not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/TopicNotFound'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30
  /certificates:
    get:
      summary: Get SSL/TLS certificate configuration
      description: |-
        This endpoint allows you to retrieve the current SSL/TLS certificate configuration.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Certificates
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CertificateConfig'
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30
    put:
      summary: Update SSL/TLS certificate configuration
      description: |-
        This endpoint allows you to update the SSL/TLS certificate configuration.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Certificates
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                certificateFile:
                  type: string
                  format: binary
                keyFile:
                  type: string
                  format: binary
                caCertificateFile:
                  type: string
                  format: binary
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CertificateConfig'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InvalidParams:
                  $ref: '#/components/examples/InvalidParams'
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30
    delete:
      summary: Delete SSL/TLS certificate configuration
      description: |-
        This endpoint allows you to delete the SSL/TLS certificate configuration.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Certificates
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      responses:
        '204':
          description: Successful response, but no content
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InvalidParams:
                  $ref: '#/components/examples/InvalidParams'
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30

  /bridges:
    get:
      summary: List all broker bridges
      description: |-
        This endpoint allows you to retrieve a list of all broker bridges.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Bridge
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/BridgeConfigGet'
        '204':
          description: |-
            No Content
            - The query is valid, but there is no data that matches the query.
        '401':
          $ref: '#/components/responses/401'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30
    post:
      summary: Create a new broker bridge
      description: |-
        This endpoint allows you to create a new broker bridge.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Bridge
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewBridgeConfig'
      responses:
        '201':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BridgeConfig'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InvalidParams:
                  $ref: '#/components/examples/InvalidParams'
        '401':
          $ref: '#/components/responses/401'
        '404':
          description: Topic not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/TopicNotFound'
        '409':
          description: Failed to add topic under the existing user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/BridgeConficted'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30
    delete:
      summary: Delete bridge configuration
      description: |-
        This endpoint allows you to delete the already configured bridge.
        
        **Note**: Authorization token can be fetched using https://{deviceIP}/device/edge/api/v2/login/direct.
      tags:
        - Bridge
      security:
        - APIKey: []
      parameters:
        - $ref: '#/components/parameters/Authorization'
      responses:
        '200':
          description: Successful response.
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InvalidParams:
                  $ref: '#/components/examples/InvalidParams'
        '401':
          $ref: '#/components/responses/401'
        '404':
          description: Bridge configuration not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InvalidParams:
                  $ref: '#/components/examples/BridgeNotFound'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                InternalServerError:
                  $ref: '#/components/examples/InternalServerError'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                ExampleServiceNotRunningError:
                  $ref: '#/components/examples/ExampleServiceNotRunningError'
          headers:
            Retry-After:
              description: Indicates how long (seconds) the client should wait before retrying the request.
              schema:
                type: integer
                format: int32
                example: 30

components:
  parameters:
    Authorization:
      name: Authorization
      in: header
      required: true
      schema:
        type: string
      description: Authorization token
  
  securitySchemes:
    APIKey:
      name: Authorization
      type: apiKey
      in: header
  schemas:

    PersistenceConfig:
      type: object
      properties:
        enabled:
          type: boolean
          description: Flag to enable/disable data persistence
        retentionPeriod:
          type: string
          enum: ['5m', '1h', '1d']
          default: '5m'

    Users:
      type: object
      properties:
        username:
          type: string
      example:
        username: edgeuser

    User:
      type: object
      properties:
        username:
          type: string
        message:
          type: string
      example:
        username: edgeuser
        message: User is added successfully

    useravailable:
      type: object
      properties:
        userexists:
          type: boolean
      example:
        userexists: true

    NewUser:
      type: object
      required:
        - username
        - password
      properties:
        username:
          type: string
        password:
          type: string
      example:
        username: edgeuser
        password: encodedpw

    Topic:
      type: object
      properties:
        username:
          type: string
          example: edgeuser
        topics:
          type: array
          items:
            $ref: '#/components/schemas/TopicPermissions'

    TopicPermissions:
      type: object
      properties:
        topic:
          type: string
        permissions:
          type: object
          properties:
            subscribe:
              type: boolean
            publish&subscribe:
              type: boolean
      example:
        topic: '/edge/xtb/newtopic'
        subscribe: true
        publish&subscribe: true


    NewTopic:
      type: object
      required:
        - username
        - password
        - topics
      properties:
        username:
          type: string
        password:
          type: string
        topics:
          type: array
          items:
            type: object
            required:
              - topicName
              - subscribe
              - publish&subscribe
            properties:
              topicName:
                type: string
              subscribe:
                type: boolean
              publish&subscribe:
                type: boolean
      example:
        username: edgeuser
        password: encodedpw
        topics:
          - topicName: '/edge/xtb/newtopic'
            subscribe: true
            publish&subscribe: true


    UpdateTopic:
      type: object
      required:
        - username
        - password
        - topics
      properties:
        username:
          type: string
        password:
          type: string
        topics:
          type: array
          items:
            type: object
            required:
              - topicName
              - subscribe
              - publish&subscribe
            properties:
              topicName:
                type: string
              subscribe:
                type: boolean
              publish&subscribe:
                type: boolean
      example:
        username: edgeuser
        password: encodedpw
        topics:
          - topicName: '/edge/xtb/updatetopic'
            subscribe: true
            publish&subscribe: true

    DeleteTopic:
      type: object
      required:
        - username
        - password
      properties:
        username:
          type: string
        password:
          type: string
      example:
        username: edgeuser
        password: encodedpw

    TopicAssociation:
      type: object
      required:
        - username
        - topic
        - permissions
      properties:
        username:
          type: string
        topic:
          type: string
        permissions:
          type: object
          properties:
            subscribe:
              type: boolean
            publish&subscribe:
              type: boolean
      example:
        username: edgeuser
        topic: '/edge/xtb/existingtopic'
        subscribe: true
        publish&subscribe: true

    CertificateConfig:
      type: object
      properties:
        enabled:
          type: boolean
        certificateFile:
          type: string
          format: binary
        keyFile:
          type: string
          format: binary
        caCertificateFile:
          type: string
          format: binary
      example:
        certificateFile: encodedcertificatestream
        keyFile: encodedkeystream
        caCertificateFile: encodedcacertstream
    BridgeConfigGet:
      type: object
      required:
      - username
      - topic
      - direction
      properties:
        username:
          type: string
          example: edgeuser
        topic:
          type: string
          example: '/edge/xtb/existingtopic'
        direction:
          type: string
          enum: ['in', 'out']
          example: 'in'

    BridgeConfig:
      type: object
      required:
      - username
      - topic
      - direction
      properties:
        username:
          type: string
          example: edgeuser
        topic:
          type: string
          example: '/edge/xtb/existingtopic'
        direction:
          type: string
          enum: ['in', 'out']
          example: 'in'
        message:
          type: string
          example: 'Topic updated successfully to the existing bridge configuration.'

    NewBridgeConfig:
      type: object
      required:
        - username
        - password
      properties:
        username:
          type: string
          example: edgeuser
        password:
          type: string  
          example: encodedpw      
        topic:
          type: string
          example: '/edge/xtb/existingtopic'
        direction:
          type: string
          enum: ['in', 'out']
          example: 'in'
    Error:
      title: Error
      type: object
      description: An error object containing a code, message, and unique identifier (logref).
      properties:
        code:
          type: string
          minLength: 2
        logref:
          type: string
          format: uuid
          minLength: 1
          description: Unique identifier for each error
        message:
          type: string
          minLength: 1
      required:
        - code
        - message
    ErrorResponse:
      title: ErrorResponse
      description: An object containing an array of error objects.
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/Error'
  examples:
    InternalServerError:
      value:
        errors:
          - code: edge.internalServerError
            logref: c105072b-39cb-49d9-999f-3873b10e3db1
            message: The server encountered an unknown error.
    ExampleServiceNotRunningError:
      value:
        errors:
          - code: edge.serviceNotRunning
            logref: c105072b-39cb-49d9-999f-3873b10e3db1
            message: Job service process is not running.
    ExpiredToken:
      value:
        errors:
          - code: edge.auth.expiredToken
            message: Token expired.
            logref: 5432e1d8-5916-4619-88ec-a507f83331bd
    InvalidToken:
      value:
        errors:
          - code: edge.auth.invalidToken
            message: Token is invalid.
            logref: 5432e1d8-5916-4619-88ec-a507f83331bd
    MissingToken:
      value:
        errors:
          - code: edge.auth.missingToken
            message: Token is required.
            logref: 3505f6bd-30cd-4deb-981d-02e89f82aa8f
    TokenUserNotFound:
      value:
        errors:
          - code: auth.application.userNotFound
            message: User not found.
            logref: 5432e1d8-5916-4619-88ec-a507f83331bd
    UnableToVerifyToken:
      value:
        errors:
          - code: auth.token.unableToVerifyToken
            message: Unable to verify token.
            logref: 5432e1d8-5916-4619-88ec-a507f83331bd
    MissingMandatoryParam:
      value:
        errors:
          - code: edge.missingMandatoryParam
            message: Mandatory body parameter/parameters Missing
            logref: c105072b-39cb-49d9-999f-3873b10e3db1
    InvalidParams:
      value:
        errors:
          - code: edge.invalidParams
            message: Parameter/parameters value is wrong.
            logref: 3fa85f64-5717-4562-b3fc-2c963f66afa6
    TopicNotFound:
      value:
        errors:
          - code: edge.topicnotfound
            message: Topic not available under the given user.
            logref: 3fa85f64-5717-4562-b3fc-2c963f65a8r6
    UserExistsError:
      value:
        errors:
          - code: edge.userexists
            message: User already exists.
            logref: 3fa85f64-5717-4562-b3fc-2c963f65a85t
    UserNotFound:
      value:
        errors:
          - code: edge.usernotfound
            message: User not found.
            logref: 3fa85f64-5717-4562-b3fc-2c963f65a8ul
    BridgeNotFound:
      value:
        errors:
          - code: edge.notfound
            message: No bridge configuration found.
            logref: fae50796-3922-4420-aeab-2582fc05dd96
    BridgeConficted:
      value:
        errors:
          - code: edge.bridgeconfigfailed
            message: Failed to configure bridge.
            logref: fae50796-3922-4420-aeab-2582fc05dd96

  responses:
    '401':
      description: |-
        Unauthorized:
        - Missing the auth token
        - Invalid auth token
        - Expired auth token
        - User not found
        - Unable to verify token
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            MissingTokenError:
              $ref: '#/components/examples/MissingToken'
            InvalidTokenError:
              $ref: '#/components/examples/InvalidToken'
            ExpiredTokenError:
              $ref: '#/components/examples/ExpiredToken'
            TokenUserNotFoundError:
              $ref: '#/components/examples/TokenUserNotFound'
            UnableToVerifyTokenError:
              $ref: '#/components/examples/UnableToVerifyToken'