Skip to content

Commit ef1cfa3

Browse files
authored
[appcomplianceautomation] Update snippets (#32477)
### Packages impacted by this PR - @azure/arm-appcomplianceautomation ### Issues associated with this PR - #32416 ### Describe the problem that is addressed by this PR Updates all `appcomplianceautomation` projects to use snippets extraction. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
1 parent 1093f4a commit ef1cfa3

File tree

4 files changed

+83
-44
lines changed

4 files changed

+83
-44
lines changed

sdk/appcomplianceautomation/arm-appcomplianceautomation/README.md

+28-15
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,35 @@ Set the values of the client ID, tenant ID, and client secret of the AAD applica
4848

4949
For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal).
5050

51-
```javascript
52-
const { AppComplianceAutomationToolForMicrosoft365 } = require("@azure/arm-appcomplianceautomation");
53-
const { DefaultAzureCredential } = require("@azure/identity");
54-
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details.
55-
56-
const client = new AppComplianceAutomationToolForMicrosoft365(new DefaultAzureCredential());
57-
58-
// For client-side applications running in the browser, use this code instead:
59-
// const credential = new InteractiveBrowserCredential({
60-
// tenantId: "<YOUR_TENANT_ID>",
61-
// clientId: "<YOUR_CLIENT_ID>"
62-
// });
63-
// const client = new AppComplianceAutomationToolForMicrosoft365(credential);
51+
Using Node.js and Node-like environments, you can use the `DefaultAzureCredential` class to authenticate the client.
52+
53+
```ts snippet:ReadmeSampleCreateClient_Node
54+
import { AppComplianceAutomationToolForMicrosoft365 } from "@azure/arm-appcomplianceautomation";
55+
import { DefaultAzureCredential } from "@azure/identity";
56+
57+
const subscriptionId = "00000000-0000-0000-0000-000000000000";
58+
const client = new AppComplianceAutomationToolForMicrosoft365(
59+
new DefaultAzureCredential(),
60+
subscriptionId,
61+
);
6462
```
6563

64+
For browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate.
65+
66+
```ts snippet:ReadmeSampleCreateClient_Browser
67+
import { InteractiveBrowserCredential } from "@azure/identity";
68+
import { AppComplianceAutomationToolForMicrosoft365 } from "@azure/arm-appcomplianceautomation";
69+
70+
const subscriptionId = "00000000-0000-0000-0000-000000000000";
71+
const credential = new InteractiveBrowserCredential({
72+
tenantId: "<YOUR_TENANT_ID>",
73+
clientId: "<YOUR_CLIENT_ID>",
74+
});
75+
const client = new AppComplianceAutomationToolForMicrosoft365(credential, subscriptionId);
76+
```
6677

6778
### JavaScript Bundle
79+
6880
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).
6981

7082
## Key concepts
@@ -79,8 +91,9 @@ To use this client library in the browser, first you need to use a bundler. For
7991

8092
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
8193

82-
```javascript
83-
const { setLogLevel } = require("@azure/logger");
94+
```ts snippet:SetLogLevel
95+
import { setLogLevel } from "@azure/logger";
96+
8497
setLogLevel("info");
8598
```
8699

sdk/appcomplianceautomation/arm-appcomplianceautomation/package.json

+12-15
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88
"node": ">=18.0.0"
99
},
1010
"dependencies": {
11-
"@azure/abort-controller": "^1.0.0",
12-
"@azure/core-auth": "^1.6.0",
13-
"@azure/core-client": "^1.7.0",
14-
"@azure/core-lro": "^2.5.4",
15-
"@azure/core-paging": "^1.2.0",
16-
"@azure/core-rest-pipeline": "^1.14.0",
17-
"tslib": "^2.2.0"
11+
"@azure/abort-controller": "^2.1.2",
12+
"@azure/core-auth": "^1.9.0",
13+
"@azure/core-client": "^1.9.2",
14+
"@azure/core-lro": "^2.7.2",
15+
"@azure/core-paging": "^1.6.2",
16+
"@azure/core-rest-pipeline": "^1.18.1",
17+
"tslib": "^2.8.1"
1818
},
1919
"keywords": [
2020
"node",
2121
"azure",
2222
"typescript",
2323
"browser",
24-
"isomorphic"
24+
"isomorphic",
25+
"cloud"
2526
],
2627
"license": "MIT",
2728
"main": "./dist/commonjs/index.js",
@@ -32,20 +33,16 @@
3233
"@azure-tools/test-recorder": "^4.1.0",
3334
"@azure-tools/test-utils-vitest": "^1.0.0",
3435
"@azure/dev-tool": "^1.0.0",
35-
"@azure/identity": "^4.0.1",
36+
"@azure/identity": "^4.5.0",
3637
"@types/node": "^18.0.0",
3738
"@vitest/browser": "^2.1.8",
3839
"@vitest/coverage-istanbul": "^2.1.8",
3940
"dotenv": "^16.0.0",
4041
"playwright": "^1.49.1",
41-
"tsx": "^4.7.1",
4242
"typescript": "~5.7.2",
4343
"vitest": "^2.1.8"
4444
},
45-
"repository": {
46-
"type": "git",
47-
"url": "https://github.com/Azure/azure-sdk-for-js.git"
48-
},
45+
"repository": "github:Azure/azure-sdk-for-js",
4946
"bugs": {
5047
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
5148
},
@@ -80,7 +77,7 @@
8077
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
8178
"unit-test:browser": "echo skipped",
8279
"unit-test:node": "dev-tool run test:vitest",
83-
"update-snippets": "echo skipped"
80+
"update-snippets": "dev-tool run update-snippets"
8481
},
8582
"sideEffects": false,
8683
"//metadata": {

sdk/appcomplianceautomation/arm-appcomplianceautomation/test/appcomplianceautomation_operations_test.spec.ts

+13-14
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
*/
88

9-
import {
10-
Recorder,
11-
RecorderStartOptions,
12-
isPlaybackMode,
13-
} from "@azure-tools/test-recorder";
9+
import type { RecorderStartOptions } from "@azure-tools/test-recorder";
10+
import { Recorder, isPlaybackMode } from "@azure-tools/test-recorder";
1411
import { createTestCredential } from "@azure-tools/test-credential";
15-
import { AppComplianceAutomationToolForMicrosoft365 } from "../src/appComplianceAutomationToolForMicrosoft365.js"
12+
import { AppComplianceAutomationToolForMicrosoft365 } from "../src/appComplianceAutomationToolForMicrosoft365.js";
1613
import { describe, it, assert, beforeEach, afterEach } from "vitest";
1714

1815
const replaceableVariables: Record<string, string> = {
19-
SUBSCRIPTION_ID: "88888888-8888-8888-8888-888888888888"
16+
SUBSCRIPTION_ID: "88888888-8888-8888-8888-888888888888",
2017
};
2118

2219
const recorderOptions: RecorderStartOptions = {
@@ -35,24 +32,26 @@ describe("appcomplianceautomation test", () => {
3532
let recorder: Recorder;
3633
let client: AppComplianceAutomationToolForMicrosoft365;
3734

38-
beforeEach(async function (ctx) {
35+
beforeEach(async (ctx) => {
3936
recorder = new Recorder(ctx);
4037
await recorder.start(recorderOptions);
4138
// This is an example of how the environment variables are used
4239
const credential = createTestCredential();
43-
client = new AppComplianceAutomationToolForMicrosoft365(credential, recorder.configureClientOptions({}));
40+
client = new AppComplianceAutomationToolForMicrosoft365(
41+
credential,
42+
recorder.configureClientOptions({}),
43+
);
4444
});
4545

46-
afterEach(async function () {
46+
afterEach(async () => {
4747
await recorder.stop();
4848
});
4949

50-
it("operations list test", async function () {
50+
it("operations list test", async () => {
5151
const resArray = new Array();
52-
for await (let item of client.operations.list()) {
52+
for await (const item of client.operations.list()) {
5353
resArray.push(item);
5454
}
5555
assert.notEqual(resArray.length, 0);
5656
});
57-
58-
})
57+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
import { describe, it } from "vitest";
5+
import { setLogLevel } from "@azure/logger";
6+
import { DefaultAzureCredential, InteractiveBrowserCredential } from "@azure/identity";
7+
import { AppComplianceAutomationToolForMicrosoft365 } from "@azure/arm-appcomplianceautomation";
8+
9+
describe("snippets", () => {
10+
it("ReadmeSampleCreateClient_Node", async () => {
11+
const subscriptionId = "00000000-0000-0000-0000-000000000000";
12+
const client = new AppComplianceAutomationToolForMicrosoft365(
13+
new DefaultAzureCredential(),
14+
subscriptionId,
15+
);
16+
});
17+
18+
it("ReadmeSampleCreateClient_Browser", async () => {
19+
const subscriptionId = "00000000-0000-0000-0000-000000000000";
20+
const credential = new InteractiveBrowserCredential({
21+
tenantId: "<YOUR_TENANT_ID>",
22+
clientId: "<YOUR_CLIENT_ID>",
23+
});
24+
const client = new AppComplianceAutomationToolForMicrosoft365(credential, subscriptionId);
25+
});
26+
27+
it("SetLogLevel", async () => {
28+
setLogLevel("info");
29+
});
30+
});

0 commit comments

Comments
 (0)