swagger: '2.0'
info:
  description: Configuration for NetScaler Events resource.
  version: 'v2'
  title: ns_event
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: ns_event
    description: NetScaler Events
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 events
   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/ns_event:
    get:
      tags:
        - ns_event
      summary: GET all ns_event
      operationId: getall_ns_event
      description: Use this operation to get events
      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 ns_event 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 ns_event 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 ns_event resources.
          enum:
            - yes
      responses:
        200:
          description:  for ns_event
          schema: 
              $ref: '#/definitions/getns_eventsResponse'
        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/ns_event/{id}:
    get:
      tags:
        - ns_event
      summary: GET by key for ns_event
      operationId: getbykey_ns_event
      description: Use this operation to get events
      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 ns_event
          schema: 
              $ref: '#/definitions/getns_eventResponse'
        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:
  getns_eventResponse:
    type: object
    required:
      - ns_event
    properties:
      ns_event:
        $ref: '#/definitions/ns_event'
    title: getns_eventResponse
    example:
      ns_event:
        counter_threshold_value: "80"
        source: "1.1.1.1"
        cmd_exec_status: "Success"
        device_entity_type: "service"
        entity: "entityStatus"
        device_type: "nsvpx"
        timestamp: "1580971329"
        operation_type: "config_change"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        category: "entityDown"
        severity: "Major"
        failureobj: "nsroot"
        device_family: "ns"
        rpt_sample_time: "1580971329"
        message: "ns_client_ipaddress : 1.1.1.1"
        user_name: "nsroot"
        config_cmd: "add snmp community abcd all"
        cmd_auth_status: "Success"
        device_entity_name: "adm_metric_collector_svc_1.1.1.1"
        counter_actual_value: "85"
        current_value: "string_value"
        threshold_value: "string_value"
        entity_type: "string_value"
        hostname: "test"
        matched_filters: "string_value"
        managed_device_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        display_event: "false"

  getns_eventsResponse:
    type: object
    required:
      - ns_event
    properties:
      ns_event:
        type: array
        items:
          $ref: '#/definitions/ns_event'
    title: getns_eventsResponse
    example:
      ns_event:
        counter_threshold_value: "80"
        source: "1.1.1.1"
        cmd_exec_status: "Success"
        device_entity_type: "service"
        entity: "entityStatus"
        device_type: "nsvpx"
        timestamp: "1580971329"
        operation_type: "config_change"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        category: "entityDown"
        severity: "Major"
        failureobj: "nsroot"
        device_family: "ns"
        rpt_sample_time: "1580971329"
        message: "ns_client_ipaddress : 1.1.1.1"
        user_name: "nsroot"
        config_cmd: "add snmp community abcd all"
        cmd_auth_status: "Success"
        device_entity_name: "adm_metric_collector_svc_1.1.1.1"
        counter_actual_value: "85"
        current_value: "string_value"
        threshold_value: "string_value"
        entity_type: "string_value"
        hostname: "test"
        matched_filters: "string_value"
        managed_device_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        display_event: "false"

  ns_event_readwrite:
    type: object
    properties:
      display_event:
        description: "Display the event even when event age threshold is set."
        type: boolean
        format: boolean

  ns_event:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all the events
            type: string
            format: uuid
          counter_threshold_value:
             description: "device threshold value for any threadhold violated traps"
             type: string
             format: string
          source:
             description: "Source from where the event is originated"
             type: string
             format: ipaddress
             minLength: 1
             maxLength: 128
          cmd_exec_status:
             description: "Command Execution Status if the event is generated for any config change or config save in device"
             type: string
             format: string
             maxLength: 255
          device_entity_type:
             description: "Device Entity Type"
             type: string
             format: string
             maxLength: 255
          entity:
             description: "Entity of Event"
             type: string
             format: string
             minLength: 1
             maxLength: 1024
          device_type:
             description: "Type of device from which we have received the event"
             type: string
             format: string
             minLength: 1
             maxLength: 64
          timestamp:
             description: "Time when the event occured"
             type: integer
             format: int32
          operation_type:
             description: "Operation Type"
             type: string
             format: string
             minLength: 1
             maxLength: 32
          category:
             description: "Category of Event"
             type: string
             format: string
             minLength: 1
             maxLength: 1024
          severity:
             description: "Severity of Event"
             type: string
             format: string
             minLength: 1
             maxLength: 32
          failureobj:
             description: "Failure objects are entity instances or counters for which an event has been generated, for example entity name"
             type: string
             format: string
             minLength: 1
             maxLength: 128
          device_family:
             description: "Family of device from which we have received the event"
             type: string
             format: string
          rpt_sample_time:
             description: "Report Sample time."
             type: number
             format: int64
          message:
             description: "Event Message - All the other properties recevied in event trap which do not specific fields in this resource(In key : value pair)"
             type: string
             format: string
             maxLength: 4096
          user_name:
             description: "Username"
             type: string
             format: string
             maxLength: 255
          config_cmd:
             description: "Config Command if the event is generated for any config change in device"
             type: string
             format: string
          cmd_auth_status:
             description: "Command Authorization Status if the event is generated for any config change or config save in device"
             type: string
             format: string
             maxLength: 255
          device_entity_name:
             description: "Device Entity Name"
             type: string
             format: string
          counter_actual_value:
             description: "device actual value for any threadhold violated traps"
             type: string
             format: string
          current_value:
             description: "Current Value, cab be used while sending traps"
             type: string
             format: string
          threshold_value:
             description: "Threshold Value, cab be used while sending traps"
             type: string
             format: string
          entity_type:
             description: "Entity Type"
             type: string
             format: string
          hostname:
             description: "Assign hostname to managed device, if this is not provided, name will be set as host name "
             type: string
             format: string
             minLength: 1
             maxLength: 256
          managed_device_id:
             description: "Managed Device ID"
             type: string
             format: uuid
      - $ref: '#/definitions/ns_event_readwrite'

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