Skip to content

Commit

Permalink
[deviceupdate] Update deviceupdate projects to use snippets extraction (
Browse files Browse the repository at this point in the history
#32791)

### Packages impacted by this PR

- @azure/arm-deviceupdate
- @azure-rest/iot-device-update

### Issues associated with this PR

- #32416

### Describe the problem that is addressed by this PR

Updates all projects under `deviceupdate` 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)
  • Loading branch information
mpodwysocki authored Jan 30, 2025
1 parent 172da8e commit 4f65772
Show file tree
Hide file tree
Showing 52 changed files with 219 additions and 328 deletions.
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

0 comments on commit 4f65772

Please sign in to comment.