openapi: 3.0.0
info:
  title: RES LEVIS API
  description: API for RES LEVIS project
  contact:
    email: info@reslevis.com
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.4
servers:
- url: http://192.168.1.3/reslevis
  description: Res Levis
- url: https://webhook.site/014887a9-bfa4-48a8-a349-935d8f8f8096
  description: Res Levis Webhook
tags:
- name: Admins
  description: Secured Admin-only calls
- name: Developers
  description: Operations available to regular developers
paths:
  /getBuildings:
    get:
      tags:
      - Developers
      summary: Get the buildings
      description: |
        Get the buildings
      operationId: getBuildings
      parameters:
      - name: id
        in: query
        description: id of the item to get
        required: false
        schema:
          type: string
      - name: searchString
        in: query
        description: pass an optional search string for looking up inventory
        required: false
        schema:
          type: string
      - name: skip
        in: query
        description: number of records to skip for pagination
        required: false
        schema:
          minimum: 0
          type: integer
          format: int32
      - name: limit
        in: query
        description: maximum number of records to return
        required: false
        schema:
          maximum: 1000
          minimum: 0
          type: integer
          format: int32
      responses:
        "200":
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/BuildingItem"
        "400":
          description: bad input parameter
    servers:
    - url: ""
      description: ""
  /postBuilding:
    post:
      tags:
      - Developers
      summary: Post a building item
      description: Post a building
      operationId: postBuilding
      requestBody:
        description: plan item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BuildingItem"
      responses:
        "201":
          description: item created
        "400":
          description: "invalid input, object invalid"
        "409":
          description: an existing item already exists
    servers:
    - url: ""
      description: ""
  /removeBuilding:
    post:
      tags:
      - Developers
      summary: Remove a building item
      description: Remove a building
      operationId: removeBuilding
      requestBody:
        description: plan item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/removeItem"
      responses:
        "201":
          description: item removed
        "400":
          description: "invalid input, object invalid"
        "409":
          description: the item can't be removed
    servers:
    - url: ""
      description: ""
  /getPlans:
    get:
      tags:
      - Developers
      summary: Get the plans
      description: |
        Get the plans
      operationId: getPlans
      parameters:
      - name: id
        in: query
        description: id of the item to get
        required: false
        schema:
          type: string
      - name: searchString
        in: query
        description: pass an optional search string for looking up inventory
        required: false
        schema:
          type: string
      - name: skip
        in: query
        description: number of records to skip for pagination
        required: false
        schema:
          minimum: 0
          type: integer
          format: int32
      - name: limit
        in: query
        description: maximum number of records to return
        required: false
        schema:
          maximum: 1000
          minimum: 0
          type: integer
          format: int32
      responses:
        "200":
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/PlanItem"
        "400":
          description: bad input parameter
    servers:
    - url: ""
      description: ""
  /postPlan:
    post:
      tags:
      - Developers
      summary: Post a plan item
      description: Post a plan
      operationId: postPlan
      requestBody:
        description: plan item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PlanItem"
      responses:
        "201":
          description: item created
        "400":
          description: "invalid input, object invalid"
        "409":
          description: an existing item already exists
    servers:
    - url: ""
      description: ""
  /removePlan:
    post:
      tags:
      - Developers
      summary: Remove a plan item
      description: Remove a plan
      operationId: removePlan
      requestBody:
        description: plan item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/removeItem"
      responses:
        "201":
          description: item removed
        "400":
          description: "invalid input, object invalid"
        "409":
          description: the item can't be removed
    servers:
    - url: ""
      description: ""
  /getZones:
    get:
      tags:
      - Developers
      summary: Get the zones
      description: |
        Get the zones
      operationId: getZones
      parameters:
      - name: id
        in: query
        description: id of the item to get
        required: false
        schema:
          type: string
      - name: searchString
        in: query
        description: pass an optional search string for looking up inventory
        required: false
        schema:
          type: string
      - name: skip
        in: query
        description: number of records to skip for pagination
        required: false
        schema:
          minimum: 0
          type: integer
          format: int32
      - name: limit
        in: query
        description: maximum number of records to return
        required: false
        schema:
          maximum: 1000
          minimum: 0
          type: integer
          format: int32
      responses:
        "200":
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/ZoneItem"
        "400":
          description: bad input parameter
    servers:
    - url: ""
      description: ""
  /postZone:
    post:
      tags:
      - Developers
      summary: Post a zone item
      description: Post a zone item
      operationId: postZone
      requestBody:
        description: zone item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ZoneItem"
      responses:
        "201":
          description: item created
        "400":
          description: "invalid input, object invalid"
        "409":
          description: an existing item already exists
    servers:
    - url: ""
      description: ""
  /removeZone:
    post:
      tags:
      - Developers
      summary: Remove a plan item
      description: Remove a plan
      operationId: removeZone
      requestBody:
        description: zone item to be removed
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/removeItem"
      responses:
        "201":
          description: item removed
        "400":
          description: "invalid input, object invalid"
        "409":
          description: the item can't be removed
    servers:
    - url: ""
      description: ""
  /getGateways:
    get:
      tags:
      - Developers
      summary: Get the gateways
      description: |
        Get the gateways
      operationId: getGateways
      parameters:
      - name: id
        in: query
        description: id of the item to get
        required: false
        schema:
          type: string
      - name: searchString
        in: query
        description: pass an optional search string for looking up inventory
        required: false
        schema:
          type: string
      - name: skip
        in: query
        description: number of records to skip for pagination
        required: false
        schema:
          minimum: 0
          type: integer
          format: int32
      - name: limit
        in: query
        description: maximum number of records to return
        required: false
        schema:
          maximum: 1000
          minimum: 0
          type: integer
          format: int32
      responses:
        "200":
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/GatewayItem"
        "400":
          description: bad input parameter
    servers:
    - url: ""
      description: ""
  /postGateway:
    post:
      tags:
      - Developers
      summary: Post a gateway item
      description: Post a gateway item
      operationId: postGateway
      requestBody:
        description: gateway item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/GatewayItem"
      responses:
        "201":
          description: item created
        "400":
          description: "invalid input, object invalid"
        "409":
          description: an existing item already exists
    servers:
    - url: ""
      description: ""
  /removeGateway:
    post:
      tags:
      - Developers
      summary: Remove a gateway item
      description: Remove a gateway
      operationId: removeGateway
      requestBody:
        description: gateway item to be removed
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/removeItem"
      responses:
        "201":
          description: item removed
        "400":
          description: "invalid input, object invalid"
        "409":
          description: the item can't be removed
    servers:
    - url: ""
      description: ""
  /getTrackers:
    get:
      tags:
      - Developers
      summary: Get the trackers
      description: |
        Get the trackers
      operationId: getTrackers
      parameters:
      - name: id
        in: query
        description: id of the item to get
        required: false
        schema:
          type: string
      - name: searchString
        in: query
        description: pass an optional search string for looking up inventory
        required: false
        schema:
          type: string
      - name: skip
        in: query
        description: number of records to skip for pagination
        required: false
        schema:
          minimum: 0
          type: integer
          format: int32
      - name: limit
        in: query
        description: maximum number of records to return
        required: false
        schema:
          maximum: 1000
          minimum: 0
          type: integer
          format: int32
      responses:
        "200":
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/TrackerItem"
        "400":
          description: bad input parameter
    servers:
    - url: ""
      description: ""
  /postTracker:
    post:
      tags:
      - Developers
      summary: Post a tracker item
      description: Post a tracker item
      operationId: postTracker
      requestBody:
        description: tracker item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TrackerItem"
      responses:
        "201":
          description: item created
        "400":
          description: "invalid input, object invalid"
        "409":
          description: an existing item already exists
    servers:
    - url: ""
      description: ""
  /removeTracker:
    post:
      tags:
      - Developers
      summary: Remove a tracker item
      description: Remove a tracker
      operationId: removeTracker
      requestBody:
        description: tracker item to be removed
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/removeItem"
      responses:
        "201":
          description: item removed
        "400":
          description: "invalid input, object invalid"
        "409":
          description: the item can't be removed
    servers:
    - url: ""
      description: ""
  /getOperators:
    get:
      tags:
      - Developers
      summary: Get the operators
      description: |
        Get the operators
      operationId: getOperators
      parameters:
      - name: id
        in: query
        description: id of the item to get
        required: false
        schema:
          type: string
      - name: searchString
        in: query
        description: pass an optional search string for looking up inventory
        required: false
        schema:
          type: string
      - name: skip
        in: query
        description: number of records to skip for pagination
        required: false
        schema:
          minimum: 0
          type: integer
          format: int32
      - name: limit
        in: query
        description: maximum number of records to return
        required: false
        schema:
          maximum: 1000
          minimum: 0
          type: integer
          format: int32
      responses:
        "200":
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/OperatorItem"
        "400":
          description: bad input parameter
    servers:
    - url: ""
      description: ""
  /postOperator:
    post:
      tags:
      - Developers
      summary: Post an operator item
      description: Post an operator item
      operationId: postOperator
      requestBody:
        description: operator item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OperatorItem"
      responses:
        "201":
          description: item created
        "400":
          description: "invalid input, object invalid"
        "409":
          description: an existing item already exists
    servers:
    - url: ""
      description: ""
  /removeOperator:
    post:
      tags:
      - Developers
      summary: Remove an operator item
      description: Remove an operator
      operationId: removeOperator
      requestBody:
        description: operator item to be removed
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/removeItem"
      responses:
        "201":
          description: item removed
        "400":
          description: "invalid input, object invalid"
        "409":
          description: the item can't be removed
    servers:
    - url: ""
      description: ""
  /getSubjects:
    get:
      tags:
      - Developers
      summary: Get the subjects
      description: |
        Get the subjects
      operationId: getSubjects
      parameters:
      - name: id
        in: query
        description: id of the item to get
        required: false
        schema:
          type: string
      - name: searchString
        in: query
        description: pass an optional search string for looking up inventory
        required: false
        schema:
          type: string
      - name: skip
        in: query
        description: number of records to skip for pagination
        required: false
        schema:
          minimum: 0
          type: integer
          format: int32
      - name: limit
        in: query
        description: maximum number of records to return
        required: false
        schema:
          maximum: 1000
          minimum: 0
          type: integer
          format: int32
      responses:
        "200":
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/SubjectItem"
        "400":
          description: bad input parameter
    servers:
    - url: ""
      description: ""
  /postSubject:
    post:
      tags:
      - Developers
      summary: Post a subject item
      description: Post a subject
      operationId: postSubject
      requestBody:
        description: subject item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SubjectItem"
      responses:
        "201":
          description: item created
        "400":
          description: "invalid input, object invalid"
        "409":
          description: an existing item already exists
    servers:
    - url: ""
      description: ""
  /removeSubject:
    post:
      tags:
      - Developers
      summary: Remove a subject item
      description: Remove a subject
      operationId: removeSubject
      requestBody:
        description: subject item to be removed
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/removeItem"
      responses:
        "201":
          description: item removed
        "400":
          description: "invalid input, object invalid"
        "409":
          description: the item can't be removed
    servers:
    - url: ""
      description: ""
  /getAlarms:
    get:
      tags:
      - Developers
      summary: Get the alarms
      description: |
        Get the alarms
      operationId: getAlarms
      parameters:
      - name: id
        in: query
        description: id of the item to get
        required: false
        schema:
          type: string
      - name: searchString
        in: query
        description: pass an optional search string for looking up inventory
        required: false
        schema:
          type: string
      - name: skip
        in: query
        description: number of records to skip for pagination
        required: false
        schema:
          minimum: 0
          type: integer
          format: int32
      - name: limit
        in: query
        description: maximum number of records to return
        required: false
        schema:
          maximum: 1000
          minimum: 0
          type: integer
          format: int32
      responses:
        "200":
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/AlarmItem"
        "400":
          description: bad input parameter
    servers:
    - url: ""
      description: ""
  /postAlarm:
    post:
      tags:
      - Developers
      summary: Post an alarm
      description: Post an alarm
      operationId: postAlarm
      requestBody:
        description: alarm item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AlarmItem"
      responses:
        "201":
          description: item created
        "400":
          description: "invalid input, object invalid"
        "409":
          description: an existing item already exists
    servers:
    - url: ""
      description: ""
  /removeAlarm:
    post:
      tags:
      - Developers
      summary: Remove an alarm item
      description: Remove an alarm
      operationId: removeAlarm
      requestBody:
        description: alarm item to be removed
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/removeItem"
      responses:
        "201":
          description: item removed
        "400":
          description: "invalid input, object invalid"
        "409":
          description: the item can't be removed
    servers:
    - url: ""
      description: ""
  /getTracks:
    get:
      tags:
      - Developers
      summary: Get the tracks
      description: |
        Get the tracks
      operationId: getTracks
      parameters:
      - name: id
        in: query
        description: id of the item to get
        required: false
        schema:
          type: string
      - name: searchString
        in: query
        description: pass an optional search string for looking up inventory
        required: false
        schema:
          type: string
      - name: skip
        in: query
        description: number of records to skip for pagination
        required: false
        schema:
          minimum: 0
          type: integer
          format: int32
      - name: limit
        in: query
        description: maximum number of records to return
        required: false
        schema:
          maximum: 1000
          minimum: 0
          type: integer
          format: int32
      responses:
        "200":
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/TrackItem"
        "400":
          description: bad input parameter
    servers:
    - url: ""
      description: ""
  /postTrack:
    post:
      tags:
      - Developers
      summary: Post a track
      description: Post a track
      operationId: postTrack
      requestBody:
        description: track item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TrackItem"
      responses:
        "201":
          description: item created
        "400":
          description: "invalid input, object invalid"
        "409":
          description: an existing item already exists
    servers:
    - url: ""
      description: ""
  /removeTrack:
    post:
      tags:
      - Developers
      summary: Remove a track item
      description: Remove a track
      operationId: removeTrack
      requestBody:
        description: track item to be removed
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/removeItem"
      responses:
        "201":
          description: item removed
        "400":
          description: "invalid input, object invalid"
        "409":
          description: the item can't be removed
    servers:
    - url: ""
      description: ""
  /getSettings:
    get:
      tags:
      - Developers
      summary: Get the groups of settings
      description: |
        Get the settings
      operationId: getSettings
      parameters:
      - name: id
        in: query
        description: id of the item to get
        required: false
        schema:
          type: string
      - name: searchString
        in: query
        description: pass an optional search string for looking up inventory
        required: false
        schema:
          type: string
      - name: skip
        in: query
        description: number of records to skip for pagination
        required: false
        schema:
          minimum: 0
          type: integer
          format: int32
      - name: limit
        in: query
        description: maximum number of records to return
        required: false
        schema:
          maximum: 1000
          minimum: 0
          type: integer
          format: int32
      responses:
        "200":
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/TrackItem"
        "400":
          description: bad input parameter
    servers:
    - url: ""
      description: ""
  /postSetting:
    post:
      tags:
      - Developers
      summary: Post a group of settings
      description: Post a group settings
      operationId: postSetting
      requestBody:
        description: group of settings item
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SettingItem"
      responses:
        "201":
          description: item created
        "400":
          description: "invalid input, object invalid"
        "409":
          description: an existing item already exists
    servers:
    - url: ""
      description: ""
  /removeSetting:
    post:
      tags:
      - Developers
      summary: Remove a group of settings item
      description: Remove a group of settings
      operationId: removeSetting
      requestBody:
        description: group of setting item to be removed
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/removeItem"
      responses:
        "201":
          description: item removed
        "400":
          description: "invalid input, object invalid"
        "409":
          description: the item can't be removed
    servers:
    - url: ""
      description: ""
components:
  schemas:
    removeItem:
      required:
      - id
      type: object
      properties:
        id:
          type: string
          format: uuid
      description: Item to be removed
    BuildingItem:
      required:
      - id
      - name
      type: object
      properties:
        id:
          type: string
          description: ID
          format: uuid
        name:
          type: string
          description: Name
          example: Hospital
        city:
          type: string
          description: City
        address:
          type: string
          description: Address
        latitude:
          type: number
          description: Latitude
        longitude:
          type: number
          description: Longitude
      description: A building or an area that groups together several plan
    PlanItem:
      required:
      - id
      - name
      type: object
      properties:
        id:
          type: string
          description: ID
          format: uuid
        name:
          type: string
          description: Name
          example: Building 1 - Floor 1
        image:
          type: string
          description: Image
          format: uri
          example: The URL of the image
        scale:
          type: number
          description: Scale
          example: 1
        Building:
          type: string
          description: Building
          format: dbid
      description: A plan is floor or a space of a building
    ZoneItem:
      required:
      - id
      - name
      type: object
      properties:
        id:
          type: string
          description: ID
          format: uuid
        name:
          type: string
          description: Name
          example: Floor 1 - Room 1
        groups:
          type: string
          description: Groups
        Plan:
          type: string
          description: Plan
          format: dbid
        Building:
          type: string
          description: Building
          format: dbid
      description: A zone is a room or a sub-area of a plan
    GatewayItem:
      required:
      - id
      - name
      type: object
      properties:
        id:
          type: string
          description: ID
          format: uuid
        name:
          type: string
          description: Name
        mac:
          type: string
          description: MAC
        status:
          type: boolean
          description: Status
        model:
          type: string
          description: Model
        ip:
          type: string
          description: IP
        position:
          type: string
          description: Position
        x:
          type: number
          description: X
        "y":
          type: number
          description: "Y"
        Plan:
          type: string
          description: Plan
          format: dbid
        Zone:
          type: string
          description: Zone
          format: dbid
        Building:
          type: string
          description: Building
          format: dbid
        notes:
          type: string
          description: Notes
      description: A gateway of the system
    TrackerItem:
      required:
      - id
      - name
      type: object
      properties:
        id:
          type: string
          description: ID
          format: uuid
        name:
          type: string
          description: Name
        mac:
          type: string
          description: MAC
        status:
          type: string
          description: Status
        model:
          type: string
          description: Model
        position:
          type: string
          description: Position
        x:
          type: number
          description: X
        "y":
          type: number
          description: "Y"
        Zone:
          type: string
          description: Zone
          format: dbid
        Building:
          type: string
          description: Building
          format: dbid
        notes:
          type: string
          description: Notes
      description: A tracker of the system
    OperatorItem:
      required:
      - id
      - name
      type: object
      properties:
        id:
          type: string
          description: ID
        name:
          type: string
          description: Name
        phone:
          type: string
          description: Phone
        zones:
          type: string
          description: Zones
        groups:
          type: string
          description: Groups
        notes:
          type: string
          description: Notes
        Building:
          type: string
          description: Building
          format: dbid
      description: An operator who monitors the subjects
    SubjectItem:
      required:
      - id
      - name
      type: object
      properties:
        id:
          type: string
          description: ID
        name:
          type: string
          description: Name
        role:
          type: string
          description: Role
        phone:
          type: string
          description: Phone
        zones:
          type: string
          description: Zones
        groups:
          type: string
          description: Groups
        Building:
          type: string
          description: Building
          format: dbid
        notes:
          type: string
          description: Notes
      description: Person or object monitored by the operators
    AlarmItem:
      required:
      - id
      type: object
      properties:
        id:
          type: string
          description: ID
        time:
          type: string
          description: Time
          format: time
        type:
          type: string
          description: Type
        status:
          type: string
          description: Status
        gateway:
          type: string
          description: Gateway
          format: uuid
        gatewayMac:
          type: string
          description: Gateway MAC
        gatewayName:
          type: string
          description: Gateway name
        Tracker:
          type: string
          description: Tracker
          format: dbid
        trackerMac:
          type: string
          description: Tracker MAC
        trackerName:
          type: string
          description: Tracker name
        Subject:
          type: string
          description: Subject
          format: dbid
        subjectName:
          type: string
          description: Subject name
        Operator:
          type: string
          description: Operator
          format: dbid
        operatorName:
          type: string
          description: Operator name
        Zone:
          type: string
          description: Zone
          format: dbid
        zoneName:
          type: string
          description: Zone name
        Building:
          type: string
          description: Building
          format: dbid
        buildingName:
          type: string
          description: Building name
      description: Alarm triggered if a monitored subject is lost or out of their zone
    TrackItem:
      required:
      - id
      type: object
      properties:
        id:
          type: string
        time:
          type: string
          description: Time
          format: date-time
        type:
          type: string
          description: Type
        status:
          type: string
          description: Status
          enum:
          - lost
          - detected
          - away
          - help
        Gateway:
          type: string
          description: Gateway
          format: dbid
        gatewayMac:
          type: string
          description: Gateway MAC
        gatewayName:
          type: string
          description: Gateway name
        Tracker:
          type: string
          description: Tracker
          format: dbid
        trackerMac:
          type: string
          description: Tracker MAC
        trackerName:
          type: string
          description: Tracker name
        Subject:
          type: string
          description: Subject
          format: dbid
        subjectName:
          type: string
          description: Subject name
        Zone:
          type: string
          description: Zone
          format: dbid
        zoneName:
          type: string
          description: Zone name
        signal:
          type: number
        Building:
          type: string
          description: Building
          format: dbid
        buildingName:
          type: string
          description: Building name
      description: Log of a state change of a tracker with respect to a gateway
    SettingItem:
      required:
      - id
      type: object
      properties:
        id:
          type: string
        name:
          type: string
          description: Setting name
        role:
          type: string
          description: Role
          enum:
          - developer
          - administrator
          - user
        debug:
          type: boolean
          description: Debug mode
          format: boolean
      description: General setting of the app
