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

[deviceupdate] Update deviceupdate projects to use snippets extraction #32791

Merged
merged 24 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
335cc69
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Jan 29, 2025
4117ac3
Migration: Update test config
mpodwysocki Jan 29, 2025
81b088a
Migration: Clean up files
mpodwysocki Jan 29, 2025
cfad50f
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Jan 29, 2025
e0d5fc6
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Jan 29, 2025
b7df039
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Jan 29, 2025
ac0401a
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Jan 29, 2025
2f2c259
Migration: Apply codemod: "addViHelper"
mpodwysocki Jan 29, 2025
13f1d5f
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Jan 29, 2025
932dfec
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Jan 29, 2025
676ccfa
Migration: rushx format
mpodwysocki Jan 29, 2025
8241d3f
[deviceupdate] Migrate deviceupdate packages to snippet extraction
mpodwysocki Jan 29, 2025
3b102a7
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Jan 29, 2025
386c808
Migration: Update test config
mpodwysocki Jan 29, 2025
2848c96
Migration: Clean up files
mpodwysocki Jan 29, 2025
42aad1b
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Jan 29, 2025
8b0ca02
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Jan 29, 2025
b0ba01a
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Jan 29, 2025
2bc8e11
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Jan 29, 2025
ee05182
Migration: Apply codemod: "addViHelper"
mpodwysocki Jan 29, 2025
7c2f011
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Jan 29, 2025
2b18f4d
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Jan 29, 2025
a1e3752
Migration: rushx format
mpodwysocki Jan 29, 2025
05a2386
[deviceupdate] Migrate deviceupdate packages to snippet extraction
mpodwysocki Jan 29, 2025
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
33 changes: 21 additions & 12 deletions sdk/deviceupdate/arm-deviceupdate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,28 @@ Set the values of the client ID, tenant ID, and client secret of the AAD applica

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).

```javascript
const { DeviceUpdate } = require("@azure/arm-deviceupdate");
const { DefaultAzureCredential } = require("@azure/identity");
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details.
Using Node.js and Node-like environments, you can use the `DefaultAzureCredential` class to authenticate the client.

```ts snippet:ReadmeSampleCreateClient_Node
import { DeviceUpdate } from "@azure/arm-deviceupdate";
import { DefaultAzureCredential } from "@azure/identity";

const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceUpdate(new DefaultAzureCredential(), subscriptionId);
```

For browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate.

// For client-side applications running in the browser, use this code instead:
// const credential = new InteractiveBrowserCredential({
// tenantId: "<YOUR_TENANT_ID>",
// clientId: "<YOUR_CLIENT_ID>"
// });
// const client = new DeviceUpdate(credential, subscriptionId);
```ts snippet:ReadmeSampleCreateClient_Browser
import { InteractiveBrowserCredential } from "@azure/identity";
import { DeviceUpdate } from "@azure/arm-deviceupdate";

const subscriptionId = "00000000-0000-0000-0000-000000000000";
const credential = new InteractiveBrowserCredential({
tenantId: "<YOUR_TENANT_ID>",
clientId: "<YOUR_CLIENT_ID>",
});
const client = new DeviceUpdate(credential, subscriptionId);
```

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

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

```javascript
const { setLogLevel } = require("@azure/logger");
```ts snippet:SetLogLevel
import { setLogLevel } from "@azure/logger";

setLogLevel("info");
```

Expand Down
2 changes: 1 addition & 1 deletion sdk/deviceupdate/arm-deviceupdate/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"repository_url": "https://github.com/Azure/azure-rest-api-specs.git",
"release_tool": "@azure-tools/[email protected]",
"use": "@autorest/[email protected]"
}
}
27 changes: 13 additions & 14 deletions sdk/deviceupdate/arm-deviceupdate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
"node": ">=18.0.0"
},
"dependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/core-auth": "^1.3.0",
"@azure/core-client": "^1.7.0",
"@azure/abort-controller": "^2.1.2",
"@azure/core-auth": "^1.9.0",
"@azure/core-client": "^1.9.2",
"@azure/core-lro": "^2.5.4",
"@azure/core-paging": "^1.2.0",
"@azure/core-rest-pipeline": "^1.12.0",
"tslib": "^2.2.0"
"@azure/core-paging": "^1.6.2",
"@azure/core-rest-pipeline": "^1.18.2",
"tslib": "^2.8.1"
},
"keywords": [
"node",
"azure",
"typescript",
"browser",
"isomorphic"
"isomorphic",
"cloud"
],
"license": "MIT",
"main": "./dist/commonjs/index.js",
Expand All @@ -32,19 +33,17 @@
"@azure-tools/test-recorder": "^4.1.0",
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/identity": "^4.0.1",
"@azure/identity": "^4.6.0",
"@azure/logger": "^1.1.4",
"@types/node": "^18.0.0",
"@vitest/browser": "^3.0.3",
"@vitest/coverage-istanbul": "^3.0.3",
"dotenv": "^16.0.0",
"playwright": "^1.49.1",
"playwright": "^1.50.0",
"typescript": "~5.7.2",
"vitest": "^3.0.3"
},
"repository": {
"type": "git",
"url": "https://github.com/Azure/azure-sdk-for-js.git"
},
"repository": "github:Azure/azure-sdk-for-js",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
Expand Down Expand Up @@ -79,7 +78,7 @@
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "echo skipped",
"unit-test:node": "dev-tool run test:vitest",
"update-snippets": "echo skipped"
"update-snippets": "dev-tool run update-snippets"
},
"sideEffects": false,
"//metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Creates or updates Account.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Create.json
*/
async function createsOrUpdatesAccount() {
async function createsOrUpdatesAccount(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand Down Expand Up @@ -46,7 +46,7 @@ async function createsOrUpdatesAccount() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
createsOrUpdatesAccount();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Deletes account.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Delete.json
*/
async function deletesAnAccount() {
async function deletesAnAccount(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -31,7 +31,7 @@ async function deletesAnAccount() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
deletesAnAccount();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Returns account details for the given account name.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Get.json
*/
async function getsAccountDetails() {
async function getsAccountDetails(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -28,7 +28,7 @@ async function getsAccountDetails() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
getsAccountDetails();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Checks whether account exists.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Head.json
*/
async function checksWhetherAccountExists() {
async function checksWhetherAccountExists(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -28,7 +28,7 @@ async function checksWhetherAccountExists() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
checksWhetherAccountExists();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Returns list of Accounts.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_List.json
*/
async function getsListOfAccounts() {
async function getsListOfAccounts(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -32,7 +32,7 @@ async function getsListOfAccounts() {
console.log(resArray);
}

async function main() {
async function main(): Promise<void> {
getsListOfAccounts();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Returns list of Accounts.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_List.json
*/
async function getListOfAccounts() {
async function getListOfAccounts(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -28,7 +28,7 @@ async function getListOfAccounts() {
console.log(resArray);
}

async function main() {
async function main(): Promise<void> {
getListOfAccounts();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Updates account's patchable properties
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Update.json
*/
async function updatesAccount() {
async function updatesAccount(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -33,7 +33,7 @@ async function updatesAccount() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
updatesAccount();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import "dotenv/config";
* @summary Checks ADU resource name availability.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/CheckNameAvailability_AlreadyExists.json
*/
async function checkNameAvailabilityAlreadyExists() {
async function checkNameAvailabilityAlreadyExists(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -38,7 +38,7 @@ async function checkNameAvailabilityAlreadyExists() {
* @summary Checks ADU resource name availability.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/CheckNameAvailability_Available.json
*/
async function checkNameAvailabilityAvailable() {
async function checkNameAvailabilityAvailable(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -52,7 +52,7 @@ async function checkNameAvailabilityAvailable() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
checkNameAvailabilityAlreadyExists();
checkNameAvailabilityAvailable();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Creates or updates instance.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Create.json
*/
async function createsOrUpdatesInstance() {
async function createsOrUpdatesInstance(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand Down Expand Up @@ -50,7 +50,7 @@ async function createsOrUpdatesInstance() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
createsOrUpdatesInstance();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Deletes instance.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Delete.json
*/
async function deletesInstance() {
async function deletesInstance(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -33,7 +33,7 @@ async function deletesInstance() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
deletesInstance();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Returns instance details for the given instance and account name.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Get.json
*/
async function getsListOfInstances() {
async function getsListOfInstances(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -33,7 +33,7 @@ async function getsListOfInstances() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
getsListOfInstances();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Checks whether instance exists.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Head.json
*/
async function checksWhetherInstanceExists() {
async function checksWhetherInstanceExists(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -33,7 +33,7 @@ async function checksWhetherInstanceExists() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
checksWhetherInstanceExists();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Returns instances for the given account name.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_ListByAccount.json
*/
async function getsListOfInstancesByAccount() {
async function getsListOfInstancesByAccount(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -34,7 +34,7 @@ async function getsListOfInstancesByAccount() {
console.log(resArray);
}

async function main() {
async function main(): Promise<void> {
getsListOfInstancesByAccount();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Updates instance's tags.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Update.json
*/
async function updatesInstance() {
async function updatesInstance(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -35,7 +35,7 @@ async function updatesInstance() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
updatesInstance();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "dotenv/config";
* @summary Returns list of operations for Microsoft.DeviceUpdate resource provider.
* x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Operations_List.json
*/
async function getsListOfOperations() {
async function getsListOfOperations(): Promise<void> {
const subscriptionId =
process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
Expand All @@ -28,7 +28,7 @@ async function getsListOfOperations() {
console.log(resArray);
}

async function main() {
async function main(): Promise<void> {
getsListOfOperations();
}

Expand Down
Loading
Loading