swagger: '2.0'
info:
  description: Configuration for Upgrade SDX resource.
  version: 'v2'
  title: sdx_upgrade
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: sdx_upgrade
    description: Upgrade SDX
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/sdx_upgrade:
    post:
      tags:
        - sdx_upgrade
      summary: POST operation for sdx_upgrade
      operationId: post_sdx_upgrade
      description: POST operation for sdx_upgrade
      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: query
          name: action
          type: string
          required: false
          enum: [upgrade]
          description: >
            actions:
              * `upgrade` - 

        - in: body
          name: sdx_upgrade
          description: sdx_upgrade object
          schema:
              $ref: '#/definitions/addsdx_upgradeRequest'
      responses:
        200:
          description: upgrade for sdx_upgrade
          schema: 
              $ref: '#/definitions/addsdx_upgradeResponse'
        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:
  addsdx_upgradeRequest:
    type: object
    required:
      - sdx_upgrade
    properties:
      sdx_upgrade:
        $ref: '#/definitions/sdx_upgrade_readwrite'
    title: addsdx_upgradeRequest
    example:
      sdx_upgrade:
        scheduleTimesEpoch: "1581031800"
        is_remote_download: "false"
        device_groups: "[instance-grp1, instance-grp2]"
        image_name: "build-sdx-12.1-56.1.tgz"
        name: "test_upgrade1"
        slack_profile: "test_slack_profile"
        mail_profiles: "test_mail_profile"
        scheduleId: "b970e730-6bc5-44c2-a2bf-8dd1382ffb5a"
        sdx_ip_address_arr: "[\"1.1.1.1\", \"1.1.1.2\"]"
        do_cleanup: "true"

  addsdx_upgradeResponse:
    type: object
    required:
      - sdx_upgrade
    properties:
      sdx_upgrade:
        $ref: '#/definitions/sdx_upgrade'
    title: addsdx_upgradeResponse
    example:
      sdx_upgrade:
        scheduleTimesEpoch: "1581031800"
        is_remote_download: "false"
        device_groups: "[instance-grp1, instance-grp2]"
        image_name: "build-sdx-12.1-56.1.tgz"
        name: "test_upgrade1"
        slack_profile: "test_slack_profile"
        task_id: "d970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        mail_profiles: "test_mail_profile"
        scheduleId: "b970e730-6bc5-44c2-a2bf-8dd1382ffb5a"
        sdx_ip_address_arr: "[\"1.1.1.1\", \"1.1.1.2\"]"
        do_cleanup: "true"

  sdx_upgrade_readwrite:
    type: object
    properties:
      scheduleTimesEpoch:
        description: "Schedule time epoch (string representation of 11 digit numbers)."
        type: string
        format: string
      is_remote_download:
        description: "True if upgrade is remote download instead of direct upload from NetScaler Console"
        type: boolean
        format: boolean
      device_groups:
        description: "Device Group Array on which for which job is run"
        type: array
        items:
          type: string
          format: string
      image_name:
        description: "image_name"
        type: string
        format: string
        minLength: 1
        maxLength: 128
      name:
        description: "Name"
        type: string
        format: string
        maxLength: 128
      slack_profile:
        description: "Slack profile"
        type: string
        format: string
      mail_profiles:
        description: "Comma separated list of Mail profiles"
        type: string
        format: string
      scheduleId:
        description: "scheduleId is used to refer maintenaince schedule task"
        type: string
        format: uuid
      sdx_ip_address_arr:
        description: "List of NetScaler SDX IP Address"
        type: array
        items:
          type: string
          format: IP Address
      do_cleanup:
        description: "True, if user wants to clean the image files once upgrade is completed successfully"
        type: boolean
        format: boolean

  sdx_upgrade:
    allOf:
      -
        properties:
          task_id:
             description: "Task ID"
             type: string
             format: uuid
      - $ref: '#/definitions/sdx_upgrade_readwrite'

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