/*
 * 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';

/**
 * The trigger that results in a scaling action.
 *
 */
class MetricTrigger {
  /**
   * Create a MetricTrigger.
   * @property {string} metricName the name of the metric that defines what the
   * rule monitors.
   * @property {string} metricResourceUri the resource identifier of the
   * resource the rule monitors.
   * @property {moment.duration} timeGrain the granularity of metrics the rule
   * monitors. Must be one of the predefined values returned from metric
   * definitions for the metric. Must be between 12 hours and 1 minute.
   * @property {string} statistic the metric statistic type. How the metrics
   * from multiple instances are combined. Possible values include: 'Average',
   * 'Min', 'Max', 'Sum'
   * @property {moment.duration} timeWindow the range of time in which instance
   * data is collected. This value must be greater than the delay in metric
   * collection, which can vary from resource-to-resource. Must be between 12
   * hours and 5 minutes.
   * @property {string} timeAggregation time aggregation type. How the data
   * that is collected should be combined over time. The default value is
   * Average. Possible values include: 'Average', 'Minimum', 'Maximum',
   * 'Total', 'Count', 'Last'
   * @property {string} operator the operator that is used to compare the
   * metric data and the threshold. Possible values include: 'Equals',
   * 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan',
   * 'LessThanOrEqual'
   * @property {number} threshold the threshold of the metric that triggers the
   * scale action.
   */
  constructor() {
  }

  /**
   * Defines the metadata of MetricTrigger
   *
   * @returns {object} metadata of MetricTrigger
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'MetricTrigger',
      type: {
        name: 'Composite',
        className: 'MetricTrigger',
        modelProperties: {
          metricName: {
            required: true,
            serializedName: 'metricName',
            type: {
              name: 'String'
            }
          },
          metricResourceUri: {
            required: true,
            serializedName: 'metricResourceUri',
            type: {
              name: 'String'
            }
          },
          timeGrain: {
            required: true,
            serializedName: 'timeGrain',
            type: {
              name: 'TimeSpan'
            }
          },
          statistic: {
            required: true,
            serializedName: 'statistic',
            type: {
              name: 'Enum',
              allowedValues: [ 'Average', 'Min', 'Max', 'Sum' ]
            }
          },
          timeWindow: {
            required: true,
            serializedName: 'timeWindow',
            type: {
              name: 'TimeSpan'
            }
          },
          timeAggregation: {
            required: true,
            serializedName: 'timeAggregation',
            type: {
              name: 'Enum',
              allowedValues: [ 'Average', 'Minimum', 'Maximum', 'Total', 'Count', 'Last' ]
            }
          },
          operator: {
            required: true,
            serializedName: 'operator',
            type: {
              name: 'Enum',
              allowedValues: [ 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' ]
            }
          },
          threshold: {
            required: true,
            serializedName: 'threshold',
            type: {
              name: 'Number'
            }
          }
        }
      }
    };
  }
}

module.exports = MetricTrigger;
