Skip to content

Commit

Permalink
CodeGen from PR 18996 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Migrate to net track2 for some resource-manager readmes (Azure#18996)

* migrate to net track2 for some mgmt RPs

* Update readme.md
  • Loading branch information
SDKAuto committed May 13, 2022
1 parent 8bbe5d5 commit bfdb5b1
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 49 deletions.
67 changes: 43 additions & 24 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions rush.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* This is the main configuration file for Rush.
* For full documentation, please see https://rushjs.io
*/ {
*/{
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json",
/**
* (Required) This specifies the version of the Rush engine to be used in this repo.
Expand Down Expand Up @@ -1690,6 +1690,11 @@
"packageName": "@azure/arm-servicelinker",
"projectFolder": "sdk/servicelinker/arm-servicelinker",
"versionPolicyName": "management"
},
{
"packageName": "@azure/arm-changes",
"projectFolder": "sdk/changes/arm-changes",
"versionPolicyName": "management"
}
]
}
}
10 changes: 5 additions & 5 deletions sdk/links/arm-links/_meta.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"commit": "a42f1b58607091c4f255ead152a8ef323fa0b280",
"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",
"commit": "a416080c85111fbe4e0a483a1b99f1126ca6e97c",
"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=/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-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"
}
11 changes: 6 additions & 5 deletions sdk/links/arm-links/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 ManagementLinkClient.",
"version": "2.0.2",
"version": "2.0.3",
"engines": {
"node": ">=12.0.0"
},
Expand Down Expand Up @@ -38,10 +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",
"@azure/arm-resources": "^5.0.0"
"@azure/dev-tool": "^1.0.0"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/links/arm-links",
"repository": {
Expand Down Expand Up @@ -92,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"
},
Expand All @@ -106,4 +107,4 @@
]
},
"autoPublish": true
}
}
36 changes: 35 additions & 1 deletion sdk/links/arm-links/src/managementLinkClient.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 { OperationsImpl, ResourceLinksImpl } from "./operations";
import { Operations, ResourceLinks } from "./operationsInterfaces";
Expand Down Expand Up @@ -45,7 +50,7 @@ export class ManagementLinkClient extends coreClient.ServiceClient {
credential: credentials
};

const packageDetails = `azsdk-js-arm-links/2.0.2`;
const packageDetails = `azsdk-js-arm-links/2.0.3`;
const userAgentPrefix =
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
Expand Down Expand Up @@ -95,6 +100,35 @@ export class ManagementLinkClient extends coreClient.ServiceClient {
this.apiVersion = options.apiVersion || "2016-09-01";
this.operations = new OperationsImpl(this);
this.resourceLinks = new ResourceLinksImpl(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 item.replace(/(?<==).*$/, apiVersion);
} else {
return item;
}
});
request.url = param[0] + "?" + newParams.join("&");
}
return next(request);
}
};
this.pipeline.addPolicy(apiVersionPolicy);
}

operations: Operations;
Expand Down
Loading

0 comments on commit bfdb5b1

Please sign in to comment.