swagger: '2.0'
info:
  description: Configuration for Thresholds resource.
  version: 'v2'
  title: threshold
host: 'adm.cloud.com'
schemes:
 - https
# tags are used for organizing operations
tags:
  - name: threshold
    description: Thresholds
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:
    get:
      tags:
        - threshold
      summary: GET all threshold
      operationId: getall_threshold
      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 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 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 resources.
          enum:
            - yes
      responses:
        200:
          description:  for threshold
          schema: 
              $ref: '#/definitions/getthresholdsResponse'
        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
      summary: POST operation for threshold
      operationId: post_threshold
      description: POST operation for threshold
      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
          description: threshold object
          schema:
              $ref: '#/definitions/addthresholdRequest'
      responses:
        200:
          description: add for threshold
          schema: 
              $ref: '#/definitions/addthresholdResponse'
        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/{id}:
    get:
      tags:
        - threshold
      summary: GET by key for threshold
      operationId: getbykey_threshold
      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
          schema: 
              $ref: '#/definitions/getthresholdResponse'
        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
      summary: PUT for threshold
      operationId: putbykey_threshold
      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
          description: threshold object
          schema:
              $ref: '#/definitions/modifythresholdRequest'
      responses:
        200:
          description: add for threshold
          schema: 
              $ref: '#/definitions/modifythresholdResponse'
        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
      summary: Delete for threshold
      operationId: deletebykey_threshold
      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
        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:
  addthresholdRequest:
    type: object
    required:
      - threshold
    properties:
      threshold:
        $ref: '#/definitions/threshold_readwrite'
    title: addthresholdRequest
    example:
      threshold:
        sms_profile: "sms_profile_name"
        stylebook_flag: "true"
        rule: "order_by_metrics_value_20 > 10"
        slack_profile: "slack_profile_name"
        feature: "Analytics"
        city: "Santa Clara"
        ctnsappname: "app_name"
        ip_address: "1.1.1.1"
        mail_profile: "mail_profile_name"
        resource_type: "app_unit"
        is_enabled: "true"
        country: "USA"
        pagerduty_profile: "pagerduty_profile"
        group_name: "WEB"
        reference_key: "attribute"
        region: "LA"
        name: "threshold_config"
        duration: "l3"
        exporter_id: "174483313"
        servicenow_profile: "pagerduty_profile"

  addthresholdResponse:
    type: object
    required:
      - threshold
    properties:
      threshold:
        $ref: '#/definitions/threshold'
    title: addthresholdResponse
    example:
      threshold:
        sms_profile: "sms_profile_name"
        stylebook_flag: "true"
        rule: "order_by_metrics_value_20 > 10"
        slack_profile: "slack_profile_name"
        feature: "Analytics"
        city: "Santa Clara"
        ctnsappname: "app_name"
        ip_address: "1.1.1.1"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        mail_profile: "mail_profile_name"
        resource_type: "app_unit"
        is_enabled: "true"
        tenant_name: "Owner"
        country: "USA"
        pagerduty_profile: "pagerduty_profile"
        group_name: "WEB"
        reference_key: "attribute"
        region: "LA"
        name: "threshold_config"
        duration: "l3"
        exporter_id: "174483313"
        servicenow_profile: "pagerduty_profile"

  getthresholdResponse:
    type: object
    required:
      - threshold
    properties:
      threshold:
        $ref: '#/definitions/threshold'
    title: getthresholdResponse
    example:
      threshold:
        sms_profile: "sms_profile_name"
        stylebook_flag: "true"
        rule: "order_by_metrics_value_20 > 10"
        slack_profile: "slack_profile_name"
        feature: "Analytics"
        city: "Santa Clara"
        ctnsappname: "app_name"
        ip_address: "1.1.1.1"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        mail_profile: "mail_profile_name"
        resource_type: "app_unit"
        is_enabled: "true"
        tenant_name: "Owner"
        country: "USA"
        pagerduty_profile: "pagerduty_profile"
        group_name: "WEB"
        reference_key: "attribute"
        region: "LA"
        name: "threshold_config"
        duration: "l3"
        exporter_id: "174483313"
        servicenow_profile: "pagerduty_profile"

  getthresholdsResponse:
    type: object
    required:
      - threshold
    properties:
      threshold:
        type: array
        items:
          $ref: '#/definitions/threshold'
    title: getthresholdsResponse
    example:
      threshold:
        sms_profile: "sms_profile_name"
        stylebook_flag: "true"
        rule: "order_by_metrics_value_20 > 10"
        slack_profile: "slack_profile_name"
        feature: "Analytics"
        city: "Santa Clara"
        ctnsappname: "app_name"
        ip_address: "1.1.1.1"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        mail_profile: "mail_profile_name"
        resource_type: "app_unit"
        is_enabled: "true"
        tenant_name: "Owner"
        country: "USA"
        pagerduty_profile: "pagerduty_profile"
        group_name: "WEB"
        reference_key: "attribute"
        region: "LA"
        name: "threshold_config"
        duration: "l3"
        exporter_id: "174483313"
        servicenow_profile: "pagerduty_profile"

  modifythresholdRequest:
    type: object
    required:
      - threshold
    properties:
      threshold:
        $ref: '#/definitions/threshold_readwrite'
    title: modifythresholdRequest
    example:
      threshold:
        sms_profile: "sms_profile_name"
        stylebook_flag: "true"
        rule: "order_by_metrics_value_20 > 10"
        slack_profile: "slack_profile_name"
        feature: "Analytics"
        city: "Santa Clara"
        ctnsappname: "app_name"
        ip_address: "1.1.1.1"
        mail_profile: "mail_profile_name"
        resource_type: "app_unit"
        is_enabled: "true"
        country: "USA"
        pagerduty_profile: "pagerduty_profile"
        group_name: "WEB"
        reference_key: "attribute"
        region: "LA"
        name: "threshold_config"
        duration: "l3"
        exporter_id: "174483313"
        servicenow_profile: "pagerduty_profile"

  modifythresholdResponse:
    type: object
    required:
      - threshold
    properties:
      threshold:
        $ref: '#/definitions/threshold'
    title: modifythresholdResponse
    example:
      threshold:
        sms_profile: "sms_profile_name"
        stylebook_flag: "true"
        rule: "order_by_metrics_value_20 > 10"
        slack_profile: "slack_profile_name"
        feature: "Analytics"
        city: "Santa Clara"
        ctnsappname: "app_name"
        ip_address: "1.1.1.1"
        id: "c970e730-6bc5-44c2-a2bf-8dd1382ffb5f"
        mail_profile: "mail_profile_name"
        resource_type: "app_unit"
        is_enabled: "true"
        tenant_name: "Owner"
        country: "USA"
        pagerduty_profile: "pagerduty_profile"
        group_name: "WEB"
        reference_key: "attribute"
        region: "LA"
        name: "threshold_config"
        duration: "l3"
        exporter_id: "174483313"
        servicenow_profile: "pagerduty_profile"

  threshold_readwrite:
    type: object
    properties:
      sms_profile:
        description: "SMS Profile"
        type: string
        format: string
      stylebook_flag:
        description: "Stylebook threshold configuration true or false"
        type: boolean
        format: boolean
      rule:
        description: "Rule"
        type: string
        format: string
      slack_profile:
        description: "Slack Profile"
        type: string
        format: string
      feature:
        description: "feature"
        type: string
        format: string
      city:
        description: "City"
        type: string
        format: string
        maxLength: 256
      ctnsappname:
        description: "AppName"
        type: string
        format: string
      ip_address:
        description: "Field to store the ip address as it is along with any extension"
        type: string
        format: string
        maxLength: 512
      mail_profile:
        description: "Mail Profile"
        type: string
        format: string
      resource_type:
        description: "Resource Type"
        type: string
        format: string
      is_enabled:
        description: "true or false"
        type: string
        format: string
      country:
        description: "Country Code"
        type: string
        format: string
        maxLength: 256
      pagerduty_profile:
        description: "PagerDuty Profile"
        type: string
        format: string
      group_name:
        description: "Group Name"
        type: string
        format: string
      reference_key:
        description: "Reference Key"
        type: string
        format: string
      region:
        description: "Region Code"
        type: string
        format: string
        maxLength: 256
      name:
        description: "name"
        type: string
        format: string
      duration:
        description: "duration of metric to be checked against threshold"
        type: string
        format: string
      exporter_id:
        description: "Exporter Id"
        type: number
        format: int64
      servicenow_profile:
        description: "Servicenow Profile"
        type: string
        format: string

  threshold:
    allOf:
      -
        properties:
          id:
            description: Id is system generated key for all the Thresholds configuration 
            type: string
            format: string
          tenant_name:
             description: "Tenant Name"
             type: string
             format: string
      - $ref: '#/definitions/threshold_readwrite'

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