swagger: '2.0'
info:
  description: Configuration for Attachments for e-mail action configured in filter rules resource.
  version: 'v2'
  title: mail_attachment
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: mail_attachment
    description: Attachments for e-mail action configured in filter rules
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  UserSecurity:
    type: basic
security:
  - UserSecurity: []
parameters:
  idParam:
   name: file_name
   in: path
   type: string
   description: File Name
   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/mail_attachment:
    get:
      tags:
        - mail_attachment
      summary: GET all mail_attachment
      operationId: getall_mail_attachment
      description: Use this operation to get attachment file
      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 mail_attachment 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 mail_attachment 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 mail_attachment resources.
          enum:
            - yes
      responses:
        200:
          description:  for mail_attachment
          schema: 
              $ref: '#/definitions/getmail_attachmentsResponse'
        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/mail_attachment/{file_name}:
    get:
      tags:
        - mail_attachment
      summary: GET by key for mail_attachment
      operationId: getbykey_mail_attachment
      description: Use this operation to get attachment file
      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 mail_attachment
          schema: 
              $ref: '#/definitions/getmail_attachmentResponse'
        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:
        - mail_attachment
      summary: Delete for mail_attachment
      operationId: deletebykey_mail_attachment
      description: Use this operation to delete attachment file
      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:  for mail_attachment
        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/upload/mail_attachment:
    post:
      tags:
        - mail_attachment
      summary: Upload operation for mail_attachment
      operationId: upload_mail_attachment
      description: Use this operation to upload attachment file
      consumes:
        - multipart/form-data
      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: formData
          name: mail_attachment
          description: mail_attachment file
          type: file
          required: true
      responses:
        200:
          description: Successful upload for mail_attachment
          schema: 
              $ref: '#/definitions/Done'
        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/download/mail_attachment/{file_name}:
    get:
      tags:
        - mail_attachment
      summary: Download operation for mail_attachment
      operationId: download_mail_attachment
      description: Use this operation to download attachment file
      consumes:
        - application/json
      produces:
        - attachment
      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: path
          name: file_name
          type: string
          required: true
          description: File Name
      responses:
        200:
          description: Successful download for mail_attachment
          schema: 
              type: file
              format: binary
        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:
  getmail_attachmentResponse:
    type: object
    required:
      - mail_attachment
    properties:
      mail_attachment:
        $ref: '#/definitions/mail_attachment'
    title: getmail_attachmentResponse
    example:
      mail_attachment:
        file_location_path: "/tmp/"
        file_size: "10KB"
        file_name: "report.csv"
        file_last_modified: "2020-01-01 12:00:00"
        is_dir: "f"

  getmail_attachmentsResponse:
    type: object
    required:
      - mail_attachment
    properties:
      mail_attachment:
        type: array
        items:
          $ref: '#/definitions/mail_attachment'
    title: getmail_attachmentsResponse
    example:
      mail_attachment:
        file_location_path: "/tmp/"
        file_size: "10KB"
        file_name: "report.csv"
        file_last_modified: "2020-01-01 12:00:00"
        is_dir: "f"

  mail_attachment_readwrite:
    type: object
    properties:
      file_location_path:
        description: "File Location on Client for upload/download"
        type: string
        format: string
        minLength: 1

  mail_attachment:
    allOf:
      -
        properties:
          file_name:
            description: File Name
            type: string
            format: string
          file_size:
             description: "Size of the file attached"
             type: number
             format: int64
          file_last_modified:
             description: "File Last Modified"
             type: string
             format: date-time
             minLength: 1
             maxLength: 128
      - $ref: '#/definitions/mail_attachment_readwrite'

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