From d8644591aa437b677eea260f13f4755cc091e3e1 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 24 Apr 2018 10:53:23 -0700 Subject: [PATCH] [AutoPR monitor/resource-manager] Added GA API version for Scheduled Query Rule (#2721) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Generated from 2e4c790d16eb6be9299db7a75798bca1697fd5e9 Added GA API version for Scheduled Query Rule Added GA API version for Scheduled Query Rule * Generated from d183bad923d3a0a4092d21203f850db6cde9f4e9 Resolving Comments Resolving Comments * Generated from df40ac3bbf17ea0180dd4adff2af3094065feca0 Made SKU as top level proprty and including generic error response format Couple of changes - 1. Made SKU as top level proprty as mentioned here - https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/resource-api-reference.md#put-resource 2. including generic error response format * Generated from 7578160670750a68d05f77ec8163b25bb72f391e Minor Changes to align implementation 1. Removed SKU - Billing Model is still under discussion, hence need not to be exposed to customers. 2. Enabled field ichanged to align with camel case. 3. 'throttleTillDate' in properties.action changed to 'throttlingInMin' to denote correct meaning and it’s data type changed to number instead of date. 4. 'status' to be removed in properties.action from examples. 5. 'severity' made a required field in properties.action. 6. Removed Examples from original spec json * Generated from fb180fb311d73934d0f5150f72638cc3de155ea0 Added Default Response payload in all APIs Changes - 1. Added Default Response payload in all APIs 2. Made azNs description more clear * Generated from fb180fb311d73934d0f5150f72638cc3de155ea0 Added Default Response payload in all APIs Changes - 1. Added Default Response payload in all APIs 2. Made azNs description more clear --- .../monitorManagement/lib/models/action.js | 14 + .../lib/models/actionGroupResource.js | 2 +- .../lib/models/alertingAction.js | 163 ++ .../lib/models/azNsActionGroup.js | 76 + .../monitorManagement/lib/models/index.d.ts | 243 +++ .../monitorManagement/lib/models/index.js | 11 +- .../lib/models/logSearchRuleResource.js | 180 +++ .../models/logSearchRuleResourceCollection.js | 59 + .../lib/models/metricAlertResource.js | 5 + .../lib/models/metricAlertResourcePatch.js | 5 + .../lib/models/metricTrigger.js | 28 + .../monitorManagement/lib/models/scaleRule.js | 7 + .../monitorManagement/lib/models/schedule.js | 63 + .../monitorManagement/lib/models/sku1.js | 53 + .../monitorManagement/lib/models/source.js | 87 ++ .../lib/models/triggerCondition.js | 106 ++ .../lib/monitorManagementClient.d.ts | 1 + .../lib/monitorManagementClient.js | 1 + .../lib/operations/index.d.ts | 405 +++++ .../monitorManagement/lib/operations/index.js | 1 + .../lib/operations/scheduledQueryRules.js | 1355 +++++++++++++++++ 21 files changed, 2863 insertions(+), 2 deletions(-) create mode 100644 lib/services/monitorManagement/lib/models/alertingAction.js create mode 100644 lib/services/monitorManagement/lib/models/azNsActionGroup.js create mode 100644 lib/services/monitorManagement/lib/models/logSearchRuleResource.js create mode 100644 lib/services/monitorManagement/lib/models/logSearchRuleResourceCollection.js create mode 100644 lib/services/monitorManagement/lib/models/schedule.js create mode 100644 lib/services/monitorManagement/lib/models/sku1.js create mode 100644 lib/services/monitorManagement/lib/models/source.js create mode 100644 lib/services/monitorManagement/lib/models/triggerCondition.js create mode 100644 lib/services/monitorManagement/lib/operations/scheduledQueryRules.js diff --git a/lib/services/monitorManagement/lib/models/action.js b/lib/services/monitorManagement/lib/models/action.js index 91eaf1b94d..e5f19a803c 100644 --- a/lib/services/monitorManagement/lib/models/action.js +++ b/lib/services/monitorManagement/lib/models/action.js @@ -19,6 +19,7 @@ class Action { * Create a Action. * @member {string} [actionGroupId] the id of the action group to use. * @member {object} [webhookProperties] + * @member {string} odatatype Polymorphic Discriminator */ constructor() { } @@ -35,6 +36,11 @@ class Action { serializedName: 'Action', type: { name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'Action', className: 'Action', modelProperties: { actionGroupId: { @@ -57,6 +63,14 @@ class Action { } } } + }, + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } } } } diff --git a/lib/services/monitorManagement/lib/models/actionGroupResource.js b/lib/services/monitorManagement/lib/models/actionGroupResource.js index f69df88ef8..9a443885a8 100644 --- a/lib/services/monitorManagement/lib/models/actionGroupResource.js +++ b/lib/services/monitorManagement/lib/models/actionGroupResource.js @@ -111,7 +111,7 @@ class ActionGroupResource extends models['Resource'] { required: true, serializedName: 'properties.groupShortName', constraints: { - MaxLength: 12 + MaxLength: 15 }, type: { name: 'String' diff --git a/lib/services/monitorManagement/lib/models/alertingAction.js b/lib/services/monitorManagement/lib/models/alertingAction.js new file mode 100644 index 0000000000..467e671bba --- /dev/null +++ b/lib/services/monitorManagement/lib/models/alertingAction.js @@ -0,0 +1,163 @@ +/* + * 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'); + +/** + * Specifiy action need to be taken when rule type is Alert + * + * @extends models['Action'] + */ +class AlertingAction extends models['Action'] { + /** + * Create a AlertingAction. + * @member {string} severity Severity of the alert. Possible values include: + * '0', '1', '2', '3', '4' + * @member {object} aznsAction azns notification group reference. + * @member {array} [aznsAction.actionGroup] Azure Group reference. + * @member {string} [aznsAction.emailSubject] Custom subject for Azns email + * @member {string} [aznsAction.customWebhookPayload] Custom webhook payload + * to be send to azns action group + * @member {number} [throttlingInMin] time (in minutes) for which Alerts + * should be throttled + * @member {object} trigger The trigger condition that results in the alert + * rule being. + * @member {string} [trigger.thresholdOperator] Evaluation operation for rule + * - 'GreaterThan' or 'LessThan. Possible values include: 'GreaterThan', + * 'LessThan', 'Equal' + * @member {number} [trigger.threshold] Result or count threshold based on + * which rule should be triggered. + * @member {object} [trigger.metricTrigger] Trigger condition for metric + * query rule + * @member {string} [trigger.metricTrigger.metricName] the name of the metric + * that defines what the rule monitors. + * @member {string} [trigger.metricTrigger.metricResourceUri] the resource + * identifier of the resource the rule monitors. + * @member {moment.duration} [trigger.metricTrigger.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. + * @member {string} [trigger.metricTrigger.statistic] the metric statistic + * type. How the metrics from multiple instances are combined. Possible + * values include: 'Average', 'Min', 'Max', 'Sum' + * @member {moment.duration} [trigger.metricTrigger.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. + * @member {string} [trigger.metricTrigger.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' + * @member {string} [trigger.metricTrigger.operator] the operator that is + * used to compare the metric data and the threshold. Possible values + * include: 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', + * 'LessThan', 'LessThanOrEqual' + * @member {number} [trigger.metricTrigger.threshold] the threshold of the + * metric that triggers the scale action. + * @member {string} [trigger.metricTrigger.thresholdOperator] Evaluation + * operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible + * values include: 'GreaterThan', 'LessThan', 'Equal' + * @member {string} [trigger.metricTrigger.metricTriggerType] Metric Trigger + * Type - 'Consecutive' or 'Total'. Possible values include: 'Consecutive', + * 'Total' + * @member {string} [trigger.metricTrigger.metricColumn] Evaluation of metric + * on a particular column + */ + constructor() { + super(); + } + + /** + * Defines the metadata of AlertingAction + * + * @returns {object} metadata of AlertingAction + * + */ + mapper() { + return { + required: false, + serializedName: 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'Action', + className: 'AlertingAction', + modelProperties: { + actionGroupId: { + required: false, + serializedName: 'actionGroupId', + type: { + name: 'String' + } + }, + webhookProperties: { + required: false, + serializedName: 'webhookProperties', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + severity: { + required: true, + serializedName: 'severity', + type: { + name: 'String' + } + }, + aznsAction: { + required: true, + serializedName: 'aznsAction', + type: { + name: 'Composite', + className: 'AzNsActionGroup' + } + }, + throttlingInMin: { + required: false, + serializedName: 'throttlingInMin', + type: { + name: 'Number' + } + }, + trigger: { + required: true, + serializedName: 'trigger', + type: { + name: 'Composite', + className: 'TriggerCondition' + } + } + } + } + }; + } +} + +module.exports = AlertingAction; diff --git a/lib/services/monitorManagement/lib/models/azNsActionGroup.js b/lib/services/monitorManagement/lib/models/azNsActionGroup.js new file mode 100644 index 0000000000..6a8177b293 --- /dev/null +++ b/lib/services/monitorManagement/lib/models/azNsActionGroup.js @@ -0,0 +1,76 @@ +/* + * 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'; + +/** + * azns notification group + * + */ +class AzNsActionGroup { + /** + * Create a AzNsActionGroup. + * @member {array} [actionGroup] Azure Group reference. + * @member {string} [emailSubject] Custom subject for Azns email + * @member {string} [customWebhookPayload] Custom webhook payload to be send + * to azns action group + */ + constructor() { + } + + /** + * Defines the metadata of AzNsActionGroup + * + * @returns {object} metadata of AzNsActionGroup + * + */ + mapper() { + return { + required: false, + serializedName: 'AzNsActionGroup', + type: { + name: 'Composite', + className: 'AzNsActionGroup', + modelProperties: { + actionGroup: { + required: false, + serializedName: 'actionGroup', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + emailSubject: { + required: false, + serializedName: 'emailSubject', + type: { + name: 'String' + } + }, + customWebhookPayload: { + required: false, + serializedName: 'customWebhookPayload', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AzNsActionGroup; diff --git a/lib/services/monitorManagement/lib/models/index.d.ts b/lib/services/monitorManagement/lib/models/index.d.ts index 44807752fe..7daa282894 100644 --- a/lib/services/monitorManagement/lib/models/index.d.ts +++ b/lib/services/monitorManagement/lib/models/index.d.ts @@ -84,6 +84,12 @@ export interface ScaleCapacity { * 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' * @member {number} threshold the threshold of the metric that triggers the * scale action. + * @member {string} [thresholdOperator] Evaluation operation for Metric + * -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: + * 'GreaterThan', 'LessThan', 'Equal' + * @member {string} [metricTriggerType] Metric Trigger Type - 'Consecutive' or + * 'Total'. Possible values include: 'Consecutive', 'Total' + * @member {string} [metricColumn] Evaluation of metric on a particular column */ export interface MetricTrigger { metricName: string; @@ -94,6 +100,9 @@ export interface MetricTrigger { timeAggregation: string; operator: string; threshold: number; + thresholdOperator?: string; + metricTriggerType?: string; + metricColumn?: string; } /** @@ -154,6 +163,13 @@ export interface ScaleAction { * 'LessThanOrEqual' * @member {number} [metricTrigger.threshold] the threshold of the metric that * triggers the scale action. + * @member {string} [metricTrigger.thresholdOperator] Evaluation operation for + * Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: + * 'GreaterThan', 'LessThan', 'Equal' + * @member {string} [metricTrigger.metricTriggerType] Metric Trigger Type - + * 'Consecutive' or 'Total'. Possible values include: 'Consecutive', 'Total' + * @member {string} [metricTrigger.metricColumn] Evaluation of metric on a + * particular column * @member {object} scaleAction the parameters for the scaling action. * @member {string} [scaleAction.direction] the scale direction. Whether the * scaling action increases or decreases the number of instances. Possible @@ -1984,10 +2000,12 @@ export interface CalculateBaselineResponse { * * @member {string} [actionGroupId] the id of the action group to use. * @member {object} [webhookProperties] + * @member {string} odatatype Polymorphic Discriminator */ export interface Action { actionGroupId?: string; webhookProperties?: { [propertyName: string]: string }; + odatatype: string; } /** @@ -2184,6 +2202,221 @@ export interface MetricAlertSingleResourceMultipleMetricCriteria extends MetricA allOf?: MetricCriteria[]; } +/** + * @class + * Initializes a new instance of the Source class. + * @constructor + * Specifies the log search query. + * + * @member {string} query Log search query. + * @member {array} [authorizedResources] List of Resource referred into query + * @member {string} datasourceId The resource uri over which log search query + * is to be run. + * @member {string} [queryType] Set value to ResultCount if query should be + * returning search result count. Set it to Number if its a metric query. + * Possible values include: 'ResultCount' + */ +export interface Source { + query: string; + authorizedResources?: string[]; + datasourceId: string; + queryType?: string; +} + +/** + * @class + * Initializes a new instance of the Schedule class. + * @constructor + * Defines how often to run the search and the time interval. + * + * @member {number} frequencyInMinutes frequency (in minutes) at which rule + * condition should be evaluated. + * @member {number} timeWindowInMinutes Time window for which data needs to be + * fetched for query (should be greater than or equal to frequencyInMinutes). + */ +export interface Schedule { + frequencyInMinutes: number; + timeWindowInMinutes: number; +} + +/** + * @class + * Initializes a new instance of the LogSearchRuleResource class. + * @constructor + * The Log Search Rule resource. + * + * @member {string} [description] The description of the Log Search rule. + * @member {string} [enabled] The flag which indicates whether the Log Search + * rule is enabled. Value should be true or false. Possible values include: + * 'true', 'false' + * @member {date} [lastUpdatedTime] Last time the rule was updated in IS08601 + * format. + * @member {string} [provisioningState] Provisioning state of the + * scheduledquery rule. Possible values include: 'Succeeded', 'Deploying', + * 'Canceled', 'Failed' + * @member {object} source Data Source against which rule will Query Data + * @member {string} [source.query] Log search query. + * @member {array} [source.authorizedResources] List of Resource referred into + * query + * @member {string} [source.datasourceId] The resource uri over which log + * search query is to be run. + * @member {string} [source.queryType] Set value to ResultCount if query should + * be returning search result count. Set it to Number if its a metric query. + * Possible values include: 'ResultCount' + * @member {object} schedule Schedule (Frequnecy, Time Window) for rule. + * @member {number} [schedule.frequencyInMinutes] frequency (in minutes) at + * which rule condition should be evaluated. + * @member {number} [schedule.timeWindowInMinutes] Time window for which data + * needs to be fetched for query (should be greater than or equal to + * frequencyInMinutes). + * @member {object} action Action needs to be taken on rule execution. + * @member {string} [action.actionGroupId] the id of the action group to use. + * @member {object} [action.webhookProperties] + * @member {string} [action.odatatype] Polymorphic Discriminator + */ +export interface LogSearchRuleResource extends Resource { + description?: string; + enabled?: string; + readonly lastUpdatedTime?: Date; + readonly provisioningState?: string; + source: Source; + schedule: Schedule; + action: Action; +} + +/** + * @class + * Initializes a new instance of the TriggerCondition class. + * @constructor + * The condition that results in the Log Search rule. + * + * @member {string} thresholdOperator Evaluation operation for rule - + * 'GreaterThan' or 'LessThan. Possible values include: 'GreaterThan', + * 'LessThan', 'Equal' + * @member {number} threshold Result or count threshold based on which rule + * should be triggered. + * @member {object} [metricTrigger] Trigger condition for metric query rule + * @member {string} [metricTrigger.metricName] the name of the metric that + * defines what the rule monitors. + * @member {string} [metricTrigger.metricResourceUri] the resource identifier + * of the resource the rule monitors. + * @member {moment.duration} [metricTrigger.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. + * @member {string} [metricTrigger.statistic] the metric statistic type. How + * the metrics from multiple instances are combined. Possible values include: + * 'Average', 'Min', 'Max', 'Sum' + * @member {moment.duration} [metricTrigger.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. + * @member {string} [metricTrigger.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' + * @member {string} [metricTrigger.operator] the operator that is used to + * compare the metric data and the threshold. Possible values include: + * 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + * 'LessThanOrEqual' + * @member {number} [metricTrigger.threshold] the threshold of the metric that + * triggers the scale action. + * @member {string} [metricTrigger.thresholdOperator] Evaluation operation for + * Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: + * 'GreaterThan', 'LessThan', 'Equal' + * @member {string} [metricTrigger.metricTriggerType] Metric Trigger Type - + * 'Consecutive' or 'Total'. Possible values include: 'Consecutive', 'Total' + * @member {string} [metricTrigger.metricColumn] Evaluation of metric on a + * particular column + */ +export interface TriggerCondition { + thresholdOperator: string; + threshold: number; + metricTrigger?: MetricTrigger; +} + +/** + * @class + * Initializes a new instance of the AzNsActionGroup class. + * @constructor + * azns notification group + * + * @member {array} [actionGroup] Azure Group reference. + * @member {string} [emailSubject] Custom subject for Azns email + * @member {string} [customWebhookPayload] Custom webhook payload to be send to + * azns action group + */ +export interface AzNsActionGroup { + actionGroup?: string[]; + emailSubject?: string; + customWebhookPayload?: string; +} + +/** + * @class + * Initializes a new instance of the AlertingAction class. + * @constructor + * Specifiy action need to be taken when rule type is Alert + * + * @member {string} severity Severity of the alert. Possible values include: + * '0', '1', '2', '3', '4' + * @member {object} aznsAction azns notification group reference. + * @member {array} [aznsAction.actionGroup] Azure Group reference. + * @member {string} [aznsAction.emailSubject] Custom subject for Azns email + * @member {string} [aznsAction.customWebhookPayload] Custom webhook payload to + * be send to azns action group + * @member {number} [throttlingInMin] time (in minutes) for which Alerts should + * be throttled + * @member {object} trigger The trigger condition that results in the alert + * rule being. + * @member {string} [trigger.thresholdOperator] Evaluation operation for rule - + * 'GreaterThan' or 'LessThan. Possible values include: 'GreaterThan', + * 'LessThan', 'Equal' + * @member {number} [trigger.threshold] Result or count threshold based on + * which rule should be triggered. + * @member {object} [trigger.metricTrigger] Trigger condition for metric query + * rule + * @member {string} [trigger.metricTrigger.metricName] the name of the metric + * that defines what the rule monitors. + * @member {string} [trigger.metricTrigger.metricResourceUri] the resource + * identifier of the resource the rule monitors. + * @member {moment.duration} [trigger.metricTrigger.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. + * @member {string} [trigger.metricTrigger.statistic] the metric statistic + * type. How the metrics from multiple instances are combined. Possible values + * include: 'Average', 'Min', 'Max', 'Sum' + * @member {moment.duration} [trigger.metricTrigger.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. + * @member {string} [trigger.metricTrigger.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' + * @member {string} [trigger.metricTrigger.operator] the operator that is used + * to compare the metric data and the threshold. Possible values include: + * 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + * 'LessThanOrEqual' + * @member {number} [trigger.metricTrigger.threshold] the threshold of the + * metric that triggers the scale action. + * @member {string} [trigger.metricTrigger.thresholdOperator] Evaluation + * operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible + * values include: 'GreaterThan', 'LessThan', 'Equal' + * @member {string} [trigger.metricTrigger.metricTriggerType] Metric Trigger + * Type - 'Consecutive' or 'Total'. Possible values include: 'Consecutive', + * 'Total' + * @member {string} [trigger.metricTrigger.metricColumn] Evaluation of metric + * on a particular column + */ +export interface AlertingAction extends Action { + severity: string; + aznsAction: AzNsActionGroup; + throttlingInMin?: number; + trigger: TriggerCondition; +} + /** * @class @@ -2296,3 +2529,13 @@ export interface MetricDefinitionCollection extends Array { */ export interface MetricAlertResourceCollection extends Array { } + +/** + * @class + * Initializes a new instance of the LogSearchRuleResourceCollection class. + * @constructor + * Represents a collection of Log Search rule resources. + * + */ +export interface LogSearchRuleResourceCollection extends Array { +} diff --git a/lib/services/monitorManagement/lib/models/index.js b/lib/services/monitorManagement/lib/models/index.js index 878adabbd3..b863800b50 100644 --- a/lib/services/monitorManagement/lib/models/index.js +++ b/lib/services/monitorManagement/lib/models/index.js @@ -105,6 +105,12 @@ exports.MetricAlertStatusCollection = require('./metricAlertStatusCollection'); exports.MetricDimension = require('./metricDimension'); exports.MetricCriteria = require('./metricCriteria'); exports.MetricAlertSingleResourceMultipleMetricCriteria = require('./metricAlertSingleResourceMultipleMetricCriteria'); +exports.Source = require('./source'); +exports.Schedule = require('./schedule'); +exports.LogSearchRuleResource = require('./logSearchRuleResource'); +exports.TriggerCondition = require('./triggerCondition'); +exports.AzNsActionGroup = require('./azNsActionGroup'); +exports.AlertingAction = require('./alertingAction'); exports.AutoscaleSettingResourceCollection = require('./autoscaleSettingResourceCollection'); exports.IncidentListResult = require('./incidentListResult'); exports.AlertRuleResourceCollection = require('./alertRuleResourceCollection'); @@ -115,6 +121,7 @@ exports.EventDataCollection = require('./eventDataCollection'); exports.EventCategoryCollection = require('./eventCategoryCollection'); exports.MetricDefinitionCollection = require('./metricDefinitionCollection'); exports.MetricAlertResourceCollection = require('./metricAlertResourceCollection'); +exports.LogSearchRuleResourceCollection = require('./logSearchRuleResourceCollection'); exports.discriminators = { 'RuleDataSource' : exports.RuleDataSource, 'RuleCondition' : exports.RuleCondition, @@ -126,6 +133,8 @@ exports.discriminators = { 'RuleAction' : exports.RuleAction, 'RuleAction.Microsoft.Azure.Management.Insights.Models.RuleEmailAction' : exports.RuleEmailAction, 'RuleAction.Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' : exports.RuleWebhookAction, + 'Action' : exports.Action, 'MetricAlertCriteria' : exports.MetricAlertCriteria, - 'MetricAlertCriteria.Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' : exports.MetricAlertSingleResourceMultipleMetricCriteria + 'MetricAlertCriteria.Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' : exports.MetricAlertSingleResourceMultipleMetricCriteria, + 'Action.Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' : exports.AlertingAction }; diff --git a/lib/services/monitorManagement/lib/models/logSearchRuleResource.js b/lib/services/monitorManagement/lib/models/logSearchRuleResource.js new file mode 100644 index 0000000000..d791a93e32 --- /dev/null +++ b/lib/services/monitorManagement/lib/models/logSearchRuleResource.js @@ -0,0 +1,180 @@ +/* + * 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. + * @member {string} [description] The description of the Log Search rule. + * @member {string} [enabled] The flag which indicates whether the Log Search + * rule is enabled. Value should be true or false. Possible values include: + * 'true', 'false' + * @member {date} [lastUpdatedTime] Last time the rule was updated in IS08601 + * format. + * @member {string} [provisioningState] Provisioning state of the + * scheduledquery rule. Possible values include: 'Succeeded', 'Deploying', + * 'Canceled', 'Failed' + * @member {object} source Data Source against which rule will Query Data + * @member {string} [source.query] Log search query. + * @member {array} [source.authorizedResources] List of Resource referred + * into query + * @member {string} [source.datasourceId] The resource uri over which log + * search query is to be run. + * @member {string} [source.queryType] Set value to ResultCount if query + * should be returning search result count. Set it to Number if its a metric + * query. Possible values include: 'ResultCount' + * @member {object} schedule Schedule (Frequnecy, Time Window) for rule. + * @member {number} [schedule.frequencyInMinutes] frequency (in minutes) at + * which rule condition should be evaluated. + * @member {number} [schedule.timeWindowInMinutes] Time window for which data + * needs to be fetched for query (should be greater than or equal to + * frequencyInMinutes). + * @member {object} action Action needs to be taken on rule execution. + * @member {string} [action.actionGroupId] the id of the action group to use. + * @member {object} [action.webhookProperties] + * @member {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: true, + 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; diff --git a/lib/services/monitorManagement/lib/models/logSearchRuleResourceCollection.js b/lib/services/monitorManagement/lib/models/logSearchRuleResourceCollection.js new file mode 100644 index 0000000000..ed1c688271 --- /dev/null +++ b/lib/services/monitorManagement/lib/models/logSearchRuleResourceCollection.js @@ -0,0 +1,59 @@ +/* + * 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'; + +/** + * Represents a collection of Log Search rule resources. + */ +class LogSearchRuleResourceCollection extends Array { + /** + * Create a LogSearchRuleResourceCollection. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of LogSearchRuleResourceCollection + * + * @returns {object} metadata of LogSearchRuleResourceCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'LogSearchRuleResourceCollection', + type: { + name: 'Composite', + className: 'LogSearchRuleResourceCollection', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'LogSearchRuleResourceElementType', + type: { + name: 'Composite', + className: 'LogSearchRuleResource' + } + } + } + } + } + } + }; + } +} + +module.exports = LogSearchRuleResourceCollection; diff --git a/lib/services/monitorManagement/lib/models/metricAlertResource.js b/lib/services/monitorManagement/lib/models/metricAlertResource.js index c21174220c..91a31fa6dd 100644 --- a/lib/services/monitorManagement/lib/models/metricAlertResource.js +++ b/lib/services/monitorManagement/lib/models/metricAlertResource.js @@ -186,6 +186,11 @@ class MetricAlertResource extends models['Resource'] { serializedName: 'ActionElementType', type: { name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'Action', className: 'Action' } } diff --git a/lib/services/monitorManagement/lib/models/metricAlertResourcePatch.js b/lib/services/monitorManagement/lib/models/metricAlertResourcePatch.js index 1832373f2d..452a6bf1b2 100644 --- a/lib/services/monitorManagement/lib/models/metricAlertResourcePatch.js +++ b/lib/services/monitorManagement/lib/models/metricAlertResourcePatch.js @@ -154,6 +154,11 @@ class MetricAlertResourcePatch { serializedName: 'ActionElementType', type: { name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'Action', className: 'Action' } } diff --git a/lib/services/monitorManagement/lib/models/metricTrigger.js b/lib/services/monitorManagement/lib/models/metricTrigger.js index 09e76603e5..3591915bf6 100644 --- a/lib/services/monitorManagement/lib/models/metricTrigger.js +++ b/lib/services/monitorManagement/lib/models/metricTrigger.js @@ -39,6 +39,13 @@ class MetricTrigger { * 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' * @member {number} threshold the threshold of the metric that triggers the * scale action. + * @member {string} [thresholdOperator] Evaluation operation for Metric + * -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: + * 'GreaterThan', 'LessThan', 'Equal' + * @member {string} [metricTriggerType] Metric Trigger Type - 'Consecutive' + * or 'Total'. Possible values include: 'Consecutive', 'Total' + * @member {string} [metricColumn] Evaluation of metric on a particular + * column */ constructor() { } @@ -115,6 +122,27 @@ class MetricTrigger { type: { name: 'Number' } + }, + thresholdOperator: { + required: false, + serializedName: 'thresholdOperator', + type: { + name: 'String' + } + }, + metricTriggerType: { + required: false, + serializedName: 'metricTriggerType', + type: { + name: 'String' + } + }, + metricColumn: { + required: false, + serializedName: 'metricColumn', + type: { + name: 'String' + } } } } diff --git a/lib/services/monitorManagement/lib/models/scaleRule.js b/lib/services/monitorManagement/lib/models/scaleRule.js index 0836d498c2..3114436dd0 100644 --- a/lib/services/monitorManagement/lib/models/scaleRule.js +++ b/lib/services/monitorManagement/lib/models/scaleRule.js @@ -46,6 +46,13 @@ class ScaleRule { * 'LessThanOrEqual' * @member {number} [metricTrigger.threshold] the threshold of the metric * that triggers the scale action. + * @member {string} [metricTrigger.thresholdOperator] Evaluation operation + * for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values + * include: 'GreaterThan', 'LessThan', 'Equal' + * @member {string} [metricTrigger.metricTriggerType] Metric Trigger Type - + * 'Consecutive' or 'Total'. Possible values include: 'Consecutive', 'Total' + * @member {string} [metricTrigger.metricColumn] Evaluation of metric on a + * particular column * @member {object} scaleAction the parameters for the scaling action. * @member {string} [scaleAction.direction] the scale direction. Whether the * scaling action increases or decreases the number of instances. Possible diff --git a/lib/services/monitorManagement/lib/models/schedule.js b/lib/services/monitorManagement/lib/models/schedule.js new file mode 100644 index 0000000000..bc53afa278 --- /dev/null +++ b/lib/services/monitorManagement/lib/models/schedule.js @@ -0,0 +1,63 @@ +/* + * 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'; + +/** + * Defines how often to run the search and the time interval. + * + */ +class Schedule { + /** + * Create a Schedule. + * @member {number} frequencyInMinutes frequency (in minutes) at which rule + * condition should be evaluated. + * @member {number} timeWindowInMinutes Time window for which data needs to + * be fetched for query (should be greater than or equal to + * frequencyInMinutes). + */ + constructor() { + } + + /** + * Defines the metadata of Schedule + * + * @returns {object} metadata of Schedule + * + */ + mapper() { + return { + required: false, + serializedName: 'Schedule', + type: { + name: 'Composite', + className: 'Schedule', + modelProperties: { + frequencyInMinutes: { + required: true, + serializedName: 'frequencyInMinutes', + type: { + name: 'Number' + } + }, + timeWindowInMinutes: { + required: true, + serializedName: 'timeWindowInMinutes', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = Schedule; diff --git a/lib/services/monitorManagement/lib/models/sku1.js b/lib/services/monitorManagement/lib/models/sku1.js new file mode 100644 index 0000000000..24be749815 --- /dev/null +++ b/lib/services/monitorManagement/lib/models/sku1.js @@ -0,0 +1,53 @@ +/* + * 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'; + +/** + * SKU of rule + * + */ +class Sku1 { + /** + * Create a Sku1. + * @member {string} [name] The name of the SKU (L1, L2, L3). Possible values + * include: 'L1', 'L2', 'L3' + */ + constructor() { + } + + /** + * Defines the metadata of Sku1 + * + * @returns {object} metadata of Sku1 + * + */ + mapper() { + return { + required: false, + serializedName: 'Sku', + type: { + name: 'Composite', + className: 'Sku1', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Sku1; diff --git a/lib/services/monitorManagement/lib/models/source.js b/lib/services/monitorManagement/lib/models/source.js new file mode 100644 index 0000000000..21f7bc859f --- /dev/null +++ b/lib/services/monitorManagement/lib/models/source.js @@ -0,0 +1,87 @@ +/* + * 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'; + +/** + * Specifies the log search query. + * + */ +class Source { + /** + * Create a Source. + * @member {string} query Log search query. + * @member {array} [authorizedResources] List of Resource referred into + * query + * @member {string} datasourceId The resource uri over which log search query + * is to be run. + * @member {string} [queryType] Set value to ResultCount if query should be + * returning search result count. Set it to Number if its a metric query. + * Possible values include: 'ResultCount' + */ + constructor() { + } + + /** + * Defines the metadata of Source + * + * @returns {object} metadata of Source + * + */ + mapper() { + return { + required: false, + serializedName: 'Source', + type: { + name: 'Composite', + className: 'Source', + modelProperties: { + query: { + required: true, + serializedName: 'query', + type: { + name: 'String' + } + }, + authorizedResources: { + required: false, + serializedName: 'authorizedResources', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + datasourceId: { + required: true, + serializedName: 'datasourceId', + type: { + name: 'String' + } + }, + queryType: { + required: false, + serializedName: 'queryType', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Source; diff --git a/lib/services/monitorManagement/lib/models/triggerCondition.js b/lib/services/monitorManagement/lib/models/triggerCondition.js new file mode 100644 index 0000000000..2db331d533 --- /dev/null +++ b/lib/services/monitorManagement/lib/models/triggerCondition.js @@ -0,0 +1,106 @@ +/* + * 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 condition that results in the Log Search rule. + * + */ +class TriggerCondition { + /** + * Create a TriggerCondition. + * @member {string} thresholdOperator Evaluation operation for rule - + * 'GreaterThan' or 'LessThan. Possible values include: 'GreaterThan', + * 'LessThan', 'Equal' + * @member {number} threshold Result or count threshold based on which rule + * should be triggered. + * @member {object} [metricTrigger] Trigger condition for metric query rule + * @member {string} [metricTrigger.metricName] the name of the metric that + * defines what the rule monitors. + * @member {string} [metricTrigger.metricResourceUri] the resource identifier + * of the resource the rule monitors. + * @member {moment.duration} [metricTrigger.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. + * @member {string} [metricTrigger.statistic] the metric statistic type. How + * the metrics from multiple instances are combined. Possible values include: + * 'Average', 'Min', 'Max', 'Sum' + * @member {moment.duration} [metricTrigger.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. + * @member {string} [metricTrigger.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' + * @member {string} [metricTrigger.operator] the operator that is used to + * compare the metric data and the threshold. Possible values include: + * 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + * 'LessThanOrEqual' + * @member {number} [metricTrigger.threshold] the threshold of the metric + * that triggers the scale action. + * @member {string} [metricTrigger.thresholdOperator] Evaluation operation + * for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values + * include: 'GreaterThan', 'LessThan', 'Equal' + * @member {string} [metricTrigger.metricTriggerType] Metric Trigger Type - + * 'Consecutive' or 'Total'. Possible values include: 'Consecutive', 'Total' + * @member {string} [metricTrigger.metricColumn] Evaluation of metric on a + * particular column + */ + constructor() { + } + + /** + * Defines the metadata of TriggerCondition + * + * @returns {object} metadata of TriggerCondition + * + */ + mapper() { + return { + required: false, + serializedName: 'TriggerCondition', + type: { + name: 'Composite', + className: 'TriggerCondition', + modelProperties: { + thresholdOperator: { + required: true, + serializedName: 'thresholdOperator', + type: { + name: 'String' + } + }, + threshold: { + required: true, + serializedName: 'threshold', + type: { + name: 'Number' + } + }, + metricTrigger: { + required: false, + serializedName: 'metricTrigger', + type: { + name: 'Composite', + className: 'MetricTrigger' + } + } + } + } + }; + } +} + +module.exports = TriggerCondition; diff --git a/lib/services/monitorManagement/lib/monitorManagementClient.d.ts b/lib/services/monitorManagement/lib/monitorManagementClient.d.ts index 9c64e133dc..23e746ef1e 100644 --- a/lib/services/monitorManagement/lib/monitorManagementClient.d.ts +++ b/lib/services/monitorManagement/lib/monitorManagementClient.d.ts @@ -71,6 +71,7 @@ export default class MonitorManagementClient extends AzureServiceClient { metricBaseline: operations.MetricBaseline; metricAlerts: operations.MetricAlerts; metricAlertsStatus: operations.MetricAlertsStatus; + scheduledQueryRules: operations.ScheduledQueryRules; } export { MonitorManagementClient, models as MonitorManagementModels }; diff --git a/lib/services/monitorManagement/lib/monitorManagementClient.js b/lib/services/monitorManagement/lib/monitorManagementClient.js index 356cd3c461..7d0d15edd2 100644 --- a/lib/services/monitorManagement/lib/monitorManagementClient.js +++ b/lib/services/monitorManagement/lib/monitorManagementClient.js @@ -88,6 +88,7 @@ class MonitorManagementClient extends ServiceClient { this.metricBaseline = new operations.MetricBaseline(this); this.metricAlerts = new operations.MetricAlerts(this); this.metricAlertsStatus = new operations.MetricAlertsStatus(this); + this.scheduledQueryRules = new operations.ScheduledQueryRules(this); this.models = models; msRest.addSerializationMixin(this); } diff --git a/lib/services/monitorManagement/lib/operations/index.d.ts b/lib/services/monitorManagement/lib/operations/index.d.ts index e27f7c32ab..36e4ac1333 100644 --- a/lib/services/monitorManagement/lib/operations/index.d.ts +++ b/lib/services/monitorManagement/lib/operations/index.d.ts @@ -4284,3 +4284,408 @@ export interface MetricAlertsStatus { listByName(resourceGroupName: string, ruleName: string, statusName: string, callback: ServiceCallback): void; listByName(resourceGroupName: string, ruleName: string, statusName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } + +/** + * @class + * ScheduledQueryRules + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface ScheduledQueryRules { + + + /** + * Creates or updates an log search rule. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} [parameters.description] The description of the Log Search + * rule. + * + * @param {string} [parameters.enabled] The flag which indicates whether the + * Log Search rule is enabled. Value should be true or false. Possible values + * include: 'true', 'false' + * + * @param {object} parameters.source Data Source against which rule will Query + * Data + * + * @param {string} parameters.source.query Log search query. + * + * @param {array} [parameters.source.authorizedResources] List of Resource + * referred into query + * + * @param {string} parameters.source.datasourceId The resource uri over which + * log search query is to be run. + * + * @param {string} [parameters.source.queryType] Set value to ResultCount if + * query should be returning search result count. Set it to Number if its a + * metric query. Possible values include: 'ResultCount' + * + * @param {object} parameters.schedule Schedule (Frequnecy, Time Window) for + * rule. + * + * @param {number} parameters.schedule.frequencyInMinutes frequency (in + * minutes) at which rule condition should be evaluated. + * + * @param {number} parameters.schedule.timeWindowInMinutes Time window for + * which data needs to be fetched for query (should be greater than or equal to + * frequencyInMinutes). + * + * @param {object} parameters.action Action needs to be taken on rule + * execution. + * + * @param {string} [parameters.action.actionGroupId] the id of the action group + * to use. + * + * @param {object} [parameters.action.webhookProperties] + * + * @param {string} parameters.action.odatatype Polymorphic Discriminator + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, ruleName: string, parameters: models.LogSearchRuleResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates an log search rule. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} [parameters.description] The description of the Log Search + * rule. + * + * @param {string} [parameters.enabled] The flag which indicates whether the + * Log Search rule is enabled. Value should be true or false. Possible values + * include: 'true', 'false' + * + * @param {object} parameters.source Data Source against which rule will Query + * Data + * + * @param {string} parameters.source.query Log search query. + * + * @param {array} [parameters.source.authorizedResources] List of Resource + * referred into query + * + * @param {string} parameters.source.datasourceId The resource uri over which + * log search query is to be run. + * + * @param {string} [parameters.source.queryType] Set value to ResultCount if + * query should be returning search result count. Set it to Number if its a + * metric query. Possible values include: 'ResultCount' + * + * @param {object} parameters.schedule Schedule (Frequnecy, Time Window) for + * rule. + * + * @param {number} parameters.schedule.frequencyInMinutes frequency (in + * minutes) at which rule condition should be evaluated. + * + * @param {number} parameters.schedule.timeWindowInMinutes Time window for + * which data needs to be fetched for query (should be greater than or equal to + * frequencyInMinutes). + * + * @param {object} parameters.action Action needs to be taken on rule + * execution. + * + * @param {string} [parameters.action.actionGroupId] the id of the action group + * to use. + * + * @param {object} [parameters.action.webhookProperties] + * + * @param {string} parameters.action.odatatype Polymorphic Discriminator + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LogSearchRuleResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {LogSearchRuleResource} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, ruleName: string, parameters: models.LogSearchRuleResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, ruleName: string, parameters: models.LogSearchRuleResource, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, ruleName: string, parameters: models.LogSearchRuleResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets an Log Search rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets an Log Search rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LogSearchRuleResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {LogSearchRuleResource} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, ruleName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, ruleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes a Log Search rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes a Log Search rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, ruleName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, ruleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List the Log Search rules within a subscription group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply on the operation. For + * more information please see + * https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listBySubscriptionWithHttpOperationResponse(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List the Log Search rules within a subscription group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply on the operation. For + * more information please see + * https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LogSearchRuleResourceCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {LogSearchRuleResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResourceCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscription(options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscription(callback: ServiceCallback): void; + listBySubscription(options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List the Log Search rules within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply on the operation. For + * more information please see + * https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List the Log Search rules within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply on the operation. For + * more information please see + * https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LogSearchRuleResourceCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {LogSearchRuleResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResourceCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/monitorManagement/lib/operations/index.js b/lib/services/monitorManagement/lib/operations/index.js index 56d8f5aa1b..450357ebfb 100644 --- a/lib/services/monitorManagement/lib/operations/index.js +++ b/lib/services/monitorManagement/lib/operations/index.js @@ -31,3 +31,4 @@ exports.Metrics = require('./metrics'); exports.MetricBaseline = require('./metricBaseline'); exports.MetricAlerts = require('./metricAlerts'); exports.MetricAlertsStatus = require('./metricAlertsStatus'); +exports.ScheduledQueryRules = require('./scheduledQueryRules'); diff --git a/lib/services/monitorManagement/lib/operations/scheduledQueryRules.js b/lib/services/monitorManagement/lib/operations/scheduledQueryRules.js new file mode 100644 index 0000000000..fc6215f9d0 --- /dev/null +++ b/lib/services/monitorManagement/lib/operations/scheduledQueryRules.js @@ -0,0 +1,1355 @@ +/* + * 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 msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Creates or updates an log search rule. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} [parameters.description] The description of the Log Search + * rule. + * + * @param {string} [parameters.enabled] The flag which indicates whether the + * Log Search rule is enabled. Value should be true or false. Possible values + * include: 'true', 'false' + * + * @param {object} parameters.source Data Source against which rule will Query + * Data + * + * @param {string} parameters.source.query Log search query. + * + * @param {array} [parameters.source.authorizedResources] List of Resource + * referred into query + * + * @param {string} parameters.source.datasourceId The resource uri over which + * log search query is to be run. + * + * @param {string} [parameters.source.queryType] Set value to ResultCount if + * query should be returning search result count. Set it to Number if its a + * metric query. Possible values include: 'ResultCount' + * + * @param {object} parameters.schedule Schedule (Frequnecy, Time Window) for + * rule. + * + * @param {number} parameters.schedule.frequencyInMinutes frequency (in + * minutes) at which rule condition should be evaluated. + * + * @param {number} parameters.schedule.timeWindowInMinutes Time window for + * which data needs to be fetched for query (should be greater than or equal to + * frequencyInMinutes). + * + * @param {object} parameters.action Action needs to be taken on rule + * execution. + * + * @param {string} [parameters.action.actionGroupId] the id of the action group + * to use. + * + * @param {object} [parameters.action.webhookProperties] + * + * @param {string} parameters.action.odatatype Polymorphic Discriminator + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, ruleName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-04-16'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['LogSearchRuleResource']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LogSearchRuleResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LogSearchRuleResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets an Log Search rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, ruleName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-04-16'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LogSearchRuleResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes a Log Search rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, ruleName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-04-16'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * List the Log Search rules within a subscription group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply on the operation. For + * more information please see + * https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listBySubscription(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let apiVersion = '2018-04-16'; + // Validate + try { + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/scheduledQueryRules'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LogSearchRuleResourceCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * List the Log Search rules within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply on the operation. For + * more information please see + * https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroup(resourceGroupName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + let apiVersion = '2018-04-16'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LogSearchRuleResourceCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ScheduledQueryRules. */ +class ScheduledQueryRules { + /** + * Create a ScheduledQueryRules. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._createOrUpdate = _createOrUpdate; + this._get = _get; + this._deleteMethod = _deleteMethod; + this._listBySubscription = _listBySubscription; + this._listByResourceGroup = _listByResourceGroup; + } + + /** + * Creates or updates an log search rule. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} [parameters.description] The description of the Log Search + * rule. + * + * @param {string} [parameters.enabled] The flag which indicates whether the + * Log Search rule is enabled. Value should be true or false. Possible values + * include: 'true', 'false' + * + * @param {object} parameters.source Data Source against which rule will Query + * Data + * + * @param {string} parameters.source.query Log search query. + * + * @param {array} [parameters.source.authorizedResources] List of Resource + * referred into query + * + * @param {string} parameters.source.datasourceId The resource uri over which + * log search query is to be run. + * + * @param {string} [parameters.source.queryType] Set value to ResultCount if + * query should be returning search result count. Set it to Number if its a + * metric query. Possible values include: 'ResultCount' + * + * @param {object} parameters.schedule Schedule (Frequnecy, Time Window) for + * rule. + * + * @param {number} parameters.schedule.frequencyInMinutes frequency (in + * minutes) at which rule condition should be evaluated. + * + * @param {number} parameters.schedule.timeWindowInMinutes Time window for + * which data needs to be fetched for query (should be greater than or equal to + * frequencyInMinutes). + * + * @param {object} parameters.action Action needs to be taken on rule + * execution. + * + * @param {string} [parameters.action.actionGroupId] the id of the action group + * to use. + * + * @param {object} [parameters.action.webhookProperties] + * + * @param {string} parameters.action.odatatype Polymorphic Discriminator + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, ruleName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, ruleName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates an log search rule. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} [parameters.description] The description of the Log Search + * rule. + * + * @param {string} [parameters.enabled] The flag which indicates whether the + * Log Search rule is enabled. Value should be true or false. Possible values + * include: 'true', 'false' + * + * @param {object} parameters.source Data Source against which rule will Query + * Data + * + * @param {string} parameters.source.query Log search query. + * + * @param {array} [parameters.source.authorizedResources] List of Resource + * referred into query + * + * @param {string} parameters.source.datasourceId The resource uri over which + * log search query is to be run. + * + * @param {string} [parameters.source.queryType] Set value to ResultCount if + * query should be returning search result count. Set it to Number if its a + * metric query. Possible values include: 'ResultCount' + * + * @param {object} parameters.schedule Schedule (Frequnecy, Time Window) for + * rule. + * + * @param {number} parameters.schedule.frequencyInMinutes frequency (in + * minutes) at which rule condition should be evaluated. + * + * @param {number} parameters.schedule.timeWindowInMinutes Time window for + * which data needs to be fetched for query (should be greater than or equal to + * frequencyInMinutes). + * + * @param {object} parameters.action Action needs to be taken on rule + * execution. + * + * @param {string} [parameters.action.actionGroupId] the id of the action group + * to use. + * + * @param {object} [parameters.action.webhookProperties] + * + * @param {string} parameters.action.odatatype Polymorphic Discriminator + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {LogSearchRuleResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, ruleName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, ruleName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, ruleName, parameters, options, optionalCallback); + } + } + + /** + * Gets an Log Search rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, ruleName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, ruleName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets an Log Search rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {LogSearchRuleResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, ruleName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, ruleName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, ruleName, options, optionalCallback); + } + } + + /** + * Deletes a Log Search rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, ruleName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, ruleName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes a Log Search rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, ruleName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, ruleName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, ruleName, options, optionalCallback); + } + } + + /** + * List the Log Search rules within a subscription group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply on the operation. For + * more information please see + * https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listBySubscriptionWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listBySubscription(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List the Log Search rules within a subscription group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply on the operation. For + * more information please see + * https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {LogSearchRuleResourceCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscription(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listBySubscription(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listBySubscription(options, optionalCallback); + } + } + + /** + * List the Log Search rules within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply on the operation. For + * more information please see + * https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List the Log Search rules within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] The filter to apply on the operation. For + * more information please see + * https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {LogSearchRuleResourceCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogSearchRuleResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + } + } + +} + +module.exports = ScheduledQueryRules;