swagger: '2.0'
info:
  description: Configuration for NetScaler Configuration Diff resource.
  version: 'v2'
  title: ns_config_diff
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: ns_config_diff
    description: NetScaler Configuration Diff
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  UserSecurity:
    type: basic
security:
  - UserSecurity: []
parameters:
  idParam:
   name: ns_ip_address
   in: path
   type: string
   description: NetScaler IP Address
   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:
  /masvc/{customerid}/nitro/v2/config/ns_config_diff/{ns_ip_address}:
    post:
      tags:
        - ns_config_diff
      summary: POST operation with actions for ns_config_diff
      operationId: post_ns_config_diff_actions
      description: POST operation with actions for ns_config_diff
      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: [diff_table_report,diff_table,do_diff,gen_batch]
          description: >
            actions:
              * `diff_table_report` -  Use this operation to display the diff report from the file mentioned in diff_file parameter
              * `diff_table` -  Use this operation to get config diff between source and target configuration files in the tabular format
              * `do_diff` -  Use this operation to get config diff between source and target configuration files in XML format
              * `gen_batch` -  Use this operation to generate batch config

        - in: body
          name: ns_config_diff
          description: ns_config_diff object
          schema:
              $ref: '#/definitions/addns_config_diffRequest'
      responses:
        200:
          description: gen_batch for ns_config_diff
          schema: 
              $ref: '#/definitions/addns_config_diffResponse'
        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:
  addns_config_diffRequest:
    type: object
    required:
      - ns_config_diff
    properties:
      ns_config_diff:
        $ref: '#/definitions/ns_config_diff_readwrite'
    title: addns_config_diffRequest
    example:
      ns_config_diff:
        diff_file: "gsbltemplate_1.1.1.1_1580616721.xml"
        source_file: "Configuration Revision -5( Thu 30 Jan 05:41:30 2020 )"
        ignoresysuserpassword: "false"
        target_file: "Running Configuration"
        corrective_command: "disable ns feature SSL"

  addns_config_diffResponse:
    type: object
    required:
      - ns_config_diff
    properties:
      ns_config_diff:
        $ref: '#/definitions/ns_config_diff'
    title: addns_config_diffResponse
    example:
      ns_config_diff:
        diff_data: "string_value"
        params_targetvalue: "string_value"
        diff_file: "gsbltemplate_1.1.1.1_1580616721.xml"
        source_file: "Configuration Revision -5( Thu 30 Jan 05:41:30 2020 )"
        params_value: "LB"
        diff_response: "string_value"
        ignoresysuserpassword: "false"
        source_command: "enable ns feature LB"
        ns_ip_address: "1.1.1.1"
        target_file: "Running Configuration"
        corrective_command: "disable ns feature SSL"
        target_command: "enable ns feature LB SSL"
        params_name: "feature"

  ns_config_diff_readwrite:
    type: object
    properties:
      diff_file:
        description: "Name of the file containing diff between source and target file generated by a schedule diff operation."
        type: string
        format: string
      source_file:
        description: "NetScaler configuration source file"
        type: string
        format: string
      ignoresysuserpassword:
        description: "When set to true, ignores password difference in diff command output"
        type: boolean
        format: boolean
      target_file:
        description: "NetScaler configuration target file"
        type: string
        format: string
      corrective_command:
        description: "Corrective command"
        type: string
        format: string

  ns_config_diff:
    allOf:
      -
        properties:
          ns_ip_address:
            description: NetScaler IP Address
            type: string
            format: IP Address
          diff_data:
             description: "Diff data in XML format."
             type: string
             format: string
          params_targetvalue:
             description: "Params target value seen in the diff output"
             type: string
             format: string
          params_value:
             description: "Params value seen in the diff output"
             type: string
             format: string
          diff_response:
             description: "Diff between source and target file"
             type: string
             format: string
          source_command:
             description: "Diff command ouput present in source"
             type: string
             format: string
          target_command:
             description: "Diff command ouput present in target"
             type: string
             format: string
          params_name:
             description: "Params name seen in the diff output"
             type: string
             format: string
      - $ref: '#/definitions/ns_config_diff_readwrite'

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