swagger: '2.0'
info:
  description: Configuration for Register Device resource.
  version: 'v2'
  title: device_registration
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: device_registration
    description: Register Device
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  UserSecurity:
    type: basic
security:
  - UserSecurity: []
parameters:
  authParam:
      in: header
      name: Authorization
      type: string
      required: true
      description: Session Id for authentication.Should be mentioned in the format CwsAuth bearer=sessionIdValue
  cloudParam:
      in: header
      name: isCloud
      type: string
      required: true
      description: set the value to true in case of Cloud services, false for on-prem deployment
paths:
  /massvc/{customerid}/nitro/v2/config/device_registration:
    post:
      tags:
        - device_registration
      summary: POST operation for device_registration
      operationId: post_device_registration
      description: POST operation for device_registration
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: path
          name: customerid
          type: string
          required: true
          description: Customer Id of the user
        - in: header
          name: Authorization
          type: string
          required: true
          description: Session Id for authentication.Should be mentioned in the format CwsAuth bearer=sessionIdValue
        - in: header
          name: isCloud
          type: string
          required: true
          description: set the value to true in case of Cloud services, false for on-prem deployment
        - in: query
          name: onerror
          description: Use this parameter to set the onerror status for nitro request. Applicable only for bulk requests.
          required: false
          type: string
          default: CONTINUE
          enum:
            - EXIT
            - CONTINUE
        - in: body
          name: device_registration
          description: device_registration object
          schema:
              $ref: '#/definitions/adddevice_registrationRequest'
      responses:
        200:
          description: add for device_registration
          schema: 
              $ref: '#/definitions/adddevice_registrationResponse'
        400:
          description: Bad input parameter
          schema: 
              $ref: '#/definitions/Error'
        401:
          description: Failed Authentication
          schema: 
              $ref: '#/definitions/Error'
        403:
          description: Unauthorized
          schema: 
              $ref: '#/definitions/Error'
        404:
          description: Item not found
          schema: 
              $ref: '#/definitions/Error'
        409:
          description: Resource Conflict
          schema: 
              $ref: '#/definitions/Error'
        500:
          description: Server Error
          schema: 
              $ref: '#/definitions/Error'
        504:
          description: Gateway Timeout
          schema: 
              $ref: '#/definitions/Error'

definitions:
  adddevice_registrationRequest:
    type: object
    required:
      - device_registration
    properties:
      device_registration:
        $ref: '#/definitions/device_registration_readwrite'
    title: adddevice_registrationRequest
    example:
      device_registration:
        device_type: "ns"
        agent_id: "88523508-5351-4b93-998c-31b97e7453d8"
        device_ip_address: "1.1.1.1"

  adddevice_registrationResponse:
    type: object
    required:
      - device_registration
    properties:
      device_registration:
        $ref: '#/definitions/device_registration'
    title: adddevice_registrationResponse
    example:
      device_registration:
        device_type: "ns"
        agent_id: "88523508-5351-4b93-998c-31b97e7453d8"
        device_ip_address: "1.1.1.1"

  device_registration_readwrite:
    type: object
    properties:
      device_type:
        description: "Device Type of the device to be registered for discovery"
        type: string
        format: string
        minLength: 1
        maxLength: 64
      agent_id:
        description: "Agent Id"
        type: string
        format: uuid
      device_ip_address:
        description: "Device to be registered for discovery."
        type: string
        format: ipaddress
        minLength: 1
        maxLength: 64

  device_registration:
    allOf:
      - $ref: '#/definitions/device_registration_readwrite'

  Error:
    properties:
      errorcode:
        type: number
        format: int32
        example: 1001
      errormessage:
        type: string
        format: string
        example: "id cannot be found"
