Skip to content

Commit d8fb4f6

Browse files
authored
[analysis-services] Update @azure/arm-analysisservices snippets (#32471)
### Packages impacted by this PR - @azure/arm-analysisservices ### Issues associated with this PR - #32416 ### Describe the problem that is addressed by this PR Adds snippets for all analysis services SDKs ### 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 f901afa commit d8fb4f6

File tree

6 files changed

+75
-45
lines changed

6 files changed

+75
-45
lines changed

sdk/analysisservices/arm-analysisservices/README.md

+21-12
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,28 @@ 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://learn.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal).
5050

51-
```javascript
52-
const { AzureAnalysisServices } = require("@azure/arm-analysisservices");
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.
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 { AzureAnalysisServices } from "@azure/arm-analysisservices";
55+
import { DefaultAzureCredential } from "@azure/identity";
5556

5657
const subscriptionId = "00000000-0000-0000-0000-000000000000";
5758
const client = new AzureAnalysisServices(new DefaultAzureCredential(), subscriptionId);
59+
```
60+
61+
For browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate.
5862

59-
// For client-side applications running in the browser, use this code instead:
60-
// const credential = new InteractiveBrowserCredential({
61-
// tenantId: "<YOUR_TENANT_ID>",
62-
// clientId: "<YOUR_CLIENT_ID>"
63-
// });
64-
// const client = new AzureAnalysisServices(credential, subscriptionId);
63+
```ts snippet:ReadmeSampleCreateClient_Browser
64+
import { InteractiveBrowserCredential } from "@azure/identity";
65+
import { AzureAnalysisServices } from "@azure/arm-analysisservices";
66+
67+
const subscriptionId = "00000000-0000-0000-0000-000000000000";
68+
const credential = new InteractiveBrowserCredential({
69+
tenantId: "<YOUR_TENANT_ID>",
70+
clientId: "<YOUR_CLIENT_ID>",
71+
});
72+
const client = new AzureAnalysisServices(credential, subscriptionId);
6573
```
6674

6775
### JavaScript Bundle
@@ -80,8 +88,9 @@ To use this client library in the browser, first you need to use a bundler. For
8088

8189
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`:
8290

83-
```javascript
84-
const { setLogLevel } = require("@azure/logger");
91+
```ts snippet:SetLogLevel
92+
import { setLogLevel } from "@azure/logger";
93+
8594
setLogLevel("info");
8695
```
8796

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
2+
3+
export default azsdkEslint.config([]);

sdk/analysisservices/arm-analysisservices/package.json

+12-16
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.3.0",
13-
"@azure/core-client": "^1.6.1",
14-
"@azure/core-lro": "^2.2.0",
15-
"@azure/core-paging": "^1.2.0",
16-
"@azure/core-rest-pipeline": "^1.8.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,19 +33,14 @@
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",
37-
"@vitest/browser": "^2.1.8",
3838
"@vitest/coverage-istanbul": "^2.1.8",
39-
"playwright": "^1.49.1",
4039
"typescript": "~5.7.2",
4140
"vitest": "^2.1.8"
4241
},
4342
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/analysisservices/arm-analysisservices",
44-
"repository": {
45-
"type": "git",
46-
"url": "https://github.com/Azure/azure-sdk-for-js.git"
47-
},
43+
"repository": "github:Azure/azure-sdk-for-js",
4844
"bugs": {
4945
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
5046
},
@@ -79,7 +75,7 @@
7975
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
8076
"unit-test:browser": "echo skipped",
8177
"unit-test:node": "dev-tool run test:vitest",
82-
"update-snippets": "echo skipped"
78+
"update-snippets": "dev-tool run update-snippets"
8379
},
8480
"sideEffects": false,
8581
"//metadata": {
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
1-
/*
2-
* Copyright (c) Microsoft Corporation.
3-
* Licensed under the MIT License.
4-
*
5-
* Code generated by Microsoft (R) AutoRest Code Generator.
6-
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
7-
*/
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
83

9-
import {
10-
Recorder,
11-
RecorderStartOptions
12-
} from "@azure-tools/test-recorder";
13-
import { afterEach, beforeEach, describe, it } from "vitest";
4+
import type { RecorderStartOptions } from "@azure-tools/test-recorder";
5+
import { Recorder } from "@azure-tools/test-recorder";
6+
import { afterEach, beforeEach, describe, it, assert } from "vitest";
147

158
const replaceableVariables: Record<string, string> = {
169
AZURE_CLIENT_ID: "azure_client_id",
1710
AZURE_CLIENT_SECRET: "azure_client_secret",
1811
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
19-
SUBSCRIPTION_ID: "azure_subscription_id"
12+
SUBSCRIPTION_ID: "azure_subscription_id",
2013
};
2114

2215
const recorderOptions: RecorderStartOptions = {
@@ -30,16 +23,16 @@ const recorderOptions: RecorderStartOptions = {
3023
describe("My test", () => {
3124
let recorder: Recorder;
3225

33-
beforeEach(async function (ctx) {
26+
beforeEach(async (ctx) => {
3427
recorder = new Recorder(ctx);
3528
await recorder.start(recorderOptions);
3629
});
3730

38-
afterEach(async function () {
31+
afterEach(async () => {
3932
await recorder.stop();
4033
});
4134

42-
it("sample test", async function () {
43-
console.log("Hi, I'm a test!");
35+
it("sample test", async () => {
36+
assert(true);
4437
});
4538
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
import { AzureAnalysisServices } from "@azure/arm-analysisservices";
5+
import { DefaultAzureCredential, InteractiveBrowserCredential } from "@azure/identity";
6+
import { setLogLevel } from "@azure/logger";
7+
import { describe, it } from "vitest";
8+
9+
describe("snippets", () => {
10+
it("ReadmeSampleCreateClient_Node", async () => {
11+
const subscriptionId = "00000000-0000-0000-0000-000000000000";
12+
const client = new AzureAnalysisServices(new DefaultAzureCredential(), subscriptionId);
13+
});
14+
15+
it("ReadmeSampleCreateClient_Browser", async () => {
16+
const subscriptionId = "00000000-0000-0000-0000-000000000000";
17+
const credential = new InteractiveBrowserCredential({
18+
tenantId: "<YOUR_TENANT_ID>",
19+
clientId: "<YOUR_CLIENT_ID>",
20+
});
21+
const client = new AzureAnalysisServices(credential, subscriptionId);
22+
});
23+
24+
it("SetLogLevel", async () => {
25+
setLogLevel("info");
26+
});
27+
});

sdk/analysisservices/arm-analysisservices/vitest.browser.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export default mergeConfig(
1212
include: [
1313
"dist-test/browser/test/**/*.spec.js",
1414
],
15+
hookTimeout: 1200000,
16+
testTimeout: 1200000,
1517
},
1618
}),
1719
);

0 commit comments

Comments
 (0)