From fa6a66d16c8d558a6ed132d7a579681d4577ce0f Mon Sep 17 00:00:00 2001 From: colawwj Date: Tue, 25 Jan 2022 09:46:38 +0800 Subject: [PATCH 1/2] iothub-track2 --- sdk/iothub/arm-iothub/CHANGELOG.md | 23 +-- sdk/iothub/arm-iothub/LICENSE | 2 +- sdk/iothub/arm-iothub/_meta.json | 6 +- sdk/iothub/arm-iothub/api-extractor.json | 25 +++- sdk/iothub/arm-iothub/package.json | 22 ++- .../arm-iothub/review/arm-iothub.api.md | 27 ++++ sdk/iothub/arm-iothub/sample.env | 4 + .../samples-dev/certificatesCreateOrUpdate.ts | 39 +++++ .../samples-dev/certificatesDelete.ts | 37 +++++ .../certificatesGenerateVerificationCode.ts | 37 +++++ .../arm-iothub/samples-dev/certificatesGet.ts | 35 +++++ .../samples-dev/certificatesListByIotHub.ts | 33 +++++ .../samples-dev/certificatesVerify.ts | 44 ++++++ .../samples-dev/iotHubManualFailover.ts | 35 +++++ .../iotHubResourceCheckNameAvailability.ts | 31 ++++ ...tHubResourceCreateEventHubConsumerGroup.ts | 44 ++++++ .../iotHubResourceCreateOrUpdate.ts | 97 +++++++++++++ .../samples-dev/iotHubResourceDelete.ts | 33 +++++ ...tHubResourceDeleteEventHubConsumerGroup.ts | 37 +++++ .../iotHubResourceExportDevices.ts | 38 +++++ .../samples-dev/iotHubResourceGet.ts | 33 +++++ .../iotHubResourceGetEndpointHealth.ts | 36 +++++ .../samples-dev/iotHubResourceGetJob.ts | 35 +++++ .../iotHubResourceGetKeysForKeyName.ts | 35 +++++ .../iotHubResourceGetQuotaMetrics.ts | 36 +++++ .../samples-dev/iotHubResourceGetStats.ts | 33 +++++ .../samples-dev/iotHubResourceGetValidSkus.ts | 36 +++++ .../iotHubResourceImportDevices.ts | 38 +++++ .../iotHubResourceListByResourceGroup.ts | 34 +++++ .../iotHubResourceListBySubscription.ts | 31 ++++ ...otHubResourceListEventHubConsumerGroups.ts | 37 +++++ .../samples-dev/iotHubResourceListJobs.ts | 36 +++++ .../samples-dev/iotHubResourceListKeys.ts | 36 +++++ .../iotHubResourceTestAllRoutes.ts | 42 ++++++ .../samples-dev/iotHubResourceTestRoute.ts | 47 +++++++ .../samples-dev/iotHubResourceUpdate.ts | 35 +++++ .../arm-iothub/samples-dev/operationsList.ts | 31 ++++ .../privateEndpointConnectionDelete.ts | 35 +++++ .../privateEndpointConnectionGet.ts | 35 +++++ .../privateEndpointConnectionUpdate.ts | 44 ++++++ .../privateEndpointConnectionsList.ts | 33 +++++ .../samples-dev/privateLinkResourcesList.ts | 35 +++++ ...ourceProviderCommonGetSubscriptionQuota.ts | 28 ++++ .../samples/v6/javascript/README.md | 120 ++++++++++++++++ .../javascript/certificatesCreateOrUpdate.js | 39 +++++ .../v6/javascript/certificatesDelete.js | 37 +++++ .../certificatesGenerateVerificationCode.js | 37 +++++ .../samples/v6/javascript/certificatesGet.js | 31 ++++ .../v6/javascript/certificatesListByIotHub.js | 30 ++++ .../v6/javascript/certificatesVerify.js | 41 ++++++ .../v6/javascript/iotHubManualFailover.js | 35 +++++ .../iotHubResourceCheckNameAvailability.js | 29 ++++ ...tHubResourceCreateEventHubConsumerGroup.js | 41 ++++++ .../iotHubResourceCreateOrUpdate.js | 97 +++++++++++++ .../v6/javascript/iotHubResourceDelete.js | 30 ++++ ...tHubResourceDeleteEventHubConsumerGroup.js | 37 +++++ .../javascript/iotHubResourceExportDevices.js | 38 +++++ .../v6/javascript/iotHubResourceGet.js | 30 ++++ .../iotHubResourceGetEndpointHealth.js | 33 +++++ .../v6/javascript/iotHubResourceGetJob.js | 31 ++++ .../iotHubResourceGetKeysForKeyName.js | 35 +++++ .../iotHubResourceGetQuotaMetrics.js | 33 +++++ .../v6/javascript/iotHubResourceGetStats.js | 30 ++++ .../javascript/iotHubResourceGetValidSkus.js | 33 +++++ .../javascript/iotHubResourceImportDevices.js | 38 +++++ .../iotHubResourceListByResourceGroup.js | 32 +++++ .../iotHubResourceListBySubscription.js | 31 ++++ ...otHubResourceListEventHubConsumerGroups.js | 37 +++++ .../v6/javascript/iotHubResourceListJobs.js | 33 +++++ .../v6/javascript/iotHubResourceListKeys.js | 33 +++++ .../javascript/iotHubResourceTestAllRoutes.js | 38 +++++ .../v6/javascript/iotHubResourceTestRoute.js | 43 ++++++ .../v6/javascript/iotHubResourceUpdate.js | 35 +++++ .../samples/v6/javascript/operationsList.js | 31 ++++ .../samples/v6/javascript/package.json | 32 +++++ .../privateEndpointConnectionDelete.js | 35 +++++ .../privateEndpointConnectionGet.js | 35 +++++ .../privateEndpointConnectionUpdate.js | 44 ++++++ .../privateEndpointConnectionsList.js | 30 ++++ .../v6/javascript/privateLinkResourcesList.js | 35 +++++ ...ourceProviderCommonGetSubscriptionQuota.js | 28 ++++ .../samples/v6/javascript/sample.env | 4 + .../samples/v6/typescript/README.md | 133 ++++++++++++++++++ .../samples/v6/typescript/package.json | 41 ++++++ .../samples/v6/typescript/sample.env | 4 + .../src/certificatesCreateOrUpdate.ts | 39 +++++ .../v6/typescript/src/certificatesDelete.ts | 37 +++++ .../certificatesGenerateVerificationCode.ts | 37 +++++ .../v6/typescript/src/certificatesGet.ts | 35 +++++ .../src/certificatesListByIotHub.ts | 33 +++++ .../v6/typescript/src/certificatesVerify.ts | 44 ++++++ .../v6/typescript/src/iotHubManualFailover.ts | 35 +++++ .../iotHubResourceCheckNameAvailability.ts | 31 ++++ ...tHubResourceCreateEventHubConsumerGroup.ts | 44 ++++++ .../src/iotHubResourceCreateOrUpdate.ts | 97 +++++++++++++ .../v6/typescript/src/iotHubResourceDelete.ts | 33 +++++ ...tHubResourceDeleteEventHubConsumerGroup.ts | 37 +++++ .../src/iotHubResourceExportDevices.ts | 38 +++++ .../v6/typescript/src/iotHubResourceGet.ts | 33 +++++ .../src/iotHubResourceGetEndpointHealth.ts | 36 +++++ .../v6/typescript/src/iotHubResourceGetJob.ts | 35 +++++ .../src/iotHubResourceGetKeysForKeyName.ts | 35 +++++ .../src/iotHubResourceGetQuotaMetrics.ts | 36 +++++ .../typescript/src/iotHubResourceGetStats.ts | 33 +++++ .../src/iotHubResourceGetValidSkus.ts | 36 +++++ .../src/iotHubResourceImportDevices.ts | 38 +++++ .../src/iotHubResourceListByResourceGroup.ts | 34 +++++ .../src/iotHubResourceListBySubscription.ts | 31 ++++ ...otHubResourceListEventHubConsumerGroups.ts | 37 +++++ .../typescript/src/iotHubResourceListJobs.ts | 36 +++++ .../typescript/src/iotHubResourceListKeys.ts | 36 +++++ .../src/iotHubResourceTestAllRoutes.ts | 42 ++++++ .../typescript/src/iotHubResourceTestRoute.ts | 47 +++++++ .../v6/typescript/src/iotHubResourceUpdate.ts | 35 +++++ .../v6/typescript/src/operationsList.ts | 31 ++++ .../src/privateEndpointConnectionDelete.ts | 35 +++++ .../src/privateEndpointConnectionGet.ts | 35 +++++ .../src/privateEndpointConnectionUpdate.ts | 44 ++++++ .../src/privateEndpointConnectionsList.ts | 33 +++++ .../src/privateLinkResourcesList.ts | 35 +++++ ...ourceProviderCommonGetSubscriptionQuota.ts | 28 ++++ .../samples/v6/typescript/tsconfig.json | 17 +++ sdk/iothub/arm-iothub/src/iotHubClient.ts | 4 +- sdk/iothub/arm-iothub/src/models/index.ts | 43 ++++++ sdk/iothub/arm-iothub/src/models/mappers.ts | 58 ++++++++ .../arm-iothub/src/models/parameters.ts | 2 +- sdk/iothub/arm-iothub/test/sampleTest.ts | 48 +++++++ sdk/iothub/arm-iothub/tsconfig.json | 23 ++- 128 files changed, 4633 insertions(+), 32 deletions(-) create mode 100644 sdk/iothub/arm-iothub/sample.env create mode 100644 sdk/iothub/arm-iothub/samples-dev/certificatesCreateOrUpdate.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/certificatesDelete.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/certificatesGenerateVerificationCode.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/certificatesGet.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/certificatesListByIotHub.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/certificatesVerify.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubManualFailover.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceCheckNameAvailability.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceCreateEventHubConsumerGroup.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceCreateOrUpdate.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceDelete.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceDeleteEventHubConsumerGroup.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceExportDevices.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceGet.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetEndpointHealth.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetJob.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetKeysForKeyName.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetQuotaMetrics.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetStats.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetValidSkus.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceImportDevices.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceListByResourceGroup.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceListBySubscription.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceListEventHubConsumerGroups.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceListJobs.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceListKeys.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceTestAllRoutes.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceTestRoute.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/iotHubResourceUpdate.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/operationsList.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionDelete.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionGet.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionUpdate.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionsList.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/privateLinkResourcesList.ts create mode 100644 sdk/iothub/arm-iothub/samples-dev/resourceProviderCommonGetSubscriptionQuota.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/README.md create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/certificatesCreateOrUpdate.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/certificatesDelete.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/certificatesGenerateVerificationCode.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/certificatesGet.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/certificatesListByIotHub.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/certificatesVerify.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubManualFailover.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCheckNameAvailability.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCreateEventHubConsumerGroup.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCreateOrUpdate.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceDelete.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceDeleteEventHubConsumerGroup.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceExportDevices.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGet.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetEndpointHealth.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetJob.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetKeysForKeyName.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetQuotaMetrics.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetStats.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetValidSkus.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceImportDevices.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListByResourceGroup.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListBySubscription.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListEventHubConsumerGroups.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListJobs.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListKeys.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceTestAllRoutes.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceTestRoute.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceUpdate.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/operationsList.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/package.json create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionDelete.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionGet.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionUpdate.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionsList.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/privateLinkResourcesList.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/resourceProviderCommonGetSubscriptionQuota.js create mode 100644 sdk/iothub/arm-iothub/samples/v6/javascript/sample.env create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/README.md create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/package.json create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/sample.env create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesCreateOrUpdate.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesDelete.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesGenerateVerificationCode.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesGet.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesListByIotHub.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesVerify.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubManualFailover.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCheckNameAvailability.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCreateEventHubConsumerGroup.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCreateOrUpdate.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceDelete.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceDeleteEventHubConsumerGroup.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceExportDevices.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGet.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetEndpointHealth.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetJob.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetKeysForKeyName.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetQuotaMetrics.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetStats.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetValidSkus.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceImportDevices.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListByResourceGroup.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListBySubscription.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListEventHubConsumerGroups.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListJobs.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListKeys.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceTestAllRoutes.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceTestRoute.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceUpdate.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/operationsList.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionDelete.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionGet.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionUpdate.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionsList.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/privateLinkResourcesList.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/src/resourceProviderCommonGetSubscriptionQuota.ts create mode 100644 sdk/iothub/arm-iothub/samples/v6/typescript/tsconfig.json create mode 100644 sdk/iothub/arm-iothub/test/sampleTest.ts diff --git a/sdk/iothub/arm-iothub/CHANGELOG.md b/sdk/iothub/arm-iothub/CHANGELOG.md index 5ca426d8043b..8ff47c320053 100644 --- a/sdk/iothub/arm-iothub/CHANGELOG.md +++ b/sdk/iothub/arm-iothub/CHANGELOG.md @@ -1,15 +1,16 @@ # Release History - -## 6.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 6.1.0 (2022-01-25) + +**Features** + + - Added Interface SystemData + - Added Type Alias CreatedByType + - Interface IotHubProperties has a new optional parameter enableDataResidency + - Type Alias IotHubDescription has a new parameter systemData + - Added Enum KnownCreatedByType + + ## 6.0.0 (2021-12-17) The package of @azure/arm-iothub is using our next generation design principles since version 6.0.0, which contains breaking changes. diff --git a/sdk/iothub/arm-iothub/LICENSE b/sdk/iothub/arm-iothub/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/iothub/arm-iothub/LICENSE +++ b/sdk/iothub/arm-iothub/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sdk/iothub/arm-iothub/_meta.json b/sdk/iothub/arm-iothub/_meta.json index d56468474e3e..5de12e35ff77 100644 --- a/sdk/iothub/arm-iothub/_meta.json +++ b/sdk/iothub/arm-iothub/_meta.json @@ -1,7 +1,7 @@ { - "commit": "e6d1396612965f2af8df6bb941be19681147930a", + "commit": "c1940e0e837e74a535b2c9166374b71b970a6b97", "readme": "specification/iothub/resource-manager/readme.md", - "autorest_command": "autorest --version=3.1.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/iothub/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211207.1", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/iothub/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20220114.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211207.1" + "use": "@autorest/typescript@6.0.0-alpha.16.20220114.1" } \ No newline at end of file diff --git a/sdk/iothub/arm-iothub/api-extractor.json b/sdk/iothub/arm-iothub/api-extractor.json index 7c973756a144..b2412ee803ce 100644 --- a/sdk/iothub/arm-iothub/api-extractor.json +++ b/sdk/iothub/arm-iothub/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-iothub.d.ts" }, "messages": { - "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, "extractorMessageReporting": { - "ae-missing-release-tag": { "logLevel": "none" }, - "ae-unresolved-link": { "logLevel": "none" } + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } } } -} +} \ No newline at end of file diff --git a/sdk/iothub/arm-iothub/package.json b/sdk/iothub/arm-iothub/package.json index bff4498042a0..35102acf5148 100644 --- a/sdk/iothub/arm-iothub/package.json +++ b/sdk/iothub/arm-iothub/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for IotHubClient.", - "version": "6.0.1", + "version": "6.1.0", "engines": { "node": ">=12.0.0" }, @@ -98,5 +98,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true -} + "//metadata": { + "constantPaths": [ + { + "path": "src/IotHubClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-iothub?view=azure-node-preview" + } +} \ No newline at end of file diff --git a/sdk/iothub/arm-iothub/review/arm-iothub.api.md b/sdk/iothub/arm-iothub/review/arm-iothub.api.md index 94a542ae6415..c5b7abffb6c8 100644 --- a/sdk/iothub/arm-iothub/review/arm-iothub.api.md +++ b/sdk/iothub/arm-iothub/review/arm-iothub.api.md @@ -149,6 +149,9 @@ export interface CloudToDeviceProperties { maxDeliveryCount?: number; } +// @public +export type CreatedByType = string; + // @public export type DefaultAction = string; @@ -333,6 +336,7 @@ export type IotHubDescription = Resource & { properties?: IotHubProperties; sku: IotHubSkuInfo; identity?: ArmIdentity; + readonly systemData?: SystemData; }; // @public @@ -372,6 +376,7 @@ export interface IotHubProperties { disableDeviceSAS?: boolean; disableLocalAuth?: boolean; disableModuleSAS?: boolean; + enableDataResidency?: boolean; enableFileUploadNotifications?: boolean; eventHubEndpoints?: { [propertyName: string]: EventHubProperties; @@ -742,6 +747,18 @@ export enum KnownCapabilities { None = "None" } +// @public +export enum KnownCreatedByType { + // (undocumented) + Application = "Application", + // (undocumented) + Key = "Key", + // (undocumented) + ManagedIdentity = "ManagedIdentity", + // (undocumented) + User = "User" +} + // @public export enum KnownDefaultAction { // (undocumented) @@ -1256,6 +1273,16 @@ export interface StorageEndpointProperties { sasTtlAsIso8601?: string; } +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + // @public export interface TagsResource { tags?: { diff --git a/sdk/iothub/arm-iothub/sample.env b/sdk/iothub/arm-iothub/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/iothub/arm-iothub/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/iothub/arm-iothub/samples-dev/certificatesCreateOrUpdate.ts b/sdk/iothub/arm-iothub/samples-dev/certificatesCreateOrUpdate.ts new file mode 100644 index 000000000000..9a013d78bb67 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/certificatesCreateOrUpdate.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Adds new or replaces existing certificate. + * + * @summary Adds new or replaces existing certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatescreateorupdate.json + */ +import { CertificateDescription, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesCreateOrUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "iothub"; + const certificateName = "cert"; + const certificateDescription: CertificateDescription = { + properties: { certificate: "############################################" } + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.createOrUpdate( + resourceGroupName, + resourceName, + certificateName, + certificateDescription + ); + console.log(result); +} + +certificatesCreateOrUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/certificatesDelete.ts b/sdk/iothub/arm-iothub/samples-dev/certificatesDelete.ts new file mode 100644 index 000000000000..e2bee6f90023 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/certificatesDelete.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Deletes an existing X509 certificate or does nothing if it does not exist. + * + * @summary Deletes an existing X509 certificate or does nothing if it does not exist. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatesdelete.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesDelete() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "myhub"; + const certificateName = "cert"; + const ifMatch = "AAAAAAAADGk="; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.delete( + resourceGroupName, + resourceName, + certificateName, + ifMatch + ); + console.log(result); +} + +certificatesDelete().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/certificatesGenerateVerificationCode.ts b/sdk/iothub/arm-iothub/samples-dev/certificatesGenerateVerificationCode.ts new file mode 100644 index 000000000000..1f98b89d8c99 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/certificatesGenerateVerificationCode.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. + * + * @summary Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_generateverificationcode.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesGenerateVerificationCode() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const certificateName = "cert"; + const ifMatch = "AAAAAAAADGk="; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.generateVerificationCode( + resourceGroupName, + resourceName, + certificateName, + ifMatch + ); + console.log(result); +} + +certificatesGenerateVerificationCode().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/certificatesGet.ts b/sdk/iothub/arm-iothub/samples-dev/certificatesGet.ts new file mode 100644 index 000000000000..849ebef06d49 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/certificatesGet.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Returns the certificate. + * + * @summary Returns the certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getcertificate.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesGet() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testhub"; + const certificateName = "cert"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.get( + resourceGroupName, + resourceName, + certificateName + ); + console.log(result); +} + +certificatesGet().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/certificatesListByIotHub.ts b/sdk/iothub/arm-iothub/samples-dev/certificatesListByIotHub.ts new file mode 100644 index 000000000000..80547fa0c2be --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/certificatesListByIotHub.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Returns the list of certificates. + * + * @summary Returns the list of certificates. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listcertificates.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesListByIotHub() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testhub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.listByIotHub( + resourceGroupName, + resourceName + ); + console.log(result); +} + +certificatesListByIotHub().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/certificatesVerify.ts b/sdk/iothub/arm-iothub/samples-dev/certificatesVerify.ts new file mode 100644 index 000000000000..163c731bb6a1 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/certificatesVerify.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. + * + * @summary Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certverify.json + */ +import { + CertificateVerificationDescription, + IotHubClient +} from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesVerify() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "myFirstProvisioningService"; + const certificateName = "cert"; + const ifMatch = "AAAAAAAADGk="; + const certificateVerificationBody: CertificateVerificationDescription = { + certificate: "#####################################" + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.verify( + resourceGroupName, + resourceName, + certificateName, + ifMatch, + certificateVerificationBody + ); + console.log(result); +} + +certificatesVerify().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubManualFailover.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubManualFailover.ts new file mode 100644 index 000000000000..ca18487069eb --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubManualFailover.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover + * + * @summary Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/IotHub_ManualFailover.json + */ +import { FailoverInput, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubManualFailover() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const iotHubName = "testHub"; + const resourceGroupName = "myResourceGroup"; + const failoverInput: FailoverInput = { failoverRegion: "testHub" }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHub.beginManualFailoverAndWait( + iotHubName, + resourceGroupName, + failoverInput + ); + console.log(result); +} + +iotHubManualFailover().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceCheckNameAvailability.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceCheckNameAvailability.ts new file mode 100644 index 000000000000..015bcdfacc24 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceCheckNameAvailability.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Check if an IoT hub name is available. + * + * @summary Check if an IoT hub name is available. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/checkNameAvailability.json + */ +import { OperationInputs, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceCheckNameAvailability() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const operationInputs: OperationInputs = { name: "test-request" }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.checkNameAvailability( + operationInputs + ); + console.log(result); +} + +iotHubResourceCheckNameAvailability().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceCreateEventHubConsumerGroup.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceCreateEventHubConsumerGroup.ts new file mode 100644 index 000000000000..f08d74458830 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceCreateEventHubConsumerGroup.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + * + * @summary Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createconsumergroup.json + */ +import { + EventHubConsumerGroupBodyDescription, + IotHubClient +} from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceCreateEventHubConsumerGroup() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const eventHubEndpointName = "events"; + const name = "test"; + const consumerGroupBody: EventHubConsumerGroupBodyDescription = { + properties: { name: "test" } + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.createEventHubConsumerGroup( + resourceGroupName, + resourceName, + eventHubEndpointName, + name, + consumerGroupBody + ); + console.log(result); +} + +iotHubResourceCreateEventHubConsumerGroup().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceCreateOrUpdate.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceCreateOrUpdate.ts new file mode 100644 index 000000000000..ec6285b2fdd6 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceCreateOrUpdate.ts @@ -0,0 +1,97 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. If certain properties are missing in the JSON, updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. + * + * @summary Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. If certain properties are missing in the JSON, updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createOrUpdate.json + */ +import { IotHubDescription, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceCreateOrUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const iotHubDescription: IotHubDescription = { + etag: "AAAAAAFD6M4=", + location: "centraluseuap", + properties: { + cloudToDevice: { + defaultTtlAsIso8601: "PT1H", + feedback: { + lockDurationAsIso8601: "PT1M", + maxDeliveryCount: 10, + ttlAsIso8601: "PT1H" + }, + maxDeliveryCount: 10 + }, + enableDataResidency: true, + enableFileUploadNotifications: false, + eventHubEndpoints: { + events: { partitionCount: 2, retentionTimeInDays: 1 } + }, + features: "None", + ipFilterRules: [], + messagingEndpoints: { + fileNotifications: { + lockDurationAsIso8601: "PT1M", + maxDeliveryCount: 10, + ttlAsIso8601: "PT1H" + } + }, + minTlsVersion: "1.2", + networkRuleSets: { + applyToBuiltInEventHubEndpoint: true, + defaultAction: "Deny", + ipRules: [ + { action: "Allow", filterName: "rule1", ipMask: "131.117.159.53" }, + { action: "Allow", filterName: "rule2", ipMask: "157.55.59.128/25" } + ] + }, + routing: { + endpoints: { + eventHubs: [], + serviceBusQueues: [], + serviceBusTopics: [], + storageContainers: [] + }, + fallbackRoute: { + name: "$fallback", + condition: "true", + endpointNames: ["events"], + isEnabled: true, + source: "DeviceMessages" + }, + routes: [] + }, + storageEndpoints: { + $default: { + connectionString: "", + containerName: "", + sasTtlAsIso8601: "PT1H" + } + } + }, + sku: { name: "S1", capacity: 1 }, + tags: {} + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.beginCreateOrUpdateAndWait( + resourceGroupName, + resourceName, + iotHubDescription + ); + console.log(result); +} + +iotHubResourceCreateOrUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceDelete.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceDelete.ts new file mode 100644 index 000000000000..54d16b14fb1f --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceDelete.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Delete an IoT hub. + * + * @summary Delete an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_delete.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceDelete() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.beginDeleteAndWait( + resourceGroupName, + resourceName + ); + console.log(result); +} + +iotHubResourceDelete().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceDeleteEventHubConsumerGroup.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceDeleteEventHubConsumerGroup.ts new file mode 100644 index 000000000000..d9b7e3fb8b4e --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceDeleteEventHubConsumerGroup.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + * + * @summary Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteconsumergroup.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceDeleteEventHubConsumerGroup() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const eventHubEndpointName = "events"; + const name = "test"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.deleteEventHubConsumerGroup( + resourceGroupName, + resourceName, + eventHubEndpointName, + name + ); + console.log(result); +} + +iotHubResourceDeleteEventHubConsumerGroup().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceExportDevices.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceExportDevices.ts new file mode 100644 index 000000000000..229f43f9b6f0 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceExportDevices.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * + * @summary Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_exportdevices.json + */ +import { ExportDevicesRequest, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceExportDevices() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const exportDevicesParameters: ExportDevicesRequest = { + excludeKeys: true, + exportBlobContainerUri: "testBlob" + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.exportDevices( + resourceGroupName, + resourceName, + exportDevicesParameters + ); + console.log(result); +} + +iotHubResourceExportDevices().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGet.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGet.ts new file mode 100644 index 000000000000..317295da37b3 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGet.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the non-security related metadata of an IoT hub. + * + * @summary Get the non-security related metadata of an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_get.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGet() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.get( + resourceGroupName, + resourceName + ); + console.log(result); +} + +iotHubResourceGet().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetEndpointHealth.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetEndpointHealth.ts new file mode 100644 index 000000000000..774f4a95fa94 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetEndpointHealth.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the health for routing endpoints. + * + * @summary Get the health for routing endpoints. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_routingendpointhealth.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetEndpointHealth() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const iotHubName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listEndpointHealth( + resourceGroupName, + iotHubName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceGetEndpointHealth().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetJob.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetJob.ts new file mode 100644 index 000000000000..449ec326c792 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetJob.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * + * @summary Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getjob.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetJob() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const jobId = "test"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getJob( + resourceGroupName, + resourceName, + jobId + ); + console.log(result); +} + +iotHubResourceGetJob().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetKeysForKeyName.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetKeysForKeyName.ts new file mode 100644 index 000000000000..f10860ce37a7 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetKeysForKeyName.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * + * @summary Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getkey.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetKeysForKeyName() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const keyName = "iothubowner"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getKeysForKeyName( + resourceGroupName, + resourceName, + keyName + ); + console.log(result); +} + +iotHubResourceGetKeysForKeyName().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetQuotaMetrics.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetQuotaMetrics.ts new file mode 100644 index 000000000000..4050046f4327 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetQuotaMetrics.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the quota metrics for an IoT hub. + * + * @summary Get the quota metrics for an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_quotametrics.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetQuotaMetrics() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listQuotaMetrics( + resourceGroupName, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceGetQuotaMetrics().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetStats.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetStats.ts new file mode 100644 index 000000000000..d9ce0b0bf630 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetStats.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the statistics from an IoT hub. + * + * @summary Get the statistics from an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_stats.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetStats() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getStats( + resourceGroupName, + resourceName + ); + console.log(result); +} + +iotHubResourceGetStats().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetValidSkus.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetValidSkus.ts new file mode 100644 index 000000000000..adcefcf33436 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceGetValidSkus.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the list of valid SKUs for an IoT hub. + * + * @summary Get the list of valid SKUs for an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getskus.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetValidSkus() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listValidSkus( + resourceGroupName, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceGetValidSkus().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceImportDevices.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceImportDevices.ts new file mode 100644 index 000000000000..6ec94da17516 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceImportDevices.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * + * @summary Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_importdevices.json + */ +import { ImportDevicesRequest, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceImportDevices() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const importDevicesParameters: ImportDevicesRequest = { + inputBlobContainerUri: "testBlob", + outputBlobContainerUri: "testBlob" + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.importDevices( + resourceGroupName, + resourceName, + importDevicesParameters + ); + console.log(result); +} + +iotHubResourceImportDevices().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListByResourceGroup.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListByResourceGroup.ts new file mode 100644 index 000000000000..0c87a5ea8aad --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListByResourceGroup.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get all the IoT hubs in a resource group. + * + * @summary Get all the IoT hubs in a resource group. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbyrg.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceListByResourceGroup() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListByResourceGroup().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListBySubscription.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListBySubscription.ts new file mode 100644 index 000000000000..69d39ff3ebba --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListBySubscription.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get all the IoT hubs in a subscription. + * + * @summary Get all the IoT hubs in a subscription. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbysubscription.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceListBySubscription() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListBySubscription().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListEventHubConsumerGroups.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListEventHubConsumerGroups.ts new file mode 100644 index 000000000000..2b7593d2745c --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListEventHubConsumerGroups.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + * + * @summary Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getconsumergroup.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceListEventHubConsumerGroups() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const eventHubEndpointName = "events"; + const name = "test"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getEventHubConsumerGroup( + resourceGroupName, + resourceName, + eventHubEndpointName, + name + ); + console.log(result); +} + +iotHubResourceListEventHubConsumerGroups().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListJobs.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListJobs.ts new file mode 100644 index 000000000000..7d430b408015 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListJobs.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * + * @summary Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listjobs.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceListJobs() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listJobs( + resourceGroupName, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListJobs().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListKeys.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListKeys.ts new file mode 100644 index 000000000000..c313a0bc4029 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceListKeys.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * + * @summary Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listkeys.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceListKeys() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listKeys( + resourceGroupName, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListKeys().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceTestAllRoutes.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceTestAllRoutes.ts new file mode 100644 index 000000000000..28e153bffd02 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceTestAllRoutes.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Test all routes configured in this Iot Hub + * + * @summary Test all routes configured in this Iot Hub + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testallroutes.json + */ +import { TestAllRoutesInput, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceTestAllRoutes() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const iotHubName = "testHub"; + const resourceGroupName = "myResourceGroup"; + const input: TestAllRoutesInput = { + message: { + appProperties: { key1: "value1" }, + body: "Body of message", + systemProperties: { key1: "value1" } + }, + routingSource: "DeviceMessages" + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.testAllRoutes( + iotHubName, + resourceGroupName, + input + ); + console.log(result); +} + +iotHubResourceTestAllRoutes().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceTestRoute.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceTestRoute.ts new file mode 100644 index 000000000000..72d9fbf2f6f2 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceTestRoute.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Test the new route for this Iot Hub + * + * @summary Test the new route for this Iot Hub + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testnewroute.json + */ +import { TestRouteInput, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceTestRoute() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const iotHubName = "testHub"; + const resourceGroupName = "myResourceGroup"; + const input: TestRouteInput = { + message: { + appProperties: { key1: "value1" }, + body: "Body of message", + systemProperties: { key1: "value1" } + }, + route: { + name: "Routeid", + endpointNames: ["id1"], + isEnabled: true, + source: "DeviceMessages" + } + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.testRoute( + iotHubName, + resourceGroupName, + input + ); + console.log(result); +} + +iotHubResourceTestRoute().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/iotHubResourceUpdate.ts b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceUpdate.ts new file mode 100644 index 000000000000..62f231fbb540 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/iotHubResourceUpdate.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method + * + * @summary Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_patch.json + */ +import { TagsResource, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "myHub"; + const iotHubTags: TagsResource = { tags: { foo: "bar" } }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.beginUpdateAndWait( + resourceGroupName, + resourceName, + iotHubTags + ); + console.log(result); +} + +iotHubResourceUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/operationsList.ts b/sdk/iothub/arm-iothub/samples-dev/operationsList.ts new file mode 100644 index 000000000000..a238767971a8 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/operationsList.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Lists all of the available IoT Hub REST API operations. + * + * @summary Lists all of the available IoT Hub REST API operations. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_operations.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function operationsList() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +operationsList().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionDelete.ts b/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionDelete.ts new file mode 100644 index 000000000000..0ca21718f8f2 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionDelete.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Delete private endpoint connection with the specified name + * + * @summary Delete private endpoint connection with the specified name + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteprivateendpointconnection.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function privateEndpointConnectionDelete() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const privateEndpointConnectionName = "myPrivateEndpointConnection"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + resourceName, + privateEndpointConnectionName + ); + console.log(result); +} + +privateEndpointConnectionDelete().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionGet.ts b/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionGet.ts new file mode 100644 index 000000000000..58bfde372355 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionGet.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get private endpoint connection properties + * + * @summary Get private endpoint connection properties + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivateendpointconnection.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function privateEndpointConnectionGet() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const privateEndpointConnectionName = "myPrivateEndpointConnection"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + resourceName, + privateEndpointConnectionName + ); + console.log(result); +} + +privateEndpointConnectionGet().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionUpdate.ts b/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionUpdate.ts new file mode 100644 index 000000000000..480a75675ff9 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionUpdate.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Update the status of a private endpoint connection with the specified name + * + * @summary Update the status of a private endpoint connection with the specified name + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_updateprivateendpointconnection.json + */ +import { PrivateEndpointConnection, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function privateEndpointConnectionUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const privateEndpointConnectionName = "myPrivateEndpointConnection"; + const privateEndpointConnection: PrivateEndpointConnection = { + properties: { + privateLinkServiceConnectionState: { + description: "Approved by johndoe@contoso.com", + status: "Approved" + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginUpdateAndWait( + resourceGroupName, + resourceName, + privateEndpointConnectionName, + privateEndpointConnection + ); + console.log(result); +} + +privateEndpointConnectionUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionsList.ts b/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionsList.ts new file mode 100644 index 000000000000..19013db3db3d --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/privateEndpointConnectionsList.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to List private endpoint connection properties + * + * @summary List private endpoint connection properties + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listprivateendpointconnections.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function privateEndpointConnectionsList() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.list( + resourceGroupName, + resourceName + ); + console.log(result); +} + +privateEndpointConnectionsList().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/privateLinkResourcesList.ts b/sdk/iothub/arm-iothub/samples-dev/privateLinkResourcesList.ts new file mode 100644 index 000000000000..1c3c00214b14 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/privateLinkResourcesList.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the specified private link resource for the given IotHub + * + * @summary Get the specified private link resource for the given IotHub + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivatelinkresources.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function privateLinkResourcesList() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const groupId = "iotHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateLinkResourcesOperations.get( + resourceGroupName, + resourceName, + groupId + ); + console.log(result); +} + +privateLinkResourcesList().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples-dev/resourceProviderCommonGetSubscriptionQuota.ts b/sdk/iothub/arm-iothub/samples-dev/resourceProviderCommonGetSubscriptionQuota.ts new file mode 100644 index 000000000000..f43af9e6dcaa --- /dev/null +++ b/sdk/iothub/arm-iothub/samples-dev/resourceProviderCommonGetSubscriptionQuota.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the number of free and paid iot hubs in the subscription + * + * @summary Get the number of free and paid iot hubs in the subscription + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_usages.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function resourceProviderCommonGetSubscriptionQuota() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.resourceProviderCommon.getSubscriptionQuota(); + console.log(result); +} + +resourceProviderCommonGetSubscriptionQuota().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/README.md b/sdk/iothub/arm-iothub/samples/v6/javascript/README.md new file mode 100644 index 000000000000..b510d0822569 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/README.md @@ -0,0 +1,120 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [certificatesCreateOrUpdate.js][certificatescreateorupdate] | Adds new or replaces existing certificate. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatescreateorupdate.json | +| [certificatesDelete.js][certificatesdelete] | Deletes an existing X509 certificate or does nothing if it does not exist. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatesdelete.json | +| [certificatesGenerateVerificationCode.js][certificatesgenerateverificationcode] | Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_generateverificationcode.json | +| [certificatesGet.js][certificatesget] | Returns the certificate. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getcertificate.json | +| [certificatesListByIotHub.js][certificateslistbyiothub] | Returns the list of certificates. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listcertificates.json | +| [certificatesVerify.js][certificatesverify] | Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certverify.json | +| [iotHubManualFailover.js][iothubmanualfailover] | Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/IotHub_ManualFailover.json | +| [iotHubResourceCheckNameAvailability.js][iothubresourcechecknameavailability] | Check if an IoT hub name is available. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/checkNameAvailability.json | +| [iotHubResourceCreateEventHubConsumerGroup.js][iothubresourcecreateeventhubconsumergroup] | Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createconsumergroup.json | +| [iotHubResourceCreateOrUpdate.js][iothubresourcecreateorupdate] | Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. If certain properties are missing in the JSON, updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createOrUpdate.json | +| [iotHubResourceDelete.js][iothubresourcedelete] | Delete an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_delete.json | +| [iotHubResourceDeleteEventHubConsumerGroup.js][iothubresourcedeleteeventhubconsumergroup] | Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteconsumergroup.json | +| [iotHubResourceExportDevices.js][iothubresourceexportdevices] | Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_exportdevices.json | +| [iotHubResourceGet.js][iothubresourceget] | Get the non-security related metadata of an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_get.json | +| [iotHubResourceGetEndpointHealth.js][iothubresourcegetendpointhealth] | Get the health for routing endpoints. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_routingendpointhealth.json | +| [iotHubResourceGetJob.js][iothubresourcegetjob] | Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getjob.json | +| [iotHubResourceGetKeysForKeyName.js][iothubresourcegetkeysforkeyname] | Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getkey.json | +| [iotHubResourceGetQuotaMetrics.js][iothubresourcegetquotametrics] | Get the quota metrics for an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_quotametrics.json | +| [iotHubResourceGetStats.js][iothubresourcegetstats] | Get the statistics from an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_stats.json | +| [iotHubResourceGetValidSkus.js][iothubresourcegetvalidskus] | Get the list of valid SKUs for an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getskus.json | +| [iotHubResourceImportDevices.js][iothubresourceimportdevices] | Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_importdevices.json | +| [iotHubResourceListByResourceGroup.js][iothubresourcelistbyresourcegroup] | Get all the IoT hubs in a resource group. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbyrg.json | +| [iotHubResourceListBySubscription.js][iothubresourcelistbysubscription] | Get all the IoT hubs in a subscription. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbysubscription.json | +| [iotHubResourceListEventHubConsumerGroups.js][iothubresourcelisteventhubconsumergroups] | Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getconsumergroup.json | +| [iotHubResourceListJobs.js][iothubresourcelistjobs] | Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listjobs.json | +| [iotHubResourceListKeys.js][iothubresourcelistkeys] | Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listkeys.json | +| [iotHubResourceTestAllRoutes.js][iothubresourcetestallroutes] | Test all routes configured in this Iot Hub x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testallroutes.json | +| [iotHubResourceTestRoute.js][iothubresourcetestroute] | Test the new route for this Iot Hub x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testnewroute.json | +| [iotHubResourceUpdate.js][iothubresourceupdate] | Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_patch.json | +| [operationsList.js][operationslist] | Lists all of the available IoT Hub REST API operations. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_operations.json | +| [privateEndpointConnectionDelete.js][privateendpointconnectiondelete] | Delete private endpoint connection with the specified name x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteprivateendpointconnection.json | +| [privateEndpointConnectionGet.js][privateendpointconnectionget] | Get private endpoint connection properties x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivateendpointconnection.json | +| [privateEndpointConnectionUpdate.js][privateendpointconnectionupdate] | Update the status of a private endpoint connection with the specified name x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_updateprivateendpointconnection.json | +| [privateEndpointConnectionsList.js][privateendpointconnectionslist] | List private endpoint connection properties x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listprivateendpointconnections.json | +| [privateLinkResourcesList.js][privatelinkresourceslist] | Get the specified private link resource for the given IotHub x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivatelinkresources.json | +| [resourceProviderCommonGetSubscriptionQuota.js][resourceprovidercommongetsubscriptionquota] | Get the number of free and paid iot hubs in the subscription x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_usages.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node certificatesCreateOrUpdate.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env node certificatesCreateOrUpdate.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[certificatescreateorupdate]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesCreateOrUpdate.js +[certificatesdelete]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesDelete.js +[certificatesgenerateverificationcode]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesGenerateVerificationCode.js +[certificatesget]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesGet.js +[certificateslistbyiothub]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesListByIotHub.js +[certificatesverify]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesVerify.js +[iothubmanualfailover]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubManualFailover.js +[iothubresourcechecknameavailability]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCheckNameAvailability.js +[iothubresourcecreateeventhubconsumergroup]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCreateEventHubConsumerGroup.js +[iothubresourcecreateorupdate]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCreateOrUpdate.js +[iothubresourcedelete]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceDelete.js +[iothubresourcedeleteeventhubconsumergroup]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceDeleteEventHubConsumerGroup.js +[iothubresourceexportdevices]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceExportDevices.js +[iothubresourceget]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGet.js +[iothubresourcegetendpointhealth]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetEndpointHealth.js +[iothubresourcegetjob]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetJob.js +[iothubresourcegetkeysforkeyname]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetKeysForKeyName.js +[iothubresourcegetquotametrics]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetQuotaMetrics.js +[iothubresourcegetstats]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetStats.js +[iothubresourcegetvalidskus]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetValidSkus.js +[iothubresourceimportdevices]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceImportDevices.js +[iothubresourcelistbyresourcegroup]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListByResourceGroup.js +[iothubresourcelistbysubscription]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListBySubscription.js +[iothubresourcelisteventhubconsumergroups]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListEventHubConsumerGroups.js +[iothubresourcelistjobs]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListJobs.js +[iothubresourcelistkeys]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListKeys.js +[iothubresourcetestallroutes]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceTestAllRoutes.js +[iothubresourcetestroute]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceTestRoute.js +[iothubresourceupdate]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceUpdate.js +[operationslist]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/operationsList.js +[privateendpointconnectiondelete]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionDelete.js +[privateendpointconnectionget]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionGet.js +[privateendpointconnectionupdate]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionUpdate.js +[privateendpointconnectionslist]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionsList.js +[privatelinkresourceslist]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/privateLinkResourcesList.js +[resourceprovidercommongetsubscriptionquota]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/javascript/resourceProviderCommonGetSubscriptionQuota.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-iothub?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/iothub/arm-iothub/README.md diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesCreateOrUpdate.js b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesCreateOrUpdate.js new file mode 100644 index 000000000000..fb2ca91b065c --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesCreateOrUpdate.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Adds new or replaces existing certificate. + * + * @summary Adds new or replaces existing certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatescreateorupdate.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function certificatesCreateOrUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "iothub"; + const certificateName = "cert"; + const certificateDescription = { + properties: { certificate: "############################################" }, + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.createOrUpdate( + resourceGroupName, + resourceName, + certificateName, + certificateDescription + ); + console.log(result); +} + +certificatesCreateOrUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesDelete.js b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesDelete.js new file mode 100644 index 000000000000..272db1b0c22e --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesDelete.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Deletes an existing X509 certificate or does nothing if it does not exist. + * + * @summary Deletes an existing X509 certificate or does nothing if it does not exist. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatesdelete.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function certificatesDelete() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "myhub"; + const certificateName = "cert"; + const ifMatch = "AAAAAAAADGk="; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.delete( + resourceGroupName, + resourceName, + certificateName, + ifMatch + ); + console.log(result); +} + +certificatesDelete().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesGenerateVerificationCode.js b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesGenerateVerificationCode.js new file mode 100644 index 000000000000..23f57d36e3f8 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesGenerateVerificationCode.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. + * + * @summary Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_generateverificationcode.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function certificatesGenerateVerificationCode() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const certificateName = "cert"; + const ifMatch = "AAAAAAAADGk="; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.generateVerificationCode( + resourceGroupName, + resourceName, + certificateName, + ifMatch + ); + console.log(result); +} + +certificatesGenerateVerificationCode().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesGet.js b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesGet.js new file mode 100644 index 000000000000..f1afb0873e81 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesGet.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Returns the certificate. + * + * @summary Returns the certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getcertificate.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function certificatesGet() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testhub"; + const certificateName = "cert"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.get(resourceGroupName, resourceName, certificateName); + console.log(result); +} + +certificatesGet().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesListByIotHub.js b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesListByIotHub.js new file mode 100644 index 000000000000..2bedb6297d01 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesListByIotHub.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Returns the list of certificates. + * + * @summary Returns the list of certificates. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listcertificates.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function certificatesListByIotHub() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testhub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.listByIotHub(resourceGroupName, resourceName); + console.log(result); +} + +certificatesListByIotHub().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesVerify.js b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesVerify.js new file mode 100644 index 000000000000..a5fad780c3ec --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/certificatesVerify.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. + * + * @summary Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certverify.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function certificatesVerify() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "myFirstProvisioningService"; + const certificateName = "cert"; + const ifMatch = "AAAAAAAADGk="; + const certificateVerificationBody = { + certificate: "#####################################", + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.verify( + resourceGroupName, + resourceName, + certificateName, + ifMatch, + certificateVerificationBody + ); + console.log(result); +} + +certificatesVerify().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubManualFailover.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubManualFailover.js new file mode 100644 index 000000000000..9e28660048f9 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubManualFailover.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover + * + * @summary Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/IotHub_ManualFailover.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubManualFailover() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const iotHubName = "testHub"; + const resourceGroupName = "myResourceGroup"; + const failoverInput = { failoverRegion: "testHub" }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHub.beginManualFailoverAndWait( + iotHubName, + resourceGroupName, + failoverInput + ); + console.log(result); +} + +iotHubManualFailover().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCheckNameAvailability.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCheckNameAvailability.js new file mode 100644 index 000000000000..ad32fc8c14c7 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCheckNameAvailability.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Check if an IoT hub name is available. + * + * @summary Check if an IoT hub name is available. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/checkNameAvailability.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceCheckNameAvailability() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const operationInputs = { name: "test-request" }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.checkNameAvailability(operationInputs); + console.log(result); +} + +iotHubResourceCheckNameAvailability().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCreateEventHubConsumerGroup.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCreateEventHubConsumerGroup.js new file mode 100644 index 000000000000..a74a15b7406a --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCreateEventHubConsumerGroup.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + * + * @summary Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createconsumergroup.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceCreateEventHubConsumerGroup() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const eventHubEndpointName = "events"; + const name = "test"; + const consumerGroupBody = { + properties: { name: "test" }, + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.createEventHubConsumerGroup( + resourceGroupName, + resourceName, + eventHubEndpointName, + name, + consumerGroupBody + ); + console.log(result); +} + +iotHubResourceCreateEventHubConsumerGroup().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCreateOrUpdate.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCreateOrUpdate.js new file mode 100644 index 000000000000..cea1c7f7abcf --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceCreateOrUpdate.js @@ -0,0 +1,97 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. If certain properties are missing in the JSON, updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. + * + * @summary Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. If certain properties are missing in the JSON, updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createOrUpdate.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceCreateOrUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const iotHubDescription = { + etag: "AAAAAAFD6M4=", + location: "centraluseuap", + properties: { + cloudToDevice: { + defaultTtlAsIso8601: "PT1H", + feedback: { + lockDurationAsIso8601: "PT1M", + maxDeliveryCount: 10, + ttlAsIso8601: "PT1H", + }, + maxDeliveryCount: 10, + }, + enableDataResidency: true, + enableFileUploadNotifications: false, + eventHubEndpoints: { + events: { partitionCount: 2, retentionTimeInDays: 1 }, + }, + features: "None", + ipFilterRules: [], + messagingEndpoints: { + fileNotifications: { + lockDurationAsIso8601: "PT1M", + maxDeliveryCount: 10, + ttlAsIso8601: "PT1H", + }, + }, + minTlsVersion: "1.2", + networkRuleSets: { + applyToBuiltInEventHubEndpoint: true, + defaultAction: "Deny", + ipRules: [ + { action: "Allow", filterName: "rule1", ipMask: "131.117.159.53" }, + { action: "Allow", filterName: "rule2", ipMask: "157.55.59.128/25" }, + ], + }, + routing: { + endpoints: { + eventHubs: [], + serviceBusQueues: [], + serviceBusTopics: [], + storageContainers: [], + }, + fallbackRoute: { + name: "$fallback", + condition: "true", + endpointNames: ["events"], + isEnabled: true, + source: "DeviceMessages", + }, + routes: [], + }, + storageEndpoints: { + $default: { + connectionString: "", + containerName: "", + sasTtlAsIso8601: "PT1H", + }, + }, + }, + sku: { name: "S1", capacity: 1 }, + tags: {}, + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.beginCreateOrUpdateAndWait( + resourceGroupName, + resourceName, + iotHubDescription + ); + console.log(result); +} + +iotHubResourceCreateOrUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceDelete.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceDelete.js new file mode 100644 index 000000000000..b76a1aa0b358 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceDelete.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Delete an IoT hub. + * + * @summary Delete an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_delete.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceDelete() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.beginDeleteAndWait(resourceGroupName, resourceName); + console.log(result); +} + +iotHubResourceDelete().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceDeleteEventHubConsumerGroup.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceDeleteEventHubConsumerGroup.js new file mode 100644 index 000000000000..4423ea5f5cab --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceDeleteEventHubConsumerGroup.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + * + * @summary Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteconsumergroup.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceDeleteEventHubConsumerGroup() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const eventHubEndpointName = "events"; + const name = "test"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.deleteEventHubConsumerGroup( + resourceGroupName, + resourceName, + eventHubEndpointName, + name + ); + console.log(result); +} + +iotHubResourceDeleteEventHubConsumerGroup().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceExportDevices.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceExportDevices.js new file mode 100644 index 000000000000..834fc8f04d08 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceExportDevices.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * + * @summary Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_exportdevices.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceExportDevices() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const exportDevicesParameters = { + excludeKeys: true, + exportBlobContainerUri: "testBlob", + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.exportDevices( + resourceGroupName, + resourceName, + exportDevicesParameters + ); + console.log(result); +} + +iotHubResourceExportDevices().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGet.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGet.js new file mode 100644 index 000000000000..d24b427f8823 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGet.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the non-security related metadata of an IoT hub. + * + * @summary Get the non-security related metadata of an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_get.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceGet() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.get(resourceGroupName, resourceName); + console.log(result); +} + +iotHubResourceGet().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetEndpointHealth.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetEndpointHealth.js new file mode 100644 index 000000000000..e6241a69db38 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetEndpointHealth.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the health for routing endpoints. + * + * @summary Get the health for routing endpoints. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_routingendpointhealth.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceGetEndpointHealth() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const iotHubName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listEndpointHealth(resourceGroupName, iotHubName)) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceGetEndpointHealth().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetJob.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetJob.js new file mode 100644 index 000000000000..8ff572dcaea5 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetJob.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * + * @summary Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getjob.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceGetJob() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const jobId = "test"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getJob(resourceGroupName, resourceName, jobId); + console.log(result); +} + +iotHubResourceGetJob().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetKeysForKeyName.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetKeysForKeyName.js new file mode 100644 index 000000000000..64ace8650a4e --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetKeysForKeyName.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * + * @summary Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getkey.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceGetKeysForKeyName() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const keyName = "iothubowner"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getKeysForKeyName( + resourceGroupName, + resourceName, + keyName + ); + console.log(result); +} + +iotHubResourceGetKeysForKeyName().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetQuotaMetrics.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetQuotaMetrics.js new file mode 100644 index 000000000000..db9e1796f4f9 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetQuotaMetrics.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the quota metrics for an IoT hub. + * + * @summary Get the quota metrics for an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_quotametrics.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceGetQuotaMetrics() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listQuotaMetrics(resourceGroupName, resourceName)) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceGetQuotaMetrics().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetStats.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetStats.js new file mode 100644 index 000000000000..bea0ee3d4b3e --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetStats.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the statistics from an IoT hub. + * + * @summary Get the statistics from an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_stats.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceGetStats() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getStats(resourceGroupName, resourceName); + console.log(result); +} + +iotHubResourceGetStats().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetValidSkus.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetValidSkus.js new file mode 100644 index 000000000000..4af34e55c1be --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceGetValidSkus.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the list of valid SKUs for an IoT hub. + * + * @summary Get the list of valid SKUs for an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getskus.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceGetValidSkus() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listValidSkus(resourceGroupName, resourceName)) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceGetValidSkus().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceImportDevices.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceImportDevices.js new file mode 100644 index 000000000000..06a21a2a253d --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceImportDevices.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * + * @summary Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_importdevices.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceImportDevices() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const importDevicesParameters = { + inputBlobContainerUri: "testBlob", + outputBlobContainerUri: "testBlob", + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.importDevices( + resourceGroupName, + resourceName, + importDevicesParameters + ); + console.log(result); +} + +iotHubResourceImportDevices().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListByResourceGroup.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListByResourceGroup.js new file mode 100644 index 000000000000..7fb6d91ad5d4 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListByResourceGroup.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get all the IoT hubs in a resource group. + * + * @summary Get all the IoT hubs in a resource group. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbyrg.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceListByResourceGroup() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListByResourceGroup().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListBySubscription.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListBySubscription.js new file mode 100644 index 000000000000..8ec652fcf5ef --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListBySubscription.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get all the IoT hubs in a subscription. + * + * @summary Get all the IoT hubs in a subscription. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbysubscription.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceListBySubscription() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListBySubscription().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListEventHubConsumerGroups.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListEventHubConsumerGroups.js new file mode 100644 index 000000000000..b94f35b18f0d --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListEventHubConsumerGroups.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + * + * @summary Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getconsumergroup.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceListEventHubConsumerGroups() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const eventHubEndpointName = "events"; + const name = "test"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getEventHubConsumerGroup( + resourceGroupName, + resourceName, + eventHubEndpointName, + name + ); + console.log(result); +} + +iotHubResourceListEventHubConsumerGroups().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListJobs.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListJobs.js new file mode 100644 index 000000000000..23353ba84a85 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListJobs.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * + * @summary Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listjobs.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceListJobs() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listJobs(resourceGroupName, resourceName)) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListJobs().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListKeys.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListKeys.js new file mode 100644 index 000000000000..a64b8a3a266c --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceListKeys.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * + * @summary Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listkeys.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceListKeys() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listKeys(resourceGroupName, resourceName)) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListKeys().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceTestAllRoutes.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceTestAllRoutes.js new file mode 100644 index 000000000000..bd18ecd3bd87 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceTestAllRoutes.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Test all routes configured in this Iot Hub + * + * @summary Test all routes configured in this Iot Hub + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testallroutes.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceTestAllRoutes() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const iotHubName = "testHub"; + const resourceGroupName = "myResourceGroup"; + const input = { + message: { + appProperties: { key1: "value1" }, + body: "Body of message", + systemProperties: { key1: "value1" }, + }, + routingSource: "DeviceMessages", + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.testAllRoutes(iotHubName, resourceGroupName, input); + console.log(result); +} + +iotHubResourceTestAllRoutes().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceTestRoute.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceTestRoute.js new file mode 100644 index 000000000000..50e88648154d --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceTestRoute.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Test the new route for this Iot Hub + * + * @summary Test the new route for this Iot Hub + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testnewroute.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceTestRoute() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const iotHubName = "testHub"; + const resourceGroupName = "myResourceGroup"; + const input = { + message: { + appProperties: { key1: "value1" }, + body: "Body of message", + systemProperties: { key1: "value1" }, + }, + route: { + name: "Routeid", + endpointNames: ["id1"], + isEnabled: true, + source: "DeviceMessages", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.testRoute(iotHubName, resourceGroupName, input); + console.log(result); +} + +iotHubResourceTestRoute().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceUpdate.js b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceUpdate.js new file mode 100644 index 000000000000..918f734fc481 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/iotHubResourceUpdate.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method + * + * @summary Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_patch.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function iotHubResourceUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "myHub"; + const iotHubTags = { tags: { foo: "bar" } }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.beginUpdateAndWait( + resourceGroupName, + resourceName, + iotHubTags + ); + console.log(result); +} + +iotHubResourceUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/operationsList.js b/sdk/iothub/arm-iothub/samples/v6/javascript/operationsList.js new file mode 100644 index 000000000000..134b01ff8110 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/operationsList.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Lists all of the available IoT Hub REST API operations. + * + * @summary Lists all of the available IoT Hub REST API operations. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_operations.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function operationsList() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +operationsList().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/package.json b/sdk/iothub/arm-iothub/samples/v6/javascript/package.json new file mode 100644 index 000000000000..ffa31a46a63b --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "azure-arm-iothub-samples-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/iothub/arm-iothub" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/iothub/arm-iothub", + "dependencies": { + "@azure/arm-iothub": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionDelete.js b/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionDelete.js new file mode 100644 index 000000000000..c3de0937def5 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionDelete.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Delete private endpoint connection with the specified name + * + * @summary Delete private endpoint connection with the specified name + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteprivateendpointconnection.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function privateEndpointConnectionDelete() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const privateEndpointConnectionName = "myPrivateEndpointConnection"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + resourceName, + privateEndpointConnectionName + ); + console.log(result); +} + +privateEndpointConnectionDelete().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionGet.js b/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionGet.js new file mode 100644 index 000000000000..30c5b9e2c22d --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionGet.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get private endpoint connection properties + * + * @summary Get private endpoint connection properties + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivateendpointconnection.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function privateEndpointConnectionGet() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const privateEndpointConnectionName = "myPrivateEndpointConnection"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + resourceName, + privateEndpointConnectionName + ); + console.log(result); +} + +privateEndpointConnectionGet().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionUpdate.js b/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionUpdate.js new file mode 100644 index 000000000000..d10fde62d863 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionUpdate.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Update the status of a private endpoint connection with the specified name + * + * @summary Update the status of a private endpoint connection with the specified name + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_updateprivateendpointconnection.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function privateEndpointConnectionUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const privateEndpointConnectionName = "myPrivateEndpointConnection"; + const privateEndpointConnection = { + properties: { + privateLinkServiceConnectionState: { + description: "Approved by johndoe@contoso.com", + status: "Approved", + }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginUpdateAndWait( + resourceGroupName, + resourceName, + privateEndpointConnectionName, + privateEndpointConnection + ); + console.log(result); +} + +privateEndpointConnectionUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionsList.js b/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionsList.js new file mode 100644 index 000000000000..db3ea28c14a5 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/privateEndpointConnectionsList.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to List private endpoint connection properties + * + * @summary List private endpoint connection properties + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listprivateendpointconnections.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function privateEndpointConnectionsList() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.list(resourceGroupName, resourceName); + console.log(result); +} + +privateEndpointConnectionsList().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/privateLinkResourcesList.js b/sdk/iothub/arm-iothub/samples/v6/javascript/privateLinkResourcesList.js new file mode 100644 index 000000000000..022212e62eee --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/privateLinkResourcesList.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the specified private link resource for the given IotHub + * + * @summary Get the specified private link resource for the given IotHub + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivatelinkresources.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function privateLinkResourcesList() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const groupId = "iotHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateLinkResourcesOperations.get( + resourceGroupName, + resourceName, + groupId + ); + console.log(result); +} + +privateLinkResourcesList().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/resourceProviderCommonGetSubscriptionQuota.js b/sdk/iothub/arm-iothub/samples/v6/javascript/resourceProviderCommonGetSubscriptionQuota.js new file mode 100644 index 000000000000..062edaf7b23d --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/resourceProviderCommonGetSubscriptionQuota.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the number of free and paid iot hubs in the subscription + * + * @summary Get the number of free and paid iot hubs in the subscription + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_usages.json + */ +const { IotHubClient } = require("@azure/arm-iothub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +async function resourceProviderCommonGetSubscriptionQuota() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.resourceProviderCommon.getSubscriptionQuota(); + console.log(result); +} + +resourceProviderCommonGetSubscriptionQuota().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/javascript/sample.env b/sdk/iothub/arm-iothub/samples/v6/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/javascript/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/README.md b/sdk/iothub/arm-iothub/samples/v6/typescript/README.md new file mode 100644 index 000000000000..658b29ee8f1c --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/README.md @@ -0,0 +1,133 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [certificatesCreateOrUpdate.ts][certificatescreateorupdate] | Adds new or replaces existing certificate. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatescreateorupdate.json | +| [certificatesDelete.ts][certificatesdelete] | Deletes an existing X509 certificate or does nothing if it does not exist. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatesdelete.json | +| [certificatesGenerateVerificationCode.ts][certificatesgenerateverificationcode] | Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_generateverificationcode.json | +| [certificatesGet.ts][certificatesget] | Returns the certificate. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getcertificate.json | +| [certificatesListByIotHub.ts][certificateslistbyiothub] | Returns the list of certificates. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listcertificates.json | +| [certificatesVerify.ts][certificatesverify] | Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certverify.json | +| [iotHubManualFailover.ts][iothubmanualfailover] | Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/IotHub_ManualFailover.json | +| [iotHubResourceCheckNameAvailability.ts][iothubresourcechecknameavailability] | Check if an IoT hub name is available. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/checkNameAvailability.json | +| [iotHubResourceCreateEventHubConsumerGroup.ts][iothubresourcecreateeventhubconsumergroup] | Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createconsumergroup.json | +| [iotHubResourceCreateOrUpdate.ts][iothubresourcecreateorupdate] | Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. If certain properties are missing in the JSON, updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createOrUpdate.json | +| [iotHubResourceDelete.ts][iothubresourcedelete] | Delete an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_delete.json | +| [iotHubResourceDeleteEventHubConsumerGroup.ts][iothubresourcedeleteeventhubconsumergroup] | Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteconsumergroup.json | +| [iotHubResourceExportDevices.ts][iothubresourceexportdevices] | Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_exportdevices.json | +| [iotHubResourceGet.ts][iothubresourceget] | Get the non-security related metadata of an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_get.json | +| [iotHubResourceGetEndpointHealth.ts][iothubresourcegetendpointhealth] | Get the health for routing endpoints. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_routingendpointhealth.json | +| [iotHubResourceGetJob.ts][iothubresourcegetjob] | Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getjob.json | +| [iotHubResourceGetKeysForKeyName.ts][iothubresourcegetkeysforkeyname] | Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getkey.json | +| [iotHubResourceGetQuotaMetrics.ts][iothubresourcegetquotametrics] | Get the quota metrics for an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_quotametrics.json | +| [iotHubResourceGetStats.ts][iothubresourcegetstats] | Get the statistics from an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_stats.json | +| [iotHubResourceGetValidSkus.ts][iothubresourcegetvalidskus] | Get the list of valid SKUs for an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getskus.json | +| [iotHubResourceImportDevices.ts][iothubresourceimportdevices] | Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_importdevices.json | +| [iotHubResourceListByResourceGroup.ts][iothubresourcelistbyresourcegroup] | Get all the IoT hubs in a resource group. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbyrg.json | +| [iotHubResourceListBySubscription.ts][iothubresourcelistbysubscription] | Get all the IoT hubs in a subscription. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbysubscription.json | +| [iotHubResourceListEventHubConsumerGroups.ts][iothubresourcelisteventhubconsumergroups] | Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getconsumergroup.json | +| [iotHubResourceListJobs.ts][iothubresourcelistjobs] | Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listjobs.json | +| [iotHubResourceListKeys.ts][iothubresourcelistkeys] | Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listkeys.json | +| [iotHubResourceTestAllRoutes.ts][iothubresourcetestallroutes] | Test all routes configured in this Iot Hub x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testallroutes.json | +| [iotHubResourceTestRoute.ts][iothubresourcetestroute] | Test the new route for this Iot Hub x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testnewroute.json | +| [iotHubResourceUpdate.ts][iothubresourceupdate] | Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_patch.json | +| [operationsList.ts][operationslist] | Lists all of the available IoT Hub REST API operations. x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_operations.json | +| [privateEndpointConnectionDelete.ts][privateendpointconnectiondelete] | Delete private endpoint connection with the specified name x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteprivateendpointconnection.json | +| [privateEndpointConnectionGet.ts][privateendpointconnectionget] | Get private endpoint connection properties x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivateendpointconnection.json | +| [privateEndpointConnectionUpdate.ts][privateendpointconnectionupdate] | Update the status of a private endpoint connection with the specified name x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_updateprivateendpointconnection.json | +| [privateEndpointConnectionsList.ts][privateendpointconnectionslist] | List private endpoint connection properties x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listprivateendpointconnections.json | +| [privateLinkResourcesList.ts][privatelinkresourceslist] | Get the specified private link resource for the given IotHub x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivatelinkresources.json | +| [resourceProviderCommonGetSubscriptionQuota.ts][resourceprovidercommongetsubscriptionquota] | Get the number of free and paid iot hubs in the subscription x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_usages.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/certificatesCreateOrUpdate.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env node dist/certificatesCreateOrUpdate.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[certificatescreateorupdate]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesCreateOrUpdate.ts +[certificatesdelete]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesDelete.ts +[certificatesgenerateverificationcode]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesGenerateVerificationCode.ts +[certificatesget]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesGet.ts +[certificateslistbyiothub]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesListByIotHub.ts +[certificatesverify]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesVerify.ts +[iothubmanualfailover]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubManualFailover.ts +[iothubresourcechecknameavailability]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCheckNameAvailability.ts +[iothubresourcecreateeventhubconsumergroup]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCreateEventHubConsumerGroup.ts +[iothubresourcecreateorupdate]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCreateOrUpdate.ts +[iothubresourcedelete]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceDelete.ts +[iothubresourcedeleteeventhubconsumergroup]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceDeleteEventHubConsumerGroup.ts +[iothubresourceexportdevices]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceExportDevices.ts +[iothubresourceget]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGet.ts +[iothubresourcegetendpointhealth]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetEndpointHealth.ts +[iothubresourcegetjob]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetJob.ts +[iothubresourcegetkeysforkeyname]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetKeysForKeyName.ts +[iothubresourcegetquotametrics]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetQuotaMetrics.ts +[iothubresourcegetstats]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetStats.ts +[iothubresourcegetvalidskus]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetValidSkus.ts +[iothubresourceimportdevices]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceImportDevices.ts +[iothubresourcelistbyresourcegroup]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListByResourceGroup.ts +[iothubresourcelistbysubscription]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListBySubscription.ts +[iothubresourcelisteventhubconsumergroups]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListEventHubConsumerGroups.ts +[iothubresourcelistjobs]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListJobs.ts +[iothubresourcelistkeys]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListKeys.ts +[iothubresourcetestallroutes]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceTestAllRoutes.ts +[iothubresourcetestroute]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceTestRoute.ts +[iothubresourceupdate]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceUpdate.ts +[operationslist]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/operationsList.ts +[privateendpointconnectiondelete]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionDelete.ts +[privateendpointconnectionget]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionGet.ts +[privateendpointconnectionupdate]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionUpdate.ts +[privateendpointconnectionslist]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionsList.ts +[privatelinkresourceslist]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateLinkResourcesList.ts +[resourceprovidercommongetsubscriptionquota]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/iothub/arm-iothub/samples/v6/typescript/src/resourceProviderCommonGetSubscriptionQuota.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-iothub?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/iothub/arm-iothub/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/package.json b/sdk/iothub/arm-iothub/samples/v6/typescript/package.json new file mode 100644 index 000000000000..5a6f7db42c31 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "azure-arm-iothub-samples-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/iothub/arm-iothub" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/iothub/arm-iothub", + "dependencies": { + "@azure/arm-iothub": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/sample.env b/sdk/iothub/arm-iothub/samples/v6/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesCreateOrUpdate.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesCreateOrUpdate.ts new file mode 100644 index 000000000000..9a013d78bb67 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesCreateOrUpdate.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Adds new or replaces existing certificate. + * + * @summary Adds new or replaces existing certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatescreateorupdate.json + */ +import { CertificateDescription, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesCreateOrUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "iothub"; + const certificateName = "cert"; + const certificateDescription: CertificateDescription = { + properties: { certificate: "############################################" } + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.createOrUpdate( + resourceGroupName, + resourceName, + certificateName, + certificateDescription + ); + console.log(result); +} + +certificatesCreateOrUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesDelete.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesDelete.ts new file mode 100644 index 000000000000..e2bee6f90023 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesDelete.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Deletes an existing X509 certificate or does nothing if it does not exist. + * + * @summary Deletes an existing X509 certificate or does nothing if it does not exist. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatesdelete.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesDelete() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "myhub"; + const certificateName = "cert"; + const ifMatch = "AAAAAAAADGk="; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.delete( + resourceGroupName, + resourceName, + certificateName, + ifMatch + ); + console.log(result); +} + +certificatesDelete().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesGenerateVerificationCode.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesGenerateVerificationCode.ts new file mode 100644 index 000000000000..1f98b89d8c99 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesGenerateVerificationCode.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. + * + * @summary Generates verification code for proof of possession flow. The verification code will be used to generate a leaf certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_generateverificationcode.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesGenerateVerificationCode() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const certificateName = "cert"; + const ifMatch = "AAAAAAAADGk="; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.generateVerificationCode( + resourceGroupName, + resourceName, + certificateName, + ifMatch + ); + console.log(result); +} + +certificatesGenerateVerificationCode().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesGet.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesGet.ts new file mode 100644 index 000000000000..849ebef06d49 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesGet.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Returns the certificate. + * + * @summary Returns the certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getcertificate.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesGet() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testhub"; + const certificateName = "cert"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.get( + resourceGroupName, + resourceName, + certificateName + ); + console.log(result); +} + +certificatesGet().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesListByIotHub.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesListByIotHub.ts new file mode 100644 index 000000000000..80547fa0c2be --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesListByIotHub.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Returns the list of certificates. + * + * @summary Returns the list of certificates. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listcertificates.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesListByIotHub() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testhub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.listByIotHub( + resourceGroupName, + resourceName + ); + console.log(result); +} + +certificatesListByIotHub().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesVerify.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesVerify.ts new file mode 100644 index 000000000000..163c731bb6a1 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/certificatesVerify.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. + * + * @summary Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certverify.json + */ +import { + CertificateVerificationDescription, + IotHubClient +} from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function certificatesVerify() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "myFirstProvisioningService"; + const certificateName = "cert"; + const ifMatch = "AAAAAAAADGk="; + const certificateVerificationBody: CertificateVerificationDescription = { + certificate: "#####################################" + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.certificates.verify( + resourceGroupName, + resourceName, + certificateName, + ifMatch, + certificateVerificationBody + ); + console.log(result); +} + +certificatesVerify().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubManualFailover.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubManualFailover.ts new file mode 100644 index 000000000000..ca18487069eb --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubManualFailover.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover + * + * @summary Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see https://aka.ms/manualfailover + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/IotHub_ManualFailover.json + */ +import { FailoverInput, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubManualFailover() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const iotHubName = "testHub"; + const resourceGroupName = "myResourceGroup"; + const failoverInput: FailoverInput = { failoverRegion: "testHub" }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHub.beginManualFailoverAndWait( + iotHubName, + resourceGroupName, + failoverInput + ); + console.log(result); +} + +iotHubManualFailover().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCheckNameAvailability.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCheckNameAvailability.ts new file mode 100644 index 000000000000..015bcdfacc24 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCheckNameAvailability.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Check if an IoT hub name is available. + * + * @summary Check if an IoT hub name is available. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/checkNameAvailability.json + */ +import { OperationInputs, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceCheckNameAvailability() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const operationInputs: OperationInputs = { name: "test-request" }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.checkNameAvailability( + operationInputs + ); + console.log(result); +} + +iotHubResourceCheckNameAvailability().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCreateEventHubConsumerGroup.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCreateEventHubConsumerGroup.ts new file mode 100644 index 000000000000..f08d74458830 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCreateEventHubConsumerGroup.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + * + * @summary Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createconsumergroup.json + */ +import { + EventHubConsumerGroupBodyDescription, + IotHubClient +} from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceCreateEventHubConsumerGroup() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const eventHubEndpointName = "events"; + const name = "test"; + const consumerGroupBody: EventHubConsumerGroupBodyDescription = { + properties: { name: "test" } + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.createEventHubConsumerGroup( + resourceGroupName, + resourceName, + eventHubEndpointName, + name, + consumerGroupBody + ); + console.log(result); +} + +iotHubResourceCreateEventHubConsumerGroup().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCreateOrUpdate.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCreateOrUpdate.ts new file mode 100644 index 000000000000..ec6285b2fdd6 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceCreateOrUpdate.ts @@ -0,0 +1,97 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. If certain properties are missing in the JSON, updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. + * + * @summary Create or update the metadata of an Iot hub. The usual pattern to modify a property is to retrieve the IoT hub metadata and security metadata, and then combine them with the modified values in a new body to update the IoT hub. If certain properties are missing in the JSON, updating IoT Hub may cause these values to fallback to default, which may lead to unexpected behavior. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createOrUpdate.json + */ +import { IotHubDescription, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceCreateOrUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const iotHubDescription: IotHubDescription = { + etag: "AAAAAAFD6M4=", + location: "centraluseuap", + properties: { + cloudToDevice: { + defaultTtlAsIso8601: "PT1H", + feedback: { + lockDurationAsIso8601: "PT1M", + maxDeliveryCount: 10, + ttlAsIso8601: "PT1H" + }, + maxDeliveryCount: 10 + }, + enableDataResidency: true, + enableFileUploadNotifications: false, + eventHubEndpoints: { + events: { partitionCount: 2, retentionTimeInDays: 1 } + }, + features: "None", + ipFilterRules: [], + messagingEndpoints: { + fileNotifications: { + lockDurationAsIso8601: "PT1M", + maxDeliveryCount: 10, + ttlAsIso8601: "PT1H" + } + }, + minTlsVersion: "1.2", + networkRuleSets: { + applyToBuiltInEventHubEndpoint: true, + defaultAction: "Deny", + ipRules: [ + { action: "Allow", filterName: "rule1", ipMask: "131.117.159.53" }, + { action: "Allow", filterName: "rule2", ipMask: "157.55.59.128/25" } + ] + }, + routing: { + endpoints: { + eventHubs: [], + serviceBusQueues: [], + serviceBusTopics: [], + storageContainers: [] + }, + fallbackRoute: { + name: "$fallback", + condition: "true", + endpointNames: ["events"], + isEnabled: true, + source: "DeviceMessages" + }, + routes: [] + }, + storageEndpoints: { + $default: { + connectionString: "", + containerName: "", + sasTtlAsIso8601: "PT1H" + } + } + }, + sku: { name: "S1", capacity: 1 }, + tags: {} + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.beginCreateOrUpdateAndWait( + resourceGroupName, + resourceName, + iotHubDescription + ); + console.log(result); +} + +iotHubResourceCreateOrUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceDelete.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceDelete.ts new file mode 100644 index 000000000000..54d16b14fb1f --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceDelete.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Delete an IoT hub. + * + * @summary Delete an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_delete.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceDelete() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.beginDeleteAndWait( + resourceGroupName, + resourceName + ); + console.log(result); +} + +iotHubResourceDelete().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceDeleteEventHubConsumerGroup.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceDeleteEventHubConsumerGroup.ts new file mode 100644 index 000000000000..d9b7e3fb8b4e --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceDeleteEventHubConsumerGroup.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + * + * @summary Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteconsumergroup.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceDeleteEventHubConsumerGroup() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const eventHubEndpointName = "events"; + const name = "test"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.deleteEventHubConsumerGroup( + resourceGroupName, + resourceName, + eventHubEndpointName, + name + ); + console.log(result); +} + +iotHubResourceDeleteEventHubConsumerGroup().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceExportDevices.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceExportDevices.ts new file mode 100644 index 000000000000..229f43f9b6f0 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceExportDevices.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * + * @summary Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_exportdevices.json + */ +import { ExportDevicesRequest, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceExportDevices() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const exportDevicesParameters: ExportDevicesRequest = { + excludeKeys: true, + exportBlobContainerUri: "testBlob" + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.exportDevices( + resourceGroupName, + resourceName, + exportDevicesParameters + ); + console.log(result); +} + +iotHubResourceExportDevices().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGet.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGet.ts new file mode 100644 index 000000000000..317295da37b3 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGet.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the non-security related metadata of an IoT hub. + * + * @summary Get the non-security related metadata of an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_get.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGet() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.get( + resourceGroupName, + resourceName + ); + console.log(result); +} + +iotHubResourceGet().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetEndpointHealth.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetEndpointHealth.ts new file mode 100644 index 000000000000..774f4a95fa94 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetEndpointHealth.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the health for routing endpoints. + * + * @summary Get the health for routing endpoints. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_routingendpointhealth.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetEndpointHealth() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const iotHubName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listEndpointHealth( + resourceGroupName, + iotHubName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceGetEndpointHealth().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetJob.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetJob.ts new file mode 100644 index 000000000000..449ec326c792 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetJob.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * + * @summary Get the details of a job from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getjob.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetJob() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const jobId = "test"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getJob( + resourceGroupName, + resourceName, + jobId + ); + console.log(result); +} + +iotHubResourceGetJob().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetKeysForKeyName.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetKeysForKeyName.ts new file mode 100644 index 000000000000..f10860ce37a7 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetKeysForKeyName.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * + * @summary Get a shared access policy by name from an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getkey.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetKeysForKeyName() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const keyName = "iothubowner"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getKeysForKeyName( + resourceGroupName, + resourceName, + keyName + ); + console.log(result); +} + +iotHubResourceGetKeysForKeyName().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetQuotaMetrics.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetQuotaMetrics.ts new file mode 100644 index 000000000000..4050046f4327 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetQuotaMetrics.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the quota metrics for an IoT hub. + * + * @summary Get the quota metrics for an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_quotametrics.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetQuotaMetrics() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listQuotaMetrics( + resourceGroupName, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceGetQuotaMetrics().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetStats.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetStats.ts new file mode 100644 index 000000000000..d9ce0b0bf630 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetStats.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the statistics from an IoT hub. + * + * @summary Get the statistics from an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_stats.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetStats() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getStats( + resourceGroupName, + resourceName + ); + console.log(result); +} + +iotHubResourceGetStats().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetValidSkus.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetValidSkus.ts new file mode 100644 index 000000000000..adcefcf33436 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceGetValidSkus.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the list of valid SKUs for an IoT hub. + * + * @summary Get the list of valid SKUs for an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getskus.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceGetValidSkus() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listValidSkus( + resourceGroupName, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceGetValidSkus().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceImportDevices.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceImportDevices.ts new file mode 100644 index 000000000000..6ec94da17516 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceImportDevices.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * + * @summary Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_importdevices.json + */ +import { ImportDevicesRequest, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceImportDevices() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const importDevicesParameters: ImportDevicesRequest = { + inputBlobContainerUri: "testBlob", + outputBlobContainerUri: "testBlob" + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.importDevices( + resourceGroupName, + resourceName, + importDevicesParameters + ); + console.log(result); +} + +iotHubResourceImportDevices().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListByResourceGroup.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListByResourceGroup.ts new file mode 100644 index 000000000000..0c87a5ea8aad --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListByResourceGroup.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get all the IoT hubs in a resource group. + * + * @summary Get all the IoT hubs in a resource group. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbyrg.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceListByResourceGroup() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListByResourceGroup().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListBySubscription.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListBySubscription.ts new file mode 100644 index 000000000000..69d39ff3ebba --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListBySubscription.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get all the IoT hubs in a subscription. + * + * @summary Get all the IoT hubs in a subscription. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbysubscription.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceListBySubscription() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListBySubscription().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListEventHubConsumerGroups.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListEventHubConsumerGroups.ts new file mode 100644 index 000000000000..2b7593d2745c --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListEventHubConsumerGroups.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + * + * @summary Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getconsumergroup.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceListEventHubConsumerGroups() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const eventHubEndpointName = "events"; + const name = "test"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.getEventHubConsumerGroup( + resourceGroupName, + resourceName, + eventHubEndpointName, + name + ); + console.log(result); +} + +iotHubResourceListEventHubConsumerGroups().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListJobs.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListJobs.ts new file mode 100644 index 000000000000..7d430b408015 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListJobs.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * + * @summary Get a list of all the jobs in an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listjobs.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceListJobs() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listJobs( + resourceGroupName, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListJobs().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListKeys.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListKeys.ts new file mode 100644 index 000000000000..c313a0bc4029 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceListKeys.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * + * @summary Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listkeys.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceListKeys() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.iotHubResource.listKeys( + resourceGroupName, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +iotHubResourceListKeys().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceTestAllRoutes.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceTestAllRoutes.ts new file mode 100644 index 000000000000..28e153bffd02 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceTestAllRoutes.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Test all routes configured in this Iot Hub + * + * @summary Test all routes configured in this Iot Hub + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testallroutes.json + */ +import { TestAllRoutesInput, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceTestAllRoutes() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const iotHubName = "testHub"; + const resourceGroupName = "myResourceGroup"; + const input: TestAllRoutesInput = { + message: { + appProperties: { key1: "value1" }, + body: "Body of message", + systemProperties: { key1: "value1" } + }, + routingSource: "DeviceMessages" + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.testAllRoutes( + iotHubName, + resourceGroupName, + input + ); + console.log(result); +} + +iotHubResourceTestAllRoutes().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceTestRoute.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceTestRoute.ts new file mode 100644 index 000000000000..72d9fbf2f6f2 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceTestRoute.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Test the new route for this Iot Hub + * + * @summary Test the new route for this Iot Hub + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testnewroute.json + */ +import { TestRouteInput, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceTestRoute() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const iotHubName = "testHub"; + const resourceGroupName = "myResourceGroup"; + const input: TestRouteInput = { + message: { + appProperties: { key1: "value1" }, + body: "Body of message", + systemProperties: { key1: "value1" } + }, + route: { + name: "Routeid", + endpointNames: ["id1"], + isEnabled: true, + source: "DeviceMessages" + } + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.testRoute( + iotHubName, + resourceGroupName, + input + ); + console.log(result); +} + +iotHubResourceTestRoute().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceUpdate.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceUpdate.ts new file mode 100644 index 000000000000..62f231fbb540 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/iotHubResourceUpdate.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method + * + * @summary Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_patch.json + */ +import { TagsResource, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function iotHubResourceUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "myHub"; + const iotHubTags: TagsResource = { tags: { foo: "bar" } }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.iotHubResource.beginUpdateAndWait( + resourceGroupName, + resourceName, + iotHubTags + ); + console.log(result); +} + +iotHubResourceUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/operationsList.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/operationsList.ts new file mode 100644 index 000000000000..a238767971a8 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/operationsList.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Lists all of the available IoT Hub REST API operations. + * + * @summary Lists all of the available IoT Hub REST API operations. + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_operations.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function operationsList() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +operationsList().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionDelete.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionDelete.ts new file mode 100644 index 000000000000..0ca21718f8f2 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionDelete.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Delete private endpoint connection with the specified name + * + * @summary Delete private endpoint connection with the specified name + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteprivateendpointconnection.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function privateEndpointConnectionDelete() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const privateEndpointConnectionName = "myPrivateEndpointConnection"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + resourceName, + privateEndpointConnectionName + ); + console.log(result); +} + +privateEndpointConnectionDelete().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionGet.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionGet.ts new file mode 100644 index 000000000000..58bfde372355 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionGet.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get private endpoint connection properties + * + * @summary Get private endpoint connection properties + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivateendpointconnection.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function privateEndpointConnectionGet() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const privateEndpointConnectionName = "myPrivateEndpointConnection"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + resourceName, + privateEndpointConnectionName + ); + console.log(result); +} + +privateEndpointConnectionGet().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionUpdate.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionUpdate.ts new file mode 100644 index 000000000000..480a75675ff9 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionUpdate.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Update the status of a private endpoint connection with the specified name + * + * @summary Update the status of a private endpoint connection with the specified name + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_updateprivateendpointconnection.json + */ +import { PrivateEndpointConnection, IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function privateEndpointConnectionUpdate() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const privateEndpointConnectionName = "myPrivateEndpointConnection"; + const privateEndpointConnection: PrivateEndpointConnection = { + properties: { + privateLinkServiceConnectionState: { + description: "Approved by johndoe@contoso.com", + status: "Approved" + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginUpdateAndWait( + resourceGroupName, + resourceName, + privateEndpointConnectionName, + privateEndpointConnection + ); + console.log(result); +} + +privateEndpointConnectionUpdate().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionsList.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionsList.ts new file mode 100644 index 000000000000..19013db3db3d --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateEndpointConnectionsList.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to List private endpoint connection properties + * + * @summary List private endpoint connection properties + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listprivateendpointconnections.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function privateEndpointConnectionsList() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.list( + resourceGroupName, + resourceName + ); + console.log(result); +} + +privateEndpointConnectionsList().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateLinkResourcesList.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateLinkResourcesList.ts new file mode 100644 index 000000000000..1c3c00214b14 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/privateLinkResourcesList.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the specified private link resource for the given IotHub + * + * @summary Get the specified private link resource for the given IotHub + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivatelinkresources.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function privateLinkResourcesList() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const resourceGroupName = "myResourceGroup"; + const resourceName = "testHub"; + const groupId = "iotHub"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.privateLinkResourcesOperations.get( + resourceGroupName, + resourceName, + groupId + ); + console.log(result); +} + +privateLinkResourcesList().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/src/resourceProviderCommonGetSubscriptionQuota.ts b/sdk/iothub/arm-iothub/samples/v6/typescript/src/resourceProviderCommonGetSubscriptionQuota.ts new file mode 100644 index 000000000000..f43af9e6dcaa --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/src/resourceProviderCommonGetSubscriptionQuota.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +/** + * This sample demonstrates how to Get the number of free and paid iot hubs in the subscription + * + * @summary Get the number of free and paid iot hubs in the subscription + * x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_usages.json + */ +import { IotHubClient } from "@azure/arm-iothub"; +import { DefaultAzureCredential } from "@azure/identity"; + +async function resourceProviderCommonGetSubscriptionQuota() { + const subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + const credential = new DefaultAzureCredential(); + const client = new IotHubClient(credential, subscriptionId); + const result = await client.resourceProviderCommon.getSubscriptionQuota(); + console.log(result); +} + +resourceProviderCommonGetSubscriptionQuota().catch(console.error); diff --git a/sdk/iothub/arm-iothub/samples/v6/typescript/tsconfig.json b/sdk/iothub/arm-iothub/samples/v6/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/iothub/arm-iothub/samples/v6/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**.ts" + ] +} diff --git a/sdk/iothub/arm-iothub/src/iotHubClient.ts b/sdk/iothub/arm-iothub/src/iotHubClient.ts index e07d85b093e4..11051ed65934 100644 --- a/sdk/iothub/arm-iothub/src/iotHubClient.ts +++ b/sdk/iothub/arm-iothub/src/iotHubClient.ts @@ -60,7 +60,7 @@ export class IotHubClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-iothub/6.0.0`; + const packageDetails = `azsdk-js-arm-iothub/6.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -83,7 +83,7 @@ export class IotHubClient extends coreClient.ServiceClient { // Assigning values to Constant parameters this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2021-07-01"; + this.apiVersion = options.apiVersion || "2021-07-02"; this.operations = new OperationsImpl(this); this.iotHubResource = new IotHubResourceImpl(this); this.resourceProviderCommon = new ResourceProviderCommonImpl(this); diff --git a/sdk/iothub/arm-iothub/src/models/index.ts b/sdk/iothub/arm-iothub/src/models/index.ts index ea885397feb4..de2928bce2aa 100644 --- a/sdk/iothub/arm-iothub/src/models/index.ts +++ b/sdk/iothub/arm-iothub/src/models/index.ts @@ -141,6 +141,8 @@ export interface IotHubProperties { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly locations?: IotHubLocationDescription[]; + /** This property when set to true, will enable data residency, thus, disabling disaster recovery. */ + enableDataResidency?: boolean; } /** The properties of an IoT hub shared access policy. */ @@ -509,6 +511,22 @@ export interface ArmUserIdentity { readonly clientId?: string; } +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemData { + /** The identity that created the resource. */ + createdBy?: string; + /** The type of identity that created the resource. */ + createdByType?: CreatedByType; + /** The timestamp of resource creation (UTC). */ + createdAt?: Date; + /** The identity that last modified the resource. */ + lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + lastModifiedByType?: CreatedByType; + /** The timestamp of resource last modification (UTC) */ + lastModifiedAt?: Date; +} + /** The common properties of an Azure resource. */ export interface Resource { /** @@ -1177,6 +1195,11 @@ export type IotHubDescription = Resource & { sku: IotHubSkuInfo; /** The managed identities for the IotHub. */ identity?: ArmIdentity; + /** + * The system meta data relating to this resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly systemData?: SystemData; }; /** Known values of {@link PublicNetworkAccess} that the service accepts. */ @@ -1361,6 +1384,26 @@ export enum KnownIotHubSku { */ export type IotHubSku = string; +/** Known values of {@link CreatedByType} that the service accepts. */ +export enum KnownCreatedByType { + User = "User", + Application = "Application", + ManagedIdentity = "ManagedIdentity", + Key = "Key" +} + +/** + * Defines values for CreatedByType. \ + * {@link KnownCreatedByType} can be used interchangeably with CreatedByType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **User** \ + * **Application** \ + * **ManagedIdentity** \ + * **Key** + */ +export type CreatedByType = string; + /** Known values of {@link JobType} that the service accepts. */ export enum KnownJobType { Unknown = "unknown", diff --git a/sdk/iothub/arm-iothub/src/models/mappers.ts b/sdk/iothub/arm-iothub/src/models/mappers.ts index 2fcb7be870c6..3a67045a8d62 100644 --- a/sdk/iothub/arm-iothub/src/models/mappers.ts +++ b/sdk/iothub/arm-iothub/src/models/mappers.ts @@ -324,6 +324,12 @@ export const IotHubProperties: coreClient.CompositeMapper = { } } } + }, + enableDataResidency: { + serializedName: "enableDataResidency", + type: { + name: "Boolean" + } } } } @@ -1450,6 +1456,51 @@ export const ArmUserIdentity: coreClient.CompositeMapper = { } }; +export const SystemData: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SystemData", + modelProperties: { + createdBy: { + serializedName: "createdBy", + type: { + name: "String" + } + }, + createdByType: { + serializedName: "createdByType", + type: { + name: "String" + } + }, + createdAt: { + serializedName: "createdAt", + type: { + name: "DateTime" + } + }, + lastModifiedBy: { + serializedName: "lastModifiedBy", + type: { + name: "String" + } + }, + lastModifiedByType: { + serializedName: "lastModifiedByType", + type: { + name: "String" + } + }, + lastModifiedAt: { + serializedName: "lastModifiedAt", + type: { + name: "DateTime" + } + } + } + } +}; + export const Resource: coreClient.CompositeMapper = { type: { name: "Composite", @@ -2985,6 +3036,13 @@ export const IotHubDescription: coreClient.CompositeMapper = { name: "Composite", className: "ArmIdentity" } + }, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" + } } } } diff --git a/sdk/iothub/arm-iothub/src/models/parameters.ts b/sdk/iothub/arm-iothub/src/models/parameters.ts index 14646b843a2e..cfd3f334feae 100644 --- a/sdk/iothub/arm-iothub/src/models/parameters.ts +++ b/sdk/iothub/arm-iothub/src/models/parameters.ts @@ -53,7 +53,7 @@ export const $host: OperationURLParameter = { export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2021-07-01", + defaultValue: "2021-07-02", isConstant: true, serializedName: "api-version", type: { diff --git a/sdk/iothub/arm-iothub/test/sampleTest.ts b/sdk/iothub/arm-iothub/test/sampleTest.ts new file mode 100644 index 000000000000..7ed89b043e1b --- /dev/null +++ b/sdk/iothub/arm-iothub/test/sampleTest.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + env, + record, + RecorderEnvironmentSetup, + Recorder +} from "@azure-tools/test-recorder"; +import * as assert from "assert"; + +const recorderEnvSetup: RecorderEnvironmentSetup = { + replaceableVariables: { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" + }, + customizationsOnRecordings: [ + (recording: any): any => + recording.replace( + /"access_token":"[^"]*"/g, + `"access_token":"access_token"` + ) + ], + queryParametersToSkip: [] +}; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function() { + recorder = record(this, recorderEnvSetup); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("sample test", async function() { + console.log("Hi, I'm a test!"); + }); +}); diff --git a/sdk/iothub/arm-iothub/tsconfig.json b/sdk/iothub/arm-iothub/tsconfig.json index 6e3251194117..a89ae98f4120 100644 --- a/sdk/iothub/arm-iothub/tsconfig.json +++ b/sdk/iothub/arm-iothub/tsconfig.json @@ -9,11 +9,24 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-iothub": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file From 980f8ab37cdc4dd9307fc47033ab2f35813452ba Mon Sep 17 00:00:00 2001 From: colawwj Date: Tue, 15 Feb 2022 11:19:48 +0800 Subject: [PATCH 2/2] update --- sdk/iothub/arm-iothub/CHANGELOG.md | 2 +- sdk/iothub/arm-iothub/_meta.json | 6 +-- sdk/iothub/arm-iothub/package.json | 2 +- sdk/iothub/arm-iothub/test/sampleTest.ts | 48 ------------------------ 4 files changed, 5 insertions(+), 53 deletions(-) delete mode 100644 sdk/iothub/arm-iothub/test/sampleTest.ts diff --git a/sdk/iothub/arm-iothub/CHANGELOG.md b/sdk/iothub/arm-iothub/CHANGELOG.md index 8ff47c320053..239d351ae5a3 100644 --- a/sdk/iothub/arm-iothub/CHANGELOG.md +++ b/sdk/iothub/arm-iothub/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 6.1.0 (2022-01-25) +## 6.1.0 (2022-02-15) **Features** diff --git a/sdk/iothub/arm-iothub/_meta.json b/sdk/iothub/arm-iothub/_meta.json index 5de12e35ff77..b0805ebbd492 100644 --- a/sdk/iothub/arm-iothub/_meta.json +++ b/sdk/iothub/arm-iothub/_meta.json @@ -1,7 +1,7 @@ { - "commit": "c1940e0e837e74a535b2c9166374b71b970a6b97", + "commit": "5b02f0befa6eaaaf93afc11274795c651e6e3c0c", "readme": "specification/iothub/resource-manager/readme.md", - "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/iothub/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20220114.1 --generate-sample=true", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/iothub/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20220128.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20220114.1" + "use": "@autorest/typescript@6.0.0-alpha.16.20220128.1" } \ No newline at end of file diff --git a/sdk/iothub/arm-iothub/package.json b/sdk/iothub/arm-iothub/package.json index 35102acf5148..c40a59456074 100644 --- a/sdk/iothub/arm-iothub/package.json +++ b/sdk/iothub/arm-iothub/package.json @@ -101,7 +101,7 @@ "//metadata": { "constantPaths": [ { - "path": "src/IotHubClient.ts", + "path": "src/iotHubClient.ts", "prefix": "packageDetails" } ] diff --git a/sdk/iothub/arm-iothub/test/sampleTest.ts b/sdk/iothub/arm-iothub/test/sampleTest.ts deleted file mode 100644 index 7ed89b043e1b..000000000000 --- a/sdk/iothub/arm-iothub/test/sampleTest.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { - env, - record, - RecorderEnvironmentSetup, - Recorder -} from "@azure-tools/test-recorder"; -import * as assert from "assert"; - -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] -}; - -describe("My test", () => { - let recorder: Recorder; - - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); - }); - - afterEach(async function() { - await recorder.stop(); - }); - - it("sample test", async function() { - console.log("Hi, I'm a test!"); - }); -});