/api/edge/result:
  post:
    tags: [Edge API]
    summary: Receive results from instrument (tiny-edge)
    description: |
      Receives instrument results and stores them in the edgeres table for processing.
      This endpoint is typically called by the tiny-edge middleware connected to laboratory analyzers.
    requestBody:
      required: true
      content:
        application/json:
          schema:
            $ref: '../components/schemas/edge-api.yaml#/EdgeResultRequest'
    responses:
      '201':
        description: Result received and queued
        content:
          application/json:
            schema:
              $ref: '../components/schemas/edge-api.yaml#/EdgeResultResponse'
      '400':
        description: Invalid JSON payload

/api/edge/order:
  get:
    tags: [Edge API]
    summary: Fetch pending orders for instruments
    description: Returns orders that need to be sent to laboratory instruments for testing
    parameters:
      - name: instrument_id
        in: query
        schema:
          type: string
        description: Filter by instrument
      - name: status
        in: query
        schema:
          type: string
        enum: [pending, acknowledged]
        description: Filter by status
    responses:
      '200':
        description: List of orders
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                data:
                  type: array
                  items:
                    $ref: '../components/schemas/edge-api.yaml#/EdgeOrder'

/api/edge/order/{orderId}/ack:
  post:
    tags: [Edge API]
    summary: Acknowledge order delivery
    description: Mark order as acknowledged by the instrument
    parameters:
      - name: orderId
        in: path
        required: true
        schema:
          type: integer
        description: Edge order ID
    responses:
      '200':
        description: Order acknowledged
        content:
          application/json:
            schema:
              $ref: '../components/schemas/common.yaml#/SuccessResponse'

/api/edge/status:
  post:
    tags: [Edge API]
    summary: Log instrument status update
    description: Receive status updates from laboratory instruments
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            required:
              - instrument_id
              - status
            properties:
              instrument_id:
                type: string
              status:
                type: string
                enum: [online, offline, error, maintenance]
              message:
                type: string
              timestamp:
                type: string
                format: date-time
    responses:
      '200':
        description: Status logged
