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

/**
 * The Log Search Rule resource.
 *
 * @extends models['Resource']
 */
class LogSearchRuleResource extends models['Resource'] {
  /**
   * Create a LogSearchRuleResource.
   * @property {string} [description] The description of the Log Search rule.
   * @property {string} [enabled] The flag which indicates whether the Log
   * Search rule is enabled. Value should be true or false. Possible values
   * include: 'true', 'false'
   * @property {date} [lastUpdatedTime] Last time the rule was updated in
   * IS08601 format.
   * @property {string} [provisioningState] Provisioning state of the scheduled
   * query rule. Possible values include: 'Succeeded', 'Deploying', 'Canceled',
   * 'Failed'
   * @property {object} source Data Source against which rule will Query Data
   * @property {string} [source.query] Log search query. Required for action
   * type - AlertingAction
   * @property {array} [source.authorizedResources] List of  Resource referred
   * into query
   * @property {string} [source.dataSourceId] The resource uri over which log
   * search query is to be run.
   * @property {string} [source.queryType] Set value to 'ResultCount'. Possible
   * values include: 'ResultCount'
   * @property {object} [schedule] Schedule (Frequency, Time Window) for rule.
   * Required for action type - AlertingAction
   * @property {number} [schedule.frequencyInMinutes] frequency (in minutes) at
   * which rule condition should be evaluated.
   * @property {number} [schedule.timeWindowInMinutes] Time window for which
   * data needs to be fetched for query (should be greater than or equal to
   * frequencyInMinutes).
   * @property {object} action Action needs to be taken on rule execution.
   * @property {string} [action.odatatype] Polymorphic Discriminator
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of LogSearchRuleResource
   *
   * @returns {object} metadata of LogSearchRuleResource
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'LogSearchRuleResource',
      type: {
        name: 'Composite',
        className: 'LogSearchRuleResource',
        modelProperties: {
          id: {
            required: false,
            readOnly: true,
            serializedName: 'id',
            type: {
              name: 'String'
            }
          },
          name: {
            required: false,
            readOnly: true,
            serializedName: 'name',
            type: {
              name: 'String'
            }
          },
          type: {
            required: false,
            readOnly: true,
            serializedName: 'type',
            type: {
              name: 'String'
            }
          },
          location: {
            required: true,
            serializedName: 'location',
            type: {
              name: 'String'
            }
          },
          tags: {
            required: false,
            serializedName: 'tags',
            type: {
              name: 'Dictionary',
              value: {
                  required: false,
                  serializedName: 'StringElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          description: {
            required: false,
            serializedName: 'properties.description',
            type: {
              name: 'String'
            }
          },
          enabled: {
            required: false,
            serializedName: 'properties.enabled',
            type: {
              name: 'String'
            }
          },
          lastUpdatedTime: {
            required: false,
            readOnly: true,
            serializedName: 'properties.lastUpdatedTime',
            type: {
              name: 'DateTime'
            }
          },
          provisioningState: {
            required: false,
            readOnly: true,
            serializedName: 'properties.provisioningState',
            type: {
              name: 'String'
            }
          },
          source: {
            required: true,
            serializedName: 'properties.source',
            type: {
              name: 'Composite',
              className: 'Source'
            }
          },
          schedule: {
            required: false,
            serializedName: 'properties.schedule',
            type: {
              name: 'Composite',
              className: 'Schedule'
            }
          },
          action: {
            required: true,
            serializedName: 'properties.action',
            type: {
              name: 'Composite',
              polymorphicDiscriminator: {
                serializedName: 'odata.type',
                clientName: 'odatatype'
              },
              uberParent: 'Action',
              className: 'Action'
            }
          }
        }
      }
    };
  }
}

module.exports = LogSearchRuleResource;
