swagger: '2.0'
info:
  description: Configuration for Threshold Expression resource.
  version: 'v2'
  title: threshold_expression
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: threshold_expression
    description: Threshold Expression
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 Thresholds configuration 
   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/threshold_expression:
    get:
      tags:
        - threshold_expression
      summary: GET all threshold_expression
      operationId: getall_threshold_expression
      description: get threshold configuration
      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 threshold_expression 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 threshold_expression 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 threshold_expression resources.
          enum:
            - yes
      responses:
        200:
          description:  for threshold_expression
          schema: 
              $ref: '#/definitions/getthreshold_expressionsResponse'
        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'

    post:
      tags:
        - threshold_expression
      summary: POST operation for threshold_expression
      operationId: post_threshold_expression
      description: POST operation for threshold_expression
      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: onerror
          description: Use this parameter to set the onerror status for nitro request. Applicable only for bulk requests.
          required: false
          type: string
          default: CONTINUE
          enum:
            - EXIT
            - CONTINUE
        - in: body
          name: threshold_expression
          description: threshold_expression object
          schema:
              $ref: '#/definitions/addthreshold_expressionRequest'
      responses:
        200:
          description: add for threshold_expression
          schema: 
              $ref: '#/definitions/addthreshold_expressionResponse'
        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/threshold_expression/{id}:
    get:
      tags:
        - threshold_expression
      summary: GET by key for threshold_expression
      operationId: getbykey_threshold_expression
      description: get threshold configuration
      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: add for threshold_expression
          schema: 
              $ref: '#/definitions/getthreshold_expressionResponse'
        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:
        - threshold_expression
      summary: PUT for threshold_expression
      operationId: putbykey_threshold_expression
      description: modify threshold configuraiton
      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: threshold_expression
          description: threshold_expression object
          schema:
              $ref: '#/definitions/modifythreshold_expressionRequest'
      responses:
        200:
          description: add for threshold_expression
          schema: 
              $ref: '#/definitions/modifythreshold_expressionResponse'
        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:
        - threshold_expression
      summary: Delete for threshold_expression
      operationId: deletebykey_threshold_expression
      description: Delete threshold configuration
      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: add for threshold_expression
        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:
  addthreshold_expressionRequest:
    type: object
    required:
      - threshold_expression
    properties:
      threshold_expression:
        $ref: '#/definitions/threshold_expression_readwrite'
    title: addthreshold_expressionRequest
    example:
      threshold_expression:
        occurence: "10"
        rule: "Hits > 10"
        threshold_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  addthreshold_expressionResponse:
    type: object
    required:
      - threshold_expression
    properties:
      threshold_expression:
        $ref: '#/definitions/threshold_expression'
    title: addthreshold_expressionResponse
    example:
      threshold_expression:
        occurence: "10"
        rule: "Hits > 10"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        threshold_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  getthreshold_expressionResponse:
    type: object
    required:
      - threshold_expression
    properties:
      threshold_expression:
        $ref: '#/definitions/threshold_expression'
    title: getthreshold_expressionResponse
    example:
      threshold_expression:
        occurence: "10"
        rule: "Hits > 10"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        threshold_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  getthreshold_expressionsResponse:
    type: object
    required:
      - threshold_expression
    properties:
      threshold_expression:
        type: array
        items:
          $ref: '#/definitions/threshold_expression'
    title: getthreshold_expressionsResponse
    example:
      threshold_expression:
        occurence: "10"
        rule: "Hits > 10"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        threshold_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  modifythreshold_expressionRequest:
    type: object
    required:
      - threshold_expression
    properties:
      threshold_expression:
        $ref: '#/definitions/threshold_expression_readwrite'
    title: modifythreshold_expressionRequest
    example:
      threshold_expression:
        occurence: "10"
        rule: "Hits > 10"
        threshold_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  modifythreshold_expressionResponse:
    type: object
    required:
      - threshold_expression
    properties:
      threshold_expression:
        $ref: '#/definitions/threshold_expression'
    title: modifythreshold_expressionResponse
    example:
      threshold_expression:
        occurence: "10"
        rule: "Hits > 10"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        threshold_id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"

  threshold_expression_readwrite:
    type: object
    properties:
      occurence:
        description: "No. of time rules happened."
        type: integer
        format: int32
      rule:
        description: "Rule to execute."
        type: string
        format: string
      threshold_id:
        description: "Id of threshold_configuration from threshold table"
        type: string
        format: uuid

  threshold_expression:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all the Thresholds configuration 
            type: string
            format: string
      - $ref: '#/definitions/threshold_expression_readwrite'

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