diff --git a/lib/services/networkManagement2/lib/models/index.d.ts b/lib/services/networkManagement2/lib/models/index.d.ts index 1b4552f3d9..ec8c7d4a1d 100644 --- a/lib/services/networkManagement2/lib/models/index.d.ts +++ b/lib/services/networkManagement2/lib/models/index.d.ts @@ -5566,35 +5566,6 @@ export interface NetworkConfigurationDiagnosticResponse { readonly results?: NetworkConfigurationDiagnosticResult[]; } -/** - * @class - * Initializes a new instance of the QueryConnectionMonitorsParameters class. - * @constructor - * Parameters to query connection monitors. - * - * @member {array} [connectionMonitorIds] List of connection monitors ID. - */ -export interface QueryConnectionMonitorsParameters { - connectionMonitorIds?: string[]; -} - -/** - * @class - * Initializes a new instance of the ConnectionMonitorsQueryResultItem class. - * @constructor - * Results of query particular connection monitor. - * - * @member {string} [resourceId] Connection monitor resource ID. - * @member {object} [report] - * @member {string} [report.sourceStatus] Status of connection monitor source. - * Possible values include: 'Uknown', 'Active', 'Inactive' - * @member {array} [report.states] Information about connection states. - */ -export interface ConnectionMonitorsQueryResultItem { - resourceId?: string; - report?: ConnectionMonitorQueryResult; -} - /** * @class * Initializes a new instance of the OperationDisplay class. @@ -7420,18 +7391,6 @@ export interface SecurityRuleListResult extends Array { export interface NetworkWatcherListResult extends Array { } -/** - * @class - * Initializes a new instance of the QueryConnectionMonitorsResponse class. - * @constructor - * Results of query connection monitors. - * - * @member {string} [nextLink] URL to get the next set of results. - */ -export interface QueryConnectionMonitorsResponse extends Array { - nextLink?: string; -} - /** * @class * Initializes a new instance of the PacketCaptureListResult class. diff --git a/lib/services/networkManagement2/lib/models/index.js b/lib/services/networkManagement2/lib/models/index.js index a83ece2d6b..736f188e5e 100644 --- a/lib/services/networkManagement2/lib/models/index.js +++ b/lib/services/networkManagement2/lib/models/index.js @@ -189,8 +189,6 @@ exports.EvaluatedNetworkSecurityGroup = require('./evaluatedNetworkSecurityGroup exports.NetworkSecurityGroupResult = require('./networkSecurityGroupResult'); exports.NetworkConfigurationDiagnosticResult = require('./networkConfigurationDiagnosticResult'); exports.NetworkConfigurationDiagnosticResponse = require('./networkConfigurationDiagnosticResponse'); -exports.QueryConnectionMonitorsParameters = require('./queryConnectionMonitorsParameters'); -exports.ConnectionMonitorsQueryResultItem = require('./connectionMonitorsQueryResultItem'); exports.OperationDisplay = require('./operationDisplay'); exports.Availability = require('./availability'); exports.Dimension = require('./dimension'); @@ -267,7 +265,6 @@ exports.NetworkInterfaceLoadBalancerListResult = require('./networkInterfaceLoad exports.NetworkSecurityGroupListResult = require('./networkSecurityGroupListResult'); exports.SecurityRuleListResult = require('./securityRuleListResult'); exports.NetworkWatcherListResult = require('./networkWatcherListResult'); -exports.QueryConnectionMonitorsResponse = require('./queryConnectionMonitorsResponse'); exports.PacketCaptureListResult = require('./packetCaptureListResult'); exports.ConnectionMonitorListResult = require('./connectionMonitorListResult'); exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/networkManagement2/lib/operations/index.d.ts b/lib/services/networkManagement2/lib/operations/index.d.ts index 4362865f0f..9ed1016140 100644 --- a/lib/services/networkManagement2/lib/operations/index.d.ts +++ b/lib/services/networkManagement2/lib/operations/index.d.ts @@ -17018,78 +17018,6 @@ export interface NetworkWatchers { getNetworkConfigurationDiagnostic(resourceGroupName: string, networkWatcherName: string, parameters: models.NetworkConfigurationDiagnosticParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - /** - * Query connection monitors. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters to get network configuration - * diagnostic. - * - * @param {array} [parameters.connectionMonitorIds] List of connection monitors - * ID. - * - * @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. - */ - queryConnectionMonitorsWithHttpOperationResponse(resourceGroupName: string, networkWatcherName: string, parameters: models.QueryConnectionMonitorsParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Query connection monitors. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters to get network configuration - * diagnostic. - * - * @param {array} [parameters.connectionMonitorIds] List of connection monitors - * ID. - * - * @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 {QueryConnectionMonitorsResponse} - 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. - * - * {QueryConnectionMonitorsResponse} [result] - The deserialized result object if an error did not occur. - * See {@link QueryConnectionMonitorsResponse} 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. - */ - queryConnectionMonitors(resourceGroupName: string, networkWatcherName: string, parameters: models.QueryConnectionMonitorsParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - queryConnectionMonitors(resourceGroupName: string, networkWatcherName: string, parameters: models.QueryConnectionMonitorsParameters, callback: ServiceCallback): void; - queryConnectionMonitors(resourceGroupName: string, networkWatcherName: string, parameters: models.QueryConnectionMonitorsParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - /** * Deletes the specified network watcher resource. * @@ -18217,194 +18145,6 @@ export interface NetworkWatchers { beginGetNetworkConfigurationDiagnostic(resourceGroupName: string, networkWatcherName: string, parameters: models.NetworkConfigurationDiagnosticParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; beginGetNetworkConfigurationDiagnostic(resourceGroupName: string, networkWatcherName: string, parameters: models.NetworkConfigurationDiagnosticParameters, callback: ServiceCallback): void; beginGetNetworkConfigurationDiagnostic(resourceGroupName: string, networkWatcherName: string, parameters: models.NetworkConfigurationDiagnosticParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Query connection monitors. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters to get network configuration - * diagnostic. - * - * @param {array} [parameters.connectionMonitorIds] List of connection monitors - * ID. - * - * @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. - */ - beginQueryConnectionMonitorsWithHttpOperationResponse(resourceGroupName: string, networkWatcherName: string, parameters: models.QueryConnectionMonitorsParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Query connection monitors. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters to get network configuration - * diagnostic. - * - * @param {array} [parameters.connectionMonitorIds] List of connection monitors - * ID. - * - * @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 {QueryConnectionMonitorsResponse} - 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. - * - * {QueryConnectionMonitorsResponse} [result] - The deserialized result object if an error did not occur. - * See {@link QueryConnectionMonitorsResponse} 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. - */ - beginQueryConnectionMonitors(resourceGroupName: string, networkWatcherName: string, parameters: models.QueryConnectionMonitorsParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginQueryConnectionMonitors(resourceGroupName: string, networkWatcherName: string, parameters: models.QueryConnectionMonitorsParameters, callback: ServiceCallback): void; - beginQueryConnectionMonitors(resourceGroupName: string, networkWatcherName: string, parameters: models.QueryConnectionMonitorsParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Query connection monitors. - * - * @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. - */ - queryConnectionMonitorsNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Query connection monitors. - * - * @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 {QueryConnectionMonitorsResponse} - 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. - * - * {QueryConnectionMonitorsResponse} [result] - The deserialized result object if an error did not occur. - * See {@link QueryConnectionMonitorsResponse} 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. - */ - queryConnectionMonitorsNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - queryConnectionMonitorsNext(nextPageLink: string, callback: ServiceCallback): void; - queryConnectionMonitorsNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - - /** - * Query connection monitors. - * - * @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. - */ - beginQueryConnectionMonitorsNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * Query connection monitors. - * - * @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 {QueryConnectionMonitorsResponse} - 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. - * - * {QueryConnectionMonitorsResponse} [result] - The deserialized result object if an error did not occur. - * See {@link QueryConnectionMonitorsResponse} 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. - */ - beginQueryConnectionMonitorsNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginQueryConnectionMonitorsNext(nextPageLink: string, callback: ServiceCallback): void; - beginQueryConnectionMonitorsNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** diff --git a/lib/services/networkManagement2/lib/operations/networkWatchers.js b/lib/services/networkManagement2/lib/operations/networkWatchers.js index 268e14327c..74267803ff 100644 --- a/lib/services/networkManagement2/lib/operations/networkWatchers.js +++ b/lib/services/networkManagement2/lib/operations/networkWatchers.js @@ -2096,91 +2096,6 @@ function _getNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherNam }); } - -/** - * Query connection monitors. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters to get network configuration - * diagnostic. - * - * @param {array} [parameters.connectionMonitorIds] List of connection monitors - * ID. - * - * @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 QueryConnectionMonitorsResponse} 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 _queryConnectionMonitors(resourceGroupName, networkWatcherName, 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.'); - } - - // Send request - this.beginQueryConnectionMonitors(resourceGroupName, networkWatcherName, parameters, options, (err, parsedResult, httpRequest, response) => { - if (err) return callback(err); - - let initialResult = new msRest.HttpOperationResponse(); - initialResult.request = httpRequest; - initialResult.response = response; - initialResult.body = response.body; - client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { - if (err) return callback(err); - - // Create Result - let result = null; - - httpRequest = pollingResult.request; - response = pollingResult.response; - let responseBody = pollingResult.body; - if (responseBody === '') responseBody = null; - - // Deserialize Response - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['QueryConnectionMonitorsResponse']().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 the specified network watcher resource. * @@ -4479,501 +4394,88 @@ function _beginGetNetworkConfigurationDiagnostic(resourceGroupName, networkWatch }); } -/** - * Query connection monitors. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters to get network configuration - * diagnostic. - * - * @param {array} [parameters.connectionMonitorIds] List of connection monitors - * ID. - * - * @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 QueryConnectionMonitorsResponse} 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 _beginQueryConnectionMonitors(resourceGroupName, networkWatcherName, 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-06-01'; - // Validate - try { - if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { - throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); - } - if (networkWatcherName === null || networkWatcherName === undefined || typeof networkWatcherName.valueOf() !== 'string') { - throw new Error('networkWatcherName 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.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); +/** Class representing a NetworkWatchers. */ +class NetworkWatchers { + /** + * Create a NetworkWatchers. + * @param {NetworkManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._createOrUpdate = _createOrUpdate; + this._get = _get; + this._deleteMethod = _deleteMethod; + this._updateTags = _updateTags; + this._list = _list; + this._listAll = _listAll; + this._getTopology = _getTopology; + this._verifyIPFlow = _verifyIPFlow; + this._getNextHop = _getNextHop; + this._getVMSecurityRules = _getVMSecurityRules; + this._getTroubleshooting = _getTroubleshooting; + this._getTroubleshootingResult = _getTroubleshootingResult; + this._setFlowLogConfiguration = _setFlowLogConfiguration; + this._getFlowLogStatus = _getFlowLogStatus; + this._checkConnectivity = _checkConnectivity; + this._getAzureReachabilityReport = _getAzureReachabilityReport; + this._listAvailableProviders = _listAvailableProviders; + this._getNetworkConfigurationDiagnostic = _getNetworkConfigurationDiagnostic; + this._beginDeleteMethod = _beginDeleteMethod; + this._beginVerifyIPFlow = _beginVerifyIPFlow; + this._beginGetNextHop = _beginGetNextHop; + this._beginGetVMSecurityRules = _beginGetVMSecurityRules; + this._beginGetTroubleshooting = _beginGetTroubleshooting; + this._beginGetTroubleshootingResult = _beginGetTroubleshootingResult; + this._beginSetFlowLogConfiguration = _beginSetFlowLogConfiguration; + this._beginGetFlowLogStatus = _beginGetFlowLogStatus; + this._beginCheckConnectivity = _beginCheckConnectivity; + this._beginGetAzureReachabilityReport = _beginGetAzureReachabilityReport; + this._beginListAvailableProviders = _beginListAvailableProviders; + this._beginGetNetworkConfigurationDiagnostic = _beginGetNetworkConfigurationDiagnostic; } - // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryConnectionMonitors'; - requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{networkWatcherName}', encodeURIComponent(networkWatcherName)); - 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 = 'POST'; - 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['QueryConnectionMonitorsParameters']().mapper(); - requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); - return callback(serializationError); - } - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200 && statusCode !== 202) { - 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['QueryConnectionMonitorsResponse']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - // Deserialize Response - if (statusCode === 202) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['QueryConnectionMonitorsResponse']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError1.request = msRest.stripRequest(httpRequest); - deserializationError1.response = msRest.stripResponse(response); - return callback(deserializationError1); - } - } - - return callback(null, result, httpRequest, response); - }); -} - - -/** - * Query connection monitors. - * - * @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 QueryConnectionMonitorsResponse} 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 _queryConnectionMonitorsNext(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.'); - } - - // Send request - this.beginQueryConnectionMonitorsNext(nextPageLink, options, (err, parsedResult, httpRequest, response) => { - if (err) return callback(err); - - let initialResult = new msRest.HttpOperationResponse(); - initialResult.request = httpRequest; - initialResult.response = response; - initialResult.body = response.body; - client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { - if (err) return callback(err); - - // Create Result - let result = null; - - httpRequest = pollingResult.request; - response = pollingResult.response; - let responseBody = pollingResult.body; - if (responseBody === '') responseBody = null; - - // Deserialize Response - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['QueryConnectionMonitorsResponse']().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); - }); - }); -} - -/** - * Query connection monitors. - * - * @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 QueryConnectionMonitorsResponse} 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 _beginQueryConnectionMonitorsNext(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 = 'POST'; - httpRequest.url = requestUrl; - httpRequest.headers = {}; - // Set Headers - httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; - if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - } - if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { - httpRequest.headers['accept-language'] = this.client.acceptLanguage; - } - if(options) { - for(let headerName in options['customHeaders']) { - if (options['customHeaders'].hasOwnProperty(headerName)) { - httpRequest.headers[headerName] = options['customHeaders'][headerName]; - } - } - } - httpRequest.body = null; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200 && statusCode !== 202) { - 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['QueryConnectionMonitorsResponse']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); - return callback(deserializationError); - } - } - // Deserialize Response - if (statusCode === 202) { - let parsedResponse = null; - try { - parsedResponse = JSON.parse(responseBody); - result = JSON.parse(responseBody); - if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['QueryConnectionMonitorsResponse']().mapper(); - result = client.deserialize(resultMapper, parsedResponse, 'result'); - } - } catch (error) { - let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError1.request = msRest.stripRequest(httpRequest); - deserializationError1.response = msRest.stripResponse(response); - return callback(deserializationError1); - } - } - - return callback(null, result, httpRequest, response); - }); -} - -/** Class representing a NetworkWatchers. */ -class NetworkWatchers { - /** - * Create a NetworkWatchers. - * @param {NetworkManagementClient} client Reference to the service client. - */ - constructor(client) { - this.client = client; - this._createOrUpdate = _createOrUpdate; - this._get = _get; - this._deleteMethod = _deleteMethod; - this._updateTags = _updateTags; - this._list = _list; - this._listAll = _listAll; - this._getTopology = _getTopology; - this._verifyIPFlow = _verifyIPFlow; - this._getNextHop = _getNextHop; - this._getVMSecurityRules = _getVMSecurityRules; - this._getTroubleshooting = _getTroubleshooting; - this._getTroubleshootingResult = _getTroubleshootingResult; - this._setFlowLogConfiguration = _setFlowLogConfiguration; - this._getFlowLogStatus = _getFlowLogStatus; - this._checkConnectivity = _checkConnectivity; - this._getAzureReachabilityReport = _getAzureReachabilityReport; - this._listAvailableProviders = _listAvailableProviders; - this._getNetworkConfigurationDiagnostic = _getNetworkConfigurationDiagnostic; - this._queryConnectionMonitors = _queryConnectionMonitors; - this._beginDeleteMethod = _beginDeleteMethod; - this._beginVerifyIPFlow = _beginVerifyIPFlow; - this._beginGetNextHop = _beginGetNextHop; - this._beginGetVMSecurityRules = _beginGetVMSecurityRules; - this._beginGetTroubleshooting = _beginGetTroubleshooting; - this._beginGetTroubleshootingResult = _beginGetTroubleshootingResult; - this._beginSetFlowLogConfiguration = _beginSetFlowLogConfiguration; - this._beginGetFlowLogStatus = _beginGetFlowLogStatus; - this._beginCheckConnectivity = _beginCheckConnectivity; - this._beginGetAzureReachabilityReport = _beginGetAzureReachabilityReport; - this._beginListAvailableProviders = _beginListAvailableProviders; - this._beginGetNetworkConfigurationDiagnostic = _beginGetNetworkConfigurationDiagnostic; - this._beginQueryConnectionMonitors = _beginQueryConnectionMonitors; - this._queryConnectionMonitorsNext = _queryConnectionMonitorsNext; - this._beginQueryConnectionMonitorsNext = _beginQueryConnectionMonitorsNext; - } - - /** - * Creates or updates a network watcher in the specified resource group. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters that define the network watcher - * resource. - * - * @param {string} [parameters.etag] A unique read-only string that changes - * whenever the resource is updated. - * - * @param {string} [parameters.id] Resource ID. - * - * @param {string} [parameters.location] Resource location. - * - * @param {object} [parameters.tags] Resource tags. - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @returns {Promise} A promise is returned - * - * @resolve {HttpOperationResponse} - The deserialized result object. - * - * @reject {Error} - The error object. - */ - createOrUpdateWithHttpOperationResponse(resourceGroupName, networkWatcherName, parameters, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._createOrUpdate(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); + /** + * Creates or updates a network watcher in the specified resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} networkWatcherName The name of the network watcher. + * + * @param {object} parameters Parameters that define the network watcher + * resource. + * + * @param {string} [parameters.etag] A unique read-only string that changes + * whenever the resource is updated. + * + * @param {string} [parameters.id] Resource ID. + * + * @param {string} [parameters.location] Resource location. + * + * @param {object} [parameters.tags] Resource tags. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, networkWatcherName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); } /** @@ -6822,118 +6324,13 @@ class NetworkWatchers { * * {object} [result] - The deserialized result object if an error did not occur. * See {@link AvailableProvidersList} 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. - */ - listAvailableProviders(resourceGroupName, networkWatcherName, 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._listAvailableProviders(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._listAvailableProviders(resourceGroupName, networkWatcherName, parameters, options, optionalCallback); - } - } - - /** - * Get network configuration diagnostic. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters to get network configuration - * diagnostic. - * - * @param {string} parameters.targetResourceId The ID of the target resource to - * perform network configuration diagnostic. Valid options are VM, - * NetworkInterface, VMSS/NetworkInterface and Application Gateway. - * - * @param {array} parameters.queries List of traffic queries. - * - * @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. - */ - getNetworkConfigurationDiagnosticWithHttpOperationResponse(resourceGroupName, networkWatcherName, parameters, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._getNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Get network configuration diagnostic. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters to get network configuration - * diagnostic. - * - * @param {string} parameters.targetResourceId The ID of the target resource to - * perform network configuration diagnostic. Valid options are VM, - * NetworkInterface, VMSS/NetworkInterface and Application Gateway. - * - * @param {array} parameters.queries List of traffic queries. - * - * @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 {NetworkConfigurationDiagnosticResponse} - 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 NetworkConfigurationDiagnosticResponse} for - * more information. + * 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. */ - getNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherName, parameters, options, optionalCallback) { + listAvailableProviders(resourceGroupName, networkWatcherName, parameters, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -6942,19 +6339,19 @@ class NetworkWatchers { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._getNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { + self._listAvailableProviders(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._getNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherName, parameters, options, optionalCallback); + return self._listAvailableProviders(resourceGroupName, networkWatcherName, parameters, options, optionalCallback); } } /** - * Query connection monitors. + * Get network configuration diagnostic. * * @param {string} resourceGroupName The name of the resource group. * @@ -6963,8 +6360,11 @@ class NetworkWatchers { * @param {object} parameters Parameters to get network configuration * diagnostic. * - * @param {array} [parameters.connectionMonitorIds] List of connection monitors - * ID. + * @param {string} parameters.targetResourceId The ID of the target resource to + * perform network configuration diagnostic. Valid options are VM, + * NetworkInterface, VMSS/NetworkInterface and Application Gateway. + * + * @param {array} parameters.queries List of traffic queries. * * @param {object} [options] Optional Parameters. * @@ -6973,15 +6373,15 @@ class NetworkWatchers { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - queryConnectionMonitorsWithHttpOperationResponse(resourceGroupName, networkWatcherName, parameters, options) { + getNetworkConfigurationDiagnosticWithHttpOperationResponse(resourceGroupName, networkWatcherName, parameters, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._queryConnectionMonitors(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { + self._getNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -6992,7 +6392,7 @@ class NetworkWatchers { } /** - * Query connection monitors. + * Get network configuration diagnostic. * * @param {string} resourceGroupName The name of the resource group. * @@ -7001,8 +6401,11 @@ class NetworkWatchers { * @param {object} parameters Parameters to get network configuration * diagnostic. * - * @param {array} [parameters.connectionMonitorIds] List of connection monitors - * ID. + * @param {string} parameters.targetResourceId The ID of the target resource to + * perform network configuration diagnostic. Valid options are VM, + * NetworkInterface, VMSS/NetworkInterface and Application Gateway. + * + * @param {array} parameters.queries List of traffic queries. * * @param {object} [options] Optional Parameters. * @@ -7016,7 +6419,7 @@ class NetworkWatchers { * * {Promise} A promise is returned * - * @resolve {QueryConnectionMonitorsResponse} - The deserialized result object. + * @resolve {NetworkConfigurationDiagnosticResponse} - The deserialized result object. * * @reject {Error} - The error object. * @@ -7025,14 +6428,14 @@ class NetworkWatchers { * {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 QueryConnectionMonitorsResponse} for more - * information. + * See {@link NetworkConfigurationDiagnosticResponse} 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. */ - queryConnectionMonitors(resourceGroupName, networkWatcherName, parameters, options, optionalCallback) { + getNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherName, parameters, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -7041,14 +6444,14 @@ class NetworkWatchers { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._queryConnectionMonitors(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { + self._getNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._queryConnectionMonitors(resourceGroupName, networkWatcherName, parameters, options, optionalCallback); + return self._getNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherName, parameters, options, optionalCallback); } } @@ -8505,275 +7908,6 @@ class NetworkWatchers { } } - /** - * Query connection monitors. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters to get network configuration - * diagnostic. - * - * @param {array} [parameters.connectionMonitorIds] List of connection monitors - * ID. - * - * @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. - */ - beginQueryConnectionMonitorsWithHttpOperationResponse(resourceGroupName, networkWatcherName, parameters, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._beginQueryConnectionMonitors(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Query connection monitors. - * - * @param {string} resourceGroupName The name of the resource group. - * - * @param {string} networkWatcherName The name of the network watcher. - * - * @param {object} parameters Parameters to get network configuration - * diagnostic. - * - * @param {array} [parameters.connectionMonitorIds] List of connection monitors - * ID. - * - * @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 {QueryConnectionMonitorsResponse} - 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 QueryConnectionMonitorsResponse} 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. - */ - beginQueryConnectionMonitors(resourceGroupName, networkWatcherName, 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._beginQueryConnectionMonitors(resourceGroupName, networkWatcherName, parameters, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._beginQueryConnectionMonitors(resourceGroupName, networkWatcherName, parameters, options, optionalCallback); - } - } - - /** - * Query connection monitors. - * - * @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. - */ - queryConnectionMonitorsNextWithHttpOperationResponse(nextPageLink, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._queryConnectionMonitorsNext(nextPageLink, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Query connection monitors. - * - * @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 {QueryConnectionMonitorsResponse} - 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 QueryConnectionMonitorsResponse} 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. - */ - queryConnectionMonitorsNext(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._queryConnectionMonitorsNext(nextPageLink, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._queryConnectionMonitorsNext(nextPageLink, options, optionalCallback); - } - } - - /** - * Query connection monitors. - * - * @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. - */ - beginQueryConnectionMonitorsNextWithHttpOperationResponse(nextPageLink, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._beginQueryConnectionMonitorsNext(nextPageLink, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * Query connection monitors. - * - * @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 {QueryConnectionMonitorsResponse} - 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 QueryConnectionMonitorsResponse} 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. - */ - beginQueryConnectionMonitorsNext(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._beginQueryConnectionMonitorsNext(nextPageLink, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._beginQueryConnectionMonitorsNext(nextPageLink, options, optionalCallback); - } - } - } module.exports = NetworkWatchers;