swagger: '2.0'
info:
  description: Configuration for Device Backup resource.
  version: 'v2'
  title: device_backup
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: device_backup
    description: Device Backup
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  UserSecurity:
    type: basic
security:
  - UserSecurity: []
parameters:
  idParam:
   name: id
   in: path
   type: string
   description: Id is system generated key for all backed up files
   required: true
  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_backup:
    get:
      tags:
        - device_backup
      summary: GET all device_backup
      operationId: getall_device_backup
      description: Get backed up files of devices
      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: filter
          type: string
          required: false
          description: "Use this query-parameter to get the filtered set of vm_device resources configured on the system. You can set a filter on any property of the resource.Example:  property-name1:property-value1 "
        - in: query
          name: pagesize
          type: integer
          required: false
          description: Use this query-parameter to get the device_backup resources in chunks.To be used along with pageno query parameter.
        - in: query
          name: pageno
          type: integer
          required: false
          description: Use this query-parameter to get the device_backup resources in chunks.To be used along with pagesize query parameter.
        - in: query
          name: count
          type: string
          required: false
          description: Use this query-parameter to get the count of device_backup resources.
          enum:
            - yes
      responses:
        200:
          description:  for device_backup
          schema: 
              $ref: '#/definitions/getdevice_backupsResponse'
        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'

  /massvc/{customerid}/nitro/v2/config/device_backup/{id}:
    get:
      tags:
        - device_backup
      summary: GET by key for device_backup
      operationId: getbykey_device_backup
      description: Get backed up files of devices
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/idParam'
        - 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
      responses:
        200:
          description:  for device_backup
          schema: 
              $ref: '#/definitions/getdevice_backupResponse'
        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'

    post:
      tags:
        - device_backup
      summary: POST operation with actions for device_backup
      operationId: post_device_backup_actions
      description: POST operation with actions for device_backup
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/idParam'
        - 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: action
          type: string
          required: true
          enum: [devicebackup,devicerestore]
          description: >
            actions:
              * `devicebackup` - Use this operation to poll all backup file from a device and updated the database
              * `devicerestore` - Use this operation to restore backed up file

        - in: body
          name: device_backup
          description: device_backup object
          schema:
              $ref: '#/definitions/adddevice_backupRequest'
      responses:
        200:
          description: devicerestore for device_backup
          schema: 
              $ref: '#/definitions/adddevice_backupResponse'
        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'

    delete:
      tags:
        - device_backup
      summary: Delete for device_backup
      operationId: deletebykey_device_backup
      description: Use this operation to delete NetScaler configuration template
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/idParam'
        - 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
      responses:
        204:
          description: devicerestore for device_backup
        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'

  /massvc/{customerid}/nitro/v2/upload/device_backup:
    post:
      tags:
        - device_backup
      summary: Upload operation for device_backup
      operationId: upload_device_backup
      description: Use this operation to upload backed up file
      consumes:
        - multipart/form-data
      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: formData
          name: device_backup
          description: device_backup file
          type: file
          required: true
      responses:
        200:
          description: Successful upload for device_backup
          schema: 
              $ref: '#/definitions/Done'
        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'

  /massvc/{customerid}/nitro/v2/download/device_backup/{id}:
    get:
      tags:
        - device_backup
      summary: Download operation for device_backup
      operationId: download_device_backup
      description: Use this operation to download backed up file
      consumes:
        - application/json
      produces:
        - attachment
      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: path
          name: id
          type: string
          required: true
          description: Id is system generated key for all backed up files
      responses:
        200:
          description: Successful download for device_backup
          schema: 
              type: file
              format: binary
        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_backupRequest:
    type: object
    required:
      - device_backup
    properties:
      device_backup:
        $ref: '#/definitions/device_backup_readwrite'
    title: adddevice_backupRequest
    example:
      device_backup:
        wallet_key_encrypted: "false"
        last_updated_time: "1580812517"
        backup_filesize: "8156768"
        ip_address: "1.1.1.1"
        encrypted: "false"
        backup_password: "password"
        use_global_password: "false"

  adddevice_backupResponse:
    type: object
    required:
      - device_backup
    properties:
      device_backup:
        $ref: '#/definitions/device_backup'
    title: adddevice_backupResponse
    example:
      device_backup:
        external_storage_info: {        parent_name: "string_value"
,        delete_from_svm: "boolean_value"
,        port: "integer_value"
,        parent_id: "string_value"
,        username: "string_value"
,        transfer_protocol: "string_value"
,        password: "string_value"
,        directory_path: "string_value"
,        id: "string_value"
,        server: "string_value"
}
        device_family: "ns"
        wallet_key_encrypted: "false"
        image_filesize: "number_value"
        last_updated_time: "1580812517"
        backup_filesize: "8156768"
        tenant_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        device_name: "devicename"
        image_filename: "string_value"
        backup_filename: "filename"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        ip_address: "1.1.1.1"
        encrypted: "false"
        act_id: "fce5b825-9217-4e58-b80c-48cfe8f0c6b3"
        backup_password: "password"
        use_global_password: "false"

  getdevice_backupResponse:
    type: object
    required:
      - device_backup
    properties:
      device_backup:
        $ref: '#/definitions/device_backup'
    title: getdevice_backupResponse
    example:
      device_backup:
        external_storage_info: {        parent_name: "string_value"
,        delete_from_svm: "boolean_value"
,        port: "integer_value"
,        parent_id: "string_value"
,        username: "string_value"
,        transfer_protocol: "string_value"
,        password: "string_value"
,        directory_path: "string_value"
,        id: "string_value"
,        server: "string_value"
}
        device_family: "ns"
        wallet_key_encrypted: "false"
        image_filesize: "number_value"
        last_updated_time: "1580812517"
        backup_filesize: "8156768"
        tenant_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        device_name: "devicename"
        image_filename: "string_value"
        backup_filename: "filename"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        ip_address: "1.1.1.1"
        encrypted: "false"
        act_id: "fce5b825-9217-4e58-b80c-48cfe8f0c6b3"
        backup_password: "password"
        use_global_password: "false"

  getdevice_backupsResponse:
    type: object
    required:
      - device_backup
    properties:
      device_backup:
        type: array
        items:
          $ref: '#/definitions/device_backup'
    title: getdevice_backupsResponse
    example:
      device_backup:
        external_storage_info: {        parent_name: "string_value"
,        delete_from_svm: "boolean_value"
,        port: "integer_value"
,        parent_id: "string_value"
,        username: "string_value"
,        transfer_protocol: "string_value"
,        password: "string_value"
,        directory_path: "string_value"
,        id: "string_value"
,        server: "string_value"
}
        device_family: "ns"
        wallet_key_encrypted: "false"
        image_filesize: "number_value"
        last_updated_time: "1580812517"
        backup_filesize: "8156768"
        tenant_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        device_name: "devicename"
        image_filename: "string_value"
        backup_filename: "filename"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        ip_address: "1.1.1.1"
        encrypted: "false"
        act_id: "fce5b825-9217-4e58-b80c-48cfe8f0c6b3"
        backup_password: "password"
        use_global_password: "false"

  device_backup_readwrite:
    type: object
    properties:
      wallet_key_encrypted:
        description: "True if wallet key encrypted for service deployment"
        type: boolean
        format: boolean
      last_updated_time:
        description: "Last Updated Time"
        type: number
        format: int64
      backup_filesize:
        description: "Backup file size"
        type: number
        format: int64
      ip_address:
        description: "Device IP Address"
        type: string
        format: ipaddress
        minLength: 1
        maxLength: 64
      encrypted:
        description: "Indicates if the backup files are encrypted"
        type: boolean
        format: boolean
      backup_password:
        description: "Backup Password"
        type: string
        format: password
      use_global_password:
        description: "Global Password"
        type: boolean
        format: boolean

  device_backup:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all backed up files
            type: string
            format: uuid
          device_name:
             description: "Device Hostname"
             type: string
             format: string
             minLength: 1
             maxLength: 128
          backup_filename:
             description: "Name of the backed up file"
             type: string
             format: string
             minLength: 1
      - $ref: '#/definitions/device_backup_readwrite'

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