/*
 * 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 alert rule object for patch operations.
 *
 */
class AlertRuleResourcePatch {
  /**
   * Create a AlertRuleResourcePatch.
   * @property {object} [tags] Resource tags
   * @property {string} name the name of the alert rule.
   * @property {string} [description] the description of the alert rule that
   * will be included in the alert email.
   * @property {boolean} isEnabled the flag that indicates whether the alert
   * rule is enabled.
   * @property {object} condition the condition that results in the alert rule
   * being activated.
   * @property {object} [condition.dataSource] the resource from which the rule
   * collects its data. For this type dataSource will always be of type
   * RuleMetricDataSource.
   * @property {string} [condition.dataSource.resourceUri] the resource
   * identifier of the resource the rule monitors. **NOTE**: this property
   * cannot be updated for an existing rule.
   * @property {string} [condition.dataSource.odatatype] Polymorphic
   * Discriminator
   * @property {string} [condition.odatatype] Polymorphic Discriminator
   * @property {array} [actions] the array of actions that are performed when
   * the alert rule becomes active, and when an alert condition is resolved.
   * @property {date} [lastUpdatedTime] Last time the rule was updated in
   * ISO8601 format.
   */
  constructor() {
  }

  /**
   * Defines the metadata of AlertRuleResourcePatch
   *
   * @returns {object} metadata of AlertRuleResourcePatch
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'AlertRuleResourcePatch',
      type: {
        name: 'Composite',
        className: 'AlertRuleResourcePatch',
        modelProperties: {
          tags: {
            required: false,
            serializedName: 'tags',
            type: {
              name: 'Dictionary',
              value: {
                  required: false,
                  serializedName: 'StringElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          name: {
            required: true,
            serializedName: 'properties.name',
            type: {
              name: 'String'
            }
          },
          description: {
            required: false,
            serializedName: 'properties.description',
            type: {
              name: 'String'
            }
          },
          isEnabled: {
            required: true,
            serializedName: 'properties.isEnabled',
            type: {
              name: 'Boolean'
            }
          },
          condition: {
            required: true,
            serializedName: 'properties.condition',
            type: {
              name: 'Composite',
              polymorphicDiscriminator: {
                serializedName: 'odata.type',
                clientName: 'odatatype'
              },
              uberParent: 'RuleCondition',
              className: 'RuleCondition'
            }
          },
          actions: {
            required: false,
            serializedName: 'properties.actions',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'RuleActionElementType',
                  type: {
                    name: 'Composite',
                    polymorphicDiscriminator: {
                      serializedName: 'odata.type',
                      clientName: 'odatatype'
                    },
                    uberParent: 'RuleAction',
                    className: 'RuleAction'
                  }
              }
            }
          },
          lastUpdatedTime: {
            required: false,
            readOnly: true,
            serializedName: 'properties.lastUpdatedTime',
            type: {
              name: 'DateTime'
            }
          }
        }
      }
    };
  }
}

module.exports = AlertRuleResourcePatch;
