swagger: '2.0'
info:
  description: Configuration for Sent mail record item keeping. resource.
  version: 'v2'
  title: sent_mails
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: sent_mails
    description: Sent mail record item keeping.
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 sent mail record.
   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/sent_mails:
    get:
      tags:
        - sent_mails
      summary: GET all sent_mails
      operationId: getall_sent_mails
      description: Use this operation to get sent mail 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 sent_mails 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 sent_mails 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 sent_mails resources.
          enum:
            - yes
      responses:
        200:
          description:  for sent_mails
          schema: 
              $ref: '#/definitions/getsent_mailssResponse'
        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/sent_mails/{id}:
    get:
      tags:
        - sent_mails
      summary: GET by key for sent_mails
      operationId: getbykey_sent_mails
      description: Use this operation to get sent mail 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 sent_mails
          schema: 
              $ref: '#/definitions/getsent_mailsResponse'
        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:
        - sent_mails
      summary: Delete for sent_mails
      operationId: deletebykey_sent_mails
      description: Use this operation to delete sent mail 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:
        204:
          description:  for sent_mails
        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:
  getsent_mailsResponse:
    type: object
    required:
      - sent_mails
    properties:
      sent_mails:
        $ref: '#/definitions/sent_mails'
    title: getsent_mailsResponse
    example:
      sent_mails:
        to_list: "userfirstname.lastname@company.com,userfirstname2.lastname2@company.com"
        failed_message: "string_value"
        subject: "sample"
        bcc_list: "userfirstname.lastname@company.com,userfirstname2.lastname2@company.com"
        is_auth: "false"
        cc_list: "userfirstname.lastname@company.com,userfirstname2.lastname2@company.com"
        port: "25"
        is_sent: "boolean_value"
        message: "Disk Usage Normal: nan%"
        username: "test"
        timestamp: "1580971329"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        is_ssl: "false"
        server_name: "1.1.1.1"
        profile_name: "test_profile"

  getsent_mailssResponse:
    type: object
    required:
      - sent_mails
    properties:
      sent_mails:
        type: array
        items:
          $ref: '#/definitions/sent_mails'
    title: getsent_mailssResponse
    example:
      sent_mails:
        to_list: "userfirstname.lastname@company.com,userfirstname2.lastname2@company.com"
        failed_message: "string_value"
        subject: "sample"
        bcc_list: "userfirstname.lastname@company.com,userfirstname2.lastname2@company.com"
        is_auth: "false"
        cc_list: "userfirstname.lastname@company.com,userfirstname2.lastname2@company.com"
        port: "25"
        is_sent: "boolean_value"
        message: "Disk Usage Normal: nan%"
        username: "test"
        timestamp: "1580971329"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        is_ssl: "false"
        server_name: "1.1.1.1"
        profile_name: "test_profile"

  sent_mails_readwrite:
    type: object
    properties:
      to_list:
        description: "List of to whom send the mail. "
        type: string
        format: string
      failed_message:
        description: "Subject of the mail sent."
        type: string
        format: string
        minLength: 1
        maxLength: 2000
      subject:
        description: "Subject of the mail sent."
        type: string
        format: string
        minLength: 1
        maxLength: 2000
      bcc_list:
        description: "List to whom BCC the mail."
        type: string
        format: string
      is_auth:
        description: "Is authentication enabled for this smtp server"
        type: boolean
        format: boolean
      cc_list:
        description: "List to whom CC the mail."
        type: string
        format: string
      port:
        description: "SMTP Server port address."
        type: integer
        format: int32
      is_sent:
        description: "Is this mail sent successfully."
        type: boolean
        format: boolean
      message:
        description: "Content of the mail sent."
        type: string
        format: string
        minLength: 1
        maxLength: 20000
      username:
        description: "Username for the smtp server"
        type: string
        format: string
        maxLength: 128
      is_ssl:
        description: "Is this smtp server is SSL support configured."
        type: boolean
        format: boolean
      server_name:
        description: "SMTP server name"
        type: string
        format: string
        minLength: 1
        maxLength: 128
      profile_name:
        description: "Profile name through which mail sent."
        type: string
        format: string
        minLength: 1
        maxLength: 128

  sent_mails:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all the sent mail record.
            type: string
            format: string
          timestamp:
             description: "Time when the mail was sent"
             type: number
             format: int64
      - $ref: '#/definitions/sent_mails_readwrite'

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