diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a9ed244e4d1..9eecf48ecf5 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -452,6 +452,10 @@ # PRLabel: %Mgmt /sdk/devspaces/arm-devspaces/ @qiaozha @MaryGao + +# PRLabel: %Mgmt +/sdk/deviceregistry/arm-deviceregistry/ @qiaozha @MaryGao + # PRLabel: %Mgmt /sdk/defendereasm/arm-defendereasm/ @qiaozha @MaryGao diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 83db1e3f3fe..69fd78b6d67 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -266,6 +266,9 @@ dependencies: '@rush-temp/arm-deviceprovisioningservices': specifier: file:./projects/arm-deviceprovisioningservices.tgz version: file:projects/arm-deviceprovisioningservices.tgz + '@rush-temp/arm-deviceregistry': + specifier: file:./projects/arm-deviceregistry.tgz + version: file:projects/arm-deviceregistry.tgz '@rush-temp/arm-deviceupdate': specifier: file:./projects/arm-deviceupdate.tgz version: file:projects/arm-deviceupdate.tgz @@ -13551,6 +13554,36 @@ packages: - supports-color dev: false + file:projects/arm-deviceregistry.tgz: + resolution: {integrity: sha512-rt9bG8kZpBqqAJx2+WpHHznBcszYbbrbgwOh6QtXtYUzcIzNEHeS85cKBMweOdRUZ2I42SPvNcobolcwZ0xOTg==, tarball: file:projects/arm-deviceregistry.tgz} + name: '@rush-temp/arm-deviceregistry' + version: 0.0.0 + dependencies: + '@azure-tools/test-credential': 1.0.4 + '@azure-tools/test-recorder': 3.2.0 + '@azure/abort-controller': 1.1.0 + '@azure/identity': 4.1.0 + '@microsoft/api-extractor': 7.43.1(@types/node@18.19.31) + '@types/chai': 4.3.14 + '@types/mocha': 10.0.6 + '@types/node': 18.19.31 + chai: 4.3.10 + cross-env: 7.0.3 + dotenv: 16.4.5 + esm: 3.2.25 + mkdirp: 3.0.1 + mocha: 10.4.0 + rimraf: 5.0.5 + ts-node: 10.9.2(@types/node@18.19.31)(typescript@5.4.5) + tslib: 2.6.2 + typescript: 5.4.5 + uglify-js: 3.17.4 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - supports-color + dev: false + file:projects/arm-deviceupdate.tgz: resolution: {integrity: sha512-/GOmyZHmi8uzev8p6qzKMw29K7fOpgpNYojS9dQhBdZyCcFK4h43WWihz3bWiIrXGurJGeHNcOaPVBKjWC2jYQ==, tarball: file:projects/arm-deviceupdate.tgz} name: '@rush-temp/arm-deviceupdate' diff --git a/eng/ignore-links.txt b/eng/ignore-links.txt index 717151fef43..b863ad79e69 100644 --- a/eng/ignore-links.txt +++ b/eng/ignore-links.txt @@ -20,4 +20,8 @@ https://docs.microsoft.com/javascript/api/@azure-rest/purview-datamap?view=azure https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/purview/purview-datamap-rest/samples https://docs.microsoft.com/javascript/api/@azure/arm-migrationdiscoverysap?view=azure-node-preview https://docs.microsoft.com/javascript/api/@azure/arm-storageactions?view=azure-node-preview +<<<<<<< HEAD +https://docs.microsoft.com/javascript/api/@azure/arm-deviceregistry?view=azure-node-preview +======= https://docs.microsoft.com/javascript/api/@azure/arm-standbypool?view=azure-node-preview +>>>>>>> main diff --git a/rush.json b/rush.json index 3eee8043131..5f104b51319 100644 --- a/rush.json +++ b/rush.json @@ -1,7 +1,7 @@ /** * This is the main configuration file for Rush. * For full documentation, please see https://rushjs.io - */{ + */ { "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", /** * (Required) This specifies the version of the Rush engine to be used in this repo. @@ -2213,6 +2213,11 @@ "projectFolder": "sdk/storageactions/arm-storageactions", "versionPolicyName": "management" }, + { + "packageName": "@azure/arm-deviceregistry", + "projectFolder": "sdk/deviceregistry/arm-deviceregistry", + "versionPolicyName": "management" + }, { "packageName": "@azure/arm-standbypool", "projectFolder": "sdk/standbypool/arm-standbypool", diff --git a/sdk/deviceregistry/arm-deviceregistry/CHANGELOG.md b/sdk/deviceregistry/arm-deviceregistry/CHANGELOG.md new file mode 100644 index 00000000000..49eeb2e7dae --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2024-04-15) + +The package of @azure/arm-deviceregistry is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/js/mgmt/quickstart). diff --git a/sdk/deviceregistry/arm-deviceregistry/LICENSE b/sdk/deviceregistry/arm-deviceregistry/LICENSE new file mode 100644 index 00000000000..7d593474096 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2024 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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/deviceregistry/arm-deviceregistry/README.md b/sdk/deviceregistry/arm-deviceregistry/README.md new file mode 100644 index 00000000000..5fdede41e84 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/README.md @@ -0,0 +1,109 @@ +# Azure DeviceRegistryManagement client library for JavaScript + +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure DeviceRegistryManagement client. + +Microsoft.DeviceRegistry Resource Provider management API. + +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/deviceregistry/arm-deviceregistry) | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-deviceregistry) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-deviceregistry?view=azure-node-preview) | +[Samples](https://github.com/Azure-Samples/azure-samples-js-management) + +## Getting started + +### Currently supported environments + +- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) +- Latest versions of Safari, Chrome, Edge and Firefox. + +See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. + +### Prerequisites + +- An [Azure subscription][azure_sub]. + +### Install the `@azure/arm-deviceregistry` package + +Install the Azure DeviceRegistryManagement client library for JavaScript with `npm`: + +```bash +npm install @azure/arm-deviceregistry +``` + +### Create and authenticate a `DeviceRegistryManagementClient` + +To create a client object to access the Azure DeviceRegistryManagement API, you will need the `endpoint` of your Azure DeviceRegistryManagement resource and a `credential`. The Azure DeviceRegistryManagement client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure DeviceRegistryManagement resource in the [Azure Portal][azure_portal]. + +You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). + +To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: + +```bash +npm install @azure/identity +``` + +You will also need to **register a new AAD application and grant access to Azure DeviceRegistryManagement** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. + +For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). + +```javascript +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. + +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new DeviceRegistryManagementClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new DeviceRegistryManagementClient(credential, subscriptionId); +``` + + +### JavaScript Bundle +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). + +## Key concepts + +### DeviceRegistryManagementClient + +`DeviceRegistryManagementClient` is the primary interface for developers using the Azure DeviceRegistryManagement client library. Explore the methods on this client object to understand the different features of the Azure DeviceRegistryManagement service that you can access. + +## Troubleshooting + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: + +```javascript +const { setLogLevel } = require("@azure/logger"); +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). + +## Next steps + +Please take a look at the [samples](https://github.com/Azure-Samples/azure-samples-js-management) directory for detailed examples on how to use this library. + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. + +## Related projects + +- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fdeviceregistry%2Farm-deviceregistry%2FREADME.png) + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_sub]: https://azure.microsoft.com/free/ +[azure_sub]: https://azure.microsoft.com/free/ +[azure_portal]: https://portal.azure.com +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential diff --git a/sdk/deviceregistry/arm-deviceregistry/_meta.json b/sdk/deviceregistry/arm-deviceregistry/_meta.json new file mode 100644 index 00000000000..06e92ef5e81 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/_meta.json @@ -0,0 +1,8 @@ +{ + "commit": "59c04c61a355af4b56dd91a4b9b5eefe76e2f0cd", + "readme": "specification/deviceregistry/resource-manager/readme.md", + "autorest_command": "autorest --version=3.9.7 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\deviceregistry\\resource-manager\\readme.md --use=@autorest/typescript@6.0.20 --generate-sample=true", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "release_tool": "@azure-tools/js-sdk-release-tools@2.7.5", + "use": "@autorest/typescript@6.0.20" +} \ No newline at end of file diff --git a/sdk/deviceregistry/arm-deviceregistry/api-extractor.json b/sdk/deviceregistry/arm-deviceregistry/api-extractor.json new file mode 100644 index 00000000000..ed3e5d0b3be --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/api-extractor.json @@ -0,0 +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" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/arm-deviceregistry.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} \ No newline at end of file diff --git a/sdk/deviceregistry/arm-deviceregistry/package.json b/sdk/deviceregistry/arm-deviceregistry/package.json new file mode 100644 index 00000000000..0c778431bd3 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/package.json @@ -0,0 +1,118 @@ +{ + "name": "@azure/arm-deviceregistry", + "sdk-type": "mgmt", + "author": "Microsoft Corporation", + "description": "A generated SDK for DeviceRegistryManagementClient.", + "version": "1.0.0-beta.1", + "engines": { + "node": ">=18.0.0" + }, + "dependencies": { + "@azure/core-lro": "^2.5.4", + "@azure/abort-controller": "^1.0.0", + "@azure/core-paging": "^1.2.0", + "@azure/core-client": "^1.7.0", + "@azure/core-auth": "^1.6.0", + "@azure/core-rest-pipeline": "^1.14.0", + "tslib": "^2.2.0" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/arm-deviceregistry.d.ts", + "devDependencies": { + "@microsoft/api-extractor": "^7.31.1", + "mkdirp": "^3.0.1", + "typescript": "~5.4.5", + "uglify-js": "^3.4.9", + "rimraf": "^5.0.0", + "dotenv": "^16.0.0", + "@azure/dev-tool": "^1.0.0", + "@azure/identity": "^4.0.1", + "@azure-tools/test-recorder": "^3.0.0", + "@azure-tools/test-credential": "^1.0.0", + "mocha": "^10.0.0", + "@types/mocha": "^10.0.0", + "esm": "^3.2.18", + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^18.0.0", + "ts-node": "^10.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/Azure/azure-sdk-for-js.git" + }, + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map", + "dist-esm/**/*.js", + "dist-esm/**/*.js.map", + "dist-esm/**/*.d.ts", + "dist-esm/**/*.d.ts.map", + "src/**/*.ts", + "README.md", + "LICENSE", + "tsconfig.json", + "review/*", + "CHANGELOG.md", + "types/*" + ], + "scripts": { + "build": "npm run clean && tsc && dev-tool run bundle && npm run minify && mkdirp ./review && npm run extract-api", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "prepack": "npm run build", + "pack": "npm pack 2>&1", + "extract-api": "api-extractor run --local", + "lint": "echo skipped", + "clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "build:node": "echo skipped", + "build:browser": "echo skipped", + "build:test": "echo skipped", + "build:samples": "echo skipped.", + "check-format": "echo skipped", + "execute:samples": "echo skipped", + "format": "echo skipped", + "test": "npm run integration-test", + "test:node": "echo skipped", + "test:browser": "echo skipped", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", + "unit-test:browser": "echo skipped", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" + }, + "sideEffects": false, + "//metadata": { + "constantPaths": [ + { + "path": "src/deviceRegistryManagementClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/deviceregistry/arm-deviceregistry", + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-deviceregistry?view=azure-node-preview" + } +} diff --git a/sdk/deviceregistry/arm-deviceregistry/review/arm-deviceregistry.api.md b/sdk/deviceregistry/arm-deviceregistry/review/arm-deviceregistry.api.md new file mode 100644 index 00000000000..5d9d5b6b4e9 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/review/arm-deviceregistry.api.md @@ -0,0 +1,611 @@ +## API Report File for "@azure/arm-deviceregistry" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import * as coreAuth from '@azure/core-auth'; +import * as coreClient from '@azure/core-client'; +import { OperationState } from '@azure/core-lro'; +import { PagedAsyncIterableIterator } from '@azure/core-paging'; +import { SimplePollerLike } from '@azure/core-lro'; + +// @public +export type ActionType = string; + +// @public +export interface Asset extends TrackedResource { + extendedLocation: ExtendedLocation; + properties?: AssetProperties; +} + +// @public +export interface AssetEndpointProfile extends TrackedResource { + extendedLocation: ExtendedLocation; + properties?: AssetEndpointProfileProperties; +} + +// @public +export interface AssetEndpointProfileListResult { + nextLink?: string; + value: AssetEndpointProfile[]; +} + +// @public +export interface AssetEndpointProfileProperties { + additionalConfiguration?: string; + readonly provisioningState?: ProvisioningState; + targetAddress: string; + transportAuthentication?: TransportAuthentication; + userAuthentication?: UserAuthentication; + readonly uuid?: string; +} + +// @public +export interface AssetEndpointProfiles { + beginCreateOrReplace(resourceGroupName: string, assetEndpointProfileName: string, resource: AssetEndpointProfile, options?: AssetEndpointProfilesCreateOrReplaceOptionalParams): Promise, AssetEndpointProfilesCreateOrReplaceResponse>>; + beginCreateOrReplaceAndWait(resourceGroupName: string, assetEndpointProfileName: string, resource: AssetEndpointProfile, options?: AssetEndpointProfilesCreateOrReplaceOptionalParams): Promise; + beginDelete(resourceGroupName: string, assetEndpointProfileName: string, options?: AssetEndpointProfilesDeleteOptionalParams): Promise, AssetEndpointProfilesDeleteResponse>>; + beginDeleteAndWait(resourceGroupName: string, assetEndpointProfileName: string, options?: AssetEndpointProfilesDeleteOptionalParams): Promise; + beginUpdate(resourceGroupName: string, assetEndpointProfileName: string, properties: AssetEndpointProfileUpdate, options?: AssetEndpointProfilesUpdateOptionalParams): Promise, AssetEndpointProfilesUpdateResponse>>; + beginUpdateAndWait(resourceGroupName: string, assetEndpointProfileName: string, properties: AssetEndpointProfileUpdate, options?: AssetEndpointProfilesUpdateOptionalParams): Promise; + get(resourceGroupName: string, assetEndpointProfileName: string, options?: AssetEndpointProfilesGetOptionalParams): Promise; + listByResourceGroup(resourceGroupName: string, options?: AssetEndpointProfilesListByResourceGroupOptionalParams): PagedAsyncIterableIterator; + listBySubscription(options?: AssetEndpointProfilesListBySubscriptionOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface AssetEndpointProfilesCreateOrReplaceHeaders { + retryAfter?: number; +} + +// @public +export interface AssetEndpointProfilesCreateOrReplaceOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type AssetEndpointProfilesCreateOrReplaceResponse = AssetEndpointProfile; + +// @public +export interface AssetEndpointProfilesDeleteHeaders { + location?: string; + retryAfter?: number; +} + +// @public +export interface AssetEndpointProfilesDeleteOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type AssetEndpointProfilesDeleteResponse = AssetEndpointProfilesDeleteHeaders; + +// @public +export interface AssetEndpointProfilesGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AssetEndpointProfilesGetResponse = AssetEndpointProfile; + +// @public +export interface AssetEndpointProfilesListByResourceGroupNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AssetEndpointProfilesListByResourceGroupNextResponse = AssetEndpointProfileListResult; + +// @public +export interface AssetEndpointProfilesListByResourceGroupOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AssetEndpointProfilesListByResourceGroupResponse = AssetEndpointProfileListResult; + +// @public +export interface AssetEndpointProfilesListBySubscriptionNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AssetEndpointProfilesListBySubscriptionNextResponse = AssetEndpointProfileListResult; + +// @public +export interface AssetEndpointProfilesListBySubscriptionOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AssetEndpointProfilesListBySubscriptionResponse = AssetEndpointProfileListResult; + +// @public +export interface AssetEndpointProfilesUpdateHeaders { + location?: string; + retryAfter?: number; +} + +// @public +export interface AssetEndpointProfilesUpdateOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type AssetEndpointProfilesUpdateResponse = AssetEndpointProfile; + +// @public +export interface AssetEndpointProfileUpdate { + properties?: AssetEndpointProfileUpdateProperties; + tags?: { + [propertyName: string]: string; + }; +} + +// @public +export interface AssetEndpointProfileUpdateProperties { + additionalConfiguration?: string; + targetAddress?: string; + transportAuthentication?: TransportAuthenticationUpdate; + userAuthentication?: UserAuthenticationUpdate; +} + +// @public +export interface AssetListResult { + nextLink?: string; + value: Asset[]; +} + +// @public +export interface AssetProperties { + assetEndpointProfileUri: string; + assetType?: string; + attributes?: { + [propertyName: string]: any; + }; + dataPoints?: DataPoint[]; + defaultDataPointsConfiguration?: string; + defaultEventsConfiguration?: string; + description?: string; + displayName?: string; + documentationUri?: string; + enabled?: boolean; + events?: Event_2[]; + externalAssetId?: string; + hardwareRevision?: string; + manufacturer?: string; + manufacturerUri?: string; + model?: string; + productCode?: string; + readonly provisioningState?: ProvisioningState; + serialNumber?: string; + softwareRevision?: string; + readonly status?: AssetStatus; + readonly uuid?: string; + readonly version?: number; +} + +// @public +export interface Assets { + beginCreateOrReplace(resourceGroupName: string, assetName: string, resource: Asset, options?: AssetsCreateOrReplaceOptionalParams): Promise, AssetsCreateOrReplaceResponse>>; + beginCreateOrReplaceAndWait(resourceGroupName: string, assetName: string, resource: Asset, options?: AssetsCreateOrReplaceOptionalParams): Promise; + beginDelete(resourceGroupName: string, assetName: string, options?: AssetsDeleteOptionalParams): Promise, AssetsDeleteResponse>>; + beginDeleteAndWait(resourceGroupName: string, assetName: string, options?: AssetsDeleteOptionalParams): Promise; + beginUpdate(resourceGroupName: string, assetName: string, properties: AssetUpdate, options?: AssetsUpdateOptionalParams): Promise, AssetsUpdateResponse>>; + beginUpdateAndWait(resourceGroupName: string, assetName: string, properties: AssetUpdate, options?: AssetsUpdateOptionalParams): Promise; + get(resourceGroupName: string, assetName: string, options?: AssetsGetOptionalParams): Promise; + listByResourceGroup(resourceGroupName: string, options?: AssetsListByResourceGroupOptionalParams): PagedAsyncIterableIterator; + listBySubscription(options?: AssetsListBySubscriptionOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface AssetsCreateOrReplaceHeaders { + retryAfter?: number; +} + +// @public +export interface AssetsCreateOrReplaceOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type AssetsCreateOrReplaceResponse = Asset; + +// @public +export interface AssetsDeleteHeaders { + location?: string; + retryAfter?: number; +} + +// @public +export interface AssetsDeleteOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type AssetsDeleteResponse = AssetsDeleteHeaders; + +// @public +export interface AssetsGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AssetsGetResponse = Asset; + +// @public +export interface AssetsListByResourceGroupNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AssetsListByResourceGroupNextResponse = AssetListResult; + +// @public +export interface AssetsListByResourceGroupOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AssetsListByResourceGroupResponse = AssetListResult; + +// @public +export interface AssetsListBySubscriptionNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AssetsListBySubscriptionNextResponse = AssetListResult; + +// @public +export interface AssetsListBySubscriptionOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AssetsListBySubscriptionResponse = AssetListResult; + +// @public +export interface AssetStatus { + errors?: AssetStatusError[]; + version?: number; +} + +// @public +export interface AssetStatusError { + code?: number; + message?: string; +} + +// @public +export interface AssetsUpdateHeaders { + location?: string; + retryAfter?: number; +} + +// @public +export interface AssetsUpdateOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type AssetsUpdateResponse = Asset; + +// @public +export interface AssetUpdate { + properties?: AssetUpdateProperties; + tags?: { + [propertyName: string]: string; + }; +} + +// @public +export interface AssetUpdateProperties { + assetType?: string; + attributes?: { + [propertyName: string]: any; + }; + dataPoints?: DataPoint[]; + defaultDataPointsConfiguration?: string; + defaultEventsConfiguration?: string; + description?: string; + displayName?: string; + documentationUri?: string; + enabled?: boolean; + events?: Event_2[]; + hardwareRevision?: string; + manufacturer?: string; + manufacturerUri?: string; + model?: string; + productCode?: string; + serialNumber?: string; + softwareRevision?: string; +} + +// @public +export type CreatedByType = string; + +// @public +export interface DataPoint { + capabilityId?: string; + dataPointConfiguration?: string; + dataSource: string; + name?: string; + observabilityMode?: DataPointsObservabilityMode; +} + +// @public +export type DataPointsObservabilityMode = string; + +// @public (undocumented) +export class DeviceRegistryManagementClient extends coreClient.ServiceClient { + // (undocumented) + $host: string; + constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: DeviceRegistryManagementClientOptionalParams); + // (undocumented) + apiVersion: string; + // (undocumented) + assetEndpointProfiles: AssetEndpointProfiles; + // (undocumented) + assets: Assets; + // (undocumented) + operations: Operations; + // (undocumented) + operationStatus: OperationStatus; + // (undocumented) + subscriptionId: string; +} + +// @public +export interface DeviceRegistryManagementClientOptionalParams extends coreClient.ServiceClientOptions { + $host?: string; + apiVersion?: string; + endpoint?: string; +} + +// @public +export interface ErrorAdditionalInfo { + readonly info?: Record; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +interface Event_2 { + capabilityId?: string; + eventConfiguration?: string; + eventNotifier: string; + name?: string; + observabilityMode?: EventsObservabilityMode; +} +export { Event_2 as Event } + +// @public +export type EventsObservabilityMode = string; + +// @public +export interface ExtendedLocation { + name: string; + type: string; +} + +// @public +export function getContinuationToken(page: unknown): string | undefined; + +// @public +export enum KnownActionType { + Internal = "Internal" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownDataPointsObservabilityMode { + Counter = "counter", + Gauge = "gauge", + Histogram = "histogram", + Log = "log", + None = "none" +} + +// @public +export enum KnownEventsObservabilityMode { + Log = "log", + None = "none" +} + +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + +// @public +export enum KnownProvisioningState { + Accepted = "Accepted", + Canceled = "Canceled", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownUserAuthenticationMode { + Anonymous = "Anonymous", + Certificate = "Certificate", + UsernamePassword = "UsernamePassword" +} + +// @public +export interface Operation { + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; +} + +// @public +export interface OperationDisplay { + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; +} + +// @public +export interface OperationListResult { + readonly nextLink?: string; + readonly value?: Operation[]; +} + +// @public +export interface Operations { + list(options?: OperationsListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface OperationsListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListNextResponse = OperationListResult; + +// @public +export interface OperationsListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListResponse = OperationListResult; + +// @public +export interface OperationStatus { + get(location: string, operationId: string, options?: OperationStatusGetOptionalParams): Promise; +} + +// @public +export interface OperationStatusGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationStatusGetResponse = OperationStatusResult; + +// @public +export interface OperationStatusResult { + endTime?: Date; + error?: ErrorDetail; + id?: string; + name?: string; + operations?: OperationStatusResult[]; + percentComplete?: number; + startTime?: Date; + status: string; +} + +// @public +export type Origin = string; + +// @public +export interface OwnCertificate { + certPasswordReference?: string; + certSecretReference?: string; + certThumbprint?: string; +} + +// @public +export type ProvisioningState = string; + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export interface TrackedResource extends Resource { + location: string; + tags?: { + [propertyName: string]: string; + }; +} + +// @public +export interface TransportAuthentication { + ownCertificates: OwnCertificate[]; +} + +// @public +export interface TransportAuthenticationUpdate { + ownCertificates?: OwnCertificate[]; +} + +// @public +export interface UserAuthentication { + mode: UserAuthenticationMode; + usernamePasswordCredentials?: UsernamePasswordCredentials; + x509Credentials?: X509Credentials; +} + +// @public +export type UserAuthenticationMode = string; + +// @public +export interface UserAuthenticationUpdate { + mode?: UserAuthenticationMode; + usernamePasswordCredentials?: UsernamePasswordCredentialsUpdate; + x509Credentials?: X509CredentialsUpdate; +} + +// @public +export interface UsernamePasswordCredentials { + passwordReference: string; + usernameReference: string; +} + +// @public +export interface UsernamePasswordCredentialsUpdate { + passwordReference?: string; + usernameReference?: string; +} + +// @public +export interface X509Credentials { + certificateReference: string; +} + +// @public +export interface X509CredentialsUpdate { + certificateReference?: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/deviceregistry/arm-deviceregistry/sample.env b/sdk/deviceregistry/arm-deviceregistry/sample.env new file mode 100644 index 00000000000..672847a3fea --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/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/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesCreateOrReplaceSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesCreateOrReplaceSample.ts new file mode 100644 index 00000000000..1197ba9e9f4 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesCreateOrReplaceSample.ts @@ -0,0 +1,59 @@ +/* + * 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. +import { + AssetEndpointProfile, + DeviceRegistryManagementClient, +} from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create a AssetEndpointProfile + * + * @summary Create a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_AssetEndpointProfile.json + */ +async function createAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const resource: AssetEndpointProfile = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + targetAddress: "https://www.example.com/myTargetAddress", + userAuthentication: { mode: "Anonymous" }, + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.beginCreateOrReplaceAndWait( + resourceGroupName, + assetEndpointProfileName, + resource, + ); + console.log(result); +} + +async function main() { + createAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesDeleteSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesDeleteSample.ts new file mode 100644 index 00000000000..3f2ea9fa342 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesDeleteSample.ts @@ -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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a AssetEndpointProfile + * + * @summary Delete a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_AssetEndpointProfile.json + */ +async function deleteAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.beginDeleteAndWait( + resourceGroupName, + assetEndpointProfileName, + ); + console.log(result); +} + +async function main() { + deleteAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesGetSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesGetSample.ts new file mode 100644 index 00000000000..407685d90fa --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesGetSample.ts @@ -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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get a AssetEndpointProfile + * + * @summary Get a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_AssetEndpointProfile.json + */ +async function getAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.get( + resourceGroupName, + assetEndpointProfileName, + ); + console.log(result); +} + +async function main() { + getAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesListByResourceGroupSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesListByResourceGroupSample.ts new file mode 100644 index 00000000000..14413102b08 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesListByResourceGroupSample.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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List AssetEndpointProfile resources by resource group + * + * @summary List AssetEndpointProfile resources by resource group + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_ResourceGroup.json + */ +async function listAssetEndpointProfilesInAResourceGroup() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assetEndpointProfiles.listByResourceGroup( + resourceGroupName, + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetEndpointProfilesInAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesListBySubscriptionSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesListBySubscriptionSample.ts new file mode 100644 index 00000000000..83e5236f301 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesListBySubscriptionSample.ts @@ -0,0 +1,40 @@ +/* + * 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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List AssetEndpointProfile resources by subscription ID + * + * @summary List AssetEndpointProfile resources by subscription ID + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_Subscription.json + */ +async function listAssetEndpointProfilesInASubscription() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assetEndpointProfiles.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetEndpointProfilesInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesUpdateSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesUpdateSample.ts new file mode 100644 index 00000000000..409b09e06b3 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetEndpointProfilesUpdateSample.ts @@ -0,0 +1,50 @@ +/* + * 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. +import { + AssetEndpointProfileUpdate, + DeviceRegistryManagementClient, +} from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update a AssetEndpointProfile + * + * @summary Update a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_AssetEndpointProfile.json + */ +async function patchAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const properties: AssetEndpointProfileUpdate = { + properties: { targetAddress: "https://www.example.com/myTargetAddress" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.beginUpdateAndWait( + resourceGroupName, + assetEndpointProfileName, + properties, + ); + console.log(result); +} + +async function main() { + patchAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsCreateOrReplaceSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsCreateOrReplaceSample.ts new file mode 100644 index 00000000000..407f10ef31a --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsCreateOrReplaceSample.ts @@ -0,0 +1,273 @@ +/* + * 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. +import { + Asset, + DeviceRegistryManagementClient, +} from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create a Asset + * + * @summary Create a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_With_ExternalAssetId.json + */ +async function createAnAssetWithExternalAssetId() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const resource: Asset = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + description: "This is a sample Asset", + assetEndpointProfileUri: "https://www.example.com/myAssetEndpointProfile", + assetType: "MyAssetType", + dataPoints: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + dataPointConfiguration: + '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + observabilityMode: "counter", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + dataPointConfiguration: + '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + observabilityMode: "none", + }, + ], + defaultDataPointsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + defaultEventsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + displayName: "AssetDisplayName", + documentationUri: "https://www.example.com/manual", + enabled: true, + events: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", + observabilityMode: "none", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", + observabilityMode: "log", + }, + ], + externalAssetId: "8ZBA6LRHU0A458969", + hardwareRevision: "1.0", + manufacturer: "Contoso", + manufacturerUri: "https://www.contoso.com/manufacturerUri", + model: "ContosoModel", + productCode: "SA34VDG", + serialNumber: "64-103816-519918-8", + softwareRevision: "2.0", + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginCreateOrReplaceAndWait( + resourceGroupName, + assetName, + resource, + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create a Asset + * + * @summary Create a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_DisplayName.json + */ +async function createAnAssetWithoutDisplayName() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const resource: Asset = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + description: "This is a sample Asset", + assetEndpointProfileUri: "https://www.example.com/myAssetEndpointProfile", + assetType: "MyAssetType", + dataPoints: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + dataPointConfiguration: + '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + observabilityMode: "counter", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + dataPointConfiguration: + '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + observabilityMode: "none", + }, + ], + defaultDataPointsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + defaultEventsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + documentationUri: "https://www.example.com/manual", + enabled: true, + events: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", + observabilityMode: "none", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", + observabilityMode: "log", + }, + ], + externalAssetId: "8ZBA6LRHU0A458969", + hardwareRevision: "1.0", + manufacturer: "Contoso", + manufacturerUri: "https://www.contoso.com/manufacturerUri", + model: "ContosoModel", + productCode: "SA34VDG", + serialNumber: "64-103816-519918-8", + softwareRevision: "2.0", + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginCreateOrReplaceAndWait( + resourceGroupName, + assetName, + resource, + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create a Asset + * + * @summary Create a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_ExternalAssetId.json + */ +async function createAnAssetWithoutExternalAssetId() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const resource: Asset = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + description: "This is a sample Asset", + assetEndpointProfileUri: "https://www.example.com/myAssetEndpointProfile", + assetType: "MyAssetType", + dataPoints: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + dataPointConfiguration: + '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + observabilityMode: "counter", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + dataPointConfiguration: + '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + observabilityMode: "none", + }, + ], + defaultDataPointsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + defaultEventsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + displayName: "AssetDisplayName", + documentationUri: "https://www.example.com/manual", + enabled: true, + events: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", + observabilityMode: "none", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", + observabilityMode: "log", + }, + ], + hardwareRevision: "1.0", + manufacturer: "Contoso", + manufacturerUri: "https://www.contoso.com/manufacturerUri", + model: "ContosoModel", + productCode: "SA34VDG", + serialNumber: "64-103816-519918-8", + softwareRevision: "2.0", + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginCreateOrReplaceAndWait( + resourceGroupName, + assetName, + resource, + ); + console.log(result); +} + +async function main() { + createAnAssetWithExternalAssetId(); + createAnAssetWithoutDisplayName(); + createAnAssetWithoutExternalAssetId(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsDeleteSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsDeleteSample.ts new file mode 100644 index 00000000000..0d62e48d59b --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsDeleteSample.ts @@ -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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a Asset + * + * @summary Delete a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_Asset.json + */ +async function deleteAnAsset() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginDeleteAndWait( + resourceGroupName, + assetName, + ); + console.log(result); +} + +async function main() { + deleteAnAsset(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsGetSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsGetSample.ts new file mode 100644 index 00000000000..c341d40c039 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsGetSample.ts @@ -0,0 +1,60 @@ +/* + * 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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get a Asset + * + * @summary Get a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json + */ +async function getAnAsset() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.get(resourceGroupName, assetName); + console.log(result); +} + +/** + * This sample demonstrates how to Get a Asset + * + * @summary Get a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset_With_SyncStatus.json + */ +async function getAnAssetWithSyncStatus() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.get(resourceGroupName, assetName); + console.log(result); +} + +async function main() { + getAnAsset(); + getAnAssetWithSyncStatus(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsListByResourceGroupSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsListByResourceGroupSample.ts new file mode 100644 index 00000000000..8d358c701a1 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsListByResourceGroupSample.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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List Asset resources by resource group + * + * @summary List Asset resources by resource group + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_ResourceGroup.json + */ +async function listAssetsInAResourceGroup() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assets.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetsInAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsListBySubscriptionSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsListBySubscriptionSample.ts new file mode 100644 index 00000000000..078c4c0cbcf --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsListBySubscriptionSample.ts @@ -0,0 +1,40 @@ +/* + * 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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List Asset resources by subscription ID + * + * @summary List Asset resources by subscription ID + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_Subscription.json + */ +async function listAssetsInASubscription() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assets.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsUpdateSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsUpdateSample.ts new file mode 100644 index 00000000000..9a752eec406 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/assetsUpdateSample.ts @@ -0,0 +1,50 @@ +/* + * 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. +import { + AssetUpdate, + DeviceRegistryManagementClient, +} from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update a Asset + * + * @summary Update a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_Asset.json + */ +async function patchAnAsset() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const properties: AssetUpdate = { + properties: { displayName: "NewAssetDisplayName", enabled: false }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginUpdateAndWait( + resourceGroupName, + assetName, + properties, + ); + console.log(result); +} + +async function main() { + patchAnAsset(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/operationStatusGetSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/operationStatusGetSample.ts new file mode 100644 index 00000000000..c862e9c73e4 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/operationStatusGetSample.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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Returns the current status of an async operation. + * + * @summary Returns the current status of an async operation. + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_OperationStatus.json + */ +async function getTheStatusOfAnAsyncOperation() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const location = "testLocation"; + const operationId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.operationStatus.get(location, operationId); + console.log(result); +} + +async function main() { + getTheStatusOfAnAsyncOperation(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples-dev/operationsListSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples-dev/operationsListSample.ts new file mode 100644 index 00000000000..9c360acf465 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples-dev/operationsListSample.ts @@ -0,0 +1,40 @@ +/* + * 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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List the operations for the provider + * + * @summary List the operations for the provider + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Operations.json + */ +async function returnsListOfOperations() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + returnsListOfOperations(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/README.md b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/README.md new file mode 100644 index 00000000000..2a901b7ced3 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/README.md @@ -0,0 +1,76 @@ +# client library samples for JavaScript (Beta) + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [assetEndpointProfilesCreateOrReplaceSample.js][assetendpointprofilescreateorreplacesample] | Create a AssetEndpointProfile x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_AssetEndpointProfile.json | +| [assetEndpointProfilesDeleteSample.js][assetendpointprofilesdeletesample] | Delete a AssetEndpointProfile x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_AssetEndpointProfile.json | +| [assetEndpointProfilesGetSample.js][assetendpointprofilesgetsample] | Get a AssetEndpointProfile x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_AssetEndpointProfile.json | +| [assetEndpointProfilesListByResourceGroupSample.js][assetendpointprofileslistbyresourcegroupsample] | List AssetEndpointProfile resources by resource group x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_ResourceGroup.json | +| [assetEndpointProfilesListBySubscriptionSample.js][assetendpointprofileslistbysubscriptionsample] | List AssetEndpointProfile resources by subscription ID x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_Subscription.json | +| [assetEndpointProfilesUpdateSample.js][assetendpointprofilesupdatesample] | Update a AssetEndpointProfile x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_AssetEndpointProfile.json | +| [assetsCreateOrReplaceSample.js][assetscreateorreplacesample] | Create a Asset x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_With_ExternalAssetId.json | +| [assetsDeleteSample.js][assetsdeletesample] | Delete a Asset x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_Asset.json | +| [assetsGetSample.js][assetsgetsample] | Get a Asset x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json | +| [assetsListByResourceGroupSample.js][assetslistbyresourcegroupsample] | List Asset resources by resource group x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_ResourceGroup.json | +| [assetsListBySubscriptionSample.js][assetslistbysubscriptionsample] | List Asset resources by subscription ID x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_Subscription.json | +| [assetsUpdateSample.js][assetsupdatesample] | Update a Asset x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_Asset.json | +| [operationStatusGetSample.js][operationstatusgetsample] | Returns the current status of an async operation. x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_OperationStatus.json | +| [operationsListSample.js][operationslistsample] | List the operations for the provider x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Operations.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +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 assetEndpointProfilesCreateOrReplaceSample.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 DEVICEREGISTRY_SUBSCRIPTION_ID="" DEVICEREGISTRY_RESOURCE_GROUP="" node assetEndpointProfilesCreateOrReplaceSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[assetendpointprofilescreateorreplacesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesCreateOrReplaceSample.js +[assetendpointprofilesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesDeleteSample.js +[assetendpointprofilesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesGetSample.js +[assetendpointprofileslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesListByResourceGroupSample.js +[assetendpointprofileslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesListBySubscriptionSample.js +[assetendpointprofilesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesUpdateSample.js +[assetscreateorreplacesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsCreateOrReplaceSample.js +[assetsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsDeleteSample.js +[assetsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsGetSample.js +[assetslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsListByResourceGroupSample.js +[assetslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsListBySubscriptionSample.js +[assetsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsUpdateSample.js +[operationstatusgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/operationStatusGetSample.js +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/operationsListSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-deviceregistry?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/deviceregistry/arm-deviceregistry/README.md diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesCreateOrReplaceSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesCreateOrReplaceSample.js new file mode 100644 index 00000000000..86f9d3073f9 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesCreateOrReplaceSample.js @@ -0,0 +1,52 @@ +/* + * 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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Create a AssetEndpointProfile + * + * @summary Create a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_AssetEndpointProfile.json + */ +async function createAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const resource = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + targetAddress: "https://www.example.com/myTargetAddress", + userAuthentication: { mode: "Anonymous" }, + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.beginCreateOrReplaceAndWait( + resourceGroupName, + assetEndpointProfileName, + resource, + ); + console.log(result); +} + +async function main() { + createAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesDeleteSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesDeleteSample.js new file mode 100644 index 00000000000..e300baa8d74 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesDeleteSample.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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Delete a AssetEndpointProfile + * + * @summary Delete a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_AssetEndpointProfile.json + */ +async function deleteAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.beginDeleteAndWait( + resourceGroupName, + assetEndpointProfileName, + ); + console.log(result); +} + +async function main() { + deleteAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesGetSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesGetSample.js new file mode 100644 index 00000000000..27f1b063d10 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesGetSample.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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get a AssetEndpointProfile + * + * @summary Get a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_AssetEndpointProfile.json + */ +async function getAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.get( + resourceGroupName, + assetEndpointProfileName, + ); + console.log(result); +} + +async function main() { + getAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesListByResourceGroupSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesListByResourceGroupSample.js new file mode 100644 index 00000000000..931157af723 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesListByResourceGroupSample.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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List AssetEndpointProfile resources by resource group + * + * @summary List AssetEndpointProfile resources by resource group + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_ResourceGroup.json + */ +async function listAssetEndpointProfilesInAResourceGroup() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assetEndpointProfiles.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetEndpointProfilesInAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesListBySubscriptionSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesListBySubscriptionSample.js new file mode 100644 index 00000000000..c70e6c0fbf2 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesListBySubscriptionSample.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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List AssetEndpointProfile resources by subscription ID + * + * @summary List AssetEndpointProfile resources by subscription ID + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_Subscription.json + */ +async function listAssetEndpointProfilesInASubscription() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assetEndpointProfiles.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetEndpointProfilesInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesUpdateSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesUpdateSample.js new file mode 100644 index 00000000000..a9ac5952762 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetEndpointProfilesUpdateSample.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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Update a AssetEndpointProfile + * + * @summary Update a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_AssetEndpointProfile.json + */ +async function patchAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const properties = { + properties: { targetAddress: "https://www.example.com/myTargetAddress" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.beginUpdateAndWait( + resourceGroupName, + assetEndpointProfileName, + properties, + ); + console.log(result); +} + +async function main() { + patchAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsCreateOrReplaceSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsCreateOrReplaceSample.js new file mode 100644 index 00000000000..2ce823e81f0 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsCreateOrReplaceSample.js @@ -0,0 +1,247 @@ +/* + * 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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Create a Asset + * + * @summary Create a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_With_ExternalAssetId.json + */ +async function createAnAssetWithExternalAssetId() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const resource = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + description: "This is a sample Asset", + assetEndpointProfileUri: "https://www.example.com/myAssetEndpointProfile", + assetType: "MyAssetType", + dataPoints: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + dataPointConfiguration: '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + observabilityMode: "counter", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + dataPointConfiguration: '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + observabilityMode: "none", + }, + ], + defaultDataPointsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + defaultEventsConfiguration: '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + displayName: "AssetDisplayName", + documentationUri: "https://www.example.com/manual", + enabled: true, + events: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + eventConfiguration: '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", + observabilityMode: "none", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + eventConfiguration: '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", + observabilityMode: "log", + }, + ], + externalAssetId: "8ZBA6LRHU0A458969", + hardwareRevision: "1.0", + manufacturer: "Contoso", + manufacturerUri: "https://www.contoso.com/manufacturerUri", + model: "ContosoModel", + productCode: "SA34VDG", + serialNumber: "64-103816-519918-8", + softwareRevision: "2.0", + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginCreateOrReplaceAndWait( + resourceGroupName, + assetName, + resource, + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create a Asset + * + * @summary Create a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_DisplayName.json + */ +async function createAnAssetWithoutDisplayName() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const resource = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + description: "This is a sample Asset", + assetEndpointProfileUri: "https://www.example.com/myAssetEndpointProfile", + assetType: "MyAssetType", + dataPoints: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + dataPointConfiguration: '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + observabilityMode: "counter", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + dataPointConfiguration: '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + observabilityMode: "none", + }, + ], + defaultDataPointsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + defaultEventsConfiguration: '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + documentationUri: "https://www.example.com/manual", + enabled: true, + events: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + eventConfiguration: '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", + observabilityMode: "none", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + eventConfiguration: '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", + observabilityMode: "log", + }, + ], + externalAssetId: "8ZBA6LRHU0A458969", + hardwareRevision: "1.0", + manufacturer: "Contoso", + manufacturerUri: "https://www.contoso.com/manufacturerUri", + model: "ContosoModel", + productCode: "SA34VDG", + serialNumber: "64-103816-519918-8", + softwareRevision: "2.0", + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginCreateOrReplaceAndWait( + resourceGroupName, + assetName, + resource, + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create a Asset + * + * @summary Create a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_ExternalAssetId.json + */ +async function createAnAssetWithoutExternalAssetId() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const resource = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + description: "This is a sample Asset", + assetEndpointProfileUri: "https://www.example.com/myAssetEndpointProfile", + assetType: "MyAssetType", + dataPoints: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + dataPointConfiguration: '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + observabilityMode: "counter", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + dataPointConfiguration: '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + observabilityMode: "none", + }, + ], + defaultDataPointsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + defaultEventsConfiguration: '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + displayName: "AssetDisplayName", + documentationUri: "https://www.example.com/manual", + enabled: true, + events: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + eventConfiguration: '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", + observabilityMode: "none", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + eventConfiguration: '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", + observabilityMode: "log", + }, + ], + hardwareRevision: "1.0", + manufacturer: "Contoso", + manufacturerUri: "https://www.contoso.com/manufacturerUri", + model: "ContosoModel", + productCode: "SA34VDG", + serialNumber: "64-103816-519918-8", + softwareRevision: "2.0", + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginCreateOrReplaceAndWait( + resourceGroupName, + assetName, + resource, + ); + console.log(result); +} + +async function main() { + createAnAssetWithExternalAssetId(); + createAnAssetWithoutDisplayName(); + createAnAssetWithoutExternalAssetId(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsDeleteSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsDeleteSample.js new file mode 100644 index 00000000000..6772d00e3c0 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsDeleteSample.js @@ -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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Delete a Asset + * + * @summary Delete a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_Asset.json + */ +async function deleteAnAsset() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginDeleteAndWait(resourceGroupName, assetName); + console.log(result); +} + +async function main() { + deleteAnAsset(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsGetSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsGetSample.js new file mode 100644 index 00000000000..f9b7c6691ab --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsGetSample.js @@ -0,0 +1,54 @@ +/* + * 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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get a Asset + * + * @summary Get a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json + */ +async function getAnAsset() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.get(resourceGroupName, assetName); + console.log(result); +} + +/** + * This sample demonstrates how to Get a Asset + * + * @summary Get a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset_With_SyncStatus.json + */ +async function getAnAssetWithSyncStatus() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.get(resourceGroupName, assetName); + console.log(result); +} + +async function main() { + getAnAsset(); + getAnAssetWithSyncStatus(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsListByResourceGroupSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsListByResourceGroupSample.js new file mode 100644 index 00000000000..465c9e43679 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsListByResourceGroupSample.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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List Asset resources by resource group + * + * @summary List Asset resources by resource group + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_ResourceGroup.json + */ +async function listAssetsInAResourceGroup() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assets.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetsInAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsListBySubscriptionSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsListBySubscriptionSample.js new file mode 100644 index 00000000000..367fcc37795 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsListBySubscriptionSample.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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List Asset resources by subscription ID + * + * @summary List Asset resources by subscription ID + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_Subscription.json + */ +async function listAssetsInASubscription() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assets.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsUpdateSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsUpdateSample.js new file mode 100644 index 00000000000..fa3bfae6586 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/assetsUpdateSample.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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Update a Asset + * + * @summary Update a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_Asset.json + */ +async function patchAnAsset() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const properties = { + properties: { displayName: "NewAssetDisplayName", enabled: false }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginUpdateAndWait(resourceGroupName, assetName, properties); + console.log(result); +} + +async function main() { + patchAnAsset(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/operationStatusGetSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/operationStatusGetSample.js new file mode 100644 index 00000000000..cf650442903 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/operationStatusGetSample.js @@ -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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Returns the current status of an async operation. + * + * @summary Returns the current status of an async operation. + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_OperationStatus.json + */ +async function getTheStatusOfAnAsyncOperation() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const location = "testLocation"; + const operationId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.operationStatus.get(location, operationId); + console.log(result); +} + +async function main() { + getTheStatusOfAnAsyncOperation(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/operationsListSample.js b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/operationsListSample.js new file mode 100644 index 00000000000..1f8dd777d26 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/operationsListSample.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. +const { DeviceRegistryManagementClient } = require("@azure/arm-deviceregistry"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List the operations for the provider + * + * @summary List the operations for the provider + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Operations.json + */ +async function returnsListOfOperations() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + returnsListOfOperations(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/package.json b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/package.json new file mode 100644 index 00000000000..adab65dbbcf --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-deviceregistry-js-beta", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript (Beta)", + "engines": { + "node": ">=18.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/deviceregistry/arm-deviceregistry" + }, + "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/deviceregistry/arm-deviceregistry", + "dependencies": { + "@azure/arm-deviceregistry": "next", + "dotenv": "latest", + "@azure/identity": "^4.0.1" + } +} diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/sample.env b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/javascript/sample.env new file mode 100644 index 00000000000..672847a3fea --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/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/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/README.md b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/README.md new file mode 100644 index 00000000000..3fa7e013a0f --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/README.md @@ -0,0 +1,89 @@ +# client library samples for TypeScript (Beta) + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [assetEndpointProfilesCreateOrReplaceSample.ts][assetendpointprofilescreateorreplacesample] | Create a AssetEndpointProfile x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_AssetEndpointProfile.json | +| [assetEndpointProfilesDeleteSample.ts][assetendpointprofilesdeletesample] | Delete a AssetEndpointProfile x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_AssetEndpointProfile.json | +| [assetEndpointProfilesGetSample.ts][assetendpointprofilesgetsample] | Get a AssetEndpointProfile x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_AssetEndpointProfile.json | +| [assetEndpointProfilesListByResourceGroupSample.ts][assetendpointprofileslistbyresourcegroupsample] | List AssetEndpointProfile resources by resource group x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_ResourceGroup.json | +| [assetEndpointProfilesListBySubscriptionSample.ts][assetendpointprofileslistbysubscriptionsample] | List AssetEndpointProfile resources by subscription ID x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_Subscription.json | +| [assetEndpointProfilesUpdateSample.ts][assetendpointprofilesupdatesample] | Update a AssetEndpointProfile x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_AssetEndpointProfile.json | +| [assetsCreateOrReplaceSample.ts][assetscreateorreplacesample] | Create a Asset x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_With_ExternalAssetId.json | +| [assetsDeleteSample.ts][assetsdeletesample] | Delete a Asset x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_Asset.json | +| [assetsGetSample.ts][assetsgetsample] | Get a Asset x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json | +| [assetsListByResourceGroupSample.ts][assetslistbyresourcegroupsample] | List Asset resources by resource group x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_ResourceGroup.json | +| [assetsListBySubscriptionSample.ts][assetslistbysubscriptionsample] | List Asset resources by subscription ID x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_Subscription.json | +| [assetsUpdateSample.ts][assetsupdatesample] | Update a Asset x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_Asset.json | +| [operationStatusGetSample.ts][operationstatusgetsample] | Returns the current status of an async operation. x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_OperationStatus.json | +| [operationsListSample.ts][operationslistsample] | List the operations for the provider x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Operations.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +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/assetEndpointProfilesCreateOrReplaceSample.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 DEVICEREGISTRY_SUBSCRIPTION_ID="" DEVICEREGISTRY_RESOURCE_GROUP="" node dist/assetEndpointProfilesCreateOrReplaceSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[assetendpointprofilescreateorreplacesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesCreateOrReplaceSample.ts +[assetendpointprofilesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesDeleteSample.ts +[assetendpointprofilesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesGetSample.ts +[assetendpointprofileslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesListByResourceGroupSample.ts +[assetendpointprofileslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesListBySubscriptionSample.ts +[assetendpointprofilesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesUpdateSample.ts +[assetscreateorreplacesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsCreateOrReplaceSample.ts +[assetsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsDeleteSample.ts +[assetsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsGetSample.ts +[assetslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsListByResourceGroupSample.ts +[assetslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsListBySubscriptionSample.ts +[assetsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsUpdateSample.ts +[operationstatusgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/operationStatusGetSample.ts +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/operationsListSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-deviceregistry?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/deviceregistry/arm-deviceregistry/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/package.json b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/package.json new file mode 100644 index 00000000000..d12a2ae7d85 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-deviceregistry-ts-beta", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript (Beta)", + "engines": { + "node": ">=18.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/deviceregistry/arm-deviceregistry" + }, + "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/deviceregistry/arm-deviceregistry", + "dependencies": { + "@azure/arm-deviceregistry": "next", + "dotenv": "latest", + "@azure/identity": "^4.0.1" + }, + "devDependencies": { + "@types/node": "^18.0.0", + "typescript": "~5.4.5", + "rimraf": "latest" + } +} diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/sample.env b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/sample.env new file mode 100644 index 00000000000..672847a3fea --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/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/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesCreateOrReplaceSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesCreateOrReplaceSample.ts new file mode 100644 index 00000000000..1197ba9e9f4 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesCreateOrReplaceSample.ts @@ -0,0 +1,59 @@ +/* + * 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. +import { + AssetEndpointProfile, + DeviceRegistryManagementClient, +} from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create a AssetEndpointProfile + * + * @summary Create a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_AssetEndpointProfile.json + */ +async function createAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const resource: AssetEndpointProfile = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + targetAddress: "https://www.example.com/myTargetAddress", + userAuthentication: { mode: "Anonymous" }, + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.beginCreateOrReplaceAndWait( + resourceGroupName, + assetEndpointProfileName, + resource, + ); + console.log(result); +} + +async function main() { + createAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesDeleteSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesDeleteSample.ts new file mode 100644 index 00000000000..3f2ea9fa342 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesDeleteSample.ts @@ -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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a AssetEndpointProfile + * + * @summary Delete a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_AssetEndpointProfile.json + */ +async function deleteAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.beginDeleteAndWait( + resourceGroupName, + assetEndpointProfileName, + ); + console.log(result); +} + +async function main() { + deleteAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesGetSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesGetSample.ts new file mode 100644 index 00000000000..407685d90fa --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesGetSample.ts @@ -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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get a AssetEndpointProfile + * + * @summary Get a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_AssetEndpointProfile.json + */ +async function getAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.get( + resourceGroupName, + assetEndpointProfileName, + ); + console.log(result); +} + +async function main() { + getAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesListByResourceGroupSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesListByResourceGroupSample.ts new file mode 100644 index 00000000000..14413102b08 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesListByResourceGroupSample.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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List AssetEndpointProfile resources by resource group + * + * @summary List AssetEndpointProfile resources by resource group + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_ResourceGroup.json + */ +async function listAssetEndpointProfilesInAResourceGroup() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assetEndpointProfiles.listByResourceGroup( + resourceGroupName, + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetEndpointProfilesInAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesListBySubscriptionSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesListBySubscriptionSample.ts new file mode 100644 index 00000000000..83e5236f301 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesListBySubscriptionSample.ts @@ -0,0 +1,40 @@ +/* + * 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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List AssetEndpointProfile resources by subscription ID + * + * @summary List AssetEndpointProfile resources by subscription ID + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_Subscription.json + */ +async function listAssetEndpointProfilesInASubscription() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assetEndpointProfiles.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetEndpointProfilesInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesUpdateSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesUpdateSample.ts new file mode 100644 index 00000000000..409b09e06b3 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetEndpointProfilesUpdateSample.ts @@ -0,0 +1,50 @@ +/* + * 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. +import { + AssetEndpointProfileUpdate, + DeviceRegistryManagementClient, +} from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update a AssetEndpointProfile + * + * @summary Update a AssetEndpointProfile + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_AssetEndpointProfile.json + */ +async function patchAnAssetEndpointProfile() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetEndpointProfileName = "my-assetendpointprofile"; + const properties: AssetEndpointProfileUpdate = { + properties: { targetAddress: "https://www.example.com/myTargetAddress" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assetEndpointProfiles.beginUpdateAndWait( + resourceGroupName, + assetEndpointProfileName, + properties, + ); + console.log(result); +} + +async function main() { + patchAnAssetEndpointProfile(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsCreateOrReplaceSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsCreateOrReplaceSample.ts new file mode 100644 index 00000000000..407f10ef31a --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsCreateOrReplaceSample.ts @@ -0,0 +1,273 @@ +/* + * 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. +import { + Asset, + DeviceRegistryManagementClient, +} from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create a Asset + * + * @summary Create a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_With_ExternalAssetId.json + */ +async function createAnAssetWithExternalAssetId() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const resource: Asset = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + description: "This is a sample Asset", + assetEndpointProfileUri: "https://www.example.com/myAssetEndpointProfile", + assetType: "MyAssetType", + dataPoints: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + dataPointConfiguration: + '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + observabilityMode: "counter", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + dataPointConfiguration: + '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + observabilityMode: "none", + }, + ], + defaultDataPointsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + defaultEventsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + displayName: "AssetDisplayName", + documentationUri: "https://www.example.com/manual", + enabled: true, + events: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", + observabilityMode: "none", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", + observabilityMode: "log", + }, + ], + externalAssetId: "8ZBA6LRHU0A458969", + hardwareRevision: "1.0", + manufacturer: "Contoso", + manufacturerUri: "https://www.contoso.com/manufacturerUri", + model: "ContosoModel", + productCode: "SA34VDG", + serialNumber: "64-103816-519918-8", + softwareRevision: "2.0", + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginCreateOrReplaceAndWait( + resourceGroupName, + assetName, + resource, + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create a Asset + * + * @summary Create a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_DisplayName.json + */ +async function createAnAssetWithoutDisplayName() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const resource: Asset = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + description: "This is a sample Asset", + assetEndpointProfileUri: "https://www.example.com/myAssetEndpointProfile", + assetType: "MyAssetType", + dataPoints: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + dataPointConfiguration: + '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + observabilityMode: "counter", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + dataPointConfiguration: + '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + observabilityMode: "none", + }, + ], + defaultDataPointsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + defaultEventsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + documentationUri: "https://www.example.com/manual", + enabled: true, + events: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", + observabilityMode: "none", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", + observabilityMode: "log", + }, + ], + externalAssetId: "8ZBA6LRHU0A458969", + hardwareRevision: "1.0", + manufacturer: "Contoso", + manufacturerUri: "https://www.contoso.com/manufacturerUri", + model: "ContosoModel", + productCode: "SA34VDG", + serialNumber: "64-103816-519918-8", + softwareRevision: "2.0", + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginCreateOrReplaceAndWait( + resourceGroupName, + assetName, + resource, + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create a Asset + * + * @summary Create a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_ExternalAssetId.json + */ +async function createAnAssetWithoutExternalAssetId() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const resource: Asset = { + extendedLocation: { + name: "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1", + type: "CustomLocation", + }, + location: "West Europe", + properties: { + description: "This is a sample Asset", + assetEndpointProfileUri: "https://www.example.com/myAssetEndpointProfile", + assetType: "MyAssetType", + dataPoints: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + dataPointConfiguration: + '{"publishingInterval":8,"samplingInterval":8,"queueSize":4}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1", + observabilityMode: "counter", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + dataPointConfiguration: + '{"publishingInterval":4,"samplingInterval":4,"queueSize":7}', + dataSource: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2", + observabilityMode: "none", + }, + ], + defaultDataPointsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + defaultEventsConfiguration: + '{"publishingInterval":10,"samplingInterval":15,"queueSize":20}', + displayName: "AssetDisplayName", + documentationUri: "https://www.example.com/manual", + enabled: true, + events: [ + { + capabilityId: "dtmi:com:example:Thermostat:__temperature;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":1,"queueSize":8}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3", + observabilityMode: "none", + }, + { + capabilityId: "dtmi:com:example:Thermostat:__pressure;1", + eventConfiguration: + '{"publishingInterval":7,"samplingInterval":8,"queueSize":4}', + eventNotifier: "nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4", + observabilityMode: "log", + }, + ], + hardwareRevision: "1.0", + manufacturer: "Contoso", + manufacturerUri: "https://www.contoso.com/manufacturerUri", + model: "ContosoModel", + productCode: "SA34VDG", + serialNumber: "64-103816-519918-8", + softwareRevision: "2.0", + }, + tags: { site: "building-1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginCreateOrReplaceAndWait( + resourceGroupName, + assetName, + resource, + ); + console.log(result); +} + +async function main() { + createAnAssetWithExternalAssetId(); + createAnAssetWithoutDisplayName(); + createAnAssetWithoutExternalAssetId(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsDeleteSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsDeleteSample.ts new file mode 100644 index 00000000000..0d62e48d59b --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsDeleteSample.ts @@ -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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a Asset + * + * @summary Delete a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_Asset.json + */ +async function deleteAnAsset() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginDeleteAndWait( + resourceGroupName, + assetName, + ); + console.log(result); +} + +async function main() { + deleteAnAsset(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsGetSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsGetSample.ts new file mode 100644 index 00000000000..c341d40c039 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsGetSample.ts @@ -0,0 +1,60 @@ +/* + * 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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get a Asset + * + * @summary Get a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json + */ +async function getAnAsset() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.get(resourceGroupName, assetName); + console.log(result); +} + +/** + * This sample demonstrates how to Get a Asset + * + * @summary Get a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset_With_SyncStatus.json + */ +async function getAnAssetWithSyncStatus() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.get(resourceGroupName, assetName); + console.log(result); +} + +async function main() { + getAnAsset(); + getAnAssetWithSyncStatus(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsListByResourceGroupSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsListByResourceGroupSample.ts new file mode 100644 index 00000000000..8d358c701a1 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsListByResourceGroupSample.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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List Asset resources by resource group + * + * @summary List Asset resources by resource group + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_ResourceGroup.json + */ +async function listAssetsInAResourceGroup() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assets.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetsInAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsListBySubscriptionSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsListBySubscriptionSample.ts new file mode 100644 index 00000000000..078c4c0cbcf --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsListBySubscriptionSample.ts @@ -0,0 +1,40 @@ +/* + * 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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List Asset resources by subscription ID + * + * @summary List Asset resources by subscription ID + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_Subscription.json + */ +async function listAssetsInASubscription() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.assets.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAssetsInASubscription(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsUpdateSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsUpdateSample.ts new file mode 100644 index 00000000000..9a752eec406 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/assetsUpdateSample.ts @@ -0,0 +1,50 @@ +/* + * 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. +import { + AssetUpdate, + DeviceRegistryManagementClient, +} from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update a Asset + * + * @summary Update a Asset + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_Asset.json + */ +async function patchAnAsset() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = + process.env["DEVICEREGISTRY_RESOURCE_GROUP"] || "myResourceGroup"; + const assetName = "my-asset"; + const properties: AssetUpdate = { + properties: { displayName: "NewAssetDisplayName", enabled: false }, + }; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.assets.beginUpdateAndWait( + resourceGroupName, + assetName, + properties, + ); + console.log(result); +} + +async function main() { + patchAnAsset(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/operationStatusGetSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/operationStatusGetSample.ts new file mode 100644 index 00000000000..c862e9c73e4 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/operationStatusGetSample.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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Returns the current status of an async operation. + * + * @summary Returns the current status of an async operation. + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_OperationStatus.json + */ +async function getTheStatusOfAnAsyncOperation() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const location = "testLocation"; + const operationId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const result = await client.operationStatus.get(location, operationId); + console.log(result); +} + +async function main() { + getTheStatusOfAnAsyncOperation(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/operationsListSample.ts b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/operationsListSample.ts new file mode 100644 index 00000000000..9c360acf465 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/src/operationsListSample.ts @@ -0,0 +1,40 @@ +/* + * 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. +import { DeviceRegistryManagementClient } from "@azure/arm-deviceregistry"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List the operations for the provider + * + * @summary List the operations for the provider + * x-ms-original-file: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Operations.json + */ +async function returnsListOfOperations() { + const subscriptionId = + process.env["DEVICEREGISTRY_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DeviceRegistryManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + returnsListOfOperations(); +} + +main().catch(console.error); diff --git a/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/tsconfig.json b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/tsconfig.json new file mode 100644 index 00000000000..e26ce2a6d8f --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/samples/v1-beta/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "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/deviceregistry/arm-deviceregistry/src/deviceRegistryManagementClient.ts b/sdk/deviceregistry/arm-deviceregistry/src/deviceRegistryManagementClient.ts new file mode 100644 index 00000000000..45872c2b459 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/deviceRegistryManagementClient.ts @@ -0,0 +1,157 @@ +/* + * 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 * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest, +} from "@azure/core-rest-pipeline"; +import * as coreAuth from "@azure/core-auth"; +import { + OperationsImpl, + AssetEndpointProfilesImpl, + AssetsImpl, + OperationStatusImpl, +} from "./operations"; +import { + Operations, + AssetEndpointProfiles, + Assets, + OperationStatus, +} from "./operationsInterfaces"; +import { DeviceRegistryManagementClientOptionalParams } from "./models"; + +export class DeviceRegistryManagementClient extends coreClient.ServiceClient { + $host: string; + apiVersion: string; + subscriptionId: string; + + /** + * Initializes a new instance of the DeviceRegistryManagementClient class. + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param subscriptionId The ID of the target subscription. + * @param options The parameter options + */ + constructor( + credentials: coreAuth.TokenCredential, + subscriptionId: string, + options?: DeviceRegistryManagementClientOptionalParams, + ) { + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + if (subscriptionId === undefined) { + throw new Error("'subscriptionId' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: DeviceRegistryManagementClientOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials, + }; + + const packageDetails = `azsdk-js-arm-deviceregistry/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; + + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix, + }, + endpoint: + options.endpoint ?? options.baseUri ?? "https://management.azure.com", + }; + super(optionsWithDefaults); + + let bearerTokenAuthenticationPolicyFound: boolean = false; + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = + options.pipeline.getOrderedPolicies(); + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName, + ); + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName, + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge, + }, + }), + ); + } + // Parameter assignments + this.subscriptionId = subscriptionId; + + // Assigning values to Constant parameters + this.$host = options.$host || "https://management.azure.com"; + this.apiVersion = options.apiVersion || "2023-11-01-preview"; + this.operations = new OperationsImpl(this); + this.assetEndpointProfiles = new AssetEndpointProfilesImpl(this); + this.assets = new AssetsImpl(this); + this.operationStatus = new OperationStatusImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest, + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + }, + }; + this.pipeline.addPolicy(apiVersionPolicy); + } + + operations: Operations; + assetEndpointProfiles: AssetEndpointProfiles; + assets: Assets; + operationStatus: OperationStatus; +} diff --git a/sdk/deviceregistry/arm-deviceregistry/src/index.ts b/sdk/deviceregistry/arm-deviceregistry/src/index.ts new file mode 100644 index 00000000000..282aa26cdb4 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/index.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +/// +export { getContinuationToken } from "./pagingHelper"; +export * from "./models"; +export { DeviceRegistryManagementClient } from "./deviceRegistryManagementClient"; +export * from "./operationsInterfaces"; diff --git a/sdk/deviceregistry/arm-deviceregistry/src/lroImpl.ts b/sdk/deviceregistry/arm-deviceregistry/src/lroImpl.ts new file mode 100644 index 00000000000..b27f5ac7209 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/lroImpl.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. + +import { AbortSignalLike } from "@azure/abort-controller"; +import { LongRunningOperation, LroResponse } from "@azure/core-lro"; + +export function createLroSpec(inputs: { + sendOperationFn: (args: any, spec: any) => Promise>; + args: Record; + spec: { + readonly requestBody?: unknown; + readonly path?: string; + readonly httpMethod: string; + } & Record; +}): LongRunningOperation { + const { args, spec, sendOperationFn } = inputs; + return { + requestMethod: spec.httpMethod, + requestPath: spec.path!, + sendInitialRequest: () => sendOperationFn(args, spec), + sendPollRequest: ( + path: string, + options?: { abortSignal?: AbortSignalLike }, + ) => { + const { requestBody, ...restSpec } = spec; + return sendOperationFn(args, { + ...restSpec, + httpMethod: "GET", + path, + abortSignal: options?.abortSignal, + }); + }, + }; +} diff --git a/sdk/deviceregistry/arm-deviceregistry/src/models/index.ts b/sdk/deviceregistry/arm-deviceregistry/src/models/index.ts new file mode 100644 index 00000000000..9f8fc1b8b7e --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/models/index.ts @@ -0,0 +1,866 @@ +/* + * 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 * as coreClient from "@azure/core-client"; + +/** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */ +export interface OperationListResult { + /** + * List of operations supported by the resource provider + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: Operation[]; + /** + * URL to get the next set of operation list results (if there are any). + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nextLink?: string; +} + +/** Details of a REST API operation, returned from the Resource Provider Operations API */ +export interface Operation { + /** + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly isDataAction?: boolean; + /** Localized display information for this particular operation. */ + display?: OperationDisplay; + /** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly origin?: Origin; + /** + * Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly actionType?: ActionType; +} + +/** Localized display information for this particular operation. */ +export interface OperationDisplay { + /** + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provider?: string; + /** + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly resource?: string; + /** + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly operation?: string; + /** + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly description?: string; +} + +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +/** The error detail. */ +export interface ErrorDetail { + /** + * The error code. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly code?: string; + /** + * The error message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** + * The error target. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly target?: string; + /** + * The error details. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly details?: ErrorDetail[]; + /** + * The error additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** + * The additional info type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * The additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly info?: Record; +} + +/** The response of a AssetEndpointProfile list operation. */ +export interface AssetEndpointProfileListResult { + /** The AssetEndpointProfile items on this page */ + value: AssetEndpointProfile[]; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Defines the Asset Endpoint Profile properties. */ +export interface AssetEndpointProfileProperties { + /** + * Globally unique, immutable, non-reusable id. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly uuid?: string; + /** The local valid URI specifying the network address/DNS name of a southbound device. The scheme part of the targetAddress URI specifies the type of the device. The additionalConfiguration field holds further connector type specific configuration. */ + targetAddress: string; + /** Defines the client authentication mechanism to the server. */ + userAuthentication?: UserAuthentication; + /** Defines the authentication mechanism for the southbound connector connecting to the shop floor/OT device. */ + transportAuthentication?: TransportAuthentication; + /** Contains connectivity type specific further configuration (e.g. OPC UA, Modbus, ONVIF). */ + additionalConfiguration?: string; + /** + * Provisioning state of the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: ProvisioningState; +} + +/** Definition of the client authentication mechanism to the server. */ +export interface UserAuthentication { + /** Defines the mode to authenticate the user of the client at the server. */ + mode: UserAuthenticationMode; + /** Defines the username and password references when UsernamePassword user authentication mode is selected. */ + usernamePasswordCredentials?: UsernamePasswordCredentials; + /** Defines the certificate reference when Certificate user authentication mode is selected. */ + x509Credentials?: X509Credentials; +} + +/** The credentials for authentication mode UsernamePassword. */ +export interface UsernamePasswordCredentials { + /** A reference to secret containing the username. */ + usernameReference: string; + /** A reference to secret containing the password. */ + passwordReference: string; +} + +/** The x509 certificate for authentication mode Certificate. */ +export interface X509Credentials { + /** A reference to secret containing the certificate and private key (e.g. stored as .der/.pem or .der/.pfx). */ + certificateReference: string; +} + +/** Definition of the authentication mechanism for the southbound connector. */ +export interface TransportAuthentication { + /** Defines a reference to a secret which contains all certificates and private keys that can be used by the southbound connector connecting to the shop floor/OT device. The accepted extensions are .der for certificates and .pfx/.pem for private keys. */ + ownCertificates: OwnCertificate[]; +} + +/** Certificate or private key that can be used by the southbound connector connecting to the shop floor/OT device. The accepted extensions are .der for certificates and .pfx/.pem for private keys. */ +export interface OwnCertificate { + /** Certificate thumbprint. */ + certThumbprint?: string; + /** Secret Reference name (cert and private key). */ + certSecretReference?: string; + /** Secret Reference Name (Pfx or Pem password). */ + certPasswordReference?: string; +} + +/** The extended location. */ +export interface ExtendedLocation { + /** The extended location type. */ + type: string; + /** The extended location name. */ + name: string; +} + +/** Common fields that are returned in the response for all Azure Resource Manager resources */ +export interface Resource { + /** + * Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The name of the resource + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly systemData?: SystemData; +} + +/** 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 response of a Asset list operation. */ +export interface AssetListResult { + /** The Asset items on this page */ + value: Asset[]; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Defines the asset properties. */ +export interface AssetProperties { + /** + * Globally unique, immutable, non-reusable id. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly uuid?: string; + /** Resource path to asset type (model) definition. */ + assetType?: string; + /** Enabled/Disabled status of the asset. */ + enabled?: boolean; + /** Asset id provided by the customer. */ + externalAssetId?: string; + /** Human-readable display name. */ + displayName?: string; + /** Human-readable description of the asset. */ + description?: string; + /** A reference to the asset endpoint profile (connection information) used by brokers to connect to an endpoint that provides data points for this asset. Must have the format /. */ + assetEndpointProfileUri: string; + /** + * An integer that is incremented each time the resource is modified. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly version?: number; + /** Asset manufacturer name. */ + manufacturer?: string; + /** Asset manufacturer URI. */ + manufacturerUri?: string; + /** Asset model name. */ + model?: string; + /** Asset product code. */ + productCode?: string; + /** Revision number of the hardware. */ + hardwareRevision?: string; + /** Revision number of the software. */ + softwareRevision?: string; + /** Reference to the documentation. */ + documentationUri?: string; + /** Asset serial number. */ + serialNumber?: string; + /** A set of key-value pairs that contain custom attributes set by the customer. */ + attributes?: { [propertyName: string]: any }; + /** Protocol-specific default configuration for all data points. Each data point can have its own configuration that overrides the default settings here. This assumes that each asset instance has one protocol. */ + defaultDataPointsConfiguration?: string; + /** Protocol-specific default configuration for all events. Each event can have its own configuration that overrides the default settings here. This assumes that each asset instance has one protocol. */ + defaultEventsConfiguration?: string; + /** Array of data points that are part of the asset. Each data point can reference an asset type capability and have per-data point configuration. See below for more details for the definition of the dataPoints element. */ + dataPoints?: DataPoint[]; + /** Array of events that are part of the asset. Each event can reference an asset type capability and have per-event configuration. See below for more details about the definition of the events element. */ + events?: Event[]; + /** + * Read only object to reflect changes that have occurred on the Edge. Similar to Kubernetes status property for custom resources. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly status?: AssetStatus; + /** + * Provisioning state of the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: ProvisioningState; +} + +/** Defines the data point properties. */ +export interface DataPoint { + /** The name of the data point. */ + name?: string; + /** The address of the source of the data in the asset (e.g. URL) so that a client can access the data source on the asset. */ + dataSource: string; + /** The path to the type definition of the capability (e.g. DTMI, OPC UA information model node id, etc.), for example dtmi:com:example:Robot:_contents:__prop1;1. */ + capabilityId?: string; + /** An indication of how the data point should be mapped to OpenTelemetry. */ + observabilityMode?: DataPointsObservabilityMode; + /** Protocol-specific configuration for the data point. For OPC UA, this could include configuration like, publishingInterval, samplingInterval, and queueSize. */ + dataPointConfiguration?: string; +} + +/** Defines the event properties. */ +export interface Event { + /** The name of the event. */ + name?: string; + /** The address of the notifier of the event in the asset (e.g. URL) so that a client can access the event on the asset. */ + eventNotifier: string; + /** The path to the type definition of the capability (e.g. DTMI, OPC UA information model node id, etc.), for example dtmi:com:example:Robot:_contents:__prop1;1. */ + capabilityId?: string; + /** An indication of how the event should be mapped to OpenTelemetry. */ + observabilityMode?: EventsObservabilityMode; + /** Protocol-specific configuration for the event. For OPC UA, this could include configuration like, publishingInterval, samplingInterval, and queueSize. */ + eventConfiguration?: string; +} + +/** Defines the asset status properties. */ +export interface AssetStatus { + /** Array object to transfer and persist errors that originate from the Edge. */ + errors?: AssetStatusError[]; + /** A read only incremental counter indicating the number of times the configuration has been modified from the perspective of the current actual (Edge) state of the Asset. Edge would be the only writer of this value and would sync back up to the cloud. In steady state, this should equal version. */ + version?: number; +} + +/** Defines the asset status error properties. */ +export interface AssetStatusError { + /** Error code for classification of errors (ex: 400, 404, 500, etc.). */ + code?: number; + /** Human readable helpful error message to provide additional context for error (ex: “capability Id 'foo' does not exist”). */ + message?: string; +} + +/** The current status of an async operation. */ +export interface OperationStatusResult { + /** Fully qualified ID for the async operation. */ + id?: string; + /** Name of the async operation. */ + name?: string; + /** Operation status. */ + status: string; + /** Percent of the operation that is complete. */ + percentComplete?: number; + /** The start time of the operation. */ + startTime?: Date; + /** The end time of the operation. */ + endTime?: Date; + /** The operations list. */ + operations?: OperationStatusResult[]; + /** If present, details of the operation error. */ + error?: ErrorDetail; +} + +/** The type used for update operations of the AssetEndpointProfile. */ +export interface AssetEndpointProfileUpdate { + /** Resource tags. */ + tags?: { [propertyName: string]: string }; + /** The updatable properties of the AssetEndpointProfile. */ + properties?: AssetEndpointProfileUpdateProperties; +} + +/** The updatable properties of the AssetEndpointProfile. */ +export interface AssetEndpointProfileUpdateProperties { + /** The local valid URI specifying the network address/DNS name of a southbound device. The scheme part of the targetAddress URI specifies the type of the device. The additionalConfiguration field holds further connector type specific configuration. */ + targetAddress?: string; + /** Defines the client authentication mechanism to the server. */ + userAuthentication?: UserAuthenticationUpdate; + /** Defines the authentication mechanism for the southbound connector connecting to the shop floor/OT device. */ + transportAuthentication?: TransportAuthenticationUpdate; + /** Contains connectivity type specific further configuration (e.g. OPC UA, Modbus, ONVIF). */ + additionalConfiguration?: string; +} + +/** Definition of the client authentication mechanism to the server. */ +export interface UserAuthenticationUpdate { + /** Defines the mode to authenticate the user of the client at the server. */ + mode?: UserAuthenticationMode; + /** Defines the username and password references when UsernamePassword user authentication mode is selected. */ + usernamePasswordCredentials?: UsernamePasswordCredentialsUpdate; + /** Defines the certificate reference when Certificate user authentication mode is selected. */ + x509Credentials?: X509CredentialsUpdate; +} + +/** The credentials for authentication mode UsernamePassword. */ +export interface UsernamePasswordCredentialsUpdate { + /** A reference to secret containing the username. */ + usernameReference?: string; + /** A reference to secret containing the password. */ + passwordReference?: string; +} + +/** The x509 certificate for authentication mode Certificate. */ +export interface X509CredentialsUpdate { + /** A reference to secret containing the certificate and private key (e.g. stored as .der/.pem or .der/.pfx). */ + certificateReference?: string; +} + +/** Definition of the authentication mechanism for the southbound connector. */ +export interface TransportAuthenticationUpdate { + /** Defines a reference to a secret which contains all certificates and private keys that can be used by the southbound connector connecting to the shop floor/OT device. The accepted extensions are .der for certificates and .pfx/.pem for private keys. */ + ownCertificates?: OwnCertificate[]; +} + +/** The type used for update operations of the Asset. */ +export interface AssetUpdate { + /** Resource tags. */ + tags?: { [propertyName: string]: string }; + /** The updatable properties of the Asset. */ + properties?: AssetUpdateProperties; +} + +/** The updatable properties of the Asset. */ +export interface AssetUpdateProperties { + /** Resource path to asset type (model) definition. */ + assetType?: string; + /** Enabled/Disabled status of the asset. */ + enabled?: boolean; + /** Human-readable display name. */ + displayName?: string; + /** Human-readable description of the asset. */ + description?: string; + /** Asset manufacturer name. */ + manufacturer?: string; + /** Asset manufacturer URI. */ + manufacturerUri?: string; + /** Asset model name. */ + model?: string; + /** Asset product code. */ + productCode?: string; + /** Revision number of the hardware. */ + hardwareRevision?: string; + /** Revision number of the software. */ + softwareRevision?: string; + /** Reference to the documentation. */ + documentationUri?: string; + /** Asset serial number. */ + serialNumber?: string; + /** A set of key-value pairs that contain custom attributes set by the customer. */ + attributes?: { [propertyName: string]: any }; + /** Protocol-specific default configuration for all data points. Each data point can have its own configuration that overrides the default settings here. This assumes that each asset instance has one protocol. */ + defaultDataPointsConfiguration?: string; + /** Protocol-specific default configuration for all events. Each event can have its own configuration that overrides the default settings here. This assumes that each asset instance has one protocol. */ + defaultEventsConfiguration?: string; + /** Array of data points that are part of the asset. Each data point can reference an asset type capability and have per-data point configuration. See below for more details for the definition of the dataPoints element. */ + dataPoints?: DataPoint[]; + /** Array of events that are part of the asset. Each event can reference an asset type capability and have per-event configuration. See below for more details about the definition of the events element. */ + events?: Event[]; +} + +/** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ +export interface TrackedResource extends Resource { + /** Resource tags. */ + tags?: { [propertyName: string]: string }; + /** The geo-location where the resource lives */ + location: string; +} + +/** Asset Endpoint Profile definition. */ +export interface AssetEndpointProfile extends TrackedResource { + /** The resource-specific properties for this resource. */ + properties?: AssetEndpointProfileProperties; + /** The extended location. */ + extendedLocation: ExtendedLocation; +} + +/** Asset definition. */ +export interface Asset extends TrackedResource { + /** The resource-specific properties for this resource. */ + properties?: AssetProperties; + /** The extended location. */ + extendedLocation: ExtendedLocation; +} + +/** Defines headers for AssetEndpointProfiles_createOrReplace operation. */ +export interface AssetEndpointProfilesCreateOrReplaceHeaders { + /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ + retryAfter?: number; +} + +/** Defines headers for AssetEndpointProfiles_update operation. */ +export interface AssetEndpointProfilesUpdateHeaders { + /** The Location header contains the URL where the status of the long running operation can be checked. */ + location?: string; + /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ + retryAfter?: number; +} + +/** Defines headers for AssetEndpointProfiles_delete operation. */ +export interface AssetEndpointProfilesDeleteHeaders { + /** The Location header contains the URL where the status of the long running operation can be checked. */ + location?: string; + /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ + retryAfter?: number; +} + +/** Defines headers for Assets_createOrReplace operation. */ +export interface AssetsCreateOrReplaceHeaders { + /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ + retryAfter?: number; +} + +/** Defines headers for Assets_update operation. */ +export interface AssetsUpdateHeaders { + /** The Location header contains the URL where the status of the long running operation can be checked. */ + location?: string; + /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ + retryAfter?: number; +} + +/** Defines headers for Assets_delete operation. */ +export interface AssetsDeleteHeaders { + /** The Location header contains the URL where the status of the long running operation can be checked. */ + location?: string; + /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ + retryAfter?: number; +} + +/** Known values of {@link Origin} that the service accepts. */ +export enum KnownOrigin { + /** User */ + User = "user", + /** System */ + System = "system", + /** UserSystem */ + UserSystem = "user,system", +} + +/** + * Defines values for Origin. \ + * {@link KnownOrigin} can be used interchangeably with Origin, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **user** \ + * **system** \ + * **user,system** + */ +export type Origin = string; + +/** Known values of {@link ActionType} that the service accepts. */ +export enum KnownActionType { + /** Internal */ + Internal = "Internal", +} + +/** + * Defines values for ActionType. \ + * {@link KnownActionType} can be used interchangeably with ActionType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Internal** + */ +export type ActionType = string; + +/** Known values of {@link UserAuthenticationMode} that the service accepts. */ +export enum KnownUserAuthenticationMode { + /** The user authentication mode is anonymous. */ + Anonymous = "Anonymous", + /** The user authentication mode is an x509 certificate. */ + Certificate = "Certificate", + /** The user authentication mode is a username and password. */ + UsernamePassword = "UsernamePassword", +} + +/** + * Defines values for UserAuthenticationMode. \ + * {@link KnownUserAuthenticationMode} can be used interchangeably with UserAuthenticationMode, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Anonymous**: The user authentication mode is anonymous. \ + * **Certificate**: The user authentication mode is an x509 certificate. \ + * **UsernamePassword**: The user authentication mode is a username and password. + */ +export type UserAuthenticationMode = string; + +/** Known values of {@link ProvisioningState} that the service accepts. */ +export enum KnownProvisioningState { + /** Resource has been created. */ + Succeeded = "Succeeded", + /** Resource creation failed. */ + Failed = "Failed", + /** Resource creation was canceled. */ + Canceled = "Canceled", + /** Resource has been accepted by the server. */ + Accepted = "Accepted", +} + +/** + * Defines values for ProvisioningState. \ + * {@link KnownProvisioningState} can be used interchangeably with ProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Succeeded**: Resource has been created. \ + * **Failed**: Resource creation failed. \ + * **Canceled**: Resource creation was canceled. \ + * **Accepted**: Resource has been accepted by the server. + */ +export type ProvisioningState = string; + +/** Known values of {@link CreatedByType} that the service accepts. */ +export enum KnownCreatedByType { + /** User */ + User = "User", + /** Application */ + Application = "Application", + /** ManagedIdentity */ + ManagedIdentity = "ManagedIdentity", + /** Key */ + 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 DataPointsObservabilityMode} that the service accepts. */ +export enum KnownDataPointsObservabilityMode { + /** No mapping to OpenTelemetry. */ + None = "none", + /** Map as counter to OpenTelemetry. */ + Counter = "counter", + /** Map as gauge to OpenTelemetry. */ + Gauge = "gauge", + /** Map as histogram to OpenTelemetry. */ + Histogram = "histogram", + /** Map as log to OpenTelemetry. */ + Log = "log", +} + +/** + * Defines values for DataPointsObservabilityMode. \ + * {@link KnownDataPointsObservabilityMode} can be used interchangeably with DataPointsObservabilityMode, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **none**: No mapping to OpenTelemetry. \ + * **counter**: Map as counter to OpenTelemetry. \ + * **gauge**: Map as gauge to OpenTelemetry. \ + * **histogram**: Map as histogram to OpenTelemetry. \ + * **log**: Map as log to OpenTelemetry. + */ +export type DataPointsObservabilityMode = string; + +/** Known values of {@link EventsObservabilityMode} that the service accepts. */ +export enum KnownEventsObservabilityMode { + /** No mapping to OpenTelemetry. */ + None = "none", + /** Map as log to OpenTelemetry. */ + Log = "log", +} + +/** + * Defines values for EventsObservabilityMode. \ + * {@link KnownEventsObservabilityMode} can be used interchangeably with EventsObservabilityMode, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **none**: No mapping to OpenTelemetry. \ + * **log**: Map as log to OpenTelemetry. + */ +export type EventsObservabilityMode = string; + +/** Optional parameters. */ +export interface OperationsListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type OperationsListResponse = OperationListResult; + +/** Optional parameters. */ +export interface OperationsListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type OperationsListNextResponse = OperationListResult; + +/** Optional parameters. */ +export interface AssetEndpointProfilesListBySubscriptionOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listBySubscription operation. */ +export type AssetEndpointProfilesListBySubscriptionResponse = + AssetEndpointProfileListResult; + +/** Optional parameters. */ +export interface AssetEndpointProfilesListByResourceGroupOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByResourceGroup operation. */ +export type AssetEndpointProfilesListByResourceGroupResponse = + AssetEndpointProfileListResult; + +/** Optional parameters. */ +export interface AssetEndpointProfilesGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type AssetEndpointProfilesGetResponse = AssetEndpointProfile; + +/** Optional parameters. */ +export interface AssetEndpointProfilesCreateOrReplaceOptionalParams + extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the createOrReplace operation. */ +export type AssetEndpointProfilesCreateOrReplaceResponse = AssetEndpointProfile; + +/** Optional parameters. */ +export interface AssetEndpointProfilesUpdateOptionalParams + extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the update operation. */ +export type AssetEndpointProfilesUpdateResponse = AssetEndpointProfile; + +/** Optional parameters. */ +export interface AssetEndpointProfilesDeleteOptionalParams + extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the delete operation. */ +export type AssetEndpointProfilesDeleteResponse = + AssetEndpointProfilesDeleteHeaders; + +/** Optional parameters. */ +export interface AssetEndpointProfilesListBySubscriptionNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listBySubscriptionNext operation. */ +export type AssetEndpointProfilesListBySubscriptionNextResponse = + AssetEndpointProfileListResult; + +/** Optional parameters. */ +export interface AssetEndpointProfilesListByResourceGroupNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByResourceGroupNext operation. */ +export type AssetEndpointProfilesListByResourceGroupNextResponse = + AssetEndpointProfileListResult; + +/** Optional parameters. */ +export interface AssetsListBySubscriptionOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listBySubscription operation. */ +export type AssetsListBySubscriptionResponse = AssetListResult; + +/** Optional parameters. */ +export interface AssetsListByResourceGroupOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByResourceGroup operation. */ +export type AssetsListByResourceGroupResponse = AssetListResult; + +/** Optional parameters. */ +export interface AssetsGetOptionalParams extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type AssetsGetResponse = Asset; + +/** Optional parameters. */ +export interface AssetsCreateOrReplaceOptionalParams + extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the createOrReplace operation. */ +export type AssetsCreateOrReplaceResponse = Asset; + +/** Optional parameters. */ +export interface AssetsUpdateOptionalParams + extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the update operation. */ +export type AssetsUpdateResponse = Asset; + +/** Optional parameters. */ +export interface AssetsDeleteOptionalParams + extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the delete operation. */ +export type AssetsDeleteResponse = AssetsDeleteHeaders; + +/** Optional parameters. */ +export interface AssetsListBySubscriptionNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listBySubscriptionNext operation. */ +export type AssetsListBySubscriptionNextResponse = AssetListResult; + +/** Optional parameters. */ +export interface AssetsListByResourceGroupNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByResourceGroupNext operation. */ +export type AssetsListByResourceGroupNextResponse = AssetListResult; + +/** Optional parameters. */ +export interface OperationStatusGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type OperationStatusGetResponse = OperationStatusResult; + +/** Optional parameters. */ +export interface DeviceRegistryManagementClientOptionalParams + extends coreClient.ServiceClientOptions { + /** server parameter */ + $host?: string; + /** Api Version */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/deviceregistry/arm-deviceregistry/src/models/mappers.ts b/sdk/deviceregistry/arm-deviceregistry/src/models/mappers.ts new file mode 100644 index 00000000000..ecf36abc97f --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/models/mappers.ts @@ -0,0 +1,1387 @@ +/* + * 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 * as coreClient from "@azure/core-client"; + +export const OperationListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationListResult", + modelProperties: { + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Operation", + }, + }, + }, + }, + nextLink: { + serializedName: "nextLink", + readOnly: true, + type: { + name: "String", + }, + }, + }, + }, +}; + +export const Operation: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Operation", + modelProperties: { + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String", + }, + }, + isDataAction: { + serializedName: "isDataAction", + readOnly: true, + type: { + name: "Boolean", + }, + }, + display: { + serializedName: "display", + type: { + name: "Composite", + className: "OperationDisplay", + }, + }, + origin: { + serializedName: "origin", + readOnly: true, + type: { + name: "String", + }, + }, + actionType: { + serializedName: "actionType", + readOnly: true, + type: { + name: "String", + }, + }, + }, + }, +}; + +export const OperationDisplay: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationDisplay", + modelProperties: { + provider: { + serializedName: "provider", + readOnly: true, + type: { + name: "String", + }, + }, + resource: { + serializedName: "resource", + readOnly: true, + type: { + name: "String", + }, + }, + operation: { + serializedName: "operation", + readOnly: true, + type: { + name: "String", + }, + }, + description: { + serializedName: "description", + readOnly: true, + type: { + name: "String", + }, + }, + }, + }, +}; + +export const ErrorResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorDetail", + }, + }, + }, + }, +}; + +export const ErrorDetail: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorDetail", + modelProperties: { + code: { + serializedName: "code", + readOnly: true, + type: { + name: "String", + }, + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String", + }, + }, + target: { + serializedName: "target", + readOnly: true, + type: { + name: "String", + }, + }, + details: { + serializedName: "details", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorDetail", + }, + }, + }, + }, + additionalInfo: { + serializedName: "additionalInfo", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorAdditionalInfo", + }, + }, + }, + }, + }, + }, +}; + +export const ErrorAdditionalInfo: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorAdditionalInfo", + modelProperties: { + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String", + }, + }, + info: { + serializedName: "info", + readOnly: true, + type: { + name: "Dictionary", + value: { type: { name: "any" } }, + }, + }, + }, + }, +}; + +export const AssetEndpointProfileListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetEndpointProfileListResult", + modelProperties: { + value: { + serializedName: "value", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "AssetEndpointProfile", + }, + }, + }, + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const AssetEndpointProfileProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetEndpointProfileProperties", + modelProperties: { + uuid: { + serializedName: "uuid", + readOnly: true, + type: { + name: "String", + }, + }, + targetAddress: { + serializedName: "targetAddress", + required: true, + type: { + name: "String", + }, + }, + userAuthentication: { + serializedName: "userAuthentication", + type: { + name: "Composite", + className: "UserAuthentication", + }, + }, + transportAuthentication: { + serializedName: "transportAuthentication", + type: { + name: "Composite", + className: "TransportAuthentication", + }, + }, + additionalConfiguration: { + serializedName: "additionalConfiguration", + type: { + name: "String", + }, + }, + provisioningState: { + serializedName: "provisioningState", + readOnly: true, + type: { + name: "String", + }, + }, + }, + }, +}; + +export const UserAuthentication: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UserAuthentication", + modelProperties: { + mode: { + serializedName: "mode", + required: true, + type: { + name: "String", + }, + }, + usernamePasswordCredentials: { + serializedName: "usernamePasswordCredentials", + type: { + name: "Composite", + className: "UsernamePasswordCredentials", + }, + }, + x509Credentials: { + serializedName: "x509Credentials", + type: { + name: "Composite", + className: "X509Credentials", + }, + }, + }, + }, +}; + +export const UsernamePasswordCredentials: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UsernamePasswordCredentials", + modelProperties: { + usernameReference: { + serializedName: "usernameReference", + required: true, + type: { + name: "String", + }, + }, + passwordReference: { + serializedName: "passwordReference", + required: true, + type: { + name: "String", + }, + }, + }, + }, +}; + +export const X509Credentials: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "X509Credentials", + modelProperties: { + certificateReference: { + serializedName: "certificateReference", + required: true, + type: { + name: "String", + }, + }, + }, + }, +}; + +export const TransportAuthentication: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TransportAuthentication", + modelProperties: { + ownCertificates: { + serializedName: "ownCertificates", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "OwnCertificate", + }, + }, + }, + }, + }, + }, +}; + +export const OwnCertificate: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OwnCertificate", + modelProperties: { + certThumbprint: { + serializedName: "certThumbprint", + type: { + name: "String", + }, + }, + certSecretReference: { + serializedName: "certSecretReference", + type: { + name: "String", + }, + }, + certPasswordReference: { + serializedName: "certPasswordReference", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const ExtendedLocation: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ExtendedLocation", + modelProperties: { + type: { + serializedName: "type", + required: true, + type: { + name: "String", + }, + }, + name: { + serializedName: "name", + required: true, + type: { + name: "String", + }, + }, + }, + }, +}; + +export const Resource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Resource", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String", + }, + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String", + }, + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String", + }, + }, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData", + }, + }, + }, + }, +}; + +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 AssetListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetListResult", + modelProperties: { + value: { + serializedName: "value", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Asset", + }, + }, + }, + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const AssetProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetProperties", + modelProperties: { + uuid: { + serializedName: "uuid", + readOnly: true, + type: { + name: "String", + }, + }, + assetType: { + serializedName: "assetType", + type: { + name: "String", + }, + }, + enabled: { + serializedName: "enabled", + type: { + name: "Boolean", + }, + }, + externalAssetId: { + serializedName: "externalAssetId", + type: { + name: "String", + }, + }, + displayName: { + serializedName: "displayName", + type: { + name: "String", + }, + }, + description: { + serializedName: "description", + type: { + name: "String", + }, + }, + assetEndpointProfileUri: { + serializedName: "assetEndpointProfileUri", + required: true, + type: { + name: "String", + }, + }, + version: { + serializedName: "version", + readOnly: true, + type: { + name: "Number", + }, + }, + manufacturer: { + serializedName: "manufacturer", + type: { + name: "String", + }, + }, + manufacturerUri: { + serializedName: "manufacturerUri", + type: { + name: "String", + }, + }, + model: { + serializedName: "model", + type: { + name: "String", + }, + }, + productCode: { + serializedName: "productCode", + type: { + name: "String", + }, + }, + hardwareRevision: { + serializedName: "hardwareRevision", + type: { + name: "String", + }, + }, + softwareRevision: { + serializedName: "softwareRevision", + type: { + name: "String", + }, + }, + documentationUri: { + serializedName: "documentationUri", + type: { + name: "String", + }, + }, + serialNumber: { + serializedName: "serialNumber", + type: { + name: "String", + }, + }, + attributes: { + serializedName: "attributes", + type: { + name: "Dictionary", + value: { type: { name: "any" } }, + }, + }, + defaultDataPointsConfiguration: { + serializedName: "defaultDataPointsConfiguration", + type: { + name: "String", + }, + }, + defaultEventsConfiguration: { + serializedName: "defaultEventsConfiguration", + type: { + name: "String", + }, + }, + dataPoints: { + serializedName: "dataPoints", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "DataPoint", + }, + }, + }, + }, + events: { + serializedName: "events", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Event", + }, + }, + }, + }, + status: { + serializedName: "status", + type: { + name: "Composite", + className: "AssetStatus", + }, + }, + provisioningState: { + serializedName: "provisioningState", + readOnly: true, + type: { + name: "String", + }, + }, + }, + }, +}; + +export const DataPoint: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "DataPoint", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String", + }, + }, + dataSource: { + serializedName: "dataSource", + required: true, + type: { + name: "String", + }, + }, + capabilityId: { + serializedName: "capabilityId", + type: { + name: "String", + }, + }, + observabilityMode: { + defaultValue: "none", + serializedName: "observabilityMode", + type: { + name: "String", + }, + }, + dataPointConfiguration: { + serializedName: "dataPointConfiguration", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const Event: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Event", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String", + }, + }, + eventNotifier: { + serializedName: "eventNotifier", + required: true, + type: { + name: "String", + }, + }, + capabilityId: { + serializedName: "capabilityId", + type: { + name: "String", + }, + }, + observabilityMode: { + defaultValue: "none", + serializedName: "observabilityMode", + type: { + name: "String", + }, + }, + eventConfiguration: { + serializedName: "eventConfiguration", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const AssetStatus: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetStatus", + modelProperties: { + errors: { + serializedName: "errors", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "AssetStatusError", + }, + }, + }, + }, + version: { + serializedName: "version", + type: { + name: "Number", + }, + }, + }, + }, +}; + +export const AssetStatusError: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetStatusError", + modelProperties: { + code: { + serializedName: "code", + type: { + name: "Number", + }, + }, + message: { + serializedName: "message", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const OperationStatusResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationStatusResult", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String", + }, + }, + name: { + serializedName: "name", + type: { + name: "String", + }, + }, + status: { + serializedName: "status", + required: true, + type: { + name: "String", + }, + }, + percentComplete: { + constraints: { + InclusiveMaximum: 100, + InclusiveMinimum: 0, + }, + serializedName: "percentComplete", + type: { + name: "Number", + }, + }, + startTime: { + serializedName: "startTime", + type: { + name: "DateTime", + }, + }, + endTime: { + serializedName: "endTime", + type: { + name: "DateTime", + }, + }, + operations: { + serializedName: "operations", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "OperationStatusResult", + }, + }, + }, + }, + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorDetail", + }, + }, + }, + }, +}; + +export const AssetEndpointProfileUpdate: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetEndpointProfileUpdate", + modelProperties: { + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } }, + }, + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "AssetEndpointProfileUpdateProperties", + }, + }, + }, + }, +}; + +export const AssetEndpointProfileUpdateProperties: coreClient.CompositeMapper = + { + type: { + name: "Composite", + className: "AssetEndpointProfileUpdateProperties", + modelProperties: { + targetAddress: { + serializedName: "targetAddress", + type: { + name: "String", + }, + }, + userAuthentication: { + serializedName: "userAuthentication", + type: { + name: "Composite", + className: "UserAuthenticationUpdate", + }, + }, + transportAuthentication: { + serializedName: "transportAuthentication", + type: { + name: "Composite", + className: "TransportAuthenticationUpdate", + }, + }, + additionalConfiguration: { + serializedName: "additionalConfiguration", + type: { + name: "String", + }, + }, + }, + }, + }; + +export const UserAuthenticationUpdate: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UserAuthenticationUpdate", + modelProperties: { + mode: { + serializedName: "mode", + type: { + name: "String", + }, + }, + usernamePasswordCredentials: { + serializedName: "usernamePasswordCredentials", + type: { + name: "Composite", + className: "UsernamePasswordCredentialsUpdate", + }, + }, + x509Credentials: { + serializedName: "x509Credentials", + type: { + name: "Composite", + className: "X509CredentialsUpdate", + }, + }, + }, + }, +}; + +export const UsernamePasswordCredentialsUpdate: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UsernamePasswordCredentialsUpdate", + modelProperties: { + usernameReference: { + serializedName: "usernameReference", + type: { + name: "String", + }, + }, + passwordReference: { + serializedName: "passwordReference", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const X509CredentialsUpdate: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "X509CredentialsUpdate", + modelProperties: { + certificateReference: { + serializedName: "certificateReference", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const TransportAuthenticationUpdate: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TransportAuthenticationUpdate", + modelProperties: { + ownCertificates: { + serializedName: "ownCertificates", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "OwnCertificate", + }, + }, + }, + }, + }, + }, +}; + +export const AssetUpdate: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetUpdate", + modelProperties: { + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } }, + }, + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "AssetUpdateProperties", + }, + }, + }, + }, +}; + +export const AssetUpdateProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetUpdateProperties", + modelProperties: { + assetType: { + serializedName: "assetType", + type: { + name: "String", + }, + }, + enabled: { + serializedName: "enabled", + type: { + name: "Boolean", + }, + }, + displayName: { + serializedName: "displayName", + type: { + name: "String", + }, + }, + description: { + serializedName: "description", + type: { + name: "String", + }, + }, + manufacturer: { + serializedName: "manufacturer", + type: { + name: "String", + }, + }, + manufacturerUri: { + serializedName: "manufacturerUri", + type: { + name: "String", + }, + }, + model: { + serializedName: "model", + type: { + name: "String", + }, + }, + productCode: { + serializedName: "productCode", + type: { + name: "String", + }, + }, + hardwareRevision: { + serializedName: "hardwareRevision", + type: { + name: "String", + }, + }, + softwareRevision: { + serializedName: "softwareRevision", + type: { + name: "String", + }, + }, + documentationUri: { + serializedName: "documentationUri", + type: { + name: "String", + }, + }, + serialNumber: { + serializedName: "serialNumber", + type: { + name: "String", + }, + }, + attributes: { + serializedName: "attributes", + type: { + name: "Dictionary", + value: { type: { name: "any" } }, + }, + }, + defaultDataPointsConfiguration: { + serializedName: "defaultDataPointsConfiguration", + type: { + name: "String", + }, + }, + defaultEventsConfiguration: { + serializedName: "defaultEventsConfiguration", + type: { + name: "String", + }, + }, + dataPoints: { + serializedName: "dataPoints", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "DataPoint", + }, + }, + }, + }, + events: { + serializedName: "events", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Event", + }, + }, + }, + }, + }, + }, +}; + +export const TrackedResource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TrackedResource", + modelProperties: { + ...Resource.type.modelProperties, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } }, + }, + }, + location: { + serializedName: "location", + required: true, + type: { + name: "String", + }, + }, + }, + }, +}; + +export const AssetEndpointProfile: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetEndpointProfile", + modelProperties: { + ...TrackedResource.type.modelProperties, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "AssetEndpointProfileProperties", + }, + }, + extendedLocation: { + serializedName: "extendedLocation", + type: { + name: "Composite", + className: "ExtendedLocation", + }, + }, + }, + }, +}; + +export const Asset: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Asset", + modelProperties: { + ...TrackedResource.type.modelProperties, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "AssetProperties", + }, + }, + extendedLocation: { + serializedName: "extendedLocation", + type: { + name: "Composite", + className: "ExtendedLocation", + }, + }, + }, + }, +}; + +export const AssetEndpointProfilesCreateOrReplaceHeaders: coreClient.CompositeMapper = + { + type: { + name: "Composite", + className: "AssetEndpointProfilesCreateOrReplaceHeaders", + modelProperties: { + retryAfter: { + serializedName: "retry-after", + type: { + name: "Number", + }, + }, + }, + }, + }; + +export const AssetEndpointProfilesUpdateHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetEndpointProfilesUpdateHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String", + }, + }, + retryAfter: { + serializedName: "retry-after", + type: { + name: "Number", + }, + }, + }, + }, +}; + +export const AssetEndpointProfilesDeleteHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetEndpointProfilesDeleteHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String", + }, + }, + retryAfter: { + serializedName: "retry-after", + type: { + name: "Number", + }, + }, + }, + }, +}; + +export const AssetsCreateOrReplaceHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetsCreateOrReplaceHeaders", + modelProperties: { + retryAfter: { + serializedName: "retry-after", + type: { + name: "Number", + }, + }, + }, + }, +}; + +export const AssetsUpdateHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetsUpdateHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String", + }, + }, + retryAfter: { + serializedName: "retry-after", + type: { + name: "Number", + }, + }, + }, + }, +}; + +export const AssetsDeleteHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AssetsDeleteHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String", + }, + }, + retryAfter: { + serializedName: "retry-after", + type: { + name: "Number", + }, + }, + }, + }, +}; diff --git a/sdk/deviceregistry/arm-deviceregistry/src/models/parameters.ts b/sdk/deviceregistry/arm-deviceregistry/src/models/parameters.ts new file mode 100644 index 00000000000..c0afb0c27f7 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/models/parameters.ts @@ -0,0 +1,188 @@ +/* + * 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 { + OperationParameter, + OperationURLParameter, + OperationQueryParameter, +} from "@azure/core-client"; +import { + AssetEndpointProfile as AssetEndpointProfileMapper, + AssetEndpointProfileUpdate as AssetEndpointProfileUpdateMapper, + Asset as AssetMapper, + AssetUpdate as AssetUpdateMapper, +} from "../models/mappers"; + +export const accept: OperationParameter = { + parameterPath: "accept", + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", + type: { + name: "String", + }, + }, +}; + +export const $host: OperationURLParameter = { + parameterPath: "$host", + mapper: { + serializedName: "$host", + required: true, + type: { + name: "String", + }, + }, + skipEncoding: true, +}; + +export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2023-11-01-preview", + isConstant: true, + serializedName: "api-version", + type: { + name: "String", + }, + }, +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String", + }, + }, + skipEncoding: true, +}; + +export const subscriptionId: OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + constraints: { + MinLength: 1, + }, + serializedName: "subscriptionId", + required: true, + type: { + name: "String", + }, + }, +}; + +export const resourceGroupName: OperationURLParameter = { + parameterPath: "resourceGroupName", + mapper: { + constraints: { + MaxLength: 90, + MinLength: 1, + }, + serializedName: "resourceGroupName", + required: true, + type: { + name: "String", + }, + }, +}; + +export const assetEndpointProfileName: OperationURLParameter = { + parameterPath: "assetEndpointProfileName", + mapper: { + constraints: { + Pattern: new RegExp("^[a-z0-9][a-z0-9-]*[a-z0-9]$"), + MaxLength: 63, + MinLength: 3, + }, + serializedName: "assetEndpointProfileName", + required: true, + type: { + name: "String", + }, + }, +}; + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String", + }, + }, +}; + +export const resource: OperationParameter = { + parameterPath: "resource", + mapper: AssetEndpointProfileMapper, +}; + +export const properties: OperationParameter = { + parameterPath: "properties", + mapper: AssetEndpointProfileUpdateMapper, +}; + +export const assetName: OperationURLParameter = { + parameterPath: "assetName", + mapper: { + constraints: { + Pattern: new RegExp("^[a-z0-9][a-z0-9-]*[a-z0-9]$"), + MaxLength: 63, + MinLength: 3, + }, + serializedName: "assetName", + required: true, + type: { + name: "String", + }, + }, +}; + +export const resource1: OperationParameter = { + parameterPath: "resource", + mapper: AssetMapper, +}; + +export const properties1: OperationParameter = { + parameterPath: "properties", + mapper: AssetUpdateMapper, +}; + +export const location: OperationURLParameter = { + parameterPath: "location", + mapper: { + constraints: { + MinLength: 1, + }, + serializedName: "location", + required: true, + type: { + name: "String", + }, + }, +}; + +export const operationId: OperationURLParameter = { + parameterPath: "operationId", + mapper: { + constraints: { + MinLength: 1, + }, + serializedName: "operationId", + required: true, + type: { + name: "String", + }, + }, +}; diff --git a/sdk/deviceregistry/arm-deviceregistry/src/operations/assetEndpointProfiles.ts b/sdk/deviceregistry/arm-deviceregistry/src/operations/assetEndpointProfiles.ts new file mode 100644 index 00000000000..39cdec0e920 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/operations/assetEndpointProfiles.ts @@ -0,0 +1,733 @@ +/* + * 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 { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { AssetEndpointProfiles } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { DeviceRegistryManagementClient } from "../deviceRegistryManagementClient"; +import { + SimplePollerLike, + OperationState, + createHttpPoller, +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; +import { + AssetEndpointProfile, + AssetEndpointProfilesListBySubscriptionNextOptionalParams, + AssetEndpointProfilesListBySubscriptionOptionalParams, + AssetEndpointProfilesListBySubscriptionResponse, + AssetEndpointProfilesListByResourceGroupNextOptionalParams, + AssetEndpointProfilesListByResourceGroupOptionalParams, + AssetEndpointProfilesListByResourceGroupResponse, + AssetEndpointProfilesGetOptionalParams, + AssetEndpointProfilesGetResponse, + AssetEndpointProfilesCreateOrReplaceOptionalParams, + AssetEndpointProfilesCreateOrReplaceResponse, + AssetEndpointProfileUpdate, + AssetEndpointProfilesUpdateOptionalParams, + AssetEndpointProfilesUpdateResponse, + AssetEndpointProfilesDeleteOptionalParams, + AssetEndpointProfilesDeleteResponse, + AssetEndpointProfilesListBySubscriptionNextResponse, + AssetEndpointProfilesListByResourceGroupNextResponse, +} from "../models"; + +/// +/** Class containing AssetEndpointProfiles operations. */ +export class AssetEndpointProfilesImpl implements AssetEndpointProfiles { + private readonly client: DeviceRegistryManagementClient; + + /** + * Initialize a new instance of the class AssetEndpointProfiles class. + * @param client Reference to the service client + */ + constructor(client: DeviceRegistryManagementClient) { + this.client = client; + } + + /** + * List AssetEndpointProfile resources by subscription ID + * @param options The options parameters. + */ + public listBySubscription( + options?: AssetEndpointProfilesListBySubscriptionOptionalParams, + ): PagedAsyncIterableIterator { + const iter = this.listBySubscriptionPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listBySubscriptionPagingPage(options, settings); + }, + }; + } + + private async *listBySubscriptionPagingPage( + options?: AssetEndpointProfilesListBySubscriptionOptionalParams, + settings?: PageSettings, + ): AsyncIterableIterator { + let result: AssetEndpointProfilesListBySubscriptionResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listBySubscription(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listBySubscriptionNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listBySubscriptionPagingAll( + options?: AssetEndpointProfilesListBySubscriptionOptionalParams, + ): AsyncIterableIterator { + for await (const page of this.listBySubscriptionPagingPage(options)) { + yield* page; + } + } + + /** + * List AssetEndpointProfile resources by resource group + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + public listByResourceGroup( + resourceGroupName: string, + options?: AssetEndpointProfilesListByResourceGroupOptionalParams, + ): PagedAsyncIterableIterator { + const iter = this.listByResourceGroupPagingAll(resourceGroupName, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings, + ); + }, + }; + } + + private async *listByResourceGroupPagingPage( + resourceGroupName: string, + options?: AssetEndpointProfilesListByResourceGroupOptionalParams, + settings?: PageSettings, + ): AsyncIterableIterator { + let result: AssetEndpointProfilesListByResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listByResourceGroupNext( + resourceGroupName, + continuationToken, + options, + ); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listByResourceGroupPagingAll( + resourceGroupName: string, + options?: AssetEndpointProfilesListByResourceGroupOptionalParams, + ): AsyncIterableIterator { + for await (const page of this.listByResourceGroupPagingPage( + resourceGroupName, + options, + )) { + yield* page; + } + } + + /** + * List AssetEndpointProfile resources by subscription ID + * @param options The options parameters. + */ + private _listBySubscription( + options?: AssetEndpointProfilesListBySubscriptionOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { options }, + listBySubscriptionOperationSpec, + ); + } + + /** + * List AssetEndpointProfile resources by resource group + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + private _listByResourceGroup( + resourceGroupName: string, + options?: AssetEndpointProfilesListByResourceGroupOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, options }, + listByResourceGroupOperationSpec, + ); + } + + /** + * Get a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + assetEndpointProfileName: string, + options?: AssetEndpointProfilesGetOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, assetEndpointProfileName, options }, + getOperationSpec, + ); + } + + /** + * Create a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param resource Resource create parameters. + * @param options The options parameters. + */ + async beginCreateOrReplace( + resourceGroupName: string, + assetEndpointProfileName: string, + resource: AssetEndpointProfile, + options?: AssetEndpointProfilesCreateOrReplaceOptionalParams, + ): Promise< + SimplePollerLike< + OperationState, + AssetEndpointProfilesCreateOrReplaceResponse + > + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperationFn = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ) => { + let currentRawResponse: coreClient.FullOperationResponse | undefined = + undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown, + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback, + }, + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON(), + }, + }; + }; + + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, assetEndpointProfileName, resource, options }, + spec: createOrReplaceOperationSpec, + }); + const poller = await createHttpPoller< + AssetEndpointProfilesCreateOrReplaceResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: "azure-async-operation", + }); + await poller.poll(); + return poller; + } + + /** + * Create a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param resource Resource create parameters. + * @param options The options parameters. + */ + async beginCreateOrReplaceAndWait( + resourceGroupName: string, + assetEndpointProfileName: string, + resource: AssetEndpointProfile, + options?: AssetEndpointProfilesCreateOrReplaceOptionalParams, + ): Promise { + const poller = await this.beginCreateOrReplace( + resourceGroupName, + assetEndpointProfileName, + resource, + options, + ); + return poller.pollUntilDone(); + } + + /** + * Update a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param properties The resource properties to be updated. + * @param options The options parameters. + */ + async beginUpdate( + resourceGroupName: string, + assetEndpointProfileName: string, + properties: AssetEndpointProfileUpdate, + options?: AssetEndpointProfilesUpdateOptionalParams, + ): Promise< + SimplePollerLike< + OperationState, + AssetEndpointProfilesUpdateResponse + > + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperationFn = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ) => { + let currentRawResponse: coreClient.FullOperationResponse | undefined = + undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown, + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback, + }, + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON(), + }, + }; + }; + + const lro = createLroSpec({ + sendOperationFn, + args: { + resourceGroupName, + assetEndpointProfileName, + properties, + options, + }, + spec: updateOperationSpec, + }); + const poller = await createHttpPoller< + AssetEndpointProfilesUpdateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: "location", + }); + await poller.poll(); + return poller; + } + + /** + * Update a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param properties The resource properties to be updated. + * @param options The options parameters. + */ + async beginUpdateAndWait( + resourceGroupName: string, + assetEndpointProfileName: string, + properties: AssetEndpointProfileUpdate, + options?: AssetEndpointProfilesUpdateOptionalParams, + ): Promise { + const poller = await this.beginUpdate( + resourceGroupName, + assetEndpointProfileName, + properties, + options, + ); + return poller.pollUntilDone(); + } + + /** + * Delete a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param options The options parameters. + */ + async beginDelete( + resourceGroupName: string, + assetEndpointProfileName: string, + options?: AssetEndpointProfilesDeleteOptionalParams, + ): Promise< + SimplePollerLike< + OperationState, + AssetEndpointProfilesDeleteResponse + > + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperationFn = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ) => { + let currentRawResponse: coreClient.FullOperationResponse | undefined = + undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown, + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback, + }, + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON(), + }, + }; + }; + + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, assetEndpointProfileName, options }, + spec: deleteOperationSpec, + }); + const poller = await createHttpPoller< + AssetEndpointProfilesDeleteResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: "location", + }); + await poller.poll(); + return poller; + } + + /** + * Delete a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param options The options parameters. + */ + async beginDeleteAndWait( + resourceGroupName: string, + assetEndpointProfileName: string, + options?: AssetEndpointProfilesDeleteOptionalParams, + ): Promise { + const poller = await this.beginDelete( + resourceGroupName, + assetEndpointProfileName, + options, + ); + return poller.pollUntilDone(); + } + + /** + * ListBySubscriptionNext + * @param nextLink The nextLink from the previous successful call to the ListBySubscription method. + * @param options The options parameters. + */ + private _listBySubscriptionNext( + nextLink: string, + options?: AssetEndpointProfilesListBySubscriptionNextOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listBySubscriptionNextOperationSpec, + ); + } + + /** + * ListByResourceGroupNext + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method. + * @param options The options parameters. + */ + private _listByResourceGroupNext( + resourceGroupName: string, + nextLink: string, + options?: AssetEndpointProfilesListByResourceGroupNextOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, nextLink, options }, + listByResourceGroupNextOperationSpec, + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listBySubscriptionOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AssetEndpointProfileListResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer, +}; +const listByResourceGroupOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AssetEndpointProfileListResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + ], + headerParameters: [Parameters.accept], + serializer, +}; +const getOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/{assetEndpointProfileName}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AssetEndpointProfile, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.assetEndpointProfileName, + ], + headerParameters: [Parameters.accept], + serializer, +}; +const createOrReplaceOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/{assetEndpointProfileName}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.AssetEndpointProfile, + }, + 201: { + bodyMapper: Mappers.AssetEndpointProfile, + }, + 202: { + bodyMapper: Mappers.AssetEndpointProfile, + }, + 204: { + bodyMapper: Mappers.AssetEndpointProfile, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + requestBody: Parameters.resource, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.assetEndpointProfileName, + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer, +}; +const updateOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/{assetEndpointProfileName}", + httpMethod: "PATCH", + responses: { + 200: { + bodyMapper: Mappers.AssetEndpointProfile, + }, + 201: { + bodyMapper: Mappers.AssetEndpointProfile, + }, + 202: { + bodyMapper: Mappers.AssetEndpointProfile, + }, + 204: { + bodyMapper: Mappers.AssetEndpointProfile, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + requestBody: Parameters.properties, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.assetEndpointProfileName, + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer, +}; +const deleteOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/{assetEndpointProfileName}", + httpMethod: "DELETE", + responses: { + 200: { + headersMapper: Mappers.AssetEndpointProfilesDeleteHeaders, + }, + 201: { + headersMapper: Mappers.AssetEndpointProfilesDeleteHeaders, + }, + 202: { + headersMapper: Mappers.AssetEndpointProfilesDeleteHeaders, + }, + 204: { + headersMapper: Mappers.AssetEndpointProfilesDeleteHeaders, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.assetEndpointProfileName, + ], + headerParameters: [Parameters.accept], + serializer, +}; +const listBySubscriptionNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AssetEndpointProfileListResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId, + ], + headerParameters: [Parameters.accept], + serializer, +}; +const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AssetEndpointProfileListResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId, + Parameters.resourceGroupName, + ], + headerParameters: [Parameters.accept], + serializer, +}; diff --git a/sdk/deviceregistry/arm-deviceregistry/src/operations/assets.ts b/sdk/deviceregistry/arm-deviceregistry/src/operations/assets.ts new file mode 100644 index 00000000000..d09b14681f0 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/operations/assets.ts @@ -0,0 +1,722 @@ +/* + * 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 { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { Assets } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { DeviceRegistryManagementClient } from "../deviceRegistryManagementClient"; +import { + SimplePollerLike, + OperationState, + createHttpPoller, +} from "@azure/core-lro"; +import { createLroSpec } from "../lroImpl"; +import { + Asset, + AssetsListBySubscriptionNextOptionalParams, + AssetsListBySubscriptionOptionalParams, + AssetsListBySubscriptionResponse, + AssetsListByResourceGroupNextOptionalParams, + AssetsListByResourceGroupOptionalParams, + AssetsListByResourceGroupResponse, + AssetsGetOptionalParams, + AssetsGetResponse, + AssetsCreateOrReplaceOptionalParams, + AssetsCreateOrReplaceResponse, + AssetUpdate, + AssetsUpdateOptionalParams, + AssetsUpdateResponse, + AssetsDeleteOptionalParams, + AssetsDeleteResponse, + AssetsListBySubscriptionNextResponse, + AssetsListByResourceGroupNextResponse, +} from "../models"; + +/// +/** Class containing Assets operations. */ +export class AssetsImpl implements Assets { + private readonly client: DeviceRegistryManagementClient; + + /** + * Initialize a new instance of the class Assets class. + * @param client Reference to the service client + */ + constructor(client: DeviceRegistryManagementClient) { + this.client = client; + } + + /** + * List Asset resources by subscription ID + * @param options The options parameters. + */ + public listBySubscription( + options?: AssetsListBySubscriptionOptionalParams, + ): PagedAsyncIterableIterator { + const iter = this.listBySubscriptionPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listBySubscriptionPagingPage(options, settings); + }, + }; + } + + private async *listBySubscriptionPagingPage( + options?: AssetsListBySubscriptionOptionalParams, + settings?: PageSettings, + ): AsyncIterableIterator { + let result: AssetsListBySubscriptionResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listBySubscription(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listBySubscriptionNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listBySubscriptionPagingAll( + options?: AssetsListBySubscriptionOptionalParams, + ): AsyncIterableIterator { + for await (const page of this.listBySubscriptionPagingPage(options)) { + yield* page; + } + } + + /** + * List Asset resources by resource group + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + public listByResourceGroup( + resourceGroupName: string, + options?: AssetsListByResourceGroupOptionalParams, + ): PagedAsyncIterableIterator { + const iter = this.listByResourceGroupPagingAll(resourceGroupName, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings, + ); + }, + }; + } + + private async *listByResourceGroupPagingPage( + resourceGroupName: string, + options?: AssetsListByResourceGroupOptionalParams, + settings?: PageSettings, + ): AsyncIterableIterator { + let result: AssetsListByResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listByResourceGroupNext( + resourceGroupName, + continuationToken, + options, + ); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listByResourceGroupPagingAll( + resourceGroupName: string, + options?: AssetsListByResourceGroupOptionalParams, + ): AsyncIterableIterator { + for await (const page of this.listByResourceGroupPagingPage( + resourceGroupName, + options, + )) { + yield* page; + } + } + + /** + * List Asset resources by subscription ID + * @param options The options parameters. + */ + private _listBySubscription( + options?: AssetsListBySubscriptionOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { options }, + listBySubscriptionOperationSpec, + ); + } + + /** + * List Asset resources by resource group + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + private _listByResourceGroup( + resourceGroupName: string, + options?: AssetsListByResourceGroupOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, options }, + listByResourceGroupOperationSpec, + ); + } + + /** + * Get a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + assetName: string, + options?: AssetsGetOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, assetName, options }, + getOperationSpec, + ); + } + + /** + * Create a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param resource Resource create parameters. + * @param options The options parameters. + */ + async beginCreateOrReplace( + resourceGroupName: string, + assetName: string, + resource: Asset, + options?: AssetsCreateOrReplaceOptionalParams, + ): Promise< + SimplePollerLike< + OperationState, + AssetsCreateOrReplaceResponse + > + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperationFn = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ) => { + let currentRawResponse: coreClient.FullOperationResponse | undefined = + undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown, + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback, + }, + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON(), + }, + }; + }; + + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, assetName, resource, options }, + spec: createOrReplaceOperationSpec, + }); + const poller = await createHttpPoller< + AssetsCreateOrReplaceResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: "azure-async-operation", + }); + await poller.poll(); + return poller; + } + + /** + * Create a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param resource Resource create parameters. + * @param options The options parameters. + */ + async beginCreateOrReplaceAndWait( + resourceGroupName: string, + assetName: string, + resource: Asset, + options?: AssetsCreateOrReplaceOptionalParams, + ): Promise { + const poller = await this.beginCreateOrReplace( + resourceGroupName, + assetName, + resource, + options, + ); + return poller.pollUntilDone(); + } + + /** + * Update a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param properties The resource properties to be updated. + * @param options The options parameters. + */ + async beginUpdate( + resourceGroupName: string, + assetName: string, + properties: AssetUpdate, + options?: AssetsUpdateOptionalParams, + ): Promise< + SimplePollerLike, AssetsUpdateResponse> + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperationFn = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ) => { + let currentRawResponse: coreClient.FullOperationResponse | undefined = + undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown, + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback, + }, + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON(), + }, + }; + }; + + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, assetName, properties, options }, + spec: updateOperationSpec, + }); + const poller = await createHttpPoller< + AssetsUpdateResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: "location", + }); + await poller.poll(); + return poller; + } + + /** + * Update a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param properties The resource properties to be updated. + * @param options The options parameters. + */ + async beginUpdateAndWait( + resourceGroupName: string, + assetName: string, + properties: AssetUpdate, + options?: AssetsUpdateOptionalParams, + ): Promise { + const poller = await this.beginUpdate( + resourceGroupName, + assetName, + properties, + options, + ); + return poller.pollUntilDone(); + } + + /** + * Delete a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param options The options parameters. + */ + async beginDelete( + resourceGroupName: string, + assetName: string, + options?: AssetsDeleteOptionalParams, + ): Promise< + SimplePollerLike, AssetsDeleteResponse> + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperationFn = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec, + ) => { + let currentRawResponse: coreClient.FullOperationResponse | undefined = + undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown, + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback, + }, + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON(), + }, + }; + }; + + const lro = createLroSpec({ + sendOperationFn, + args: { resourceGroupName, assetName, options }, + spec: deleteOperationSpec, + }); + const poller = await createHttpPoller< + AssetsDeleteResponse, + OperationState + >(lro, { + restoreFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: "location", + }); + await poller.poll(); + return poller; + } + + /** + * Delete a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param options The options parameters. + */ + async beginDeleteAndWait( + resourceGroupName: string, + assetName: string, + options?: AssetsDeleteOptionalParams, + ): Promise { + const poller = await this.beginDelete( + resourceGroupName, + assetName, + options, + ); + return poller.pollUntilDone(); + } + + /** + * ListBySubscriptionNext + * @param nextLink The nextLink from the previous successful call to the ListBySubscription method. + * @param options The options parameters. + */ + private _listBySubscriptionNext( + nextLink: string, + options?: AssetsListBySubscriptionNextOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listBySubscriptionNextOperationSpec, + ); + } + + /** + * ListByResourceGroupNext + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method. + * @param options The options parameters. + */ + private _listByResourceGroupNext( + resourceGroupName: string, + nextLink: string, + options?: AssetsListByResourceGroupNextOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, nextLink, options }, + listByResourceGroupNextOperationSpec, + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listBySubscriptionOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceRegistry/assets", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AssetListResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer, +}; +const listByResourceGroupOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AssetListResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + ], + headerParameters: [Parameters.accept], + serializer, +}; +const getOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets/{assetName}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.Asset, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.assetName, + ], + headerParameters: [Parameters.accept], + serializer, +}; +const createOrReplaceOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets/{assetName}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.Asset, + }, + 201: { + bodyMapper: Mappers.Asset, + }, + 202: { + bodyMapper: Mappers.Asset, + }, + 204: { + bodyMapper: Mappers.Asset, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + requestBody: Parameters.resource1, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.assetName, + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer, +}; +const updateOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets/{assetName}", + httpMethod: "PATCH", + responses: { + 200: { + bodyMapper: Mappers.Asset, + }, + 201: { + bodyMapper: Mappers.Asset, + }, + 202: { + bodyMapper: Mappers.Asset, + }, + 204: { + bodyMapper: Mappers.Asset, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + requestBody: Parameters.properties1, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.assetName, + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer, +}; +const deleteOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceRegistry/assets/{assetName}", + httpMethod: "DELETE", + responses: { + 200: { + headersMapper: Mappers.AssetsDeleteHeaders, + }, + 201: { + headersMapper: Mappers.AssetsDeleteHeaders, + }, + 202: { + headersMapper: Mappers.AssetsDeleteHeaders, + }, + 204: { + headersMapper: Mappers.AssetsDeleteHeaders, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.assetName, + ], + headerParameters: [Parameters.accept], + serializer, +}; +const listBySubscriptionNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AssetListResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId, + ], + headerParameters: [Parameters.accept], + serializer, +}; +const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AssetListResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId, + Parameters.resourceGroupName, + ], + headerParameters: [Parameters.accept], + serializer, +}; diff --git a/sdk/deviceregistry/arm-deviceregistry/src/operations/index.ts b/sdk/deviceregistry/arm-deviceregistry/src/operations/index.ts new file mode 100644 index 00000000000..a5b6de543e8 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/operations/index.ts @@ -0,0 +1,12 @@ +/* + * 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. + */ + +export * from "./operations"; +export * from "./assetEndpointProfiles"; +export * from "./assets"; +export * from "./operationStatus"; diff --git a/sdk/deviceregistry/arm-deviceregistry/src/operations/operationStatus.ts b/sdk/deviceregistry/arm-deviceregistry/src/operations/operationStatus.ts new file mode 100644 index 00000000000..b192ce24790 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/operations/operationStatus.ts @@ -0,0 +1,71 @@ +/* + * 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 { OperationStatus } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { DeviceRegistryManagementClient } from "../deviceRegistryManagementClient"; +import { + OperationStatusGetOptionalParams, + OperationStatusGetResponse, +} from "../models"; + +/** Class containing OperationStatus operations. */ +export class OperationStatusImpl implements OperationStatus { + private readonly client: DeviceRegistryManagementClient; + + /** + * Initialize a new instance of the class OperationStatus class. + * @param client Reference to the service client + */ + constructor(client: DeviceRegistryManagementClient) { + this.client = client; + } + + /** + * Returns the current status of an async operation. + * @param location The name of Azure region. + * @param operationId The ID of an ongoing async operation. + * @param options The options parameters. + */ + get( + location: string, + operationId: string, + options?: OperationStatusGetOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { location, operationId, options }, + getOperationSpec, + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const getOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceRegistry/locations/{location}/operationStatuses/{operationId}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationStatusResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.location, + Parameters.operationId, + ], + headerParameters: [Parameters.accept], + serializer, +}; diff --git a/sdk/deviceregistry/arm-deviceregistry/src/operations/operations.ts b/sdk/deviceregistry/arm-deviceregistry/src/operations/operations.ts new file mode 100644 index 00000000000..221d98ab21a --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/operations/operations.ts @@ -0,0 +1,149 @@ +/* + * 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 { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { Operations } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { DeviceRegistryManagementClient } from "../deviceRegistryManagementClient"; +import { + Operation, + OperationsListNextOptionalParams, + OperationsListOptionalParams, + OperationsListResponse, + OperationsListNextResponse, +} from "../models"; + +/// +/** Class containing Operations operations. */ +export class OperationsImpl implements Operations { + private readonly client: DeviceRegistryManagementClient; + + /** + * Initialize a new instance of the class Operations class. + * @param client Reference to the service client + */ + constructor(client: DeviceRegistryManagementClient) { + this.client = client; + } + + /** + * List the operations for the provider + * @param options The options parameters. + */ + public list( + options?: OperationsListOptionalParams, + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); + }, + }; + } + + private async *listPagingPage( + options?: OperationsListOptionalParams, + settings?: PageSettings, + ): AsyncIterableIterator { + let result: OperationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listPagingAll( + options?: OperationsListOptionalParams, + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + + /** + * List the operations for the provider + * @param options The options parameters. + */ + private _list( + options?: OperationsListOptionalParams, + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + nextLink: string, + options?: OperationsListNextOptionalParams, + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec, + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.DeviceRegistry/operations", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationListResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer, +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationListResult, + }, + default: { + bodyMapper: Mappers.ErrorResponse, + }, + }, + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer, +}; diff --git a/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/assetEndpointProfiles.ts b/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/assetEndpointProfiles.ts new file mode 100644 index 00000000000..95f8f1046d8 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/assetEndpointProfiles.ts @@ -0,0 +1,145 @@ +/* + * 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 { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; +import { + AssetEndpointProfile, + AssetEndpointProfilesListBySubscriptionOptionalParams, + AssetEndpointProfilesListByResourceGroupOptionalParams, + AssetEndpointProfilesGetOptionalParams, + AssetEndpointProfilesGetResponse, + AssetEndpointProfilesCreateOrReplaceOptionalParams, + AssetEndpointProfilesCreateOrReplaceResponse, + AssetEndpointProfileUpdate, + AssetEndpointProfilesUpdateOptionalParams, + AssetEndpointProfilesUpdateResponse, + AssetEndpointProfilesDeleteOptionalParams, + AssetEndpointProfilesDeleteResponse, +} from "../models"; + +/// +/** Interface representing a AssetEndpointProfiles. */ +export interface AssetEndpointProfiles { + /** + * List AssetEndpointProfile resources by subscription ID + * @param options The options parameters. + */ + listBySubscription( + options?: AssetEndpointProfilesListBySubscriptionOptionalParams, + ): PagedAsyncIterableIterator; + /** + * List AssetEndpointProfile resources by resource group + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + listByResourceGroup( + resourceGroupName: string, + options?: AssetEndpointProfilesListByResourceGroupOptionalParams, + ): PagedAsyncIterableIterator; + /** + * Get a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + assetEndpointProfileName: string, + options?: AssetEndpointProfilesGetOptionalParams, + ): Promise; + /** + * Create a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param resource Resource create parameters. + * @param options The options parameters. + */ + beginCreateOrReplace( + resourceGroupName: string, + assetEndpointProfileName: string, + resource: AssetEndpointProfile, + options?: AssetEndpointProfilesCreateOrReplaceOptionalParams, + ): Promise< + SimplePollerLike< + OperationState, + AssetEndpointProfilesCreateOrReplaceResponse + > + >; + /** + * Create a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param resource Resource create parameters. + * @param options The options parameters. + */ + beginCreateOrReplaceAndWait( + resourceGroupName: string, + assetEndpointProfileName: string, + resource: AssetEndpointProfile, + options?: AssetEndpointProfilesCreateOrReplaceOptionalParams, + ): Promise; + /** + * Update a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param properties The resource properties to be updated. + * @param options The options parameters. + */ + beginUpdate( + resourceGroupName: string, + assetEndpointProfileName: string, + properties: AssetEndpointProfileUpdate, + options?: AssetEndpointProfilesUpdateOptionalParams, + ): Promise< + SimplePollerLike< + OperationState, + AssetEndpointProfilesUpdateResponse + > + >; + /** + * Update a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param properties The resource properties to be updated. + * @param options The options parameters. + */ + beginUpdateAndWait( + resourceGroupName: string, + assetEndpointProfileName: string, + properties: AssetEndpointProfileUpdate, + options?: AssetEndpointProfilesUpdateOptionalParams, + ): Promise; + /** + * Delete a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param options The options parameters. + */ + beginDelete( + resourceGroupName: string, + assetEndpointProfileName: string, + options?: AssetEndpointProfilesDeleteOptionalParams, + ): Promise< + SimplePollerLike< + OperationState, + AssetEndpointProfilesDeleteResponse + > + >; + /** + * Delete a AssetEndpointProfile + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetEndpointProfileName Asset Endpoint Profile name parameter. + * @param options The options parameters. + */ + beginDeleteAndWait( + resourceGroupName: string, + assetEndpointProfileName: string, + options?: AssetEndpointProfilesDeleteOptionalParams, + ): Promise; +} diff --git a/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/assets.ts b/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/assets.ts new file mode 100644 index 00000000000..1c8ea67be71 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/assets.ts @@ -0,0 +1,139 @@ +/* + * 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 { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { SimplePollerLike, OperationState } from "@azure/core-lro"; +import { + Asset, + AssetsListBySubscriptionOptionalParams, + AssetsListByResourceGroupOptionalParams, + AssetsGetOptionalParams, + AssetsGetResponse, + AssetsCreateOrReplaceOptionalParams, + AssetsCreateOrReplaceResponse, + AssetUpdate, + AssetsUpdateOptionalParams, + AssetsUpdateResponse, + AssetsDeleteOptionalParams, + AssetsDeleteResponse, +} from "../models"; + +/// +/** Interface representing a Assets. */ +export interface Assets { + /** + * List Asset resources by subscription ID + * @param options The options parameters. + */ + listBySubscription( + options?: AssetsListBySubscriptionOptionalParams, + ): PagedAsyncIterableIterator; + /** + * List Asset resources by resource group + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + listByResourceGroup( + resourceGroupName: string, + options?: AssetsListByResourceGroupOptionalParams, + ): PagedAsyncIterableIterator; + /** + * Get a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + assetName: string, + options?: AssetsGetOptionalParams, + ): Promise; + /** + * Create a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param resource Resource create parameters. + * @param options The options parameters. + */ + beginCreateOrReplace( + resourceGroupName: string, + assetName: string, + resource: Asset, + options?: AssetsCreateOrReplaceOptionalParams, + ): Promise< + SimplePollerLike< + OperationState, + AssetsCreateOrReplaceResponse + > + >; + /** + * Create a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param resource Resource create parameters. + * @param options The options parameters. + */ + beginCreateOrReplaceAndWait( + resourceGroupName: string, + assetName: string, + resource: Asset, + options?: AssetsCreateOrReplaceOptionalParams, + ): Promise; + /** + * Update a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param properties The resource properties to be updated. + * @param options The options parameters. + */ + beginUpdate( + resourceGroupName: string, + assetName: string, + properties: AssetUpdate, + options?: AssetsUpdateOptionalParams, + ): Promise< + SimplePollerLike, AssetsUpdateResponse> + >; + /** + * Update a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param properties The resource properties to be updated. + * @param options The options parameters. + */ + beginUpdateAndWait( + resourceGroupName: string, + assetName: string, + properties: AssetUpdate, + options?: AssetsUpdateOptionalParams, + ): Promise; + /** + * Delete a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param options The options parameters. + */ + beginDelete( + resourceGroupName: string, + assetName: string, + options?: AssetsDeleteOptionalParams, + ): Promise< + SimplePollerLike, AssetsDeleteResponse> + >; + /** + * Delete a Asset + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param assetName Asset name parameter. + * @param options The options parameters. + */ + beginDeleteAndWait( + resourceGroupName: string, + assetName: string, + options?: AssetsDeleteOptionalParams, + ): Promise; +} diff --git a/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/index.ts b/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/index.ts new file mode 100644 index 00000000000..a5b6de543e8 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/index.ts @@ -0,0 +1,12 @@ +/* + * 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. + */ + +export * from "./operations"; +export * from "./assetEndpointProfiles"; +export * from "./assets"; +export * from "./operationStatus"; diff --git a/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/operationStatus.ts b/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/operationStatus.ts new file mode 100644 index 00000000000..e2a1a2c1cda --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/operationStatus.ts @@ -0,0 +1,27 @@ +/* + * 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 { + OperationStatusGetOptionalParams, + OperationStatusGetResponse, +} from "../models"; + +/** Interface representing a OperationStatus. */ +export interface OperationStatus { + /** + * Returns the current status of an async operation. + * @param location The name of Azure region. + * @param operationId The ID of an ongoing async operation. + * @param options The options parameters. + */ + get( + location: string, + operationId: string, + options?: OperationStatusGetOptionalParams, + ): Promise; +} diff --git a/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/operations.ts b/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/operations.ts new file mode 100644 index 00000000000..251f5f582e6 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/operationsInterfaces/operations.ts @@ -0,0 +1,22 @@ +/* + * 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 { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Operation, OperationsListOptionalParams } from "../models"; + +/// +/** Interface representing a Operations. */ +export interface Operations { + /** + * List the operations for the provider + * @param options The options parameters. + */ + list( + options?: OperationsListOptionalParams, + ): PagedAsyncIterableIterator; +} diff --git a/sdk/deviceregistry/arm-deviceregistry/src/pagingHelper.ts b/sdk/deviceregistry/arm-deviceregistry/src/pagingHelper.ts new file mode 100644 index 00000000000..205cccc2659 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/src/pagingHelper.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. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined, +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/deviceregistry/arm-deviceregistry/test/deviceregistry_operations_test.spec.ts b/sdk/deviceregistry/arm-deviceregistry/test/deviceregistry_operations_test.spec.ts new file mode 100644 index 00000000000..83084ba7a00 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/test/deviceregistry_operations_test.spec.ts @@ -0,0 +1,69 @@ +/* + * 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, + Recorder, + RecorderStartOptions, + delay, + isPlaybackMode, +} from "@azure-tools/test-recorder"; +import { createTestCredential } from "@azure-tools/test-credential"; +import { assert } from "chai"; +import { Context } from "mocha"; +import { DeviceRegistryManagementClient } from "../src/deviceRegistryManagementClient"; + +const replaceableVariables: Record = { + 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" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables +}; + +export const testPollingOptions = { + updateIntervalInMs: isPlaybackMode() ? 0 : undefined, +}; + +describe.skip("DeviceRegistry test", () => { + let recorder: Recorder; + let subscriptionId: string; + let client: DeviceRegistryManagementClient; + let location: string; + let resourceGroup: string; + let resourcename: string; + + beforeEach(async function (this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); + subscriptionId = env.SUBSCRIPTION_ID || ''; + // This is an example of how the environment variables are used + const credential = createTestCredential(); + client = new DeviceRegistryManagementClient(credential, subscriptionId, recorder.configureClientOptions({})); + location = "eastus"; + resourceGroup = "myjstest"; + resourcename = "resourcetest"; + + }); + + afterEach(async function () { + await recorder.stop(); + }); + + it("operations list test", async function () { + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + assert.notEqual(resArray.length, 0); + }); + +}) diff --git a/sdk/deviceregistry/arm-deviceregistry/tsconfig.json b/sdk/deviceregistry/arm-deviceregistry/tsconfig.json new file mode 100644 index 00000000000..0eb02e21367 --- /dev/null +++ b/sdk/deviceregistry/arm-deviceregistry/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "module": "es6", + "moduleResolution": "node", + "strict": true, + "target": "es6", + "sourceMap": true, + "declarationMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "lib": [ + "es6", + "dom" + ], + "declaration": true, + "outDir": "./dist-esm", + "importHelpers": true, + "paths": { + "@azure/arm-deviceregistry": [ + "./src/index" + ] + } + }, + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/deviceregistry/ci.mgmt.yml b/sdk/deviceregistry/ci.mgmt.yml new file mode 100644 index 00000000000..9ff6e9b200e --- /dev/null +++ b/sdk/deviceregistry/ci.mgmt.yml @@ -0,0 +1,38 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/deviceregistry/arm-deviceregistry + - sdk/deviceregistry/ci.mgmt.yml + +pr: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/deviceregistry/arm-deviceregistry + - sdk/deviceregistry/ci.mgmt.yml + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: deviceregistry + Artifacts: + - name: azure-arm-deviceregistry + safeName: azurearmdeviceregistry + \ No newline at end of file