swagger: '2.0'
info:
  description: Configuration for Backup Policy resource.
  version: 'v2'
  title: backup_policy
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: backup_policy
    description: Backup Policy
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
   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/backup_policy:
    get:
      tags:
        - backup_policy
      summary: GET all backup_policy
      operationId: getall_backup_policy
      description: Use this operation to get backup policy to view the number of previous backups to retain and backup file encryption details
      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 backup_policy 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 backup_policy 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 backup_policy resources.
          enum:
            - yes
      responses:
        200:
          description:  for backup_policy
          schema: 
              $ref: '#/definitions/getbackup_policysResponse'
        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/backup_policy/{id}:
    get:
      tags:
        - backup_policy
      summary: GET by key for backup_policy
      operationId: getbykey_backup_policy
      description: Use this operation to get backup policy to view the number of previous backups to retain and backup file encryption details
      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 backup_policy
          schema: 
              $ref: '#/definitions/getbackup_policyResponse'
        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:
        - backup_policy
      summary: PUT for backup_policy
      operationId: putbykey_backup_policy
      description: Use this operation to modify the number of previous backups to retain and backup file encryption details
      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: backup_policy
          description: backup_policy object
          schema:
              $ref: '#/definitions/modifybackup_policyRequest'
      responses:
        200:
          description:  for backup_policy
          schema: 
              $ref: '#/definitions/modifybackup_policyResponse'
        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:
  getbackup_policyResponse:
    type: object
    required:
      - backup_policy
    properties:
      backup_policy:
        $ref: '#/definitions/backup_policy'
    title: getbackup_policyResponse
    example:
      backup_policy:
        backup_to_retain: "integer_value"
        enable_external_transfer: "false"
        policy_name: "mps_policy_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"
}
        backup_password: "string_value"
        encrypt_backup_file: "false"
        id: "2b38ae44-a824-4f51-a155-23ab334gfd"

  getbackup_policysResponse:
    type: object
    required:
      - backup_policy
    properties:
      backup_policy:
        type: array
        items:
          $ref: '#/definitions/backup_policy'
    title: getbackup_policysResponse
    example:
      backup_policy:
        backup_to_retain: "integer_value"
        enable_external_transfer: "false"
        policy_name: "mps_policy_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"
}
        backup_password: "string_value"
        encrypt_backup_file: "false"
        id: "2b38ae44-a824-4f51-a155-23ab334gfd"

  modifybackup_policyRequest:
    type: object
    required:
      - backup_policy
    properties:
      backup_policy:
        $ref: '#/definitions/backup_policy_readwrite'
    title: modifybackup_policyRequest
    example:
      backup_policy:
        backup_to_retain: "integer_value"
        enable_external_transfer: "false"
        policy_name: "mps_policy_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"
}
        backup_password: "string_value"
        encrypt_backup_file: "false"

  modifybackup_policyResponse:
    type: object
    required:
      - backup_policy
    properties:
      backup_policy:
        $ref: '#/definitions/backup_policy'
    title: modifybackup_policyResponse
    example:
      backup_policy:
        backup_to_retain: "integer_value"
        enable_external_transfer: "false"
        policy_name: "mps_policy_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"
}
        backup_password: "string_value"
        encrypt_backup_file: "false"
        id: "2b38ae44-a824-4f51-a155-23ab334gfd"

  backup_policy_readwrite:
    type: object
    properties:
      backup_to_retain:
        description: "Number of previous backups to retain"
        type: integer
        format: int32
      enable_external_transfer:
        description: "Enable transfer of backup file to external server"
        type: boolean
        format: boolean
      policy_name:
        description: "Policy Name"
        type: string
        format: string
        minLength: 1
        maxLength: 128
      external_storage_info:
        $ref: '#/definitions/backup_external_storage_readwrite'
      backup_password:
        description: "Password for backup file encryption"
        type: string
        format: password
      encrypt_backup_file:
        description: "Encrypts backup files"
        type: boolean
        format: boolean

  backup_policy:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key
            type: string
            format: string
      - $ref: '#/definitions/backup_policy_readwrite'

  backup_external_storage_readwrite:
    type: object
    properties:
      parent_name:
        type: string
        format: string
      delete_from_svm:
        description: "Password for backup file encryption"
        type: boolean
        format: boolean
      port:
        description: "External transfer server port"
        type: integer
        format: int32
      parent_id:
        type: string
        format: string
      username:
        description: "Username"
        type: string
        format: string
      transfer_protocol:
        description: "File transfer Protocol: SCP, SFTP or FTP"
        type: string
        format: string
      password:
        description: "Password"
        type: string
        format: password
      directory_path:
        description: "External server directory path where backup file will be uploaded"
        type: string
        format: string
      server:
        description: "External server IP Address/Hostname"
        type: string
        format: string

  backup_external_storage:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all backed up files
            type: string
            format: string
      - $ref: '#/definitions/backup_external_storage_readwrite'

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