components:
  content:
    automatedNavigationState:
      schema:
        properties:
          mode:
            $ref: shared.yaml#/components/schemas/automatedNavigationState
        required:
          - mode
        type: object
  pathParameters:
    key:
      examples:
        1:
          value: 1
        2:
          value: 2
        3:
          value: 3
        4:
          value: 4
        5:
          value: 5
        6:
          value: 6
      in: path
      name: key
      schema:
        $ref: shared.yaml#/components/schemas/streamdeckKeyId
    uuid:
      description: This unique Id determines the target of a given command
      examples:
        25cf9853-3a37-4f99-8547-fb11d85887e9:
          value: 25cf9853-3a37-4f99-8547-fb11d85887e9
        4759336b-a08d-494b-ab21-50ff70d18cb5:
          value: 4759336b-a08d-494b-ab21-50ff70d18cb5
        df855ecb-c219-43a3-9202-410e3e5a0253:
          value: df855ecb-c219-43a3-9202-410e3e5a0253
      in: path
      name: uuid
      required: true
      schema:
        $ref: shared.yaml#/components/schemas/deviceId
  responses:
    AlreadyExistsError:
      description: The resource already exists
    LabeledPositionNotFoundError:
      description: The specified labeled position was not found
    LoginFailedError:
      description: Login was not successful
    MachineNotFoundError:
      description: The specified machine was not found
    NoAccessError:
      description: "The request could not be processed, because you have no access to do this.  \n\nSee errormessage for details"
    NotFoundError:
      description: ran into an error while executing the result
    ParameterNotFoundError:
      description: |-
        The request could not be processed, are all required properties/parameters filled?

        See errormessage for details
    UnauthorizedError:
      description: You're not authorized! You need to provide authentication
  schemas:
    filename:
      examples:
        - rexasipro.gif
      format: filename
      type: string
    navigationTarget:
      properties:
        orientation:
          type: number
        reason:
          $ref: '#/components/schemas/commandReason'
        x:
          type: number
        y:
          type: number
      type: object
    uuid:
      examples:
        - 52964e20-2441-46da-a279-b60d179294f3
        - 25cf9853-3a37-4f99-8547-fb11d85887e9
      format: uuid
      type: string
  securitySchemes:
    authkey:
      description: The Authkey needed
      in: query
      name: auth
      type: apiKey
info:
  description: |-
    This is the documentation for the REXASI-PRO Orchestrator.

    **NOTE**: Commit: c2d59e1 Date: 2024.07.03_10:54:52
  title: REXASI-PRO Orchestrator
  version: 1.0.0
openapi: 3.0.2
paths:
  /device/{uuid}/automatedNavigation:
    get:
      parameters:
        - $ref: '#/components/pathParameters/uuid'
      responses:
        "200":
          content:
            application/json:
              $ref: '#/components/content/automatedNavigationState'
          description: Returns the current automated navigation mode
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "403":
          $ref: '#/components/responses/NoAccessError'
        "404":
          $ref: '#/components/responses/MachineNotFoundError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
    post:
      description: Change the automatic navigation mode
      parameters:
        - $ref: '#/components/pathParameters/uuid'
      requestBody:
        content:
          application/json:
            $ref: '#/components/content/automatedNavigationState'
      responses:
        "204":
          description: Command received successfully
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "403":
          $ref: '#/components/responses/NoAccessError'
        "404":
          $ref: '#/components/responses/MachineNotFoundError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
      security:
        - authkey:
            - user
      tags:
        - wheelchair
  /device/{uuid}/computePath:
    post:
      description: Computes a path the given target
      parameters:
        - $ref: '#/components/pathParameters/uuid'
      requestBody:
        content:
          application/json:
            schema:
              properties:
                nominalSpeed:
                  $ref: shared.yaml#/components/schemas/speed
                pose:
                  $ref: shared.yaml#/components/schemas/pose
                targetPoint:
                  description: set of target points. If more than one the orchestrator will choose the best one
                  items:
                    $ref: shared.yaml#/components/schemas/pose
                  minItems: 1
                  type: array
                timestamp:
                  description: Timestamp of pose.
                  format: date-time
                  type: string
              required:
                - pose
                - targetPoint
              type: object
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                properties:
                  globalPath:
                    description: sequence of waypoints to visit, the last one is the target point
                    items:
                      $ref: shared.yaml#/components/schemas/pose
                    type: array
                  wheelchairID:
                    $ref: shared.yaml#/components/schemas/deviceId
                required:
                  - globalPath
                type: object
          description: path computed successfully.
        "400":
          content:
            application/json:
              schema:
                properties:
                  errorMessage:
                    description: description of the error
                    type: string
                  unknownField:
                    description: set of unknown fields
                    items:
                      description: name of the fields
                      type: string
                    type: array
                type: object
          description: Invalid request. To be detailed.
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "404":
          $ref: '#/components/responses/MachineNotFoundError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
      tags:
        - wheelchair
        - drone
  /device/{uuid}/maxSpeed:
    get:
      description: Get the current maximum speed of a device
      parameters:
        - $ref: '#/components/pathParameters/uuid'
      responses:
        "200":
          #description: Command received successfully
          content:
            application/json:
              schema:
                properties:
                  speed:
                    $ref: shared.yaml#/components/schemas/speed
                required:
                  - speed
                type: object
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "403":
          $ref: '#/components/responses/NoAccessError'
        "404":
          $ref: '#/components/responses/MachineNotFoundError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
      security:
        - authkey:
            - user
      tags:
        - wheelchair
        - drone
    post:
      description: Change the maximum speed of a device
      parameters:
        - $ref: '#/components/pathParameters/uuid'
      requestBody:
        content:
          application/json:
            schema:
              properties:
                speed:
                  $ref: shared.yaml#/components/schemas/speed
              required:
                - speed
              type: object
      responses:
        "204":
          description: Command received successfully
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "403":
          $ref: '#/components/responses/NoAccessError'
        "404":
          $ref: '#/components/responses/MachineNotFoundError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
      security:
        - authkey:
            - user
      tags:
        - wheelchair
        - drone
  /device/{uuid}/pose:
    get:
      description: |-
        Get the current position of the entity.
        Should be cached from the async api status [see here](/asyncstudio.html?url=/wheelchair-mqtt.yaml&readOnly=true#operation-publish-/device/{deviceId}/pose/status)
      parameters:
        - $ref: '#/components/pathParameters/uuid'
      responses:
        "200":
          #description: Command received successfully
          content:
            application/json:
              $ref: shared.yaml#/components/content/pose
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "403":
          $ref: '#/components/responses/NoAccessError'
        "404":
          $ref: '#/components/responses/MachineNotFoundError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
      security:
        - authkey:
            - user
      tags:
        - wheelchair
        - drone
  /device/{uuid}/route:
    get:
      description: Get the list of (still to cross) poses to reach the final goal
      parameters:
        - $ref: '#/components/pathParameters/uuid'
      responses:
        "200":
          #description: Command received successfully
          content:
            application/json:
              $ref: shared.yaml#/components/content/route
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "403":
          $ref: '#/components/responses/NoAccessError'
        "404":
          $ref: '#/components/responses/MachineNotFoundError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
      security:
        - authkey:
            - user
      tags:
        - wheelchair
        - drone
    post:
      description: |-
        This will set a (new) sequence of poses as the navigation goal of the device.
        If there are multiple poses the resulting path will lead through all poses in the order given.
      parameters:
        - $ref: '#/components/pathParameters/uuid'
      requestBody:
        content:
          application/json:
            $ref: shared.yaml#/components/content/route
      responses:
        "204":
          description: Command received successfully
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "403":
          $ref: '#/components/responses/NoAccessError'
        "404":
          $ref: '#/components/responses/MachineNotFoundError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
      security:
        - authkey:
            - user
      summary: Sends the device on a path to the last position while using each point as a waypoint
      tags:
        - wheelchair
        - drone
  /device/{uuid}/stop:
    post:
      description: Engage or disengage the emergency stop.
      parameters:
        - $ref: '#/components/pathParameters/uuid'
      requestBody:
        content:
          application/json:
            examples:
              continue:
                value:
                  stop: false
              danger:
                value:
                  reason: Dangerous obstacle around the corner
                  stop: true
            schema:
              properties:
                reason:
                  $ref: '#/components/schemas/commandReason'
                stop:
                  description: |-
                    Whether the stop should engage or the system can resume normally

                    True: Stops the device in a safe manner as soon as possible
                    False: Resume normal operation
                  type: boolean
              required:
                - stop
              type: object
      responses:
        "204":
          description: Command received successfully
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "403":
          $ref: '#/components/responses/NoAccessError'
        "404":
          $ref: '#/components/responses/MachineNotFoundError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
      security:
        - authkey:
            - user
      tags:
        - wheelchair
        - drone
  /device/{uuid}/streamdeck/key_{key}/file:
    get:
      description: Get the image file to be displayed on the given {key}
      parameters:
        - $ref: '#/components/pathParameters/uuid'
        - $ref: '#/components/pathParameters/key'
      responses:
        "200":
          content:
            application/json:
              schema:
                properties:
                  file:
                    $ref: '#/components/schemas/filename'
                type: object
          description: The shown filename
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
      security:
        - authkey:
            - user
      summary: Get the image displayed on the button if the key is not pressed
      tags:
        - streamdeck
    post:
      description: |-
        Set the image file to be displayed on the given {key}

        **NOTE**: Should be forwarded to /device/{uuid}/streamdeck/key_{key}/file
      parameters:
        - $ref: '#/components/pathParameters/uuid'
        - $ref: '#/components/pathParameters/key'
      requestBody:
        content:
          application/json:
            schema:
              properties:
                file:
                  $ref: '#/components/schemas/filename'
              type: object
      responses:
        "200":
          description: Request was forwarded
        "401":
          $ref: '#/components/responses/UnauthorizedError'
        "422":
          $ref: '#/components/responses/ParameterNotFoundError'
      security:
        - authkey:
            - user
      summary: Sets the image displayed on the button if the key is not pressed
      tags:
        - streamdeck
  /system/alive:
    get:
      description: Check if the system is still responsive (health check)
      responses:
        "200":
          description: everything okay
      summary: Healthcheck api
      tags:
        - server
  /system/stop:
    get:
      description: <br/>
      responses:
        "200":
          description: everything okay
        "401":
          description: auth failed
      security:
        - authkey:
            - admin
      summary: This will be used to stop the program
      tags:
        - server
    post:
      description: <br/>
      responses:
        "200":
          description: everything okay
        "401":
          description: auth failed
      security:
        - authkey:
            - admin
      summary: This will be used to stop the program
      tags:
        - server
servers:
  - description: Current Host
    url: http://localhost:5000
  - description: Local Test
    url: http://localhost:5000
