/*
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is
 * regenerated.
 */

'use strict';

const models = require('./index');

/**
 * A rule condition based on a metric crossing a threshold.
 *
 * @extends models['RuleCondition']
 */
class ThresholdRuleCondition extends models['RuleCondition'] {
  /**
   * Create a ThresholdRuleCondition.
   * @property {string} operator the operator used to compare the data and the
   * threshold. Possible values include: 'GreaterThan', 'GreaterThanOrEqual',
   * 'LessThan', 'LessThanOrEqual'
   * @property {number} threshold the threshold value that activates the alert.
   * @property {moment.duration} [windowSize] the period of time (in ISO 8601
   * duration format) that is used to monitor alert activity based on the
   * threshold. If specified then it must be between 5 minutes and 1 day.
   * @property {string} [timeAggregation] the time aggregation operator. How
   * the data that are collected should be combined over time. The default
   * value is the PrimaryAggregationType of the Metric. Possible values
   * include: 'Average', 'Minimum', 'Maximum', 'Total', 'Last'
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of ThresholdRuleCondition
   *
   * @returns {object} metadata of ThresholdRuleCondition
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition',
      type: {
        name: 'Composite',
        polymorphicDiscriminator: {
          serializedName: 'odata.type',
          clientName: 'odatatype'
        },
        uberParent: 'RuleCondition',
        className: 'ThresholdRuleCondition',
        modelProperties: {
          dataSource: {
            required: false,
            serializedName: 'dataSource',
            type: {
              name: 'Composite',
              polymorphicDiscriminator: {
                serializedName: 'odata.type',
                clientName: 'odatatype'
              },
              uberParent: 'RuleDataSource',
              className: 'RuleDataSource'
            }
          },
          odatatype: {
            required: true,
            serializedName: 'odata\\.type',
            isPolymorphicDiscriminator: true,
            type: {
              name: 'String'
            }
          },
          operator: {
            required: true,
            serializedName: 'operator',
            type: {
              name: 'Enum',
              allowedValues: [ 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' ]
            }
          },
          threshold: {
            required: true,
            serializedName: 'threshold',
            type: {
              name: 'Number'
            }
          },
          windowSize: {
            required: false,
            serializedName: 'windowSize',
            type: {
              name: 'TimeSpan'
            }
          },
          timeAggregation: {
            required: false,
            serializedName: 'timeAggregation',
            type: {
              name: 'Enum',
              allowedValues: [ 'Average', 'Minimum', 'Maximum', 'Total', 'Last' ]
            }
          }
        }
      }
    };
  }
}

module.exports = ThresholdRuleCondition;
