openapi: 3.1.0
info:
  title: API logistics_v1 1.0.0
  version: 1.0.0
servers:
- url: https://data.movemore.hs-offenburg.de/api/logistics/v1
paths:
  /health:
    get:
      description: Test if server is responsive.
      responses:
        "200":
          content:
            text/plain:
              schema:
                type: string
          description: Server healthy
        "404":
          description: Server not healty
  /tracker:
    get:
      description: Get Tracker by field value
      parameters:
      - explode: true
        in: query
        name: dev_eui
        required: false
        schema:
          type: integer
        style: form
      - explode: true
        in: query
        name: name
        required: false
        schema:
          type: string
        style: form
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Tracker"
          description: Tracker retrieved
        "404":
          description: Tracker does not exist
    put:
      description: |
        Create or or update Tracker

        If the object id is zero, the object is inserted and the new id is filled into the returned object.

        If the object id is non-zero, the object is updated and returned.
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Tracker"
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Tracker"
          description: Tracker updated
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Tracker"
          description: Tracker created
        "422":
          description: Tracker is invalid
  /tracker/{id}:
    delete:
      description: Delete Tracker by database id
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          type: integer
        style: simple
      responses:
        "204":
          description: Tracker deleted
        "404":
          description: Tracker does not exist
    get:
      description: Get Tracker by database id
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          type: integer
        style: simple
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Tracker"
          description: Tracker retrieved
        "404":
          description: Tracker does not exist
  /tracker/{id}/values:
    get:
      description: Get list of Measurement from Tracker by database id
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          type: integer
        style: simple
      responses:
        "200":
          content:
            application/json:
              schema:
                items:
                  $ref: "#/components/schemas/Measurement"
                type: array
                default: null
          description: List of Measurement retrieved
        "404":
          description: Tracker does not exist
    put:
      description: Add list of Measurement to Tracker by database id
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          type: integer
        style: simple
      requestBody:
        content:
          application/json:
            schema:
              items:
                $ref: "#/components/schemas/Measurement"
              type: array
              default: null
      responses:
        "200":
          description: Tracker updated
        "404":
          description: Tracker does not exist
        "422":
          description: Tracker is invalid
  /tracker_list:
    get:
      description: Get list of all Tracker
      responses:
        "200":
          content:
            application/json:
              schema:
                items:
                  $ref: "#/components/schemas/Tracker"
                type: array
                default: null
          description: List of Tracker retrieved
components:
  schemas:
    Measurement:
      example:
        accuracy: 0
        battery: 6
        button_triggered: 1
        gnss_error: true
        gnss_fix: true
        gw_latitude: 5.962134
        gw_longitude: 5.637377
        latitude: 2.302136
        longitude: 7.0614014
        moving_mode: 9
        temperature: 3
        timestamp: 2
      properties:
        accuracy:
          format: int32
          title: accuracy
          type: integer
        battery:
          format: int32
          title: battery
          type: integer
        button_triggered:
          format: int32
          title: button_triggered
          type: integer
        gnss_error:
          title: gnss_error
          type: boolean
        gnss_fix:
          title: gnss_fix
          type: boolean
        gw_latitude:
          format: float
          title: gw_latitude
          type: number
        gw_longitude:
          format: float
          title: gw_longitude
          type: number
        latitude:
          format: float
          title: latitude
          type: number
        longitude:
          format: float
          title: longitude
          type: number
        moving_mode:
          format: int32
          title: moving_mode
          type: integer
        temperature:
          format: int32
          title: temperature
          type: integer
        timestamp:
          description: Unix timestamp in milliseconds
          format: int64
          title: timestamp
          type: integer
      required:
      - accuracy
      - battery
      - button_triggered
      - gnss_error
      - gnss_fix
      - gw_latitude
      - gw_longitude
      - latitude
      - longitude
      - moving_mode
      - temperature
      - timestamp
      title: Measurement
    Tracker:
      example:
        dev_eui: 0
        id: 6
        name: name
      properties:
        dev_eui:
          description: The devEUI of the tracker
          format: int64
          title: dev_eui
          type: integer
        id:
          default: 0
          title: id
          type: integer
        name:
          title: name
          type: string
      required:
      - dev_eui
      - name
      title: Tracker
