schemes:
  - https
swagger: '2.0'
info:
  description: |-
    **Warning:** This API is soon be deprecated
    IE Edge Device API
  title: IE Edge Device API
  version: v1.0.0
host: localhost
basePath: /device/edge/api/v1
tags:
  - name: device
  - name: login
  
paths:
  /hard-reset:
    post:
      description: This method restores the IE Device to its original onboarding state
      consumes:
        - application/json
      produces:
        - application/json
      tags:
        - device
      summary: Restore default onboarding state
      operationId: hard-reset
      parameters:
        - type: string
          description: The Authorization token
          name: Authorization
          in: header
          required: true
        - type: string
          description: The client's display language, e.g. en-US
          name: Accept-Language
          in: header
      responses:
        '202':
          description: Successfully triggered factory reset. The success of the asynchronous operation is not guaranteed
        '401':
          description: Missing auth token. Error code edge.auth.missingToken edge.auth.expiredToken edge.auth.invalidToken
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        '409':
          description: Conflict with device state. Error code edge.updateRunning edge.notsupported
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        '500':
          description: Unknown. Error code edge.unableToFactoryReset
          schema:
            $ref: '#/definitions/response.ErrorResponse'
  /login/direct:
    post:
      tags:
        - login
      summary: Log in with username and password
      description: |-
        This method logs in a user to the edge management with the username, password, and verification code ( if multi-
        factor verification is enabled ).
      operationId: create-token
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: body
          name: body
          description: 'The map of login credentials, including username, password and verificationCode (optional)'
          required: true
          schema:
            $ref: '#/definitions/Login'
      responses:
        '200':
          description: Successful operation
          schema:
            $ref: '#/definitions/LoginResponse'
        '400':
          description: |-
            user.suspended
        '404':
          description: notFound.user
        '500':
          description: something.wrong
  /activate:
    post:
      description: |-
        This method activates the Edge core and registers it to the IEMS.
        Activating an Edge core requires a file that contains information, such as local username, local password, and edge core name.
        Get this file from IEMS by calling e.g.
        POST https://XXXX/p.service/api/devices/create
        Body Param: {"device":{"localUserName":"emailID","localPassword":"password","deviceId":"edgecoreid","deviceName":"edge core name","macAddress":"3a:71:18:34:82:c2","hostName":"hostname","platformActualName":"x86_64","softwarePlatformName":"dockercompose"}}
      consumes:
        - multipart/form-data
      produces:
        - application/json
      tags:
        - device
      summary: Activate and register edge core
      operationId: activate
      parameters:
        - type: string
          description: 'The client’s display language, e.g. en-US'
          name: Accept-Language
          in: header
        - type: file
          description: configuration file previously retrieved from IEM
          name: files
          in: formData
          required: true
      responses:
        '204':
          description: Successful operation
        '400':
          description: 'Error-Code: edge.fileRequired, edge.failedToParseBodyMap, edge.unableToParse, edge.invalidActivationFile'
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        '413':
          description: 'Error-Code: edge.file.size.configExceeded'
          schema:
            $ref: '#/definitions/response.ErrorResponse'
        '409':
          description: 'Error-Code: edge.activationInprogress, edge.alreadyActivated'
          schema:
            $ref: '#/definitions/response.ErrorResponse'        
        '500':
          description: 'Error-Code: edge.UnableToAddDeviceInfoInDB,edge.unableToParseOnboardingFile, edge.unableToGenerateToken, edge.unableToGetIPAddress, edge.unableToActivated, edge.nameUnavailable, edge.unabletoUploadOnboardingFile, edge.UnableToOpenFile, edge.unableToCopyFile, edge.noSpaceAvailableForUploadOnboardingFile, edge.unableToAddCertiificates",edge.retryWithNewOnboardingFile, edge.retryOnboardConfigurationConflict'
          schema:
            $ref: '#/definitions/response.ErrorResponse'
definitions:
  response.ErrorResponse:
    type: object
    properties:
      errors:
        type: array
        items:
          $ref: '#/definitions/response.ErrorObject'
  response.ErrorObject:
    type: object
    properties:
      code:
        type: string
      data:
        type: object
      field:
        type: string
      innerError:
        type: string
      logref:
        type: string
      message:
        type: string
  Login:
    type: object
    required:
      - username
      - password
    properties:
      username:
        type: string
        description: Associated user name for basic auth
      password:
        type: string
        description: Associated password for basic auth
  LoginResponse:
    type: object
    properties:
      data:
        type: object
        properties:
          access_token:
            type: string
            description: access token
          expires_in:
            type: integer
            format: int64
            description: Exipration time of the token
