diff --git a/lib/services/monitorManagement/lib/models/action.js b/lib/services/monitorManagement/lib/models/action.js index 282636d503..60cf981165 100644 --- a/lib/services/monitorManagement/lib/models/action.js +++ b/lib/services/monitorManagement/lib/models/action.js @@ -11,7 +11,8 @@ 'use strict'; /** - * Class representing a Action. + * Action descriptor. + * */ class Action { /** diff --git a/lib/services/monitorManagement/lib/models/alertingAction.js b/lib/services/monitorManagement/lib/models/alertingAction.js index 8348e8945f..03ee8274af 100644 --- a/lib/services/monitorManagement/lib/models/alertingAction.js +++ b/lib/services/monitorManagement/lib/models/alertingAction.js @@ -42,7 +42,8 @@ class AlertingAction extends models['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 {number} [trigger.metricTrigger.threshold] The threshold of the + * metric trigger. * @member {string} [trigger.metricTrigger.metricTriggerType] Metric Trigger * Type - 'Consecutive' or 'Total'. Possible values include: 'Consecutive', * 'Total' diff --git a/lib/services/monitorManagement/lib/models/diagnosticSettingsResource.js b/lib/services/monitorManagement/lib/models/diagnosticSettingsResource.js index b255747c24..e4b3da0650 100644 --- a/lib/services/monitorManagement/lib/models/diagnosticSettingsResource.js +++ b/lib/services/monitorManagement/lib/models/diagnosticSettingsResource.js @@ -22,6 +22,8 @@ class DiagnosticSettingsResource extends models['ProxyOnlyResource'] { * Create a DiagnosticSettingsResource. * @member {string} [storageAccountId] The resource ID of the storage account * to which you would like to send Diagnostic Logs. + * @member {string} [serviceBusRuleId] The service bus rule Id of the + * diagnostic setting. This is here to maintain backwards compatibility. * @member {string} [eventHubAuthorizationRuleId] The resource Id for the * event hub authorization rule. * @member {string} [eventHubName] The name of the event hub. If none is @@ -82,6 +84,13 @@ class DiagnosticSettingsResource extends models['ProxyOnlyResource'] { name: 'String' } }, + serviceBusRuleId: { + required: false, + serializedName: 'properties.serviceBusRuleId', + type: { + name: 'String' + } + }, eventHubAuthorizationRuleId: { required: false, serializedName: 'properties.eventHubAuthorizationRuleId', diff --git a/lib/services/monitorManagement/lib/models/eventData.js b/lib/services/monitorManagement/lib/models/eventData.js index 4e8b1c3046..7a0c296d1c 100644 --- a/lib/services/monitorManagement/lib/models/eventData.js +++ b/lib/services/monitorManagement/lib/models/eventData.js @@ -19,7 +19,7 @@ const models = require('./index'); class EventData { /** * Create a EventData. - * @member {object} [authorization] + * @member {object} [authorization] The sender authorization information. * @member {string} [authorization.action] the permissible actions. For * instance: microsoft.support/supporttickets/write * @member {string} [authorization.role] the role of the user. For instance: diff --git a/lib/services/monitorManagement/lib/models/index.d.ts b/lib/services/monitorManagement/lib/models/index.d.ts index d37350de68..b459593228 100644 --- a/lib/services/monitorManagement/lib/models/index.d.ts +++ b/lib/services/monitorManagement/lib/models/index.d.ts @@ -1126,6 +1126,8 @@ export interface LogSettings { * * @member {string} [storageAccountId] The resource ID of the storage account * to which you would like to send Diagnostic Logs. + * @member {string} [serviceBusRuleId] The service bus rule Id of the + * diagnostic setting. This is here to maintain backwards compatibility. * @member {string} [eventHubAuthorizationRuleId] The resource Id for the event * hub authorization rule. * @member {string} [eventHubName] The name of the event hub. If none is @@ -1139,6 +1141,7 @@ export interface LogSettings { */ export interface DiagnosticSettingsResource extends ProxyOnlyResource { storageAccountId?: string; + serviceBusRuleId?: string; eventHubAuthorizationRuleId?: string; eventHubName?: string; metrics?: MetricSettings[]; @@ -1594,7 +1597,7 @@ export interface HttpRequestInfo { * @constructor * The Azure event log entries are of type EventData * - * @member {object} [authorization] + * @member {object} [authorization] The sender authorization information. * @member {string} [authorization.action] the permissible actions. For * instance: microsoft.support/supporttickets/write * @member {string} [authorization.role] the role of the user. For instance: @@ -1983,7 +1986,7 @@ export interface CalculateBaselineResponse { * An alert action. * * @member {string} [actionGroupId] the id of the action group to use. - * @member {object} [webhookProperties] + * @member {object} [webhookProperties] The properties of a webhook object. */ export interface MetricAlertAction { actionGroupId?: string; @@ -2095,7 +2098,8 @@ export interface MetricAlertResourcePatch { * @constructor * An alert status properties. * - * @member {object} [dimensions] + * @member {object} [dimensions] An object describing the type of the + * dimensions. * @member {string} [status] status value * @member {date} [timestamp] UTC time when the status was checked. */ @@ -2116,7 +2120,8 @@ export interface MetricAlertStatusProperties { * @member {string} [type] The extended resource type name. * @member {object} [properties] The alert status properties of the metric * alert status. - * @member {object} [properties.dimensions] + * @member {object} [properties.dimensions] An object describing the type of + * the dimensions. * @member {string} [properties.status] status value * @member {date} [properties.timestamp] UTC time when the status was checked. */ @@ -2143,6 +2148,8 @@ export interface MetricAlertStatusCollection { * @class * Initializes a new instance of the MetricDimension class. * @constructor + * Specifies a metric dimension. + * * @member {string} name Name of the dimension. * @member {string} operator the dimension operator. * @member {array} values list of dimension values. @@ -2157,6 +2164,8 @@ export interface MetricDimension { * @class * Initializes a new instance of the MetricCriteria class. * @constructor + * Criterion to filter metrics. + * * @member {string} name Name of the criteria. * @member {string} metricName Name of the metric. * @member {string} [metricNamespace] Namespace of the metric. @@ -2230,6 +2239,8 @@ export interface Schedule { * @class * Initializes a new instance of the Action class. * @constructor + * Action descriptor. + * * @member {string} odatatype Polymorphic Discriminator */ export interface Action { @@ -2298,10 +2309,12 @@ export interface LogSearchRuleResourcePatch { * @class * Initializes a new instance of the LogMetricTrigger class. * @constructor + * A log metrics trigger descriptor. + * * @member {string} [thresholdOperator] Evaluation operation for Metric * -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: * 'GreaterThan', 'LessThan', 'Equal' - * @member {number} [threshold] + * @member {number} [threshold] The threshold of the metric trigger. * @member {string} [metricTriggerType] Metric Trigger Type - 'Consecutive' or * 'Total'. Possible values include: 'Consecutive', 'Total' * @member {string} [metricColumn] Evaluation of metric on a particular column @@ -2328,7 +2341,8 @@ export interface LogMetricTrigger { * @member {string} [metricTrigger.thresholdOperator] Evaluation operation for * Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: * 'GreaterThan', 'LessThan', 'Equal' - * @member {number} [metricTrigger.threshold] + * @member {number} [metricTrigger.threshold] The threshold of the metric + * trigger. * @member {string} [metricTrigger.metricTriggerType] Metric Trigger Type - * 'Consecutive' or 'Total'. Possible values include: 'Consecutive', 'Total' * @member {string} [metricTrigger.metricColumn] Evaluation of metric on a @@ -2386,7 +2400,8 @@ export interface AzNsActionGroup { * @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 {number} [trigger.metricTrigger.threshold] The threshold of the + * metric trigger. * @member {string} [trigger.metricTrigger.metricTriggerType] Metric Trigger * Type - 'Consecutive' or 'Total'. Possible values include: 'Consecutive', * 'Total' diff --git a/lib/services/monitorManagement/lib/models/logMetricTrigger.js b/lib/services/monitorManagement/lib/models/logMetricTrigger.js index 2af865ec82..9f50a4aaf4 100644 --- a/lib/services/monitorManagement/lib/models/logMetricTrigger.js +++ b/lib/services/monitorManagement/lib/models/logMetricTrigger.js @@ -11,7 +11,8 @@ 'use strict'; /** - * Class representing a LogMetricTrigger. + * A log metrics trigger descriptor. + * */ class LogMetricTrigger { /** @@ -19,7 +20,7 @@ class LogMetricTrigger { * @member {string} [thresholdOperator] Evaluation operation for Metric * -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: * 'GreaterThan', 'LessThan', 'Equal' - * @member {number} [threshold] + * @member {number} [threshold] The threshold of the metric trigger. * @member {string} [metricTriggerType] Metric Trigger Type - 'Consecutive' * or 'Total'. Possible values include: 'Consecutive', 'Total' * @member {string} [metricColumn] Evaluation of metric on a particular diff --git a/lib/services/monitorManagement/lib/models/metricAlertAction.js b/lib/services/monitorManagement/lib/models/metricAlertAction.js index 839c184556..2b70ef2515 100644 --- a/lib/services/monitorManagement/lib/models/metricAlertAction.js +++ b/lib/services/monitorManagement/lib/models/metricAlertAction.js @@ -18,7 +18,7 @@ class MetricAlertAction { /** * Create a MetricAlertAction. * @member {string} [actionGroupId] the id of the action group to use. - * @member {object} [webhookProperties] + * @member {object} [webhookProperties] The properties of a webhook object. */ constructor() { } diff --git a/lib/services/monitorManagement/lib/models/metricAlertStatus.js b/lib/services/monitorManagement/lib/models/metricAlertStatus.js index 6df29691be..388183af45 100644 --- a/lib/services/monitorManagement/lib/models/metricAlertStatus.js +++ b/lib/services/monitorManagement/lib/models/metricAlertStatus.js @@ -24,7 +24,8 @@ class MetricAlertStatus { * @member {string} [type] The extended resource type name. * @member {object} [properties] The alert status properties of the metric * alert status. - * @member {object} [properties.dimensions] + * @member {object} [properties.dimensions] An object describing the type of + * the dimensions. * @member {string} [properties.status] status value * @member {date} [properties.timestamp] UTC time when the status was * checked. diff --git a/lib/services/monitorManagement/lib/models/metricAlertStatusProperties.js b/lib/services/monitorManagement/lib/models/metricAlertStatusProperties.js index b9581c6cda..73ef0ae1bd 100644 --- a/lib/services/monitorManagement/lib/models/metricAlertStatusProperties.js +++ b/lib/services/monitorManagement/lib/models/metricAlertStatusProperties.js @@ -17,7 +17,8 @@ class MetricAlertStatusProperties { /** * Create a MetricAlertStatusProperties. - * @member {object} [dimensions] + * @member {object} [dimensions] An object describing the type of the + * dimensions. * @member {string} [status] status value * @member {date} [timestamp] UTC time when the status was checked. */ diff --git a/lib/services/monitorManagement/lib/models/metricCriteria.js b/lib/services/monitorManagement/lib/models/metricCriteria.js index 19192dc18a..8be5418acb 100644 --- a/lib/services/monitorManagement/lib/models/metricCriteria.js +++ b/lib/services/monitorManagement/lib/models/metricCriteria.js @@ -13,7 +13,8 @@ const models = require('./index'); /** - * Class representing a MetricCriteria. + * Criterion to filter metrics. + * */ class MetricCriteria { /** diff --git a/lib/services/monitorManagement/lib/models/metricDimension.js b/lib/services/monitorManagement/lib/models/metricDimension.js index 4805da9870..70b761f9e4 100644 --- a/lib/services/monitorManagement/lib/models/metricDimension.js +++ b/lib/services/monitorManagement/lib/models/metricDimension.js @@ -11,7 +11,8 @@ 'use strict'; /** - * Class representing a MetricDimension. + * Specifies a metric dimension. + * */ class MetricDimension { /** diff --git a/lib/services/monitorManagement/lib/models/triggerCondition.js b/lib/services/monitorManagement/lib/models/triggerCondition.js index 9238fb4928..b69f6b6a0a 100644 --- a/lib/services/monitorManagement/lib/models/triggerCondition.js +++ b/lib/services/monitorManagement/lib/models/triggerCondition.js @@ -28,7 +28,8 @@ class TriggerCondition { * @member {string} [metricTrigger.thresholdOperator] Evaluation operation * for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values * include: 'GreaterThan', 'LessThan', 'Equal' - * @member {number} [metricTrigger.threshold] + * @member {number} [metricTrigger.threshold] The threshold of the metric + * trigger. * @member {string} [metricTrigger.metricTriggerType] Metric Trigger Type - * 'Consecutive' or 'Total'. Possible values include: 'Consecutive', 'Total' * @member {string} [metricTrigger.metricColumn] Evaluation of metric on a diff --git a/lib/services/monitorManagement/lib/operations/alertRules.js b/lib/services/monitorManagement/lib/operations/alertRules.js index 3676f74c97..a8ecdb6a79 100644 --- a/lib/services/monitorManagement/lib/operations/alertRules.js +++ b/lib/services/monitorManagement/lib/operations/alertRules.js @@ -843,6 +843,138 @@ function _listByResourceGroup(resourceGroupName, options, callback) { }); } +/** + * List the alert rules within a subscription. + * + * @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 AlertRuleResourceCollection} 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 apiVersion = '2016-03-01'; + // 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 (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/alertrules'; + 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) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().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['AlertRuleResourceCollection']().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 AlertRules. */ class AlertRules { /** @@ -856,6 +988,7 @@ class AlertRules { this._get = _get; this._update = _update; this._listByResourceGroup = _listByResourceGroup; + this._listBySubscription = _listBySubscription; } /** @@ -1418,6 +1551,85 @@ class AlertRules { } } + /** + * List the alert rules within a subscription. + * + * @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. + */ + 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 alert rules within a subscription. + * + * @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 {AlertRuleResourceCollection} - 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 AlertRuleResourceCollection} 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); + } + } + } module.exports = AlertRules; diff --git a/lib/services/monitorManagement/lib/operations/autoscaleSettings.js b/lib/services/monitorManagement/lib/operations/autoscaleSettings.js index a65507da16..d5a5fdd181 100644 --- a/lib/services/monitorManagement/lib/operations/autoscaleSettings.js +++ b/lib/services/monitorManagement/lib/operations/autoscaleSettings.js @@ -809,6 +809,139 @@ function _update(resourceGroupName, autoscaleSettingName, autoscaleSettingResour }); } +/** + * Lists the autoscale settings for a subscription + * + * @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 AutoscaleSettingResourceCollection} 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 apiVersion = '2015-04-01'; + // 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 (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/autoscalesettings'; + 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['AutoscaleSettingResourceCollection']().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); + }); +} + /** * Lists the autoscale settings for a resource group * @@ -938,6 +1071,135 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { }); } +/** + * Lists the autoscale settings for a subscription + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 AutoscaleSettingResourceCollection} 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 _listBySubscriptionNext(nextPageLink, 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.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink 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 requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // 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['AutoscaleSettingResourceCollection']().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 AutoscaleSettings. */ class AutoscaleSettings { /** @@ -951,7 +1213,9 @@ class AutoscaleSettings { this._deleteMethod = _deleteMethod; this._get = _get; this._update = _update; + this._listBySubscription = _listBySubscription; this._listByResourceGroupNext = _listByResourceGroupNext; + this._listBySubscriptionNext = _listBySubscriptionNext; } /** @@ -1471,6 +1735,85 @@ class AutoscaleSettings { } } + /** + * Lists the autoscale settings for a subscription + * + * @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. + */ + 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; + }); + }); + } + + /** + * Lists the autoscale settings for a subscription + * + * @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 {AutoscaleSettingResourceCollection} - 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 AutoscaleSettingResourceCollection} 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); + } + } + /** * Lists the autoscale settings for a resource group * @@ -1556,6 +1899,91 @@ class AutoscaleSettings { } } + /** + * Lists the autoscale settings for a subscription + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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. + */ + listBySubscriptionNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listBySubscriptionNext(nextPageLink, 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 autoscale settings for a subscription + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 {AutoscaleSettingResourceCollection} - 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 AutoscaleSettingResourceCollection} 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. + */ + listBySubscriptionNext(nextPageLink, 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._listBySubscriptionNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listBySubscriptionNext(nextPageLink, options, optionalCallback); + } + } + } module.exports = AutoscaleSettings; diff --git a/lib/services/monitorManagement/lib/operations/diagnosticSettingsOperations.js b/lib/services/monitorManagement/lib/operations/diagnosticSettingsOperations.js index be6f0864d9..78f0d6d643 100644 --- a/lib/services/monitorManagement/lib/operations/diagnosticSettingsOperations.js +++ b/lib/services/monitorManagement/lib/operations/diagnosticSettingsOperations.js @@ -165,6 +165,9 @@ function _get(resourceUri, name, options, callback) { * @param {string} [parameters.storageAccountId] The resource ID of the storage * account to which you would like to send Diagnostic Logs. * + * @param {string} [parameters.serviceBusRuleId] The service bus rule Id of the + * diagnostic setting. This is here to maintain backwards compatibility. + * * @param {string} [parameters.eventHubAuthorizationRuleId] The resource Id for * the event hub authorization rule. * @@ -701,6 +704,9 @@ class DiagnosticSettingsOperations { * @param {string} [parameters.storageAccountId] The resource ID of the storage * account to which you would like to send Diagnostic Logs. * + * @param {string} [parameters.serviceBusRuleId] The service bus rule Id of the + * diagnostic setting. This is here to maintain backwards compatibility. + * * @param {string} [parameters.eventHubAuthorizationRuleId] The resource Id for * the event hub authorization rule. * @@ -753,6 +759,9 @@ class DiagnosticSettingsOperations { * @param {string} [parameters.storageAccountId] The resource ID of the storage * account to which you would like to send Diagnostic Logs. * + * @param {string} [parameters.serviceBusRuleId] The service bus rule Id of the + * diagnostic setting. This is here to maintain backwards compatibility. + * * @param {string} [parameters.eventHubAuthorizationRuleId] The resource Id for * the event hub authorization rule. * diff --git a/lib/services/monitorManagement/lib/operations/index.d.ts b/lib/services/monitorManagement/lib/operations/index.d.ts index 59f94d7ec9..77e4ab7c1e 100644 --- a/lib/services/monitorManagement/lib/operations/index.d.ts +++ b/lib/services/monitorManagement/lib/operations/index.d.ts @@ -404,6 +404,58 @@ export interface AutoscaleSettings { update(resourceGroupName: string, autoscaleSettingName: string, autoscaleSettingResource: models.AutoscaleSettingResourcePatch, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Lists the autoscale settings for a subscription + * + * @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. + */ + listBySubscriptionWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the autoscale settings for a subscription + * + * @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 {AutoscaleSettingResourceCollection} - 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. + * + * {AutoscaleSettingResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResourceCollection} 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?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscription(callback: ServiceCallback): void; + listBySubscription(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Lists the autoscale settings for a resource group * @@ -460,6 +512,64 @@ export interface AutoscaleSettings { listByResourceGroupNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; listByResourceGroupNext(nextPageLink: string, callback: ServiceCallback): void; listByResourceGroupNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the autoscale settings for a subscription + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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. + */ + listBySubscriptionNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the autoscale settings for a subscription + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 {AutoscaleSettingResourceCollection} - 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. + * + * {AutoscaleSettingResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResourceCollection} 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. + */ + listBySubscriptionNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscriptionNext(nextPageLink: string, callback: ServiceCallback): void; + listBySubscriptionNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** @@ -1085,6 +1195,58 @@ export interface AlertRules { listByResourceGroup(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List the alert rules within a subscription. + * + * @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. + */ + listBySubscriptionWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List the alert rules within a subscription. + * + * @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 {AlertRuleResourceCollection} - 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. + * + * {AlertRuleResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResourceCollection} 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?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscription(callback: ServiceCallback): void; + listBySubscription(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** @@ -1567,6 +1729,9 @@ export interface DiagnosticSettingsOperations { * @param {string} [parameters.storageAccountId] The resource ID of the storage * account to which you would like to send Diagnostic Logs. * + * @param {string} [parameters.serviceBusRuleId] The service bus rule Id of the + * diagnostic setting. This is here to maintain backwards compatibility. + * * @param {string} [parameters.eventHubAuthorizationRuleId] The resource Id for * the event hub authorization rule. * @@ -1607,6 +1772,9 @@ export interface DiagnosticSettingsOperations { * @param {string} [parameters.storageAccountId] The resource ID of the storage * account to which you would like to send Diagnostic Logs. * + * @param {string} [parameters.serviceBusRuleId] The service bus rule Id of the + * diagnostic setting. This is here to maintain backwards compatibility. + * * @param {string} [parameters.eventHubAuthorizationRuleId] The resource Id for * the event hub authorization rule. *