From c0840b064a4841f6d51338f8a39dfe6f4971d3e8 Mon Sep 17 00:00:00 2001 From: Jhonatan Sandoval Velasco <122501764+JhontSouth@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:24:00 -0500 Subject: [PATCH 1/4] feat: Extraction of thumbprint value through the certificate (#4580) * extract thumbprint from cert value * fix documentation * keep previous constructor with new structure * include validation to avoid undefined.trim() --- libraries/botframework-connector/package.json | 3 +- ...tificateServiceClientCredentialsFactory.ts | 57 ++++++++++++++++--- yarn.lock | 5 ++ 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/libraries/botframework-connector/package.json b/libraries/botframework-connector/package.json index 5ca4e70ea1..f6c2d51294 100644 --- a/libraries/botframework-connector/package.json +++ b/libraries/botframework-connector/package.json @@ -37,7 +37,8 @@ "cross-fetch": "^3.0.5", "jsonwebtoken": "^9.0.0", "rsa-pem-from-mod-exp": "^0.8.4", - "zod": "^3.22.4" + "zod": "^3.22.4", + "openssl-wrapper": "^0.3.4" }, "devDependencies": { "@types/jsonwebtoken": "8.3.5", diff --git a/libraries/botframework-connector/src/auth/certificateServiceClientCredentialsFactory.ts b/libraries/botframework-connector/src/auth/certificateServiceClientCredentialsFactory.ts index 65b0682751..407cb62b63 100644 --- a/libraries/botframework-connector/src/auth/certificateServiceClientCredentialsFactory.ts +++ b/libraries/botframework-connector/src/auth/certificateServiceClientCredentialsFactory.ts @@ -10,6 +10,9 @@ import type { ServiceClientCredentials } from '@azure/ms-rest-js'; import { ServiceClientCredentialsFactory } from './serviceClientCredentialsFactory'; import { ok } from 'assert'; import { CertificateAppCredentials } from './certificateAppCredentials'; +import { promisify } from 'util'; +import * as opensslWrapper from 'openssl-wrapper'; +const openssl = promisify(opensslWrapper.default); /** * A Certificate implementation of the [ServiceClientCredentialsFactory](xref:botframework-connector.ServiceClientCredentialsFactory) abstract class. @@ -37,23 +40,51 @@ export class CertificateServiceClientCredentialsFactory extends ServiceClientCre certificatePrivateKey: string, tenantId?: string, x5c?: string + ); + + /** + * Initializes a new instance of the CertificateServiceClientCredentialsFactory class. + * + * @param appId Microsoft application Id related to the certificate. + * @param x5c Value that enables application developers to achieve easy certificates roll-over in Azure AD + * set this parameter to send the public certificate (BEGIN CERTIFICATE) to Azure AD, so that Azure AD can use it to validate the subject name based on a trusted issuer policy. + * @param certificatePrivateKey A PEM encoded certificate private key. + * @param tenantId Optional. The oauth token tenant. + */ + constructor(appId: string, x5c: string, certificatePrivateKey: string, tenantId?: string); + + /** + * @internal + */ + constructor( + appId: string, + certificateThumbprintOrx5c: string, + certificatePrivateKey: string, + tenantId?: string, + x5c?: string ) { super(); + ok(appId?.trim(), 'CertificateServiceClientCredentialsFactory.constructor(): missing appId.'); - ok( - certificateThumbprint?.trim(), - 'CertificateServiceClientCredentialsFactory.constructor(): missing certificateThumbprint.' - ); ok( certificatePrivateKey?.trim(), 'CertificateServiceClientCredentialsFactory.constructor(): missing certificatePrivateKey.' ); + if (certificateThumbprintOrx5c?.includes('-----BEGIN CERTIFICATE-----')) { + this.x5c = certificateThumbprintOrx5c; + } else { + ok( + certificateThumbprintOrx5c?.trim(), + 'CertificateServiceClientCredentialsFactory.constructor(): missing certificateThumbprint or x5c value.' + ); + this.certificateThumbprint = certificateThumbprintOrx5c; + this.x5c = x5c; + } + this.appId = appId; - this.certificateThumbprint = certificateThumbprint; this.certificatePrivateKey = certificatePrivateKey; this.tenantId = tenantId; - this.x5c = x5c; } /** @@ -63,6 +94,18 @@ export class CertificateServiceClientCredentialsFactory extends ServiceClientCre return appId === this.appId; } + /** + * @param cert Value with the certificate content. + * @returns The thumbprint value calculated from the cert content. + */ + private async getThumbprint(cert) { + const fingerprintResponse = await openssl('x509', Buffer.from(cert), { fingerprint: true, noout: true }); + return Buffer.from(fingerprintResponse) + .toString() + .replace(/^.*Fingerprint=/, '') + .replace(/:/g, '') + .trim(); + } /** * @inheritdoc */ @@ -82,7 +125,7 @@ export class CertificateServiceClientCredentialsFactory extends ServiceClientCre return new CertificateAppCredentials( this.appId, - this.certificateThumbprint, + this.certificateThumbprint ?? (await this.getThumbprint(this.x5c)), this.certificatePrivateKey, this.tenantId, audience, diff --git a/yarn.lock b/yarn.lock index e7a453183e..916ca71cc3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10254,6 +10254,11 @@ open@8.4.0, open@^8.0.0: is-docker "^2.1.1" is-wsl "^2.2.0" +openssl-wrapper@^0.3.4: + version "0.3.4" + resolved "https://registry.yarnpkg.com/openssl-wrapper/-/openssl-wrapper-0.3.4.tgz#c01ec98e4dcd2b5dfe0b693f31827200e3b81b07" + integrity sha512-iITsrx6Ho8V3/2OVtmZzzX8wQaKAaFXEJQdzoPUZDtyf5jWFlqo+h+OhGT4TATQ47f9ACKHua8nw7Qoy85aeKQ== + optionator@^0.8.1: version "0.8.3" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" From 90745251a201b2b64439c96b2cc2448a29f7f887 Mon Sep 17 00:00:00 2001 From: Jhonatan Sandoval Velasco <122501764+JhontSouth@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:08:17 -0500 Subject: [PATCH 2/4] fix: [#4470] Migrate off @azure/ms-rest-js tools (#4576) * update yarn lock without ms-rest-js * remove ms-rest-js in tools * set @azure/core-util version * remove core-util of resolutions --- package.json | 1 - tools/framework/suite-base.js | 116 +++--- .../operations/deploymentOperations.js | 99 ++--- .../lib/resource/operations/deployments.js | 331 +++++++--------- .../lib/resource/operations/providers.js | 103 +++-- .../lib/resource/operations/resourceGroups.js | 223 +++++------ .../lib/resource/operations/resources.js | 371 ++++++++---------- .../lib/resource/operations/tags.js | 123 +++--- .../lib/resource/resourceManagementClient.js | 5 +- yarn.lock | 34 +- 10 files changed, 647 insertions(+), 759 deletions(-) diff --git a/package.json b/package.json index 36b9a83566..70c1780800 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ }, "devDependencies": { "@azure/logger": "^1.0.2", - "@azure/ms-rest-js": "^2.7.0", "@microsoft/api-extractor": "^7.38.2", "@standardlabs/downlevel-dts": "^0.7.5", "@standardlabs/is-private": "^1.0.1", diff --git a/tools/framework/suite-base.js b/tools/framework/suite-base.js index 355b29b9e5..32e0b7d980 100644 --- a/tools/framework/suite-base.js +++ b/tools/framework/suite-base.js @@ -21,11 +21,11 @@ var sinon = require('sinon'); var _ = require('underscore'); var util = require('util'); var uuid = require('uuid'); -var msRest = require('@azure/ms-rest-js'); -var identity = require('@azure/identity'); -var { Environment } = require('@azure/ms-rest-azure-env'); +var { TokenCredentials } = require('botframework-connector'); var MicrosoftAppCredentials = require('botframework-connector/lib/auth/microsoftAppCredentials'); var TokenApiClient = require('botframework-connector/lib/tokenApi/tokenApiClient'); +var identity = require('@azure/identity'); +var { Environment } = require('@azure/ms-rest-azure-env'); var FileTokenCache = require('../util/fileTokenCache'); var MockTokenCache = require('./mock-token-cache'); var nockHelper = require('./nock-helper'); @@ -59,7 +59,7 @@ function SuiteBase(mochaSuiteObject, testPrefix, env, libraryPath) { this.mockServerClient; this.currentTest = ''; //Recording info - this.setRecordingsDirectory(path.join(__dirname, '../../', `libraries/${ libraryPath }/tests/recordings/`)); + this.setRecordingsDirectory(path.join(__dirname, '../../', `libraries/${libraryPath}/tests/recordings/`)); this.suiteRecordingsFile = this.getRecordingsDirectory() + 'suite.' + this.testPrefix + '.nock.js'; //test modes // dotenv reads booleans as strings, so we'll use ternary statements to conver to boolean @@ -74,7 +74,7 @@ function SuiteBase(mochaSuiteObject, testPrefix, env, libraryPath) { this.username = process.env['AZURE_USERNAME'] || 'username@example.com'; this.password = process.env['AZURE_PASSWORD'] || 'dummypassword'; this.secret = process.env['CLIENT_SECRET'] || 'dummysecret'; - const clientApplication = new msal.PublicClientApplication({auth: {}}); + const clientApplication = new msal.PublicClientApplication({ auth: {} }); this.tokenCache = clientApplication.getTokenCache(); this._setCredentials(); @@ -98,11 +98,11 @@ function SuiteBase(mochaSuiteObject, testPrefix, env, libraryPath) { _.extend(SuiteBase.prototype, { - _setCredentials: function() { + _setCredentials: function () { if (!this.isPlayback) { if (process.env['SKIP_CREDENTIAL_CHECK']) { let token = process.env['AZURE_ACCESS_TOKEN'] || 'token'; - this.credentials = new msRest.TokenCredentials('token'); + this.credentials = new TokenCredentials('token'); } else if ((process.env['AZURE_PASSWORD'] && process.env['CLIENT_SECRET']) || (!process.env['AZURE_PASSWORD'] && !process.env['CLIENT_SECRET'])) { throw new Error('You must either set the envt. variables \'AZURE_USERNAME\' ' + @@ -128,8 +128,8 @@ _.extend(SuiteBase.prototype, { * * @returns {@azure/identity.UsernamePasswordCredential} The user token credentials object. */ - _createUserCredentials: function() { - if(process.env['AZURE_ENVIRONMENT'] && process.env['AZURE_ENVIRONMENT'].toUpperCase() === 'DOGFOOD') { + _createUserCredentials: function () { + if (process.env['AZURE_ENVIRONMENT'] && process.env['AZURE_ENVIRONMENT'].toUpperCase() === 'DOGFOOD') { var df = { name: 'Dogfood', portalUrl: 'https://windows.azure-test.net/', @@ -152,8 +152,8 @@ _.extend(SuiteBase.prototype, { * * @returns {@azure/identity.ClientSecretCredential} The application token credentials object. */ - _createApplicationCredentials: function() { - if(process.env['AZURE_ENVIRONMENT'] && process.env['AZURE_ENVIRONMENT'].toUpperCase() === 'DOGFOOD') { + _createApplicationCredentials: function () { + if (process.env['AZURE_ENVIRONMENT'] && process.env['AZURE_ENVIRONMENT'].toUpperCase() === 'DOGFOOD') { var df = { name: 'Dogfood', portalUrl: 'https://windows.azure-test.net/', @@ -177,7 +177,7 @@ _.extend(SuiteBase.prototype, { /** * Creates a ResourceManagementClient and sets it as a property of the suite. */ - _setupResourceManagementClient: function() { + _setupResourceManagementClient: function () { if (!this.resourceManagement) { this.resourceManagement = new ResourceManagementClient(this.credentials, this.subscriptionId); } @@ -194,7 +194,7 @@ _.extend(SuiteBase.prototype, { * * @returns {function} callback(err, result) - It contains error and result for the create request. */ - createResourcegroup: function(groupName, location, callback) { + createResourcegroup: function (groupName, location, callback) { console.log('Creating Resource Group: \'' + groupName + '\' at location: \'' + location + '\''); this._setupResourceManagementClient(); return this.resourceManagement.resourceGroups.createOrUpdate(groupName, { @@ -209,7 +209,7 @@ _.extend(SuiteBase.prototype, { * * @returns {function} callback(err, result) - It contains error and result for the delete request. */ - deleteResourcegroup: function(groupName, callback) { + deleteResourcegroup: function (groupName, callback) { console.log('Deleting Resource Group: ' + groupName); if (!this.resourceManagement) { this._setupResourceManagementClient(); @@ -222,7 +222,7 @@ _.extend(SuiteBase.prototype, { * * @returns {string} The test recordings directory */ - getRecordingsDirectory: function() { + getRecordingsDirectory: function () { return this.recordingsDirectory; }, @@ -231,7 +231,7 @@ _.extend(SuiteBase.prototype, { * * @param {string} dir The test recordings directory */ - setRecordingsDirectory: function(dir) { + setRecordingsDirectory: function (dir) { if (!fs.existsSync(dir)) { fs.mkdirSync(dir); } @@ -243,19 +243,19 @@ _.extend(SuiteBase.prototype, { * * @returns {string} The curent test recordings file */ - getTestRecordingsFile: function() { + getTestRecordingsFile: function () { this.testRecordingsFile = this.getRecordingsDirectory() + this.normalizeTestName(this.currentTest) + '.nock.js'; return this.testRecordingsFile; }, - normalizeTestName: function(str) { + normalizeTestName: function (str) { return str.replace(/[{}\[\]'";\(\)#@~`!%&\^\$\+=,\/\\?<>\|\*:]/ig, '').replace(/(\s+)/ig, '_'); }, - normalizeEnvironment: function(env) { - this.requiredEnvironment = env.map(function(env) { - if (typeof(env) === 'string') { + normalizeEnvironment: function (env) { + this.requiredEnvironment = env.map(function (env) { + if (typeof (env) === 'string') { return { name: env, secure: false @@ -266,14 +266,14 @@ _.extend(SuiteBase.prototype, { }); }, - validateEnvironment: function() { + validateEnvironment: function () { if (this.isPlayback) { return; } var messages = []; var missing = []; - this.requiredEnvironment.forEach(function(e) { + this.requiredEnvironment.forEach(function (e) { if (!process.env[e.name] && !e.defaultValue) { missing.push(e.name); } @@ -289,8 +289,8 @@ _.extend(SuiteBase.prototype, { } }, - setEnvironmentDefaults: function() { - this.requiredEnvironment.forEach(function(env) { + setEnvironmentDefaults: function () { + this.requiredEnvironment.forEach(function (env) { if (env.defaultValue && !process.env[env.name]) { process.env[env.name] = env.defaultValue; } @@ -302,7 +302,7 @@ _.extend(SuiteBase.prototype, { * * @returns {string} The curent suite recordings file */ - getSuiteRecordingsFile: function() { + getSuiteRecordingsFile: function () { return this.suiteRecordingsFile; }, @@ -312,7 +312,7 @@ _.extend(SuiteBase.prototype, { * * @param {function} callback A hook to provide the steps to execute during setup suite */ - setupSuite: function(callback, isAsyncSetUp) { + setupSuite: function (callback, isAsyncSetUp) { if (this.isMocked) { process.env.AZURE_ENABLE_STRICT_SSL = false; } @@ -344,9 +344,9 @@ _.extend(SuiteBase.prototype, { } var self = this; async.series([ - function(firstCallback) { + function (firstCallback) { if (isAsyncSetUp) { - callback(function() { + callback(function () { firstCallback(null); }); } else { @@ -354,7 +354,7 @@ _.extend(SuiteBase.prototype, { firstCallback(null); } }, - function(secondCallback) { + function (secondCallback) { //write the suite level testids and uuids to a suite recordings file if (self.isMocked && self.isRecording) { self.writeRecordingHeader(self.getSuiteRecordingsFile()); @@ -367,11 +367,11 @@ _.extend(SuiteBase.prototype, { secondCallback(null); } ], - function(err, results) { - if (err) { - throw err; - } - }); + function (err, results) { + if (err) { + throw err; + } + }); }, /** @@ -380,7 +380,7 @@ _.extend(SuiteBase.prototype, { * * @param {function} callback A hook to provide the steps to execute during setup suite */ - setupSuiteAsync: function(callback) { + setupSuiteAsync: function (callback) { this.setupSuite(callback, true); }, @@ -389,7 +389,7 @@ _.extend(SuiteBase.prototype, { * * @param {function} callback A hook to provide the steps to execute after the suite has completed execution */ - teardownSuite: function(callback) { + teardownSuite: function (callback) { if (this.isMocked) { delete process.env.AZURE_ENABLE_STRICT_SSL; } @@ -402,7 +402,7 @@ _.extend(SuiteBase.prototype, { * * @param {function} callback A hook to provide the steps to execute before the test starts execution */ - setupTest: function(callback) { + setupTest: function (callback) { this.currentTest = this.mochaSuiteObject.currentTest.fullTitle(); this.numberOfRandomTestIdGenerated = 0; this.currentUuid = 0; @@ -436,7 +436,7 @@ _.extend(SuiteBase.prototype, { this.tokenCache = new MockTokenCache(); if (nocked.scopes.length === 1) { - nocked.scopes[0].forEach(function(createScopeFunc) { + nocked.scopes[0].forEach(function (createScopeFunc) { createScopeFunc(nockHelper.nock); }); } else { @@ -454,14 +454,14 @@ _.extend(SuiteBase.prototype, { * * @param {function} callback A hook to provide the steps to execute after the test has completed execution */ - baseTeardownTest: function(callback) { + baseTeardownTest: function (callback) { if (this.isMocked) { if (this.isRecording) { // play nock recording var scope = '['; var lineWritten; var importFsAndPathInRecording = false; - nockHelper.nock.recorder.play().forEach(function(line) { + nockHelper.nock.recorder.play().forEach(function (line) { if (line.indexOf('nock') >= 0) { // apply fixups of nock generated mocks @@ -534,9 +534,9 @@ _.extend(SuiteBase.prototype, { * @param {string} filename (Optional) The file name to which the uuids need to be added * If the filename is not provided then it will get the current test recording file. */ - writeGeneratedUuids: function(filename) { + writeGeneratedUuids: function (filename) { if (this.uuidsGenerated.length > 0) { - var uuids = this.uuidsGenerated.map(function(uuid) { + var uuids = this.uuidsGenerated.map(function (uuid) { return '\'' + uuid + '\''; }).join(','); var content = util.format('\n exports.uuidsGenerated = function() { return [%s];};', uuids); @@ -552,9 +552,9 @@ _.extend(SuiteBase.prototype, { * @param {string} filename (Optional) The file name to which the random test ids need to be added * If the filename is not provided then it will get the current test recording file. */ - writeGeneratedRandomTestIds: function(filename) { + writeGeneratedRandomTestIds: function (filename) { if (this.randomTestIdsGenerated.length > 0) { - var ids = this.randomTestIdsGenerated.map(function(id) { + var ids = this.randomTestIdsGenerated.map(function (id) { return '\'' + id + '\''; }).join(','); var content = util.format('\n exports.randomTestIdsGenerated = function() { return [%s];};', ids); @@ -570,7 +570,7 @@ _.extend(SuiteBase.prototype, { * @param {string} filename (Optional) The file name to which the mock variables need to be added * If the filename is not provided then it will get the current test recording file. */ - writeMockVariables: function(filename) { + writeMockVariables: function (filename) { if (this.mockVariables && Object.keys(this.mockVariables).length > 0) { var mockVariablesObject = JSON.stringify(this.mockVariables); var content = util.format('\n exports.mockVariables = function() { return %s; };', mockVariablesObject); @@ -586,7 +586,7 @@ _.extend(SuiteBase.prototype, { * @param {string} filename (Optional) The file name to which the recording header needs to be added * If the filename is not provided then it will get the current test recording file. */ - writeRecordingHeader: function(filename) { + writeRecordingHeader: function (filename) { var template = fs.readFileSync(path.join(__dirname, 'preamble.template'), { encoding: 'utf8' }); @@ -603,7 +603,7 @@ _.extend(SuiteBase.prototype, { * @param {array} currentList The current list of identifiers. * @return {string} A new unique identifier. */ - generateId: function(prefix, currentList) { + generateId: function (prefix, currentList) { if (!currentList) { currentList = []; } @@ -635,7 +635,7 @@ _.extend(SuiteBase.prototype, { * retrieve the guid from the recording file if in 'Playback' mode. * @return {string} A new Guid. */ - generateGuid: function() { + generateGuid: function () { var newGuid; //record or live if (!this.isPlayback) { @@ -658,7 +658,7 @@ _.extend(SuiteBase.prototype, { * Saves the mock variable with the specified name to the recording file when the test is run * in 'Record' mode or keeps it in memory when the test is run in 'Live' mode. */ - saveMockVariable: function(mockVariableName, mockVariable) { + saveMockVariable: function (mockVariableName, mockVariable) { //record or live if (!this.isPlayback) { this.mockVariables[mockVariableName] = mockVariable; @@ -669,7 +669,7 @@ _.extend(SuiteBase.prototype, { * Gets the mock variable with the specified name. Returns undefined if the variable name is not present. * @return {object} A mock variable. */ - getMockVariable: function(mockVariableName) { + getMockVariable: function (mockVariableName) { return this.mockVariables[mockVariableName]; }, @@ -683,7 +683,7 @@ _.extend(SuiteBase.prototype, { * returns new function that runs when method is called. * @return {object} The created stub. */ - wrap: function(sinonObj, object, property, setup) { + wrap: function (sinonObj, object, property, setup) { var original = object[property]; return sinonObj.stub(object, property, setup(original)); }, @@ -696,7 +696,7 @@ _.extend(SuiteBase.prototype, { * (This ensures that there are no duplicates in the list) * @return {string} The generated random nmumber. */ - generateRandomId: function(prefix, currentList) { + generateRandomId: function (prefix, currentList) { var newNumber; while (true) { newNumber = prefix + Math.floor(Math.random() * 10000); @@ -710,19 +710,19 @@ _.extend(SuiteBase.prototype, { /** * Stubs certain methods. */ - _stubMethods: function() { - if (this.isPlayback) { + _stubMethods: function () { + if (this.isPlayback) { if (this.createResourcegroup.restore) { this.createResourcegroup.restore(); } - sinon.stub(this, 'createResourcegroup').callsFake(function(groupName, location, callback) { + sinon.stub(this, 'createResourcegroup').callsFake(function (groupName, location, callback) { return callback(null); }); if (this.deleteResourcegroup.restore) { this.deleteResourcegroup.restore(); } - sinon.stub(this, 'deleteResourcegroup').callsFake(function(groupName, callback) { + sinon.stub(this, 'deleteResourcegroup').callsFake(function (groupName, callback) { return callback(null); }); @@ -766,7 +766,7 @@ _.extend(SuiteBase.prototype, { connectionName: 'mockConnection', token: 'mockToken', expiration: 'mockExpiration', - _response : { + _response: { bodyAsText: 'mockBody', parsedBody: { channelId: 'mockChannel', diff --git a/tools/resourceManagement/lib/resource/operations/deploymentOperations.js b/tools/resourceManagement/lib/resource/operations/deploymentOperations.js index 25224f40d2..e4e6a0d86b 100644 --- a/tools/resourceManagement/lib/resource/operations/deploymentOperations.js +++ b/tools/resourceManagement/lib/resource/operations/deploymentOperations.js @@ -10,9 +10,8 @@ 'use strict'; -const msRest = require('@azure/ms-rest-js'); +const { stripRequest, stripResponse, WebResource } = require("@azure/core-http"); const uuid = require('uuid'); -const WebResource = msRest.WebResource; /** * Gets a deployments operation. @@ -43,9 +42,9 @@ const WebResource = msRest.WebResource; * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _get(resourceGroupName, deploymentName, operationId, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -58,16 +57,13 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback) 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -75,16 +71,13 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback) throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); } if (deploymentName !== null && deploymentName !== undefined) { - if (deploymentName.length > 64) - { + if (deploymentName.length > 64) { throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64'); } - if (deploymentName.length < 1) - { + if (deploymentName.length < 1) { throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1'); } - if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) - { + if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -125,13 +118,13 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback) // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -147,8 +140,8 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback) if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -164,7 +157,7 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback) } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -184,8 +177,8 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback) } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -225,9 +218,9 @@ function _get(resourceGroupName, deploymentName, operationId, options, callback) * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _list(resourceGroupName, deploymentName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -241,16 +234,13 @@ function _list(resourceGroupName, deploymentName, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -258,16 +248,13 @@ function _list(resourceGroupName, deploymentName, options, callback) { throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); } if (deploymentName !== null && deploymentName !== undefined) { - if (deploymentName.length > 64) - { + if (deploymentName.length > 64) { throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64'); } - if (deploymentName.length < 1) - { + if (deploymentName.length < 1) { throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1'); } - if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) - { + if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -310,13 +297,13 @@ function _list(resourceGroupName, deploymentName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -332,8 +319,8 @@ function _list(resourceGroupName, deploymentName, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -349,7 +336,7 @@ function _list(resourceGroupName, deploymentName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -369,8 +356,8 @@ function _list(resourceGroupName, deploymentName, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -405,9 +392,9 @@ function _list(resourceGroupName, deploymentName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _listNext(nextPageLink, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -438,13 +425,13 @@ function _listNext(nextPageLink, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -460,8 +447,8 @@ function _listNext(nextPageLink, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -477,7 +464,7 @@ function _listNext(nextPageLink, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -497,8 +484,8 @@ function _listNext(nextPageLink, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } diff --git a/tools/resourceManagement/lib/resource/operations/deployments.js b/tools/resourceManagement/lib/resource/operations/deployments.js index d3547639ea..01bb1ccdd9 100644 --- a/tools/resourceManagement/lib/resource/operations/deployments.js +++ b/tools/resourceManagement/lib/resource/operations/deployments.js @@ -10,10 +10,8 @@ 'use strict'; -const msRest = require('@azure/ms-rest-js'); +const { stripRequest, stripResponse, WebResource } = require("@azure/core-http"); const uuid = require('uuid'); -const WebResource = msRest.WebResource; - /** * @summary Deletes a deployment from the deployment history. @@ -52,9 +50,9 @@ const WebResource = msRest.WebResource; * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _deleteMethod(resourceGroupName, deploymentName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -115,9 +113,9 @@ function _deleteMethod(resourceGroupName, deploymentName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _checkExistence(resourceGroupName, deploymentName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -130,16 +128,13 @@ function _checkExistence(resourceGroupName, deploymentName, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -147,16 +142,13 @@ function _checkExistence(resourceGroupName, deploymentName, options, callback) { throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); } if (deploymentName !== null && deploymentName !== undefined) { - if (deploymentName.length > 64) - { + if (deploymentName.length > 64) { throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64'); } - if (deploymentName.length < 1) - { + if (deploymentName.length < 1) { throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1'); } - if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) - { + if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -193,13 +185,13 @@ function _checkExistence(resourceGroupName, deploymentName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -215,8 +207,8 @@ function _checkExistence(resourceGroupName, deploymentName, options, callback) { if (statusCode !== 204 && statusCode !== 404) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -232,7 +224,7 @@ function _checkExistence(resourceGroupName, deploymentName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -336,9 +328,9 @@ function _checkExistence(resourceGroupName, deploymentName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _createOrUpdate(resourceGroupName, deploymentName, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -377,8 +369,8 @@ function _createOrUpdate(resourceGroupName, deploymentName, parameters, options, } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } @@ -414,9 +406,9 @@ function _createOrUpdate(resourceGroupName, deploymentName, parameters, options, * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _get(resourceGroupName, deploymentName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -429,16 +421,13 @@ function _get(resourceGroupName, deploymentName, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -446,16 +435,13 @@ function _get(resourceGroupName, deploymentName, options, callback) { throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); } if (deploymentName !== null && deploymentName !== undefined) { - if (deploymentName.length > 64) - { + if (deploymentName.length > 64) { throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64'); } - if (deploymentName.length < 1) - { + if (deploymentName.length < 1) { throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1'); } - if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) - { + if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -492,13 +478,13 @@ function _get(resourceGroupName, deploymentName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -514,8 +500,8 @@ function _get(resourceGroupName, deploymentName, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -531,7 +517,7 @@ function _get(resourceGroupName, deploymentName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -551,8 +537,8 @@ function _get(resourceGroupName, deploymentName, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -592,9 +578,9 @@ function _get(resourceGroupName, deploymentName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _cancel(resourceGroupName, deploymentName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -607,16 +593,13 @@ function _cancel(resourceGroupName, deploymentName, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -624,16 +607,13 @@ function _cancel(resourceGroupName, deploymentName, options, callback) { throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); } if (deploymentName !== null && deploymentName !== undefined) { - if (deploymentName.length > 64) - { + if (deploymentName.length > 64) { throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64'); } - if (deploymentName.length < 1) - { + if (deploymentName.length < 1) { throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1'); } - if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) - { + if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -670,13 +650,13 @@ function _cancel(resourceGroupName, deploymentName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -692,8 +672,8 @@ function _cancel(resourceGroupName, deploymentName, options, callback) { if (statusCode !== 204) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -709,7 +689,7 @@ function _cancel(resourceGroupName, deploymentName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -809,9 +789,9 @@ function _cancel(resourceGroupName, deploymentName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _validate(resourceGroupName, deploymentName, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -824,16 +804,13 @@ function _validate(resourceGroupName, deploymentName, parameters, options, callb 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -841,16 +818,13 @@ function _validate(resourceGroupName, deploymentName, parameters, options, callb throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); } if (deploymentName !== null && deploymentName !== undefined) { - if (deploymentName.length > 64) - { + if (deploymentName.length > 64) { throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64'); } - if (deploymentName.length < 1) - { + if (deploymentName.length < 1) { throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1'); } - if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) - { + if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -890,13 +864,13 @@ function _validate(resourceGroupName, deploymentName, parameters, options, callb // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -913,7 +887,7 @@ function _validate(resourceGroupName, deploymentName, parameters, options, callb } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); + `payload - ${JSON.stringify(parameters, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -926,8 +900,8 @@ function _validate(resourceGroupName, deploymentName, parameters, options, callb if (statusCode !== 200 && statusCode !== 400) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -943,7 +917,7 @@ function _validate(resourceGroupName, deploymentName, parameters, options, callb } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -963,8 +937,8 @@ function _validate(resourceGroupName, deploymentName, parameters, options, callb } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -980,8 +954,8 @@ function _validate(resourceGroupName, deploymentName, parameters, options, callb } } catch (error) { let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError1.request = msRest.stripRequest(httpRequest); - deserializationError1.response = msRest.stripResponse(response); + deserializationError1.request = stripRequest(httpRequest); + deserializationError1.response = stripResponse(response); return callback(deserializationError1); } } @@ -1019,9 +993,9 @@ function _validate(resourceGroupName, deploymentName, parameters, options, callb * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _exportTemplate(resourceGroupName, deploymentName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1034,16 +1008,13 @@ function _exportTemplate(resourceGroupName, deploymentName, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1051,16 +1022,13 @@ function _exportTemplate(resourceGroupName, deploymentName, options, callback) { throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); } if (deploymentName !== null && deploymentName !== undefined) { - if (deploymentName.length > 64) - { + if (deploymentName.length > 64) { throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64'); } - if (deploymentName.length < 1) - { + if (deploymentName.length < 1) { throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1'); } - if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) - { + if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1097,13 +1065,13 @@ function _exportTemplate(resourceGroupName, deploymentName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1119,8 +1087,8 @@ function _exportTemplate(resourceGroupName, deploymentName, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1136,7 +1104,7 @@ function _exportTemplate(resourceGroupName, deploymentName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1156,8 +1124,8 @@ function _exportTemplate(resourceGroupName, deploymentName, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -1197,9 +1165,9 @@ function _exportTemplate(resourceGroupName, deploymentName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _listByResourceGroup(resourceGroupName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1214,16 +1182,13 @@ function _listByResourceGroup(resourceGroupName, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1271,13 +1236,13 @@ function _listByResourceGroup(resourceGroupName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1293,8 +1258,8 @@ function _listByResourceGroup(resourceGroupName, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1310,7 +1275,7 @@ function _listByResourceGroup(resourceGroupName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1330,8 +1295,8 @@ function _listByResourceGroup(resourceGroupName, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -1377,9 +1342,9 @@ function _listByResourceGroup(resourceGroupName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _beginDeleteMethod(resourceGroupName, deploymentName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1392,16 +1357,13 @@ function _beginDeleteMethod(resourceGroupName, deploymentName, options, callback 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1409,16 +1371,13 @@ function _beginDeleteMethod(resourceGroupName, deploymentName, options, callback throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); } if (deploymentName !== null && deploymentName !== undefined) { - if (deploymentName.length > 64) - { + if (deploymentName.length > 64) { throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64'); } - if (deploymentName.length < 1) - { + if (deploymentName.length < 1) { throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1'); } - if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) - { + if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1455,13 +1414,13 @@ function _beginDeleteMethod(resourceGroupName, deploymentName, options, callback // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1477,8 +1436,8 @@ function _beginDeleteMethod(resourceGroupName, deploymentName, options, callback if (statusCode !== 202 && statusCode !== 204) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1494,7 +1453,7 @@ function _beginDeleteMethod(resourceGroupName, deploymentName, options, callback } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1596,9 +1555,9 @@ function _beginDeleteMethod(resourceGroupName, deploymentName, options, callback * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _beginCreateOrUpdate(resourceGroupName, deploymentName, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1611,16 +1570,13 @@ function _beginCreateOrUpdate(resourceGroupName, deploymentName, parameters, opt 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1628,16 +1584,13 @@ function _beginCreateOrUpdate(resourceGroupName, deploymentName, parameters, opt throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); } if (deploymentName !== null && deploymentName !== undefined) { - if (deploymentName.length > 64) - { + if (deploymentName.length > 64) { throw new Error('"deploymentName" should satisfy the constraint - "MaxLength": 64'); } - if (deploymentName.length < 1) - { + if (deploymentName.length < 1) { throw new Error('"deploymentName" should satisfy the constraint - "MinLength": 1'); } - if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) - { + if (deploymentName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"deploymentName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1677,13 +1630,13 @@ function _beginCreateOrUpdate(resourceGroupName, deploymentName, parameters, opt // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1700,7 +1653,7 @@ function _beginCreateOrUpdate(resourceGroupName, deploymentName, parameters, opt } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); + `payload - ${JSON.stringify(parameters, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -1713,8 +1666,8 @@ function _beginCreateOrUpdate(resourceGroupName, deploymentName, parameters, opt if (statusCode !== 200 && statusCode !== 201) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1730,7 +1683,7 @@ function _beginCreateOrUpdate(resourceGroupName, deploymentName, parameters, opt } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1750,8 +1703,8 @@ function _beginCreateOrUpdate(resourceGroupName, deploymentName, parameters, opt } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -1767,8 +1720,8 @@ function _beginCreateOrUpdate(resourceGroupName, deploymentName, parameters, opt } } catch (error) { let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError1.request = msRest.stripRequest(httpRequest); - deserializationError1.response = msRest.stripResponse(response); + deserializationError1.request = stripRequest(httpRequest); + deserializationError1.response = stripResponse(response); return callback(deserializationError1); } } @@ -1802,9 +1755,9 @@ function _beginCreateOrUpdate(resourceGroupName, deploymentName, parameters, opt * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _listByResourceGroupNext(nextPageLink, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1835,13 +1788,13 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1857,8 +1810,8 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1874,7 +1827,7 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1894,8 +1847,8 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } diff --git a/tools/resourceManagement/lib/resource/operations/providers.js b/tools/resourceManagement/lib/resource/operations/providers.js index 253b915471..0876c3944c 100644 --- a/tools/resourceManagement/lib/resource/operations/providers.js +++ b/tools/resourceManagement/lib/resource/operations/providers.js @@ -10,9 +10,8 @@ 'use strict'; -const msRest = require('@azure/ms-rest-js'); +const { stripRequest, stripResponse, WebResource } = require("@azure/core-http"); const uuid = require('uuid'); -const WebResource = msRest.WebResource; /** * Unregisters a subscription from a resource provider. @@ -39,9 +38,9 @@ const WebResource = msRest.WebResource; * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _unregister(resourceProviderNamespace, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -85,13 +84,13 @@ function _unregister(resourceProviderNamespace, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -107,8 +106,8 @@ function _unregister(resourceProviderNamespace, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -124,7 +123,7 @@ function _unregister(resourceProviderNamespace, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -144,8 +143,8 @@ function _unregister(resourceProviderNamespace, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -179,9 +178,9 @@ function _unregister(resourceProviderNamespace, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _register(resourceProviderNamespace, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -225,13 +224,13 @@ function _register(resourceProviderNamespace, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -247,8 +246,8 @@ function _register(resourceProviderNamespace, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -264,7 +263,7 @@ function _register(resourceProviderNamespace, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -284,8 +283,8 @@ function _register(resourceProviderNamespace, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -324,9 +323,9 @@ function _register(resourceProviderNamespace, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _list(options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -380,13 +379,13 @@ function _list(options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -402,8 +401,8 @@ function _list(options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -419,7 +418,7 @@ function _list(options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -439,8 +438,8 @@ function _list(options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -477,9 +476,9 @@ function _list(options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _get(resourceProviderNamespace, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -530,13 +529,13 @@ function _get(resourceProviderNamespace, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -552,8 +551,8 @@ function _get(resourceProviderNamespace, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -569,7 +568,7 @@ function _get(resourceProviderNamespace, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -589,8 +588,8 @@ function _get(resourceProviderNamespace, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -624,9 +623,9 @@ function _get(resourceProviderNamespace, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _listNext(nextPageLink, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -657,13 +656,13 @@ function _listNext(nextPageLink, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -679,8 +678,8 @@ function _listNext(nextPageLink, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -696,7 +695,7 @@ function _listNext(nextPageLink, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -716,8 +715,8 @@ function _listNext(nextPageLink, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } diff --git a/tools/resourceManagement/lib/resource/operations/resourceGroups.js b/tools/resourceManagement/lib/resource/operations/resourceGroups.js index 2923c7e597..49b6629c5b 100644 --- a/tools/resourceManagement/lib/resource/operations/resourceGroups.js +++ b/tools/resourceManagement/lib/resource/operations/resourceGroups.js @@ -10,9 +10,8 @@ 'use strict'; -const msRest = require('@azure/ms-rest-js'); +const { stripRequest, stripResponse, WebResource } = require("@azure/core-http"); const uuid = require('uuid'); -const WebResource = msRest.WebResource; /** * Checks whether a resource group exists. @@ -38,9 +37,9 @@ const WebResource = msRest.WebResource; * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _checkExistence(resourceGroupName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -53,16 +52,13 @@ function _checkExistence(resourceGroupName, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -98,13 +94,13 @@ function _checkExistence(resourceGroupName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -120,8 +116,8 @@ function _checkExistence(resourceGroupName, options, callback) { if (statusCode !== 204 && statusCode !== 404) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -137,7 +133,7 @@ function _checkExistence(resourceGroupName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -192,9 +188,9 @@ function _checkExistence(resourceGroupName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _createOrUpdate(resourceGroupName, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -207,16 +203,13 @@ function _createOrUpdate(resourceGroupName, parameters, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -255,13 +248,13 @@ function _createOrUpdate(resourceGroupName, parameters, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -278,7 +271,7 @@ function _createOrUpdate(resourceGroupName, parameters, options, callback) { } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); + `payload - ${JSON.stringify(parameters, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -291,8 +284,8 @@ function _createOrUpdate(resourceGroupName, parameters, options, callback) { if (statusCode !== 201 && statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -308,7 +301,7 @@ function _createOrUpdate(resourceGroupName, parameters, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -328,8 +321,8 @@ function _createOrUpdate(resourceGroupName, parameters, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -345,8 +338,8 @@ function _createOrUpdate(resourceGroupName, parameters, options, callback) { } } catch (error) { let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError1.request = msRest.stripRequest(httpRequest); - deserializationError1.response = msRest.stripResponse(response); + deserializationError1.request = stripRequest(httpRequest); + deserializationError1.response = stripResponse(response); return callback(deserializationError1); } } @@ -384,9 +377,9 @@ function _createOrUpdate(resourceGroupName, parameters, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _deleteMethod(resourceGroupName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -446,9 +439,9 @@ function _deleteMethod(resourceGroupName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _get(resourceGroupName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -461,16 +454,13 @@ function _get(resourceGroupName, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -506,13 +496,13 @@ function _get(resourceGroupName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -528,8 +518,8 @@ function _get(resourceGroupName, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -545,7 +535,7 @@ function _get(resourceGroupName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -565,8 +555,8 @@ function _get(resourceGroupName, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -615,9 +605,9 @@ function _get(resourceGroupName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _update(resourceGroupName, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -630,16 +620,13 @@ function _update(resourceGroupName, parameters, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -678,13 +665,13 @@ function _update(resourceGroupName, parameters, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -701,7 +688,7 @@ function _update(resourceGroupName, parameters, options, callback) { } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); + `payload - ${JSON.stringify(parameters, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -714,8 +701,8 @@ function _update(resourceGroupName, parameters, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -731,7 +718,7 @@ function _update(resourceGroupName, parameters, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -751,8 +738,8 @@ function _update(resourceGroupName, parameters, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -797,9 +784,9 @@ function _update(resourceGroupName, parameters, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _exportTemplate(resourceGroupName, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -812,16 +799,13 @@ function _exportTemplate(resourceGroupName, parameters, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -860,13 +844,13 @@ function _exportTemplate(resourceGroupName, parameters, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -883,7 +867,7 @@ function _exportTemplate(resourceGroupName, parameters, options, callback) { } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); + `payload - ${JSON.stringify(parameters, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -896,8 +880,8 @@ function _exportTemplate(resourceGroupName, parameters, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -913,7 +897,7 @@ function _exportTemplate(resourceGroupName, parameters, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -933,8 +917,8 @@ function _exportTemplate(resourceGroupName, parameters, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -971,9 +955,9 @@ function _exportTemplate(resourceGroupName, parameters, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _list(options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1027,13 +1011,13 @@ function _list(options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1049,8 +1033,8 @@ function _list(options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1066,7 +1050,7 @@ function _list(options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1086,8 +1070,8 @@ function _list(options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -1124,9 +1108,9 @@ function _list(options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _beginDeleteMethod(resourceGroupName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1139,16 +1123,13 @@ function _beginDeleteMethod(resourceGroupName, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1184,13 +1165,13 @@ function _beginDeleteMethod(resourceGroupName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1206,8 +1187,8 @@ function _beginDeleteMethod(resourceGroupName, options, callback) { if (statusCode !== 202 && statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1223,7 +1204,7 @@ function _beginDeleteMethod(resourceGroupName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1262,9 +1243,9 @@ function _beginDeleteMethod(resourceGroupName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _listNext(nextPageLink, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1295,13 +1276,13 @@ function _listNext(nextPageLink, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1317,8 +1298,8 @@ function _listNext(nextPageLink, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1334,7 +1315,7 @@ function _listNext(nextPageLink, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1354,8 +1335,8 @@ function _listNext(nextPageLink, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } diff --git a/tools/resourceManagement/lib/resource/operations/resources.js b/tools/resourceManagement/lib/resource/operations/resources.js index 7f3c1b7f07..3efa42587d 100644 --- a/tools/resourceManagement/lib/resource/operations/resources.js +++ b/tools/resourceManagement/lib/resource/operations/resources.js @@ -11,9 +11,7 @@ 'use strict'; const uuid = require('uuid'); -const msRest = require('@azure/ms-rest-js'); - -const WebResource = msRest.WebResource; +const { stripRequest, stripResponse, WebResource } = require("@azure/core-http"); /** * Get all the resources for a resource group. @@ -47,9 +45,9 @@ const WebResource = msRest.WebResource; * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _listByResourceGroup(resourceGroupName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -65,16 +63,13 @@ function _listByResourceGroup(resourceGroupName, options, callback) { 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -128,13 +123,13 @@ function _listByResourceGroup(resourceGroupName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -150,8 +145,8 @@ function _listByResourceGroup(resourceGroupName, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -167,7 +162,7 @@ function _listByResourceGroup(resourceGroupName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -187,8 +182,8 @@ function _listByResourceGroup(resourceGroupName, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -234,9 +229,9 @@ function _listByResourceGroup(resourceGroupName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _moveResources(sourceResourceGroupName, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -311,9 +306,9 @@ function _moveResources(sourceResourceGroupName, parameters, options, callback) * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _validateMoveResources(sourceResourceGroupName, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -377,9 +372,9 @@ function _validateMoveResources(sourceResourceGroupName, parameters, options, ca * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _list(options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -440,13 +435,13 @@ function _list(options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -462,8 +457,8 @@ function _list(options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -479,7 +474,7 @@ function _list(options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -499,8 +494,8 @@ function _list(options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -545,9 +540,9 @@ function _list(options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _checkExistence(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -560,16 +555,13 @@ function _checkExistence(resourceGroupName, resourceProviderNamespace, parentRes 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -621,13 +613,13 @@ function _checkExistence(resourceGroupName, resourceProviderNamespace, parentRes // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -643,8 +635,8 @@ function _checkExistence(resourceGroupName, resourceProviderNamespace, parentRes if (statusCode !== 204 && statusCode !== 404) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -660,7 +652,7 @@ function _checkExistence(resourceGroupName, resourceProviderNamespace, parentRes } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -710,9 +702,9 @@ function _checkExistence(resourceGroupName, resourceProviderNamespace, parentRes * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _deleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -826,9 +818,9 @@ function _deleteMethod(resourceGroupName, resourceProviderNamespace, parentResou * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _createOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -867,8 +859,8 @@ function _createOrUpdate(resourceGroupName, resourceProviderNamespace, parentRes } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } @@ -913,9 +905,9 @@ function _createOrUpdate(resourceGroupName, resourceProviderNamespace, parentRes * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _get(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -928,16 +920,13 @@ function _get(resourceGroupName, resourceProviderNamespace, parentResourcePath, 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -989,13 +978,13 @@ function _get(resourceGroupName, resourceProviderNamespace, parentResourcePath, // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1011,8 +1000,8 @@ function _get(resourceGroupName, resourceProviderNamespace, parentResourcePath, if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1028,7 +1017,7 @@ function _get(resourceGroupName, resourceProviderNamespace, parentResourcePath, } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1048,8 +1037,8 @@ function _get(resourceGroupName, resourceProviderNamespace, parentResourcePath, } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -1085,9 +1074,9 @@ function _get(resourceGroupName, resourceProviderNamespace, parentResourcePath, * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _checkExistenceById(resourceId, apiVersion, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1127,13 +1116,13 @@ function _checkExistenceById(resourceId, apiVersion, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1149,8 +1138,8 @@ function _checkExistenceById(resourceId, apiVersion, options, callback) { if (statusCode !== 204 && statusCode !== 404) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1166,7 +1155,7 @@ function _checkExistenceById(resourceId, apiVersion, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1208,9 +1197,9 @@ function _checkExistenceById(resourceId, apiVersion, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _deleteById(resourceId, apiVersion, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1316,9 +1305,9 @@ function _deleteById(resourceId, apiVersion, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _createOrUpdateById(resourceId, apiVersion, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1357,8 +1346,8 @@ function _createOrUpdateById(resourceId, apiVersion, parameters, options, callba } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } @@ -1395,9 +1384,9 @@ function _createOrUpdateById(resourceId, apiVersion, parameters, options, callba * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _getById(resourceId, apiVersion, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1437,13 +1426,13 @@ function _getById(resourceId, apiVersion, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1459,8 +1448,8 @@ function _getById(resourceId, apiVersion, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1476,7 +1465,7 @@ function _getById(resourceId, apiVersion, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1496,8 +1485,8 @@ function _getById(resourceId, apiVersion, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -1542,9 +1531,9 @@ function _getById(resourceId, apiVersion, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _beginMoveResources(sourceResourceGroupName, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1557,16 +1546,13 @@ function _beginMoveResources(sourceResourceGroupName, parameters, options, callb throw new Error('sourceResourceGroupName cannot be null or undefined and it must be of type string.'); } if (sourceResourceGroupName !== null && sourceResourceGroupName !== undefined) { - if (sourceResourceGroupName.length > 90) - { + if (sourceResourceGroupName.length > 90) { throw new Error('"sourceResourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (sourceResourceGroupName.length < 1) - { + if (sourceResourceGroupName.length < 1) { throw new Error('"sourceResourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (sourceResourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (sourceResourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"sourceResourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1605,13 +1591,13 @@ function _beginMoveResources(sourceResourceGroupName, parameters, options, callb // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1628,7 +1614,7 @@ function _beginMoveResources(sourceResourceGroupName, parameters, options, callb } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); + `payload - ${JSON.stringify(parameters, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -1641,8 +1627,8 @@ function _beginMoveResources(sourceResourceGroupName, parameters, options, callb if (statusCode !== 202 && statusCode !== 204) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1658,7 +1644,7 @@ function _beginMoveResources(sourceResourceGroupName, parameters, options, callb } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1710,9 +1696,9 @@ function _beginMoveResources(sourceResourceGroupName, parameters, options, callb * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _beginValidateMoveResources(sourceResourceGroupName, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1725,16 +1711,13 @@ function _beginValidateMoveResources(sourceResourceGroupName, parameters, option throw new Error('sourceResourceGroupName cannot be null or undefined and it must be of type string.'); } if (sourceResourceGroupName !== null && sourceResourceGroupName !== undefined) { - if (sourceResourceGroupName.length > 90) - { + if (sourceResourceGroupName.length > 90) { throw new Error('"sourceResourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (sourceResourceGroupName.length < 1) - { + if (sourceResourceGroupName.length < 1) { throw new Error('"sourceResourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (sourceResourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (sourceResourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"sourceResourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1773,13 +1756,13 @@ function _beginValidateMoveResources(sourceResourceGroupName, parameters, option // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1796,7 +1779,7 @@ function _beginValidateMoveResources(sourceResourceGroupName, parameters, option } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); + `payload - ${JSON.stringify(parameters, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -1809,8 +1792,8 @@ function _beginValidateMoveResources(sourceResourceGroupName, parameters, option if (statusCode !== 202 && statusCode !== 204 && statusCode !== 409) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1826,7 +1809,7 @@ function _beginValidateMoveResources(sourceResourceGroupName, parameters, option } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -1874,9 +1857,9 @@ function _beginValidateMoveResources(sourceResourceGroupName, parameters, option * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -1889,16 +1872,13 @@ function _beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parent 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -1950,13 +1930,13 @@ function _beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parent // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -1972,8 +1952,8 @@ function _beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parent if (statusCode !== 200 && statusCode !== 204 && statusCode !== 202) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -1989,7 +1969,7 @@ function _beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parent } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -2080,9 +2060,9 @@ function _beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parent * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -2095,16 +2075,13 @@ function _beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, pare 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) - { + if (resourceGroupName.length > 90) { throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90'); } - if (resourceGroupName.length < 1) - { + if (resourceGroupName.length < 1) { throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1'); } - if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) - { + if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null) { throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/'); } } @@ -2159,13 +2136,13 @@ function _beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, pare // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -2182,7 +2159,7 @@ function _beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, pare } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); + `payload - ${JSON.stringify(parameters, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -2195,8 +2172,8 @@ function _beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, pare if (statusCode !== 201 && statusCode !== 200 && statusCode !== 202) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -2212,7 +2189,7 @@ function _beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, pare } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -2232,8 +2209,8 @@ function _beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, pare } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -2249,8 +2226,8 @@ function _beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, pare } } catch (error) { let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError1.request = msRest.stripRequest(httpRequest); - deserializationError1.response = msRest.stripResponse(response); + deserializationError1.request = stripRequest(httpRequest); + deserializationError1.response = stripResponse(response); return callback(deserializationError1); } } @@ -2286,9 +2263,9 @@ function _beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, pare * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _beginDeleteById(resourceId, apiVersion, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -2328,13 +2305,13 @@ function _beginDeleteById(resourceId, apiVersion, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -2350,8 +2327,8 @@ function _beginDeleteById(resourceId, apiVersion, options, callback) { if (statusCode !== 200 && statusCode !== 204 && statusCode !== 202) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -2367,7 +2344,7 @@ function _beginDeleteById(resourceId, apiVersion, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -2450,9 +2427,9 @@ function _beginDeleteById(resourceId, apiVersion, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -2495,13 +2472,13 @@ function _beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, c // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -2518,7 +2495,7 @@ function _beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, c } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + - `payload - ${JSON.stringify(parameters, null, 2)}.`); + `payload - ${JSON.stringify(parameters, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; @@ -2531,8 +2508,8 @@ function _beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, c if (statusCode !== 201 && statusCode !== 200 && statusCode !== 202) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -2548,7 +2525,7 @@ function _beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, c } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -2568,8 +2545,8 @@ function _beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, c } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -2585,8 +2562,8 @@ function _beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, c } } catch (error) { let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError1.request = msRest.stripRequest(httpRequest); - deserializationError1.response = msRest.stripResponse(response); + deserializationError1.request = stripRequest(httpRequest); + deserializationError1.response = stripResponse(response); return callback(deserializationError1); } } @@ -2620,9 +2597,9 @@ function _beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, c * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _listByResourceGroupNext(nextPageLink, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -2653,13 +2630,13 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -2675,8 +2652,8 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -2692,7 +2669,7 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -2712,8 +2689,8 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -2747,9 +2724,9 @@ function _listByResourceGroupNext(nextPageLink, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _listNext(nextPageLink, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -2780,13 +2757,13 @@ function _listNext(nextPageLink, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -2802,8 +2779,8 @@ function _listNext(nextPageLink, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -2819,7 +2796,7 @@ function _listNext(nextPageLink, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -2839,8 +2816,8 @@ function _listNext(nextPageLink, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } diff --git a/tools/resourceManagement/lib/resource/operations/tags.js b/tools/resourceManagement/lib/resource/operations/tags.js index e1e0c57402..bbd72bade2 100644 --- a/tools/resourceManagement/lib/resource/operations/tags.js +++ b/tools/resourceManagement/lib/resource/operations/tags.js @@ -10,9 +10,8 @@ 'use strict'; -const msRest = require('@azure/ms-rest-js'); +const { stripRequest, stripResponse, WebResource } = require("@azure/core-http"); const uuid = require('uuid'); -const WebResource = msRest.WebResource; /** * Deletes a tag value. @@ -39,9 +38,9 @@ const WebResource = msRest.WebResource; * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _deleteValue(tagName, tagValue, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -89,13 +88,13 @@ function _deleteValue(tagName, tagValue, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -111,8 +110,8 @@ function _deleteValue(tagName, tagValue, options, callback) { if (statusCode !== 200 && statusCode !== 204) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -128,7 +127,7 @@ function _deleteValue(tagName, tagValue, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -167,9 +166,9 @@ function _deleteValue(tagName, tagValue, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _createOrUpdateValue(tagName, tagValue, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -217,13 +216,13 @@ function _createOrUpdateValue(tagName, tagValue, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -239,8 +238,8 @@ function _createOrUpdateValue(tagName, tagValue, options, callback) { if (statusCode !== 200 && statusCode !== 201) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -256,7 +255,7 @@ function _createOrUpdateValue(tagName, tagValue, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -276,8 +275,8 @@ function _createOrUpdateValue(tagName, tagValue, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -293,8 +292,8 @@ function _createOrUpdateValue(tagName, tagValue, options, callback) { } } catch (error) { let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError1.request = msRest.stripRequest(httpRequest); - deserializationError1.response = msRest.stripResponse(response); + deserializationError1.request = stripRequest(httpRequest); + deserializationError1.response = stripResponse(response); return callback(deserializationError1); } } @@ -331,9 +330,9 @@ function _createOrUpdateValue(tagName, tagValue, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _createOrUpdate(tagName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -377,13 +376,13 @@ function _createOrUpdate(tagName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -399,8 +398,8 @@ function _createOrUpdate(tagName, options, callback) { if (statusCode !== 200 && statusCode !== 201) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -416,7 +415,7 @@ function _createOrUpdate(tagName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -436,8 +435,8 @@ function _createOrUpdate(tagName, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -453,8 +452,8 @@ function _createOrUpdate(tagName, options, callback) { } } catch (error) { let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError1.request = msRest.stripRequest(httpRequest); - deserializationError1.response = msRest.stripResponse(response); + deserializationError1.request = stripRequest(httpRequest); + deserializationError1.response = stripResponse(response); return callback(deserializationError1); } } @@ -488,9 +487,9 @@ function _createOrUpdate(tagName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _deleteMethod(tagName, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -534,13 +533,13 @@ function _deleteMethod(tagName, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -556,8 +555,8 @@ function _deleteMethod(tagName, options, callback) { if (statusCode !== 200 && statusCode !== 204) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -573,7 +572,7 @@ function _deleteMethod(tagName, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -609,9 +608,9 @@ function _deleteMethod(tagName, options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _list(options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -651,13 +650,13 @@ function _list(options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -673,8 +672,8 @@ function _list(options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -690,7 +689,7 @@ function _list(options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -710,8 +709,8 @@ function _list(options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } @@ -746,9 +745,9 @@ function _list(options, callback) { * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _listNext(nextPageLink, options, callback) { - /* jshint validthis: true */ + /* jshint validthis: true */ let client = this.client; - if(!callback && typeof options === 'function') { + if (!callback && typeof options === 'function') { callback = options; options = null; } @@ -779,13 +778,13 @@ function _listNext(nextPageLink, options, callback) { // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { - httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); + httpRequest.headers['x-ms-client-request-id'] = uuid.v4(); } 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) { + for (let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } @@ -801,8 +800,8 @@ function _listNext(nextPageLink, options, callback) { if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; - error.request = msRest.stripRequest(httpRequest); - error.response = msRest.stripResponse(response); + error.request = stripRequest(httpRequest); + error.response = stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { @@ -818,7 +817,7 @@ function _listNext(nextPageLink, options, callback) { } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + - `- "${responseBody}" for the default response.`; + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); @@ -838,8 +837,8 @@ function _listNext(nextPageLink, options, callback) { } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); - deserializationError.request = msRest.stripRequest(httpRequest); - deserializationError.response = msRest.stripResponse(response); + deserializationError.request = stripRequest(httpRequest); + deserializationError.response = stripResponse(response); return callback(deserializationError); } } diff --git a/tools/resourceManagement/lib/resource/resourceManagementClient.js b/tools/resourceManagement/lib/resource/resourceManagementClient.js index fe9af60ba1..187e4427ed 100644 --- a/tools/resourceManagement/lib/resource/resourceManagementClient.js +++ b/tools/resourceManagement/lib/resource/resourceManagementClient.js @@ -14,10 +14,9 @@ 'use strict'; -const msRest = require('@azure/ms-rest-js'); +const { ServiceClient, Serializer } = require("@azure/core-http"); const fs = require('fs'); const path = require('path'); -const ServiceClient = msRest.ServiceClient; const models = require('./models'); const operations = require('./operations'); @@ -88,7 +87,7 @@ class ResourceManagementClient extends ServiceClient { addSerializationMixin(destObject) { ['serialize', 'serializeObject', 'deserialize'].forEach((property) => { - destObject[property] = msRest.Serializer[property]; + destObject[property] = Serializer[property]; }); }; diff --git a/yarn.lock b/yarn.lock index 916ca71cc3..515ef834f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30,12 +30,13 @@ resolved "https://registry.yarnpkg.com/@azure/core-asynciterator-polyfill/-/core-asynciterator-polyfill-1.0.0.tgz#dcccebb88406e5c76e0e1d52e8cc4c43a68b3ee7" integrity sha512-kmv8CGrPfN9SwMwrkiBK9VTQYxdFQEGe0BmQk+M8io56P9KNzpAxcWE/1fxJj7uouwN4kXF0BHW8DNlgx+wtCg== -"@azure/core-auth@^1.1.4", "@azure/core-auth@^1.3.0": - version "1.3.2" - resolved "https://registry.yarnpkg.com/@azure/core-auth/-/core-auth-1.3.2.tgz#6a2c248576c26df365f6c7881ca04b7f6d08e3d0" - integrity sha512-7CU6DmCHIZp5ZPiZ9r3J17lTKMmYsm/zGvNkjArQwPkrLlZ1TZ+EUYfGgh2X31OLMVAQCTJZW4cXHJi02EbJnA== +"@azure/core-auth@^1.1.4": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@azure/core-auth/-/core-auth-1.5.0.tgz#a41848c5c31cb3b7c84c409885267d55a2c92e44" + integrity sha512-udzoBuYG1VBoHVohDTrvKjyzel34zt77Bhp7dQntVGGD0ehVq48owENbBG8fIgkHRNUBQH5k1r0hpoMu5L8+kw== dependencies: "@azure/abort-controller" "^1.0.0" + "@azure/core-util" "^1.1.0" tslib "^2.2.0" "@azure/core-auth@^1.2.0", "@azure/core-auth@^1.4.0": @@ -46,6 +47,14 @@ "@azure/abort-controller" "^1.0.0" tslib "^2.2.0" +"@azure/core-auth@^1.3.0": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@azure/core-auth/-/core-auth-1.3.2.tgz#6a2c248576c26df365f6c7881ca04b7f6d08e3d0" + integrity sha512-7CU6DmCHIZp5ZPiZ9r3J17lTKMmYsm/zGvNkjArQwPkrLlZ1TZ+EUYfGgh2X31OLMVAQCTJZW4cXHJi02EbJnA== + dependencies: + "@azure/abort-controller" "^1.0.0" + tslib "^2.2.0" + "@azure/core-client@^1.4.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@azure/core-client/-/core-client-1.5.0.tgz#7aabb87d20e08db3683a117191c844bc19adb74e" @@ -143,22 +152,7 @@ "@opentelemetry/api" "^0.10.2" tslib "^2.0.0" -"@azure/core-util@^1.0.0-beta.1": - version "1.0.0-beta.1" - resolved "https://registry.yarnpkg.com/@azure/core-util/-/core-util-1.0.0-beta.1.tgz#2efd2c74b4b0a38180369f50fe274a3c4cd36e98" - integrity sha512-pS6cup979/qyuyNP9chIybK2qVkJ3MarbY/bx3JcGKE6An6dRweLnsfJfU2ydqUI/B51Rjnn59ajHIhCUTwWZw== - dependencies: - tslib "^2.0.0" - -"@azure/core-util@^1.1.1": - version "1.3.2" - resolved "https://registry.yarnpkg.com/@azure/core-util/-/core-util-1.3.2.tgz#3f8cfda1e87fac0ce84f8c1a42fcd6d2a986632d" - integrity sha512-2bECOUh88RvL1pMZTcc6OzfobBeWDBf5oBbhjIhT1MV9otMVWCzpOJkkiKtrnO88y5GGBelgY8At73KGAdbkeQ== - dependencies: - "@azure/abort-controller" "^1.0.0" - tslib "^2.2.0" - -"@azure/core-util@^1.2.0": +"@azure/core-util@^1.0.0-beta.1", "@azure/core-util@^1.1.0", "@azure/core-util@^1.1.1", "@azure/core-util@^1.2.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@azure/core-util/-/core-util-1.5.0.tgz#ffe49c3e867044da67daeb8122143fa065e1eb0e" integrity sha512-GZBpVFDtQ/15hW1OgBcRdT4Bl7AEpcEZqLfbAvOtm1CQUncKWiYapFHVD588hmlV27NbOOtSm3cnLF3lvoHi4g== From 20ac13abba09e634d0c855824f0afca1a7995f47 Mon Sep 17 00:00:00 2001 From: Jhonatan Sandoval Velasco <122501764+JhontSouth@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:08:52 -0500 Subject: [PATCH 3/4] fix: [#4470] Migrate off @azure/ms-rest-js (#4578) * update yarn lock without ms-rest-js * remove ms-rest-js in botbuilder * remove ms-rest-js in botframework-connector * update botbuilder package.json * update package json * update with lint format * update packages * update botbuilder api signature * update yarn.lock --- libraries/botbuilder/etc/botbuilder.api.md | 6 +- libraries/botbuilder/package.json | 2 +- .../botbuilder/src/botFrameworkAdapter.ts | 2 +- libraries/botbuilder/src/cloudAdapter.ts | 2 +- .../src/streaming/streamingHttpClient.ts | 2 +- .../tests/botFrameworkAdapter.test.js | 2 +- libraries/botbuilder/tests/teamsInfo.test.js | 16 +- libraries/botframework-connector/package.json | 2 +- .../src/auth/appCredentials.ts | 9 +- .../src/auth/botFrameworkClientImpl.ts | 2 +- ...tificateServiceClientCredentialsFactory.ts | 2 +- .../src/auth/connectorFactoryImpl.ts | 2 +- .../botframework-connector/src/auth/index.ts | 1 + ...IdentityServiceClientCredentialsFactory.ts | 2 +- .../msalServiceClientCredentialsFactory.ts | 2 +- .../passwordServiceClientCredentialFactory.ts | 2 +- .../auth/serviceClientCredentialsFactory.ts | 2 +- .../src/auth/tokenCredentials.ts | 42 +++++ .../src/auth/userTokenClientImpl.ts | 2 +- .../src/connectorApi/connectorClient.ts | 4 +- .../connectorApi/connectorClientContext.ts | 10 +- .../src/connectorApi/models/index.ts | 56 +++--- .../src/connectorApi/models/mappers.ts | 127 +++++++------ .../src/connectorApi/models/parameters.ts | 16 +- .../connectorApi/operations/attachments.ts | 24 +-- .../connectorApi/operations/conversations.ts | 170 +++++++++--------- .../src/teams/models/index.ts | 2 +- .../src/teams/models/mappers.ts | 154 ++++++++-------- .../src/teams/models/parameters.ts | 12 +- .../src/teams/operations/teams.ts | 110 ++++++------ .../src/teams/teamsConnectorClient.ts | 2 +- .../src/teams/teamsConnectorClientContext.ts | 2 +- .../src/tokenApi/models/index.ts | 155 ++++++++-------- .../src/tokenApi/models/mappers.ts | 21 ++- .../src/tokenApi/models/parameters.ts | 24 +-- .../src/tokenApi/operations/botSignIn.ts | 20 +-- .../src/tokenApi/operations/userToken.ts | 58 +++--- .../src/tokenApi/tokenApiClient.ts | 4 +- .../src/tokenApi/tokenApiClientContext.ts | 12 +- .../tests/appCredentials.test.js | 2 +- .../botFrameworkAuthenticationFactory.test.js | 2 +- .../tests/ms-rest-mappers-test.js | 6 +- 42 files changed, 568 insertions(+), 527 deletions(-) create mode 100644 libraries/botframework-connector/src/auth/tokenCredentials.ts diff --git a/libraries/botbuilder/etc/botbuilder.api.md b/libraries/botbuilder/etc/botbuilder.api.md index 374f266dde..b02ab46725 100644 --- a/libraries/botbuilder/etc/botbuilder.api.md +++ b/libraries/botbuilder/etc/botbuilder.api.md @@ -41,8 +41,8 @@ import { ExtendedUserTokenProvider } from 'botbuilder-core'; import { FileConsentCardResponse } from 'botbuilder-core'; import { GetPropertyPaneConfigurationResponse } from 'botbuilder-core'; import { HandleActionResponse } from 'botbuilder-core'; -import { HttpClient } from '@azure/ms-rest-js'; -import { HttpOperationResponse } from '@azure/ms-rest-js'; +import { HttpClient } from '@azure/core-http'; +import { HttpOperationResponse } from '@azure/core-http'; import { ICredentialProvider } from 'botframework-connector'; import { INodeBuffer } from 'botframework-streaming'; import { INodeSocket } from 'botframework-streaming'; @@ -99,7 +99,7 @@ import { TranscriptInfo } from 'botbuilder-core'; import { TranscriptStore } from 'botbuilder-core'; import { TurnContext } from 'botbuilder-core'; import { UserState } from 'botbuilder-core'; -import { WebResource } from '@azure/ms-rest-js'; +import { WebResource } from '@azure/core-http'; // Warning: (ae-forgotten-export) The symbol "ConnectorClientBuilder" needs to be exported by the entry point index.d.ts // diff --git a/libraries/botbuilder/package.json b/libraries/botbuilder/package.json index ea8918c26e..266a914298 100644 --- a/libraries/botbuilder/package.json +++ b/libraries/botbuilder/package.json @@ -27,7 +27,7 @@ } }, "dependencies": { - "@azure/ms-rest-js": "^2.7.0", + "@azure/core-http": "^3.0.2", "@azure/msal-node": "^1.2.0", "axios": "^0.25.0", "botbuilder-core": "4.1.6", diff --git a/libraries/botbuilder/src/botFrameworkAdapter.ts b/libraries/botbuilder/src/botFrameworkAdapter.ts index a5bbfd4afd..cbe01ab5f7 100644 --- a/libraries/botbuilder/src/botFrameworkAdapter.ts +++ b/libraries/botbuilder/src/botFrameworkAdapter.ts @@ -9,7 +9,7 @@ import * as z from 'zod'; import { BotFrameworkHttpAdapter } from './botFrameworkHttpAdapter'; import { ConnectorClientBuilder, Request, Response, ResponseT, WebRequest, WebResponse } from './interfaces'; -import { HttpClient, RequestPolicyFactory, userAgentPolicy } from '@azure/ms-rest-js'; +import { HttpClient, RequestPolicyFactory, userAgentPolicy } from '@azure/core-http'; import { INodeBufferT, INodeSocketT, LogicT } from './zod'; import { arch, release, type } from 'os'; import { delay, retry } from 'botbuilder-stdlib'; diff --git a/libraries/botbuilder/src/cloudAdapter.ts b/libraries/botbuilder/src/cloudAdapter.ts index bc64874df3..16db792401 100644 --- a/libraries/botbuilder/src/cloudAdapter.ts +++ b/libraries/botbuilder/src/cloudAdapter.ts @@ -5,7 +5,7 @@ import * as z from 'zod'; import type { BotFrameworkHttpAdapter } from './botFrameworkHttpAdapter'; import { Activity, CloudAdapterBase, InvokeResponse, StatusCodes, TurnContext } from 'botbuilder-core'; import { GET, POST, VERSION_PATH } from './streaming'; -import { HttpClient, HttpHeaders, HttpOperationResponse, WebResource } from '@azure/ms-rest-js'; +import { HttpClient, HttpHeaders, HttpOperationResponse, WebResource } from '@azure/core-http'; import { INodeBufferT, INodeSocketT, LogicT } from './zod'; import { Request, Response, ResponseT } from './interfaces'; import { USER_AGENT } from './botFrameworkAdapter'; diff --git a/libraries/botbuilder/src/streaming/streamingHttpClient.ts b/libraries/botbuilder/src/streaming/streamingHttpClient.ts index 53dbf3d664..0d631ba2bb 100644 --- a/libraries/botbuilder/src/streaming/streamingHttpClient.ts +++ b/libraries/botbuilder/src/streaming/streamingHttpClient.ts @@ -6,7 +6,7 @@ * Licensed under the MIT License. */ -import { WebResource, HttpOperationResponse, HttpClient } from '@azure/ms-rest-js'; +import { WebResource, HttpOperationResponse, HttpClient } from '@azure/core-http'; import { IStreamingTransportServer, StreamingRequest } from 'botframework-streaming'; /** diff --git a/libraries/botbuilder/tests/botFrameworkAdapter.test.js b/libraries/botbuilder/tests/botFrameworkAdapter.test.js index 60607ecfb9..ca5d995d69 100644 --- a/libraries/botbuilder/tests/botFrameworkAdapter.test.js +++ b/libraries/botbuilder/tests/botFrameworkAdapter.test.js @@ -6,7 +6,7 @@ const sinon = require('sinon'); const { BotFrameworkAdapter } = require('../'); const { Conversations } = require('botframework-connector/lib/connectorApi/operations'); const { UserToken, BotSignIn } = require('botframework-connector/lib/tokenApi/operations'); -const { userAgentPolicy, HttpHeaders } = require('@azure/ms-rest-js'); +const { userAgentPolicy, HttpHeaders } = require('@azure/core-http'); const { ActivityTypes, diff --git a/libraries/botbuilder/tests/teamsInfo.test.js b/libraries/botbuilder/tests/teamsInfo.test.js index 8ab7ff957d..718d85a8a2 100644 --- a/libraries/botbuilder/tests/teamsInfo.test.js +++ b/libraries/botbuilder/tests/teamsInfo.test.js @@ -1081,7 +1081,7 @@ describe('TeamsInfo', function () { try { await TeamsInfo.sendMeetingNotification(context, notification, meetingId); } catch (e) { - assert.deepEqual(errorResponse, e.body); + assert.deepEqual(errorResponse, e.details); isErrorThrown = true; } @@ -1214,7 +1214,7 @@ describe('TeamsInfo', function () { try { await TeamsInfo.sendMessageToListOfUsers(context, activity, tenantId, members); } catch (e) { - assert.deepEqual(errorResponse, e.errors[0].body); + assert.deepEqual(errorResponse, e.errors[0].details); isErrorThrown = true; } @@ -1307,7 +1307,7 @@ describe('TeamsInfo', function () { try { await TeamsInfo.sendMessageToAllUsersInTenant(context, activity, tenantId); } catch (e) { - assert.deepEqual(errorResponse, e.errors[0].body); + assert.deepEqual(errorResponse, e.errors[0].details); isErrorThrown = true; } @@ -1395,7 +1395,7 @@ describe('TeamsInfo', function () { try { await TeamsInfo.sendMessageToAllUsersInTeam(context, activity, tenantId, teamId); } catch (e) { - assert.deepEqual(errorResponse, e.errors[0].body); + assert.deepEqual(errorResponse, e.errors[0].details); isErrorThrown = true; } @@ -1502,7 +1502,7 @@ describe('TeamsInfo', function () { try { await TeamsInfo.sendMessageToListOfChannels(context, activity, tenantId, members); } catch (e) { - assert.deepEqual(errorResponse, e.errors[0].body); + assert.deepEqual(errorResponse, e.errors[0].details); isErrorThrown = true; } @@ -1579,7 +1579,7 @@ describe('TeamsInfo', function () { try { await TeamsInfo.getOperationState(context, operationId); } catch (e) { - assert.deepEqual(errorResponse, e.errors[0].body); + assert.deepEqual(errorResponse, e.errors[0].details); isErrorThrown = true; } @@ -1648,7 +1648,7 @@ describe('TeamsInfo', function () { try { await TeamsInfo.getFailedEntries(context, operationId); } catch (e) { - assert.deepEqual(errorResponse, e.errors[0].body); + assert.deepEqual(errorResponse, e.errors[0].details); isErrorThrown = true; } @@ -1697,7 +1697,7 @@ describe('TeamsInfo', function () { try { await TeamsInfo.cancelOperation(context, operationId); } catch (e) { - assert.deepEqual(errorResponse, e.errors[0].body); + assert.deepEqual(errorResponse, e.errors[0].details); isErrorThrown = true; } diff --git a/libraries/botframework-connector/package.json b/libraries/botframework-connector/package.json index f6c2d51294..b5773a0a25 100644 --- a/libraries/botframework-connector/package.json +++ b/libraries/botframework-connector/package.json @@ -27,8 +27,8 @@ } }, "dependencies": { + "@azure/core-http": "^3.0.2", "@azure/identity": "^2.0.4", - "@azure/ms-rest-js": "^2.7.0", "@azure/msal-node": "^1.2.0", "axios": "^0.25.0", "base64url": "^3.0.0", diff --git a/libraries/botframework-connector/src/auth/appCredentials.ts b/libraries/botframework-connector/src/auth/appCredentials.ts index a646f2a5fd..4df398456f 100644 --- a/libraries/botframework-connector/src/auth/appCredentials.ts +++ b/libraries/botframework-connector/src/auth/appCredentials.ts @@ -6,8 +6,9 @@ * Licensed under the MIT License. */ -import * as msrest from '@azure/ms-rest-js'; import { ConfidentialClientApplication } from '@azure/msal-node'; +import { ServiceClientCredentials, WebResource } from '@azure/core-http'; +import { TokenCredentials } from './tokenCredentials'; import { AuthenticationConstants } from './authenticationConstants'; import { AuthenticatorResult } from './authenticatorResult'; @@ -15,7 +16,7 @@ import { AuthenticatorResult } from './authenticatorResult'; * General AppCredentials auth implementation and cache. * Subclasses can implement refreshToken to acquire the token. */ -export abstract class AppCredentials implements msrest.ServiceClientCredentials { +export abstract class AppCredentials implements ServiceClientCredentials { private static readonly cache: Map = new Map(); appId: string; @@ -148,9 +149,9 @@ export abstract class AppCredentials implements msrest.ServiceClientCredentials * @param webResource The WebResource HTTP request. * @returns A Promise representing the asynchronous operation. */ - async signRequest(webResource: msrest.WebResource): Promise { + async signRequest(webResource: WebResource): Promise { if (this.shouldSetToken()) { - return new msrest.TokenCredentials(await this.getToken()).signRequest(webResource); + return new TokenCredentials(await this.getToken()).signRequest(webResource); } return webResource; diff --git a/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts b/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts index 26321d4ee4..9c15fe2390 100644 --- a/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts +++ b/libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts @@ -8,7 +8,7 @@ import { BotFrameworkClient } from '../skills'; import { ConversationIdHttpHeaderName } from '../conversationConstants'; import { ServiceClientCredentialsFactory } from './serviceClientCredentialsFactory'; import { USER_AGENT } from './connectorFactoryImpl'; -import { WebResource } from '@azure/ms-rest-js'; +import { WebResource } from '@azure/core-http'; import { ok } from 'assert'; const botFrameworkClientFetchImpl: typeof fetch = async (input, init) => { diff --git a/libraries/botframework-connector/src/auth/certificateServiceClientCredentialsFactory.ts b/libraries/botframework-connector/src/auth/certificateServiceClientCredentialsFactory.ts index 407cb62b63..681ef47000 100644 --- a/libraries/botframework-connector/src/auth/certificateServiceClientCredentialsFactory.ts +++ b/libraries/botframework-connector/src/auth/certificateServiceClientCredentialsFactory.ts @@ -6,7 +6,7 @@ * Licensed under the MIT License. */ -import type { ServiceClientCredentials } from '@azure/ms-rest-js'; +import type { ServiceClientCredentials } from '@azure/core-http'; import { ServiceClientCredentialsFactory } from './serviceClientCredentialsFactory'; import { ok } from 'assert'; import { CertificateAppCredentials } from './certificateAppCredentials'; diff --git a/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts b/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts index bd3ae37ced..ea6d77a6a6 100644 --- a/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts +++ b/libraries/botframework-connector/src/auth/connectorFactoryImpl.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { getDefaultUserAgentValue, RequestPolicyFactory, userAgentPolicy } from '@azure/ms-rest-js'; +import { getDefaultUserAgentValue, RequestPolicyFactory, userAgentPolicy } from '@azure/core-http'; import { ConnectorClient } from '../connectorApi/connectorClient'; import { ConnectorClientOptions } from '../connectorApi/models'; import { ConnectorFactory } from './connectorFactory'; diff --git a/libraries/botframework-connector/src/auth/index.ts b/libraries/botframework-connector/src/auth/index.ts index 5d78f5bc5c..38a5cb890e 100644 --- a/libraries/botframework-connector/src/auth/index.ts +++ b/libraries/botframework-connector/src/auth/index.ts @@ -39,3 +39,4 @@ export * from './userTokenClient'; export { MsalAppCredentials } from './msalAppCredentials'; export { MsalServiceClientCredentialsFactory } from './msalServiceClientCredentialsFactory'; +export { TokenCredentials } from './tokenCredentials'; diff --git a/libraries/botframework-connector/src/auth/managedIdentityServiceClientCredentialsFactory.ts b/libraries/botframework-connector/src/auth/managedIdentityServiceClientCredentialsFactory.ts index 00d5b9b047..127b54b29e 100644 --- a/libraries/botframework-connector/src/auth/managedIdentityServiceClientCredentialsFactory.ts +++ b/libraries/botframework-connector/src/auth/managedIdentityServiceClientCredentialsFactory.ts @@ -7,7 +7,7 @@ */ import type { IJwtTokenProviderFactory } from './jwtTokenProviderFactory'; -import type { ServiceClientCredentials } from '@azure/ms-rest-js'; +import type { ServiceClientCredentials } from '@azure/core-http'; import { ManagedIdentityAppCredentials } from './managedIdentityAppCredentials'; import { ServiceClientCredentialsFactory } from './serviceClientCredentialsFactory'; import { ok } from 'assert'; diff --git a/libraries/botframework-connector/src/auth/msalServiceClientCredentialsFactory.ts b/libraries/botframework-connector/src/auth/msalServiceClientCredentialsFactory.ts index 1f183cbb78..e807aa513e 100644 --- a/libraries/botframework-connector/src/auth/msalServiceClientCredentialsFactory.ts +++ b/libraries/botframework-connector/src/auth/msalServiceClientCredentialsFactory.ts @@ -6,7 +6,7 @@ import { ConfidentialClientApplication } from '@azure/msal-node'; import { MsalAppCredentials } from './msalAppCredentials'; -import { ServiceClientCredentials } from '@azure/ms-rest-js'; +import { ServiceClientCredentials } from '@azure/core-http'; import { ServiceClientCredentialsFactory } from './serviceClientCredentialsFactory'; import { AuthenticationConstants } from './authenticationConstants'; import { GovernmentConstants } from './governmentConstants'; diff --git a/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts b/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts index 388cd62b52..ec01185056 100644 --- a/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts +++ b/libraries/botframework-connector/src/auth/passwordServiceClientCredentialFactory.ts @@ -4,7 +4,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ServiceClientCredentials } from '@azure/ms-rest-js'; +import type { ServiceClientCredentials } from '@azure/core-http'; import { AuthenticationConstants } from './authenticationConstants'; import { GovernmentConstants } from './governmentConstants'; import { MicrosoftAppCredentials } from './microsoftAppCredentials'; diff --git a/libraries/botframework-connector/src/auth/serviceClientCredentialsFactory.ts b/libraries/botframework-connector/src/auth/serviceClientCredentialsFactory.ts index 3630728dea..f790d97a21 100644 --- a/libraries/botframework-connector/src/auth/serviceClientCredentialsFactory.ts +++ b/libraries/botframework-connector/src/auth/serviceClientCredentialsFactory.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ServiceClientCredentials } from '@azure/ms-rest-js'; +import { ServiceClientCredentials } from '@azure/core-http'; // Export underlying type for convenience export { ServiceClientCredentials }; diff --git a/libraries/botframework-connector/src/auth/tokenCredentials.ts b/libraries/botframework-connector/src/auth/tokenCredentials.ts new file mode 100644 index 0000000000..9614344345 --- /dev/null +++ b/libraries/botframework-connector/src/auth/tokenCredentials.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +import { HttpHeaders, Constants, WebResourceLike, ServiceClientCredentials } from '@azure/core-http'; + +const HeaderConstants = Constants.HeaderConstants; +const DEFAULT_AUTHORIZATION_SCHEME = 'Bearer'; + +/** + * A credentials object that uses a token string and a authorzation scheme to authenticate. + */ +export class TokenCredentials implements ServiceClientCredentials { + token: string; + authorizationScheme: string = DEFAULT_AUTHORIZATION_SCHEME; + + /** + * Creates a new TokenCredentials object. + * + * @class + * @param {string} token The token. + * @param {string} [authorizationScheme] The authorization scheme. + */ + constructor(token: string, authorizationScheme: string = DEFAULT_AUTHORIZATION_SCHEME) { + if (!token) { + throw new Error('token cannot be null or undefined.'); + } + this.token = token; + this.authorizationScheme = authorizationScheme; + } + + /** + * Signs a request with the Authentication header. + * + * @param {WebResourceLike} webResource The WebResourceLike to be signed. + * @returns {Promise} The signed request object. + */ + signRequest(webResource: WebResourceLike) { + if (!webResource.headers) webResource.headers = new HttpHeaders(); + webResource.headers.set(HeaderConstants.AUTHORIZATION, `${this.authorizationScheme} ${this.token}`); + return Promise.resolve(webResource); + } +} diff --git a/libraries/botframework-connector/src/auth/userTokenClientImpl.ts b/libraries/botframework-connector/src/auth/userTokenClientImpl.ts index 2a8850f5a6..7946648ee1 100644 --- a/libraries/botframework-connector/src/auth/userTokenClientImpl.ts +++ b/libraries/botframework-connector/src/auth/userTokenClientImpl.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import * as z from 'zod'; -import type { ServiceClientCredentials } from '@azure/ms-rest-js'; +import type { ServiceClientCredentials } from '@azure/core-http'; import { Activity, SignInUrlResponse, TokenExchangeRequest, TokenResponse, TokenStatus } from 'botframework-schema'; import { ConnectorClientOptions } from '../connectorApi/models'; import { TokenApiClient } from '../tokenApi/tokenApiClient'; diff --git a/libraries/botframework-connector/src/connectorApi/connectorClient.ts b/libraries/botframework-connector/src/connectorApi/connectorClient.ts index 93c7af47ff..f5f320d3f8 100644 --- a/libraries/botframework-connector/src/connectorApi/connectorClient.ts +++ b/libraries/botframework-connector/src/connectorApi/connectorClient.ts @@ -5,7 +5,7 @@ import * as Mappers from './models/mappers'; import * as Models from './models'; -import * as msRest from '@azure/ms-rest-js'; +import { ServiceClientCredentials } from '@azure/core-http'; import * as operations from './operations'; import { ConnectorClientContext } from './connectorClientContext'; @@ -20,7 +20,7 @@ class ConnectorClient extends ConnectorClientContext { * @param credentials Subscription credentials which uniquely identify client subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.ConnectorClientOptions) { + constructor(credentials: ServiceClientCredentials, options?: Models.ConnectorClientOptions) { super(credentials, options); this.attachments = new operations.Attachments(this); this.conversations = new operations.Conversations(this); diff --git a/libraries/botframework-connector/src/connectorApi/connectorClientContext.ts b/libraries/botframework-connector/src/connectorApi/connectorClientContext.ts index 131844f99e..02b0abede9 100644 --- a/libraries/botframework-connector/src/connectorApi/connectorClientContext.ts +++ b/libraries/botframework-connector/src/connectorApi/connectorClientContext.ts @@ -3,21 +3,21 @@ * Licensed under the MIT License. */ -import * as msRest from "@azure/ms-rest-js"; +import { ServiceClient, ServiceClientCredentials, getDefaultUserAgentValue } from "@azure/core-http"; import * as Models from "./models"; const packageName = "botframework-connector"; const packageVersion = "4.0.0"; -export class ConnectorClientContext extends msRest.ServiceClient { - credentials: msRest.ServiceClientCredentials; +export class ConnectorClientContext extends ServiceClient { + credentials: ServiceClientCredentials; /** * Initializes a new instance of the ConnectorClientContext class. * @param credentials Subscription credentials which uniquely identify client subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.ConnectorClientOptions) { + constructor(credentials: ServiceClientCredentials, options?: Models.ConnectorClientOptions) { if (credentials === null || credentials === undefined) { throw new Error('\'credentials\' cannot be null.'); } @@ -27,7 +27,7 @@ export class ConnectorClientContext extends msRest.ServiceClient { options = {} as Models.ConnectorClientOptions; } // TODO This is to workaround fact that AddUserAgent() was removed. - const defaultUserAgent = msRest.getDefaultUserAgentValue(); + const defaultUserAgent = getDefaultUserAgentValue(); options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent} ${options.userAgent || ''}`; super(credentials, options); diff --git a/libraries/botframework-connector/src/connectorApi/models/index.ts b/libraries/botframework-connector/src/connectorApi/models/index.ts index b8af605d37..8b4a7f9709 100644 --- a/libraries/botframework-connector/src/connectorApi/models/index.ts +++ b/libraries/botframework-connector/src/connectorApi/models/index.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. */ -import * as msRest from "@azure/ms-rest-js"; -import { ServiceClientOptions } from "@azure/ms-rest-js"; + +import { ServiceClientOptions, RequestOptionsBase, HttpResponse } from "@azure/core-http"; import { AttachmentInfo, ChannelAccount, ConversationResourceResponse, ConversationsResult, PagedMembersResult, ResourceResponse } from "botframework-schema"; export * from "botframework-schema"; @@ -22,7 +22,7 @@ export interface ConnectorClientOptions extends ServiceClientOptions { /** * Optional Parameters. */ -export interface ConversationsGetConversationsOptionalParams extends msRest.RequestOptionsBase { +export interface ConversationsGetConversationsOptionalParams extends RequestOptionsBase { /** * skip or continuation token */ @@ -32,7 +32,7 @@ export interface ConversationsGetConversationsOptionalParams extends msRest.Requ /** * Optional Parameters. */ -export interface ConversationsGetConversationPagedMembersOptionalParams extends msRest.RequestOptionsBase { +export interface ConversationsGetConversationPagedMembersOptionalParams extends RequestOptionsBase { /** * Suggested page size */ @@ -50,7 +50,7 @@ export type AttachmentsGetAttachmentInfoResponse = AttachmentInfo & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ @@ -86,7 +86,7 @@ export type AttachmentsGetAttachmentResponse = { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse; + _response: HttpResponse; }; /** @@ -96,7 +96,7 @@ export type ConversationsGetConversationsResponse = ConversationsResult & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ @@ -116,7 +116,7 @@ export type ConversationsCreateConversationResponse = ConversationResourceRespon /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ @@ -136,7 +136,7 @@ export type ConversationsSendToConversationResponse = ResourceResponse & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ @@ -156,7 +156,7 @@ export type ConversationsSendConversationHistoryResponse = ResourceResponse & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ @@ -176,7 +176,7 @@ export type ConversationsUpdateActivityResponse = ResourceResponse & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ @@ -196,7 +196,7 @@ export type ConversationsReplyToActivityResponse = ResourceResponse & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ @@ -216,7 +216,7 @@ export type ConversationsGetConversationMembersResponse = Array /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ @@ -233,21 +233,21 @@ export type ConversationsGetConversationMembersResponse = Array * Contains response data for the getConversationMember operation. */ export type ConversationsGetConversationMemberResponse = ChannelAccount & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { /** - * The underlying HTTP response. + * The response body as text (string format) */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: ChannelAccount; - }; + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: ChannelAccount; }; +}; /** * Contains response data for the getConversationPagedMembers operation. @@ -256,7 +256,7 @@ export type ConversationsGetConversationPagedMembersResponse = PagedMembersResul /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ @@ -276,7 +276,7 @@ export type ConversationsGetActivityMembersResponse = Array & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ @@ -296,7 +296,7 @@ export type ConversationsUploadAttachmentResponse = ResourceResponse & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ diff --git a/libraries/botframework-connector/src/connectorApi/models/mappers.ts b/libraries/botframework-connector/src/connectorApi/models/mappers.ts index 711904f78f..559bb2a97b 100644 --- a/libraries/botframework-connector/src/connectorApi/models/mappers.ts +++ b/libraries/botframework-connector/src/connectorApi/models/mappers.ts @@ -3,10 +3,9 @@ * Licensed under the MIT License. */ -import * as msRest from "@azure/ms-rest-js"; +import { CompositeMapper } from "@azure/core-http" - -export const AttachmentView: msRest.CompositeMapper = { +export const AttachmentView: CompositeMapper = { serializedName: "AttachmentView", type: { name: "Composite", @@ -28,7 +27,7 @@ export const AttachmentView: msRest.CompositeMapper = { } }; -export const AttachmentInfo: msRest.CompositeMapper = { +export const AttachmentInfo: CompositeMapper = { serializedName: "AttachmentInfo", type: { name: "Composite", @@ -62,7 +61,7 @@ export const AttachmentInfo: msRest.CompositeMapper = { } }; -export const InnerHttpError: msRest.CompositeMapper = { +export const InnerHttpError: CompositeMapper = { serializedName: "InnerHttpError", type: { name: "Composite", @@ -84,7 +83,7 @@ export const InnerHttpError: msRest.CompositeMapper = { } }; -export const ErrorModel: msRest.CompositeMapper = { +export const ErrorModel: CompositeMapper = { serializedName: "Error", type: { name: "Composite", @@ -113,7 +112,7 @@ export const ErrorModel: msRest.CompositeMapper = { } }; -export const ErrorResponse: msRest.CompositeMapper = { +export const ErrorResponse: CompositeMapper = { serializedName: "ErrorResponse", type: { name: "Composite", @@ -130,7 +129,7 @@ export const ErrorResponse: msRest.CompositeMapper = { } }; -export const ChannelAccount: msRest.CompositeMapper = { +export const ChannelAccount: CompositeMapper = { serializedName: "ChannelAccount", type: { name: "Composite", @@ -164,7 +163,7 @@ export const ChannelAccount: msRest.CompositeMapper = { } }; -export const ConversationAccount: msRest.CompositeMapper = { +export const ConversationAccount: CompositeMapper = { serializedName: "ConversationAccount", type: { name: "Composite", @@ -222,7 +221,7 @@ export const ConversationAccount: msRest.CompositeMapper = { } }; -export const MessageReaction: msRest.CompositeMapper = { +export const MessageReaction: CompositeMapper = { serializedName: "MessageReaction", type: { name: "Composite", @@ -238,7 +237,7 @@ export const MessageReaction: msRest.CompositeMapper = { } }; -export const CardAction: msRest.CompositeMapper = { +export const CardAction: CompositeMapper = { serializedName: "CardAction", type: { name: "Composite", @@ -296,7 +295,7 @@ export const CardAction: msRest.CompositeMapper = { } }; -export const SuggestedActions: msRest.CompositeMapper = { +export const SuggestedActions: CompositeMapper = { serializedName: "SuggestedActions", type: { name: "Composite", @@ -329,7 +328,7 @@ export const SuggestedActions: msRest.CompositeMapper = { } }; -export const Attachment: msRest.CompositeMapper = { +export const Attachment: CompositeMapper = { serializedName: "Attachment", type: { name: "Composite", @@ -369,7 +368,7 @@ export const Attachment: msRest.CompositeMapper = { } }; -export const Entity: msRest.CompositeMapper = { +export const Entity: CompositeMapper = { serializedName: "Entity", type: { name: "Composite", @@ -398,7 +397,7 @@ export const Entity: msRest.CompositeMapper = { } }; -export const ConversationReference: msRest.CompositeMapper = { +export const ConversationReference: CompositeMapper = { serializedName: "ConversationReference", type: { name: "Composite", @@ -447,7 +446,7 @@ export const ConversationReference: msRest.CompositeMapper = { } }; -export const TextHighlight: msRest.CompositeMapper = { +export const TextHighlight: CompositeMapper = { serializedName: "TextHighlight", type: { name: "Composite", @@ -469,7 +468,7 @@ export const TextHighlight: msRest.CompositeMapper = { } }; -export const SemanticAction: msRest.CompositeMapper = { +export const SemanticAction: CompositeMapper = { serializedName: "SemanticAction", type: { name: "Composite", @@ -503,7 +502,7 @@ export const SemanticAction: msRest.CompositeMapper = { } }; -export const Activity: msRest.CompositeMapper = { +export const Activity: CompositeMapper = { serializedName: "Activity", type: { name: "Composite", @@ -823,7 +822,7 @@ export const Activity: msRest.CompositeMapper = { } }; -export const ConversationParameters: msRest.CompositeMapper = { +export const ConversationParameters: CompositeMapper = { serializedName: "ConversationParameters", type: { name: "Composite", @@ -883,7 +882,7 @@ export const ConversationParameters: msRest.CompositeMapper = { } }; -export const ConversationResourceResponse: msRest.CompositeMapper = { +export const ConversationResourceResponse: CompositeMapper = { serializedName: "ConversationResourceResponse", type: { name: "Composite", @@ -911,7 +910,7 @@ export const ConversationResourceResponse: msRest.CompositeMapper = { } }; -export const ConversationMembers: msRest.CompositeMapper = { +export const ConversationMembers: CompositeMapper = { serializedName: "ConversationMembers", type: { name: "Composite", @@ -939,7 +938,7 @@ export const ConversationMembers: msRest.CompositeMapper = { } }; -export const ConversationsResult: msRest.CompositeMapper = { +export const ConversationsResult: CompositeMapper = { serializedName: "ConversationsResult", type: { name: "Composite", @@ -967,7 +966,7 @@ export const ConversationsResult: msRest.CompositeMapper = { } }; -export const ExpectedReplies: msRest.CompositeMapper = { +export const ExpectedReplies: CompositeMapper = { serializedName: "ExpectedReplies", type: { name: "Composite", @@ -989,7 +988,7 @@ export const ExpectedReplies: msRest.CompositeMapper = { } }; -export const ResourceResponse: msRest.CompositeMapper = { +export const ResourceResponse: CompositeMapper = { serializedName: "ResourceResponse", type: { name: "Composite", @@ -1005,7 +1004,7 @@ export const ResourceResponse: msRest.CompositeMapper = { } }; -export const Transcript: msRest.CompositeMapper = { +export const Transcript: CompositeMapper = { serializedName: "Transcript", type: { name: "Composite", @@ -1027,7 +1026,7 @@ export const Transcript: msRest.CompositeMapper = { } }; -export const PagedMembersResult: msRest.CompositeMapper = { +export const PagedMembersResult: CompositeMapper = { serializedName: "PagedMembersResult", type: { name: "Composite", @@ -1055,7 +1054,7 @@ export const PagedMembersResult: msRest.CompositeMapper = { } }; -export const AttachmentData: msRest.CompositeMapper = { +export const AttachmentData: CompositeMapper = { serializedName: "AttachmentData", type: { name: "Composite", @@ -1089,7 +1088,7 @@ export const AttachmentData: msRest.CompositeMapper = { } }; -export const CardImage: msRest.CompositeMapper = { +export const CardImage: CompositeMapper = { serializedName: "CardImage", type: { name: "Composite", @@ -1118,7 +1117,7 @@ export const CardImage: msRest.CompositeMapper = { } }; -export const HeroCard: msRest.CompositeMapper = { +export const HeroCard: CompositeMapper = { serializedName: "HeroCard", type: { name: "Composite", @@ -1177,7 +1176,7 @@ export const HeroCard: msRest.CompositeMapper = { } }; -export const ThumbnailUrl: msRest.CompositeMapper = { +export const ThumbnailUrl: CompositeMapper = { serializedName: "ThumbnailUrl", type: { name: "Composite", @@ -1199,7 +1198,7 @@ export const ThumbnailUrl: msRest.CompositeMapper = { } }; -export const MediaUrl: msRest.CompositeMapper = { +export const MediaUrl: CompositeMapper = { serializedName: "MediaUrl", type: { name: "Composite", @@ -1221,7 +1220,7 @@ export const MediaUrl: msRest.CompositeMapper = { } }; -export const AnimationCard: msRest.CompositeMapper = { +export const AnimationCard: CompositeMapper = { serializedName: "AnimationCard", type: { name: "Composite", @@ -1316,7 +1315,7 @@ export const AnimationCard: msRest.CompositeMapper = { } }; -export const AudioCard: msRest.CompositeMapper = { +export const AudioCard: CompositeMapper = { serializedName: "AudioCard", type: { name: "Composite", @@ -1411,7 +1410,7 @@ export const AudioCard: msRest.CompositeMapper = { } }; -export const BasicCard: msRest.CompositeMapper = { +export const BasicCard: CompositeMapper = { serializedName: "BasicCard", type: { name: "Composite", @@ -1470,7 +1469,7 @@ export const BasicCard: msRest.CompositeMapper = { } }; -export const MediaCard: msRest.CompositeMapper = { +export const MediaCard: CompositeMapper = { serializedName: "MediaCard", type: { name: "Composite", @@ -1565,7 +1564,7 @@ export const MediaCard: msRest.CompositeMapper = { } }; -export const Fact: msRest.CompositeMapper = { +export const Fact: CompositeMapper = { serializedName: "Fact", type: { name: "Composite", @@ -1587,7 +1586,7 @@ export const Fact: msRest.CompositeMapper = { } }; -export const ReceiptItem: msRest.CompositeMapper = { +export const ReceiptItem: CompositeMapper = { serializedName: "ReceiptItem", type: { name: "Composite", @@ -1641,7 +1640,7 @@ export const ReceiptItem: msRest.CompositeMapper = { } }; -export const ReceiptCard: msRest.CompositeMapper = { +export const ReceiptCard: CompositeMapper = { serializedName: "ReceiptCard", type: { name: "Composite", @@ -1718,7 +1717,7 @@ export const ReceiptCard: msRest.CompositeMapper = { } }; -export const SigninCard: msRest.CompositeMapper = { +export const SigninCard: CompositeMapper = { serializedName: "SigninCard", type: { name: "Composite", @@ -1746,7 +1745,7 @@ export const SigninCard: msRest.CompositeMapper = { } }; -export const OAuthCard: msRest.CompositeMapper = { +export const OAuthCard: CompositeMapper = { serializedName: "OAuthCard", type: { name: "Composite", @@ -1780,7 +1779,7 @@ export const OAuthCard: msRest.CompositeMapper = { } }; -export const ThumbnailCard: msRest.CompositeMapper = { +export const ThumbnailCard: CompositeMapper = { serializedName: "ThumbnailCard", type: { name: "Composite", @@ -1839,7 +1838,7 @@ export const ThumbnailCard: msRest.CompositeMapper = { } }; -export const VideoCard: msRest.CompositeMapper = { +export const VideoCard: CompositeMapper = { serializedName: "VideoCard", type: { name: "Composite", @@ -1934,7 +1933,7 @@ export const VideoCard: msRest.CompositeMapper = { } }; -export const GeoCoordinates: msRest.CompositeMapper = { +export const GeoCoordinates: CompositeMapper = { serializedName: "GeoCoordinates", type: { name: "Composite", @@ -1974,7 +1973,7 @@ export const GeoCoordinates: msRest.CompositeMapper = { } }; -export const Mention: msRest.CompositeMapper = { +export const Mention: CompositeMapper = { serializedName: "Mention", type: { name: "Composite", @@ -2003,7 +2002,7 @@ export const Mention: msRest.CompositeMapper = { } }; -export const Place: msRest.CompositeMapper = { +export const Place: CompositeMapper = { serializedName: "Place", type: { name: "Composite", @@ -2043,7 +2042,7 @@ export const Place: msRest.CompositeMapper = { } }; -export const Thing: msRest.CompositeMapper = { +export const Thing: CompositeMapper = { serializedName: "Thing", type: { name: "Composite", @@ -2065,7 +2064,7 @@ export const Thing: msRest.CompositeMapper = { } }; -export const MediaEventValue: msRest.CompositeMapper = { +export const MediaEventValue: CompositeMapper = { serializedName: "MediaEventValue", type: { name: "Composite", @@ -2081,7 +2080,7 @@ export const MediaEventValue: msRest.CompositeMapper = { } }; -export const TokenRequest: msRest.CompositeMapper = { +export const TokenRequest: CompositeMapper = { serializedName: "TokenRequest", type: { name: "Composite", @@ -2108,7 +2107,7 @@ export const TokenRequest: msRest.CompositeMapper = { } }; -export const TokenResponse: msRest.CompositeMapper = { +export const TokenResponse: CompositeMapper = { serializedName: "TokenResponse", type: { name: "Composite", @@ -2142,7 +2141,7 @@ export const TokenResponse: msRest.CompositeMapper = { } }; -export const MicrosoftPayMethodData: msRest.CompositeMapper = { +export const MicrosoftPayMethodData: CompositeMapper = { serializedName: "MicrosoftPayMethodData", type: { name: "Composite", @@ -2183,7 +2182,7 @@ export const MicrosoftPayMethodData: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentAddress: msRest.CompositeMapper = { +export const PaymentAddress: CompositeMapper = { serializedName: "PaymentAddress", type: { name: "Composite", @@ -2267,7 +2266,7 @@ export const PaymentAddress: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentCurrencyAmount: msRest.CompositeMapper = { +export const PaymentCurrencyAmount: CompositeMapper = { serializedName: "PaymentCurrencyAmount", type: { name: "Composite", @@ -2298,7 +2297,7 @@ export const PaymentCurrencyAmount: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentItem: msRest.CompositeMapper = { +export const PaymentItem: CompositeMapper = { serializedName: "PaymentItem", type: { name: "Composite", @@ -2330,7 +2329,7 @@ export const PaymentItem: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentShippingOption: msRest.CompositeMapper = { +export const PaymentShippingOption: CompositeMapper = { serializedName: "PaymentShippingOption", type: { name: "Composite", @@ -2368,7 +2367,7 @@ export const PaymentShippingOption: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentDetailsModifier: msRest.CompositeMapper = { +export const PaymentDetailsModifier: CompositeMapper = { serializedName: "PaymentDetailsModifier", type: { name: "Composite", @@ -2417,7 +2416,7 @@ export const PaymentDetailsModifier: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentDetails: msRest.CompositeMapper = { +export const PaymentDetails: CompositeMapper = { serializedName: "PaymentDetails", type: { name: "Composite", @@ -2479,7 +2478,7 @@ export const PaymentDetails: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentMethodData: msRest.CompositeMapper = { +export const PaymentMethodData: CompositeMapper = { serializedName: "PaymentMethodData", type: { name: "Composite", @@ -2509,7 +2508,7 @@ export const PaymentMethodData: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentOptions: msRest.CompositeMapper = { +export const PaymentOptions: CompositeMapper = { serializedName: "PaymentOptions", type: { name: "Composite", @@ -2552,7 +2551,7 @@ export const PaymentOptions: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentRequest: msRest.CompositeMapper = { +export const PaymentRequest: CompositeMapper = { serializedName: "PaymentRequest", type: { name: "Composite", @@ -2603,7 +2602,7 @@ export const PaymentRequest: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentResponse: msRest.CompositeMapper = { +export const PaymentResponse: CompositeMapper = { serializedName: "PaymentResponse", type: { name: "Composite", @@ -2653,7 +2652,7 @@ export const PaymentResponse: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentRequestComplete: msRest.CompositeMapper = { +export const PaymentRequestComplete: CompositeMapper = { serializedName: "PaymentRequestComplete", type: { name: "Composite", @@ -2686,7 +2685,7 @@ export const PaymentRequestComplete: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentRequestCompleteResult: msRest.CompositeMapper = { +export const PaymentRequestCompleteResult: CompositeMapper = { serializedName: "PaymentRequestCompleteResult", type: { name: "Composite", @@ -2705,7 +2704,7 @@ export const PaymentRequestCompleteResult: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentRequestUpdate: msRest.CompositeMapper = { +export const PaymentRequestUpdate: CompositeMapper = { serializedName: "PaymentRequestUpdate", type: { name: "Composite", @@ -2744,7 +2743,7 @@ export const PaymentRequestUpdate: msRest.CompositeMapper = { /** * @deprecated Bot Framework no longer supports payments */ -export const PaymentRequestUpdateResult: msRest.CompositeMapper = { +export const PaymentRequestUpdateResult: CompositeMapper = { serializedName: "PaymentRequestUpdateResult", type: { name: "Composite", diff --git a/libraries/botframework-connector/src/connectorApi/models/parameters.ts b/libraries/botframework-connector/src/connectorApi/models/parameters.ts index 3cb141f5a0..6b0f81797c 100644 --- a/libraries/botframework-connector/src/connectorApi/models/parameters.ts +++ b/libraries/botframework-connector/src/connectorApi/models/parameters.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. */ -import * as msRest from "@azure/ms-rest-js"; +import { OperationURLParameter, OperationQueryParameter } from "@azure/core-http" -export const activityId: msRest.OperationURLParameter = { +export const activityId: OperationURLParameter = { parameterPath: "activityId", mapper: { required: true, @@ -15,7 +15,7 @@ export const activityId: msRest.OperationURLParameter = { } } }; -export const attachmentId: msRest.OperationURLParameter = { +export const attachmentId: OperationURLParameter = { parameterPath: "attachmentId", mapper: { required: true, @@ -25,7 +25,7 @@ export const attachmentId: msRest.OperationURLParameter = { } } }; -export const continuationToken: msRest.OperationQueryParameter = { +export const continuationToken: OperationQueryParameter = { parameterPath: [ "options", "continuationToken" @@ -37,7 +37,7 @@ export const continuationToken: msRest.OperationQueryParameter = { } } }; -export const conversationId: msRest.OperationURLParameter = { +export const conversationId: OperationURLParameter = { parameterPath: "conversationId", mapper: { required: true, @@ -47,7 +47,7 @@ export const conversationId: msRest.OperationURLParameter = { } } }; -export const memberId: msRest.OperationURLParameter = { +export const memberId: OperationURLParameter = { parameterPath: "memberId", mapper: { required: true, @@ -57,7 +57,7 @@ export const memberId: msRest.OperationURLParameter = { } } }; -export const pageSize: msRest.OperationQueryParameter = { +export const pageSize: OperationQueryParameter = { parameterPath: [ "options", "pageSize" @@ -69,7 +69,7 @@ export const pageSize: msRest.OperationQueryParameter = { } } }; -export const viewId: msRest.OperationURLParameter = { +export const viewId: OperationURLParameter = { parameterPath: "viewId", mapper: { required: true, diff --git a/libraries/botframework-connector/src/connectorApi/operations/attachments.ts b/libraries/botframework-connector/src/connectorApi/operations/attachments.ts index e002716162..c28e2f0b98 100644 --- a/libraries/botframework-connector/src/connectorApi/operations/attachments.ts +++ b/libraries/botframework-connector/src/connectorApi/operations/attachments.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -import * as msRest from "@azure/ms-rest-js"; +import { RequestOptionsBase, ServiceCallback, OperationSpec, Serializer } from "@azure/core-http"; import { ConnectorClientContext } from "../connectorClientContext"; import * as Models from "../models"; import * as Mappers from "../models/attachmentsMappers"; @@ -28,19 +28,19 @@ export class Attachments { * @param [options] The optional parameters * @returns Promise */ - getAttachmentInfo(attachmentId: string, options?: msRest.RequestOptionsBase): Promise; + getAttachmentInfo(attachmentId: string, options?: RequestOptionsBase): Promise; /** * @param attachmentId attachment id * @param callback The callback */ - getAttachmentInfo(attachmentId: string, callback: msRest.ServiceCallback): void; + getAttachmentInfo(attachmentId: string, callback: ServiceCallback): void; /** * @param attachmentId attachment id * @param options The optional parameters * @param callback The callback */ - getAttachmentInfo(attachmentId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - getAttachmentInfo(attachmentId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getAttachmentInfo(attachmentId: string, options: RequestOptionsBase, callback: ServiceCallback): void; + getAttachmentInfo(attachmentId: string, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { attachmentId, @@ -58,21 +58,21 @@ export class Attachments { * @param [options] The optional parameters * @returns Promise */ - getAttachment(attachmentId: string, viewId: string, options?: msRest.RequestOptionsBase): Promise; + getAttachment(attachmentId: string, viewId: string, options?: RequestOptionsBase): Promise; /** * @param attachmentId attachment id * @param viewId View id from attachmentInfo * @param callback The callback */ - getAttachment(attachmentId: string, viewId: string, callback: msRest.ServiceCallback): void; + getAttachment(attachmentId: string, viewId: string, callback: ServiceCallback): void; /** * @param attachmentId attachment id * @param viewId View id from attachmentInfo * @param options The optional parameters * @param callback The callback */ - getAttachment(attachmentId: string, viewId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - getAttachment(attachmentId: string, viewId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getAttachment(attachmentId: string, viewId: string, options: RequestOptionsBase, callback: ServiceCallback): void; + getAttachment(attachmentId: string, viewId: string, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { attachmentId, @@ -85,8 +85,8 @@ export class Attachments { } // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const getAttachmentInfoOperationSpec: msRest.OperationSpec = { +const serializer = new Serializer(Mappers); +const getAttachmentInfoOperationSpec: OperationSpec = { httpMethod: "GET", path: "v3/attachments/{attachmentId}", urlParameters: [ @@ -103,7 +103,7 @@ const getAttachmentInfoOperationSpec: msRest.OperationSpec = { serializer }; -const getAttachmentOperationSpec: msRest.OperationSpec = { +const getAttachmentOperationSpec: OperationSpec = { httpMethod: "GET", path: "v3/attachments/{attachmentId}/views/{viewId}", urlParameters: [ diff --git a/libraries/botframework-connector/src/connectorApi/operations/conversations.ts b/libraries/botframework-connector/src/connectorApi/operations/conversations.ts index 5fd98decea..c38c3c14e1 100644 --- a/libraries/botframework-connector/src/connectorApi/operations/conversations.ts +++ b/libraries/botframework-connector/src/connectorApi/operations/conversations.ts @@ -6,7 +6,7 @@ import * as Mappers from "../models/conversationsMappers"; import * as Models from "../models"; import * as Parameters from "../models/parameters"; -import * as msRest from "@azure/ms-rest-js"; +import { ServiceCallback, RequestOptionsBase, RestResponse, Serializer, OperationSpec } from "@azure/core-http" import { ConnectorClientContext } from "../connectorClientContext"; import { ConversationIdHttpHeaderName } from "../../conversationConstants"; @@ -42,13 +42,13 @@ export class Conversations { /** * @param callback The callback */ - getConversations(callback: msRest.ServiceCallback): void; + getConversations(callback: ServiceCallback): void; /** * @param options The optional parameters * @param callback The callback */ - getConversations(options: Models.ConversationsGetConversationsOptionalParams, callback: msRest.ServiceCallback): void; - getConversations(options?: Models.ConversationsGetConversationsOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getConversations(options: Models.ConversationsGetConversationsOptionalParams, callback: ServiceCallback): void; + getConversations(options?: Models.ConversationsGetConversationsOptionalParams | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { options @@ -84,19 +84,19 @@ export class Conversations { * @param [options] The optional parameters * @returns Promise */ - createConversation(parameters: Models.ConversationParameters, options?: msRest.RequestOptionsBase): Promise; + createConversation(parameters: Models.ConversationParameters, options?: RequestOptionsBase): Promise; /** * @param parameters Parameters to create the conversation from * @param callback The callback */ - createConversation(parameters: Models.ConversationParameters, callback: msRest.ServiceCallback): void; + createConversation(parameters: Models.ConversationParameters, callback: ServiceCallback): void; /** * @param parameters Parameters to create the conversation from * @param options The optional parameters * @param callback The callback */ - createConversation(parameters: Models.ConversationParameters, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - createConversation(parameters: Models.ConversationParameters, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + createConversation(parameters: Models.ConversationParameters, options: RequestOptionsBase, callback: ServiceCallback): void; + createConversation(parameters: Models.ConversationParameters, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { parameters, @@ -125,21 +125,21 @@ export class Conversations { * @param [options] The optional parameters * @returns Promise */ - sendToConversation(conversationId: string, activity: Partial, options?: msRest.RequestOptionsBase): Promise; + sendToConversation(conversationId: string, activity: Partial, options?: RequestOptionsBase): Promise; /** * @param conversationId Conversation ID * @param activity Activity to send * @param callback The callback */ - sendToConversation(conversationId: string, activity: Partial, callback: msRest.ServiceCallback): void; + sendToConversation(conversationId: string, activity: Partial, callback: ServiceCallback): void; /** * @param conversationId Conversation ID * @param activity Activity to send * @param options The optional parameters * @param callback The callback */ - sendToConversation(conversationId: string, activity: Partial, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - sendToConversation(conversationId: string, activity: Partial, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + sendToConversation(conversationId: string, activity: Partial, options: RequestOptionsBase, callback: ServiceCallback): void; + sendToConversation(conversationId: string, activity: Partial, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -162,21 +162,21 @@ export class Conversations { * @param [options] The optional parameters * @returns Promise */ - sendConversationHistory(conversationId: string, history: Models.Transcript, options?: msRest.RequestOptionsBase): Promise; + sendConversationHistory(conversationId: string, history: Models.Transcript, options?: RequestOptionsBase): Promise; /** * @param conversationId Conversation ID * @param history Historic activities * @param callback The callback */ - sendConversationHistory(conversationId: string, history: Models.Transcript, callback: msRest.ServiceCallback): void; + sendConversationHistory(conversationId: string, history: Models.Transcript, callback: ServiceCallback): void; /** * @param conversationId Conversation ID * @param history Historic activities * @param options The optional parameters * @param callback The callback */ - sendConversationHistory(conversationId: string, history: Models.Transcript, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - sendConversationHistory(conversationId: string, history: Models.Transcript, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + sendConversationHistory(conversationId: string, history: Models.Transcript, options: RequestOptionsBase, callback: ServiceCallback): void; + sendConversationHistory(conversationId: string, history: Models.Transcript, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -201,14 +201,14 @@ export class Conversations { * @param [options] The optional parameters * @returns Promise */ - updateActivity(conversationId: string, activityId: string, activity: Partial, options?: msRest.RequestOptionsBase): Promise; + updateActivity(conversationId: string, activityId: string, activity: Partial, options?: RequestOptionsBase): Promise; /** * @param conversationId Conversation ID * @param activityId activityId to update * @param activity replacement Activity * @param callback The callback */ - updateActivity(conversationId: string, activityId: string, activity: Partial, callback: msRest.ServiceCallback): void; + updateActivity(conversationId: string, activityId: string, activity: Partial, callback: ServiceCallback): void; /** * @param conversationId Conversation ID * @param activityId activityId to update @@ -216,8 +216,8 @@ export class Conversations { * @param options The optional parameters * @param callback The callback */ - updateActivity(conversationId: string, activityId: string, activity: Partial, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - updateActivity(conversationId: string, activityId: string, activity: Partial, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + updateActivity(conversationId: string, activityId: string, activity: Partial, options: RequestOptionsBase, callback: ServiceCallback): void; + updateActivity(conversationId: string, activityId: string, activity: Partial, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -249,14 +249,14 @@ export class Conversations { * @param [options] The optional parameters * @returns Promise */ - replyToActivity(conversationId: string, activityId: string, activity: Partial, options?: msRest.RequestOptionsBase): Promise; + replyToActivity(conversationId: string, activityId: string, activity: Partial, options?: RequestOptionsBase): Promise; /** * @param conversationId Conversation ID * @param activityId activityId the reply is to (OPTIONAL) * @param activity Activity to send * @param callback The callback */ - replyToActivity(conversationId: string, activityId: string, activity: Partial, callback: msRest.ServiceCallback): void; + replyToActivity(conversationId: string, activityId: string, activity: Partial, callback: ServiceCallback): void; /** * @param conversationId Conversation ID * @param activityId activityId the reply is to (OPTIONAL) @@ -264,8 +264,8 @@ export class Conversations { * @param options The optional parameters * @param callback The callback */ - replyToActivity(conversationId: string, activityId: string, activity: Partial, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - replyToActivity(conversationId: string, activityId: string, activity: Partial, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + replyToActivity(conversationId: string, activityId: string, activity: Partial, options: RequestOptionsBase, callback: ServiceCallback): void; + replyToActivity(conversationId: string, activityId: string, activity: Partial, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -286,23 +286,23 @@ export class Conversations { * @param conversationId Conversation ID * @param activityId activityId to delete * @param [options] The optional parameters - * @returns Promise + * @returns Promise */ - deleteActivity(conversationId: string, activityId: string, options?: msRest.RequestOptionsBase): Promise; + deleteActivity(conversationId: string, activityId: string, options?: RequestOptionsBase): Promise; /** * @param conversationId Conversation ID * @param activityId activityId to delete * @param callback The callback */ - deleteActivity(conversationId: string, activityId: string, callback: msRest.ServiceCallback): void; + deleteActivity(conversationId: string, activityId: string, callback: ServiceCallback): void; /** * @param conversationId Conversation ID * @param activityId activityId to delete * @param options The optional parameters * @param callback The callback */ - deleteActivity(conversationId: string, activityId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - deleteActivity(conversationId: string, activityId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + deleteActivity(conversationId: string, activityId: string, options: RequestOptionsBase, callback: ServiceCallback): void; + deleteActivity(conversationId: string, activityId: string, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -323,19 +323,19 @@ export class Conversations { * @param [options] The optional parameters * @returns Promise */ - getConversationMembers(conversationId: string, options?: msRest.RequestOptionsBase): Promise; + getConversationMembers(conversationId: string, options?: RequestOptionsBase): Promise; /** * @param conversationId Conversation ID * @param callback The callback */ - getConversationMembers(conversationId: string, callback: msRest.ServiceCallback): void; + getConversationMembers(conversationId: string, callback: ServiceCallback): void; /** * @param conversationId Conversation ID * @param options The optional parameters * @param callback The callback */ - getConversationMembers(conversationId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - getConversationMembers(conversationId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getConversationMembers(conversationId: string, options: RequestOptionsBase, callback: ServiceCallback): void; + getConversationMembers(conversationId: string, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -351,7 +351,7 @@ export class Conversations { * @param options The optional parameters * @param callback The callback */ - getConversationMember(conversationId: string, memberId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getConversationMember(conversationId: string, memberId: string, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -388,14 +388,14 @@ export class Conversations { * @param conversationId Conversation ID * @param callback The callback */ - getConversationPagedMembers(conversationId: string, callback: msRest.ServiceCallback): void; + getConversationPagedMembers(conversationId: string, callback: ServiceCallback): void; /** * @param conversationId Conversation ID * @param options The optional parameters * @param callback The callback */ - getConversationPagedMembers(conversationId: string, options: Models.ConversationsGetConversationPagedMembersOptionalParams, callback: msRest.ServiceCallback): void; - getConversationPagedMembers(conversationId: string, options?: Models.ConversationsGetConversationPagedMembersOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getConversationPagedMembers(conversationId: string, options: Models.ConversationsGetConversationPagedMembersOptionalParams, callback: ServiceCallback): void; + getConversationPagedMembers(conversationId: string, options?: Models.ConversationsGetConversationPagedMembersOptionalParams | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -415,23 +415,23 @@ export class Conversations { * @param conversationId Conversation ID * @param memberId ID of the member to delete from this conversation * @param [options] The optional parameters - * @returns Promise + * @returns Promise */ - deleteConversationMember(conversationId: string, memberId: string, options?: msRest.RequestOptionsBase): Promise; + deleteConversationMember(conversationId: string, memberId: string, options?: RequestOptionsBase): Promise; /** * @param conversationId Conversation ID * @param memberId ID of the member to delete from this conversation * @param callback The callback */ - deleteConversationMember(conversationId: string, memberId: string, callback: msRest.ServiceCallback): void; + deleteConversationMember(conversationId: string, memberId: string, callback: ServiceCallback): void; /** * @param conversationId Conversation ID * @param memberId ID of the member to delete from this conversation * @param options The optional parameters * @param callback The callback */ - deleteConversationMember(conversationId: string, memberId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - deleteConversationMember(conversationId: string, memberId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + deleteConversationMember(conversationId: string, memberId: string, options: RequestOptionsBase, callback: ServiceCallback): void; + deleteConversationMember(conversationId: string, memberId: string, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -453,21 +453,21 @@ export class Conversations { * @param [options] The optional parameters * @returns Promise */ - getActivityMembers(conversationId: string, activityId: string, options?: msRest.RequestOptionsBase): Promise; + getActivityMembers(conversationId: string, activityId: string, options?: RequestOptionsBase): Promise; /** * @param conversationId Conversation ID * @param activityId Activity ID * @param callback The callback */ - getActivityMembers(conversationId: string, activityId: string, callback: msRest.ServiceCallback): void; + getActivityMembers(conversationId: string, activityId: string, callback: ServiceCallback): void; /** * @param conversationId Conversation ID * @param activityId Activity ID * @param options The optional parameters * @param callback The callback */ - getActivityMembers(conversationId: string, activityId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - getActivityMembers(conversationId: string, activityId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getActivityMembers(conversationId: string, activityId: string, options: RequestOptionsBase, callback: ServiceCallback): void; + getActivityMembers(conversationId: string, activityId: string, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -492,21 +492,21 @@ export class Conversations { * @param [options] The optional parameters * @returns Promise */ - uploadAttachment(conversationId: string, attachmentUpload: Models.AttachmentData, options?: msRest.RequestOptionsBase): Promise; + uploadAttachment(conversationId: string, attachmentUpload: Models.AttachmentData, options?: RequestOptionsBase): Promise; /** * @param conversationId Conversation ID * @param attachmentUpload Attachment data * @param callback The callback */ - uploadAttachment(conversationId: string, attachmentUpload: Models.AttachmentData, callback: msRest.ServiceCallback): void; + uploadAttachment(conversationId: string, attachmentUpload: Models.AttachmentData, callback: ServiceCallback): void; /** * @param conversationId Conversation ID * @param attachmentUpload Attachment data * @param options The optional parameters * @param callback The callback */ - uploadAttachment(conversationId: string, attachmentUpload: Models.AttachmentData, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - uploadAttachment(conversationId: string, attachmentUpload: Models.AttachmentData, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + uploadAttachment(conversationId: string, attachmentUpload: Models.AttachmentData, options: RequestOptionsBase, callback: ServiceCallback): void; + uploadAttachment(conversationId: string, attachmentUpload: Models.AttachmentData, options?: RequestOptionsBase | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { conversationId, @@ -519,8 +519,8 @@ export class Conversations { } // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const getConversationsOperationSpec: msRest.OperationSpec = { +const serializer = new Serializer(Mappers); +const getConversationsOperationSpec: OperationSpec = { httpMethod: "GET", path: "v3/conversations", queryParameters: [ @@ -537,7 +537,7 @@ const getConversationsOperationSpec: msRest.OperationSpec = { serializer }; -const createConversationOperationSpec: msRest.OperationSpec = { +const createConversationOperationSpec: OperationSpec = { httpMethod: "POST", path: "v3/conversations", requestBody: { @@ -564,7 +564,7 @@ const createConversationOperationSpec: msRest.OperationSpec = { serializer }; -const sendToConversationOperationSpec: msRest.OperationSpec = { +const sendToConversationOperationSpec: OperationSpec = { httpMethod: "POST", path: "v3/conversations/{conversationId}/activities", urlParameters: [ @@ -594,7 +594,7 @@ const sendToConversationOperationSpec: msRest.OperationSpec = { serializer }; -const sendConversationHistoryOperationSpec: msRest.OperationSpec = { +const sendConversationHistoryOperationSpec: OperationSpec = { httpMethod: "POST", path: "v3/conversations/{conversationId}/activities/history", urlParameters: [ @@ -624,7 +624,7 @@ const sendConversationHistoryOperationSpec: msRest.OperationSpec = { serializer }; -const updateActivityOperationSpec: msRest.OperationSpec = { +const updateActivityOperationSpec: OperationSpec = { httpMethod: "PUT", path: "v3/conversations/{conversationId}/activities/{activityId}", urlParameters: [ @@ -655,7 +655,7 @@ const updateActivityOperationSpec: msRest.OperationSpec = { serializer }; -const replyToActivityOperationSpec: msRest.OperationSpec = { +const replyToActivityOperationSpec: OperationSpec = { httpMethod: "POST", path: "v3/conversations/{conversationId}/activities/{activityId}", urlParameters: [ @@ -695,7 +695,7 @@ const replyToActivityOperationSpec: msRest.OperationSpec = { serializer }; -const deleteActivityOperationSpec: msRest.OperationSpec = { +const deleteActivityOperationSpec: OperationSpec = { httpMethod: "DELETE", path: "v3/conversations/{conversationId}/activities/{activityId}", urlParameters: [ @@ -712,7 +712,7 @@ const deleteActivityOperationSpec: msRest.OperationSpec = { serializer }; -const getConversationMembersOperationSpec: msRest.OperationSpec = { +const getConversationMembersOperationSpec: OperationSpec = { httpMethod: "GET", path: "v3/conversations/{conversationId}/members", urlParameters: [ @@ -723,13 +723,13 @@ const getConversationMembersOperationSpec: msRest.OperationSpec = { bodyMapper: { serializedName: "parsedResponse", type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ChannelAccount" - } + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ChannelAccount" } + } } } }, @@ -740,25 +740,25 @@ const getConversationMembersOperationSpec: msRest.OperationSpec = { serializer }; -const getConversationMemberOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - path: "v3/conversations/{conversationId}/members/{memberId}", - urlParameters: [ - Parameters.conversationId, - Parameters.memberId - ], - responses: { - 200: { - bodyMapper: Mappers.ChannelAccount, - }, - default: { - bodyMapper: Mappers.ErrorResponse - } +const getConversationMemberOperationSpec: OperationSpec = { + httpMethod: "GET", + path: "v3/conversations/{conversationId}/members/{memberId}", + urlParameters: [ + Parameters.conversationId, + Parameters.memberId + ], + responses: { + 200: { + bodyMapper: Mappers.ChannelAccount, }, - serializer - }; + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; -const getConversationPagedMembersOperationSpec: msRest.OperationSpec = { +const getConversationPagedMembersOperationSpec: OperationSpec = { httpMethod: "GET", path: "v3/conversations/{conversationId}/pagedmembers", urlParameters: [ @@ -777,7 +777,7 @@ const getConversationPagedMembersOperationSpec: msRest.OperationSpec = { serializer }; -const deleteConversationMemberOperationSpec: msRest.OperationSpec = { +const deleteConversationMemberOperationSpec: OperationSpec = { httpMethod: "DELETE", path: "v3/conversations/{conversationId}/members/{memberId}", urlParameters: [ @@ -794,7 +794,7 @@ const deleteConversationMemberOperationSpec: msRest.OperationSpec = { serializer }; -const getActivityMembersOperationSpec: msRest.OperationSpec = { +const getActivityMembersOperationSpec: OperationSpec = { httpMethod: "GET", path: "v3/conversations/{conversationId}/activities/{activityId}/members", urlParameters: [ @@ -823,7 +823,7 @@ const getActivityMembersOperationSpec: msRest.OperationSpec = { serializer }; -const uploadAttachmentOperationSpec: msRest.OperationSpec = { +const uploadAttachmentOperationSpec: OperationSpec = { httpMethod: "POST", path: "v3/conversations/{conversationId}/attachments", urlParameters: [ diff --git a/libraries/botframework-connector/src/teams/models/index.ts b/libraries/botframework-connector/src/teams/models/index.ts index fefa1140df..76358b0d7d 100644 --- a/libraries/botframework-connector/src/teams/models/index.ts +++ b/libraries/botframework-connector/src/teams/models/index.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -import { HttpResponse, ServiceClientOptions, RequestOptionsBase } from '@azure/ms-rest-js'; +import { HttpResponse, ServiceClientOptions, RequestOptionsBase } from '@azure/core-http'; import { ConversationList, TeamDetails, diff --git a/libraries/botframework-connector/src/teams/models/mappers.ts b/libraries/botframework-connector/src/teams/models/mappers.ts index 3111fb1076..86124cf8f2 100644 --- a/libraries/botframework-connector/src/teams/models/mappers.ts +++ b/libraries/botframework-connector/src/teams/models/mappers.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. */ -import * as msRest from '@azure/ms-rest-js'; +import { CompositeMapper } from '@azure/core-http'; -export const ChannelInfo: msRest.CompositeMapper = { +export const ChannelInfo: CompositeMapper = { serializedName: 'ChannelInfo', type: { name: 'Composite', @@ -33,7 +33,7 @@ export const ChannelInfo: msRest.CompositeMapper = { }, }; -export const ConversationList: msRest.CompositeMapper = { +export const ConversationList: CompositeMapper = { serializedName: 'ConversationList', type: { name: 'Composite', @@ -55,7 +55,7 @@ export const ConversationList: msRest.CompositeMapper = { }, }; -export const TeamDetails: msRest.CompositeMapper = { +export const TeamDetails: CompositeMapper = { serializedName: 'TeamDetails', type: { name: 'Composite', @@ -89,7 +89,7 @@ export const TeamDetails: msRest.CompositeMapper = { }, }; -export const TeamInfo: msRest.CompositeMapper = { +export const TeamInfo: CompositeMapper = { serializedName: 'TeamInfo', type: { name: 'Composite', @@ -117,7 +117,7 @@ export const TeamInfo: msRest.CompositeMapper = { }, }; -export const NotificationInfo: msRest.CompositeMapper = { +export const NotificationInfo: CompositeMapper = { serializedName: 'NotificationInfo', type: { name: 'Composite', @@ -145,7 +145,7 @@ export const NotificationInfo: msRest.CompositeMapper = { }, }; -export const TenantInfo: msRest.CompositeMapper = { +export const TenantInfo: CompositeMapper = { serializedName: 'TenantInfo', type: { name: 'Composite', @@ -161,7 +161,7 @@ export const TenantInfo: msRest.CompositeMapper = { }, }; -export const TeamsChannelData: msRest.CompositeMapper = { +export const TeamsChannelData: CompositeMapper = { serializedName: 'TeamsChannelData', type: { name: 'Composite', @@ -212,7 +212,7 @@ export const TeamsChannelData: msRest.CompositeMapper = { }, }; -export const TeamsChannelDataSettings: msRest.CompositeMapper = { +export const TeamsChannelDataSettings: CompositeMapper = { serializedName: 'TeamsChannelDataSettings', type: { name: 'Composite', @@ -229,7 +229,7 @@ export const TeamsChannelDataSettings: msRest.CompositeMapper = { }, }; -export const ChannelAccount: msRest.CompositeMapper = { +export const ChannelAccount: CompositeMapper = { serializedName: 'ChannelAccount', type: { name: 'Composite', @@ -251,7 +251,7 @@ export const ChannelAccount: msRest.CompositeMapper = { }, }; -export const TeamsChannelAccount: msRest.CompositeMapper = { +export const TeamsChannelAccount: CompositeMapper = { serializedName: 'TeamsChannelAccount', type: { name: 'Composite', @@ -298,7 +298,7 @@ export const TeamsChannelAccount: msRest.CompositeMapper = { }, }; -export const Meeting: msRest.CompositeMapper = { +export const Meeting: CompositeMapper = { serializedName: 'meeting', type: { name: 'Composite', @@ -320,7 +320,7 @@ export const Meeting: msRest.CompositeMapper = { }, }; -export const TeamsMeetingParticipant: msRest.CompositeMapper = { +export const TeamsMeetingParticipant: CompositeMapper = { serializedName: 'TeamsMeetingParticipant', type: { name: 'Composite', @@ -351,7 +351,7 @@ export const TeamsMeetingParticipant: msRest.CompositeMapper = { }, }; -export const TeamsMeetingInfo: msRest.CompositeMapper = { +export const TeamsMeetingInfo: CompositeMapper = { serializedName: 'TeamsMeetingInfo', type: { name: 'Composite', @@ -382,7 +382,7 @@ export const TeamsMeetingInfo: msRest.CompositeMapper = { }, }; -export const TeamsMeetingDetails: msRest.CompositeMapper = { +export const TeamsMeetingDetails: CompositeMapper = { serializedName: 'TeamsMeetingDetails', type: { name: 'Composite', @@ -434,7 +434,7 @@ export const TeamsMeetingDetails: msRest.CompositeMapper = { }, }; -export const MeetingNotification: msRest.CompositeMapper = { +export const MeetingNotification: CompositeMapper = { serializedName: 'MeetingNotification', type: { name: 'Composite', @@ -485,7 +485,7 @@ export const MeetingNotificationChannelData = { }, }; -export const OnBehalfOf: msRest.CompositeMapper = { +export const OnBehalfOf: CompositeMapper = { serializedName: 'OnBehalfOf', type: { name: 'Composite', @@ -519,7 +519,7 @@ export const OnBehalfOf: msRest.CompositeMapper = { }, }; -export const MeetingNotificationRecipientFailureInfo: msRest.CompositeMapper = { +export const MeetingNotificationRecipientFailureInfo: CompositeMapper = { serializedName: 'MeetingNotificationRecipientFailureInfo', type: { name: 'Composite', @@ -547,7 +547,7 @@ export const MeetingNotificationRecipientFailureInfo: msRest.CompositeMapper = { }, }; -export const MeetingNotificationResponse: msRest.CompositeMapper = { +export const MeetingNotificationResponse: CompositeMapper = { serializedName: 'MeetingNotificationResponse', type: { name: 'Composite', @@ -569,7 +569,7 @@ export const MeetingNotificationResponse: msRest.CompositeMapper = { }, }; -export const CardAction: msRest.CompositeMapper = { +export const CardAction: CompositeMapper = { serializedName: 'CardAction', type: { name: 'Composite', @@ -603,7 +603,7 @@ export const CardAction: msRest.CompositeMapper = { }, }; -export const CardImage: msRest.CompositeMapper = { +export const CardImage: CompositeMapper = { serializedName: 'CardImage', type: { name: 'Composite', @@ -632,7 +632,7 @@ export const CardImage: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardFact: msRest.CompositeMapper = { +export const O365ConnectorCardFact: CompositeMapper = { serializedName: 'O365ConnectorCardFact', type: { name: 'Composite', @@ -654,7 +654,7 @@ export const O365ConnectorCardFact: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardImage: msRest.CompositeMapper = { +export const O365ConnectorCardImage: CompositeMapper = { serializedName: 'O365ConnectorCardImage', type: { name: 'Composite', @@ -676,7 +676,7 @@ export const O365ConnectorCardImage: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardActionBase: msRest.CompositeMapper = { +export const O365ConnectorCardActionBase: CompositeMapper = { serializedName: 'O365ConnectorCardActionBase', type: { name: 'Composite', @@ -704,7 +704,7 @@ export const O365ConnectorCardActionBase: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardSection: msRest.CompositeMapper = { +export const O365ConnectorCardSection: CompositeMapper = { serializedName: 'O365ConnectorCardSection', type: { name: 'Composite', @@ -798,7 +798,7 @@ export const O365ConnectorCardSection: msRest.CompositeMapper = { }, }; -export const O365ConnectorCard: msRest.CompositeMapper = { +export const O365ConnectorCard: CompositeMapper = { serializedName: 'O365ConnectorCard', type: { name: 'Composite', @@ -856,7 +856,7 @@ export const O365ConnectorCard: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardViewAction: msRest.CompositeMapper = { +export const O365ConnectorCardViewAction: CompositeMapper = { serializedName: 'O365ConnectorCardViewAction', type: { name: 'Composite', @@ -878,7 +878,7 @@ export const O365ConnectorCardViewAction: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardOpenUriTarget: msRest.CompositeMapper = { +export const O365ConnectorCardOpenUriTarget: CompositeMapper = { serializedName: 'O365ConnectorCardOpenUriTarget', type: { name: 'Composite', @@ -900,7 +900,7 @@ export const O365ConnectorCardOpenUriTarget: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardOpenUri: msRest.CompositeMapper = { +export const O365ConnectorCardOpenUri: CompositeMapper = { serializedName: 'O365ConnectorCardOpenUri', type: { name: 'Composite', @@ -923,7 +923,7 @@ export const O365ConnectorCardOpenUri: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardHttpPOST: msRest.CompositeMapper = { +export const O365ConnectorCardHttpPOST: CompositeMapper = { serializedName: 'O365ConnectorCardHttpPOST', type: { name: 'Composite', @@ -940,7 +940,7 @@ export const O365ConnectorCardHttpPOST: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardInputBase: msRest.CompositeMapper = { +export const O365ConnectorCardInputBase: CompositeMapper = { serializedName: 'O365ConnectorCardInputBase', type: { name: 'Composite', @@ -980,7 +980,7 @@ export const O365ConnectorCardInputBase: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardActionCard: msRest.CompositeMapper = { +export const O365ConnectorCardActionCard: CompositeMapper = { serializedName: 'O365ConnectorCardActionCard', type: { name: 'Composite', @@ -1015,7 +1015,7 @@ export const O365ConnectorCardActionCard: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardTextInput: msRest.CompositeMapper = { +export const O365ConnectorCardTextInput: CompositeMapper = { serializedName: 'O365ConnectorCardTextInput', type: { name: 'Composite', @@ -1038,7 +1038,7 @@ export const O365ConnectorCardTextInput: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardDateInput: msRest.CompositeMapper = { +export const O365ConnectorCardDateInput: CompositeMapper = { serializedName: 'O365ConnectorCardDateInput', type: { name: 'Composite', @@ -1055,7 +1055,7 @@ export const O365ConnectorCardDateInput: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardMultichoiceInputChoice: msRest.CompositeMapper = { +export const O365ConnectorCardMultichoiceInputChoice: CompositeMapper = { serializedName: 'O365ConnectorCardMultichoiceInputChoice', type: { name: 'Composite', @@ -1077,7 +1077,7 @@ export const O365ConnectorCardMultichoiceInputChoice: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardMultichoiceInput: msRest.CompositeMapper = { +export const O365ConnectorCardMultichoiceInput: CompositeMapper = { serializedName: 'O365ConnectorCardMultichoiceInput', type: { name: 'Composite', @@ -1112,7 +1112,7 @@ export const O365ConnectorCardMultichoiceInput: msRest.CompositeMapper = { }, }; -export const O365ConnectorCardActionQuery: msRest.CompositeMapper = { +export const O365ConnectorCardActionQuery: CompositeMapper = { serializedName: 'O365ConnectorCardActionQuery', type: { name: 'Composite', @@ -1134,7 +1134,7 @@ export const O365ConnectorCardActionQuery: msRest.CompositeMapper = { }, }; -export const SigninStateVerificationQuery: msRest.CompositeMapper = { +export const SigninStateVerificationQuery: CompositeMapper = { serializedName: 'SigninStateVerificationQuery', type: { name: 'Composite', @@ -1150,7 +1150,7 @@ export const SigninStateVerificationQuery: msRest.CompositeMapper = { }, }; -export const MessagingExtensionQueryOptions: msRest.CompositeMapper = { +export const MessagingExtensionQueryOptions: CompositeMapper = { serializedName: 'MessagingExtensionQueryOptions', type: { name: 'Composite', @@ -1172,7 +1172,7 @@ export const MessagingExtensionQueryOptions: msRest.CompositeMapper = { }, }; -export const MessagingExtensionParameter: msRest.CompositeMapper = { +export const MessagingExtensionParameter: CompositeMapper = { serializedName: 'MessagingExtensionParameter', type: { name: 'Composite', @@ -1194,7 +1194,7 @@ export const MessagingExtensionParameter: msRest.CompositeMapper = { }, }; -export const MessagingExtensionQuery: msRest.CompositeMapper = { +export const MessagingExtensionQuery: CompositeMapper = { serializedName: 'MessagingExtensionQuery', type: { name: 'Composite', @@ -1235,7 +1235,7 @@ export const MessagingExtensionQuery: msRest.CompositeMapper = { }, }; -export const Activity: msRest.CompositeMapper = { +export const Activity: CompositeMapper = { serializedName: 'Activity', type: { name: 'Composite', @@ -1257,7 +1257,7 @@ export const Activity: msRest.CompositeMapper = { }, }; -export const MessageActionsPayloadUser: msRest.CompositeMapper = { +export const MessageActionsPayloadUser: CompositeMapper = { serializedName: 'MessageActionsPayloadUser', type: { name: 'Composite', @@ -1285,7 +1285,7 @@ export const MessageActionsPayloadUser: msRest.CompositeMapper = { }, }; -export const MessageActionsPayloadApp: msRest.CompositeMapper = { +export const MessageActionsPayloadApp: CompositeMapper = { serializedName: 'MessageActionsPayloadApp', type: { name: 'Composite', @@ -1313,7 +1313,7 @@ export const MessageActionsPayloadApp: msRest.CompositeMapper = { }, }; -export const MessageActionsPayloadConversation: msRest.CompositeMapper = { +export const MessageActionsPayloadConversation: CompositeMapper = { serializedName: 'MessageActionsPayloadConversation', type: { name: 'Composite', @@ -1341,7 +1341,7 @@ export const MessageActionsPayloadConversation: msRest.CompositeMapper = { }, }; -export const MessageActionsPayloadFrom: msRest.CompositeMapper = { +export const MessageActionsPayloadFrom: CompositeMapper = { serializedName: 'MessageActionsPayloadFrom', type: { name: 'Composite', @@ -1372,7 +1372,7 @@ export const MessageActionsPayloadFrom: msRest.CompositeMapper = { }, }; -export const MessageActionsPayloadBody: msRest.CompositeMapper = { +export const MessageActionsPayloadBody: CompositeMapper = { serializedName: 'MessageActionsPayload_body', type: { name: 'Composite', @@ -1400,7 +1400,7 @@ export const MessageActionsPayloadBody: msRest.CompositeMapper = { }, }; -export const MessageActionsPayloadAttachment: msRest.CompositeMapper = { +export const MessageActionsPayloadAttachment: CompositeMapper = { serializedName: 'MessageActionsPayloadAttachment', type: { name: 'Composite', @@ -1446,7 +1446,7 @@ export const MessageActionsPayloadAttachment: msRest.CompositeMapper = { }, }; -export const MessageActionsPayloadMention: msRest.CompositeMapper = { +export const MessageActionsPayloadMention: CompositeMapper = { serializedName: 'MessageActionsPayloadMention', type: { name: 'Composite', @@ -1475,7 +1475,7 @@ export const MessageActionsPayloadMention: msRest.CompositeMapper = { }, }; -export const MessageActionsPayloadReaction: msRest.CompositeMapper = { +export const MessageActionsPayloadReaction: CompositeMapper = { serializedName: 'MessageActionsPayloadReaction', type: { name: 'Composite', @@ -1504,7 +1504,7 @@ export const MessageActionsPayloadReaction: msRest.CompositeMapper = { }, }; -export const MessageActionsPayload: msRest.CompositeMapper = { +export const MessageActionsPayload: CompositeMapper = { serializedName: 'MessageActionsPayload', type: { name: 'Composite', @@ -1636,7 +1636,7 @@ export const MessageActionsPayload: msRest.CompositeMapper = { }, }; -export const TaskModuleRequest: msRest.CompositeMapper = { +export const TaskModuleRequest: CompositeMapper = { serializedName: 'TaskModuleRequest', type: { name: 'Composite', @@ -1659,7 +1659,7 @@ export const TaskModuleRequest: msRest.CompositeMapper = { }, }; -export const MessagingExtensionAction: msRest.CompositeMapper = { +export const MessagingExtensionAction: CompositeMapper = { serializedName: 'MessagingExtensionAction', type: { name: 'Composite', @@ -1707,7 +1707,7 @@ export const MessagingExtensionAction: msRest.CompositeMapper = { }, }; -export const TaskModuleResponseBase: msRest.CompositeMapper = { +export const TaskModuleResponseBase: CompositeMapper = { serializedName: 'TaskModuleResponseBase', type: { name: 'Composite', @@ -1723,7 +1723,7 @@ export const TaskModuleResponseBase: msRest.CompositeMapper = { }, }; -export const Attachment: msRest.CompositeMapper = { +export const Attachment: CompositeMapper = { serializedName: 'Attachment', type: { name: 'Composite', @@ -1763,7 +1763,7 @@ export const Attachment: msRest.CompositeMapper = { }, }; -export const MessagingExtensionAttachment: msRest.CompositeMapper = { +export const MessagingExtensionAttachment: CompositeMapper = { serializedName: 'MessagingExtensionAttachment', type: { name: 'Composite', @@ -1781,7 +1781,7 @@ export const MessagingExtensionAttachment: msRest.CompositeMapper = { }, }; -export const MessagingExtensionSuggestedAction: msRest.CompositeMapper = { +export const MessagingExtensionSuggestedAction: CompositeMapper = { serializedName: 'MessagingExtensionSuggestedAction', type: { name: 'Composite', @@ -1803,7 +1803,7 @@ export const MessagingExtensionSuggestedAction: msRest.CompositeMapper = { }, }; -export const MessagingExtensionResult: msRest.CompositeMapper = { +export const MessagingExtensionResult: CompositeMapper = { serializedName: 'MessagingExtensionResult', type: { name: 'Composite', @@ -1857,7 +1857,7 @@ export const MessagingExtensionResult: msRest.CompositeMapper = { }, }; -export const CacheInfo: msRest.CompositeMapper = { +export const CacheInfo: CompositeMapper = { serializedName: 'cacheInfo', type: { name: 'Composite', @@ -1879,7 +1879,7 @@ export const CacheInfo: msRest.CompositeMapper = { }, }; -export const MessagingExtensionActionResponse: msRest.CompositeMapper = { +export const MessagingExtensionActionResponse: CompositeMapper = { serializedName: 'MessagingExtensionActionResponse', type: { name: 'Composite', @@ -1910,7 +1910,7 @@ export const MessagingExtensionActionResponse: msRest.CompositeMapper = { }, }; -export const MessagingExtensionResponse: msRest.CompositeMapper = { +export const MessagingExtensionResponse: CompositeMapper = { serializedName: 'MessagingExtensionResponse', type: { name: 'Composite', @@ -1934,7 +1934,7 @@ export const MessagingExtensionResponse: msRest.CompositeMapper = { }, }; -export const FileConsentCard: msRest.CompositeMapper = { +export const FileConsentCard: CompositeMapper = { serializedName: 'FileConsentCard', type: { name: 'Composite', @@ -1968,7 +1968,7 @@ export const FileConsentCard: msRest.CompositeMapper = { }, }; -export const FileDownloadInfo: msRest.CompositeMapper = { +export const FileDownloadInfo: CompositeMapper = { serializedName: 'FileDownloadInfo', type: { name: 'Composite', @@ -2002,7 +2002,7 @@ export const FileDownloadInfo: msRest.CompositeMapper = { }, }; -export const FileInfoCard: msRest.CompositeMapper = { +export const FileInfoCard: CompositeMapper = { serializedName: 'FileInfoCard', type: { name: 'Composite', @@ -2030,7 +2030,7 @@ export const FileInfoCard: msRest.CompositeMapper = { }, }; -export const FileUploadInfo: msRest.CompositeMapper = { +export const FileUploadInfo: CompositeMapper = { serializedName: 'FileUploadInfo', type: { name: 'Composite', @@ -2070,7 +2070,7 @@ export const FileUploadInfo: msRest.CompositeMapper = { }, }; -export const FileConsentCardResponse: msRest.CompositeMapper = { +export const FileConsentCardResponse: CompositeMapper = { serializedName: 'FileConsentCardResponse', type: { name: 'Composite', @@ -2099,7 +2099,7 @@ export const FileConsentCardResponse: msRest.CompositeMapper = { }, }; -export const TaskModuleTaskInfo: msRest.CompositeMapper = { +export const TaskModuleTaskInfo: CompositeMapper = { serializedName: 'TaskModuleTaskInfo', type: { name: 'Composite', @@ -2152,7 +2152,7 @@ export const TaskModuleTaskInfo: msRest.CompositeMapper = { }, }; -export const TaskModuleContinueResponse: msRest.CompositeMapper = { +export const TaskModuleContinueResponse: CompositeMapper = { serializedName: 'TaskModuleContinueResponse', type: { name: 'Composite', @@ -2170,7 +2170,7 @@ export const TaskModuleContinueResponse: msRest.CompositeMapper = { }, }; -export const TaskModuleMessageResponse: msRest.CompositeMapper = { +export const TaskModuleMessageResponse: CompositeMapper = { serializedName: 'TaskModuleMessageResponse', type: { name: 'Composite', @@ -2187,7 +2187,7 @@ export const TaskModuleMessageResponse: msRest.CompositeMapper = { }, }; -export const TaskModuleResponse: msRest.CompositeMapper = { +export const TaskModuleResponse: CompositeMapper = { serializedName: 'TaskModuleResponse', type: { name: 'Composite', @@ -2211,7 +2211,7 @@ export const TaskModuleResponse: msRest.CompositeMapper = { }, }; -export const TaskModuleRequestContext: msRest.CompositeMapper = { +export const TaskModuleRequestContext: CompositeMapper = { serializedName: 'TaskModuleRequest_context', type: { name: 'Composite', @@ -2227,7 +2227,7 @@ export const TaskModuleRequestContext: msRest.CompositeMapper = { }, }; -export const AppBasedLinkQuery: msRest.CompositeMapper = { +export const AppBasedLinkQuery: CompositeMapper = { serializedName: 'AppBasedLinkQuery', type: { name: 'Composite', @@ -2249,7 +2249,7 @@ export const AppBasedLinkQuery: msRest.CompositeMapper = { }, }; -export const BatchOperationRequest: msRest.CompositeMapper = { +export const BatchOperationRequest: CompositeMapper = { serializedName: 'BatchOperationRequest', type: { name: 'Composite', @@ -2312,7 +2312,7 @@ export const BatchOperationRequest: msRest.CompositeMapper = { }, }; -export const BatchOperationResponse: msRest.CompositeMapper = { +export const BatchOperationResponse: CompositeMapper = { serializedName: 'BatchOperationResponse', type: { name: 'Composite', @@ -2328,7 +2328,7 @@ export const BatchOperationResponse: msRest.CompositeMapper = { }, }; -export const GetTeamsOperationStateResponse: msRest.CompositeMapper = { +export const GetTeamsOperationStateResponse: CompositeMapper = { serializedName: 'GetTeamsOperationStateResponse', type: { name: 'Composite', @@ -2367,7 +2367,7 @@ export const GetTeamsOperationStateResponse: msRest.CompositeMapper = { }, }; -export const GetTeamsFailedEntriesResponse: msRest.CompositeMapper = { +export const GetTeamsFailedEntriesResponse: CompositeMapper = { serializedName: 'BatchFailedEntriesResponse', type: { name: 'Composite', @@ -2409,7 +2409,7 @@ export const GetTeamsFailedEntriesResponse: msRest.CompositeMapper = { }, }; -export const TeamsMember: msRest.CompositeMapper = { +export const TeamsMember: CompositeMapper = { serializedName: 'TeamsMember', type: { name: 'Composite', diff --git a/libraries/botframework-connector/src/teams/models/parameters.ts b/libraries/botframework-connector/src/teams/models/parameters.ts index f9bbd68152..4f3e13d646 100644 --- a/libraries/botframework-connector/src/teams/models/parameters.ts +++ b/libraries/botframework-connector/src/teams/models/parameters.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. */ -import * as msRest from '@azure/ms-rest-js'; +import { OperationURLParameter, OperationQueryParameter } from '@azure/core-http'; -export const teamId: msRest.OperationURLParameter = { +export const teamId: OperationURLParameter = { parameterPath: 'teamId', mapper: { required: true, @@ -16,7 +16,7 @@ export const teamId: msRest.OperationURLParameter = { }, }; -export const meetingId: msRest.OperationURLParameter = { +export const meetingId: OperationURLParameter = { parameterPath: 'meetingId', mapper: { required: true, @@ -27,7 +27,7 @@ export const meetingId: msRest.OperationURLParameter = { }, }; -export const participantId: msRest.OperationURLParameter = { +export const participantId: OperationURLParameter = { parameterPath: 'participantId', mapper: { required: true, @@ -38,7 +38,7 @@ export const participantId: msRest.OperationURLParameter = { }, }; -export const tenantId: msRest.OperationQueryParameter = { +export const tenantId: OperationQueryParameter = { parameterPath: ['options', 'tenantId'], mapper: { serializedName: 'tenantId', @@ -48,7 +48,7 @@ export const tenantId: msRest.OperationQueryParameter = { }, }; -export const operationId: msRest.OperationURLParameter = { +export const operationId: OperationURLParameter = { parameterPath: 'operationId', mapper: { serializedName: 'operationId', diff --git a/libraries/botframework-connector/src/teams/operations/teams.ts b/libraries/botframework-connector/src/teams/operations/teams.ts index 4ffee4d8dd..b3942c889b 100644 --- a/libraries/botframework-connector/src/teams/operations/teams.ts +++ b/libraries/botframework-connector/src/teams/operations/teams.ts @@ -4,7 +4,7 @@ * Licensed under the MIT License. */ -import * as msRest from '@azure/ms-rest-js'; +import { ServiceCallback, RequestOptionsBase, Serializer, OperationSpec } from '@azure/core-http' import * as Models from '../models'; import * as Mappers from '../models/teamsMappers'; import * as Parameters from '../models/parameters'; @@ -47,7 +47,7 @@ export class Teams { */ fetchChannelList( teamId: string, - options?: msRest.RequestOptionsBase + options?: RequestOptionsBase ): Promise; /** * Fetches channel list for a given team. @@ -55,7 +55,7 @@ export class Teams { * @param teamId Team Id. * @param callback The callback. */ - fetchChannelList(teamId: string, callback: msRest.ServiceCallback): void; + fetchChannelList(teamId: string, callback: ServiceCallback): void; /** * Fetches channel list for a given team. * @@ -65,8 +65,8 @@ export class Teams { */ fetchChannelList( teamId: string, - options: msRest.RequestOptionsBase, - callback: msRest.ServiceCallback + options: RequestOptionsBase, + callback: ServiceCallback ): void; /** * Fetches channel list for a given team. @@ -78,8 +78,8 @@ export class Teams { */ fetchChannelList( teamId: string, - options?: msRest.RequestOptionsBase | msRest.ServiceCallback, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase | ServiceCallback, + callback?: ServiceCallback ): Promise { return this.client.sendOperationRequest( { @@ -100,7 +100,7 @@ export class Teams { */ fetchTeamDetails( teamId: string, - options?: msRest.RequestOptionsBase + options?: RequestOptionsBase ): Promise; /** * Fetches details related to a team. @@ -108,7 +108,7 @@ export class Teams { * @param teamId Team Id. * @param callback The callback. */ - fetchTeamDetails(teamId: string, callback: msRest.ServiceCallback): void; + fetchTeamDetails(teamId: string, callback: ServiceCallback): void; /** * Fetches details related to a team. * @@ -118,8 +118,8 @@ export class Teams { */ fetchTeamDetails( teamId: string, - options: msRest.RequestOptionsBase, - callback: msRest.ServiceCallback + options: RequestOptionsBase, + callback: ServiceCallback ): void; /** * Fetches details related to a team. @@ -131,8 +131,8 @@ export class Teams { */ fetchTeamDetails( teamId: string, - options?: msRest.RequestOptionsBase | msRest.ServiceCallback, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase | ServiceCallback, + callback?: ServiceCallback ): Promise { return this.client.sendOperationRequest( { @@ -166,7 +166,7 @@ export class Teams { fetchMeetingParticipant( meetingId: string, participantId: string, - callback: msRest.ServiceCallback + callback: ServiceCallback ): void; /** * @param meetingId Meeting Id @@ -178,7 +178,7 @@ export class Teams { meetingId: string, participantId: string, options: Models.TeamsFetchMeetingParticipantOptionalParams, - callback: msRest.ServiceCallback + callback: ServiceCallback ): void; /** * @param meetingId Meeting Id. @@ -190,8 +190,8 @@ export class Teams { fetchMeetingParticipant( meetingId: string, participantId: string, - options?: Models.TeamsFetchMeetingParticipantOptionalParams | msRest.ServiceCallback, - callback?: msRest.ServiceCallback + options?: Models.TeamsFetchMeetingParticipantOptionalParams | ServiceCallback, + callback?: ServiceCallback ): Promise { return this.client.sendOperationRequest( { @@ -214,7 +214,7 @@ export class Teams { */ fetchMeetingInfo( meetingId: string, - options?: msRest.RequestOptionsBase | msRest.ServiceCallback + options?: RequestOptionsBase | ServiceCallback ): Promise; /** * @param meetingId Meeting Id, encoded as a BASE64 string. @@ -222,7 +222,7 @@ export class Teams { */ fetchMeetingInfo( meetingId: string, - callback: msRest.ServiceCallback + callback: ServiceCallback ): void; /** * @param meetingId Meeting Id, encoded as a BASE64 string. @@ -231,8 +231,8 @@ export class Teams { */ fetchMeetingInfo( meetingId: string, - options: msRest.RequestOptionsBase | msRest.ServiceCallback, - callback: msRest.ServiceCallback + options: RequestOptionsBase | ServiceCallback, + callback: ServiceCallback ): void; /** * @param meetingId Meeting Id. @@ -242,8 +242,8 @@ export class Teams { */ fetchMeetingInfo( meetingId: string, - options?: msRest.RequestOptionsBase | msRest.ServiceCallback, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase | ServiceCallback, + callback?: ServiceCallback ): Promise { return this.client.sendOperationRequest( { @@ -265,7 +265,7 @@ export class Teams { sendMeetingNotification( meetingId: string, notification: MeetingNotification, - options?: msRest.RequestOptionsBase, + options?: RequestOptionsBase, ): Promise /** * @param meetingId Meeting Id. @@ -275,7 +275,7 @@ export class Teams { sendMeetingNotification( meetingId: string, notification: MeetingNotification, - callback: msRest.ServiceCallback + callback: ServiceCallback ): void; /** * @param meetingId Meeting Id. @@ -286,8 +286,8 @@ export class Teams { sendMeetingNotification( meetingId: string, notification: MeetingNotification, - options: msRest.RequestOptionsBase, - callback: msRest.ServiceCallback + options: RequestOptionsBase, + callback: ServiceCallback ): void; /** * @param meetingId Meeting Id. @@ -299,8 +299,8 @@ export class Teams { sendMeetingNotification( meetingId: string, notification: MeetingNotification, - options?: msRest.RequestOptionsBase, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase, + callback?: ServiceCallback ): Promise { return this.client.sendOperationRequest( { @@ -328,8 +328,8 @@ export class Teams { activity: Activity, tenantId: string, members: TeamsMember[], - options?: msRest.RequestOptionsBase, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase, + callback?: ServiceCallback ): Promise { const content = { activity, @@ -358,8 +358,8 @@ export class Teams { sendMessageToAllUsersInTenant( activity: Activity, tenantId: string, - options?: msRest.RequestOptionsBase, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase, + callback?: ServiceCallback ): Promise { const content = { activity, @@ -389,8 +389,8 @@ export class Teams { activity: Activity, tenantId: string, teamId: string, - options?: msRest.RequestOptionsBase, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase, + callback?: ServiceCallback ): Promise { const content = { activity, @@ -421,8 +421,8 @@ export class Teams { activity: Activity, tenantId: string, members: TeamsMember[], - options?: msRest.RequestOptionsBase, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase, + callback?: ServiceCallback ): Promise { const content = { activity, @@ -449,8 +449,8 @@ export class Teams { */ getOperationState( operationId: string, - options?: msRest.RequestOptionsBase, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase, + callback?: ServiceCallback ): Promise { return retryAction(() => this.client.sendOperationRequest( { @@ -472,8 +472,8 @@ export class Teams { */ getOperationFailedEntries( operationId: string, - options?: msRest.RequestOptionsBase, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase, + callback?: ServiceCallback ): Promise { return retryAction(() => this.client.sendOperationRequest( { @@ -494,7 +494,7 @@ export class Teams { */ cancelOperation( operationId: string, - options?: msRest.RequestOptionsBase, + options?: RequestOptionsBase, ): Promise { return retryAction(() => this.client.sendOperationRequest( { @@ -507,8 +507,8 @@ export class Teams { } // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const fetchChannelListOperationSpec: msRest.OperationSpec = { +const serializer = new Serializer(Mappers); +const fetchChannelListOperationSpec: OperationSpec = { httpMethod: 'GET', path: 'v3/teams/{teamId}/conversations', urlParameters: [Parameters.teamId], @@ -521,7 +521,7 @@ const fetchChannelListOperationSpec: msRest.OperationSpec = { serializer, }; -const fetchTeamDetailsOperationSpec: msRest.OperationSpec = { +const fetchTeamDetailsOperationSpec: OperationSpec = { httpMethod: 'GET', path: 'v3/teams/{teamId}', urlParameters: [Parameters.teamId], @@ -534,7 +534,7 @@ const fetchTeamDetailsOperationSpec: msRest.OperationSpec = { serializer, }; -const fetchMeetingParticipantOperationSpec: msRest.OperationSpec = { +const fetchMeetingParticipantOperationSpec: OperationSpec = { httpMethod: 'GET', path: 'v1/meetings/{meetingId}/participants/{participantId}', urlParameters: [Parameters.meetingId, Parameters.participantId], @@ -548,7 +548,7 @@ const fetchMeetingParticipantOperationSpec: msRest.OperationSpec = { serializer, }; -const fetchMeetingInfoOperationSpec: msRest.OperationSpec = { +const fetchMeetingInfoOperationSpec: OperationSpec = { httpMethod: 'GET', path: 'v1/meetings/{meetingId}', urlParameters: [Parameters.meetingId], @@ -561,7 +561,7 @@ const fetchMeetingInfoOperationSpec: msRest.OperationSpec = { serializer, }; -const sendMeetingNotificationOperationSpec: msRest.OperationSpec = { +const sendMeetingNotificationOperationSpec: OperationSpec = { httpMethod: 'POST', path: 'v1/meetings/{meetingId}/notification', urlParameters: [Parameters.meetingId], @@ -586,7 +586,7 @@ const sendMeetingNotificationOperationSpec: msRest.OperationSpec = { serializer } -const sendMessageToListOfUsersOperationSpec: msRest.OperationSpec = { +const sendMessageToListOfUsersOperationSpec: OperationSpec = { httpMethod: 'POST', path: 'v3/batch/conversation/users', requestBody: { @@ -607,7 +607,7 @@ const sendMessageToListOfUsersOperationSpec: msRest.OperationSpec = { serializer } -const sendMessageToAllUsersInTenantOperationSpec: msRest.OperationSpec = { +const sendMessageToAllUsersInTenantOperationSpec: OperationSpec = { httpMethod: 'POST', path: 'v3/batch/conversation/tenant', requestBody: { @@ -628,7 +628,7 @@ const sendMessageToAllUsersInTenantOperationSpec: msRest.OperationSpec = { serializer } -const sendMessageToAllUsersInTeamOperationSpec: msRest.OperationSpec = { +const sendMessageToAllUsersInTeamOperationSpec: OperationSpec = { httpMethod: 'POST', path: 'v3/batch/conversation/team', requestBody: { @@ -649,7 +649,7 @@ const sendMessageToAllUsersInTeamOperationSpec: msRest.OperationSpec = { serializer } -const sendMessageToListOfChannelsOperationSpec: msRest.OperationSpec = { +const sendMessageToListOfChannelsOperationSpec: OperationSpec = { httpMethod: 'POST', path: 'v3/batch/conversation/channels', requestBody: { @@ -670,7 +670,7 @@ const sendMessageToListOfChannelsOperationSpec: msRest.OperationSpec = { serializer } -const getOperationStateSpec: msRest.OperationSpec = { +const getOperationStateSpec: OperationSpec = { httpMethod: 'GET', path: 'v3/batch/conversation/{operationId}', urlParameters: [Parameters.operationId], @@ -685,7 +685,7 @@ const getOperationStateSpec: msRest.OperationSpec = { serializer, }; -const getPagedFailedEntriesSpec: msRest.OperationSpec = { +const getPagedFailedEntriesSpec: OperationSpec = { httpMethod: 'GET', path: 'v3/batch/conversation/failedentries/{operationId}', urlParameters: [Parameters.operationId], @@ -700,7 +700,7 @@ const getPagedFailedEntriesSpec: msRest.OperationSpec = { serializer, }; -const cancelOperationSpec: msRest.OperationSpec = { +const cancelOperationSpec: OperationSpec = { httpMethod: 'DELETE', path: 'v3/batch/conversation/{operationId}', urlParameters: [Parameters.operationId], diff --git a/libraries/botframework-connector/src/teams/teamsConnectorClient.ts b/libraries/botframework-connector/src/teams/teamsConnectorClient.ts index a11c08f4ec..dcfff5a484 100644 --- a/libraries/botframework-connector/src/teams/teamsConnectorClient.ts +++ b/libraries/botframework-connector/src/teams/teamsConnectorClient.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -import { ServiceClientCredentials } from '@azure/ms-rest-js'; +import { ServiceClientCredentials } from '@azure/core-http'; import * as Models from './models'; import * as Mappers from './models/mappers'; import * as operations from './operations'; diff --git a/libraries/botframework-connector/src/teams/teamsConnectorClientContext.ts b/libraries/botframework-connector/src/teams/teamsConnectorClientContext.ts index 068ec3800b..d1ea5a6d3e 100644 --- a/libraries/botframework-connector/src/teams/teamsConnectorClientContext.ts +++ b/libraries/botframework-connector/src/teams/teamsConnectorClientContext.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -import { ServiceClientCredentials, ServiceClient } from '@azure/ms-rest-js'; +import { ServiceClientCredentials, ServiceClient } from '@azure/core-http'; import { TeamsConnectorClientOptions } from './models'; /** diff --git a/libraries/botframework-connector/src/tokenApi/models/index.ts b/libraries/botframework-connector/src/tokenApi/models/index.ts index 6c6f22d885..687310d099 100644 --- a/libraries/botframework-connector/src/tokenApi/models/index.ts +++ b/libraries/botframework-connector/src/tokenApi/models/index.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. */ -import { ServiceClientOptions } from "@azure/ms-rest-js"; -import * as msRest from "@azure/ms-rest-js"; +import { ServiceClientOptions, RequestOptionsBase, HttpResponse } from "@azure/core-http"; import { SignInUrlResponse, TokenResponse, TokenStatus } from "botframework-schema"; /** @@ -82,7 +81,7 @@ export interface TokenApiClientOptions extends ServiceClientOptions { * * @extends RequestOptionsBase */ -export interface BotSignInGetSignInUrlOptionalParams extends msRest.RequestOptionsBase { +export interface BotSignInGetSignInUrlOptionalParams extends RequestOptionsBase { /** * @member {string} [codeChallenge] */ @@ -104,7 +103,7 @@ export interface BotSignInGetSignInUrlOptionalParams extends msRest.RequestOptio * * @extends RequestOptionsBase */ -export interface BotSignInGetSignInResourceOptionalParams extends msRest.RequestOptionsBase { +export interface BotSignInGetSignInResourceOptionalParams extends RequestOptionsBase { /** * @member {string} [codeChallenge] */ @@ -126,7 +125,7 @@ export interface BotSignInGetSignInResourceOptionalParams extends msRest.Request * * @extends RequestOptionsBase */ -export interface UserTokenGetTokenOptionalParams extends msRest.RequestOptionsBase { +export interface UserTokenGetTokenOptionalParams extends RequestOptionsBase { /** * @member {string} [channelId] */ @@ -144,7 +143,7 @@ export interface UserTokenGetTokenOptionalParams extends msRest.RequestOptionsBa * * @extends RequestOptionsBase */ -export interface UserTokenGetAadTokensOptionalParams extends msRest.RequestOptionsBase { +export interface UserTokenGetAadTokensOptionalParams extends RequestOptionsBase { /** * @member {string} [channelId] */ @@ -158,7 +157,7 @@ export interface UserTokenGetAadTokensOptionalParams extends msRest.RequestOptio * * @extends RequestOptionsBase */ -export interface UserTokenSignOutOptionalParams extends msRest.RequestOptionsBase { +export interface UserTokenSignOutOptionalParams extends RequestOptionsBase { /** * @member {string} [connectionName] */ @@ -176,7 +175,7 @@ export interface UserTokenSignOutOptionalParams extends msRest.RequestOptionsBas * * @extends RequestOptionsBase */ -export interface UserTokenGetTokenStatusOptionalParams extends msRest.RequestOptionsBase { +export interface UserTokenGetTokenStatusOptionalParams extends RequestOptionsBase { /** * @member {string} [channelId] */ @@ -198,16 +197,16 @@ export type BotSignInGetSignInUrlResponse = { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: string; - }; + _response: HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: string; + }; }; /** @@ -217,16 +216,16 @@ export type BotSignInGetSignInResourceResponse = SignInUrlResponse & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: SignInUrlResponse; - }; + _response: HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: SignInUrlResponse; + }; }; /** @@ -236,16 +235,16 @@ export type UserTokenGetTokenResponse = TokenResponse & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: TokenResponse; - }; + _response: HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: TokenResponse; + }; }; /** @@ -260,16 +259,16 @@ export type UserTokenGetAadTokensResponse = { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: { [propertyName: string]: TokenResponse }; - }; + _response: HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: { [propertyName: string]: TokenResponse }; + }; }; /** @@ -283,16 +282,16 @@ export type UserTokenSignOutResponse = { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: any; - }; + _response: HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: any; + }; }; /** @@ -302,16 +301,16 @@ export type UserTokenGetTokenStatusResponse = Array & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: TokenStatus[]; - }; + _response: HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: TokenStatus[]; + }; }; /** @@ -325,14 +324,14 @@ export type UserTokenExchangeAsyncResponse = { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - /** - * The response body as parsed JSON or XML - */ - parsedBody: any; - }; + _response: HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: any; + }; }; diff --git a/libraries/botframework-connector/src/tokenApi/models/mappers.ts b/libraries/botframework-connector/src/tokenApi/models/mappers.ts index 9a84c712b7..a92d719ecf 100644 --- a/libraries/botframework-connector/src/tokenApi/models/mappers.ts +++ b/libraries/botframework-connector/src/tokenApi/models/mappers.ts @@ -3,10 +3,9 @@ * Licensed under the MIT License. */ -import * as msRest from "@azure/ms-rest-js"; +import { CompositeMapper } from "@azure/core-http"; - -export const TokenExchangeResource: msRest.CompositeMapper = { +export const TokenExchangeResource: CompositeMapper = { serializedName: "TokenExchangeResource", type: { name: "Composite", @@ -34,7 +33,7 @@ export const TokenExchangeResource: msRest.CompositeMapper = { } }; -export const SignInUrlResponse: msRest.CompositeMapper = { +export const SignInUrlResponse: CompositeMapper = { serializedName: "SignInUrlResponse", type: { name: "Composite", @@ -57,7 +56,7 @@ export const SignInUrlResponse: msRest.CompositeMapper = { } }; -export const TokenResponse: msRest.CompositeMapper = { +export const TokenResponse: CompositeMapper = { serializedName: "TokenResponse", type: { name: "Composite", @@ -91,7 +90,7 @@ export const TokenResponse: msRest.CompositeMapper = { } }; -export const InnerHttpError: msRest.CompositeMapper = { +export const InnerHttpError: CompositeMapper = { serializedName: "InnerHttpError", type: { name: "Composite", @@ -113,7 +112,7 @@ export const InnerHttpError: msRest.CompositeMapper = { } }; -export const ErrorModel: msRest.CompositeMapper = { +export const ErrorModel: CompositeMapper = { serializedName: "Error", type: { name: "Composite", @@ -142,7 +141,7 @@ export const ErrorModel: msRest.CompositeMapper = { } }; -export const ErrorResponse: msRest.CompositeMapper = { +export const ErrorResponse: CompositeMapper = { serializedName: "ErrorResponse", type: { name: "Composite", @@ -159,7 +158,7 @@ export const ErrorResponse: msRest.CompositeMapper = { } }; -export const AadResourceUrls: msRest.CompositeMapper = { +export const AadResourceUrls: CompositeMapper = { serializedName: "AadResourceUrls", type: { name: "Composite", @@ -180,7 +179,7 @@ export const AadResourceUrls: msRest.CompositeMapper = { } }; -export const TokenStatus: msRest.CompositeMapper = { +export const TokenStatus: CompositeMapper = { serializedName: "TokenStatus", type: { name: "Composite", @@ -214,7 +213,7 @@ export const TokenStatus: msRest.CompositeMapper = { } }; -export const TokenExchangeRequest: msRest.CompositeMapper = { +export const TokenExchangeRequest: CompositeMapper = { serializedName: "TokenExchangeRequest", type: { name: "Composite", diff --git a/libraries/botframework-connector/src/tokenApi/models/parameters.ts b/libraries/botframework-connector/src/tokenApi/models/parameters.ts index 97972ea8dd..f6c3a94800 100644 --- a/libraries/botframework-connector/src/tokenApi/models/parameters.ts +++ b/libraries/botframework-connector/src/tokenApi/models/parameters.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. */ -import * as msRest from "@azure/ms-rest-js"; +import { OperationQueryParameter } from "@azure/core-http" -export const channelId0: msRest.OperationQueryParameter = { +export const channelId0: OperationQueryParameter = { parameterPath: [ "options", "channelId" @@ -17,7 +17,7 @@ export const channelId0: msRest.OperationQueryParameter = { } } }; -export const channelId1: msRest.OperationQueryParameter = { +export const channelId1: OperationQueryParameter = { parameterPath: "channelId", mapper: { required: true, @@ -27,7 +27,7 @@ export const channelId1: msRest.OperationQueryParameter = { } } }; -export const code: msRest.OperationQueryParameter = { +export const code: OperationQueryParameter = { parameterPath: [ "options", "code" @@ -39,7 +39,7 @@ export const code: msRest.OperationQueryParameter = { } } }; -export const codeChallenge: msRest.OperationQueryParameter = { +export const codeChallenge: OperationQueryParameter = { parameterPath: [ "options", "codeChallenge" @@ -51,7 +51,7 @@ export const codeChallenge: msRest.OperationQueryParameter = { } } }; -export const connectionName0: msRest.OperationQueryParameter = { +export const connectionName0: OperationQueryParameter = { parameterPath: "connectionName", mapper: { required: true, @@ -61,7 +61,7 @@ export const connectionName0: msRest.OperationQueryParameter = { } } }; -export const connectionName1: msRest.OperationQueryParameter = { +export const connectionName1: OperationQueryParameter = { parameterPath: [ "options", "connectionName" @@ -73,7 +73,7 @@ export const connectionName1: msRest.OperationQueryParameter = { } } }; -export const emulatorUrl: msRest.OperationQueryParameter = { +export const emulatorUrl: OperationQueryParameter = { parameterPath: [ "options", "emulatorUrl" @@ -85,7 +85,7 @@ export const emulatorUrl: msRest.OperationQueryParameter = { } } }; -export const finalRedirect: msRest.OperationQueryParameter = { +export const finalRedirect: OperationQueryParameter = { parameterPath: [ "options", "finalRedirect" @@ -97,7 +97,7 @@ export const finalRedirect: msRest.OperationQueryParameter = { } } }; -export const include: msRest.OperationQueryParameter = { +export const include: OperationQueryParameter = { parameterPath: [ "options", "include" @@ -109,7 +109,7 @@ export const include: msRest.OperationQueryParameter = { } } }; -export const state: msRest.OperationQueryParameter = { +export const state: OperationQueryParameter = { parameterPath: "state", mapper: { required: true, @@ -119,7 +119,7 @@ export const state: msRest.OperationQueryParameter = { } } }; -export const userId: msRest.OperationQueryParameter = { +export const userId: OperationQueryParameter = { parameterPath: "userId", mapper: { required: true, diff --git a/libraries/botframework-connector/src/tokenApi/operations/botSignIn.ts b/libraries/botframework-connector/src/tokenApi/operations/botSignIn.ts index 4c91abc844..f35b18984e 100644 --- a/libraries/botframework-connector/src/tokenApi/operations/botSignIn.ts +++ b/libraries/botframework-connector/src/tokenApi/operations/botSignIn.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -import * as msRest from "@azure/ms-rest-js"; +import { ServiceCallback, Serializer, OperationSpec } from "@azure/core-http"; import * as Models from "../models"; import * as Mappers from "../models/botSignInMappers"; import * as Parameters from "../models/parameters"; @@ -32,14 +32,14 @@ export class BotSignIn { * @param state * @param callback The callback */ - getSignInUrl(state: string, callback: msRest.ServiceCallback): void; + getSignInUrl(state: string, callback: ServiceCallback): void; /** * @param state * @param options The optional parameters * @param callback The callback */ - getSignInUrl(state: string, options: Models.BotSignInGetSignInUrlOptionalParams, callback: msRest.ServiceCallback): void; - getSignInUrl(state: string, options?: Models.BotSignInGetSignInUrlOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getSignInUrl(state: string, options: Models.BotSignInGetSignInUrlOptionalParams, callback: ServiceCallback): void; + getSignInUrl(state: string, options?: Models.BotSignInGetSignInUrlOptionalParams | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { state, @@ -59,14 +59,14 @@ export class BotSignIn { * @param state * @param callback The callback */ - getSignInResource(state: string, callback: msRest.ServiceCallback): void; + getSignInResource(state: string, callback: ServiceCallback): void; /** * @param state * @param options The optional parameters * @param callback The callback */ - getSignInResource(state: string, options: Models.BotSignInGetSignInResourceOptionalParams, callback: msRest.ServiceCallback): void; - getSignInResource(state: string, options?: Models.BotSignInGetSignInResourceOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getSignInResource(state: string, options: Models.BotSignInGetSignInResourceOptionalParams, callback: ServiceCallback): void; + getSignInResource(state: string, options?: Models.BotSignInGetSignInResourceOptionalParams | ServiceCallback, callback?: ServiceCallback): Promise { return this.client.sendOperationRequest( { state, @@ -78,8 +78,8 @@ export class BotSignIn { } // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const getSignInUrlOperationSpec: msRest.OperationSpec = { +const serializer = new Serializer(Mappers); +const getSignInUrlOperationSpec: OperationSpec = { httpMethod: "GET", path: "api/botsignin/GetSignInUrl", queryParameters: [ @@ -102,7 +102,7 @@ const getSignInUrlOperationSpec: msRest.OperationSpec = { serializer }; -const getSignInResourceOperationSpec: msRest.OperationSpec = { +const getSignInResourceOperationSpec: OperationSpec = { httpMethod: "GET", path: "api/botsignin/GetSignInResource", queryParameters: [ diff --git a/libraries/botframework-connector/src/tokenApi/operations/userToken.ts b/libraries/botframework-connector/src/tokenApi/operations/userToken.ts index 7505223ca8..4eba5a3b39 100644 --- a/libraries/botframework-connector/src/tokenApi/operations/userToken.ts +++ b/libraries/botframework-connector/src/tokenApi/operations/userToken.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -import * as msRest from '@azure/ms-rest-js'; +import { ServiceCallback, RequestOptionsBase, Serializer, OperationSpec } from '@azure/core-http'; import * as Models from '../models'; import * as Mappers from '../models/userTokenMappers'; import * as Parameters from '../models/parameters'; @@ -39,7 +39,7 @@ export class UserToken { * @param connectionName * @param callback The callback */ - getToken(userId: string, connectionName: string, callback: msRest.ServiceCallback): void; + getToken(userId: string, connectionName: string, callback: ServiceCallback): void; /** * @param userId * @param connectionName @@ -50,13 +50,13 @@ export class UserToken { userId: string, connectionName: string, options: Models.UserTokenGetTokenOptionalParams, - callback: msRest.ServiceCallback + callback: ServiceCallback ): void; getToken( userId: string, connectionName: string, - options?: Models.UserTokenGetTokenOptionalParams | msRest.ServiceCallback, - callback?: msRest.ServiceCallback + options?: Models.UserTokenGetTokenOptionalParams | ServiceCallback, + callback?: ServiceCallback ): Promise { return this.client.sendOperationRequest( { @@ -92,7 +92,7 @@ export class UserToken { userId: string, connectionName: string, aadResourceUrls: Models.AadResourceUrls, - callback: msRest.ServiceCallback<{ [propertyName: string]: TokenResponse }> + callback: ServiceCallback<{ [propertyName: string]: TokenResponse }> ): void; /** * @param userId @@ -106,7 +106,7 @@ export class UserToken { connectionName: string, aadResourceUrls: Models.AadResourceUrls, options: Models.UserTokenGetAadTokensOptionalParams, - callback: msRest.ServiceCallback<{ [propertyName: string]: TokenResponse }> + callback: ServiceCallback<{ [propertyName: string]: TokenResponse }> ): void; getAadTokens( userId: string, @@ -114,8 +114,8 @@ export class UserToken { aadResourceUrls: Models.AadResourceUrls, options?: | Models.UserTokenGetAadTokensOptionalParams - | msRest.ServiceCallback<{ [propertyName: string]: TokenResponse }>, - callback?: msRest.ServiceCallback<{ [propertyName: string]: TokenResponse }> + | ServiceCallback<{ [propertyName: string]: TokenResponse }>, + callback?: ServiceCallback<{ [propertyName: string]: TokenResponse }> ): Promise { return this.client.sendOperationRequest( { @@ -139,7 +139,7 @@ export class UserToken { * @param userId * @param callback The callback */ - signOut(userId: string, callback: msRest.ServiceCallback): void; + signOut(userId: string, callback: ServiceCallback): void; /** * @param userId * @param options The optional parameters @@ -148,12 +148,12 @@ export class UserToken { signOut( userId: string, options: Models.UserTokenSignOutOptionalParams, - callback: msRest.ServiceCallback + callback: ServiceCallback ): void; signOut( userId: string, - options?: Models.UserTokenSignOutOptionalParams | msRest.ServiceCallback, - callback?: msRest.ServiceCallback + options?: Models.UserTokenSignOutOptionalParams | ServiceCallback, + callback?: ServiceCallback ): Promise { return this.client.sendOperationRequest( { @@ -178,7 +178,7 @@ export class UserToken { * @param userId * @param callback The callback */ - getTokenStatus(userId: string, callback: msRest.ServiceCallback): void; + getTokenStatus(userId: string, callback: ServiceCallback): void; /** * @param userId * @param options The optional parameters @@ -187,12 +187,12 @@ export class UserToken { getTokenStatus( userId: string, options: Models.UserTokenGetTokenStatusOptionalParams, - callback: msRest.ServiceCallback + callback: ServiceCallback ): void; getTokenStatus( userId: string, - options?: Models.UserTokenGetTokenStatusOptionalParams | msRest.ServiceCallback, - callback?: msRest.ServiceCallback + options?: Models.UserTokenGetTokenStatusOptionalParams | ServiceCallback, + callback?: ServiceCallback ): Promise { return this.client.sendOperationRequest( { @@ -217,7 +217,7 @@ export class UserToken { connectionName: string, channelId: string, exchangeRequest: TokenExchangeRequest, - options?: msRest.RequestOptionsBase + options?: RequestOptionsBase ): Promise; /** * @param userId @@ -231,7 +231,7 @@ export class UserToken { connectionName: string, channelId: string, exchangeRequest: TokenExchangeRequest, - callback: msRest.ServiceCallback + callback: ServiceCallback ): void; /** * @param userId @@ -246,16 +246,16 @@ export class UserToken { connectionName: string, channelId: string, exchangeRequest: TokenExchangeRequest, - options: msRest.RequestOptionsBase, - callback: msRest.ServiceCallback + options: RequestOptionsBase, + callback: ServiceCallback ): void; exchangeAsync( userId: string, connectionName: string, channelId: string, exchangeRequest: TokenExchangeRequest, - options?: msRest.RequestOptionsBase | msRest.ServiceCallback, - callback?: msRest.ServiceCallback + options?: RequestOptionsBase | ServiceCallback, + callback?: ServiceCallback ): Promise { return this.client.sendOperationRequest( { @@ -272,8 +272,8 @@ export class UserToken { } // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const getTokenOperationSpec: msRest.OperationSpec = { +const serializer = new Serializer(Mappers); +const getTokenOperationSpec: OperationSpec = { httpMethod: 'GET', path: 'api/usertoken/GetToken', queryParameters: [Parameters.userId, Parameters.connectionName0, Parameters.channelId0, Parameters.code], @@ -291,7 +291,7 @@ const getTokenOperationSpec: msRest.OperationSpec = { serializer, }; -const getAadTokensOperationSpec: msRest.OperationSpec = { +const getAadTokensOperationSpec: OperationSpec = { httpMethod: 'POST', path: 'api/usertoken/GetAadTokens', queryParameters: [Parameters.userId, Parameters.connectionName0, Parameters.channelId0], @@ -324,7 +324,7 @@ const getAadTokensOperationSpec: msRest.OperationSpec = { serializer, }; -const signOutOperationSpec: msRest.OperationSpec = { +const signOutOperationSpec: OperationSpec = { httpMethod: 'DELETE', path: 'api/usertoken/SignOut', queryParameters: [Parameters.userId, Parameters.connectionName1, Parameters.channelId0], @@ -345,7 +345,7 @@ const signOutOperationSpec: msRest.OperationSpec = { serializer, }; -const getTokenStatusOperationSpec: msRest.OperationSpec = { +const getTokenStatusOperationSpec: OperationSpec = { httpMethod: 'GET', path: 'api/usertoken/GetTokenStatus', queryParameters: [Parameters.userId, Parameters.channelId0, Parameters.include], @@ -371,7 +371,7 @@ const getTokenStatusOperationSpec: msRest.OperationSpec = { serializer, }; -const exchangeAsyncOperationSpec: msRest.OperationSpec = { +const exchangeAsyncOperationSpec: OperationSpec = { httpMethod: 'POST', path: 'api/usertoken/exchange', queryParameters: [Parameters.userId, Parameters.connectionName0, Parameters.channelId1], diff --git a/libraries/botframework-connector/src/tokenApi/tokenApiClient.ts b/libraries/botframework-connector/src/tokenApi/tokenApiClient.ts index 94f996f5bc..4c432d20e4 100644 --- a/libraries/botframework-connector/src/tokenApi/tokenApiClient.ts +++ b/libraries/botframework-connector/src/tokenApi/tokenApiClient.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -import * as msRest from "@azure/ms-rest-js"; +import { ServiceClientCredentials } from "@azure/core-http"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; import * as operations from "./operations"; @@ -19,7 +19,7 @@ class TokenApiClient extends TokenApiClientContext { * @param credentials Subscription credentials which uniquely identify client subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.TokenApiClientOptions) { + constructor(credentials: ServiceClientCredentials, options?: Models.TokenApiClientOptions) { super(credentials, options); this.botSignIn = new operations.BotSignIn(this); this.userToken = new operations.UserToken(this); diff --git a/libraries/botframework-connector/src/tokenApi/tokenApiClientContext.ts b/libraries/botframework-connector/src/tokenApi/tokenApiClientContext.ts index 5a04fd5cd0..664008e07f 100644 --- a/libraries/botframework-connector/src/tokenApi/tokenApiClientContext.ts +++ b/libraries/botframework-connector/src/tokenApi/tokenApiClientContext.ts @@ -3,18 +3,18 @@ * Licensed under the MIT License. */ -import * as msRest from "@azure/ms-rest-js"; +import { ServiceClient, ServiceClientCredentials, getDefaultUserAgentValue } from "@azure/core-http"; import * as Models from "./models"; const packageName = "botframework-Token"; const packageVersion = "4.0.0"; -export class TokenApiClientContext extends msRest.ServiceClient { - credentials: msRest.ServiceClientCredentials; +export class TokenApiClientContext extends ServiceClient { + credentials: ServiceClientCredentials; // Protects against JSON.stringify leaking secrets private toJSON(): unknown { - return { name: this.constructor.name }; + return { name: this.constructor.name }; } /** @@ -22,7 +22,7 @@ export class TokenApiClientContext extends msRest.ServiceClient { * @param credentials Subscription credentials which uniquely identify client subscription. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.TokenApiClientOptions) { + constructor(credentials: ServiceClientCredentials, options?: Models.TokenApiClientOptions) { if (credentials === null || credentials === undefined) { throw new Error('\'credentials\' cannot be null.'); } @@ -30,7 +30,7 @@ export class TokenApiClientContext extends msRest.ServiceClient { if (!options) { options = {}; } - const defaultUserAgent = msRest.getDefaultUserAgentValue(); + const defaultUserAgent = getDefaultUserAgentValue(); options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent} ${options.userAgent || ''}`; super(credentials, options); diff --git a/libraries/botframework-connector/tests/appCredentials.test.js b/libraries/botframework-connector/tests/appCredentials.test.js index 77f75dd5e9..d8104402d9 100644 --- a/libraries/botframework-connector/tests/appCredentials.test.js +++ b/libraries/botframework-connector/tests/appCredentials.test.js @@ -5,7 +5,7 @@ const { AuthenticationConstants, CertificateAppCredentials, MicrosoftAppCredentials } = require('../'); const { ok: assert, strictEqual } = require('assert'); -const { WebResource } = require('@azure/ms-rest-js'); +const { WebResource } = require('@azure/core-http'); const APP_ID = '2cd87869-38a0-4182-9251-d056e8f0ac24'; const APP_PASSWORD = 'password'; diff --git a/libraries/botframework-connector/tests/botFrameworkAuthenticationFactory.test.js b/libraries/botframework-connector/tests/botFrameworkAuthenticationFactory.test.js index d202f18ac8..44090d10ee 100644 --- a/libraries/botframework-connector/tests/botFrameworkAuthenticationFactory.test.js +++ b/libraries/botframework-connector/tests/botFrameworkAuthenticationFactory.test.js @@ -11,7 +11,7 @@ const { PasswordServiceClientCredentialFactory, SkillValidation, } = require('..'); -const { HttpHeaders } = require('@azure/ms-rest-js'); +const { HttpHeaders } = require('@azure/core-http'); describe('BotFrameworkAuthenticationFactory', function () { it('should create anonymous BotFrameworkAuthentication', function () { diff --git a/libraries/botframework-connector/tests/ms-rest-mappers-test.js b/libraries/botframework-connector/tests/ms-rest-mappers-test.js index 166a9868cf..75261898b3 100644 --- a/libraries/botframework-connector/tests/ms-rest-mappers-test.js +++ b/libraries/botframework-connector/tests/ms-rest-mappers-test.js @@ -1,13 +1,13 @@ -const msRest = require('@azure/ms-rest-js'); +const { Serializer } = require('@azure/core-http'); const Mappers = require('../lib/connectorApi/models/mappers'); -const Serializer = new msRest.Serializer({ Activity: Mappers.Activity, Entity: Mappers.Entity }); +const serializer = new Serializer({ Activity: Mappers.Activity, Entity: Mappers.Entity }); const assert = require('assert'); describe('serialize', function () { const entity = [{ type: 'mention', keyone: 'valueOne', keytwo: { keythree: 'valueThree' } }]; const activity = { type: 'message', entities: entity }; it('should retain custom Entity properties', function () { - const serializedObject = Serializer.serialize(Mappers.Activity, activity); + const serializedObject = serializer.serialize(Mappers.Activity, activity); assert.deepStrictEqual(serializedObject.entities, entity); }); }); From f3db3e98bb139c7aecc921483ea188574de7aada Mon Sep 17 00:00:00 2001 From: Jhonatan Sandoval Velasco <122501764+JhontSouth@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:30:22 -0500 Subject: [PATCH 4/4] fix: [#4470] Migrate off @azure/ms-rest-js botbuilder-ai (#4577) * update yarn lock without ms-rest-js * remove ms-rest-js in botbuilder-ai * update lint formats * add @azure/core-util to resolutions * change models class name * remove core-util of resolutions --- .../botbuilder-ai/etc/botbuilder-ai.api.md | 4 +- libraries/botbuilder-ai/package.json | 4 +- libraries/botbuilder-ai/src/luisRecognizer.ts | 4 +- .../src/luisRecognizerOptionsV2.ts | 4 +- .../src/luisRuntimeClientContext.ts | 43 +++ .../src/luisV2-models/luisMappers.ts | 20 +- .../src/luisV2-models/luisModels.ts | 268 ++++++++++++++++++ .../src/luisV2-models/luisParameters.ts | 18 +- .../src/luisV2-models/luisPrediction.ts | 16 +- .../src/luisV2-models/luisResult.ts | 10 +- .../src/luisV2-models/luisRuntimeClientV2.ts | 6 +- .../tests/luisRecognizer.test.js | 83 +++--- libraries/botbuilder-ai/tests/luisSdk.test.js | 4 +- libraries/botframework-connector/package.json | 1 + yarn.lock | 49 +--- 15 files changed, 410 insertions(+), 124 deletions(-) create mode 100644 libraries/botbuilder-ai/src/luisRuntimeClientContext.ts create mode 100644 libraries/botbuilder-ai/src/luisV2-models/luisModels.ts diff --git a/libraries/botbuilder-ai/etc/botbuilder-ai.api.md b/libraries/botbuilder-ai/etc/botbuilder-ai.api.md index 9bf6f33b32..780e37e44e 100644 --- a/libraries/botbuilder-ai/etc/botbuilder-ai.api.md +++ b/libraries/botbuilder-ai/etc/botbuilder-ai.api.md @@ -23,12 +23,12 @@ import { DialogTurnResult } from 'botbuilder-dialogs'; import { EnumExpression } from 'adaptive-expressions'; import { Expression } from 'adaptive-expressions'; import { IntExpression } from 'adaptive-expressions'; -import * as msRest from '@azure/ms-rest-js'; import { NumberExpression } from 'adaptive-expressions'; import { ObjectExpression } from 'adaptive-expressions'; import { Recognizer } from 'botbuilder-dialogs'; import { RecognizerConfiguration } from 'botbuilder-dialogs'; import { RecognizerResult } from 'botbuilder-core'; +import { RequestOptionsBase } from '@azure/core-http'; import { ServiceCollection } from 'botbuilder-dialogs-adaptive-runtime-core'; import { StringExpression } from 'adaptive-expressions'; import { TemplateInterface } from 'botbuilder-dialogs'; @@ -290,7 +290,7 @@ export class LuisComponentRegistration extends ComponentRegistration { } // @public -export interface LuisPredictionOptions extends msRest.RequestOptionsBase { +export interface LuisPredictionOptions extends RequestOptionsBase { bingSpellCheckSubscriptionKey?: string; includeAllIntents?: boolean; includeInstanceData?: boolean; diff --git a/libraries/botbuilder-ai/package.json b/libraries/botbuilder-ai/package.json index 4691e52198..b8ff15a736 100644 --- a/libraries/botbuilder-ai/package.json +++ b/libraries/botbuilder-ai/package.json @@ -27,13 +27,13 @@ } }, "dependencies": { - "@azure/cognitiveservices-luis-runtime": "^4.0.0", - "@azure/ms-rest-js": "^2.7.0", + "@azure/core-http": "^3.0.2", "adaptive-expressions": "4.1.6", "botbuilder-core": "4.1.6", "botbuilder-dialogs": "4.1.6", "botbuilder-dialogs-adaptive-runtime-core": "4.1.6", "botbuilder-dialogs-declarative": "4.1.6", + "botframework-connector": "4.1.6", "lodash": "^4.17.21", "node-fetch": "^2.6.7", "url-parse": "^1.5.9", diff --git a/libraries/botbuilder-ai/src/luisRecognizer.ts b/libraries/botbuilder-ai/src/luisRecognizer.ts index 14a0647247..7f8b7458a7 100644 --- a/libraries/botbuilder-ai/src/luisRecognizer.ts +++ b/libraries/botbuilder-ai/src/luisRecognizer.ts @@ -5,7 +5,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import * as msRest from '@azure/ms-rest-js'; +import { RequestOptionsBase } from '@azure/core-http'; import Url from 'url-parse'; import { BotTelemetryClient, NullTelemetryClient, RecognizerResult, TurnContext } from 'botbuilder-core'; @@ -41,7 +41,7 @@ export interface LuisApplication { * * Options per LUIS prediction. */ -export interface LuisPredictionOptions extends msRest.RequestOptionsBase { +export interface LuisPredictionOptions extends RequestOptionsBase { /** * If true, return all intents instead of just the top scoring intent. */ diff --git a/libraries/botbuilder-ai/src/luisRecognizerOptionsV2.ts b/libraries/botbuilder-ai/src/luisRecognizerOptionsV2.ts index 9467d15ef4..68ce30cb7b 100644 --- a/libraries/botbuilder-ai/src/luisRecognizerOptionsV2.ts +++ b/libraries/botbuilder-ai/src/luisRecognizerOptionsV2.ts @@ -6,7 +6,7 @@ * Licensed under the MIT License. */ -import * as msRest from '@azure/ms-rest-js'; +import { TokenCredentials } from 'botframework-connector'; import * as os from 'os'; import { LuisApplication, LuisRecognizerOptionsV2 } from './luisRecognizer'; import { CompositeChildModel, CompositeEntityModel, EntityModel, LuisResult } from './luisV2-models/luisResult'; @@ -50,7 +50,7 @@ export class LuisRecognizerV2 extends LuisRecognizerInternal { // - We have to cast "creds as any" to avoid a build break relating to different versions // of autorest being used by our various components. This is just a build issue and // shouldn't effect production bots. - const creds = new msRest.TokenCredentials(application.endpointKey); + const creds = new TokenCredentials(application.endpointKey); const baseUri = application.endpoint || 'https://westus.api.cognitive.microsoft.com'; // eslint-disable-next-line @typescript-eslint/no-explicit-any this.luisClient = new LuisClient(creds as any, baseUri); diff --git a/libraries/botbuilder-ai/src/luisRuntimeClientContext.ts b/libraries/botbuilder-ai/src/luisRuntimeClientContext.ts new file mode 100644 index 0000000000..c7df9e844c --- /dev/null +++ b/libraries/botbuilder-ai/src/luisRuntimeClientContext.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +import { ServiceClient, ServiceClientCredentials, ServiceClientOptions } from '@azure/core-http'; + +/** + * Client for LUIS context + */ +export class LUISRuntimeClientContext extends ServiceClient { + endpoint: string; + credentials: ServiceClientCredentials; + + /** + * Initializes a new instance of the LUISRuntimeClientContext class. + * + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus.api.cognitive.microsoft.com). + * @param [options] The parameter options + */ + constructor(credentials: ServiceClientCredentials, endpoint: string, options?: ServiceClientOptions) { + if (endpoint == undefined) { + throw new Error("'endpoint' cannot be null."); + } + if (credentials == undefined) { + throw new Error("'credentials' cannot be null."); + } + + if (!options) { + options = {}; + } + + super(credentials, options); + + this.baseUri = '{Endpoint}/luis/v3.0-preview'; + this.requestContentType = 'application/json; charset=utf-8'; + this.endpoint = endpoint; + this.credentials = credentials; + } +} diff --git a/libraries/botbuilder-ai/src/luisV2-models/luisMappers.ts b/libraries/botbuilder-ai/src/luisV2-models/luisMappers.ts index fedb748c69..a33169405b 100644 --- a/libraries/botbuilder-ai/src/luisV2-models/luisMappers.ts +++ b/libraries/botbuilder-ai/src/luisV2-models/luisMappers.ts @@ -6,9 +6,9 @@ * Licensed under the MIT License. */ -import * as msRest from '@azure/ms-rest-js'; +import { CompositeMapper } from '@azure/core-http'; -export const IntentModel: msRest.CompositeMapper = { +export const IntentModel: CompositeMapper = { serializedName: 'IntentModel', type: { name: 'Composite', @@ -34,7 +34,7 @@ export const IntentModel: msRest.CompositeMapper = { }, }; -export const EntityModel: msRest.CompositeMapper = { +export const EntityModel: CompositeMapper = { serializedName: 'EntityModel', type: { name: 'Composite', @@ -77,7 +77,7 @@ export const EntityModel: msRest.CompositeMapper = { }, }; -export const CompositeChildModel: msRest.CompositeMapper = { +export const CompositeChildModel: CompositeMapper = { serializedName: 'CompositeChildModel', type: { name: 'Composite', @@ -101,7 +101,7 @@ export const CompositeChildModel: msRest.CompositeMapper = { }, }; -export const CompositeEntityModel: msRest.CompositeMapper = { +export const CompositeEntityModel: CompositeMapper = { serializedName: 'CompositeEntityModel', type: { name: 'Composite', @@ -138,7 +138,7 @@ export const CompositeEntityModel: msRest.CompositeMapper = { }, }; -export const Sentiment: msRest.CompositeMapper = { +export const Sentiment: CompositeMapper = { serializedName: 'Sentiment', type: { name: 'Composite', @@ -160,7 +160,7 @@ export const Sentiment: msRest.CompositeMapper = { }, }; -export const LuisResult: msRest.CompositeMapper = { +export const LuisResult: CompositeMapper = { serializedName: 'LuisResult', type: { name: 'Composite', @@ -244,7 +244,7 @@ export const LuisResult: msRest.CompositeMapper = { }, }; -export const EntityWithScore: msRest.CompositeMapper = { +export const EntityWithScore: CompositeMapper = { serializedName: 'EntityWithScore', type: { name: 'Composite', @@ -267,7 +267,7 @@ export const EntityWithScore: msRest.CompositeMapper = { }, }; -export const EntityWithResolution: msRest.CompositeMapper = { +export const EntityWithResolution: CompositeMapper = { serializedName: 'EntityWithResolution', type: { name: 'Composite', @@ -286,7 +286,7 @@ export const EntityWithResolution: msRest.CompositeMapper = { }, }; -export const APIError: msRest.CompositeMapper = { +export const APIError: CompositeMapper = { serializedName: 'APIError', type: { name: 'Composite', diff --git a/libraries/botbuilder-ai/src/luisV2-models/luisModels.ts b/libraries/botbuilder-ai/src/luisV2-models/luisModels.ts new file mode 100644 index 0000000000..367bb25983 --- /dev/null +++ b/libraries/botbuilder-ai/src/luisV2-models/luisModels.ts @@ -0,0 +1,268 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +import { RequestOptionsBase, HttpResponse } from '@azure/core-http'; + +/** + * Represents an intent prediction. + */ +export interface Intent { + /** + * The score of the fired intent. + */ + score?: number; + /** + * The prediction of the dispatched application. + */ + childApp?: Prediction; +} + +/** + * The result of the sentiment analysis. + */ +export interface Sentiment { + /** + * The label of the sentiment analysis result. + */ + label?: string; + /** + * The sentiment score of the query. + */ + score: number; +} + +/** + * Represents the prediction of a query. + */ +export interface Prediction { + /** + * The query after pre-processing and normalization. + */ + normalizedQuery: string; + /** + * The query after spell checking. Only set if spell check was enabled and a spelling mistake was + * found. + */ + alteredQuery?: string; + /** + * The name of the top scoring intent. + */ + topIntent: string; + /** + * A dictionary representing the intents that fired. + */ + intents: { [propertyName: string]: Intent }; + /** + * The dictionary representing the entities that fired. + */ + entities: { [propertyName: string]: any }; + /** + * The result of the sentiment analysis. + */ + sentiment?: Sentiment; +} + +/** + * Represents the prediction response. + */ +export interface PredictionResponse { + /** + * The query used in the prediction. + */ + query: string; + /** + * The prediction of the requested query. + */ + prediction: Prediction; +} + +/** + * Represents the definition of the error that occurred. + */ +export interface ErrorBody { + /** + * The error code. + */ + code: string; + /** + * The error message. + */ + message: string; +} + +/** + * Represents the error that occurred. + */ +export interface ErrorModel { + error: ErrorBody; +} + +/** + * The custom options for the prediction request. + */ +export interface PredictionRequestOptions { + /** + * The reference DateTime used for predicting datetime entities. + */ + datetimeReference?: Date; + /** + * Whether to make the external entities resolution override the predictions if an overlap + * occurs. + */ + overridePredictions?: boolean; +} + +/** + * Defines a user predicted entity that extends an already existing one. + */ +export interface ExternalEntity { + /** + * The name of the entity to extend. + */ + entityName: string; + /** + * The start character index of the predicted entity. + */ + startIndex: number; + /** + * The length of the predicted entity. + */ + entityLength: number; + /** + * A user supplied custom resolution to return as the entity's prediction. + */ + resolution?: any; +} + +/** + * Defines a sub-list to append to an existing list entity. + */ +export interface RequestList { + /** + * The name of the sub-list. + */ + name?: string; + /** + * The canonical form of the sub-list. + */ + canonicalForm: string; + /** + * The synonyms of the canonical form. + */ + synonyms?: string[]; +} + +/** + * Defines an extension for a list entity. + */ +export interface DynamicList { + /** + * The name of the list entity to extend. + */ + listEntityName: string; + /** + * The lists to append on the extended list entity. + */ + requestLists: RequestList[]; +} + +/** + * Represents the prediction request parameters. + */ +export interface PredictionRequest { + /** + * The query to predict. + */ + query: string; + /** + * The custom options defined for this request. + */ + options?: PredictionRequestOptions; + /** + * The externally predicted entities for this request. + */ + externalEntities?: ExternalEntity[]; + /** + * The dynamically created list entities for this request. + */ + dynamicLists?: DynamicList[]; +} + +/** + * Optional Parameters. + */ +export interface PredictionGetVersionPredictionOptionalParams extends RequestOptionsBase { + /** + * Indicates whether to get extra metadata for the entities predictions or not. + */ + verbose?: boolean; + /** + * Indicates whether to return all the intents in the response or just the top intent. + */ + showAllIntents?: boolean; + /** + * Indicates whether to log the endpoint query or not. + */ + log?: boolean; +} + +/** + * Optional Parameters. + */ +export interface PredictionGetSlotPredictionOptionalParams extends RequestOptionsBase { + /** + * Indicates whether to get extra metadata for the entities predictions or not. + */ + verbose?: boolean; + /** + * Indicates whether to return all the intents in the response or just the top intent. + */ + showAllIntents?: boolean; + /** + * Indicates whether to log the endpoint query or not. + */ + log?: boolean; +} + +/** + * Contains response data for the getVersionPrediction operation. + */ +export type PredictionGetVersionPredictionResponse = PredictionResponse & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: PredictionResponse; + }; +}; + +/** + * Contains response data for the getSlotPrediction operation. + */ +export type PredictionGetSlotPredictionResponse = PredictionResponse & { + /** + * The underlying HTTP response. + */ + _response: HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: PredictionResponse; + }; +}; diff --git a/libraries/botbuilder-ai/src/luisV2-models/luisParameters.ts b/libraries/botbuilder-ai/src/luisV2-models/luisParameters.ts index 4cd610964b..8ff31939a0 100644 --- a/libraries/botbuilder-ai/src/luisV2-models/luisParameters.ts +++ b/libraries/botbuilder-ai/src/luisV2-models/luisParameters.ts @@ -6,9 +6,9 @@ * Licensed under the MIT License. */ -import * as msRest from '@azure/ms-rest-js'; +import { OperationURLParameter, OperationQueryParameter } from '@azure/core-http'; -export const appId: msRest.OperationURLParameter = { +export const appId: OperationURLParameter = { parameterPath: 'appId', mapper: { required: true, @@ -18,7 +18,7 @@ export const appId: msRest.OperationURLParameter = { }, }, }; -export const bingSpellCheckSubscriptionKey: msRest.OperationQueryParameter = { +export const bingSpellCheckSubscriptionKey: OperationQueryParameter = { parameterPath: ['options', 'bingSpellCheckSubscriptionKey'], mapper: { serializedName: 'bing-spell-check-subscription-key', @@ -27,7 +27,7 @@ export const bingSpellCheckSubscriptionKey: msRest.OperationQueryParameter = { }, }, }; -export const endpoint: msRest.OperationURLParameter = { +export const endpoint: OperationURLParameter = { parameterPath: 'endpoint', mapper: { required: true, @@ -39,7 +39,7 @@ export const endpoint: msRest.OperationURLParameter = { }, skipEncoding: true, }; -export const log: msRest.OperationQueryParameter = { +export const log: OperationQueryParameter = { parameterPath: ['options', 'log'], mapper: { serializedName: 'log', @@ -48,7 +48,7 @@ export const log: msRest.OperationQueryParameter = { }, }, }; -export const spellCheck: msRest.OperationQueryParameter = { +export const spellCheck: OperationQueryParameter = { parameterPath: ['options', 'spellCheck'], mapper: { serializedName: 'spellCheck', @@ -57,7 +57,7 @@ export const spellCheck: msRest.OperationQueryParameter = { }, }, }; -export const staging: msRest.OperationQueryParameter = { +export const staging: OperationQueryParameter = { parameterPath: ['options', 'staging'], mapper: { serializedName: 'staging', @@ -66,7 +66,7 @@ export const staging: msRest.OperationQueryParameter = { }, }, }; -export const timezoneOffset: msRest.OperationQueryParameter = { +export const timezoneOffset: OperationQueryParameter = { parameterPath: ['options', 'timezoneOffset'], mapper: { serializedName: 'timezoneOffset', @@ -75,7 +75,7 @@ export const timezoneOffset: msRest.OperationQueryParameter = { }, }, }; -export const verbose: msRest.OperationQueryParameter = { +export const verbose: OperationQueryParameter = { parameterPath: ['options', 'verbose'], mapper: { serializedName: 'verbose', diff --git a/libraries/botbuilder-ai/src/luisV2-models/luisPrediction.ts b/libraries/botbuilder-ai/src/luisV2-models/luisPrediction.ts index 08644a3114..5ed5aa9648 100644 --- a/libraries/botbuilder-ai/src/luisV2-models/luisPrediction.ts +++ b/libraries/botbuilder-ai/src/luisV2-models/luisPrediction.ts @@ -6,8 +6,8 @@ * Licensed under the MIT License. */ -import * as msRest from '@azure/ms-rest-js'; -import { LUISRuntimeClientContext } from '@azure/cognitiveservices-luis-runtime'; +import { ServiceCallback, OperationSpec, Serializer } from '@azure/core-http'; +import { LUISRuntimeClientContext } from '../luisRuntimeClientContext'; import { LuisResult, PredictionResolveOptionalParams, PredictionResolveResponse } from './luisResult'; import * as Parameters from './luisParameters'; import * as Mappers from './luisMappers'; @@ -44,7 +44,7 @@ export class LuisPrediction { * @param query The utterance to predict. * @param callback The callback */ - resolve(appId: string, query: string, callback: msRest.ServiceCallback): void; + resolve(appId: string, query: string, callback: ServiceCallback): void; /** * @param appId The LUIS application ID (Guid). * @param query The utterance to predict. @@ -55,7 +55,7 @@ export class LuisPrediction { appId: string, query: string, options: PredictionResolveOptionalParams, - callback: msRest.ServiceCallback + callback: ServiceCallback ): void; /** * @param appId The LUIS application ID (Guid). @@ -67,8 +67,8 @@ export class LuisPrediction { resolve( appId: string, query: string, - options?: PredictionResolveOptionalParams | msRest.ServiceCallback, - callback?: msRest.ServiceCallback + options?: PredictionResolveOptionalParams | ServiceCallback, + callback?: ServiceCallback ): Promise { return this.client.sendOperationRequest( { @@ -83,8 +83,8 @@ export class LuisPrediction { } // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const resolveOperationSpec: msRest.OperationSpec = { +const serializer = new Serializer(Mappers); +const resolveOperationSpec: OperationSpec = { httpMethod: 'POST', path: 'apps/{appId}', urlParameters: [Parameters.endpoint, Parameters.appId], diff --git a/libraries/botbuilder-ai/src/luisV2-models/luisResult.ts b/libraries/botbuilder-ai/src/luisV2-models/luisResult.ts index e29a2bb851..3c4feb8ffd 100644 --- a/libraries/botbuilder-ai/src/luisV2-models/luisResult.ts +++ b/libraries/botbuilder-ai/src/luisV2-models/luisResult.ts @@ -6,8 +6,8 @@ * Licensed under the MIT License. */ -import { LUISRuntimeModels as LuisModels } from '@azure/cognitiveservices-luis-runtime'; -import * as msRest from '@azure/ms-rest-js'; +import { Sentiment } from './luisModels'; +import { HttpResponse, RequestOptionsBase } from '@azure/core-http'; /** * Prediction, based on the input query, containing intent(s) and entities. @@ -40,7 +40,7 @@ export interface LuisResult { /** * Sentiment of the input utterance. */ - sentimentAnalysis?: LuisModels.Sentiment; + sentimentAnalysis?: Sentiment; /** * Prediction, based on the input query, containing intents and entities. */ @@ -122,7 +122,7 @@ export interface CompositeChildModel { /** * Optional Parameters. */ -export interface PredictionResolveOptionalParams extends msRest.RequestOptionsBase { +export interface PredictionResolveOptionalParams extends RequestOptionsBase { /** * The timezone offset for the location of the request. */ @@ -156,7 +156,7 @@ export type PredictionResolveResponse = LuisResult & { /** * The underlying HTTP response. */ - _response: msRest.HttpResponse & { + _response: HttpResponse & { /** * The response body as text (string format) */ diff --git a/libraries/botbuilder-ai/src/luisV2-models/luisRuntimeClientV2.ts b/libraries/botbuilder-ai/src/luisV2-models/luisRuntimeClientV2.ts index 6a6c0529a4..8e1ee25a77 100644 --- a/libraries/botbuilder-ai/src/luisV2-models/luisRuntimeClientV2.ts +++ b/libraries/botbuilder-ai/src/luisV2-models/luisRuntimeClientV2.ts @@ -6,11 +6,11 @@ * Licensed under the MIT License. */ -import * as msRest from '@azure/ms-rest-js'; +import { ServiceClientCredentials, ServiceClientOptions } from '@azure/core-http'; import * as Models from './luisResult'; import * as Mappers from './luisMappers'; import { LuisPrediction } from './luisPrediction'; -import { LUISRuntimeClientContext } from '@azure/cognitiveservices-luis-runtime'; +import { LUISRuntimeClientContext } from '../luisRuntimeClientContext'; /** * Represents the LUIS client for V2 of the runtime. @@ -29,7 +29,7 @@ class LUISRuntimeClientV2 extends LUISRuntimeClientContext { * https://westus.api.cognitive.microsoft.com). * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { + constructor(credentials: ServiceClientCredentials, endpoint: string, options?: ServiceClientOptions) { super(credentials, endpoint, options); this.prediction = new LuisPrediction(this); super.baseUri = '{Endpoint}/luis/v2.0'; diff --git a/libraries/botbuilder-ai/tests/luisRecognizer.test.js b/libraries/botbuilder-ai/tests/luisRecognizer.test.js index e2f5334b41..466f49bead 100644 --- a/libraries/botbuilder-ai/tests/luisRecognizer.test.js +++ b/libraries/botbuilder-ai/tests/luisRecognizer.test.js @@ -500,69 +500,86 @@ describe('LuisRecognizer', function () { returnStatusCode(400); const context = new TestContext({ text: 'Hello world!' }); - await assert.rejects( - recognizer.recognize(context), - new Error( - "Response 400: The request's body or parameters are incorrect, meaning they are missing, malformed, or too large." - ) - ); + const errorResponse = + "Response 400: The request's body or parameters are incorrect, meaning they are missing, malformed, or too large."; + try { + await recognizer.recognize(context); + } catch (error) { + assert.deepEqual(errorResponse, error.message); + } }); maybeIt('should throw expected 401 error message.', async () => { returnStatusCode(401); const context = new TestContext({ text: 'Hello world!' }); - await assert.rejects( - recognizer.recognize(context), - new Error("Response 401: The key used is invalid, malformed, empty, or doesn't match the region.") - ); + const errorResponse = "Response 401: The key used is invalid, malformed, empty, or doesn't match the region."; + try { + await recognizer.recognize(context); + } catch (error) { + assert.deepEqual(errorResponse, error.message); + } }); maybeIt('should throw expected 403 error message.', async () => { returnStatusCode(403); const context = new TestContext({ text: 'Hello world!' }); - await assert.rejects( - recognizer.recognize(context), - new Error('Response 403: Total monthly key quota limit exceeded.') - ); + const errorResponse = 'Response 403: Total monthly key quota limit exceeded.'; + try { + await recognizer.recognize(context); + } catch (error) { + assert.deepEqual(errorResponse, error.message); + } }); maybeIt('should throw expected 409 error message.', async () => { returnStatusCode(409); const context = new TestContext({ text: 'Hello world!' }); - await assert.rejects( - recognizer.recognize(context), - new Error('Response 409: Application loading in progress, please try again.') - ); + const errorResponse = 'Response 409: Application loading in progress, please try again.'; + try { + await recognizer.recognize(context); + } catch (error) { + assert.deepEqual(errorResponse, error.message); + } }); maybeIt('should throw expected 410 error message.', async () => { returnStatusCode(410); const context = new TestContext({ text: 'Hello world!' }); - await assert.rejects( - recognizer.recognize(context), - new Error('Response 410: Please retrain and republish your application.') - ); + const errorResponse = 'Response 410: Please retrain and republish your application.'; + try { + await recognizer.recognize(context); + } catch (error) { + assert.deepEqual(errorResponse, error.message); + } }); maybeIt('should throw expected 414 error message.', async () => { returnStatusCode(414); const context = new TestContext({ text: 'Hello world!' }); - await assert.rejects( - recognizer.recognize(context), - new Error('Response 414: The query is too long. Please reduce the query length to 500 or less characters.') - ); + const errorResponse = + 'Response 414: The query is too long. Please reduce the query length to 500 or less characters.'; + try { + await recognizer.recognize(context); + } catch (error) { + assert.deepEqual(errorResponse, error.message); + } }); maybeIt('should throw expected 429 error m`essage.', async () => { returnStatusCode(429); const context = new TestContext({ text: 'Hello world!' }); - await assert.rejects(recognizer.recognize(context), Error('Response 429: Too many requests.')); + const errorResponse = 'Response 429: Too many requests.'; + try { + await recognizer.recognize(context); + } catch (error) { + assert.deepEqual(errorResponse, error.message); + } }); maybeIt('should throw unexpected error message with correct status code.', async () => { @@ -570,12 +587,12 @@ describe('LuisRecognizer', function () { returnStatusCode(statusCode); const context = new TestContext({ text: 'Hello world!' }); - await assert.rejects( - recognizer.recognize(context), - new Error( - `Response ${statusCode}: Unexpected status code received. Please verify that your LUIS application is properly setup.` - ) - ); + const errorResponse = `Response ${statusCode}: Unexpected status code received. Please verify that your LUIS application is properly setup.`; + try { + await recognizer.recognize(context); + } catch (error) { + assert.deepEqual(errorResponse, error.message); + } }); maybeIt( diff --git a/libraries/botbuilder-ai/tests/luisSdk.test.js b/libraries/botbuilder-ai/tests/luisSdk.test.js index e29047459a..8ecf61352a 100644 --- a/libraries/botbuilder-ai/tests/luisSdk.test.js +++ b/libraries/botbuilder-ai/tests/luisSdk.test.js @@ -2,7 +2,7 @@ const assert = require('assert'); const fs = require('fs-extra'); const nock = require('nock'); const { LUISRuntimeClientV2 } = require('../lib/luisV2-models/luisRuntimeClientV2'); -const msRest = require('@azure/ms-rest-js'); +const { TokenCredentials } = require('botframework-connector'); const applicationId = '00000000-0000-0000-0000-000000000000'; // This can be any endpoint key for calling LUIS @@ -13,7 +13,7 @@ const k = process.env.LUISAPPKEY || 'test'; const mockLuis = true; const baseUrl = 'https://westus.api.cognitive.microsoft.com'; -const creds = new msRest.TokenCredentials(k); +const creds = new TokenCredentials(k); function ExpectedPath(file) { return __dirname + '/TestData/LuisSdk/' + file; diff --git a/libraries/botframework-connector/package.json b/libraries/botframework-connector/package.json index b5773a0a25..cb27058bf6 100644 --- a/libraries/botframework-connector/package.json +++ b/libraries/botframework-connector/package.json @@ -30,6 +30,7 @@ "@azure/core-http": "^3.0.2", "@azure/identity": "^2.0.4", "@azure/msal-node": "^1.2.0", + "@azure/core-http": "^3.0.2", "axios": "^0.25.0", "base64url": "^3.0.0", "botbuilder-stdlib": "4.1.6", diff --git a/yarn.lock b/yarn.lock index 515ef834f8..600a86b34c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17,28 +17,11 @@ dependencies: tslib "^1.9.3" -"@azure/cognitiveservices-luis-runtime@^4.0.0": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@azure/cognitiveservices-luis-runtime/-/cognitiveservices-luis-runtime-4.0.1.tgz#7c49b0a98af2b3d1c76e2fee64b1270769de1b25" - integrity sha512-W5oDt1LvJQmtxCIDq1aFh8R4W+5ZKSTC+9So9DIGVZmy29SMxBNyTf8OTliHDv0L+P6Y2XBySoGCliPYfTyrhQ== - dependencies: - "@azure/ms-rest-js" "^2.0.3" - tslib "^1.10.0" - "@azure/core-asynciterator-polyfill@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@azure/core-asynciterator-polyfill/-/core-asynciterator-polyfill-1.0.0.tgz#dcccebb88406e5c76e0e1d52e8cc4c43a68b3ee7" integrity sha512-kmv8CGrPfN9SwMwrkiBK9VTQYxdFQEGe0BmQk+M8io56P9KNzpAxcWE/1fxJj7uouwN4kXF0BHW8DNlgx+wtCg== -"@azure/core-auth@^1.1.4": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@azure/core-auth/-/core-auth-1.5.0.tgz#a41848c5c31cb3b7c84c409885267d55a2c92e44" - integrity sha512-udzoBuYG1VBoHVohDTrvKjyzel34zt77Bhp7dQntVGGD0ehVq48owENbBG8fIgkHRNUBQH5k1r0hpoMu5L8+kw== - dependencies: - "@azure/abort-controller" "^1.0.0" - "@azure/core-util" "^1.1.0" - tslib "^2.2.0" - "@azure/core-auth@^1.2.0", "@azure/core-auth@^1.4.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@azure/core-auth/-/core-auth-1.4.0.tgz#6fa9661c1705857820dbc216df5ba5665ac36a9e" @@ -152,7 +135,7 @@ "@opentelemetry/api" "^0.10.2" tslib "^2.0.0" -"@azure/core-util@^1.0.0-beta.1", "@azure/core-util@^1.1.0", "@azure/core-util@^1.1.1", "@azure/core-util@^1.2.0": +"@azure/core-util@^1.0.0-beta.1", "@azure/core-util@^1.1.1", "@azure/core-util@^1.2.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@azure/core-util/-/core-util-1.5.0.tgz#ffe49c3e867044da67daeb8122143fa065e1eb0e" integrity sha512-GZBpVFDtQ/15hW1OgBcRdT4Bl7AEpcEZqLfbAvOtm1CQUncKWiYapFHVD588hmlV27NbOOtSm3cnLF3lvoHi4g== @@ -224,20 +207,6 @@ resolved "https://registry.yarnpkg.com/@azure/ms-rest-azure-env/-/ms-rest-azure-env-2.0.0.tgz#45809f89763a480924e21d3c620cd40866771625" integrity sha512-dG76W7ElfLi+fbTjnZVGj+M9e0BIEJmRxU6fHaUQ12bZBe8EJKYb2GV50YWNaP2uJiVQ5+7nXEVj1VN1UQtaEw== -"@azure/ms-rest-js@^2.0.3", "@azure/ms-rest-js@^2.7.0": - version "2.7.0" - resolved "https://registry.yarnpkg.com/@azure/ms-rest-js/-/ms-rest-js-2.7.0.tgz#8639065577ffdf4946951e1d246334ebfd72d537" - integrity sha512-ngbzWbqF+NmztDOpLBVDxYM+XLcUj7nKhxGbSU9WtIsXfRB//cf2ZbAG5HkOrhU9/wd/ORRB6lM/d69RKVjiyA== - dependencies: - "@azure/core-auth" "^1.1.4" - abort-controller "^3.0.0" - form-data "^2.5.0" - node-fetch "^2.6.7" - tslib "^1.10.0" - tunnel "0.0.6" - uuid "^8.3.2" - xml2js "^0.5.0" - "@azure/msal-browser@^2.16.0": version "2.17.0" resolved "https://registry.yarnpkg.com/@azure/msal-browser/-/msal-browser-2.17.0.tgz#beb7d91e6123534b42c0d2ce85eda42a136a8555" @@ -2734,13 +2703,6 @@ abbrev@1: resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== -abort-controller@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" - integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== - dependencies: - event-target-shim "^5.0.0" - accepts@^1.3.7, accepts@~1.3.8: version "1.3.8" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" @@ -5985,11 +5947,6 @@ event-emitter@~0.3.5: d "1" es5-ext "~0.10.14" -event-target-shim@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" - integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== - events@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/events/-/events-3.2.0.tgz#93b87c18f8efcd4202a461aec4dfc0556b639379" @@ -13035,7 +12992,7 @@ tsconfig-paths@^3.9.0: minimist "^1.2.0" strip-bom "^3.0.0" -tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: +tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== @@ -13072,7 +13029,7 @@ tty-browserify@0.0.1: resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" integrity sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw== -tunnel@0.0.6, tunnel@^0.0.6: +tunnel@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==