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

/**
 * Criterion to filter metrics.
 *
 * @extends models['MultiMetricCriteria']
 */
class MetricCriteria extends models['MultiMetricCriteria'] {
  /**
   * Create a MetricCriteria.
   * @property {string} name Name of the criteria.
   * @property {string} metricName Name of the metric.
   * @property {string} [metricNamespace] Namespace of the metric.
   * @property {object} operator the criteria operator.
   * @property {object} timeAggregation the criteria time aggregation types.
   * @property {number} threshold the criteria threshold value that activates
   * the alert.
   * @property {array} [dimensions] List of dimension conditions.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of MetricCriteria
   *
   * @returns {object} metadata of MetricCriteria
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'StaticThresholdCriterion',
      type: {
        name: 'Composite',
        polymorphicDiscriminator: {
          serializedName: 'criterionType',
          clientName: 'criterionType'
        },
        uberParent: 'MultiMetricCriteria',
        className: 'MetricCriteria',
        modelProperties: {
          criterionType: {
            required: true,
            serializedName: 'criterionType',
            isPolymorphicDiscriminator: true,
            type: {
              name: 'String'
            }
          },
          name: {
            required: true,
            serializedName: 'name',
            type: {
              name: 'String'
            }
          },
          metricName: {
            required: true,
            serializedName: 'metricName',
            type: {
              name: 'String'
            }
          },
          metricNamespace: {
            required: false,
            serializedName: 'metricNamespace',
            type: {
              name: 'String'
            }
          },
          operator: {
            required: true,
            serializedName: 'operator',
            type: {
              name: 'Object'
            }
          },
          timeAggregation: {
            required: true,
            serializedName: 'timeAggregation',
            type: {
              name: 'Object'
            }
          },
          threshold: {
            required: true,
            serializedName: 'threshold',
            type: {
              name: 'Number'
            }
          },
          dimensions: {
            required: false,
            serializedName: 'dimensions',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'MetricDimensionElementType',
                  type: {
                    name: 'Composite',
                    className: 'MetricDimension'
                  }
              }
            }
          }
        }
      }
    };
  }
}

module.exports = MetricCriteria;
