From 9b2c181eb47527f85ddd6b6cb02a2ae6e7f8315a Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Sun, 22 May 2022 21:04:33 +0000 Subject: [PATCH] CodeGen from PR 19174 in Azure/azure-rest-api-specs Merge 98d4aaf2b1fe0ab634cbbe884b2719fb57ff0e87 into 0cda3c555d19258fcc24c65f3d9e977ac892216a --- .../arm-mixedreality/CHANGELOG.md | 2 +- sdk/mixedreality/arm-mixedreality/_meta.json | 12 +++--- .../arm-mixedreality/package.json | 20 ++++------ .../src/mixedRealityClient.ts | 34 ++++++++++++++++ .../arm-mixedreality/test/sampleTest.ts | 39 ++++++++----------- .../arm-mixedreality/tsconfig.json | 10 +---- 6 files changed, 67 insertions(+), 50 deletions(-) diff --git a/sdk/mixedreality/arm-mixedreality/CHANGELOG.md b/sdk/mixedreality/arm-mixedreality/CHANGELOG.md index 5743bb72bdc2..f85c8e8d3ac5 100644 --- a/sdk/mixedreality/arm-mixedreality/CHANGELOG.md +++ b/sdk/mixedreality/arm-mixedreality/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 4.1.0-beta.1 (2022-04-25) +## 4.1.0-beta.1 (2022-05-22) **Features** diff --git a/sdk/mixedreality/arm-mixedreality/_meta.json b/sdk/mixedreality/arm-mixedreality/_meta.json index a0daafc1ef3b..bc78a0509af8 100644 --- a/sdk/mixedreality/arm-mixedreality/_meta.json +++ b/sdk/mixedreality/arm-mixedreality/_meta.json @@ -1,8 +1,8 @@ { - "commit": "d967edeee8fd6af6d40bffe53cceed1bd053d7ad", - "readme": "specification\\mixedreality\\resource-manager\\readme.md", - "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\mixedreality\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", + "commit": "f124e9f0d4b821d2e8d02757ff60e3e91ac4a123", + "readme": "specification/mixedreality/resource-manager/readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/mixedreality/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220425.1", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", - "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" -} + "release_tool": "@azure-tools/js-sdk-release-tools@2.3.0", + "use": "@autorest/typescript@6.0.0-alpha.19.20220425.1" +} \ No newline at end of file diff --git a/sdk/mixedreality/arm-mixedreality/package.json b/sdk/mixedreality/arm-mixedreality/package.json index 7429f9786922..b16261214280 100644 --- a/sdk/mixedreality/arm-mixedreality/package.json +++ b/sdk/mixedreality/arm-mixedreality/package.json @@ -38,9 +38,11 @@ "uglify-js": "^3.4.9", "rimraf": "^3.0.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "cross-env": "^7.0.2", + "@azure/dev-tool": "^1.0.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/mixedreality/arm-mixedreality", "repository": { @@ -91,7 +93,7 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", "integration-test:browser": "echo skipped", "docs": "echo skipped" }, @@ -104,13 +106,5 @@ } ] }, - "autoPublish": true, - "//sampleConfiguration": { - "productName": "", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-mixedreality?view=azure-node-preview" - } -} + "autoPublish": true +} \ No newline at end of file diff --git a/sdk/mixedreality/arm-mixedreality/src/mixedRealityClient.ts b/sdk/mixedreality/arm-mixedreality/src/mixedRealityClient.ts index 9cb97b6cccc5..67db5b6c6f66 100644 --- a/sdk/mixedreality/arm-mixedreality/src/mixedRealityClient.ts +++ b/sdk/mixedreality/arm-mixedreality/src/mixedRealityClient.ts @@ -8,6 +8,11 @@ import * as coreClient from "@azure/core-client"; import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { OperationsImpl, @@ -115,6 +120,35 @@ export class MixedRealityClient extends coreClient.ServiceClient { this.spatialAnchorsAccounts = new SpatialAnchorsAccountsImpl(this); this.remoteRenderingAccounts = new RemoteRenderingAccountsImpl(this); this.objectAnchorsAccounts = new ObjectAnchorsAccountsImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return item.replace(/(?<==).*$/, apiVersion); + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } /** diff --git a/sdk/mixedreality/arm-mixedreality/test/sampleTest.ts b/sdk/mixedreality/arm-mixedreality/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/mixedreality/arm-mixedreality/test/sampleTest.ts +++ b/sdk/mixedreality/arm-mixedreality/test/sampleTest.ts @@ -7,35 +7,30 @@ */ import { - env, - record, - RecorderEnvironmentSetup, - Recorder + Recorder, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import * as assert from "assert"; +import { assert } from "chai"; +import { Context } from "mocha"; -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables }; describe("My test", () => { let recorder: Recorder; - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); }); afterEach(async function() { diff --git a/sdk/mixedreality/arm-mixedreality/tsconfig.json b/sdk/mixedreality/arm-mixedreality/tsconfig.json index 1d3b90d5ee29..3e6ae96443f3 100644 --- a/sdk/mixedreality/arm-mixedreality/tsconfig.json +++ b/sdk/mixedreality/arm-mixedreality/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-mixedreality": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"