diff --git a/lib/services/monitorManagement/lib/models/activityLogAlertActionList.js b/lib/services/monitorManagement/lib/models/activityLogAlertActionList.js index 2de7dd16fe..3db57621c6 100644 --- a/lib/services/monitorManagement/lib/models/activityLogAlertActionList.js +++ b/lib/services/monitorManagement/lib/models/activityLogAlertActionList.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * A list of activity log alert actions. * diff --git a/lib/services/monitorManagement/lib/models/activityLogAlertAllOfCondition.js b/lib/services/monitorManagement/lib/models/activityLogAlertAllOfCondition.js index 234f03ce70..62e16b8ba7 100644 --- a/lib/services/monitorManagement/lib/models/activityLogAlertAllOfCondition.js +++ b/lib/services/monitorManagement/lib/models/activityLogAlertAllOfCondition.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * An Activity Log alert condition that is met when all its member conditions * are met. diff --git a/lib/services/monitorManagement/lib/models/alertRuleResourcePatch.js b/lib/services/monitorManagement/lib/models/alertRuleResourcePatch.js index 3094d95d8b..5f3a812930 100644 --- a/lib/services/monitorManagement/lib/models/alertRuleResourcePatch.js +++ b/lib/services/monitorManagement/lib/models/alertRuleResourcePatch.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The alert rule object for patch operations. * diff --git a/lib/services/monitorManagement/lib/models/autoscaleNotification.js b/lib/services/monitorManagement/lib/models/autoscaleNotification.js index d56fcbc701..df7056debe 100644 --- a/lib/services/monitorManagement/lib/models/autoscaleNotification.js +++ b/lib/services/monitorManagement/lib/models/autoscaleNotification.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Autoscale notification. * diff --git a/lib/services/monitorManagement/lib/models/autoscaleProfile.js b/lib/services/monitorManagement/lib/models/autoscaleProfile.js index 33064b28ce..0e71d11fc7 100644 --- a/lib/services/monitorManagement/lib/models/autoscaleProfile.js +++ b/lib/services/monitorManagement/lib/models/autoscaleProfile.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Autoscale profile. * diff --git a/lib/services/monitorManagement/lib/models/autoscaleSettingResourcePatch.js b/lib/services/monitorManagement/lib/models/autoscaleSettingResourcePatch.js index fe1ac2f14a..5a16e79145 100644 --- a/lib/services/monitorManagement/lib/models/autoscaleSettingResourcePatch.js +++ b/lib/services/monitorManagement/lib/models/autoscaleSettingResourcePatch.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The autoscale setting object for patch operations. * diff --git a/lib/services/monitorManagement/lib/models/baselineMetadataValue.js b/lib/services/monitorManagement/lib/models/baselineMetadataValue.js index f0353fa4b3..904515ec31 100644 --- a/lib/services/monitorManagement/lib/models/baselineMetadataValue.js +++ b/lib/services/monitorManagement/lib/models/baselineMetadataValue.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Represents a baseline metadata value. * diff --git a/lib/services/monitorManagement/lib/models/baselineResponse.js b/lib/services/monitorManagement/lib/models/baselineResponse.js index db9e23dd39..4a7ff3c87e 100644 --- a/lib/services/monitorManagement/lib/models/baselineResponse.js +++ b/lib/services/monitorManagement/lib/models/baselineResponse.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The response to a baseline query. * diff --git a/lib/services/monitorManagement/lib/models/calculateBaselineResponse.js b/lib/services/monitorManagement/lib/models/calculateBaselineResponse.js index 3b8328e966..2c3984cfe7 100644 --- a/lib/services/monitorManagement/lib/models/calculateBaselineResponse.js +++ b/lib/services/monitorManagement/lib/models/calculateBaselineResponse.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The response to a calcualte baseline call. * diff --git a/lib/services/monitorManagement/lib/models/diagnosticSettingsCategoryResourceCollection.js b/lib/services/monitorManagement/lib/models/diagnosticSettingsCategoryResourceCollection.js index 00199aec14..b3808199b6 100644 --- a/lib/services/monitorManagement/lib/models/diagnosticSettingsCategoryResourceCollection.js +++ b/lib/services/monitorManagement/lib/models/diagnosticSettingsCategoryResourceCollection.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Represents a collection of diagnostic setting category resources. * diff --git a/lib/services/monitorManagement/lib/models/diagnosticSettingsResourceCollection.js b/lib/services/monitorManagement/lib/models/diagnosticSettingsResourceCollection.js index 89650e1336..adf6899c2e 100644 --- a/lib/services/monitorManagement/lib/models/diagnosticSettingsResourceCollection.js +++ b/lib/services/monitorManagement/lib/models/diagnosticSettingsResourceCollection.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Represents a collection of alert rule resources. * diff --git a/lib/services/monitorManagement/lib/models/eventData.js b/lib/services/monitorManagement/lib/models/eventData.js index 7a0c296d1c..5b22aed759 100644 --- a/lib/services/monitorManagement/lib/models/eventData.js +++ b/lib/services/monitorManagement/lib/models/eventData.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The Azure event log entries are of type EventData * diff --git a/lib/services/monitorManagement/lib/models/index.d.ts b/lib/services/monitorManagement/lib/models/index.d.ts index e8facbcd0b..d351ebbf76 100644 --- a/lib/services/monitorManagement/lib/models/index.d.ts +++ b/lib/services/monitorManagement/lib/models/index.d.ts @@ -2173,8 +2173,11 @@ export interface MetricDimension { * @member {string} name Name of the criteria. * @member {string} metricName Name of the metric. * @member {string} [metricNamespace] Namespace of the metric. - * @member {object} operator the criteria operator. - * @member {object} timeAggregation the criteria time aggregation types. + * @member {string} operator the criteria operator. Possible values include: + * 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + * 'LessThanOrEqual' + * @member {string} timeAggregation the criteria time aggregation types. + * Possible values include: 'Average', 'Minimum', 'Maximum', 'Total' * @member {number} threshold the criteria threshold value that activates the * alert. * @member {array} [dimensions] List of dimension conditions. @@ -2183,8 +2186,8 @@ export interface MetricCriteria { name: string; metricName: string; metricNamespace?: string; - operator: any; - timeAggregation: any; + operator: string; + timeAggregation: string; threshold: number; dimensions?: MetricDimension[]; } @@ -2419,6 +2422,38 @@ export interface AlertingAction extends Action { trigger: TriggerCondition; } +/** + * @class + * Initializes a new instance of the MetricNamespaceName class. + * @constructor + * The fully qualified metric namespace name. + * + * @member {string} [metricNamespaceName] The metric namespace name. + */ +export interface MetricNamespaceName { + metricNamespaceName?: string; +} + +/** + * @class + * Initializes a new instance of the MetricNamespace class. + * @constructor + * Metric namespace class specifies the metadata for a metric namespace. + * + * @member {string} [id] The ID of the metricNamespace. + * @member {string} [type] The type of the namespace. + * @member {string} [name] The name of the namespace. + * @member {object} [properties] Properties which include the fully qualified + * namespace name. + * @member {string} [properties.metricNamespaceName] The metric namespace name. + */ +export interface MetricNamespace { + id?: string; + type?: string; + name?: string; + properties?: MetricNamespaceName; +} + /** * @class @@ -2541,3 +2576,13 @@ export interface MetricAlertResourceCollection extends Array { } + +/** + * @class + * Initializes a new instance of the MetricNamespaceCollection class. + * @constructor + * Represents collection of metric namespaces. + * + */ +export interface MetricNamespaceCollection extends Array { +} diff --git a/lib/services/monitorManagement/lib/models/index.js b/lib/services/monitorManagement/lib/models/index.js index 52f190460c..542841f1c7 100644 --- a/lib/services/monitorManagement/lib/models/index.js +++ b/lib/services/monitorManagement/lib/models/index.js @@ -114,6 +114,8 @@ exports.LogMetricTrigger = require('./logMetricTrigger'); exports.TriggerCondition = require('./triggerCondition'); exports.AzNsActionGroup = require('./azNsActionGroup'); exports.AlertingAction = require('./alertingAction'); +exports.MetricNamespaceName = require('./metricNamespaceName'); +exports.MetricNamespace = require('./metricNamespace'); exports.AutoscaleSettingResourceCollection = require('./autoscaleSettingResourceCollection'); exports.IncidentListResult = require('./incidentListResult'); exports.AlertRuleResourceCollection = require('./alertRuleResourceCollection'); @@ -125,6 +127,7 @@ exports.EventCategoryCollection = require('./eventCategoryCollection'); exports.MetricDefinitionCollection = require('./metricDefinitionCollection'); exports.MetricAlertResourceCollection = require('./metricAlertResourceCollection'); exports.LogSearchRuleResourceCollection = require('./logSearchRuleResourceCollection'); +exports.MetricNamespaceCollection = require('./metricNamespaceCollection'); exports.discriminators = { 'RuleDataSource' : exports.RuleDataSource, 'RuleCondition' : exports.RuleCondition, diff --git a/lib/services/monitorManagement/lib/models/logProfileResourcePatch.js b/lib/services/monitorManagement/lib/models/logProfileResourcePatch.js index f9b2822b45..442c7cf801 100644 --- a/lib/services/monitorManagement/lib/models/logProfileResourcePatch.js +++ b/lib/services/monitorManagement/lib/models/logProfileResourcePatch.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The log profile resource for patch operations. * diff --git a/lib/services/monitorManagement/lib/models/logSettings.js b/lib/services/monitorManagement/lib/models/logSettings.js index de7aa7b6c6..dc1240e08c 100644 --- a/lib/services/monitorManagement/lib/models/logSettings.js +++ b/lib/services/monitorManagement/lib/models/logSettings.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Part of MultiTenantDiagnosticSettings. Specifies the settings for a * particular log. diff --git a/lib/services/monitorManagement/lib/models/metadataValue.js b/lib/services/monitorManagement/lib/models/metadataValue.js index e57162fef2..4d25ff04c0 100644 --- a/lib/services/monitorManagement/lib/models/metadataValue.js +++ b/lib/services/monitorManagement/lib/models/metadataValue.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Represents a metric metadata value. * diff --git a/lib/services/monitorManagement/lib/models/metric.js b/lib/services/monitorManagement/lib/models/metric.js index 62f4e00afc..95b5947525 100644 --- a/lib/services/monitorManagement/lib/models/metric.js +++ b/lib/services/monitorManagement/lib/models/metric.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The result data of a query. * diff --git a/lib/services/monitorManagement/lib/models/metricAlertResourcePatch.js b/lib/services/monitorManagement/lib/models/metricAlertResourcePatch.js index 2211860368..aac4cc1abd 100644 --- a/lib/services/monitorManagement/lib/models/metricAlertResourcePatch.js +++ b/lib/services/monitorManagement/lib/models/metricAlertResourcePatch.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The metric alert resource for patch operations. * diff --git a/lib/services/monitorManagement/lib/models/metricAlertStatus.js b/lib/services/monitorManagement/lib/models/metricAlertStatus.js index 388183af45..fbf72c3a94 100644 --- a/lib/services/monitorManagement/lib/models/metricAlertStatus.js +++ b/lib/services/monitorManagement/lib/models/metricAlertStatus.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * An alert status. * diff --git a/lib/services/monitorManagement/lib/models/metricAlertStatusCollection.js b/lib/services/monitorManagement/lib/models/metricAlertStatusCollection.js index e3679d730b..deb2869449 100644 --- a/lib/services/monitorManagement/lib/models/metricAlertStatusCollection.js +++ b/lib/services/monitorManagement/lib/models/metricAlertStatusCollection.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Represents a collection of alert rule resources. * diff --git a/lib/services/monitorManagement/lib/models/metricCriteria.js b/lib/services/monitorManagement/lib/models/metricCriteria.js index 8be5418acb..1364f00f1f 100644 --- a/lib/services/monitorManagement/lib/models/metricCriteria.js +++ b/lib/services/monitorManagement/lib/models/metricCriteria.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Criterion to filter metrics. * @@ -22,8 +20,11 @@ class MetricCriteria { * @member {string} name Name of the criteria. * @member {string} metricName Name of the metric. * @member {string} [metricNamespace] Namespace of the metric. - * @member {object} operator the criteria operator. - * @member {object} timeAggregation the criteria time aggregation types. + * @member {string} operator the criteria operator. Possible values include: + * 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + * 'LessThanOrEqual' + * @member {string} timeAggregation the criteria time aggregation types. + * Possible values include: 'Average', 'Minimum', 'Maximum', 'Total' * @member {number} threshold the criteria threshold value that activates the * alert. * @member {array} [dimensions] List of dimension conditions. @@ -70,14 +71,14 @@ class MetricCriteria { required: true, serializedName: 'operator', type: { - name: 'Object' + name: 'String' } }, timeAggregation: { required: true, serializedName: 'timeAggregation', type: { - name: 'Object' + name: 'String' } }, threshold: { diff --git a/lib/services/monitorManagement/lib/models/metricDefinition.js b/lib/services/monitorManagement/lib/models/metricDefinition.js index 06e73cee86..4f214262f4 100644 --- a/lib/services/monitorManagement/lib/models/metricDefinition.js +++ b/lib/services/monitorManagement/lib/models/metricDefinition.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Metric definition class specifies the metadata for a metric. * diff --git a/lib/services/monitorManagement/lib/models/metricNamespace.js b/lib/services/monitorManagement/lib/models/metricNamespace.js new file mode 100644 index 0000000000..0f3005649b --- /dev/null +++ b/lib/services/monitorManagement/lib/models/metricNamespace.js @@ -0,0 +1,80 @@ +/* + * 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'; + +/** + * Metric namespace class specifies the metadata for a metric namespace. + * + */ +class MetricNamespace { + /** + * Create a MetricNamespace. + * @member {string} [id] The ID of the metricNamespace. + * @member {string} [type] The type of the namespace. + * @member {string} [name] The name of the namespace. + * @member {object} [properties] Properties which include the fully qualified + * namespace name. + * @member {string} [properties.metricNamespaceName] The metric namespace + * name. + */ + constructor() { + } + + /** + * Defines the metadata of MetricNamespace + * + * @returns {object} metadata of MetricNamespace + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricNamespace', + type: { + name: 'Composite', + className: 'MetricNamespace', + modelProperties: { + id: { + required: false, + serializedName: 'id', + type: { + name: 'String' + } + }, + type: { + required: false, + serializedName: 'type', + type: { + name: 'String' + } + }, + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + properties: { + required: false, + serializedName: 'properties', + type: { + name: 'Composite', + className: 'MetricNamespaceName' + } + } + } + } + }; + } +} + +module.exports = MetricNamespace; diff --git a/lib/services/monitorManagement/lib/models/metricNamespaceCollection.js b/lib/services/monitorManagement/lib/models/metricNamespaceCollection.js new file mode 100644 index 0000000000..b5694f2dc9 --- /dev/null +++ b/lib/services/monitorManagement/lib/models/metricNamespaceCollection.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 collection of metric namespaces. + */ +class MetricNamespaceCollection extends Array { + /** + * Create a MetricNamespaceCollection. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of MetricNamespaceCollection + * + * @returns {object} metadata of MetricNamespaceCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricNamespaceCollection', + type: { + name: 'Composite', + className: 'MetricNamespaceCollection', + modelProperties: { + value: { + required: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'MetricNamespaceElementType', + type: { + name: 'Composite', + className: 'MetricNamespace' + } + } + } + } + } + } + }; + } +} + +module.exports = MetricNamespaceCollection; diff --git a/lib/services/monitorManagement/lib/models/metricNamespaceName.js b/lib/services/monitorManagement/lib/models/metricNamespaceName.js new file mode 100644 index 0000000000..12cbd9c56b --- /dev/null +++ b/lib/services/monitorManagement/lib/models/metricNamespaceName.js @@ -0,0 +1,52 @@ +/* + * 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 fully qualified metric namespace name. + * + */ +class MetricNamespaceName { + /** + * Create a MetricNamespaceName. + * @member {string} [metricNamespaceName] The metric namespace name. + */ + constructor() { + } + + /** + * Defines the metadata of MetricNamespaceName + * + * @returns {object} metadata of MetricNamespaceName + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricNamespaceName', + type: { + name: 'Composite', + className: 'MetricNamespaceName', + modelProperties: { + metricNamespaceName: { + required: false, + serializedName: 'metricNamespaceName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = MetricNamespaceName; diff --git a/lib/services/monitorManagement/lib/models/metricSettings.js b/lib/services/monitorManagement/lib/models/metricSettings.js index bdde9809ff..24fc9968a9 100644 --- a/lib/services/monitorManagement/lib/models/metricSettings.js +++ b/lib/services/monitorManagement/lib/models/metricSettings.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Part of MultiTenantDiagnosticSettings. Specifies the settings for a * particular metric. diff --git a/lib/services/monitorManagement/lib/models/operation.js b/lib/services/monitorManagement/lib/models/operation.js index 83a27ddcc0..8f276ea7b4 100644 --- a/lib/services/monitorManagement/lib/models/operation.js +++ b/lib/services/monitorManagement/lib/models/operation.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Microsoft Insights API operation definition. * diff --git a/lib/services/monitorManagement/lib/models/operationListResult.js b/lib/services/monitorManagement/lib/models/operationListResult.js index cad3161962..7ceaf0ffa1 100644 --- a/lib/services/monitorManagement/lib/models/operationListResult.js +++ b/lib/services/monitorManagement/lib/models/operationListResult.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Result of the request to list Microsoft.Insights operations. It contains a * list of operations and a URL link to get the next set of results. diff --git a/lib/services/monitorManagement/lib/models/recurrence.js b/lib/services/monitorManagement/lib/models/recurrence.js index c271dcd206..090c6fc5e2 100644 --- a/lib/services/monitorManagement/lib/models/recurrence.js +++ b/lib/services/monitorManagement/lib/models/recurrence.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The repeating times at which this profile begins. This element is not used * if the FixedDate element is used. diff --git a/lib/services/monitorManagement/lib/models/response.js b/lib/services/monitorManagement/lib/models/response.js index 20e0c9cbb3..6e2b85c300 100644 --- a/lib/services/monitorManagement/lib/models/response.js +++ b/lib/services/monitorManagement/lib/models/response.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The response to a metrics query. * diff --git a/lib/services/monitorManagement/lib/models/ruleCondition.js b/lib/services/monitorManagement/lib/models/ruleCondition.js index 5b43f85397..7d106a306e 100644 --- a/lib/services/monitorManagement/lib/models/ruleCondition.js +++ b/lib/services/monitorManagement/lib/models/ruleCondition.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The condition that results in the alert rule being activated. * diff --git a/lib/services/monitorManagement/lib/models/scaleRule.js b/lib/services/monitorManagement/lib/models/scaleRule.js index 0836d498c2..beda6ba5a8 100644 --- a/lib/services/monitorManagement/lib/models/scaleRule.js +++ b/lib/services/monitorManagement/lib/models/scaleRule.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * A rule that provide the triggers and parameters for the scaling action. * diff --git a/lib/services/monitorManagement/lib/models/timeSeriesElement.js b/lib/services/monitorManagement/lib/models/timeSeriesElement.js index 576f5a51ab..1290bd7598 100644 --- a/lib/services/monitorManagement/lib/models/timeSeriesElement.js +++ b/lib/services/monitorManagement/lib/models/timeSeriesElement.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * A time series result type. The discriminator value is always TimeSeries in * this case. diff --git a/lib/services/monitorManagement/lib/models/triggerCondition.js b/lib/services/monitorManagement/lib/models/triggerCondition.js index b69f6b6a0a..b39bdee93d 100644 --- a/lib/services/monitorManagement/lib/models/triggerCondition.js +++ b/lib/services/monitorManagement/lib/models/triggerCondition.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The condition that results in the Log Search rule. * diff --git a/lib/services/monitorManagement/lib/monitorManagementClient.d.ts b/lib/services/monitorManagement/lib/monitorManagementClient.d.ts index abfb3a46d3..d086aa113b 100644 --- a/lib/services/monitorManagement/lib/monitorManagementClient.d.ts +++ b/lib/services/monitorManagement/lib/monitorManagementClient.d.ts @@ -72,6 +72,7 @@ export default class MonitorManagementClient extends AzureServiceClient { metricAlerts: operations.MetricAlerts; metricAlertsStatus: operations.MetricAlertsStatus; scheduledQueryRules: operations.ScheduledQueryRules; + metricNamespaces: operations.MetricNamespaces; } export { MonitorManagementClient, models as MonitorManagementModels }; diff --git a/lib/services/monitorManagement/lib/monitorManagementClient.js b/lib/services/monitorManagement/lib/monitorManagementClient.js index 5391569009..8ba6797787 100644 --- a/lib/services/monitorManagement/lib/monitorManagementClient.js +++ b/lib/services/monitorManagement/lib/monitorManagementClient.js @@ -89,6 +89,7 @@ class MonitorManagementClient extends ServiceClient { this.metricAlerts = new operations.MetricAlerts(this); this.metricAlertsStatus = new operations.MetricAlertsStatus(this); this.scheduledQueryRules = new operations.ScheduledQueryRules(this); + this.metricNamespaces = new operations.MetricNamespaces(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 77e4ab7c1e..9e1034411e 100644 --- a/lib/services/monitorManagement/lib/operations/index.d.ts +++ b/lib/services/monitorManagement/lib/operations/index.d.ts @@ -4932,3 +4932,74 @@ export interface ScheduledQueryRules { listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; listByResourceGroup(resourceGroupName: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } + +/** + * @class + * MetricNamespaces + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface MetricNamespaces { + + + /** + * Lists the metric namespaces for the resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.startTime] The ISO 8601 conform Date start time + * from which to query for metric namespaces. + * + * @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. + */ + listWithHttpOperationResponse(resourceUri: string, options?: { startTime? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the metric namespaces for the resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.startTime] The ISO 8601 conform Date start time + * from which to query for metric namespaces. + * + * @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 {MetricNamespaceCollection} - 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. + * + * {MetricNamespaceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link MetricNamespaceCollection} 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. + */ + list(resourceUri: string, options?: { startTime? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(resourceUri: string, callback: ServiceCallback): void; + list(resourceUri: string, options: { startTime? : 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 450357ebfb..a1056fd10a 100644 --- a/lib/services/monitorManagement/lib/operations/index.js +++ b/lib/services/monitorManagement/lib/operations/index.js @@ -32,3 +32,4 @@ exports.MetricBaseline = require('./metricBaseline'); exports.MetricAlerts = require('./metricAlerts'); exports.MetricAlertsStatus = require('./metricAlertsStatus'); exports.ScheduledQueryRules = require('./scheduledQueryRules'); +exports.MetricNamespaces = require('./metricNamespaces'); diff --git a/lib/services/monitorManagement/lib/operations/metricNamespaces.js b/lib/services/monitorManagement/lib/operations/metricNamespaces.js new file mode 100644 index 0000000000..8cc3819e91 --- /dev/null +++ b/lib/services/monitorManagement/lib/operations/metricNamespaces.js @@ -0,0 +1,264 @@ +/* + * 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; + +/** + * Lists the metric namespaces for the resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.startTime] The ISO 8601 conform Date start time + * from which to query for metric namespaces. + * + * @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 MetricNamespaceCollection} 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 _list(resourceUri, 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 startTime = (options && options.startTime !== undefined) ? options.startTime : undefined; + let apiVersion = '2017-12-01-preview'; + // Validate + try { + if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { + throw new Error('resourceUri cannot be null or undefined and it must be of type string.'); + } + if (startTime !== null && startTime !== undefined && typeof startTime.valueOf() !== 'string') { + throw new Error('startTime 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('/') ? '' : '/') + '{resourceUri}/providers/microsoft.insights/metricNamespaces'; + requestUrl = requestUrl.replace('{resourceUri}', resourceUri); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (startTime !== null && startTime !== undefined) { + queryParameters.push('startTime=' + encodeURIComponent(startTime)); + } + 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['MetricNamespaceCollection']().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 MetricNamespaces. */ +class MetricNamespaces { + /** + * Create a MetricNamespaces. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists the metric namespaces for the resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.startTime] The ISO 8601 conform Date start time + * from which to query for metric namespaces. + * + * @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. + */ + listWithHttpOperationResponse(resourceUri, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(resourceUri, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the metric namespaces for the resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.startTime] The ISO 8601 conform Date start time + * from which to query for metric namespaces. + * + * @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 {MetricNamespaceCollection} - 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 MetricNamespaceCollection} 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. + */ + list(resourceUri, 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._list(resourceUri, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(resourceUri, options, optionalCallback); + } + } + +} + +module.exports = MetricNamespaces;