diff --git a/lib/services/monitorManagement/lib/models/alertingAction.js b/lib/services/monitorManagement/lib/models/alertingAction.js index 467e671bba..d351800793 100644 --- a/lib/services/monitorManagement/lib/models/alertingAction.js +++ b/lib/services/monitorManagement/lib/models/alertingAction.js @@ -22,13 +22,14 @@ 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 {object} aznsAction Azure action group reference. + * @member {array} [aznsAction.actionGroup] Azure Action Group reference. + * @member {string} [aznsAction.emailSubject] Custom subject override for all + * email ids in Azure action group + * @member {string} [aznsAction.customWebhookPayload] Custom payload to be + * sent for all webook URI in Azure action group * @member {number} [throttlingInMin] time (in minutes) for which Alerts - * should be throttled + * should be throttled or suppressed. * @member {object} trigger The trigger condition that results in the alert * rule being. * @member {string} [trigger.thresholdOperator] Evaluation operation for rule @@ -38,34 +39,10 @@ class AlertingAction extends models['Action'] { * 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 {number} [trigger.metricTrigger.threshold] * @member {string} [trigger.metricTrigger.metricTriggerType] Metric Trigger * Type - 'Consecutive' or 'Total'. Possible values include: 'Consecutive', * 'Total' diff --git a/lib/services/monitorManagement/lib/models/azNsActionGroup.js b/lib/services/monitorManagement/lib/models/azNsActionGroup.js index 6a8177b293..c3d0dea8ee 100644 --- a/lib/services/monitorManagement/lib/models/azNsActionGroup.js +++ b/lib/services/monitorManagement/lib/models/azNsActionGroup.js @@ -11,16 +11,17 @@ 'use strict'; /** - * azns notification group + * Azure action 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 + * @member {array} [actionGroup] Azure Action Group reference. + * @member {string} [emailSubject] Custom subject override for all email ids + * in Azure action group + * @member {string} [customWebhookPayload] Custom payload to be sent for all + * webook URI in Azure action group */ constructor() { } diff --git a/lib/services/monitorManagement/lib/models/index.d.ts b/lib/services/monitorManagement/lib/models/index.d.ts index fe85bf4a97..36f9f74e94 100644 --- a/lib/services/monitorManagement/lib/models/index.d.ts +++ b/lib/services/monitorManagement/lib/models/index.d.ts @@ -84,12 +84,6 @@ 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; @@ -100,9 +94,6 @@ export interface MetricTrigger { timeAggregation: string; operator: string; threshold: number; - thresholdOperator?: string; - metricTriggerType?: string; - metricColumn?: string; } /** @@ -163,13 +154,6 @@ 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 @@ -2216,16 +2200,15 @@ export interface MetricAlertSingleResourceMultipleMetricCriteria extends MetricA * * @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 + * @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' + * @member {string} [queryType] Set value to 'ResultCount'. Possible values + * include: 'ResultCount' */ export interface Source { query: string; authorizedResources?: string[]; - datasourceId: string; + dataSourceId: string; queryType?: string; } @@ -2264,11 +2247,10 @@ export interface Schedule { * @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 + * @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 {string} [source.queryType] Set value to 'ResultCount'. 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. @@ -2290,6 +2272,41 @@ export interface LogSearchRuleResource extends Resource { action: Action; } +/** + * @class + * Initializes a new instance of the LogSearchRuleResourcePatch class. + * @constructor + * The log search rule resource for patch operations. + * + * @member {object} [tags] Resource tags + * @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' + */ +export interface LogSearchRuleResourcePatch { + tags?: { [propertyName: string]: string }; + enabled?: string; +} + +/** + * @class + * Initializes a new instance of the LogMetricTrigger class. + * @constructor + * @member {string} [thresholdOperator] Evaluation operation for Metric + * -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: + * 'GreaterThan', 'LessThan', 'Equal' + * @member {number} [threshold] + * @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 LogMetricTrigger { + thresholdOperator?: string; + threshold?: number; + metricTriggerType?: string; + metricColumn?: string; +} + /** * @class * Initializes a new instance of the TriggerCondition class. @@ -2302,34 +2319,10 @@ export interface LogSearchRuleResource extends Resource { * @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 {number} [metricTrigger.threshold] * @member {string} [metricTrigger.metricTriggerType] Metric Trigger Type - * 'Consecutive' or 'Total'. Possible values include: 'Consecutive', 'Total' * @member {string} [metricTrigger.metricColumn] Evaluation of metric on a @@ -2338,19 +2331,20 @@ export interface LogSearchRuleResource extends Resource { export interface TriggerCondition { thresholdOperator: string; threshold: number; - metricTrigger?: MetricTrigger; + metricTrigger?: LogMetricTrigger; } /** * @class * Initializes a new instance of the AzNsActionGroup class. * @constructor - * azns notification group + * Azure action 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 + * @member {array} [actionGroup] Azure Action Group reference. + * @member {string} [emailSubject] Custom subject override for all email ids in + * Azure action group + * @member {string} [customWebhookPayload] Custom payload to be sent for all + * webook URI in Azure action group */ export interface AzNsActionGroup { actionGroup?: string[]; @@ -2366,13 +2360,14 @@ export interface AzNsActionGroup { * * @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 {object} aznsAction Azure action group reference. + * @member {array} [aznsAction.actionGroup] Azure Action Group reference. + * @member {string} [aznsAction.emailSubject] Custom subject override for all + * email ids in Azure action group + * @member {string} [aznsAction.customWebhookPayload] Custom payload to be sent + * for all webook URI in Azure action group * @member {number} [throttlingInMin] time (in minutes) for which Alerts should - * be throttled + * be throttled or suppressed. * @member {object} trigger The trigger condition that results in the alert * rule being. * @member {string} [trigger.thresholdOperator] Evaluation operation for rule - @@ -2382,34 +2377,10 @@ export interface AzNsActionGroup { * 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 {number} [trigger.metricTrigger.threshold] * @member {string} [trigger.metricTrigger.metricTriggerType] Metric Trigger * Type - 'Consecutive' or 'Total'. Possible values include: 'Consecutive', * 'Total' diff --git a/lib/services/monitorManagement/lib/models/index.js b/lib/services/monitorManagement/lib/models/index.js index b863800b50..fa8c80671d 100644 --- a/lib/services/monitorManagement/lib/models/index.js +++ b/lib/services/monitorManagement/lib/models/index.js @@ -108,6 +108,8 @@ exports.MetricAlertSingleResourceMultipleMetricCriteria = require('./metricAlert exports.Source = require('./source'); exports.Schedule = require('./schedule'); exports.LogSearchRuleResource = require('./logSearchRuleResource'); +exports.LogSearchRuleResourcePatch = require('./logSearchRuleResourcePatch'); +exports.LogMetricTrigger = require('./logMetricTrigger'); exports.TriggerCondition = require('./triggerCondition'); exports.AzNsActionGroup = require('./azNsActionGroup'); exports.AlertingAction = require('./alertingAction'); diff --git a/lib/services/monitorManagement/lib/models/logMetricTrigger.js b/lib/services/monitorManagement/lib/models/logMetricTrigger.js new file mode 100644 index 0000000000..2af865ec82 --- /dev/null +++ b/lib/services/monitorManagement/lib/models/logMetricTrigger.js @@ -0,0 +1,79 @@ +/* + * 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'; + +/** + * Class representing a LogMetricTrigger. + */ +class LogMetricTrigger { + /** + * Create a LogMetricTrigger. + * @member {string} [thresholdOperator] Evaluation operation for Metric + * -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: + * 'GreaterThan', 'LessThan', 'Equal' + * @member {number} [threshold] + * @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() { + } + + /** + * Defines the metadata of LogMetricTrigger + * + * @returns {object} metadata of LogMetricTrigger + * + */ + mapper() { + return { + required: false, + serializedName: 'LogMetricTrigger', + type: { + name: 'Composite', + className: 'LogMetricTrigger', + modelProperties: { + thresholdOperator: { + required: false, + serializedName: 'thresholdOperator', + type: { + name: 'String' + } + }, + threshold: { + required: false, + serializedName: 'threshold', + type: { + name: 'Number' + } + }, + metricTriggerType: { + required: false, + serializedName: 'metricTriggerType', + type: { + name: 'String' + } + }, + metricColumn: { + required: false, + serializedName: 'metricColumn', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = LogMetricTrigger; diff --git a/lib/services/monitorManagement/lib/models/logSearchRuleResource.js b/lib/services/monitorManagement/lib/models/logSearchRuleResource.js index d791a93e32..3c45326de4 100644 --- a/lib/services/monitorManagement/lib/models/logSearchRuleResource.js +++ b/lib/services/monitorManagement/lib/models/logSearchRuleResource.js @@ -33,11 +33,10 @@ class LogSearchRuleResource extends models['Resource'] { * @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 + * @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 {string} [source.queryType] Set value to 'ResultCount'. 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. diff --git a/lib/services/monitorManagement/lib/models/logSearchRuleResourcePatch.js b/lib/services/monitorManagement/lib/models/logSearchRuleResourcePatch.js new file mode 100644 index 0000000000..f06f7b4f95 --- /dev/null +++ b/lib/services/monitorManagement/lib/models/logSearchRuleResourcePatch.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The log search rule resource for patch operations. + * + */ +class LogSearchRuleResourcePatch { + /** + * Create a LogSearchRuleResourcePatch. + * @member {object} [tags] Resource tags + * @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' + */ + constructor() { + } + + /** + * Defines the metadata of LogSearchRuleResourcePatch + * + * @returns {object} metadata of LogSearchRuleResourcePatch + * + */ + mapper() { + return { + required: false, + serializedName: 'LogSearchRuleResourcePatch', + type: { + name: 'Composite', + className: 'LogSearchRuleResourcePatch', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + enabled: { + required: false, + serializedName: 'properties.enabled', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = LogSearchRuleResourcePatch; diff --git a/lib/services/monitorManagement/lib/models/metricAlertAction.js b/lib/services/monitorManagement/lib/models/metricAlertAction.js new file mode 100644 index 0000000000..839c184556 --- /dev/null +++ b/lib/services/monitorManagement/lib/models/metricAlertAction.js @@ -0,0 +1,67 @@ +/* + * 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'; + +/** + * An alert action. + * + */ +class MetricAlertAction { + /** + * Create a MetricAlertAction. + * @member {string} [actionGroupId] the id of the action group to use. + * @member {object} [webhookProperties] + */ + constructor() { + } + + /** + * Defines the metadata of MetricAlertAction + * + * @returns {object} metadata of MetricAlertAction + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricAlertAction', + type: { + name: 'Composite', + className: 'MetricAlertAction', + 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' + } + } + } + } + } + } + }; + } +} + +module.exports = MetricAlertAction; diff --git a/lib/services/monitorManagement/lib/models/metricTrigger.js b/lib/services/monitorManagement/lib/models/metricTrigger.js index 3591915bf6..09e76603e5 100644 --- a/lib/services/monitorManagement/lib/models/metricTrigger.js +++ b/lib/services/monitorManagement/lib/models/metricTrigger.js @@ -39,13 +39,6 @@ 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() { } @@ -122,27 +115,6 @@ 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 3114436dd0..0836d498c2 100644 --- a/lib/services/monitorManagement/lib/models/scaleRule.js +++ b/lib/services/monitorManagement/lib/models/scaleRule.js @@ -46,13 +46,6 @@ 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/source.js b/lib/services/monitorManagement/lib/models/source.js index 21f7bc859f..d576129d8a 100644 --- a/lib/services/monitorManagement/lib/models/source.js +++ b/lib/services/monitorManagement/lib/models/source.js @@ -20,11 +20,10 @@ class 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 + * @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' + * @member {string} [queryType] Set value to 'ResultCount'. Possible values + * include: 'ResultCount' */ constructor() { } @@ -64,9 +63,9 @@ class Source { } } }, - datasourceId: { + dataSourceId: { required: true, - serializedName: 'datasourceId', + serializedName: 'dataSourceId', type: { name: 'String' } diff --git a/lib/services/monitorManagement/lib/models/triggerCondition.js b/lib/services/monitorManagement/lib/models/triggerCondition.js index 2db331d533..9238fb4928 100644 --- a/lib/services/monitorManagement/lib/models/triggerCondition.js +++ b/lib/services/monitorManagement/lib/models/triggerCondition.js @@ -25,34 +25,10 @@ class TriggerCondition { * @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 {number} [metricTrigger.threshold] * @member {string} [metricTrigger.metricTriggerType] Metric Trigger Type - * 'Consecutive' or 'Total'. Possible values include: 'Consecutive', 'Total' * @member {string} [metricTrigger.metricColumn] Evaluation of metric on a @@ -94,7 +70,7 @@ class TriggerCondition { serializedName: 'metricTrigger', type: { name: 'Composite', - className: 'MetricTrigger' + className: 'LogMetricTrigger' } } } diff --git a/lib/services/monitorManagement/lib/operations/index.d.ts b/lib/services/monitorManagement/lib/operations/index.d.ts index 69e78676ea..5408621247 100644 --- a/lib/services/monitorManagement/lib/operations/index.d.ts +++ b/lib/services/monitorManagement/lib/operations/index.d.ts @@ -4330,12 +4330,11 @@ export interface ScheduledQueryRules { * @param {array} [parameters.source.authorizedResources] List of Resource * referred into query * - * @param {string} parameters.source.datasourceId The resource uri over which + * @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 {string} [parameters.source.queryType] Set value to 'ResultCount'. + * Possible values include: 'ResultCount' * * @param {object} parameters.schedule Schedule (Frequnecy, Time Window) for * rule. @@ -4398,12 +4397,11 @@ export interface ScheduledQueryRules { * @param {array} [parameters.source.authorizedResources] List of Resource * referred into query * - * @param {string} parameters.source.datasourceId The resource uri over which + * @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 {string} [parameters.source.queryType] Set value to 'ResultCount'. + * Possible values include: 'ResultCount' * * @param {object} parameters.schedule Schedule (Frequnecy, Time Window) for * rule. @@ -4520,6 +4518,81 @@ export interface ScheduledQueryRules { get(resourceGroupName: string, ruleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Update 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 update. + * + * @param {object} [parameters.tags] Resource tags + * + * @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} [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. + */ + updateWithHttpOperationResponse(resourceGroupName: string, ruleName: string, parameters: models.LogSearchRuleResourcePatch, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update 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 update. + * + * @param {object} [parameters.tags] Resource tags + * + * @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} [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. + */ + update(resourceGroupName: string, ruleName: string, parameters: models.LogSearchRuleResourcePatch, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, ruleName: string, parameters: models.LogSearchRuleResourcePatch, callback: ServiceCallback): void; + update(resourceGroupName: string, ruleName: string, parameters: models.LogSearchRuleResourcePatch, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Deletes a Log Search rule * diff --git a/lib/services/monitorManagement/lib/operations/scheduledQueryRules.js b/lib/services/monitorManagement/lib/operations/scheduledQueryRules.js index fc6215f9d0..8411475524 100644 --- a/lib/services/monitorManagement/lib/operations/scheduledQueryRules.js +++ b/lib/services/monitorManagement/lib/operations/scheduledQueryRules.js @@ -38,12 +38,11 @@ const WebResource = msRest.WebResource; * @param {array} [parameters.source.authorizedResources] List of Resource * referred into query * - * @param {string} parameters.source.datasourceId The resource uri over which + * @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 {string} [parameters.source.queryType] Set value to 'ResultCount'. + * Possible values include: 'ResultCount' * * @param {object} parameters.schedule Schedule (Frequnecy, Time Window) for * rule. @@ -384,6 +383,175 @@ function _get(resourceGroupName, ruleName, options, callback) { }); } +/** + * Update 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 update. + * + * @param {object} [parameters.tags] Resource tags + * + * @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} [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 _update(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 = 'PATCH'; + 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['LogSearchRuleResourcePatch']().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) { + 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 * @@ -814,6 +982,7 @@ class ScheduledQueryRules { this.client = client; this._createOrUpdate = _createOrUpdate; this._get = _get; + this._update = _update; this._deleteMethod = _deleteMethod; this._listBySubscription = _listBySubscription; this._listByResourceGroup = _listByResourceGroup; @@ -843,12 +1012,11 @@ class ScheduledQueryRules { * @param {array} [parameters.source.authorizedResources] List of Resource * referred into query * - * @param {string} parameters.source.datasourceId The resource uri over which + * @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 {string} [parameters.source.queryType] Set value to 'ResultCount'. + * Possible values include: 'ResultCount' * * @param {object} parameters.schedule Schedule (Frequnecy, Time Window) for * rule. @@ -923,12 +1091,11 @@ class ScheduledQueryRules { * @param {array} [parameters.source.authorizedResources] List of Resource * referred into query * - * @param {string} parameters.source.datasourceId The resource uri over which + * @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 {string} [parameters.source.queryType] Set value to 'ResultCount'. + * Possible values include: 'ResultCount' * * @param {object} parameters.schedule Schedule (Frequnecy, Time Window) for * rule. @@ -1087,6 +1254,108 @@ class ScheduledQueryRules { } } + /** + * Update 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 update. + * + * @param {object} [parameters.tags] Resource tags + * + * @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} [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. + */ + updateWithHttpOperationResponse(resourceGroupName, ruleName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(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; + }); + }); + } + + /** + * Update 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 update. + * + * @param {object} [parameters.tags] Resource tags + * + * @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} [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. + */ + update(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._update(resourceGroupName, ruleName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, ruleName, parameters, options, optionalCallback); + } + } + /** * Deletes a Log Search rule *