From eef0a4fb57c6b544b44913525f004a62b2678ba8 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 27 May 2022 09:48:55 +0000 Subject: [PATCH] CodeGen from PR 19250 in Azure/azure-rest-api-specs Merge c313c71377ccb05fe9bd1b7982373e89afcbca27 into b2de552d860a5cc148c7a0b7a739fd0dacb5b5a4 --- .../arm-appinsights/CHANGELOG.md | 16 ++------ .../arm-appinsights/_meta.json | 8 ++-- .../arm-appinsights/package.json | 14 ++++--- .../review/arm-appinsights.api.md | 27 ++++++++----- .../applicationInsightsManagementClient.ts | 27 ++++++++++++- .../arm-appinsights/src/models/index.ts | 32 ++++++++++----- .../arm-appinsights/src/models/parameters.ts | 4 +- .../src/operations/workbooks.ts | 16 ++++---- .../src/operationsInterfaces/workbooks.ts | 12 +++--- .../arm-appinsights/test/sampleTest.ts | 39 ++++++++----------- 10 files changed, 113 insertions(+), 82 deletions(-) diff --git a/sdk/applicationinsights/arm-appinsights/CHANGELOG.md b/sdk/applicationinsights/arm-appinsights/CHANGELOG.md index 17cc01daf1e6..b4b7f4dabee9 100644 --- a/sdk/applicationinsights/arm-appinsights/CHANGELOG.md +++ b/sdk/applicationinsights/arm-appinsights/CHANGELOG.md @@ -1,18 +1,8 @@ # Release History + +## 5.0.0-beta.4 (2022-05-27) -## 5.0.0-beta.4 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - -## 5.0.0-beta.3 (2022-03-15) - -The package of @azure/arm-appinsights is using our next generation design principles since version 5.0.0-beta.3, which contains breaking changes. +The package of @azure/arm-appinsights is using our next generation design principles since version 5.0.0-beta.4, which contains breaking changes. To understand the detail of the change, please refer to [Changelog](https://aka.ms/js-track2-changelog). diff --git a/sdk/applicationinsights/arm-appinsights/_meta.json b/sdk/applicationinsights/arm-appinsights/_meta.json index fbfdce42da6d..5dbc8b19ef88 100644 --- a/sdk/applicationinsights/arm-appinsights/_meta.json +++ b/sdk/applicationinsights/arm-appinsights/_meta.json @@ -1,8 +1,8 @@ { - "commit": "e432d9cc87bfed320d8feead4b448be9481c9181", + "commit": "3fc9fb492ab7c0e6642ba7fcfe585846f9078628", "readme": "specification/applicationinsights/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:\\mydev\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\applicationinsights\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-beta.16", + "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/applicationinsights/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.1.1", - "use": "@autorest/typescript@6.0.0-beta.16" + "release_tool": "@azure-tools/js-sdk-release-tools@2.3.1", + "use": "@autorest/typescript@6.0.0-alpha.19.20220425.1" } \ No newline at end of file diff --git a/sdk/applicationinsights/arm-appinsights/package.json b/sdk/applicationinsights/arm-appinsights/package.json index 674cd19d83e3..84f0fbd21122 100644 --- a/sdk/applicationinsights/arm-appinsights/package.json +++ b/sdk/applicationinsights/arm-appinsights/package.json @@ -9,9 +9,9 @@ }, "dependencies": { "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@azure/core-auth": "^1.3.0", - "@azure/core-rest-pipeline": "^1.1.0", + "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" }, "keywords": [ @@ -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/applicationinsights/arm-appinsights", "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" }, @@ -105,4 +107,4 @@ ] }, "autoPublish": true -} +} \ No newline at end of file diff --git a/sdk/applicationinsights/arm-appinsights/review/arm-appinsights.api.md b/sdk/applicationinsights/arm-appinsights/review/arm-appinsights.api.md index 1e1ccaf4c218..7cfd7d3f2425 100644 --- a/sdk/applicationinsights/arm-appinsights/review/arm-appinsights.api.md +++ b/sdk/applicationinsights/arm-appinsights/review/arm-appinsights.api.md @@ -968,17 +968,21 @@ export enum KnownRequestSource { } // @public -export enum KnownSharedTypeKind { +export enum KnownStorageType { // (undocumented) - Shared = "shared", + ServiceProfiler = "ServiceProfiler" +} + +// @public +export enum KnownWorkbookSharedTypeKind { // (undocumented) - User = "user" + Shared = "shared" } // @public -export enum KnownStorageType { +export enum KnownWorkbookUpdateSharedTypeKind { // (undocumented) - ServiceProfiler = "ServiceProfiler" + Shared = "shared" } // @public @@ -1238,9 +1242,6 @@ export interface Resource { readonly type?: string; } -// @public -export type SharedTypeKind = string; - // @public export type StorageType = string; @@ -1447,7 +1448,7 @@ export interface WorkbookInnerErrorTrace { // @public export type WorkbookResource = TrackedResource & { identity?: WorkbookResourceIdentity; - kind?: Kind; + kind?: WorkbookSharedTypeKind; etag?: string; }; @@ -1486,6 +1487,9 @@ export interface WorkbooksGetOptionalParams extends coreClient.OperationOptions // @public export type WorkbooksGetResponse = Workbook; +// @public +export type WorkbookSharedTypeKind = string; + // @public export interface WorkbooksListByResourceGroupNextOptionalParams extends coreClient.OperationOptions { canFetchContent?: boolean; @@ -1683,7 +1687,7 @@ export interface WorkbookUpdateParameters { category?: string; description?: string; displayName?: string; - kind?: SharedTypeKind; + kind?: WorkbookUpdateSharedTypeKind; revision?: string; serializedData?: string; tags?: { @@ -1692,6 +1696,9 @@ export interface WorkbookUpdateParameters { tagsPropertiesTags?: string[]; } +// @public +export type WorkbookUpdateSharedTypeKind = string; + // @public export interface WorkItemConfiguration { configDisplayName?: string; diff --git a/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClient.ts b/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClient.ts index 0cb98514a1ae..ff04cc11b1da 100644 --- a/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClient.ts +++ b/sdk/applicationinsights/arm-appinsights/src/applicationInsightsManagementClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { AnnotationsImpl, @@ -98,9 +99,33 @@ export class ApplicationInsightsManagementClient extends coreClient.ServiceClien userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/applicationinsights/arm-appinsights/src/models/index.ts b/sdk/applicationinsights/arm-appinsights/src/models/index.ts index 92be8b5e5416..1caa7a3ee12d 100644 --- a/sdk/applicationinsights/arm-appinsights/src/models/index.ts +++ b/sdk/applicationinsights/arm-appinsights/src/models/index.ts @@ -924,7 +924,7 @@ export interface WorkbookErrorDefinition { /** The parameters that can be provided when updating workbook properties properties. */ export interface WorkbookUpdateParameters { /** The kind of workbook. Only valid value is shared. */ - kind?: SharedTypeKind; + kind?: WorkbookUpdateSharedTypeKind; /** Resource tags. */ tags?: { [propertyName: string]: string }; /** The user-defined name (display name) of the workbook. */ @@ -1341,7 +1341,7 @@ export type WorkbookResource = TrackedResource & { /** Identity used for BYOS */ identity?: WorkbookResourceIdentity; /** The kind of workbook. Only valid value is shared. */ - kind?: Kind; + kind?: WorkbookSharedTypeKind; /** Resource etag */ etag?: string; }; @@ -1352,7 +1352,7 @@ export type ComponentLinkedStorageAccounts = ProxyResource & { linkedStorageAccount?: string; }; -/** An Application Insights workbook definition. */ +/** A workbook definition. */ export type Workbook = WorkbookResource & { /** * Metadata pertaining to creation and last modification of the resource. @@ -1586,21 +1586,33 @@ export enum KnownManagedServiceIdentityType { */ export type ManagedServiceIdentityType = string; -/** Known values of {@link SharedTypeKind} that the service accepts. */ -export enum KnownSharedTypeKind { - User = "user", +/** Known values of {@link WorkbookSharedTypeKind} that the service accepts. */ +export enum KnownWorkbookSharedTypeKind { Shared = "shared" } /** - * Defines values for SharedTypeKind. \ - * {@link KnownSharedTypeKind} can be used interchangeably with SharedTypeKind, + * Defines values for WorkbookSharedTypeKind. \ + * {@link KnownWorkbookSharedTypeKind} can be used interchangeably with WorkbookSharedTypeKind, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **shared** + */ +export type WorkbookSharedTypeKind = string; + +/** Known values of {@link WorkbookUpdateSharedTypeKind} that the service accepts. */ +export enum KnownWorkbookUpdateSharedTypeKind { + Shared = "shared" +} + +/** + * Defines values for WorkbookUpdateSharedTypeKind. \ + * {@link KnownWorkbookUpdateSharedTypeKind} can be used interchangeably with WorkbookUpdateSharedTypeKind, * this enum contains the known values that the service supports. * ### Known values supported by the service - * **user** \ * **shared** */ -export type SharedTypeKind = string; +export type WorkbookUpdateSharedTypeKind = string; /** Known values of {@link ApplicationType} that the service accepts. */ export enum KnownApplicationType { diff --git a/sdk/applicationinsights/arm-appinsights/src/models/parameters.ts b/sdk/applicationinsights/arm-appinsights/src/models/parameters.ts index 6efff1734966..5f050754320e 100644 --- a/sdk/applicationinsights/arm-appinsights/src/models/parameters.ts +++ b/sdk/applicationinsights/arm-appinsights/src/models/parameters.ts @@ -357,7 +357,7 @@ export const scope: OperationQueryParameter = { }; export const typeParam: OperationQueryParameter = { - parameterPath: ["options", "typeParam"], + parameterPath: ["options", "type"], mapper: { defaultValue: "none", serializedName: "type", @@ -475,7 +475,7 @@ export const workbookProperties: OperationParameter = { export const apiVersion3: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2021-08-01", + defaultValue: "2022-04-01", isConstant: true, serializedName: "api-version", type: { diff --git a/sdk/applicationinsights/arm-appinsights/src/operations/workbooks.ts b/sdk/applicationinsights/arm-appinsights/src/operations/workbooks.ts index cd8f5b310ea8..c8592d750300 100644 --- a/sdk/applicationinsights/arm-appinsights/src/operations/workbooks.ts +++ b/sdk/applicationinsights/arm-appinsights/src/operations/workbooks.ts @@ -178,7 +178,7 @@ export class WorkbooksImpl implements Workbooks { /** * Get the revisions for the workbook defined by its resourceName. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param options The options parameters. */ public listRevisionsList( @@ -281,7 +281,7 @@ export class WorkbooksImpl implements Workbooks { /** * Get a single workbook by its resourceName. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param options The options parameters. */ get( @@ -298,7 +298,7 @@ export class WorkbooksImpl implements Workbooks { /** * Delete a workbook. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param options The options parameters. */ delete( @@ -315,7 +315,7 @@ export class WorkbooksImpl implements Workbooks { /** * Create a new workbook. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param workbookProperties Properties that need to be specified to create a new workbook. * @param options The options parameters. */ @@ -334,7 +334,7 @@ export class WorkbooksImpl implements Workbooks { /** * Updates a workbook that has already been added. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param options The options parameters. */ update( @@ -351,7 +351,7 @@ export class WorkbooksImpl implements Workbooks { /** * Get the revisions for the workbook defined by its resourceName. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param options The options parameters. */ private _revisionsList( @@ -368,7 +368,7 @@ export class WorkbooksImpl implements Workbooks { /** * Get a single workbook revision defined by its revisionId. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param revisionId The id of the workbook's revision. * @param options The options parameters. */ @@ -423,7 +423,7 @@ export class WorkbooksImpl implements Workbooks { /** * RevisionsListNext * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param nextLink The nextLink from the previous successful call to the RevisionsList method. * @param options The options parameters. */ diff --git a/sdk/applicationinsights/arm-appinsights/src/operationsInterfaces/workbooks.ts b/sdk/applicationinsights/arm-appinsights/src/operationsInterfaces/workbooks.ts index 012c62cdc6a6..252a0e0bcb11 100644 --- a/sdk/applicationinsights/arm-appinsights/src/operationsInterfaces/workbooks.ts +++ b/sdk/applicationinsights/arm-appinsights/src/operationsInterfaces/workbooks.ts @@ -50,7 +50,7 @@ export interface Workbooks { /** * Get the revisions for the workbook defined by its resourceName. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param options The options parameters. */ listRevisionsList( @@ -61,7 +61,7 @@ export interface Workbooks { /** * Get a single workbook by its resourceName. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param options The options parameters. */ get( @@ -72,7 +72,7 @@ export interface Workbooks { /** * Delete a workbook. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param options The options parameters. */ delete( @@ -83,7 +83,7 @@ export interface Workbooks { /** * Create a new workbook. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param workbookProperties Properties that need to be specified to create a new workbook. * @param options The options parameters. */ @@ -96,7 +96,7 @@ export interface Workbooks { /** * Updates a workbook that has already been added. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param options The options parameters. */ update( @@ -107,7 +107,7 @@ export interface Workbooks { /** * Get a single workbook revision defined by its revisionId. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param resourceName The name of the Application Insights component resource. + * @param resourceName The name of the resource. * @param revisionId The id of the workbook's revision. * @param options The options parameters. */ diff --git a/sdk/applicationinsights/arm-appinsights/test/sampleTest.ts b/sdk/applicationinsights/arm-appinsights/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/applicationinsights/arm-appinsights/test/sampleTest.ts +++ b/sdk/applicationinsights/arm-appinsights/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() {