Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR @azure/arm-features] Updated description for HTTP HEAD by resource ID #1150

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sdk/features/arm-features/_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/[email protected].20220408.1 --generate-sample=true",
"commit": "3908ebda6b1eb5d683b0808e1d3200b6be2bb5ce",
"readme": "specification/resources/resource-manager/readme.md",
"autorest_command": "autorest --version=3.7.3 --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/[email protected].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/[email protected].20220408.1"
"release_tool": "@azure-tools/js-sdk-release-tools@2.4.0",
"use": "@autorest/[email protected].20220425.1"
}
22 changes: 8 additions & 14 deletions sdk/features/arm-features/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 FeatureClient.",
"version": "3.0.1",
"version": "3.0.2",
"engines": {
"node": ">=12.0.0"
},
Expand Down Expand Up @@ -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/features/arm-features",
"repository": {
Expand Down Expand Up @@ -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"
},
Expand All @@ -104,13 +106,5 @@
}
]
},
"autoPublish": true,
"//sampleConfiguration": {
"productName": "",
"productSlugs": [
"azure"
],
"disableDocsMs": true,
"apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-features?view=azure-node-preview"
}
}
"autoPublish": true
}
36 changes: 35 additions & 1 deletion sdk/features/arm-features/src/featureClient.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 { PagedAsyncIterableIterator } from "@azure/core-paging";
import {
Expand Down Expand Up @@ -62,7 +67,7 @@ export class FeatureClient extends coreClient.ServiceClient {
credential: credentials
};

const packageDetails = `azsdk-js-arm-features/3.0.1`;
const packageDetails = `azsdk-js-arm-features/3.0.2`;
const userAgentPrefix =
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
Expand Down Expand Up @@ -114,6 +119,35 @@ export class FeatureClient extends coreClient.ServiceClient {
this.subscriptionFeatureRegistrations = new SubscriptionFeatureRegistrationsImpl(
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);
}

/**
Expand Down
85 changes: 18 additions & 67 deletions sdk/features/arm-features/test/sampleTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,86 +7,37 @@
*/

import {
env,
record,
RecorderEnvironmentSetup,
Recorder,
delay,
isPlaybackMode
RecorderStartOptions,
env
} from "@azure-tools/test-recorder";
import * as assert from "assert";
import { ClientSecretCredential } from "@azure/identity";
import { FeatureClient } from "../src/featureClient";

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: []
import { assert } from "chai";
import { Context } from "mocha";

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"
};

export const testPollingOptions = {
updateIntervalInMs: isPlaybackMode() ? 0 : undefined,
const recorderOptions: RecorderStartOptions = {
envSetupForPlayback: replaceableVariables
};

describe("Features test", () => {
describe("My test", () => {
let recorder: Recorder;
let subscriptionId: string;
let client: FeatureClient;
let location: string;
let resourceGroup: string;

beforeEach(async function() {
recorder = record(this, recorderEnvSetup);
subscriptionId = env.SUBSCRIPTION_ID;
// This is an example of how the environment variables are used
const credential = new ClientSecretCredential(
env.AZURE_TENANT_ID,
env.AZURE_CLIENT_ID,
env.AZURE_CLIENT_SECRET
);
client = new FeatureClient(credential, subscriptionId);
location = "eastus";
resourceGroup = "myjstest";
beforeEach(async function(this: Context) {
recorder = new Recorder(this.currentTest);
await recorder.start(recorderOptions);
});

afterEach(async function() {
await recorder.stop();
});

it("features listall test", async function() {
const arrayList = [];
for await (const item of client.features.listAll()) {
arrayList.push(item);
}
assert.notEqual(arrayList.length,0);
});

it("features list test", async function() {
const arrayList = [];
for await (const item of client.features.list("Microsoft.Compute")) {
arrayList.push(item);
}
assert.notEqual(arrayList.length,0);
});

it("features get test", async function() {
const arrayList = new Array();
for await (const item of client.features.list("Microsoft.Compute")) {
arrayList.push(item);
}
const featureName = arrayList[0].name.split("/")[1];
const feature = await client.features.get("Microsoft.Compute", featureName);
assert.equal(feature.name,"Microsoft.Compute/"+featureName);
it("sample test", async function() {
console.log("Hi, I'm a test!");
});
});
11 changes: 2 additions & 9 deletions sdk/features/arm-features/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,12 @@
],
"declaration": true,
"outDir": "./dist-esm",
"importHelpers": true,
"paths": {
"@azure/arm-features": [
"./src/index"
]
}
"importHelpers": true
},
"include": [
"./src/**/*.ts",
"./test/**/*.ts",
"samples-dev/**/*.ts",
"./test/**/*.ts",
"samples-dev/**/*.ts"
"./test/**/*.ts"
],
"exclude": [
"node_modules"
Expand Down