Skip to content

Commit

Permalink
CodeGen from PR 21203 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 6dec761fe5805a570da5e99a179d6bfab1290724 into cacf126b6a1d44e144a999dce18e34bf520521c5
  • Loading branch information
SDKAuto committed Oct 20, 2022
1 parent 03e4fa2 commit cf421c4
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 124 deletions.
94 changes: 51 additions & 43 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions sdk/changes/arm-changes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Release History

## 1.0.1 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes


## 1.1.0 (2022-10-20)

**Features**

- Added Interface ChangeResourceResult


## 1.0.0 (2022-05-09)

The package of @azure/arm-changes is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/js-track2-quickstart).
8 changes: 4 additions & 4 deletions sdk/changes/arm-changes/_meta.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"commit": "ee15422a60409285806e1673e191fe69333a7743",
"commit": "58c77a8df2fa09cf1fb85d2f91e75564c9d1a444",
"readme": "specification/resources/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\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true",
"autorest_command": "autorest --version=3.8.4 --typescript --modelerfour.lenient-model-deduplication --azure-arm --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/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-rc.2",
"repository_url": "https://github.com/Azure/azure-rest-api-specs.git",
"release_tool": "@azure-tools/js-sdk-release-tools@2.3.0",
"use": "@autorest/typescript@6.0.0-alpha.19.20220408.1"
"release_tool": "@azure-tools/js-sdk-release-tools@2.4.4",
"use": "@autorest/typescript@6.0.0-rc.2"
}
29 changes: 12 additions & 17 deletions sdk/changes/arm-changes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sdk-type": "mgmt",
"author": "Microsoft Corporation",
"description": "A generated SDK for ChangesClient.",
"version": "1.0.1",
"version": "1.1.0",
"engines": {
"node": ">=14.0.0"
},
Expand Down Expand Up @@ -34,13 +34,17 @@
"mkdirp": "^1.0.4",
"rollup": "^2.66.1",
"rollup-plugin-sourcemaps": "^0.6.3",
"typescript": "~4.2.0",
"typescript": "~4.6.0",
"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"
"@types/chai": "^4.2.8",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"@azure/dev-tool": "^1.0.0"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/changes/arm-changes",
"repository": {
Expand Down Expand Up @@ -91,9 +95,8 @@
"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:browser": "echo skipped",
"docs": "echo skipped"
"integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'",
"integration-test:browser": "echo skipped"
},
"sideEffects": false,
"//metadata": {
Expand All @@ -104,13 +107,5 @@
}
]
},
"autoPublish": true,
"//sampleConfiguration": {
"productName": "",
"productSlugs": [
"azure"
],
"disableDocsMs": true,
"apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-changes?view=azure-node-preview"
}
}
"autoPublish": true
}
4 changes: 2 additions & 2 deletions sdk/changes/arm-changes/review/arm-changes.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export interface ChangeResourceListResult {
}

// @public
export type ChangeResourceResult = Resource & {
export interface ChangeResourceResult extends Resource {
properties?: ChangeProperties;
};
}

// @public
export interface Changes {
Expand Down
73 changes: 57 additions & 16 deletions sdk/changes/arm-changes/src/changesClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { ChangesImpl } from "./operations";
import { Changes } from "./operationsInterfaces";
Expand Down Expand Up @@ -46,7 +51,7 @@ export class ChangesClient extends coreClient.ServiceClient {
credential: credentials
};

const packageDetails = `azsdk-js-arm-changes/1.0.1`;
const packageDetails = `azsdk-js-arm-changes/1.1.0`;
const userAgentPrefix =
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
Expand All @@ -66,27 +71,34 @@ export class ChangesClient extends coreClient.ServiceClient {
};
super(optionsWithDefaults);

let bearerTokenAuthenticationPolicyFound: boolean = false;
if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) {
const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies();
const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(
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
}
})
);
}
}
if (
!options ||
!options.pipeline ||
options.pipeline.getOrderedPolicies().length == 0 ||
!bearerTokenAuthenticationPolicyFound
) {
this.pipeline.removePolicy({
name: coreRestPipeline.bearerTokenAuthenticationPolicyName
});
this.pipeline.addPolicy(
coreRestPipeline.bearerTokenAuthenticationPolicy({
credential: credentials,
scopes: `${optionsWithDefaults.credentialScopes}`,
challengeCallbacks: {
authorizeRequestOnChallenge:
coreClient.authorizeRequestOnClaimChallenge
}
})
);
}
// Parameter assignments
this.subscriptionId = subscriptionId;
Expand All @@ -95,6 +107,35 @@ export class ChangesClient extends coreClient.ServiceClient {
this.$host = options.$host || "https://management.azure.com";
this.apiVersion = options.apiVersion || "2022-05-01";
this.changes = new ChangesImpl(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<PipelineResponse> {
const param = request.url.split("?");
if (param.length > 1) {
const newParams = param[1].split("&").map((item) => {
if (item.indexOf("api-version") > -1) {
return "api-version=" + apiVersion;
} else {
return item;
}
});
request.url = param[0] + "?" + newParams.join("&");
}
return next(request);
}
};
this.pipeline.addPolicy(apiVersionPolicy);
}

changes: Changes;
Expand Down
5 changes: 3 additions & 2 deletions sdk/changes/arm-changes/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ export interface ErrorAdditionalInfo {
}

/** Change Resource */
export type ChangeResourceResult = Resource & {
export interface ChangeResourceResult extends Resource {
/** The properties of a change */
properties?: ChangeProperties;
};
}

/** Defines values for ChangeType. */
export type ChangeType = "Update" | "Delete" | "Create";
/** Defines values for PropertyChangeType. */
Expand Down
39 changes: 17 additions & 22 deletions sdk/changes/arm-changes/test/sampleTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> = {
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() {
Expand Down
16 changes: 9 additions & 7 deletions sdk/changes/arm-changes/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
],
"declaration": true,
"outDir": "./dist-esm",
"importHelpers": true,
"paths": {
"@azure/arm-changes": [
"./src/index"
]
}
"importHelpers": true
},
"include": [
"./src/**/*.ts",
"./test/**/*.ts",
"samples-dev/**/*.ts"
"./test/**/*.ts",
"./test/**/*.ts",
"./test/**/*.ts",
"./test/**/*.ts",
"./test/**/*.ts",
"./test/**/*.ts",
"./test/**/*.ts",
"./test/**/*.ts"
],
"exclude": [
"node_modules"
Expand Down

0 comments on commit cf421c4

Please sign in to comment.