/*
 * 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 certain number of locations failing.
 *
 * @extends models['RuleCondition']
 */
class LocationThresholdRuleCondition extends models['RuleCondition'] {
  /**
   * Create a LocationThresholdRuleCondition.
   * @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 {number} failedLocationCount the number of locations that must
   * fail to activate the alert.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of LocationThresholdRuleCondition
   *
   * @returns {object} metadata of LocationThresholdRuleCondition
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition',
      type: {
        name: 'Composite',
        polymorphicDiscriminator: {
          serializedName: 'odata.type',
          clientName: 'odatatype'
        },
        uberParent: 'RuleCondition',
        className: 'LocationThresholdRuleCondition',
        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'
            }
          },
          windowSize: {
            required: false,
            serializedName: 'windowSize',
            type: {
              name: 'TimeSpan'
            }
          },
          failedLocationCount: {
            required: true,
            serializedName: 'failedLocationCount',
            constraints: {
              InclusiveMinimum: 0
            },
            type: {
              name: 'Number'
            }
          }
        }
      }
    };
  }
}

module.exports = LocationThresholdRuleCondition;
