swagger: '2.0'
info:
  description: Configuration for Upgrade Citrix SD-WAN WO resource.
  version: 'v2'
  title: cbwanopt_upgrade
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: cbwanopt_upgrade
    description: Upgrade Citrix SD-WAN WO
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/cbwanopt_upgrade:
    post:
      tags:
        - cbwanopt_upgrade
      summary: POST operation for cbwanopt_upgrade
      operationId: post_cbwanopt_upgrade
      description: POST operation for cbwanopt_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: cbwanopt_upgrade
          description: cbwanopt_upgrade object
          schema:
              $ref: '#/definitions/addcbwanopt_upgradeRequest'
      responses:
        200:
          description: upgrade for cbwanopt_upgrade
          schema: 
              $ref: '#/definitions/addcbwanopt_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:
  addcbwanopt_upgradeRequest:
    type: object
    required:
      - cbwanopt_upgrade
    properties:
      cbwanopt_upgrade:
        $ref: '#/definitions/cbwanopt_upgrade_readwrite'
    title: addcbwanopt_upgradeRequest
    example:
      cbwanopt_upgrade:
        scheduleTimesEpoch: "1581031800"
        device_groups: "[instance-grp1, instance-grp2]"
        image_name: "ctx-sdw-wo-11.0.4.11.upg"
        name: "test_upgrade_1"
        slack_profile: "test_slack_profile"
        on_error: "EXIT"
        execute_sequentially: "false"
        scheduleId: "b970e730-6bc5-44c2-a2bf-8dd1382ffb5a"
        mail_profiles: "test_mail_profile"
        sdx_ip_address_arr: "[\"10.102.40.60\", \"10.102.40.70\"]"
        do_cleanup: "true"

  addcbwanopt_upgradeResponse:
    type: object
    required:
      - cbwanopt_upgrade
    properties:
      cbwanopt_upgrade:
        $ref: '#/definitions/cbwanopt_upgrade'
    title: addcbwanopt_upgradeResponse
    example:
      cbwanopt_upgrade:
        scheduleTimesEpoch: "1581031800"
        device_groups: "[instance-grp1, instance-grp2]"
        mode: "0"
        image_name: "ctx-sdw-wo-11.0.4.11.upg"
        name: "test_upgrade_1"
        slack_profile: "test_slack_profile"
        on_error: "EXIT"
        execute_sequentially: "false"
        task_id: "d970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        scheduleId: "b970e730-6bc5-44c2-a2bf-8dd1382ffb5a"
        mail_profiles: "test_mail_profile"
        sdx_ip_address_arr: "[\"10.102.40.60\", \"10.102.40.70\"]"
        do_cleanup: "true"

  cbwanopt_upgrade_readwrite:
    type: object
    properties:
      scheduleTimesEpoch:
        description: "Schedule time epoch (string representation of 11 digit numbers)."
        type: string
        format: string
      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 of upgrade job"
        type: string
        format: string
        maxLength: 128
      slack_profile:
        description: "Slack profile"
        type: string
        format: string
      on_error:
        description: "Behaviour on encountering error while applying configuration template on a device: CONTINUE|EXIT"
        type: string
        format: string
        minLength: 1
        maxLength: 16
      execute_sequentially:
        description: "True if configuration template is to be applied to devices sequentially"
        type: boolean
        format: boolean
      scheduleId:
        description: "scheduleId is used to refer maintenaince schedule task"
        type: string
        format: uuid
      mail_profiles:
        description: "Comma separated list of Mail profiles"
        type: string
        format: string
      sdx_ip_address_arr:
        description: "List of Citrix SD-WAN WAN Optimization device 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

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

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