From 11234e9e18cf1d400f8250bda15d6056c739fae8 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 23 Oct 2018 12:53:07 -0700 Subject: [PATCH 1/3] Generated from 4b6f298444a858abae912e63dd544acedb760373 (#3888) Merge branch 'master' of https://github.com/Azure/azure-rest-api-specs into sbmigrateaction # Conflicts: # specification/servicebus/resource-manager/Microsoft.ServiceBus/stable/2017-04-01/servicebus.json --- .../lib/models/index.d.ts | 13 + .../serviceBusManagement2/lib/models/index.js | 1 + .../lib/models/sBNamespaceMigrate.js | 54 ++++ .../lib/operations/index.d.ts | 70 +++++ .../lib/operations/namespaces.js | 269 ++++++++++++++++++ 5 files changed, 407 insertions(+) create mode 100644 lib/services/serviceBusManagement2/lib/models/sBNamespaceMigrate.js diff --git a/lib/services/serviceBusManagement2/lib/models/index.d.ts b/lib/services/serviceBusManagement2/lib/models/index.d.ts index c1e6072706..ef16e447ae 100644 --- a/lib/services/serviceBusManagement2/lib/models/index.d.ts +++ b/lib/services/serviceBusManagement2/lib/models/index.d.ts @@ -137,6 +137,19 @@ export interface SBNamespaceUpdateParameters extends ResourceNamespacePatch { readonly metricId?: string; } +/** + * @class + * Initializes a new instance of the SBNamespaceMigrate class. + * @constructor + * Namespace Migrate Object + * + * @member {string} targetNamespaceType Type of namespaces. Possible values + * include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' + */ +export interface SBNamespaceMigrate { + targetNamespaceType: string; +} + /** * @class * Initializes a new instance of the SBAuthorizationRule class. diff --git a/lib/services/serviceBusManagement2/lib/models/index.js b/lib/services/serviceBusManagement2/lib/models/index.js index 5f6026f84e..c6442ce38b 100644 --- a/lib/services/serviceBusManagement2/lib/models/index.js +++ b/lib/services/serviceBusManagement2/lib/models/index.js @@ -24,6 +24,7 @@ exports.ResourceNamespacePatch = require('./resourceNamespacePatch'); exports.SBSku = require('./sBSku'); exports.SBNamespace = require('./sBNamespace'); exports.SBNamespaceUpdateParameters = require('./sBNamespaceUpdateParameters'); +exports.SBNamespaceMigrate = require('./sBNamespaceMigrate'); exports.SBAuthorizationRule = require('./sBAuthorizationRule'); exports.AuthorizationRuleProperties = require('./authorizationRuleProperties'); exports.AccessKeys = require('./accessKeys'); diff --git a/lib/services/serviceBusManagement2/lib/models/sBNamespaceMigrate.js b/lib/services/serviceBusManagement2/lib/models/sBNamespaceMigrate.js new file mode 100644 index 0000000000..c5c45aef82 --- /dev/null +++ b/lib/services/serviceBusManagement2/lib/models/sBNamespaceMigrate.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Namespace Migrate Object + * + */ +class SBNamespaceMigrate { + /** + * Create a SBNamespaceMigrate. + * @member {string} targetNamespaceType Type of namespaces. Possible values + * include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' + */ + constructor() { + } + + /** + * Defines the metadata of SBNamespaceMigrate + * + * @returns {object} metadata of SBNamespaceMigrate + * + */ + mapper() { + return { + required: false, + serializedName: 'SBNamespaceMigrate', + type: { + name: 'Composite', + className: 'SBNamespaceMigrate', + modelProperties: { + targetNamespaceType: { + required: true, + serializedName: 'targetNamespaceType', + type: { + name: 'Enum', + allowedValues: [ 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' ] + } + } + } + } + }; + } +} + +module.exports = SBNamespaceMigrate; diff --git a/lib/services/serviceBusManagement2/lib/operations/index.d.ts b/lib/services/serviceBusManagement2/lib/operations/index.d.ts index 568b69e8a0..6058e1dbd2 100644 --- a/lib/services/serviceBusManagement2/lib/operations/index.d.ts +++ b/lib/services/serviceBusManagement2/lib/operations/index.d.ts @@ -1052,6 +1052,76 @@ export interface Namespaces { regenerateKeys(resourceGroupName: string, namespaceName: string, authorizationRuleName: string, parameters: models.RegenerateAccessKeyParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * This operation Migrate the given namespace to provided name type + * + * @param {string} resourceGroupName Name of the Resource group within the + * Azure subscription. + * + * @param {string} namespaceName The namespace name + * + * @param {object} parameters Parameters supplied to migrate namespace type. + * + * @param {string} parameters.targetNamespaceType Type of namespaces. Possible + * values include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' + * + * @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. + */ + migrateWithHttpOperationResponse(resourceGroupName: string, namespaceName: string, parameters: models.SBNamespaceMigrate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * This operation Migrate the given namespace to provided name type + * + * @param {string} resourceGroupName Name of the Resource group within the + * Azure subscription. + * + * @param {string} namespaceName The namespace name + * + * @param {object} parameters Parameters supplied to migrate namespace type. + * + * @param {string} parameters.targetNamespaceType Type of namespaces. Possible + * values include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + migrate(resourceGroupName: string, namespaceName: string, parameters: models.SBNamespaceMigrate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + migrate(resourceGroupName: string, namespaceName: string, parameters: models.SBNamespaceMigrate, callback: ServiceCallback): void; + migrate(resourceGroupName: string, namespaceName: string, parameters: models.SBNamespaceMigrate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Gets a list of IP Filter rules for a Namespace. * diff --git a/lib/services/serviceBusManagement2/lib/operations/namespaces.js b/lib/services/serviceBusManagement2/lib/operations/namespaces.js index d74429a1a3..cecdc5c1dd 100644 --- a/lib/services/serviceBusManagement2/lib/operations/namespaces.js +++ b/lib/services/serviceBusManagement2/lib/operations/namespaces.js @@ -2123,6 +2123,177 @@ function _regenerateKeys(resourceGroupName, namespaceName, authorizationRuleName }); } +/** + * This operation Migrate the given namespace to provided name type + * + * @param {string} resourceGroupName Name of the Resource group within the + * Azure subscription. + * + * @param {string} namespaceName The namespace name + * + * @param {object} parameters Parameters supplied to migrate namespace type. + * + * @param {string} parameters.targetNamespaceType Type of namespaces. Possible + * values include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _migrate(resourceGroupName, namespaceName, 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.'); + } + // 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 (resourceGroupName !== null && resourceGroupName !== undefined) { + if (resourceGroupName.length > 90) + { + throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); + } + if (resourceGroupName.length < 1) + { + throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); + } + } + if (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') { + throw new Error('namespaceName cannot be null or undefined and it must be of type string.'); + } + if (namespaceName !== null && namespaceName !== undefined) { + if (namespaceName.length > 50) + { + throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50'); + } + if (namespaceName.length < 6) + { + throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6'); + } + } + if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.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['SBNamespaceMigrate']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + /** * Gets a list of IP Filter rules for a Namespace. * @@ -4571,6 +4742,7 @@ class Namespaces { this._getAuthorizationRule = _getAuthorizationRule; this._listKeys = _listKeys; this._regenerateKeys = _regenerateKeys; + this._migrate = _migrate; this._listIpFilterRules = _listIpFilterRules; this._createOrUpdateIpFilterRule = _createOrUpdateIpFilterRule; this._deleteIpFilterRule = _deleteIpFilterRule; @@ -5852,6 +6024,103 @@ class Namespaces { } } + /** + * This operation Migrate the given namespace to provided name type + * + * @param {string} resourceGroupName Name of the Resource group within the + * Azure subscription. + * + * @param {string} namespaceName The namespace name + * + * @param {object} parameters Parameters supplied to migrate namespace type. + * + * @param {string} parameters.targetNamespaceType Type of namespaces. Possible + * values include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' + * + * @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. + */ + migrateWithHttpOperationResponse(resourceGroupName, namespaceName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._migrate(resourceGroupName, namespaceName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * This operation Migrate the given namespace to provided name type + * + * @param {string} resourceGroupName Name of the Resource group within the + * Azure subscription. + * + * @param {string} namespaceName The namespace name + * + * @param {object} parameters Parameters supplied to migrate namespace type. + * + * @param {string} parameters.targetNamespaceType Type of namespaces. Possible + * values include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + migrate(resourceGroupName, namespaceName, 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._migrate(resourceGroupName, namespaceName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._migrate(resourceGroupName, namespaceName, parameters, options, optionalCallback); + } + } + /** * Gets a list of IP Filter rules for a Namespace. * From 98eab34070024703955c9e29debb7caa30347697 Mon Sep 17 00:00:00 2001 From: Dan Schulte Date: Tue, 23 Oct 2018 13:53:35 -0700 Subject: [PATCH 2/3] Regenerate azure-arm-sb --- .../lib/models/index.d.ts | 13 - .../serviceBusManagement2/lib/models/index.js | 1 - .../lib/operations/index.d.ts | 70 ----- .../lib/operations/namespaces.js | 269 ------------------ 4 files changed, 353 deletions(-) diff --git a/lib/services/serviceBusManagement2/lib/models/index.d.ts b/lib/services/serviceBusManagement2/lib/models/index.d.ts index ef16e447ae..c1e6072706 100644 --- a/lib/services/serviceBusManagement2/lib/models/index.d.ts +++ b/lib/services/serviceBusManagement2/lib/models/index.d.ts @@ -137,19 +137,6 @@ export interface SBNamespaceUpdateParameters extends ResourceNamespacePatch { readonly metricId?: string; } -/** - * @class - * Initializes a new instance of the SBNamespaceMigrate class. - * @constructor - * Namespace Migrate Object - * - * @member {string} targetNamespaceType Type of namespaces. Possible values - * include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' - */ -export interface SBNamespaceMigrate { - targetNamespaceType: string; -} - /** * @class * Initializes a new instance of the SBAuthorizationRule class. diff --git a/lib/services/serviceBusManagement2/lib/models/index.js b/lib/services/serviceBusManagement2/lib/models/index.js index c6442ce38b..5f6026f84e 100644 --- a/lib/services/serviceBusManagement2/lib/models/index.js +++ b/lib/services/serviceBusManagement2/lib/models/index.js @@ -24,7 +24,6 @@ exports.ResourceNamespacePatch = require('./resourceNamespacePatch'); exports.SBSku = require('./sBSku'); exports.SBNamespace = require('./sBNamespace'); exports.SBNamespaceUpdateParameters = require('./sBNamespaceUpdateParameters'); -exports.SBNamespaceMigrate = require('./sBNamespaceMigrate'); exports.SBAuthorizationRule = require('./sBAuthorizationRule'); exports.AuthorizationRuleProperties = require('./authorizationRuleProperties'); exports.AccessKeys = require('./accessKeys'); diff --git a/lib/services/serviceBusManagement2/lib/operations/index.d.ts b/lib/services/serviceBusManagement2/lib/operations/index.d.ts index 6058e1dbd2..568b69e8a0 100644 --- a/lib/services/serviceBusManagement2/lib/operations/index.d.ts +++ b/lib/services/serviceBusManagement2/lib/operations/index.d.ts @@ -1052,76 +1052,6 @@ export interface Namespaces { regenerateKeys(resourceGroupName: string, namespaceName: string, authorizationRuleName: string, parameters: models.RegenerateAccessKeyParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - /** - * This operation Migrate the given namespace to provided name type - * - * @param {string} resourceGroupName Name of the Resource group within the - * Azure subscription. - * - * @param {string} namespaceName The namespace name - * - * @param {object} parameters Parameters supplied to migrate namespace type. - * - * @param {string} parameters.targetNamespaceType Type of namespaces. Possible - * values include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' - * - * @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. - */ - migrateWithHttpOperationResponse(resourceGroupName: string, namespaceName: string, parameters: models.SBNamespaceMigrate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; - - /** - * This operation Migrate the given namespace to provided name type - * - * @param {string} resourceGroupName Name of the Resource group within the - * Azure subscription. - * - * @param {string} namespaceName The namespace name - * - * @param {object} parameters Parameters supplied to migrate namespace type. - * - * @param {string} parameters.targetNamespaceType Type of namespaces. Possible - * values include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {ServiceCallback} [optionalCallback] - The optional callback. - * - * @returns {ServiceCallback|Promise} If a callback was passed as the last - * parameter then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned. - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error|ServiceError} - The error object. - * - * {ServiceCallback} optionalCallback(err, result, request, response) - * - * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {WebResource} [request] - The HTTP Request object if an error did not occur. - * - * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. - */ - migrate(resourceGroupName: string, namespaceName: string, parameters: models.SBNamespaceMigrate, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - migrate(resourceGroupName: string, namespaceName: string, parameters: models.SBNamespaceMigrate, callback: ServiceCallback): void; - migrate(resourceGroupName: string, namespaceName: string, parameters: models.SBNamespaceMigrate, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; - - /** * Gets a list of IP Filter rules for a Namespace. * diff --git a/lib/services/serviceBusManagement2/lib/operations/namespaces.js b/lib/services/serviceBusManagement2/lib/operations/namespaces.js index cecdc5c1dd..d74429a1a3 100644 --- a/lib/services/serviceBusManagement2/lib/operations/namespaces.js +++ b/lib/services/serviceBusManagement2/lib/operations/namespaces.js @@ -2123,177 +2123,6 @@ function _regenerateKeys(resourceGroupName, namespaceName, authorizationRuleName }); } -/** - * This operation Migrate the given namespace to provided name type - * - * @param {string} resourceGroupName Name of the Resource group within the - * Azure subscription. - * - * @param {string} namespaceName The namespace name - * - * @param {object} parameters Parameters supplied to migrate namespace type. - * - * @param {string} parameters.targetNamespaceType Type of namespaces. Possible - * values include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} callback - The callback. - * - * @returns {function} callback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ -function _migrate(resourceGroupName, namespaceName, 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.'); - } - // 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 (resourceGroupName !== null && resourceGroupName !== undefined) { - if (resourceGroupName.length > 90) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); - } - if (resourceGroupName.length < 1) - { - throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); - } - } - if (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') { - throw new Error('namespaceName cannot be null or undefined and it must be of type string.'); - } - if (namespaceName !== null && namespaceName !== undefined) { - if (namespaceName.length > 50) - { - throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50'); - } - if (namespaceName.length < 6) - { - throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6'); - } - } - if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { - throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); - } - if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { - throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); - } - if (parameters === null || parameters === undefined) { - throw new Error('parameters cannot be null or undefined.'); - } - if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { - throw new Error('this.client.acceptLanguage must be of type string.'); - } - } catch (error) { - return callback(error); - } - - // Construct URL - let baseUrl = this.client.baseUri; - let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrate'; - requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); - requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName)); - requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); - let queryParameters = []; - queryParameters.push('api-version=' + encodeURIComponent(this.client.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['SBNamespaceMigrate']().mapper(); - requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); - requestContent = JSON.stringify(requestModel); - } - } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); - return callback(serializationError); - } - httpRequest.body = requestContent; - // Send Request - return client.pipeline(httpRequest, (err, response, responseBody) => { - if (err) { - return callback(err); - } - let statusCode = response.statusCode; - if (statusCode !== 200) { - let error = new Error(responseBody); - error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); - if (responseBody === '') responseBody = null; - let parsedErrorResponse; - try { - parsedErrorResponse = JSON.parse(responseBody); - if (parsedErrorResponse) { - let internalError = null; - if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; - error.code = internalError ? internalError.code : parsedErrorResponse.code; - error.message = internalError ? internalError.message : parsedErrorResponse.message; - } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['ErrorResponse']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } - } catch (defaultError) { - error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; - return callback(error); - } - return callback(error); - } - // Create Result - let result = null; - if (responseBody === '') responseBody = null; - - return callback(null, result, httpRequest, response); - }); -} - /** * Gets a list of IP Filter rules for a Namespace. * @@ -4742,7 +4571,6 @@ class Namespaces { this._getAuthorizationRule = _getAuthorizationRule; this._listKeys = _listKeys; this._regenerateKeys = _regenerateKeys; - this._migrate = _migrate; this._listIpFilterRules = _listIpFilterRules; this._createOrUpdateIpFilterRule = _createOrUpdateIpFilterRule; this._deleteIpFilterRule = _deleteIpFilterRule; @@ -6024,103 +5852,6 @@ class Namespaces { } } - /** - * This operation Migrate the given namespace to provided name type - * - * @param {string} resourceGroupName Name of the Resource group within the - * Azure subscription. - * - * @param {string} namespaceName The namespace name - * - * @param {object} parameters Parameters supplied to migrate namespace type. - * - * @param {string} parameters.targetNamespaceType Type of namespaces. Possible - * values include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' - * - * @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. - */ - migrateWithHttpOperationResponse(resourceGroupName, namespaceName, parameters, options) { - let client = this.client; - let self = this; - return new Promise((resolve, reject) => { - self._migrate(resourceGroupName, namespaceName, parameters, options, (err, result, request, response) => { - let httpOperationResponse = new msRest.HttpOperationResponse(request, response); - httpOperationResponse.body = result; - if (err) { reject(err); } - else { resolve(httpOperationResponse); } - return; - }); - }); - } - - /** - * This operation Migrate the given namespace to provided name type - * - * @param {string} resourceGroupName Name of the Resource group within the - * Azure subscription. - * - * @param {string} namespaceName The namespace name - * - * @param {object} parameters Parameters supplied to migrate namespace type. - * - * @param {string} parameters.targetNamespaceType Type of namespaces. Possible - * values include: 'Messaging', 'NotificationHub', 'Mixed', 'EventHub', 'Relay' - * - * @param {object} [options] Optional Parameters. - * - * @param {object} [options.customHeaders] Headers that will be added to the - * request - * - * @param {function} [optionalCallback] - The optional callback. - * - * @returns {function|Promise} If a callback was passed as the last parameter - * then it returns the callback else returns a Promise. - * - * {Promise} A promise is returned - * - * @resolve {null} - The deserialized result object. - * - * @reject {Error} - The error object. - * - * {function} optionalCallback(err, result, request, response) - * - * {Error} err - The Error object if an error occurred, null otherwise. - * - * {null} [result] - The deserialized result object if an error did not occur. - * - * {object} [request] - The HTTP Request object if an error did not occur. - * - * {stream} [response] - The HTTP Response stream if an error did not occur. - */ - migrate(resourceGroupName, namespaceName, 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._migrate(resourceGroupName, namespaceName, parameters, options, (err, result, request, response) => { - if (err) { reject(err); } - else { resolve(result); } - return; - }); - }); - } else { - return self._migrate(resourceGroupName, namespaceName, parameters, options, optionalCallback); - } - } - /** * Gets a list of IP Filter rules for a Namespace. * From c9c4d6042c0396ef6f16eca87a5d3953ba73a9d1 Mon Sep 17 00:00:00 2001 From: Dan Schulte Date: Tue, 23 Oct 2018 13:54:28 -0700 Subject: [PATCH 3/3] Update azure-arm-sb to 2.6.0 --- lib/services/serviceBusManagement2/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/serviceBusManagement2/package.json b/lib/services/serviceBusManagement2/package.json index eb2c9223e9..1be6c6df82 100644 --- a/lib/services/serviceBusManagement2/package.json +++ b/lib/services/serviceBusManagement2/package.json @@ -2,7 +2,7 @@ "name": "azure-arm-sb", "author": "Microsoft Corporation", "description": "ServiceBusManagementClient Library with typescript type definitions for node", - "version": "2.5.0", + "version": "2.6.0", "dependencies": { "ms-rest": "^2.3.3", "ms-rest-azure": "^2.5.5"