openapi: 3.0.1
info:
  title: Mainflux Provision service
  description: |
    HTTP API for Provision service
    Some useful links:
    - [The Mainflux repository](https://github.com/mainflux/mainflux)
  contact:
    email: info@mainflux.com
  license:
    name: Apache 2.0
    url: https://github.com/mainflux/mainflux/blob/master/LICENSE
  version: 0.14.0

servers:
  - url: http://localhost:9016
  - url: https://localhost:9016

tags:
  - name: provision
    description: Everything about your Provision
    externalDocs:
      description: Find out more about provision
      url: http://docs.mainflux.io/

paths:
  /mapping:
    post:
      summary: Adds new device to proxy
      description: Adds new device to proxy
      tags:
        - provision
      requestBody:
        $ref: "#/components/requestBodies/ProvisionReq"
      responses:
        '201':
          description: Created
        '400':
          description: Failed due to malformed JSON.
        "401":
          description: Missing or invalid access token provided.
        '500':
          $ref: "#/components/responses/ServiceError"
    get:
      summary: Gets current mapping.
      description: Gets current mapping. This can be used in UI
        so that when bootstrap config is created from UI matches
        configuration created with provision service.
      tags:
        - provision
      responses:
        '200':
          $ref: "#/components/responses/ProvisionRes"
        "401":
          description: Missing or invalid access token provided.
        '500':
          $ref: "#/components/responses/ServiceError"
  /health:
    get:
      summary: Retrieves service health check info.
      tags:
        - health
      responses:
        '200':
          $ref: "#/components/responses/HealthRes"
        '500':
          $ref: "#/components/responses/ServiceError"

components:
  requestBodies:
    ProvisionReq:
      description: MAC address of device or other identifier
      content:
        application/json:
          schema:
            type: object
            required:
              - external_id
              - external_key
            properties:
              external_id:
                type: string
              external_key:
                 type: string
              name:
                 type: string

  responses:
    ServiceError:
      description: Unexpected server-side error occurred.
    ProvisionRes:
      description: Current mapping JSON representation.
      content:
        application/json:
          schema:
            type: object
    HealthRes:
      description: Service Health Check.
      content:
        application/json:
          schema:
            $ref: "./schemas/HealthInfo.yml"

  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        * Users access: "Authorization: Bearer <user_token>"

security:
  - bearerAuth: []
