swagger: '2.0'
info:
  description: Configuration for Maintenance Job resource.
  version: 'v2'
  title: maintenance_job
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: maintenance_job
    description: Maintenance Job
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 the maintenance jobs
   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/maintenance_job:
    get:
      tags:
        - maintenance_job
      summary: GET all maintenance_job
      operationId: getall_maintenance_job
      description: Use this operation to get config job
      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 maintenance_job 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 maintenance_job 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 maintenance_job resources.
          enum:
            - yes
      responses:
        200:
          description:  for maintenance_job
          schema: 
              $ref: '#/definitions/getmaintenance_jobsResponse'
        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:
        - maintenance_job
      summary: POST operation for maintenance_job
      operationId: post_maintenance_job
      description: POST operation for maintenance_job
      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: maintenance_job
          description: maintenance_job object
          schema:
              $ref: '#/definitions/addmaintenance_jobRequest'
      responses:
        200:
          description: add for maintenance_job
          schema: 
              $ref: '#/definitions/addmaintenance_jobResponse'
        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/maintenance_job/{id}:
    get:
      tags:
        - maintenance_job
      summary: GET by key for maintenance_job
      operationId: getbykey_maintenance_job
      description: Use this operation to get config job
      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: add for maintenance_job
          schema: 
              $ref: '#/definitions/getmaintenance_jobResponse'
        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'

    put:
      tags:
        - maintenance_job
      summary: PUT for maintenance_job
      operationId: putbykey_maintenance_job
      description: Use this operation to update config job
      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: body
          name: maintenance_job
          description: maintenance_job object
          schema:
              $ref: '#/definitions/modifymaintenance_jobRequest'
      responses:
        200:
          description: add for maintenance_job
          schema: 
              $ref: '#/definitions/modifymaintenance_jobResponse'
        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:
        - maintenance_job
      summary: Delete for maintenance_job
      operationId: deletebykey_maintenance_job
      description: Use this operation to delete config job
      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: add for maintenance_job
        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:
  addmaintenance_jobRequest:
    type: object
    required:
      - maintenance_job
    properties:
      maintenance_job:
        $ref: '#/definitions/maintenance_job_readwrite'
    title: addmaintenance_jobRequest
    example:
      maintenance_job:
        task_name: "UpgradeNetScaler"
        slack_profile: "test_slack_profile"
        parent_id: "6a56c246-b4f4-4b16-8158-f8ac028f2b88"
        scheduleTimesEpoch: "1581031800"
        device_family: "ns"
        tasklog_id: "b93b29ff-a4f1-4cdb-56e7-ccabf28b4eb9"
        name: "test_upgrdae1"
        mail_profiles: "test_mail_profile"
        type: "1"
        failed_devices: "[1.1.1.1, 1.1.1.2]"
        device_groups: "[instance-grp1, instance-grp2]"
        failed_message: "[1.1.1.1:NetScaler is unreachable, 1.1.1.2:Insufficient diskspace]"
        attached_maintenance_job: "string_value"
        devices: "[1.1.1.1-1.1.1.2, 1.1.1.3]"
        scheduleTime: "10:10"
        additional_info: "[info1, info2]"

  addmaintenance_jobResponse:
    type: object
    required:
      - maintenance_job
    properties:
      maintenance_job:
        $ref: '#/definitions/maintenance_job'
    title: addmaintenance_jobResponse
    example:
      maintenance_job:
        status: "Completed"
        task_name: "UpgradeNetScaler"
        slack_profile: "test_slack_profile"
        additional_info_db: "string_value"
        resilience_devices_db: "string_value"
        isADMResilienceJob: "false"
        parent_id: "6a56c246-b4f4-4b16-8158-f8ac028f2b88"
        tenant_id: "7ed7946f-4af7-11e9-99d2-b6fe81a85d18"
        timestamp: "1581059664"
        isRetryForResilienceJob: "false"
        devices_db: "string_value"
        resource_object: "string_value"
        id: "a970e730-6bc5-44c2-a2bf-8dd1382ffb5e"
        scheduleTimesEpoch: "1581031800"
        device_family: "ns"
        tasklog_id: "b93b29ff-a4f1-4cdb-56e7-ccabf28b4eb9"
        name: "test_upgrdae1"
        username: "test_user1"
        device_groups_db: "string_value"
        resource: "string_value"
        mail_profiles: "test_mail_profile"
        action: "string_value"
        type: "1"
        failed_devices: "[1.1.1.1, 1.1.1.2]"
        device_groups: "[instance-grp1, instance-grp2]"
        failed_message: "[1.1.1.1:NetScaler is unreachable, 1.1.1.2:Insufficient diskspace]"
        devices_count: "0"
        attached_maintenance_job: "string_value"
        devices: "[1.1.1.1-1.1.1.2, 1.1.1.3]"
        scheduleTime: "10:10"
        devices_completed_count: "0"
        additional_info: "[info1, info2]"

  getmaintenance_jobResponse:
    type: object
    required:
      - maintenance_job
    properties:
      maintenance_job:
        $ref: '#/definitions/maintenance_job'
    title: getmaintenance_jobResponse
    example:
      maintenance_job:
        status: "Completed"
        task_name: "UpgradeNetScaler"
        slack_profile: "test_slack_profile"
        additional_info_db: "string_value"
        resilience_devices_db: "string_value"
        isADMResilienceJob: "false"
        parent_id: "6a56c246-b4f4-4b16-8158-f8ac028f2b88"
        tenant_id: "7ed7946f-4af7-11e9-99d2-b6fe81a85d18"
        timestamp: "1581059664"
        isRetryForResilienceJob: "false"
        devices_db: "string_value"
        resource_object: "string_value"
        id: "a970e730-6bc5-44c2-a2bf-8dd1382ffb5e"
        scheduleTimesEpoch: "1581031800"
        device_family: "ns"
        tasklog_id: "b93b29ff-a4f1-4cdb-56e7-ccabf28b4eb9"
        name: "test_upgrdae1"
        username: "test_user1"
        device_groups_db: "string_value"
        resource: "string_value"
        mail_profiles: "test_mail_profile"
        action: "string_value"
        type: "1"
        failed_devices: "[1.1.1.1, 1.1.1.2]"
        device_groups: "[instance-grp1, instance-grp2]"
        failed_message: "[1.1.1.1:NetScaler is unreachable, 1.1.1.2:Insufficient diskspace]"
        devices_count: "0"
        attached_maintenance_job: "string_value"
        devices: "[1.1.1.1-1.1.1.2, 1.1.1.3]"
        scheduleTime: "10:10"
        devices_completed_count: "0"
        additional_info: "[info1, info2]"

  getmaintenance_jobsResponse:
    type: object
    required:
      - maintenance_job
    properties:
      maintenance_job:
        type: array
        items:
          $ref: '#/definitions/maintenance_job'
    title: getmaintenance_jobsResponse
    example:
      maintenance_job:
        status: "Completed"
        task_name: "UpgradeNetScaler"
        slack_profile: "test_slack_profile"
        additional_info_db: "string_value"
        resilience_devices_db: "string_value"
        isADMResilienceJob: "false"
        parent_id: "6a56c246-b4f4-4b16-8158-f8ac028f2b88"
        tenant_id: "7ed7946f-4af7-11e9-99d2-b6fe81a85d18"
        timestamp: "1581059664"
        isRetryForResilienceJob: "false"
        devices_db: "string_value"
        resource_object: "string_value"
        id: "a970e730-6bc5-44c2-a2bf-8dd1382ffb5e"
        scheduleTimesEpoch: "1581031800"
        device_family: "ns"
        tasklog_id: "b93b29ff-a4f1-4cdb-56e7-ccabf28b4eb9"
        name: "test_upgrdae1"
        username: "test_user1"
        device_groups_db: "string_value"
        resource: "string_value"
        mail_profiles: "test_mail_profile"
        action: "string_value"
        type: "1"
        failed_devices: "[1.1.1.1, 1.1.1.2]"
        device_groups: "[instance-grp1, instance-grp2]"
        failed_message: "[1.1.1.1:NetScaler is unreachable, 1.1.1.2:Insufficient diskspace]"
        devices_count: "0"
        attached_maintenance_job: "string_value"
        devices: "[1.1.1.1-1.1.1.2, 1.1.1.3]"
        scheduleTime: "10:10"
        devices_completed_count: "0"
        additional_info: "[info1, info2]"

  modifymaintenance_jobRequest:
    type: object
    required:
      - maintenance_job
    properties:
      maintenance_job:
        $ref: '#/definitions/maintenance_job_readwrite'
    title: modifymaintenance_jobRequest
    example:
      maintenance_job:
        task_name: "UpgradeNetScaler"
        slack_profile: "test_slack_profile"
        parent_id: "6a56c246-b4f4-4b16-8158-f8ac028f2b88"
        scheduleTimesEpoch: "1581031800"
        device_family: "ns"
        tasklog_id: "b93b29ff-a4f1-4cdb-56e7-ccabf28b4eb9"
        name: "test_upgrdae1"
        mail_profiles: "test_mail_profile"
        type: "1"
        failed_devices: "[1.1.1.1, 1.1.1.2]"
        device_groups: "[instance-grp1, instance-grp2]"
        failed_message: "[1.1.1.1:NetScaler is unreachable, 1.1.1.2:Insufficient diskspace]"
        attached_maintenance_job: "string_value"
        devices: "[1.1.1.1-1.1.1.2, 1.1.1.3]"
        scheduleTime: "10:10"
        additional_info: "[info1, info2]"

  modifymaintenance_jobResponse:
    type: object
    required:
      - maintenance_job
    properties:
      maintenance_job:
        $ref: '#/definitions/maintenance_job'
    title: modifymaintenance_jobResponse
    example:
      maintenance_job:
        status: "Completed"
        task_name: "UpgradeNetScaler"
        slack_profile: "test_slack_profile"
        additional_info_db: "string_value"
        resilience_devices_db: "string_value"
        isADMResilienceJob: "false"
        parent_id: "6a56c246-b4f4-4b16-8158-f8ac028f2b88"
        tenant_id: "7ed7946f-4af7-11e9-99d2-b6fe81a85d18"
        timestamp: "1581059664"
        isRetryForResilienceJob: "false"
        devices_db: "string_value"
        resource_object: "string_value"
        id: "a970e730-6bc5-44c2-a2bf-8dd1382ffb5e"
        scheduleTimesEpoch: "1581031800"
        device_family: "ns"
        tasklog_id: "b93b29ff-a4f1-4cdb-56e7-ccabf28b4eb9"
        name: "test_upgrdae1"
        username: "test_user1"
        device_groups_db: "string_value"
        resource: "string_value"
        mail_profiles: "test_mail_profile"
        action: "string_value"
        type: "1"
        failed_devices: "[1.1.1.1, 1.1.1.2]"
        device_groups: "[instance-grp1, instance-grp2]"
        failed_message: "[1.1.1.1:NetScaler is unreachable, 1.1.1.2:Insufficient diskspace]"
        devices_count: "0"
        attached_maintenance_job: "string_value"
        devices: "[1.1.1.1-1.1.1.2, 1.1.1.3]"
        scheduleTime: "10:10"
        devices_completed_count: "0"
        additional_info: "[info1, info2]"

  maintenance_job_readwrite:
    type: object
    properties:
      task_name:
        description: "task name of maintenance job."
        type: string
        format: string
      slack_profile:
        description: "Slack profile"
        type: string
        format: string
      parent_id:
        description: "Parent Id of maintenance job."
        type: string
        format: uuid
      scheduleTimesEpoch:
        description: "Schedule time epoch (string representation of 11 digit numbers)."
        type: string
        format: string
      device_family:
        description: "Family of Devices for which config job was executed"
        type: string
        format: string
        minLength: 1
        maxLength: 64
      tasklog_id:
        description: "Task Log Id of the Config Job"
        type: string
        format: uuid
        minLength: 1
        maxLength: 128
      name:
        description: "Name of maintenance job"
        type: string
        format: string
        minLength: 1
        maxLength: 128
      mail_profiles:
        description: "Comma separated list of Mail profiles"
        type: string
        format: string
      type:
        description: "Device type for selected device_family"
        type: string
        format: string
        maxLength: 64
      failed_devices:
        description: "filter failed_devices:true to get list of failed devices as array in this property."
        type: array
        items:
          type: string
          format: string
      device_groups:
        description: "Device Group Array on which for which job is run"
        type: array
        items:
          type: string
          format: string
      failed_message:
        description: "Comma separated instances error details"
        type: array
        items:
          type: string
          format: string
      attached_maintenance_job:
        description: "Attached maintenance job"
        type: string
        format: string
      devices:
        description: "Device IP Address Array on which job is run"
        type: array
        items:
          type: string
          format: IP Address
      scheduleTime:
        description: "Comma separated times of the day(DD:HH:MM) on which Configuration Template is scheduled"
        type: string
        format: string
      additional_info:
        description: "Additional info Array"
        type: array
        items:
          type: string
          format: string

  maintenance_job:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all the maintenance jobs
            type: string
            format: uuid
          status:
             description: "Status of maintenance Job Started, In Progress, Scheduled, Failed, Completed"
             type: string
             format: string
             maxLength: 128
          tenant_id:
             description: "Tenant Id of the Config Jobs"
             type: string
             format: uuid
          timestamp:
             description: "Time of Creation of Maintenance Job"
             type: integer
             format: int32
          username:
             description: "Name of user who created maintenance job"
             type: string
             format: string
          devices_count:
             description: "Number of Devices on which commands executed"
             type: integer
             format: int32
          devices_completed_count:
             description: "Devices Completed Count"
             type: integer
             format: int32
      - $ref: '#/definitions/maintenance_job_readwrite'

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