swagger: '2.0'
info:
  description: Configuration for Audit log messages resource.
  version: 'v2'
  title: audit_log
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: audit_log
    description: Audit log messages
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 audit log entries
   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/audit_log:
    get:
      tags:
        - audit_log
      summary: GET all audit_log
      operationId: getall_audit_log
      description: Use this operation to get audit log message
      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 audit_log 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 audit_log 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 audit_log resources.
          enum:
            - yes
      responses:
        200:
          description:  for audit_log
          schema: 
              $ref: '#/definitions/getaudit_logsResponse'
        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/audit_log/{id}:
    get:
      tags:
        - audit_log
      summary: GET by key for audit_log
      operationId: getbykey_audit_log
      description: Use this operation to get audit log message
      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 audit_log
          schema: 
              $ref: '#/definitions/getaudit_logResponse'
        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:
  getaudit_logResponse:
    type: object
    required:
      - audit_log
    properties:
      audit_log:
        $ref: '#/definitions/audit_log'
    title: getaudit_logResponse
    example:
      audit_log:
        status: "Success"
        port: "22"
        message: "cert_verified=false"
        username: "nsroot"
        client_type: "GUI"
        tenant_id: "77c01113-b715-4e1c-8162-8f2d70a5a745"
        audittime: "1580940000"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        ip_address: "1.1.1.1"
        resource_name: "nsroot"
        operation: "login"
        command: "tenant_name=Owner,..."
        resource_type: "login"

  getaudit_logsResponse:
    type: object
    required:
      - audit_log
    properties:
      audit_log:
        type: array
        items:
          $ref: '#/definitions/audit_log'
    title: getaudit_logsResponse
    example:
      audit_log:
        status: "Success"
        port: "22"
        message: "cert_verified=false"
        username: "nsroot"
        client_type: "GUI"
        tenant_id: "77c01113-b715-4e1c-8162-8f2d70a5a745"
        audittime: "1580940000"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        ip_address: "1.1.1.1"
        resource_name: "nsroot"
        operation: "login"
        command: "tenant_name=Owner,..."
        resource_type: "login"

  audit_log_readwrite:
    type: object
    properties:
      command:
        description: "Command given for this action"
        type: string
        format: string

  audit_log:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all the audit log entries
            type: string
            format: uuid
          status:
             description: "Status of this action whether accepted/rejected by system"
             type: string
             format: string
             maxLength: 128
          port:
             description: "Client port from where operation specified for this entry was performed"
             type: integer
             format: int32
          message:
             description: "Message for this action"
             type: string
             format: string
             minLength: 1
             maxLength: 256
          username:
             description: "User Name, who performed operation specified for this entry"
             type: string
             format: string
             minLength: 1
             maxLength: 128
          client_type:
             description: "Client Type"
             type: string
             format: string
          audittime:
             description: "Action Time on which operation specified for this entry was started"
             type: integer
             format: int32
          ip_address:
             description: "Client IP Address from where operation specified for this entry was performed"
             type: string
             format: ipaddress
             minLength: 1
             maxLength: 64
          resource_name:
             description: "Resource Name on which operation specified for this entry was performed"
             type: string
             format: string
             minLength: 1
             maxLength: 128
          operation:
             description: "Operation Type that is performed"
             type: string
             format: string
             minLength: 1
             maxLength: 32
          resource_type:
             description: "Resource Type on which operation specified for this entry was performed "
             type: string
             format: string
             minLength: 1
             maxLength: 64
      - $ref: '#/definitions/audit_log_readwrite'

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