Skip to content

Commit

Permalink
[deviceregistry] Update deviceregistry projects to use snippets extra…
Browse files Browse the repository at this point in the history
…ction (#32790)

### Packages impacted by this PR

- @azure/arm-deviceregistry

### Issues associated with this PR

- #32416

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

Updates all projects under `deviceregistry` 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 701a55b commit 2e79f92
Show file tree
Hide file tree
Showing 91 changed files with 249 additions and 216 deletions.
33 changes: 21 additions & 12 deletions sdk/deviceregistry/arm-deviceregistry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,28 @@ You will also need to **register a new AAD application and grant access to Azure

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 { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry");
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 { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry";
import { DefaultAzureCredential } from "@azure/identity";

const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(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 DeviceRegistryManagementClient(credential, subscriptionId);
```ts snippet:ReadmeSampleCreateClient_Browser
import { InteractiveBrowserCredential } from "@azure/identity";
import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry";

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

### JavaScript Bundle
Expand All @@ -81,8 +89,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
20 changes: 10 additions & 10 deletions sdk/deviceregistry/arm-deviceregistry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,26 @@
"dependencies": {
"@azure-rest/core-client": "^2.3.1",
"@azure/abort-controller": "^2.1.2",
"@azure/core-auth": "^1.6.0",
"@azure/core-auth": "^1.9.0",
"@azure/core-lro": "^3.1.0",
"@azure/core-rest-pipeline": "^1.5.0",
"@azure/core-util": "^1.9.2",
"@azure/logger": "^1.0.0",
"tslib": "^2.6.2"
"@azure/core-rest-pipeline": "^1.18.2",
"@azure/core-util": "^1.11.0",
"@azure/logger": "^1.1.4",
"tslib": "^2.8.1"
},
"devDependencies": {
"@azure-tools/test-credential": "^2.0.0",
"@azure-tools/test-recorder": "^4.1.0",
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/identity": "^4.2.1",
"@azure/identity": "^4.6.0",
"@types/node": "^18.0.0",
"@vitest/browser": "^3.0.3",
"@vitest/coverage-istanbul": "^3.0.3",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"playwright": "^1.49.1",
"playwright": "^1.50.0",
"typescript": "~5.7.2",
"vitest": "^3.0.3"
},
Expand All @@ -95,7 +95,7 @@
"generate:client": "echo skipped",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"integration-test:node": "dev-tool run test:vitest --esm",
"lint": "echo skipped",
"lint:fix": "echo skipped",
"minify": "dev-tool run vendored uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js",
Expand All @@ -104,9 +104,9 @@
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
"test:node": "npm run clean && dev-tool run build-package && npm run unit-test:node && npm run integration-test:node",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "npm run build:test && dev-tool run test:vitest --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"
},
"//sampleConfiguration": {
"productName": "@azure/arm-deviceregistry",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary create a AssetEndpointProfile
* x-ms-original-file: 2024-09-01-preview/Create_AssetEndpointProfile.json
*/
async function createAssetEndpointProfile() {
async function createAssetEndpointProfile(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand Down Expand Up @@ -40,7 +40,7 @@ async function createAssetEndpointProfile() {
* @summary create a AssetEndpointProfile
* x-ms-original-file: 2024-09-01-preview/Create_AssetEndpointProfile_With_DiscoveredAepRef.json
*/
async function createAssetEndpointProfileWithDiscoveredAepRef() {
async function createAssetEndpointProfileWithDiscoveredAepRef(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand All @@ -65,7 +65,7 @@ async function createAssetEndpointProfileWithDiscoveredAepRef() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
await createAssetEndpointProfile();
await createAssetEndpointProfileWithDiscoveredAepRef();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary delete a AssetEndpointProfile
* x-ms-original-file: 2024-09-01-preview/Delete_AssetEndpointProfile.json
*/
async function deleteAssetEndpointProfile() {
async function deleteAssetEndpointProfile(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
await client.assetEndpointProfiles.delete("myResourceGroup", "my-assetendpointprofile");
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary get a AssetEndpointProfile
* x-ms-original-file: 2024-09-01-preview/Get_AssetEndpointProfile.json
*/
async function getAssetEndpointProfile() {
async function getAssetEndpointProfile(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand All @@ -27,7 +27,7 @@ async function getAssetEndpointProfile() {
* @summary get a AssetEndpointProfile
* x-ms-original-file: 2024-09-01-preview/Get_AssetEndpointProfile_With_SyncStatus.json
*/
async function getAssetEndpointProfileWithSyncStatus() {
async function getAssetEndpointProfileWithSyncStatus(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand All @@ -38,7 +38,7 @@ async function getAssetEndpointProfileWithSyncStatus() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
await getAssetEndpointProfile();
await getAssetEndpointProfileWithSyncStatus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary list AssetEndpointProfile resources by resource group
* x-ms-original-file: 2024-09-01-preview/List_AssetEndpointProfiles_ResourceGroup.json
*/
async function listAssetEndpointProfilesResourceGroup() {
async function listAssetEndpointProfilesResourceGroup(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand All @@ -22,7 +22,7 @@ async function listAssetEndpointProfilesResourceGroup() {
console.log(resArray);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary list AssetEndpointProfile resources by subscription ID
* x-ms-original-file: 2024-09-01-preview/List_AssetEndpointProfiles_Subscription.json
*/
async function listAssetEndpointProfilesSubscription() {
async function listAssetEndpointProfilesSubscription(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand All @@ -22,7 +22,7 @@ async function listAssetEndpointProfilesSubscription() {
console.log(resArray);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary update a AssetEndpointProfile
* x-ms-original-file: 2024-09-01-preview/Update_AssetEndpointProfile.json
*/
async function updateAssetEndpointProfile() {
async function updateAssetEndpointProfile(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand All @@ -24,7 +24,7 @@ async function updateAssetEndpointProfile() {
console.log(result);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary create a Asset
* x-ms-original-file: 2024-09-01-preview/Create_Asset_Without_DisplayName.json
*/
async function createAssetWithoutDisplayName() {
async function createAssetWithoutDisplayName(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand Down Expand Up @@ -85,7 +85,7 @@ async function createAssetWithoutDisplayName() {
* @summary create a Asset
* x-ms-original-file: 2024-09-01-preview/Create_Asset_Without_ExternalAssetId.json
*/
async function createAssetWithoutExternalAssetId() {
async function createAssetWithoutExternalAssetId(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand Down Expand Up @@ -160,7 +160,7 @@ async function createAssetWithoutExternalAssetId() {
* @summary create a Asset
* x-ms-original-file: 2024-09-01-preview/Create_Asset_With_DiscoveredAssetRef.json
*/
async function createAssetWithDiscoveredAssetRefs() {
async function createAssetWithDiscoveredAssetRefs(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand Down Expand Up @@ -237,7 +237,7 @@ async function createAssetWithDiscoveredAssetRefs() {
* @summary create a Asset
* x-ms-original-file: 2024-09-01-preview/Create_Asset_With_ExternalAssetId.json
*/
async function createAssetWithExternalAssetId() {
async function createAssetWithExternalAssetId(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand Down Expand Up @@ -307,7 +307,7 @@ async function createAssetWithExternalAssetId() {
console.log(result);
}

async function main() {
async function main(): Promise<void> {
await createAssetWithoutDisplayName();
await createAssetWithoutExternalAssetId();
await createAssetWithDiscoveredAssetRefs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary delete a Asset
* x-ms-original-file: 2024-09-01-preview/Delete_Asset.json
*/
async function deleteAsset() {
async function deleteAsset(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
await client.assets.delete("myResourceGroup", "my-asset");
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary get a Asset
* x-ms-original-file: 2024-09-01-preview/Get_Asset.json
*/
async function getAsset() {
async function getAsset(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand All @@ -24,15 +24,15 @@ async function getAsset() {
* @summary get a Asset
* x-ms-original-file: 2024-09-01-preview/Get_Asset_With_SyncStatus.json
*/
async function getAssetWithSyncStatus() {
async function getAssetWithSyncStatus(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
const result = await client.assets.get("myResourceGroup", "my-asset");
console.log(result);
}

async function main() {
async function main(): Promise<void> {
await getAsset();
await getAssetWithSyncStatus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary list Asset resources by resource group
* x-ms-original-file: 2024-09-01-preview/List_Assets_ResourceGroup.json
*/
async function listAssetsResourceGroup() {
async function listAssetsResourceGroup(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand All @@ -22,7 +22,7 @@ async function listAssetsResourceGroup() {
console.log(resArray);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary list Asset resources by subscription ID
* x-ms-original-file: 2024-09-01-preview/List_Assets_Subscription.json
*/
async function listAssetsSubscription() {
async function listAssetsSubscription(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand All @@ -22,7 +22,7 @@ async function listAssetsSubscription() {
console.log(resArray);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary update a Asset
* x-ms-original-file: 2024-09-01-preview/Update_Asset.json
*/
async function updateAsset() {
async function updateAsset(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
Expand All @@ -20,7 +20,7 @@ async function updateAsset() {
console.log(result);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { DefaultAzureCredential } from "@azure/identity";
* @summary get a BillingContainer
* x-ms-original-file: 2024-09-01-preview/Get_BillingContainer.json
*/
async function getBillingContainer() {
async function getBillingContainer(): Promise<void> {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new DeviceRegistryManagementClient(credential, subscriptionId);
const result = await client.billingContainers.get("my-billingContainer");
console.log(result);
}

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

Expand Down
Loading

0 comments on commit 2e79f92

Please sign in to comment.