diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 238dcd9310a3..263809ef2bc7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14222,24 +14222,27 @@ importers: sdk/healthbot/arm-healthbot: dependencies: + '@azure-rest/core-client': + specifier: ^2.3.1 + version: link:../../core/core-client-rest '@azure/abort-controller': specifier: ^2.1.2 version: link:../../core/abort-controller '@azure/core-auth': specifier: ^1.9.0 version: link:../../core/core-auth - '@azure/core-client': - specifier: ^1.9.2 - version: link:../../core/core-client '@azure/core-lro': - specifier: ^2.2.0 - version: 2.7.2 - '@azure/core-paging': - specifier: ^1.6.2 - version: link:../../core/core-paging + specifier: ^3.1.0 + version: link:../../core/core-lro '@azure/core-rest-pipeline': - specifier: ^1.18.2 + specifier: ^1.20.0 version: link:../../core/core-rest-pipeline + '@azure/core-util': + specifier: ^1.12.0 + version: link:../../core/core-util + '@azure/logger': + specifier: ^1.2.0 + version: link:../../core/logger tslib: specifier: ^2.8.1 version: 2.8.1 @@ -14256,12 +14259,12 @@ importers: '@azure/dev-tool': specifier: workspace:^ version: link:../../../common/tools/dev-tool + '@azure/eslint-plugin-azure-sdk': + specifier: workspace:^ + version: link:../../../common/tools/eslint-plugin-azure-sdk '@azure/identity': specifier: catalog:internal version: 4.13.0 - '@azure/logger': - specifier: ^1.1.4 - version: link:../../core/logger '@types/node': specifier: 'catalog:' version: 20.19.30 @@ -14274,9 +14277,18 @@ importers: cross-env: specifier: 'catalog:' version: 10.1.0 + dotenv: + specifier: catalog:testing + version: 16.6.1 + eslint: + specifier: 'catalog:' + version: 9.39.2 playwright: specifier: catalog:testing version: 1.58.0 + prettier: + specifier: 'catalog:' + version: 3.8.1 rimraf: specifier: 'catalog:' version: 6.1.2 diff --git a/sdk/healthbot/arm-healthbot/CHANGELOG.md b/sdk/healthbot/arm-healthbot/CHANGELOG.md index df01c61a2268..d6ca840b589c 100644 --- a/sdk/healthbot/arm-healthbot/CHANGELOG.md +++ b/sdk/healthbot/arm-healthbot/CHANGELOG.md @@ -1,21 +1,40 @@ # Release History -## 2.1.2 (Unreleased) +## 3.0.0 (2026-01-22) ### Features Added + - Added operation BotsOperations.beginUpdate + - Added operation BotsOperations.beginUpdateAndWait + - Added operation BotsOperations.create + - Added operation BotsOperations.delete + - Added operation BotsOperations.listSecrets + - Added operation BotsOperations.regenerateApiJwtSecret + - Added interface HealthBotKey + - Added interface HealthBotKeysResponse + - Added interface KeyVaultProperties + - Interface HealthBotProperties has a new optional parameter accessControlMethod + - Interface HealthBotProperties has a new optional parameter keyVaultProperties + - Interface HealthBotUpdateParameters has a new optional parameter properties + - Added support for Azure cloud environment selection + - Added type CreatedByType ### Breaking Changes + - Operation Bots.beginCreate has a new signature + - Operation Bots.beginCreateAndWait has a new signature + - Operation Bots.get has a new signature + - Operation Bots.update has a new signature + - Removed interface AvailableOperations + - Removed interface BotResponseList + - Removed type alias IdentityType + - Type alias SkuName has been changed + - Removed enum KnownIdentityType + - Long-running operations now return PollerLike instead of SimplePollerLike + - Rehydration moved from an operation option (resumeFrom) to a client-level helper restorePoller function + - Replaced getContinuationToken helper with direct continuationToken property + +**Note:** This release includes migration-related changes. See the [migration guide](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/migration-guide-for-libraries-generated-from-TypeSpec.md) for details on migrating from previous versions. -### Bugs Fixed - -### Other Changes - -## 2.1.1 (2025-08-22) - -### Other Changes - - - Other fixes - + ## 2.1.0 (2022-11-25) ### Features Added @@ -32,4 +51,4 @@ To understand the detail of the change, please refer to [Changelog](https://aka. To migrate the existing applications to the latest version, please refer to [Migration Guide](https://aka.ms/js-track2-migration-guide). -To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/js/mgmt/quickstart ). +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/js/mgmt/quickstart). diff --git a/sdk/healthbot/arm-healthbot/LICENSE b/sdk/healthbot/arm-healthbot/LICENSE index b2f52a2bad4e..63447fd8bbbf 100644 --- a/sdk/healthbot/arm-healthbot/LICENSE +++ b/sdk/healthbot/arm-healthbot/LICENSE @@ -18,4 +18,4 @@ 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. +SOFTWARE. \ No newline at end of file diff --git a/sdk/healthbot/arm-healthbot/README.md b/sdk/healthbot/arm-healthbot/README.md index 21b1c226eebe..710390e741cf 100644 --- a/sdk/healthbot/arm-healthbot/README.md +++ b/sdk/healthbot/arm-healthbot/README.md @@ -4,10 +4,12 @@ This package contains an isomorphic SDK (runs both in Node.js and in browsers) f Azure Health Bot is a cloud platform that empowers developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual health assistants and health bots, that help them improve processes and reduce costs. -[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/healthbot/arm-healthbot) | -[Package (NPM)](https://www.npmjs.com/package/@azure/arm-healthbot) | -[API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-healthbot) | -[Samples](https://github.com/Azure-Samples/azure-samples-js-management) +Key links: + +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/healthbot/arm-healthbot) +- [Package (NPM)](https://www.npmjs.com/package/@azure/arm-healthbot) +- [API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-healthbot) +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/healthbot/arm-healthbot/samples) ## Getting started @@ -44,7 +46,6 @@ npm install @azure/identity ``` You will also need to **register a new AAD application and grant access to Azure Healthbot** 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://learn.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). @@ -64,16 +65,16 @@ For browser environments, use the `InteractiveBrowserCredential` from the `@azur import { InteractiveBrowserCredential } from "@azure/identity"; import { HealthbotClient } from "@azure/arm-healthbot"; -const subscriptionId = "00000000-0000-0000-0000-000000000000"; const credential = new InteractiveBrowserCredential({ tenantId: "", clientId: "", }); +const subscriptionId = "00000000-0000-0000-0000-000000000000"; const client = new HealthbotClient(credential, subscriptionId); ``` -### JavaScript Bundle +### 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 @@ -98,7 +99,7 @@ For more detailed instructions on how to enable logs, you can look at the [@azur ## 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. +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/healthbot/arm-healthbot/samples) directory for detailed examples on how to use this library. ## Contributing @@ -108,8 +109,6 @@ If you'd like to contribute to this library, please read the [contributing guide - [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) -[azure_cli]: https://learn.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 diff --git a/sdk/healthbot/arm-healthbot/_meta.json b/sdk/healthbot/arm-healthbot/_meta.json deleted file mode 100644 index 56c411411aa4..000000000000 --- a/sdk/healthbot/arm-healthbot/_meta.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "commit": "1f1d5b0b9ce6cc94605b2fd619dce374fb6e033a", - "readme": "specification\\healthbot\\resource-manager\\readme.md", - "autorest_command": "autorest --version=3.8.4 --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\\healthbot\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.3.20221108.1 --generate-sample=true", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.4.2", - "use": "@autorest/typescript@6.0.0-rc.3.20221108.1" -} diff --git a/sdk/healthbot/arm-healthbot/api-extractor.json b/sdk/healthbot/arm-healthbot/api-extractor.json index 16d81e2eb512..870d6d399477 100644 --- a/sdk/healthbot/arm-healthbot/api-extractor.json +++ b/sdk/healthbot/arm-healthbot/api-extractor.json @@ -1,3 +1 @@ -{ - "extends": "../../../api-extractor-base.json" -} +{ "extends": "../../../api-extractor-base.json" } diff --git a/sdk/healthbot/arm-healthbot/assets.json b/sdk/healthbot/arm-healthbot/assets.json deleted file mode 100644 index d43c1d74df4b..000000000000 --- a/sdk/healthbot/arm-healthbot/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "js", - "TagPrefix": "js/healthbot/arm-healthbot", - "Tag": "js/healthbot/arm-healthbot_01d2179c38" -} diff --git a/sdk/healthbot/arm-healthbot/eslint.config.mjs b/sdk/healthbot/arm-healthbot/eslint.config.mjs new file mode 100644 index 000000000000..6d2f8a5914c3 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/eslint.config.mjs @@ -0,0 +1,14 @@ +import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; + +export default azsdkEslint.config([ + { + rules: { + "@azure/azure-sdk/ts-modules-only-named": "warn", + "@azure/azure-sdk/ts-package-json-types": "warn", + "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", + "@azure/azure-sdk/ts-package-json-files-required": "off", + "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", + "tsdoc/syntax": "warn", + }, + }, +]); diff --git a/sdk/healthbot/arm-healthbot/metadata.json b/sdk/healthbot/arm-healthbot/metadata.json new file mode 100644 index 000000000000..6dee0a967e91 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/metadata.json @@ -0,0 +1,44 @@ +{ + "apiVersion": "2025-11-01", + "emitterVersion": "0.47.1", + "crossLanguageDefinitions": { + "CrossLanguagePackageId": "Microsoft.HealthBot", + "CrossLanguageDefinitionId": { + "@azure/arm-healthbot!AvailableOperations:interface": "Microsoft.HealthBot.AvailableOperations", + "@azure/arm-healthbot!OperationDetail:interface": "Microsoft.HealthBot.OperationDetail", + "@azure/arm-healthbot!OperationDisplay:interface": "Microsoft.HealthBot.OperationDisplay", + "@azure/arm-healthbot!Error:interface": "Microsoft.HealthBot.Error", + "@azure/arm-healthbot!ErrorError:interface": "Microsoft.HealthBot.ErrorDetail", + "@azure/arm-healthbot!ErrorAdditionalInfo:interface": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "@azure/arm-healthbot!HealthBot:interface": "Microsoft.HealthBot.HealthBot", + "@azure/arm-healthbot!HealthBotProperties:interface": "Microsoft.HealthBot.HealthBotProperties", + "@azure/arm-healthbot!KeyVaultProperties:interface": "Microsoft.HealthBot.KeyVaultProperties", + "@azure/arm-healthbot!Sku:interface": "Microsoft.HealthBot.Sku", + "@azure/arm-healthbot!Identity:interface": "Microsoft.HealthBot.Identity", + "@azure/arm-healthbot!UserAssignedIdentity:interface": "Microsoft.HealthBot.UserAssignedIdentity", + "@azure/arm-healthbot!TrackedResource:interface": "Azure.ResourceManager.CommonTypes.TrackedResource", + "@azure/arm-healthbot!Resource:interface": "Azure.ResourceManager.CommonTypes.Resource", + "@azure/arm-healthbot!SystemData:interface": "Azure.ResourceManager.CommonTypes.SystemData", + "@azure/arm-healthbot!ArmOperationStatusResourceProvisioningState:interface": "Azure.ResourceManager.ArmOperationStatus", + "@azure/arm-healthbot!ErrorDetail:interface": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "@azure/arm-healthbot!HealthBotUpdateParameters:interface": "Microsoft.HealthBot.HealthBotUpdateParameters", + "@azure/arm-healthbot!BotResponseList:interface": "Microsoft.HealthBot.BotResponseList", + "@azure/arm-healthbot!HealthBotKeysResponse:interface": "Microsoft.HealthBot.HealthBotKeysResponse", + "@azure/arm-healthbot!HealthBotKey:interface": "Microsoft.HealthBot.HealthBotKey", + "@azure/arm-healthbot!KnownSkuName:enum": "Microsoft.HealthBot.SkuName", + "@azure/arm-healthbot!KnownResourceIdentityType:enum": "Microsoft.HealthBot.ResourceIdentityType", + "@azure/arm-healthbot!KnowncreatedByType:enum": "Azure.ResourceManager.CommonTypes.createdByType", + "@azure/arm-healthbot!KnownResourceProvisioningState:enum": "Azure.ResourceManager.ResourceProvisioningState", + "@azure/arm-healthbot!KnownVersions:enum": "Microsoft.HealthBot.Versions", + "@azure/arm-healthbot!BotsOperations#regenerateApiJwtSecret:member": "Microsoft.HealthBot.HealthBots.regenerateApiJwtSecret", + "@azure/arm-healthbot!BotsOperations#listSecrets:member": "Microsoft.HealthBot.HealthBots.listSecrets", + "@azure/arm-healthbot!BotsOperations#list:member": "Microsoft.HealthBot.HealthBots.list", + "@azure/arm-healthbot!BotsOperations#listByResourceGroup:member": "Microsoft.HealthBot.HealthBots.listByResourceGroup", + "@azure/arm-healthbot!BotsOperations#delete:member": "Microsoft.HealthBot.HealthBots.delete", + "@azure/arm-healthbot!BotsOperations#update:member": "Microsoft.HealthBot.HealthBots.update", + "@azure/arm-healthbot!BotsOperations#create:member": "Microsoft.HealthBot.HealthBots.create", + "@azure/arm-healthbot!BotsOperations#get:member": "Microsoft.HealthBot.HealthBots.get", + "@azure/arm-healthbot!OperationsOperations#list:member": "Azure.ResourceManager.Legacy.Operations.list" + } + } +} diff --git a/sdk/healthbot/arm-healthbot/package.json b/sdk/healthbot/arm-healthbot/package.json index 85b84e02cf6e..13b7142ee327 100644 --- a/sdk/healthbot/arm-healthbot/package.json +++ b/sdk/healthbot/arm-healthbot/package.json @@ -1,114 +1,122 @@ { "name": "@azure/arm-healthbot", - "sdk-type": "mgmt", - "author": "Microsoft Corporation", + "version": "3.0.0", "description": "A generated SDK for HealthbotClient.", - "version": "2.1.2", "engines": { "node": ">=20.0.0" }, - "dependencies": { - "@azure/abort-controller": "^2.1.2", - "@azure/core-auth": "^1.9.0", - "@azure/core-client": "^1.9.2", - "@azure/core-lro": "^2.2.0", - "@azure/core-paging": "^1.6.2", - "@azure/core-rest-pipeline": "^1.18.2", - "tslib": "^2.8.1" + "sideEffects": false, + "autoPublish": false, + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./api": "./src/api/index.ts", + "./api/bots": "./src/api/bots/index.ts", + "./api/operations": "./src/api/operations/index.ts", + "./models": "./src/models/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false, + "project": "../../../tsconfig.src.build.json" }, + "type": "module", + "browser": "./dist/browser/index.js", + "react-native": "./dist/react-native/index.js", "keywords": [ "node", "azure", + "cloud", "typescript", "browser", - "isomorphic", - "cloud" + "isomorphic" ], + "author": "Microsoft Corporation", "license": "MIT", - "main": "./dist/commonjs/index.js", - "module": "./dist/esm/index.js", - "types": "./dist/commonjs/index.d.ts", + "files": [ + "dist/", + "!dist/**/*.d.*ts.map", + "README.md", + "LICENSE" + ], + "sdk-type": "mgmt", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/healthbot/arm-healthbot/README.md", + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "//metadata": { + "constantPaths": [ + { + "path": "src/api/healthbotContext.ts", + "prefix": "userAgentInfo" + } + ] + }, + "dependencies": { + "@azure/core-util": "^1.12.0", + "@azure-rest/core-client": "^2.3.1", + "@azure/abort-controller": "^2.1.2", + "@azure/core-auth": "^1.9.0", + "@azure/core-lro": "^3.1.0", + "@azure/core-rest-pipeline": "^1.20.0", + "@azure/logger": "^1.2.0", + "tslib": "^2.8.1" + }, "devDependencies": { "@azure-tools/test-credential": "workspace:^", "@azure-tools/test-recorder": "workspace:^", "@azure-tools/test-utils-vitest": "workspace:^", "@azure/dev-tool": "workspace:^", + "tshy": "catalog:", + "@azure/eslint-plugin-azure-sdk": "workspace:^", "@azure/identity": "catalog:internal", - "@azure/logger": "^1.1.4", "@types/node": "catalog:", + "cross-env": "catalog:", + "eslint": "catalog:", + "prettier": "catalog:", + "rimraf": "catalog:", "@vitest/browser-playwright": "catalog:testing", "@vitest/coverage-istanbul": "catalog:testing", - "cross-env": "catalog:", + "dotenv": "catalog:testing", "playwright": "catalog:testing", - "rimraf": "catalog:", - "tshy": "catalog:", "typescript": "catalog:", "vitest": "catalog:testing" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/healthbot/arm-healthbot", - "repository": "github:Azure/azure-sdk-for-js", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "files": [ - "dist/", - "README.md", - "LICENSE", - "review/", - "CHANGELOG.md" - ], "scripts": { - "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", - "build:samples": "tsc -p tsconfig.samples.json && dev-tool samples publish -f", - "check-format": "echo skipped", "clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", - "execute:samples": "echo skipped", - "extract-api": "dev-tool run extract-api", - "format": "echo skipped", - "lint": "echo skipped", + "extract-api": "rimraf review && dev-tool run extract-api", "pack": "pnpm pack 2>&1", + "lint": "echo skipped", + "lint:fix": "echo skipped", + "build:samples": "tsc -p tsconfig.samples.json && dev-tool samples publish -f", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "execute:samples": "dev-tool samples run samples-dev", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "generate:client": "echo skipped", + "test:browser": "dev-tool run build-test && dev-tool run test:vitest --browser", + "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", + "test:node": "dev-tool run test:vitest", + "test:node:esm": "dev-tool run test:vitest --esm", "test": "npm run test:node && npm run test:browser", - "test:browser": "echo skipped", - "test:node": "dev-tool run build-test --no-browser-test && dev-tool run test:vitest", "update-snippets": "dev-tool run update-snippets" }, - "sideEffects": false, - "//metadata": { - "constantPaths": [ - { - "path": "src/healthbotClient.ts", - "prefix": "packageDetails" - } - ] - }, - "autoPublish": true, "//sampleConfiguration": { - "productName": "", + "productName": "@azure/arm-healthbot", "productSlugs": [ "azure" ], "disableDocsMs": true, "apiRefLink": "https://learn.microsoft.com/javascript/api/@azure/arm-healthbot?view=azure-node-preview" }, - "type": "module", - "tshy": { - "project": "../../../tsconfig.src.build.json", - "exports": { - "./package.json": "./package.json", - ".": "./src/index.ts" - }, - "dialects": [ - "esm", - "commonjs" - ], - "esmDialects": [ - "browser", - "react-native" - ], - "selfLink": false - }, - "browser": "./dist/browser/index.js", - "react-native": "./dist/react-native/index.js", "exports": { "./package.json": "./package.json", ".": { @@ -128,6 +136,81 @@ "types": "./dist/commonjs/index.d.ts", "default": "./dist/commonjs/index.js" } + }, + "./api": { + "browser": { + "types": "./dist/browser/api/index.d.ts", + "default": "./dist/browser/api/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/index.d.ts", + "default": "./dist/react-native/api/index.js" + }, + "import": { + "types": "./dist/esm/api/index.d.ts", + "default": "./dist/esm/api/index.js" + }, + "require": { + "types": "./dist/commonjs/api/index.d.ts", + "default": "./dist/commonjs/api/index.js" + } + }, + "./api/bots": { + "browser": { + "types": "./dist/browser/api/bots/index.d.ts", + "default": "./dist/browser/api/bots/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/bots/index.d.ts", + "default": "./dist/react-native/api/bots/index.js" + }, + "import": { + "types": "./dist/esm/api/bots/index.d.ts", + "default": "./dist/esm/api/bots/index.js" + }, + "require": { + "types": "./dist/commonjs/api/bots/index.d.ts", + "default": "./dist/commonjs/api/bots/index.js" + } + }, + "./api/operations": { + "browser": { + "types": "./dist/browser/api/operations/index.d.ts", + "default": "./dist/browser/api/operations/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/operations/index.d.ts", + "default": "./dist/react-native/api/operations/index.js" + }, + "import": { + "types": "./dist/esm/api/operations/index.d.ts", + "default": "./dist/esm/api/operations/index.js" + }, + "require": { + "types": "./dist/commonjs/api/operations/index.d.ts", + "default": "./dist/commonjs/api/operations/index.js" + } + }, + "./models": { + "browser": { + "types": "./dist/browser/models/index.d.ts", + "default": "./dist/browser/models/index.js" + }, + "react-native": { + "types": "./dist/react-native/models/index.d.ts", + "default": "./dist/react-native/models/index.js" + }, + "import": { + "types": "./dist/esm/models/index.d.ts", + "default": "./dist/esm/models/index.js" + }, + "require": { + "types": "./dist/commonjs/models/index.d.ts", + "default": "./dist/commonjs/models/index.js" + } } - } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts", + "module": "./dist/esm/index.js" } diff --git a/sdk/healthbot/arm-healthbot/review/arm-healthbot-api-bots-node.api.md b/sdk/healthbot/arm-healthbot/review/arm-healthbot-api-bots-node.api.md new file mode 100644 index 000000000000..0a35631b8b24 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/review/arm-healthbot-api-bots-node.api.md @@ -0,0 +1,73 @@ +## API Report File for "@azure/arm-healthbot" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; +import type { OperationState } from '@azure/core-lro'; +import type { PollerLike } from '@azure/core-lro'; + +// @public +export function $delete(context: HealthbotContext, resourceGroupName: string, botName: string, options?: BotsDeleteOptionalParams): PollerLike, void>; + +// @public +export interface BotsCreateOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface BotsDeleteOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface BotsGetOptionalParams extends OperationOptions { +} + +// @public +export interface BotsListByResourceGroupOptionalParams extends OperationOptions { +} + +// @public +export interface BotsListOptionalParams extends OperationOptions { +} + +// @public +export interface BotsListSecretsOptionalParams extends OperationOptions { +} + +// @public +export interface BotsRegenerateApiJwtSecretOptionalParams extends OperationOptions { +} + +// @public +export interface BotsUpdateOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export function create(context: HealthbotContext, resourceGroupName: string, botName: string, parameters: HealthBot, options?: BotsCreateOptionalParams): PollerLike, HealthBot>; + +// @public +export function get(context: HealthbotContext, resourceGroupName: string, botName: string, options?: BotsGetOptionalParams): Promise; + +// @public +export function list(context: HealthbotContext, options?: BotsListOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listByResourceGroup(context: HealthbotContext, resourceGroupName: string, options?: BotsListByResourceGroupOptionalParams): PagedAsyncIterableIterator; + +// @public +export function listSecrets(context: HealthbotContext, resourceGroupName: string, botName: string, options?: BotsListSecretsOptionalParams): Promise; + +// @public +export function regenerateApiJwtSecret(context: HealthbotContext, resourceGroupName: string, botName: string, options?: BotsRegenerateApiJwtSecretOptionalParams): Promise; + +// @public +export function update(context: HealthbotContext, resourceGroupName: string, botName: string, parameters: HealthBotUpdateParameters, options?: BotsUpdateOptionalParams): PollerLike, HealthBot>; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/healthbot/arm-healthbot/review/arm-healthbot-api-node.api.md b/sdk/healthbot/arm-healthbot/review/arm-healthbot-api-node.api.md new file mode 100644 index 000000000000..5a5966b1ac95 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/review/arm-healthbot-api-node.api.md @@ -0,0 +1,28 @@ +## API Report File for "@azure/arm-healthbot" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { ClientOptions } from '@azure-rest/core-client'; +import type { TokenCredential } from '@azure/core-auth'; + +// @public +export function createHealthbot(credential: TokenCredential, subscriptionId: string, options?: HealthbotClientOptionalParams): HealthbotContext; + +// @public +export interface HealthbotClientOptionalParams extends ClientOptions { + apiVersion?: string; + cloudSetting?: AzureSupportedClouds; +} + +// @public +export interface HealthbotContext extends Client { + apiVersion: string; + subscriptionId: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/healthbot/arm-healthbot/review/arm-healthbot-api-operations-node.api.md b/sdk/healthbot/arm-healthbot/review/arm-healthbot-api-operations-node.api.md new file mode 100644 index 000000000000..99ec97c40377 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/review/arm-healthbot-api-operations-node.api.md @@ -0,0 +1,19 @@ +## API Report File for "@azure/arm-healthbot" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export function list(context: HealthbotContext, options?: OperationsListOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface OperationsListOptionalParams extends OperationOptions { +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/healthbot/arm-healthbot/review/arm-healthbot-models-node.api.md b/sdk/healthbot/arm-healthbot/review/arm-healthbot-models-node.api.md new file mode 100644 index 000000000000..68f4a05c9754 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/review/arm-healthbot-models-node.api.md @@ -0,0 +1,156 @@ +## API Report File for "@azure/arm-healthbot" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +// @public +export type CreatedByType = string; + +// @public +export interface ErrorAdditionalInfo { + readonly info?: any; + readonly type?: string; +} + +// @public +export interface ErrorError { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorModel[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorModel { + error?: ErrorError; +} + +// @public +export interface HealthBot extends TrackedResource { + identity?: Identity; + properties?: HealthBotProperties; + sku: Sku; +} + +// @public +export interface HealthBotKey { + keyName?: string; + value?: string; +} + +// @public +export interface HealthBotKeysResponse { + secrets?: HealthBotKey[]; +} + +// @public +export interface HealthBotProperties { + readonly accessControlMethod?: string; + readonly botManagementPortalLink?: string; + keyVaultProperties?: KeyVaultProperties; + readonly provisioningState?: string; +} + +// @public +export interface HealthBotUpdateParameters { + identity?: Identity; + // (undocumented) + location?: string; + properties?: HealthBotProperties; + sku?: Sku; + tags?: Record; +} + +// @public +export interface Identity { + readonly principalId?: string; + readonly tenantId?: string; + type?: ResourceIdentityType; + userAssignedIdentities?: Record; +} + +// @public +export interface KeyVaultProperties { + keyName: string; + keyVaultUri: string; + keyVersion?: string; + userIdentity?: string; +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownVersions { + V20250525 = "2025-05-25", + V20251101 = "2025-11-01" +} + +// @public +export interface OperationDetail { + display?: OperationDisplay; + isDataAction?: boolean; + name?: string; + origin?: string; + properties?: any; +} + +// @public +export interface OperationDisplay { + description?: string; + operation?: string; + provider?: string; + resource?: string; +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export type ResourceIdentityType = "SystemAssigned" | "UserAssigned" | "SystemAssigned, UserAssigned" | "None"; + +// @public +export interface Sku { + name: SkuName; +} + +// @public +export type SkuName = "F0" | "C0" | "PES" | "C1"; + +// @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?: Record; +} + +// @public +export interface UserAssignedIdentity { + readonly clientId?: string; + readonly principalId?: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/healthbot/arm-healthbot/review/arm-healthbot-node.api.md b/sdk/healthbot/arm-healthbot/review/arm-healthbot-node.api.md index 1782f5a8cc5a..95a7d7e0e56a 100644 --- a/sdk/healthbot/arm-healthbot/review/arm-healthbot-node.api.md +++ b/sdk/healthbot/arm-healthbot/review/arm-healthbot-node.api.md @@ -4,96 +4,96 @@ ```ts -import * as coreAuth from '@azure/core-auth'; -import * as coreClient from '@azure/core-client'; -import { PagedAsyncIterableIterator } from '@azure/core-paging'; -import { PollerLike } from '@azure/core-lro'; -import { PollOperationState } from '@azure/core-lro'; +import type { AbortSignalLike } from '@azure/abort-controller'; +import type { CancelOnProgress } from '@azure/core-lro'; +import type { ClientOptions } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; +import type { OperationState } from '@azure/core-lro'; +import type { PathUncheckedResponse } from '@azure-rest/core-client'; +import type { Pipeline } from '@azure/core-rest-pipeline'; +import type { PollerLike } from '@azure/core-lro'; +import type { TokenCredential } from '@azure/core-auth'; // @public -export interface AvailableOperations { - nextLink?: string; - value?: OperationDetail[]; +export enum AzureClouds { + AZURE_CHINA_CLOUD = "AZURE_CHINA_CLOUD", + AZURE_PUBLIC_CLOUD = "AZURE_PUBLIC_CLOUD", + AZURE_US_GOVERNMENT = "AZURE_US_GOVERNMENT" } // @public -export interface BotResponseList { - readonly nextLink?: string; - readonly value?: HealthBot[]; -} - -// @public -export interface Bots { - beginCreate(resourceGroupName: string, botName: string, parameters: HealthBot, options?: BotsCreateOptionalParams): Promise, BotsCreateResponse>>; - beginCreateAndWait(resourceGroupName: string, botName: string, parameters: HealthBot, options?: BotsCreateOptionalParams): Promise; - beginDelete(resourceGroupName: string, botName: string, options?: BotsDeleteOptionalParams): Promise, void>>; - beginDeleteAndWait(resourceGroupName: string, botName: string, options?: BotsDeleteOptionalParams): Promise; - get(resourceGroupName: string, botName: string, options?: BotsGetOptionalParams): Promise; - list(options?: BotsListOptionalParams): PagedAsyncIterableIterator; - listByResourceGroup(resourceGroupName: string, options?: BotsListByResourceGroupOptionalParams): PagedAsyncIterableIterator; - update(resourceGroupName: string, botName: string, parameters: HealthBotUpdateParameters, options?: BotsUpdateOptionalParams): Promise; -} +export type AzureSupportedClouds = `${AzureClouds}`; // @public -export interface BotsCreateOptionalParams extends coreClient.OperationOptions { - resumeFrom?: string; +export interface BotsCreateOptionalParams extends OperationOptions { updateIntervalInMs?: number; } // @public -export type BotsCreateResponse = HealthBot; - -// @public -export interface BotsDeleteOptionalParams extends coreClient.OperationOptions { - resumeFrom?: string; +export interface BotsDeleteOptionalParams extends OperationOptions { updateIntervalInMs?: number; } // @public -export interface BotsGetOptionalParams extends coreClient.OperationOptions { +export interface BotsGetOptionalParams extends OperationOptions { } // @public -export type BotsGetResponse = HealthBot; - -// @public -export interface BotsListByResourceGroupNextOptionalParams extends coreClient.OperationOptions { +export interface BotsListByResourceGroupOptionalParams extends OperationOptions { } // @public -export type BotsListByResourceGroupNextResponse = BotResponseList; - -// @public -export interface BotsListByResourceGroupOptionalParams extends coreClient.OperationOptions { +export interface BotsListOptionalParams extends OperationOptions { } // @public -export type BotsListByResourceGroupResponse = BotResponseList; - -// @public -export interface BotsListNextOptionalParams extends coreClient.OperationOptions { +export interface BotsListSecretsOptionalParams extends OperationOptions { } // @public -export type BotsListNextResponse = BotResponseList; +export interface BotsOperations { + // @deprecated (undocumented) + beginCreate: (resourceGroupName: string, botName: string, parameters: HealthBot, options?: BotsCreateOptionalParams) => Promise, HealthBot>>; + // @deprecated (undocumented) + beginCreateAndWait: (resourceGroupName: string, botName: string, parameters: HealthBot, options?: BotsCreateOptionalParams) => Promise; + // @deprecated (undocumented) + beginDelete: (resourceGroupName: string, botName: string, options?: BotsDeleteOptionalParams) => Promise, void>>; + // @deprecated (undocumented) + beginDeleteAndWait: (resourceGroupName: string, botName: string, options?: BotsDeleteOptionalParams) => Promise; + // @deprecated (undocumented) + beginUpdate: (resourceGroupName: string, botName: string, parameters: HealthBotUpdateParameters, options?: BotsUpdateOptionalParams) => Promise, HealthBot>>; + // @deprecated (undocumented) + beginUpdateAndWait: (resourceGroupName: string, botName: string, parameters: HealthBotUpdateParameters, options?: BotsUpdateOptionalParams) => Promise; + create: (resourceGroupName: string, botName: string, parameters: HealthBot, options?: BotsCreateOptionalParams) => PollerLike, HealthBot>; + delete: (resourceGroupName: string, botName: string, options?: BotsDeleteOptionalParams) => PollerLike, void>; + get: (resourceGroupName: string, botName: string, options?: BotsGetOptionalParams) => Promise; + list: (options?: BotsListOptionalParams) => PagedAsyncIterableIterator; + listByResourceGroup: (resourceGroupName: string, options?: BotsListByResourceGroupOptionalParams) => PagedAsyncIterableIterator; + listSecrets: (resourceGroupName: string, botName: string, options?: BotsListSecretsOptionalParams) => Promise; + regenerateApiJwtSecret: (resourceGroupName: string, botName: string, options?: BotsRegenerateApiJwtSecretOptionalParams) => Promise; + update: (resourceGroupName: string, botName: string, parameters: HealthBotUpdateParameters, options?: BotsUpdateOptionalParams) => PollerLike, HealthBot>; +} // @public -export interface BotsListOptionalParams extends coreClient.OperationOptions { +export interface BotsRegenerateApiJwtSecretOptionalParams extends OperationOptions { } // @public -export type BotsListResponse = BotResponseList; +export interface BotsUpdateOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} // @public -export interface BotsUpdateOptionalParams extends coreClient.OperationOptions { -} +export type ContinuablePage = TPage & { + continuationToken?: string; +}; // @public -export type BotsUpdateResponse = HealthBot; +export type CreatedByType = string; // @public export interface ErrorAdditionalInfo { - readonly info?: Record; + readonly info?: any; readonly type?: string; } @@ -111,9 +111,6 @@ export interface ErrorModel { error?: ErrorError; } -// @public -export function getContinuationToken(page: unknown): string | undefined; - // @public export interface HealthBot extends TrackedResource { identity?: Identity; @@ -122,30 +119,36 @@ export interface HealthBot extends TrackedResource { } // @public (undocumented) -export class HealthbotClient extends coreClient.ServiceClient { - // (undocumented) - $host: string; - constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: HealthbotClientOptionalParams); - // (undocumented) - apiVersion: string; - // (undocumented) - bots: Bots; - // (undocumented) - operations: Operations; - // (undocumented) - subscriptionId: string; +export class HealthbotClient { + constructor(credential: TokenCredential, options?: HealthbotClientOptionalParams); + constructor(credential: TokenCredential, subscriptionId: string, options?: HealthbotClientOptionalParams); + readonly bots: BotsOperations; + readonly operations: OperationsOperations; + readonly pipeline: Pipeline; } // @public -export interface HealthbotClientOptionalParams extends coreClient.ServiceClientOptions { - $host?: string; +export interface HealthbotClientOptionalParams extends ClientOptions { apiVersion?: string; - endpoint?: string; + cloudSetting?: AzureSupportedClouds; +} + +// @public +export interface HealthBotKey { + keyName?: string; + value?: string; +} + +// @public +export interface HealthBotKeysResponse { + secrets?: HealthBotKey[]; } // @public export interface HealthBotProperties { + readonly accessControlMethod?: string; readonly botManagementPortalLink?: string; + keyVaultProperties?: KeyVaultProperties; readonly provisioningState?: string; } @@ -154,10 +157,9 @@ export interface HealthBotUpdateParameters { identity?: Identity; // (undocumented) location?: string; + properties?: HealthBotProperties; sku?: Sku; - tags?: { - [propertyName: string]: string; - }; + tags?: Record; } // @public @@ -165,29 +167,38 @@ export interface Identity { readonly principalId?: string; readonly tenantId?: string; type?: ResourceIdentityType; - userAssignedIdentities?: { - [propertyName: string]: UserAssignedIdentity; - }; + userAssignedIdentities?: Record; } // @public -export type IdentityType = string; +export interface KeyVaultProperties { + keyName: string; + keyVaultUri: string; + keyVersion?: string; + userIdentity?: string; +} // @public -export enum KnownIdentityType { +export enum KnownCreatedByType { Application = "Application", Key = "Key", ManagedIdentity = "ManagedIdentity", User = "User" } +// @public +export enum KnownVersions { + V20250525 = "2025-05-25", + V20251101 = "2025-11-01" +} + // @public export interface OperationDetail { display?: OperationDisplay; isDataAction?: boolean; name?: string; origin?: string; - properties?: Record; + properties?: any; } // @public @@ -199,23 +210,25 @@ export interface OperationDisplay { } // @public -export interface Operations { - list(options?: OperationsListOptionalParams): PagedAsyncIterableIterator; +export interface OperationsListOptionalParams extends OperationOptions { } // @public -export interface OperationsListNextOptionalParams extends coreClient.OperationOptions { +export interface OperationsOperations { + list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; } // @public -export type OperationsListNextResponse = AvailableOperations; - -// @public -export interface OperationsListOptionalParams extends coreClient.OperationOptions { +export interface PagedAsyncIterableIterator { + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; + next(): Promise>; } // @public -export type OperationsListResponse = AvailableOperations; +export interface PageSettings { + continuationToken?: string; +} // @public export interface Resource { @@ -228,30 +241,60 @@ export interface Resource { // @public export type ResourceIdentityType = "SystemAssigned" | "UserAssigned" | "SystemAssigned, UserAssigned" | "None"; +// @public +export function restorePoller(client: HealthbotClient, serializedState: string, sourceOperation: (...args: any[]) => PollerLike, TResult>, options?: RestorePollerOptions): PollerLike, TResult>; + +// @public (undocumented) +export interface RestorePollerOptions extends OperationOptions { + abortSignal?: AbortSignalLike; + processResponseBody?: (result: TResponse) => Promise; + updateIntervalInMs?: number; +} + +// @public +export interface SimplePollerLike, TResult> { + getOperationState(): TState; + getResult(): TResult | undefined; + isDone(): boolean; + // @deprecated + isStopped(): boolean; + onProgress(callback: (state: TState) => void): CancelOnProgress; + poll(options?: { + abortSignal?: AbortSignalLike; + }): Promise; + pollUntilDone(pollOptions?: { + abortSignal?: AbortSignalLike; + }): Promise; + serialize(): Promise; + // @deprecated + stopPolling(): void; + submitted(): Promise; + // @deprecated + toString(): string; +} + // @public export interface Sku { name: SkuName; } // @public -export type SkuName = "F0" | "S1" | "C0"; +export type SkuName = "F0" | "C0" | "PES" | "C1"; // @public export interface SystemData { createdAt?: Date; createdBy?: string; - createdByType?: IdentityType; + createdByType?: CreatedByType; lastModifiedAt?: Date; lastModifiedBy?: string; - lastModifiedByType?: IdentityType; + lastModifiedByType?: CreatedByType; } // @public export interface TrackedResource extends Resource { location: string; - tags?: { - [propertyName: string]: string; - }; + tags?: Record; } // @public @@ -260,11 +303,6 @@ export interface UserAssignedIdentity { readonly principalId?: string; } -// @public -export interface ValidationResult { - status?: string; -} - // (No @packageDocumentation comment for this package) ``` diff --git a/sdk/healthbot/arm-healthbot/sample.env b/sdk/healthbot/arm-healthbot/sample.env index 672847a3fea0..508439fc7d62 100644 --- a/sdk/healthbot/arm-healthbot/sample.env +++ b/sdk/healthbot/arm-healthbot/sample.env @@ -1,4 +1 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= \ No newline at end of file +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/healthbot/arm-healthbot/samples-dev/botsCreateSample.ts b/sdk/healthbot/arm-healthbot/samples-dev/botsCreateSample.ts index 0cbad92108c2..697b59a3ecf6 100644 --- a/sdk/healthbot/arm-healthbot/samples-dev/botsCreateSample.ts +++ b/sdk/healthbot/arm-healthbot/samples-dev/botsCreateSample.ts @@ -1,38 +1,37 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to Create a new Azure Health Bot. - * - * @summary Create a new Azure Health Bot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceCreationPut.json - */ - -import type { HealthBot } from "@azure/arm-healthbot"; import { HealthbotClient } from "@azure/arm-healthbot"; import { DefaultAzureCredential } from "@azure/identity"; +/** + * This sample demonstrates how to create a new Azure Health Bot. + * + * @summary create a new Azure Health Bot. + * x-ms-original-file: 2025-11-01/ResourceCreationPut.json + */ async function botCreate(): Promise { + const credential = new DefaultAzureCredential(); const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; - const parameters: HealthBot = { + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.create("healthbotClient", "samplebotname", { identity: { type: "SystemAssigned, UserAssigned", userAssignedIdentities: { - "/subscriptions/subscriptionId/resourcegroups/myrg/providers/microsoftManagedidentity/userassignedidentities/myMi": + "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": {}, - "/subscriptions/subscriptionId/resourcegroups/myrg/providers/microsoftManagedidentity/userassignedidentities/myMi2": + "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": {}, }, }, location: "East US", sku: { name: "F0" }, - }; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.beginCreateAndWait(resourceGroupName, botName, parameters); + }); console.log(result); } -botCreate().catch(console.error); +async function main(): Promise { + await botCreate(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples-dev/botsDeleteSample.ts b/sdk/healthbot/arm-healthbot/samples-dev/botsDeleteSample.ts index 1824a9ec5bf8..95c70e6d2c4c 100644 --- a/sdk/healthbot/arm-healthbot/samples-dev/botsDeleteSample.ts +++ b/sdk/healthbot/arm-healthbot/samples-dev/botsDeleteSample.ts @@ -1,24 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to Delete a HealthBot. - * - * @summary Delete a HealthBot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceDeletionDelete.json - */ - import { HealthbotClient } from "@azure/arm-healthbot"; import { DefaultAzureCredential } from "@azure/identity"; +/** + * This sample demonstrates how to delete a HealthBot. + * + * @summary delete a HealthBot. + * x-ms-original-file: 2025-11-01/ResourceDeletionDelete.json + */ async function botDelete(): Promise { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.beginDeleteAndWait(resourceGroupName, botName); - console.log(result); + await client.bots.delete("healthbotClient", "samplebotname"); +} + +async function main(): Promise { + await botDelete(); } -botDelete().catch(console.error); +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples-dev/botsGetSample.ts b/sdk/healthbot/arm-healthbot/samples-dev/botsGetSample.ts index dffe44516223..c16588b971bb 100644 --- a/sdk/healthbot/arm-healthbot/samples-dev/botsGetSample.ts +++ b/sdk/healthbot/arm-healthbot/samples-dev/botsGetSample.ts @@ -1,24 +1,25 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to Get a HealthBot. - * - * @summary Get a HealthBot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceInfoGet.json - */ - import { HealthbotClient } from "@azure/arm-healthbot"; import { DefaultAzureCredential } from "@azure/identity"; +/** + * This sample demonstrates how to get a HealthBot. + * + * @summary get a HealthBot. + * x-ms-original-file: 2025-11-01/ResourceInfoGet.json + */ async function resourceInfoGet(): Promise { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.get(resourceGroupName, botName); + const result = await client.bots.get("healthbotClient", "samplebotname"); console.log(result); } -resourceInfoGet().catch(console.error); +async function main(): Promise { + await resourceInfoGet(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples-dev/botsListByResourceGroupSample.ts b/sdk/healthbot/arm-healthbot/samples-dev/botsListByResourceGroupSample.ts index 4a472d55e636..f61575b709a9 100644 --- a/sdk/healthbot/arm-healthbot/samples-dev/botsListByResourceGroupSample.ts +++ b/sdk/healthbot/arm-healthbot/samples-dev/botsListByResourceGroupSample.ts @@ -1,26 +1,29 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to Returns all the resources of a particular type belonging to a resource group - * - * @summary Returns all the resources of a particular type belonging to a resource group - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ListBotsByResourceGroup.json - */ - import { HealthbotClient } from "@azure/arm-healthbot"; import { DefaultAzureCredential } from "@azure/identity"; +/** + * This sample demonstrates how to returns all the resources of a particular type belonging to a resource group + * + * @summary returns all the resources of a particular type belonging to a resource group + * x-ms-original-file: 2025-11-01/ListBotsByResourceGroup.json + */ async function listBotsByResourceGroup(): Promise { - const subscriptionId = "subscription-id"; - const resourceGroupName = "OneResourceGroupName"; const credential = new DefaultAzureCredential(); + const subscriptionId = "subscription-id"; const client = new HealthbotClient(credential, subscriptionId); const resArray = new Array(); - for await (const item of client.bots.listByResourceGroup(resourceGroupName)) { + for await (const item of client.bots.listByResourceGroup("OneResourceGroupName")) { resArray.push(item); } + console.log(resArray); } -listBotsByResourceGroup().catch(console.error); +async function main(): Promise { + await listBotsByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples-dev/botsListSample.ts b/sdk/healthbot/arm-healthbot/samples-dev/botsListSample.ts index ae68f80e6916..0eef2901781d 100644 --- a/sdk/healthbot/arm-healthbot/samples-dev/botsListSample.ts +++ b/sdk/healthbot/arm-healthbot/samples-dev/botsListSample.ts @@ -1,25 +1,29 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to Returns all the resources of a particular type belonging to a subscription. - * - * @summary Returns all the resources of a particular type belonging to a subscription. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ListBotsBySubscription.json - */ - import { HealthbotClient } from "@azure/arm-healthbot"; import { DefaultAzureCredential } from "@azure/identity"; +/** + * This sample demonstrates how to returns all the resources of a particular type belonging to a subscription. + * + * @summary returns all the resources of a particular type belonging to a subscription. + * x-ms-original-file: 2025-11-01/ListBotsBySubscription.json + */ async function listBotsBySubscription(): Promise { - const subscriptionId = "subscription-id"; const credential = new DefaultAzureCredential(); + const subscriptionId = "subscription-id"; const client = new HealthbotClient(credential, subscriptionId); const resArray = new Array(); for await (const item of client.bots.list()) { resArray.push(item); } + console.log(resArray); } -listBotsBySubscription().catch(console.error); +async function main(): Promise { + await listBotsBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples-dev/botsListSecretsSample.ts b/sdk/healthbot/arm-healthbot/samples-dev/botsListSecretsSample.ts new file mode 100644 index 000000000000..da122f73f58b --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples-dev/botsListSecretsSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list all secrets of a HealthBot. + * + * @summary list all secrets of a HealthBot. + * x-ms-original-file: 2025-11-01/ListSecrets.json + */ +async function botListSecrets(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.listSecrets("healthbotClient", "samplebotname"); + console.log(result); +} + +async function main(): Promise { + await botListSecrets(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples-dev/botsRegenerateApiJwtSecretSample.ts b/sdk/healthbot/arm-healthbot/samples-dev/botsRegenerateApiJwtSecretSample.ts new file mode 100644 index 000000000000..ea89d5d27810 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples-dev/botsRegenerateApiJwtSecretSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to regenerate the API JWT Secret of a HealthBot. + * + * @summary regenerate the API JWT Secret of a HealthBot. + * x-ms-original-file: 2025-11-01/RegenerateApiJwtSecret.json + */ +async function botRegenerateAPIJWTSecret(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.regenerateApiJwtSecret("healthbotClient", "samplebotname"); + console.log(result); +} + +async function main(): Promise { + await botRegenerateAPIJWTSecret(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples-dev/botsUpdateSample.ts b/sdk/healthbot/arm-healthbot/samples-dev/botsUpdateSample.ts index 2e503edfff8e..3df607484f9b 100644 --- a/sdk/healthbot/arm-healthbot/samples-dev/botsUpdateSample.ts +++ b/sdk/healthbot/arm-healthbot/samples-dev/botsUpdateSample.ts @@ -1,26 +1,27 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to Patch a HealthBot. - * - * @summary Patch a HealthBot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceUpdatePatch.json - */ - -import type { HealthBotUpdateParameters } from "@azure/arm-healthbot"; import { HealthbotClient } from "@azure/arm-healthbot"; import { DefaultAzureCredential } from "@azure/identity"; +/** + * This sample demonstrates how to patch a HealthBot. + * + * @summary patch a HealthBot. + * x-ms-original-file: 2025-11-01/ResourceUpdatePatch.json + */ async function botUpdate(): Promise { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; - const parameters: HealthBotUpdateParameters = { sku: { name: "F0" } }; const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.update(resourceGroupName, botName, parameters); + const result = await client.bots.update("healthbotClient", "samplebotname", { + sku: { name: "F0" }, + }); console.log(result); } -botUpdate().catch(console.error); +async function main(): Promise { + await botUpdate(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples-dev/operationsListSample.ts b/sdk/healthbot/arm-healthbot/samples-dev/operationsListSample.ts index afffabe7d011..1c9bd15140b0 100644 --- a/sdk/healthbot/arm-healthbot/samples-dev/operationsListSample.ts +++ b/sdk/healthbot/arm-healthbot/samples-dev/operationsListSample.ts @@ -1,25 +1,28 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to Lists all the available Azure Health Bot operations. - * - * @summary Lists all the available Azure Health Bot operations. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/GetOperations.json - */ - import { HealthbotClient } from "@azure/arm-healthbot"; import { DefaultAzureCredential } from "@azure/identity"; +/** + * This sample demonstrates how to lists all the available Azure Health Bot operations. + * + * @summary lists all the available Azure Health Bot operations. + * x-ms-original-file: 2025-11-01/GetOperations.json + */ async function getOperations(): Promise { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); + const client = new HealthbotClient(credential); const resArray = new Array(); for await (const item of client.operations.list()) { resArray.push(item); } + console.log(resArray); } -getOperations().catch(console.error); +async function main(): Promise { + await getOperations(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsCreateSample.js b/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsCreateSample.js deleted file mode 100644 index 66115bfba317..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsCreateSample.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { HealthbotClient } = require("@azure/arm-healthbot"); -const { DefaultAzureCredential } = require("@azure/identity"); - -/** - * This sample demonstrates how to Create a new Azure Health Bot. - * - * @summary Create a new Azure Health Bot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceCreationPut.json - */ -async function botCreate() { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; - const parameters = { - identity: { - type: "SystemAssigned, UserAssigned", - userAssignedIdentities: { - "/subscriptions/subscriptionId/resourcegroups/myrg/providers/microsoftManagedidentity/userassignedidentities/myMi": - {}, - "/subscriptions/subscriptionId/resourcegroups/myrg/providers/microsoftManagedidentity/userassignedidentities/myMi2": - {}, - }, - }, - location: "East US", - sku: { name: "F0" }, - }; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.beginCreateAndWait(resourceGroupName, botName, parameters); - console.log(result); -} - -botCreate().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsDeleteSample.js b/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsDeleteSample.js deleted file mode 100644 index 6056c3f3753b..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsDeleteSample.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { HealthbotClient } = require("@azure/arm-healthbot"); -const { DefaultAzureCredential } = require("@azure/identity"); - -/** - * This sample demonstrates how to Delete a HealthBot. - * - * @summary Delete a HealthBot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceDeletionDelete.json - */ -async function botDelete() { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.beginDeleteAndWait(resourceGroupName, botName); - console.log(result); -} - -botDelete().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsGetSample.js b/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsGetSample.js deleted file mode 100644 index f71faef1524b..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsGetSample.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { HealthbotClient } = require("@azure/arm-healthbot"); -const { DefaultAzureCredential } = require("@azure/identity"); - -/** - * This sample demonstrates how to Get a HealthBot. - * - * @summary Get a HealthBot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceInfoGet.json - */ -async function resourceInfoGet() { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.get(resourceGroupName, botName); - console.log(result); -} - -resourceInfoGet().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsListByResourceGroupSample.js b/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsListByResourceGroupSample.js deleted file mode 100644 index a21f6a6c3ba5..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsListByResourceGroupSample.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { HealthbotClient } = require("@azure/arm-healthbot"); -const { DefaultAzureCredential } = require("@azure/identity"); - -/** - * This sample demonstrates how to Returns all the resources of a particular type belonging to a resource group - * - * @summary Returns all the resources of a particular type belonging to a resource group - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ListBotsByResourceGroup.json - */ -async function listBotsByResourceGroup() { - const subscriptionId = "subscription-id"; - const resourceGroupName = "OneResourceGroupName"; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.bots.listByResourceGroup(resourceGroupName)) { - resArray.push(item); - } - console.log(resArray); -} - -listBotsByResourceGroup().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsListSample.js b/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsListSample.js deleted file mode 100644 index 282035affb6a..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsListSample.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { HealthbotClient } = require("@azure/arm-healthbot"); -const { DefaultAzureCredential } = require("@azure/identity"); - -/** - * This sample demonstrates how to Returns all the resources of a particular type belonging to a subscription. - * - * @summary Returns all the resources of a particular type belonging to a subscription. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ListBotsBySubscription.json - */ -async function listBotsBySubscription() { - const subscriptionId = "subscription-id"; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.bots.list()) { - resArray.push(item); - } - console.log(resArray); -} - -listBotsBySubscription().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsUpdateSample.js b/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsUpdateSample.js deleted file mode 100644 index 0f4165558e44..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsUpdateSample.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { HealthbotClient } = require("@azure/arm-healthbot"); -const { DefaultAzureCredential } = require("@azure/identity"); - -/** - * This sample demonstrates how to Patch a HealthBot. - * - * @summary Patch a HealthBot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceUpdatePatch.json - */ -async function botUpdate() { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; - const parameters = { sku: { name: "F0" } }; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.update(resourceGroupName, botName, parameters); - console.log(result); -} - -botUpdate().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/javascript/operationsListSample.js b/sdk/healthbot/arm-healthbot/samples/v2/javascript/operationsListSample.js deleted file mode 100644 index d6b92a6aa95f..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/javascript/operationsListSample.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { HealthbotClient } = require("@azure/arm-healthbot"); -const { DefaultAzureCredential } = require("@azure/identity"); - -/** - * This sample demonstrates how to Lists all the available Azure Health Bot operations. - * - * @summary Lists all the available Azure Health Bot operations. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/GetOperations.json - */ -async function getOperations() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.operations.list()) { - resArray.push(item); - } - console.log(resArray); -} - -getOperations().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/javascript/sample.env b/sdk/healthbot/arm-healthbot/samples/v2/javascript/sample.env deleted file mode 100644 index 672847a3fea0..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/javascript/sample.env +++ /dev/null @@ -1,4 +0,0 @@ -# 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/healthbot/arm-healthbot/samples/v2/typescript/sample.env b/sdk/healthbot/arm-healthbot/samples/v2/typescript/sample.env deleted file mode 100644 index 672847a3fea0..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/sample.env +++ /dev/null @@ -1,4 +0,0 @@ -# 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/healthbot/arm-healthbot/samples/v2/typescript/src/botsCreateSample.ts b/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsCreateSample.ts deleted file mode 100644 index d9dca4fafd8c..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsCreateSample.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { HealthBot, HealthbotClient } from "@azure/arm-healthbot"; -import { DefaultAzureCredential } from "@azure/identity"; - -/** - * This sample demonstrates how to Create a new Azure Health Bot. - * - * @summary Create a new Azure Health Bot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceCreationPut.json - */ -async function botCreate(): Promise { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; - const parameters: HealthBot = { - identity: { - type: "SystemAssigned, UserAssigned", - userAssignedIdentities: { - "/subscriptions/subscriptionId/resourcegroups/myrg/providers/microsoftManagedidentity/userassignedidentities/myMi": {}, - "/subscriptions/subscriptionId/resourcegroups/myrg/providers/microsoftManagedidentity/userassignedidentities/myMi2": {} - } - }, - location: "East US", - sku: { name: "F0" } - }; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.beginCreateAndWait( - resourceGroupName, - botName, - parameters - ); - console.log(result); -} - -botCreate().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsDeleteSample.ts b/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsDeleteSample.ts deleted file mode 100644 index 61db1af1425a..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsDeleteSample.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { HealthbotClient } from "@azure/arm-healthbot"; -import { DefaultAzureCredential } from "@azure/identity"; - -/** - * This sample demonstrates how to Delete a HealthBot. - * - * @summary Delete a HealthBot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceDeletionDelete.json - */ -async function botDelete(): Promise { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.beginDeleteAndWait( - resourceGroupName, - botName - ); - console.log(result); -} - -botDelete().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsGetSample.ts b/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsGetSample.ts deleted file mode 100644 index 48729ea34fa8..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsGetSample.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { HealthbotClient } from "@azure/arm-healthbot"; -import { DefaultAzureCredential } from "@azure/identity"; - -/** - * This sample demonstrates how to Get a HealthBot. - * - * @summary Get a HealthBot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceInfoGet.json - */ -async function resourceInfoGet(): Promise { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.get(resourceGroupName, botName); - console.log(result); -} - -resourceInfoGet().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsListByResourceGroupSample.ts b/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsListByResourceGroupSample.ts deleted file mode 100644 index ec960a239d9b..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsListByResourceGroupSample.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { HealthbotClient } from "@azure/arm-healthbot"; -import { DefaultAzureCredential } from "@azure/identity"; - -/** - * This sample demonstrates how to Returns all the resources of a particular type belonging to a resource group - * - * @summary Returns all the resources of a particular type belonging to a resource group - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ListBotsByResourceGroup.json - */ -async function listBotsByResourceGroup(): Promise { - const subscriptionId = "subscription-id"; - const resourceGroupName = "OneResourceGroupName"; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.bots.listByResourceGroup(resourceGroupName)) { - resArray.push(item); - } - console.log(resArray); -} - -listBotsByResourceGroup().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsListSample.ts b/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsListSample.ts deleted file mode 100644 index d98647ba981c..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsListSample.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { HealthbotClient } from "@azure/arm-healthbot"; -import { DefaultAzureCredential } from "@azure/identity"; - -/** - * This sample demonstrates how to Returns all the resources of a particular type belonging to a subscription. - * - * @summary Returns all the resources of a particular type belonging to a subscription. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ListBotsBySubscription.json - */ -async function listBotsBySubscription(): Promise { - const subscriptionId = "subscription-id"; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.bots.list()) { - resArray.push(item); - } - console.log(resArray); -} - -listBotsBySubscription().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsUpdateSample.ts b/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsUpdateSample.ts deleted file mode 100644 index c8be2d7548fc..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsUpdateSample.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { - HealthBotUpdateParameters, - HealthbotClient -} from "@azure/arm-healthbot"; -import { DefaultAzureCredential } from "@azure/identity"; - -/** - * This sample demonstrates how to Patch a HealthBot. - * - * @summary Patch a HealthBot. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceUpdatePatch.json - */ -async function botUpdate(): Promise { - const subscriptionId = "subid"; - const resourceGroupName = "healthbotClient"; - const botName = "samplebotname"; - const parameters: HealthBotUpdateParameters = { sku: { name: "F0" } }; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const result = await client.bots.update( - resourceGroupName, - botName, - parameters - ); - console.log(result); -} - -botUpdate().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/operationsListSample.ts b/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/operationsListSample.ts deleted file mode 100644 index 651e0b8017c2..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/operationsListSample.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { HealthbotClient } from "@azure/arm-healthbot"; -import { DefaultAzureCredential } from "@azure/identity"; - -/** - * This sample demonstrates how to Lists all the available Azure Health Bot operations. - * - * @summary Lists all the available Azure Health Bot operations. - * x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/GetOperations.json - */ -async function getOperations(): Promise { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const credential = new DefaultAzureCredential(); - const client = new HealthbotClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.operations.list()) { - resArray.push(item); - } - console.log(resArray); -} - -getOperations().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/typescript/tsconfig.json b/sdk/healthbot/arm-healthbot/samples/v2/typescript/tsconfig.json deleted file mode 100644 index ad5ff9a19d36..000000000000 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2018", - "module": "commonjs", - "moduleResolution": "node", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "alwaysStrict": true, - "outDir": "dist", - "rootDir": "src" - }, - "include": [ - "src/**/*.ts" - ] -} diff --git a/sdk/healthbot/arm-healthbot/samples/v2/javascript/README.md b/sdk/healthbot/arm-healthbot/samples/v3/javascript/README.md similarity index 51% rename from sdk/healthbot/arm-healthbot/samples/v2/javascript/README.md rename to sdk/healthbot/arm-healthbot/samples/v3/javascript/README.md index 41d67aee35cb..accd3dedddbf 100644 --- a/sdk/healthbot/arm-healthbot/samples/v2/javascript/README.md +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/README.md @@ -1,16 +1,18 @@ -# client library samples for JavaScript - -These sample programs show how to use the JavaScript client libraries for in some common scenarios. - -| **File Name** | **Description** | -| ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [botsCreateSample.js][botscreatesample] | Create a new Azure Health Bot. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceCreationPut.json | -| [botsDeleteSample.js][botsdeletesample] | Delete a HealthBot. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceDeletionDelete.json | -| [botsGetSample.js][botsgetsample] | Get a HealthBot. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceInfoGet.json | -| [botsListByResourceGroupSample.js][botslistbyresourcegroupsample] | Returns all the resources of a particular type belonging to a resource group x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ListBotsByResourceGroup.json | -| [botsListSample.js][botslistsample] | Returns all the resources of a particular type belonging to a subscription. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ListBotsBySubscription.json | -| [botsUpdateSample.js][botsupdatesample] | Patch a HealthBot. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceUpdatePatch.json | -| [operationsListSample.js][operationslistsample] | Lists all the available Azure Health Bot operations. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/GetOperations.json | +# @azure/arm-healthbot client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for @azure/arm-healthbot in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | +| [botsCreateSample.js][botscreatesample] | create a new Azure Health Bot. x-ms-original-file: 2025-11-01/ResourceCreationPut.json | +| [botsDeleteSample.js][botsdeletesample] | delete a HealthBot. x-ms-original-file: 2025-11-01/ResourceDeletionDelete.json | +| [botsGetSample.js][botsgetsample] | get a HealthBot. x-ms-original-file: 2025-11-01/ResourceInfoGet.json | +| [botsListByResourceGroupSample.js][botslistbyresourcegroupsample] | returns all the resources of a particular type belonging to a resource group x-ms-original-file: 2025-11-01/ListBotsByResourceGroup.json | +| [botsListSample.js][botslistsample] | returns all the resources of a particular type belonging to a subscription. x-ms-original-file: 2025-11-01/ListBotsBySubscription.json | +| [botsListSecretsSample.js][botslistsecretssample] | list all secrets of a HealthBot. x-ms-original-file: 2025-11-01/ListSecrets.json | +| [botsRegenerateApiJwtSecretSample.js][botsregenerateapijwtsecretsample] | regenerate the API JWT Secret of a HealthBot. x-ms-original-file: 2025-11-01/RegenerateApiJwtSecret.json | +| [botsUpdateSample.js][botsupdatesample] | patch a HealthBot. x-ms-original-file: 2025-11-01/ResourceUpdatePatch.json | +| [operationsListSample.js][operationslistsample] | lists all the available Azure Health Bot operations. x-ms-original-file: 2025-11-01/GetOperations.json | ## Prerequisites @@ -40,23 +42,25 @@ npm install node botsCreateSample.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): +Alternatively, run a single sample with the required environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): ```bash -cross-env node botsCreateSample.js +node botsCreateSample.js ``` ## Next Steps Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. -[botscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsCreateSample.js -[botsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsDeleteSample.js -[botsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsGetSample.js -[botslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsListByResourceGroupSample.js -[botslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsListSample.js -[botsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/javascript/botsUpdateSample.js -[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/javascript/operationsListSample.js +[botscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsCreateSample.js +[botsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsDeleteSample.js +[botsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsGetSample.js +[botslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListByResourceGroupSample.js +[botslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListSample.js +[botslistsecretssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListSecretsSample.js +[botsregenerateapijwtsecretsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsRegenerateApiJwtSecretSample.js +[botsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsUpdateSample.js +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/javascript/operationsListSample.js [apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-healthbot?view=azure-node-preview [freesub]: https://azure.microsoft.com/free/ [package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/healthbot/arm-healthbot/README.md diff --git a/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsCreateSample.js b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsCreateSample.js new file mode 100644 index 000000000000..e288d6f88545 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsCreateSample.js @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { HealthbotClient } = require("@azure/arm-healthbot"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to create a new Azure Health Bot. + * + * @summary create a new Azure Health Bot. + * x-ms-original-file: 2025-11-01/ResourceCreationPut.json + */ +async function botCreate() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.create("healthbotClient", "samplebotname", { + identity: { + type: "SystemAssigned, UserAssigned", + userAssignedIdentities: { + "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": + {}, + "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": + {}, + }, + }, + location: "East US", + sku: { name: "F0" }, + }); + console.log(result); +} + +async function main() { + await botCreate(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsDeleteSample.js b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsDeleteSample.js new file mode 100644 index 000000000000..4b1908eea459 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsDeleteSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { HealthbotClient } = require("@azure/arm-healthbot"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to delete a HealthBot. + * + * @summary delete a HealthBot. + * x-ms-original-file: 2025-11-01/ResourceDeletionDelete.json + */ +async function botDelete() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + await client.bots.delete("healthbotClient", "samplebotname"); +} + +async function main() { + await botDelete(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsGetSample.js b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsGetSample.js new file mode 100644 index 000000000000..b3edd0415ae1 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsGetSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { HealthbotClient } = require("@azure/arm-healthbot"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a HealthBot. + * + * @summary get a HealthBot. + * x-ms-original-file: 2025-11-01/ResourceInfoGet.json + */ +async function resourceInfoGet() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.get("healthbotClient", "samplebotname"); + console.log(result); +} + +async function main() { + await resourceInfoGet(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListByResourceGroupSample.js b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListByResourceGroupSample.js new file mode 100644 index 000000000000..593adf1573ff --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListByResourceGroupSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { HealthbotClient } = require("@azure/arm-healthbot"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to returns all the resources of a particular type belonging to a resource group + * + * @summary returns all the resources of a particular type belonging to a resource group + * x-ms-original-file: 2025-11-01/ListBotsByResourceGroup.json + */ +async function listBotsByResourceGroup() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subscription-id"; + const client = new HealthbotClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.bots.listByResourceGroup("OneResourceGroupName")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await listBotsByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListSample.js b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListSample.js new file mode 100644 index 000000000000..feea6470498e --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { HealthbotClient } = require("@azure/arm-healthbot"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to returns all the resources of a particular type belonging to a subscription. + * + * @summary returns all the resources of a particular type belonging to a subscription. + * x-ms-original-file: 2025-11-01/ListBotsBySubscription.json + */ +async function listBotsBySubscription() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subscription-id"; + const client = new HealthbotClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.bots.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await listBotsBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListSecretsSample.js b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListSecretsSample.js new file mode 100644 index 000000000000..f2d6c60bce5a --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsListSecretsSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { HealthbotClient } = require("@azure/arm-healthbot"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list all secrets of a HealthBot. + * + * @summary list all secrets of a HealthBot. + * x-ms-original-file: 2025-11-01/ListSecrets.json + */ +async function botListSecrets() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.listSecrets("healthbotClient", "samplebotname"); + console.log(result); +} + +async function main() { + await botListSecrets(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsRegenerateApiJwtSecretSample.js b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsRegenerateApiJwtSecretSample.js new file mode 100644 index 000000000000..37e49aac8184 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsRegenerateApiJwtSecretSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { HealthbotClient } = require("@azure/arm-healthbot"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to regenerate the API JWT Secret of a HealthBot. + * + * @summary regenerate the API JWT Secret of a HealthBot. + * x-ms-original-file: 2025-11-01/RegenerateApiJwtSecret.json + */ +async function botRegenerateAPIJWTSecret() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.regenerateApiJwtSecret("healthbotClient", "samplebotname"); + console.log(result); +} + +async function main() { + await botRegenerateAPIJWTSecret(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsUpdateSample.js b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsUpdateSample.js new file mode 100644 index 000000000000..a0b6f4f492f3 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/botsUpdateSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { HealthbotClient } = require("@azure/arm-healthbot"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to patch a HealthBot. + * + * @summary patch a HealthBot. + * x-ms-original-file: 2025-11-01/ResourceUpdatePatch.json + */ +async function botUpdate() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.update("healthbotClient", "samplebotname", { + sku: { name: "F0" }, + }); + console.log(result); +} + +async function main() { + await botUpdate(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/javascript/operationsListSample.js b/sdk/healthbot/arm-healthbot/samples/v3/javascript/operationsListSample.js new file mode 100644 index 000000000000..9138a979e41f --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/operationsListSample.js @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { HealthbotClient } = require("@azure/arm-healthbot"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to lists all the available Azure Health Bot operations. + * + * @summary lists all the available Azure Health Bot operations. + * x-ms-original-file: 2025-11-01/GetOperations.json + */ +async function getOperations() { + const credential = new DefaultAzureCredential(); + const client = new HealthbotClient(credential); + const resArray = new Array(); + for await (const item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await getOperations(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v2/javascript/package.json b/sdk/healthbot/arm-healthbot/samples/v3/javascript/package.json similarity index 79% rename from sdk/healthbot/arm-healthbot/samples/v2/javascript/package.json rename to sdk/healthbot/arm-healthbot/samples/v3/javascript/package.json index 032ad57344e8..414bea54adc1 100644 --- a/sdk/healthbot/arm-healthbot/samples/v2/javascript/package.json +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/package.json @@ -2,7 +2,7 @@ "name": "@azure-samples/arm-healthbot-js", "private": true, "version": "1.0.0", - "description": " client library samples for JavaScript", + "description": "@azure/arm-healthbot client library samples for JavaScript", "engines": { "node": ">=20.0.0" }, @@ -14,6 +14,7 @@ "keywords": [ "node", "azure", + "cloud", "typescript", "browser", "isomorphic" @@ -27,6 +28,9 @@ "dependencies": { "@azure/arm-healthbot": "latest", "dotenv": "latest", - "@azure/identity": "^4.2.1" + "@azure/identity": "^4.13.0" + }, + "devDependencies": { + "cross-env": "latest" } } diff --git a/sdk/healthbot/arm-healthbot/samples/v3/javascript/sample.env b/sdk/healthbot/arm-healthbot/samples/v3/javascript/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/javascript/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/healthbot/arm-healthbot/samples/v2/typescript/README.md b/sdk/healthbot/arm-healthbot/samples/v3/typescript/README.md similarity index 54% rename from sdk/healthbot/arm-healthbot/samples/v2/typescript/README.md rename to sdk/healthbot/arm-healthbot/samples/v3/typescript/README.md index 872dfbabda08..8b021b24901e 100644 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/README.md +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/README.md @@ -1,16 +1,18 @@ -# client library samples for TypeScript - -These sample programs show how to use the TypeScript client libraries for in some common scenarios. - -| **File Name** | **Description** | -| ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [botsCreateSample.ts][botscreatesample] | Create a new Azure Health Bot. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceCreationPut.json | -| [botsDeleteSample.ts][botsdeletesample] | Delete a HealthBot. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceDeletionDelete.json | -| [botsGetSample.ts][botsgetsample] | Get a HealthBot. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceInfoGet.json | -| [botsListByResourceGroupSample.ts][botslistbyresourcegroupsample] | Returns all the resources of a particular type belonging to a resource group x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ListBotsByResourceGroup.json | -| [botsListSample.ts][botslistsample] | Returns all the resources of a particular type belonging to a subscription. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ListBotsBySubscription.json | -| [botsUpdateSample.ts][botsupdatesample] | Patch a HealthBot. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/ResourceUpdatePatch.json | -| [operationsListSample.ts][operationslistsample] | Lists all the available Azure Health Bot operations. x-ms-original-file: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-06-10/examples/GetOperations.json | +# @azure/arm-healthbot client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for @azure/arm-healthbot in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | +| [botsCreateSample.ts][botscreatesample] | create a new Azure Health Bot. x-ms-original-file: 2025-11-01/ResourceCreationPut.json | +| [botsDeleteSample.ts][botsdeletesample] | delete a HealthBot. x-ms-original-file: 2025-11-01/ResourceDeletionDelete.json | +| [botsGetSample.ts][botsgetsample] | get a HealthBot. x-ms-original-file: 2025-11-01/ResourceInfoGet.json | +| [botsListByResourceGroupSample.ts][botslistbyresourcegroupsample] | returns all the resources of a particular type belonging to a resource group x-ms-original-file: 2025-11-01/ListBotsByResourceGroup.json | +| [botsListSample.ts][botslistsample] | returns all the resources of a particular type belonging to a subscription. x-ms-original-file: 2025-11-01/ListBotsBySubscription.json | +| [botsListSecretsSample.ts][botslistsecretssample] | list all secrets of a HealthBot. x-ms-original-file: 2025-11-01/ListSecrets.json | +| [botsRegenerateApiJwtSecretSample.ts][botsregenerateapijwtsecretsample] | regenerate the API JWT Secret of a HealthBot. x-ms-original-file: 2025-11-01/RegenerateApiJwtSecret.json | +| [botsUpdateSample.ts][botsupdatesample] | patch a HealthBot. x-ms-original-file: 2025-11-01/ResourceUpdatePatch.json | +| [operationsListSample.ts][operationslistsample] | lists all the available Azure Health Bot operations. x-ms-original-file: 2025-11-01/GetOperations.json | ## Prerequisites @@ -52,23 +54,25 @@ npm run build node dist/botsCreateSample.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): +Alternatively, run a single sample with the required environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): ```bash -cross-env node dist/botsCreateSample.js +node dist/botsCreateSample.js ``` ## Next Steps Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. -[botscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsCreateSample.ts -[botsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsDeleteSample.ts -[botsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsGetSample.ts -[botslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsListByResourceGroupSample.ts -[botslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsListSample.ts -[botsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/botsUpdateSample.ts -[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v2/typescript/src/operationsListSample.ts +[botscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsCreateSample.ts +[botsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsDeleteSample.ts +[botsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsGetSample.ts +[botslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListByResourceGroupSample.ts +[botslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListSample.ts +[botslistsecretssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListSecretsSample.ts +[botsregenerateapijwtsecretsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsRegenerateApiJwtSecretSample.ts +[botsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsUpdateSample.ts +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/operationsListSample.ts [apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-healthbot?view=azure-node-preview [freesub]: https://azure.microsoft.com/free/ [package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/healthbot/arm-healthbot/README.md diff --git a/sdk/healthbot/arm-healthbot/samples/v2/typescript/package.json b/sdk/healthbot/arm-healthbot/samples/v3/typescript/package.json similarity index 80% rename from sdk/healthbot/arm-healthbot/samples/v2/typescript/package.json rename to sdk/healthbot/arm-healthbot/samples/v3/typescript/package.json index 5640431f5b6c..3e64a0ab08b7 100644 --- a/sdk/healthbot/arm-healthbot/samples/v2/typescript/package.json +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/package.json @@ -2,7 +2,7 @@ "name": "@azure-samples/arm-healthbot-ts", "private": true, "version": "1.0.0", - "description": " client library samples for TypeScript", + "description": "@azure/arm-healthbot client library samples for TypeScript", "engines": { "node": ">=20.0.0" }, @@ -18,6 +18,7 @@ "keywords": [ "node", "azure", + "cloud", "typescript", "browser", "isomorphic" @@ -31,11 +32,12 @@ "dependencies": { "@azure/arm-healthbot": "latest", "dotenv": "latest", - "@azure/identity": "^4.2.1" + "@azure/identity": "^4.13.0" }, "devDependencies": { "@types/node": "^20.0.0", - "typescript": "~5.8.2", - "rimraf": "latest" + "cross-env": "latest", + "rimraf": "latest", + "typescript": "~5.9.3" } } diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/sample.env b/sdk/healthbot/arm-healthbot/samples/v3/typescript/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsCreateSample.ts b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsCreateSample.ts new file mode 100644 index 000000000000..697b59a3ecf6 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsCreateSample.ts @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a new Azure Health Bot. + * + * @summary create a new Azure Health Bot. + * x-ms-original-file: 2025-11-01/ResourceCreationPut.json + */ +async function botCreate(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.create("healthbotClient", "samplebotname", { + identity: { + type: "SystemAssigned, UserAssigned", + userAssignedIdentities: { + "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": + {}, + "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": + {}, + }, + }, + location: "East US", + sku: { name: "F0" }, + }); + console.log(result); +} + +async function main(): Promise { + await botCreate(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsDeleteSample.ts b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsDeleteSample.ts new file mode 100644 index 000000000000..95c70e6d2c4c --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsDeleteSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a HealthBot. + * + * @summary delete a HealthBot. + * x-ms-original-file: 2025-11-01/ResourceDeletionDelete.json + */ +async function botDelete(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + await client.bots.delete("healthbotClient", "samplebotname"); +} + +async function main(): Promise { + await botDelete(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsGetSample.ts b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsGetSample.ts new file mode 100644 index 000000000000..c16588b971bb --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsGetSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a HealthBot. + * + * @summary get a HealthBot. + * x-ms-original-file: 2025-11-01/ResourceInfoGet.json + */ +async function resourceInfoGet(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.get("healthbotClient", "samplebotname"); + console.log(result); +} + +async function main(): Promise { + await resourceInfoGet(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListByResourceGroupSample.ts b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListByResourceGroupSample.ts new file mode 100644 index 000000000000..f61575b709a9 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListByResourceGroupSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to returns all the resources of a particular type belonging to a resource group + * + * @summary returns all the resources of a particular type belonging to a resource group + * x-ms-original-file: 2025-11-01/ListBotsByResourceGroup.json + */ +async function listBotsByResourceGroup(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subscription-id"; + const client = new HealthbotClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.bots.listByResourceGroup("OneResourceGroupName")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listBotsByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListSample.ts b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListSample.ts new file mode 100644 index 000000000000..0eef2901781d --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to returns all the resources of a particular type belonging to a subscription. + * + * @summary returns all the resources of a particular type belonging to a subscription. + * x-ms-original-file: 2025-11-01/ListBotsBySubscription.json + */ +async function listBotsBySubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subscription-id"; + const client = new HealthbotClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.bots.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listBotsBySubscription(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListSecretsSample.ts b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListSecretsSample.ts new file mode 100644 index 000000000000..da122f73f58b --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsListSecretsSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list all secrets of a HealthBot. + * + * @summary list all secrets of a HealthBot. + * x-ms-original-file: 2025-11-01/ListSecrets.json + */ +async function botListSecrets(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.listSecrets("healthbotClient", "samplebotname"); + console.log(result); +} + +async function main(): Promise { + await botListSecrets(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsRegenerateApiJwtSecretSample.ts b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsRegenerateApiJwtSecretSample.ts new file mode 100644 index 000000000000..ea89d5d27810 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsRegenerateApiJwtSecretSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to regenerate the API JWT Secret of a HealthBot. + * + * @summary regenerate the API JWT Secret of a HealthBot. + * x-ms-original-file: 2025-11-01/RegenerateApiJwtSecret.json + */ +async function botRegenerateAPIJWTSecret(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.regenerateApiJwtSecret("healthbotClient", "samplebotname"); + console.log(result); +} + +async function main(): Promise { + await botRegenerateAPIJWTSecret(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsUpdateSample.ts b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsUpdateSample.ts new file mode 100644 index 000000000000..3df607484f9b --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/botsUpdateSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to patch a HealthBot. + * + * @summary patch a HealthBot. + * x-ms-original-file: 2025-11-01/ResourceUpdatePatch.json + */ +async function botUpdate(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "subid"; + const client = new HealthbotClient(credential, subscriptionId); + const result = await client.bots.update("healthbotClient", "samplebotname", { + sku: { name: "F0" }, + }); + console.log(result); +} + +async function main(): Promise { + await botUpdate(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/operationsListSample.ts b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/operationsListSample.ts new file mode 100644 index 000000000000..1c9bd15140b0 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/src/operationsListSample.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { HealthbotClient } from "@azure/arm-healthbot"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to lists all the available Azure Health Bot operations. + * + * @summary lists all the available Azure Health Bot operations. + * x-ms-original-file: 2025-11-01/GetOperations.json + */ +async function getOperations(): Promise { + const credential = new DefaultAzureCredential(); + const client = new HealthbotClient(credential); + const resArray = new Array(); + for await (const item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await getOperations(); +} + +main().catch(console.error); diff --git a/sdk/healthbot/arm-healthbot/samples/v3/typescript/tsconfig.json b/sdk/healthbot/arm-healthbot/samples/v3/typescript/tsconfig.json new file mode 100644 index 000000000000..400db87cf648 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/samples/v3/typescript/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ES2023", + "module": "commonjs", + "lib": [], + "importHelpers": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node10", + "esModuleInterop": true, + "outDir": "./dist", + "resolveJsonModule": true + }, + "include": [ + "./src" + ] +} diff --git a/sdk/healthbot/arm-healthbot/src/api/bots/index.ts b/sdk/healthbot/arm-healthbot/src/api/bots/index.ts new file mode 100644 index 000000000000..6eb02a1d19c4 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/api/bots/index.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + regenerateApiJwtSecret, + listSecrets, + list, + listByResourceGroup, + $delete, + update, + create, + get, +} from "./operations.js"; +export { + BotsRegenerateApiJwtSecretOptionalParams, + BotsListSecretsOptionalParams, + BotsListOptionalParams, + BotsListByResourceGroupOptionalParams, + BotsDeleteOptionalParams, + BotsUpdateOptionalParams, + BotsCreateOptionalParams, + BotsGetOptionalParams, +} from "./options.js"; diff --git a/sdk/healthbot/arm-healthbot/src/api/bots/operations.ts b/sdk/healthbot/arm-healthbot/src/api/bots/operations.ts new file mode 100644 index 000000000000..494c66ae2256 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/api/bots/operations.ts @@ -0,0 +1,434 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { HealthbotContext as Client } from "../index.js"; +import type { + HealthBot, + HealthBotUpdateParameters, + _BotResponseList, + HealthBotKeysResponse, + HealthBotKey, +} from "../../models/models.js"; +import { + errorDeserializer, + healthBotSerializer, + healthBotDeserializer, + healthBotUpdateParametersSerializer, + _botResponseListDeserializer, + healthBotKeysResponseDeserializer, + healthBotKeyDeserializer, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { + BotsRegenerateApiJwtSecretOptionalParams, + BotsListSecretsOptionalParams, + BotsListOptionalParams, + BotsListByResourceGroupOptionalParams, + BotsDeleteOptionalParams, + BotsUpdateOptionalParams, + BotsCreateOptionalParams, + BotsGetOptionalParams, +} from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; +import type { PollerLike, OperationState } from "@azure/core-lro"; + +export function _regenerateApiJwtSecretSend( + context: Client, + resourceGroupName: string, + botName: string, + options: BotsRegenerateApiJwtSecretOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/regenerateApiJwtSecret{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + botName: botName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _regenerateApiJwtSecretDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorDeserializer(result.body); + throw error; + } + + return healthBotKeyDeserializer(result.body); +} + +/** Regenerate the API JWT Secret of a HealthBot. */ +export async function regenerateApiJwtSecret( + context: Client, + resourceGroupName: string, + botName: string, + options: BotsRegenerateApiJwtSecretOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _regenerateApiJwtSecretSend(context, resourceGroupName, botName, options); + return _regenerateApiJwtSecretDeserialize(result); +} + +export function _listSecretsSend( + context: Client, + resourceGroupName: string, + botName: string, + options: BotsListSecretsOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/listSecrets{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + botName: botName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listSecretsDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorDeserializer(result.body); + throw error; + } + + return healthBotKeysResponseDeserializer(result.body); +} + +/** List all secrets of a HealthBot. */ +export async function listSecrets( + context: Client, + resourceGroupName: string, + botName: string, + options: BotsListSecretsOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _listSecretsSend(context, resourceGroupName, botName, options); + return _listSecretsDeserialize(result); +} + +export function _listSend( + context: Client, + options: BotsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize(result: PathUncheckedResponse): Promise<_BotResponseList> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorDeserializer(result.body); + throw error; + } + + return _botResponseListDeserializer(result.body); +} + +/** Returns all the resources of a particular type belonging to a subscription. */ +export function list( + context: Client, + options: BotsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _listByResourceGroupSend( + context: Client, + resourceGroupName: string, + options: BotsListByResourceGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listByResourceGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_BotResponseList> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorDeserializer(result.body); + throw error; + } + + return _botResponseListDeserializer(result.body); +} + +/** Returns all the resources of a particular type belonging to a resource group */ +export function listByResourceGroup( + context: Client, + resourceGroupName: string, + options: BotsListByResourceGroupOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listByResourceGroupSend(context, resourceGroupName, options), + _listByResourceGroupDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _$deleteSend( + context: Client, + resourceGroupName: string, + botName: string, + options: BotsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + botName: botName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ ...operationOptionsToRequestParameters(options) }); +} + +export async function _$deleteDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "202", "204", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a HealthBot. */ +/** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ +export function $delete( + context: Client, + resourceGroupName: string, + botName: string, + options: BotsDeleteOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller(context, _$deleteDeserialize, ["200", "202", "204", "201"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => _$deleteSend(context, resourceGroupName, botName, options), + resourceLocationConfig: "location", + }) as PollerLike, void>; +} + +export function _updateSend( + context: Client, + resourceGroupName: string, + botName: string, + parameters: HealthBotUpdateParameters, + options: BotsUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + botName: botName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: healthBotUpdateParametersSerializer(parameters), + }); +} + +export async function _updateDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "201", "202"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorDeserializer(result.body); + throw error; + } + + return healthBotDeserializer(result.body); +} + +/** Patch a HealthBot. */ +export function update( + context: Client, + resourceGroupName: string, + botName: string, + parameters: HealthBotUpdateParameters, + options: BotsUpdateOptionalParams = { requestOptions: {} }, +): PollerLike, HealthBot> { + return getLongRunningPoller(context, _updateDeserialize, ["200", "201", "202"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => _updateSend(context, resourceGroupName, botName, parameters, options), + resourceLocationConfig: "location", + }) as PollerLike, HealthBot>; +} + +export function _createSend( + context: Client, + resourceGroupName: string, + botName: string, + parameters: HealthBot, + options: BotsCreateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + botName: botName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: healthBotSerializer(parameters), + }); +} + +export async function _createDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "201", "202"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorDeserializer(result.body); + throw error; + } + + return healthBotDeserializer(result.body); +} + +/** Create a new Azure Health Bot. */ +export function create( + context: Client, + resourceGroupName: string, + botName: string, + parameters: HealthBot, + options: BotsCreateOptionalParams = { requestOptions: {} }, +): PollerLike, HealthBot> { + return getLongRunningPoller(context, _createDeserialize, ["200", "201", "202"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => _createSend(context, resourceGroupName, botName, parameters, options), + resourceLocationConfig: "azure-async-operation", + }) as PollerLike, HealthBot>; +} + +export function _getSend( + context: Client, + resourceGroupName: string, + botName: string, + options: BotsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + botName: botName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorDeserializer(result.body); + throw error; + } + + return healthBotDeserializer(result.body); +} + +/** Get a HealthBot. */ +export async function get( + context: Client, + resourceGroupName: string, + botName: string, + options: BotsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, resourceGroupName, botName, options); + return _getDeserialize(result); +} diff --git a/sdk/healthbot/arm-healthbot/src/api/bots/options.ts b/sdk/healthbot/arm-healthbot/src/api/bots/options.ts new file mode 100644 index 000000000000..fd5c72aa84f2 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/api/bots/options.ts @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface BotsRegenerateApiJwtSecretOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface BotsListSecretsOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface BotsListOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface BotsListByResourceGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface BotsDeleteOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface BotsUpdateOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface BotsCreateOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface BotsGetOptionalParams extends OperationOptions {} diff --git a/sdk/healthbot/arm-healthbot/src/api/healthbotContext.ts b/sdk/healthbot/arm-healthbot/src/api/healthbotContext.ts new file mode 100644 index 000000000000..a3baf5413834 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/api/healthbotContext.ts @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { logger } from "../logger.js"; +import { KnownVersions } from "../models/models.js"; +import type { AzureSupportedClouds } from "../static-helpers/cloudSettingHelpers.js"; +import { getArmEndpoint } from "../static-helpers/cloudSettingHelpers.js"; +import type { Client, ClientOptions } from "@azure-rest/core-client"; +import { getClient } from "@azure-rest/core-client"; +import type { TokenCredential } from "@azure/core-auth"; + +/** Azure Health Bot is a cloud platform that empowers developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual health assistants and health bots, that help them improve processes and reduce costs. */ +export interface HealthbotContext extends Client { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion: string; + /** The ID of the target subscription. The value must be an UUID. */ + subscriptionId: string; +} + +/** Optional parameters for the client. */ +export interface HealthbotClientOptionalParams extends ClientOptions { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion?: string; + /** Specifies the Azure cloud environment for the client. */ + cloudSetting?: AzureSupportedClouds; +} + +/** Azure Health Bot is a cloud platform that empowers developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual health assistants and health bots, that help them improve processes and reduce costs. */ +export function createHealthbot( + credential: TokenCredential, + subscriptionId: string, + options: HealthbotClientOptionalParams = {}, +): HealthbotContext { + const endpointUrl = + options.endpoint ?? getArmEndpoint(options.cloudSetting) ?? "https://management.azure.com"; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentInfo = `azsdk-js-arm-healthbot/1.0.0-beta.1`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}` + : `azsdk-js-api ${userAgentInfo}`; + const { apiVersion: _, ...updatedOptions } = { + ...options, + userAgentOptions: { userAgentPrefix }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + credentials: { scopes: options.credentials?.scopes ?? [`${endpointUrl}/.default`] }, + }; + const clientContext = getClient(endpointUrl, credential, updatedOptions); + clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + const apiVersion = options.apiVersion ?? "2025-11-01"; + clientContext.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version")) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); + return { ...clientContext, apiVersion, subscriptionId } as HealthbotContext; +} diff --git a/sdk/healthbot/arm-healthbot/src/api/index.ts b/sdk/healthbot/arm-healthbot/src/api/index.ts new file mode 100644 index 000000000000..d73b05255eb6 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/api/index.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + createHealthbot, + HealthbotContext, + HealthbotClientOptionalParams, +} from "./healthbotContext.js"; diff --git a/sdk/healthbot/arm-healthbot/src/api/operations/index.ts b/sdk/healthbot/arm-healthbot/src/api/operations/index.ts new file mode 100644 index 000000000000..24a804d14fcf --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/api/operations/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { list } from "./operations.js"; +export { OperationsListOptionalParams } from "./options.js"; diff --git a/sdk/healthbot/arm-healthbot/src/api/operations/operations.ts b/sdk/healthbot/arm-healthbot/src/api/operations/operations.ts new file mode 100644 index 000000000000..b09a6bbd3e37 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/api/operations/operations.ts @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { HealthbotContext as Client } from "../index.js"; +import type { _AvailableOperations, OperationDetail } from "../../models/models.js"; +import { _availableOperationsDeserializer, errorDeserializer } from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { OperationsListOptionalParams } from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _listSend( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.HealthBot/operations{?api%2Dversion}", + { + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_AvailableOperations> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorDeserializer(result.body); + throw error; + } + + return _availableOperationsDeserializer(result.body); +} + +/** Lists all the available Azure Health Bot operations. */ +export function list( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} diff --git a/sdk/healthbot/arm-healthbot/src/api/operations/options.ts b/sdk/healthbot/arm-healthbot/src/api/operations/options.ts new file mode 100644 index 000000000000..b9a3fd9758a3 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/api/operations/options.ts @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface OperationsListOptionalParams extends OperationOptions {} diff --git a/sdk/healthbot/arm-healthbot/src/classic/bots/index.ts b/sdk/healthbot/arm-healthbot/src/classic/bots/index.ts new file mode 100644 index 000000000000..bb6c4c3e152a --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/classic/bots/index.ts @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { HealthbotContext } from "../../api/healthbotContext.js"; +import { + regenerateApiJwtSecret, + listSecrets, + list, + listByResourceGroup, + $delete, + update, + create, + get, +} from "../../api/bots/operations.js"; +import type { + BotsRegenerateApiJwtSecretOptionalParams, + BotsListSecretsOptionalParams, + BotsListOptionalParams, + BotsListByResourceGroupOptionalParams, + BotsDeleteOptionalParams, + BotsUpdateOptionalParams, + BotsCreateOptionalParams, + BotsGetOptionalParams, +} from "../../api/bots/options.js"; +import type { + HealthBot, + HealthBotUpdateParameters, + HealthBotKeysResponse, + HealthBotKey, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import type { SimplePollerLike } from "../../static-helpers/simplePollerHelpers.js"; +import { getSimplePoller } from "../../static-helpers/simplePollerHelpers.js"; +import type { PollerLike, OperationState } from "@azure/core-lro"; + +/** Interface representing a Bots operations. */ +export interface BotsOperations { + /** Regenerate the API JWT Secret of a HealthBot. */ + regenerateApiJwtSecret: ( + resourceGroupName: string, + botName: string, + options?: BotsRegenerateApiJwtSecretOptionalParams, + ) => Promise; + /** List all secrets of a HealthBot. */ + listSecrets: ( + resourceGroupName: string, + botName: string, + options?: BotsListSecretsOptionalParams, + ) => Promise; + /** Returns all the resources of a particular type belonging to a subscription. */ + list: (options?: BotsListOptionalParams) => PagedAsyncIterableIterator; + /** Returns all the resources of a particular type belonging to a resource group */ + listByResourceGroup: ( + resourceGroupName: string, + options?: BotsListByResourceGroupOptionalParams, + ) => PagedAsyncIterableIterator; + /** Delete a HealthBot. */ + /** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ + delete: ( + resourceGroupName: string, + botName: string, + options?: BotsDeleteOptionalParams, + ) => PollerLike, void>; + /** @deprecated use delete instead */ + beginDelete: ( + resourceGroupName: string, + botName: string, + options?: BotsDeleteOptionalParams, + ) => Promise, void>>; + /** @deprecated use delete instead */ + beginDeleteAndWait: ( + resourceGroupName: string, + botName: string, + options?: BotsDeleteOptionalParams, + ) => Promise; + /** Patch a HealthBot. */ + update: ( + resourceGroupName: string, + botName: string, + parameters: HealthBotUpdateParameters, + options?: BotsUpdateOptionalParams, + ) => PollerLike, HealthBot>; + /** @deprecated use update instead */ + beginUpdate: ( + resourceGroupName: string, + botName: string, + parameters: HealthBotUpdateParameters, + options?: BotsUpdateOptionalParams, + ) => Promise, HealthBot>>; + /** @deprecated use update instead */ + beginUpdateAndWait: ( + resourceGroupName: string, + botName: string, + parameters: HealthBotUpdateParameters, + options?: BotsUpdateOptionalParams, + ) => Promise; + /** Create a new Azure Health Bot. */ + create: ( + resourceGroupName: string, + botName: string, + parameters: HealthBot, + options?: BotsCreateOptionalParams, + ) => PollerLike, HealthBot>; + /** @deprecated use create instead */ + beginCreate: ( + resourceGroupName: string, + botName: string, + parameters: HealthBot, + options?: BotsCreateOptionalParams, + ) => Promise, HealthBot>>; + /** @deprecated use create instead */ + beginCreateAndWait: ( + resourceGroupName: string, + botName: string, + parameters: HealthBot, + options?: BotsCreateOptionalParams, + ) => Promise; + /** Get a HealthBot. */ + get: ( + resourceGroupName: string, + botName: string, + options?: BotsGetOptionalParams, + ) => Promise; +} + +function _getBots(context: HealthbotContext) { + return { + regenerateApiJwtSecret: ( + resourceGroupName: string, + botName: string, + options?: BotsRegenerateApiJwtSecretOptionalParams, + ) => regenerateApiJwtSecret(context, resourceGroupName, botName, options), + listSecrets: ( + resourceGroupName: string, + botName: string, + options?: BotsListSecretsOptionalParams, + ) => listSecrets(context, resourceGroupName, botName, options), + list: (options?: BotsListOptionalParams) => list(context, options), + listByResourceGroup: ( + resourceGroupName: string, + options?: BotsListByResourceGroupOptionalParams, + ) => listByResourceGroup(context, resourceGroupName, options), + delete: (resourceGroupName: string, botName: string, options?: BotsDeleteOptionalParams) => + $delete(context, resourceGroupName, botName, options), + beginDelete: async ( + resourceGroupName: string, + botName: string, + options?: BotsDeleteOptionalParams, + ) => { + const poller = $delete(context, resourceGroupName, botName, options); + await poller.submitted(); + return getSimplePoller(poller); + }, + beginDeleteAndWait: async ( + resourceGroupName: string, + botName: string, + options?: BotsDeleteOptionalParams, + ) => { + return await $delete(context, resourceGroupName, botName, options); + }, + update: ( + resourceGroupName: string, + botName: string, + parameters: HealthBotUpdateParameters, + options?: BotsUpdateOptionalParams, + ) => update(context, resourceGroupName, botName, parameters, options), + beginUpdate: async ( + resourceGroupName: string, + botName: string, + parameters: HealthBotUpdateParameters, + options?: BotsUpdateOptionalParams, + ) => { + const poller = update(context, resourceGroupName, botName, parameters, options); + await poller.submitted(); + return getSimplePoller(poller); + }, + beginUpdateAndWait: async ( + resourceGroupName: string, + botName: string, + parameters: HealthBotUpdateParameters, + options?: BotsUpdateOptionalParams, + ) => { + return await update(context, resourceGroupName, botName, parameters, options); + }, + create: ( + resourceGroupName: string, + botName: string, + parameters: HealthBot, + options?: BotsCreateOptionalParams, + ) => create(context, resourceGroupName, botName, parameters, options), + beginCreate: async ( + resourceGroupName: string, + botName: string, + parameters: HealthBot, + options?: BotsCreateOptionalParams, + ) => { + const poller = create(context, resourceGroupName, botName, parameters, options); + await poller.submitted(); + return getSimplePoller(poller); + }, + beginCreateAndWait: async ( + resourceGroupName: string, + botName: string, + parameters: HealthBot, + options?: BotsCreateOptionalParams, + ) => { + return await create(context, resourceGroupName, botName, parameters, options); + }, + get: (resourceGroupName: string, botName: string, options?: BotsGetOptionalParams) => + get(context, resourceGroupName, botName, options), + }; +} + +export function _getBotsOperations(context: HealthbotContext): BotsOperations { + return { + ..._getBots(context), + }; +} diff --git a/sdk/healthbot/arm-healthbot/src/classic/index.ts b/sdk/healthbot/arm-healthbot/src/classic/index.ts new file mode 100644 index 000000000000..b4a8012c36a8 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/classic/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { BotsOperations } from "./bots/index.js"; +export { OperationsOperations } from "./operations/index.js"; diff --git a/sdk/healthbot/arm-healthbot/src/classic/operations/index.ts b/sdk/healthbot/arm-healthbot/src/classic/operations/index.ts new file mode 100644 index 000000000000..adea03347dab --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/classic/operations/index.ts @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { HealthbotContext } from "../../api/healthbotContext.js"; +import { list } from "../../api/operations/operations.js"; +import type { OperationsListOptionalParams } from "../../api/operations/options.js"; +import type { OperationDetail } from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Operations operations. */ +export interface OperationsOperations { + /** Lists all the available Azure Health Bot operations. */ + list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; +} + +function _getOperations(context: HealthbotContext) { + return { + list: (options?: OperationsListOptionalParams) => list(context, options), + }; +} + +export function _getOperationsOperations(context: HealthbotContext): OperationsOperations { + return { + ..._getOperations(context), + }; +} diff --git a/sdk/healthbot/arm-healthbot/src/healthbotClient.ts b/sdk/healthbot/arm-healthbot/src/healthbotClient.ts index 2391550580aa..e1c5f5043b53 100644 --- a/sdk/healthbot/arm-healthbot/src/healthbotClient.ts +++ b/sdk/healthbot/arm-healthbot/src/healthbotClient.ts @@ -1,142 +1,58 @@ -/* - * 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 { BotsImpl, OperationsImpl } from "./operations/index.js"; -import { Bots, Operations } from "./operationsInterfaces/index.js"; -import { HealthbotClientOptionalParams } from "./models/index.js"; - -export class HealthbotClient extends coreClient.ServiceClient { - $host: string; - subscriptionId: string; - apiVersion: string; - - /** - * Initializes a new instance of the HealthbotClient class. - * @param credentials Subscription credentials which uniquely identify client subscription. - * @param subscriptionId Azure Subscription ID. - * @param options The parameter options - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { HealthbotContext, HealthbotClientOptionalParams } from "./api/index.js"; +import { createHealthbot } from "./api/index.js"; +import type { BotsOperations } from "./classic/bots/index.js"; +import { _getBotsOperations } from "./classic/bots/index.js"; +import type { OperationsOperations } from "./classic/operations/index.js"; +import { _getOperationsOperations } from "./classic/operations/index.js"; +import type { TokenCredential } from "@azure/core-auth"; +import type { Pipeline } from "@azure/core-rest-pipeline"; + +export { HealthbotClientOptionalParams } from "./api/healthbotContext.js"; + +export class HealthbotClient { + private _client: HealthbotContext; + /** The pipeline used by this client to make requests */ + public readonly pipeline: Pipeline; + + constructor(credential: TokenCredential, options?: HealthbotClientOptionalParams); constructor( - credentials: coreAuth.TokenCredential, + credential: TokenCredential, subscriptionId: string, - options?: HealthbotClientOptionalParams + options?: HealthbotClientOptionalParams, + ); + /** Azure Health Bot is a cloud platform that empowers developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual health assistants and health bots, that help them improve processes and reduce costs. */ + constructor( + credential: TokenCredential, + subscriptionIdOrOptions?: string | HealthbotClientOptionalParams, + options?: HealthbotClientOptionalParams, ) { - if (credentials === undefined) { - throw new Error("'credentials' cannot be null"); - } - if (subscriptionId === undefined) { - throw new Error("'subscriptionId' cannot be null"); - } + let subscriptionId: string | undefined; - // Initializing default values for options - if (!options) { - options = {}; + if (typeof subscriptionIdOrOptions === "string") { + subscriptionId = subscriptionIdOrOptions; + } else if (typeof subscriptionIdOrOptions === "object") { + options = subscriptionIdOrOptions; } - const defaults: HealthbotClientOptionalParams = { - requestContentType: "application/json; charset=utf-8", - credential: credentials - }; - - const packageDetails = `azsdk-js-arm-healthbot/2.1.2`; - const userAgentPrefix = - options.userAgentOptions && options.userAgentOptions.userAgentPrefix - ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` - : `${packageDetails}`; - const optionsWithDefaults = { - ...defaults, + options = options ?? {}; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-client` + : `azsdk-js-client`; + this._client = createHealthbot(credential, subscriptionId ?? "", { ...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 || "2021-06-10"; - this.bots = new BotsImpl(this); - this.operations = new OperationsImpl(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); + userAgentOptions: { userAgentPrefix }, + }); + this.pipeline = this._client.pipeline; + this.bots = _getBotsOperations(this._client); + this.operations = _getOperationsOperations(this._client); } - bots: Bots; - operations: Operations; + /** The operation groups for bots */ + public readonly bots: BotsOperations; + /** The operation groups for operations */ + public readonly operations: OperationsOperations; } diff --git a/sdk/healthbot/arm-healthbot/src/index.ts b/sdk/healthbot/arm-healthbot/src/index.ts index 26f96ab74c17..bc5a9679bf86 100644 --- a/sdk/healthbot/arm-healthbot/src/index.ts +++ b/sdk/healthbot/arm-healthbot/src/index.ts @@ -1,13 +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. + +import { AzureClouds, AzureSupportedClouds } from "./static-helpers/cloudSettingHelpers.js"; +import { + PageSettings, + ContinuablePage, + PagedAsyncIterableIterator, +} from "./static-helpers/pagingHelpers.js"; -/// -export { getContinuationToken } from "./pagingHelper.js"; -export * from "./models/index.js"; export { HealthbotClient } from "./healthbotClient.js"; -export * from "./operationsInterfaces/index.js"; +export { SimplePollerLike } from "./static-helpers/simplePollerHelpers.js"; +export { restorePoller, RestorePollerOptions } from "./restorePollerHelpers.js"; +export { + OperationDetail, + OperationDisplay, + ErrorModel, + ErrorError, + ErrorAdditionalInfo, + HealthBot, + HealthBotProperties, + KeyVaultProperties, + Sku, + SkuName, + Identity, + ResourceIdentityType, + UserAssignedIdentity, + TrackedResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + HealthBotUpdateParameters, + HealthBotKeysResponse, + HealthBotKey, + KnownVersions, +} from "./models/index.js"; +export { HealthbotClientOptionalParams } from "./api/index.js"; +export { + BotsRegenerateApiJwtSecretOptionalParams, + BotsListSecretsOptionalParams, + BotsListOptionalParams, + BotsListByResourceGroupOptionalParams, + BotsDeleteOptionalParams, + BotsUpdateOptionalParams, + BotsCreateOptionalParams, + BotsGetOptionalParams, +} from "./api/bots/index.js"; +export { OperationsListOptionalParams } from "./api/operations/index.js"; +export { BotsOperations, OperationsOperations } from "./classic/index.js"; +export { PageSettings, ContinuablePage, PagedAsyncIterableIterator }; +export { AzureClouds, AzureSupportedClouds }; diff --git a/sdk/healthbot/arm-healthbot/src/logger.ts b/sdk/healthbot/arm-healthbot/src/logger.ts new file mode 100644 index 000000000000..69ed3de410c3 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; +export const logger = createClientLogger("arm-healthbot"); diff --git a/sdk/healthbot/arm-healthbot/src/lroImpl.ts b/sdk/healthbot/arm-healthbot/src/lroImpl.ts deleted file mode 100644 index 518d5f053b4e..000000000000 --- a/sdk/healthbot/arm-healthbot/src/lroImpl.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { LongRunningOperation, LroResponse } from "@azure/core-lro"; - -export class LroImpl implements LongRunningOperation { - constructor( - private sendOperationFn: (args: any, spec: any) => Promise>, - private args: Record, - private spec: { - readonly requestBody?: unknown; - readonly path?: string; - readonly httpMethod: string; - } & Record, - public requestPath: string = spec.path!, - public requestMethod: string = spec.httpMethod - ) {} - public async sendInitialRequest(): Promise> { - return this.sendOperationFn(this.args, this.spec); - } - public async sendPollRequest(path: string): Promise> { - const { requestBody, ...restSpec } = this.spec; - return this.sendOperationFn(this.args, { - ...restSpec, - path, - httpMethod: "GET" - }); - } -} diff --git a/sdk/healthbot/arm-healthbot/src/models/index.ts b/sdk/healthbot/arm-healthbot/src/models/index.ts index 6e74933f5226..2fa771d80e87 100644 --- a/sdk/healthbot/arm-healthbot/src/models/index.ts +++ b/sdk/healthbot/arm-healthbot/src/models/index.ts @@ -1,355 +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 * as coreClient from "@azure/core-client"; - -/** The resource model definition representing SKU */ -export interface Sku { - /** The name of the Azure Health Bot SKU */ - name: SkuName; -} - -/** Identity for the resource. */ -export interface Identity { - /** - * The principal ID of resource identity. This property will only be provided for a system assigned identity. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly principalId?: string; - /** - * The tenant ID of resource. This property will only be provided for a system assigned identity. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly tenantId?: string; - /** The identity type. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the Azure Health Bot */ - type?: ResourceIdentityType; - /** - * The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: - * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - * - */ - userAssignedIdentities?: { [propertyName: string]: UserAssignedIdentity }; -} - -/** The details of the user assigned managed identity used by the Video Analyzer resource. */ -export interface UserAssignedIdentity { - /** - * The principal ID of user assigned identity. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly principalId?: string; - /** - * The client ID of user assigned identity. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly clientId?: string; -} - -/** The properties of a Azure Health Bot. The Health Bot Service is a cloud platform that empowers developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual health assistants and health bots, that help them improve processes and reduce costs. */ -export interface HealthBotProperties { - /** - * The provisioning state of the Azure Health Bot resource. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly provisioningState?: string; - /** - * The link. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly botManagementPortalLink?: string; -} - -/** The resource model definition for a ARM tracked top level resource */ -export interface Resource { - /** - * Fully qualified resource Id for the resource. - * 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. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly type?: string; - /** - * Metadata pertaining to creation and last modification of the resource - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly systemData?: SystemData; -} - -/** Read only system data */ -export interface SystemData { - /** The identity that created the resource. */ - createdBy?: string; - /** The type of identity that created the resource */ - createdByType?: IdentityType; - /** 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?: IdentityType; - /** The timestamp of resource last modification (UTC) */ - lastModifiedAt?: Date; -} - -/** The resource management error response. */ -export interface ErrorModel { - /** The error object. */ - error?: ErrorError; -} - -/** The error object. */ -export interface ErrorError { - /** - * 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?: ErrorModel[]; - /** - * 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; -} - -/** Parameters for updating a Azure Health Bot. */ -export interface HealthBotUpdateParameters { - /** Tags for a Azure Health Bot. */ - tags?: { [propertyName: string]: string }; - /** SKU of the Azure Health Bot. */ - sku?: Sku; - /** The identity of the Azure Health Bot. */ - identity?: Identity; - location?: string; -} - -/** The list of Azure Health Bot operation response. */ -export interface BotResponseList { - /** - * The link used to get the next page of bot service resources. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly nextLink?: string; - /** - * Gets the list of Azure Health Bot results and their properties. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly value?: HealthBot[]; -} - -/** Available operations of the service */ -export interface AvailableOperations { - /** Collection of available operation details */ - value?: OperationDetail[]; - /** - * URL client should use to fetch the next page (per server side paging). - * It's null for now, added for future use. - */ - nextLink?: string; -} - -/** Operation detail payload */ -export interface OperationDetail { - /** Name of the operation */ - name?: string; - /** Indicates whether the operation is a data action */ - isDataAction?: boolean; - /** Display of the operation */ - display?: OperationDisplay; - /** Origin of the operation */ - origin?: string; - /** Additional properties. */ - properties?: Record; -} - -/** Operation display payload */ -export interface OperationDisplay { - /** Resource provider of the operation */ - provider?: string; - /** Resource of the operation */ - resource?: string; - /** Localized friendly name for the operation */ - operation?: string; - /** Localized friendly description for the operation */ - description?: string; -} - -/** The response returned from validation process */ -export interface ValidationResult { - /** The status code of the response validation. */ - status?: string; -} - -/** The resource model definition for a ARM tracked top level resource */ -export interface TrackedResource extends Resource { - /** Resource tags. */ - tags?: { [propertyName: string]: string }; - /** The geo-location where the resource lives */ - location: string; -} - -/** Azure Health Bot resource definition */ -export interface HealthBot extends TrackedResource { - /** SKU of the Azure Health Bot. */ - sku: Sku; - /** The identity of the Azure Health Bot. */ - identity?: Identity; - /** The set of properties specific to Azure Health Bot resource. */ - properties?: HealthBotProperties; -} - -/** Known values of {@link IdentityType} that the service accepts. */ -export enum KnownIdentityType { - /** User */ - User = "User", - /** Application */ - Application = "Application", - /** ManagedIdentity */ - ManagedIdentity = "ManagedIdentity", - /** Key */ - Key = "Key" -} - -/** - * Defines values for IdentityType. \ - * {@link KnownIdentityType} can be used interchangeably with IdentityType, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **User** \ - * **Application** \ - * **ManagedIdentity** \ - * **Key** - */ -export type IdentityType = string; -/** Defines values for SkuName. */ -export type SkuName = "F0" | "S1" | "C0"; -/** Defines values for ResourceIdentityType. */ -export type ResourceIdentityType = - | "SystemAssigned" - | "UserAssigned" - | "SystemAssigned, UserAssigned" - | "None"; - -/** Optional parameters. */ -export interface BotsCreateOptionalParams 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 create operation. */ -export type BotsCreateResponse = HealthBot; - -/** Optional parameters. */ -export interface BotsGetOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the get operation. */ -export type BotsGetResponse = HealthBot; - -/** Optional parameters. */ -export interface BotsUpdateOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the update operation. */ -export type BotsUpdateResponse = HealthBot; - -/** Optional parameters. */ -export interface BotsDeleteOptionalParams 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; -} - -/** Optional parameters. */ -export interface BotsListByResourceGroupOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listByResourceGroup operation. */ -export type BotsListByResourceGroupResponse = BotResponseList; - -/** Optional parameters. */ -export interface BotsListOptionalParams extends coreClient.OperationOptions {} - -/** Contains response data for the list operation. */ -export type BotsListResponse = BotResponseList; - -/** Optional parameters. */ -export interface BotsListByResourceGroupNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listByResourceGroupNext operation. */ -export type BotsListByResourceGroupNextResponse = BotResponseList; - -/** Optional parameters. */ -export interface BotsListNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listNext operation. */ -export type BotsListNextResponse = BotResponseList; - -/** Optional parameters. */ -export interface OperationsListOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the list operation. */ -export type OperationsListResponse = AvailableOperations; - -/** Optional parameters. */ -export interface OperationsListNextOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the listNext operation. */ -export type OperationsListNextResponse = AvailableOperations; - -/** Optional parameters. */ -export interface HealthbotClientOptionalParams - extends coreClient.ServiceClientOptions { - /** server parameter */ - $host?: string; - /** Api Version */ - apiVersion?: string; - /** Overrides client endpoint. */ - endpoint?: string; -} +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + OperationDetail, + OperationDisplay, + ErrorModel, + ErrorError, + ErrorAdditionalInfo, + HealthBot, + HealthBotProperties, + KeyVaultProperties, + Sku, + SkuName, + Identity, + ResourceIdentityType, + UserAssignedIdentity, + TrackedResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + HealthBotUpdateParameters, + HealthBotKeysResponse, + HealthBotKey, + KnownVersions, +} from "./models.js"; diff --git a/sdk/healthbot/arm-healthbot/src/models/mappers.ts b/sdk/healthbot/arm-healthbot/src/models/mappers.ts deleted file mode 100644 index 6e36900d1d66..000000000000 --- a/sdk/healthbot/arm-healthbot/src/models/mappers.ts +++ /dev/null @@ -1,530 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import * as coreClient from "@azure/core-client"; - -export const Sku: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "Sku", - modelProperties: { - name: { - serializedName: "name", - required: true, - type: { - name: "Enum", - allowedValues: ["F0", "S1", "C0"] - } - } - } - } -}; - -export const Identity: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "Identity", - modelProperties: { - principalId: { - serializedName: "principalId", - readOnly: true, - type: { - name: "String" - } - }, - tenantId: { - serializedName: "tenantId", - readOnly: true, - type: { - name: "String" - } - }, - type: { - serializedName: "type", - type: { - name: "Enum", - allowedValues: [ - "SystemAssigned", - "UserAssigned", - "SystemAssigned, UserAssigned", - "None" - ] - } - }, - userAssignedIdentities: { - serializedName: "userAssignedIdentities", - type: { - name: "Dictionary", - value: { - type: { name: "Composite", className: "UserAssignedIdentity" } - } - } - } - } - } -}; - -export const UserAssignedIdentity: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "UserAssignedIdentity", - modelProperties: { - principalId: { - serializedName: "principalId", - readOnly: true, - type: { - name: "String" - } - }, - clientId: { - serializedName: "clientId", - readOnly: true, - type: { - name: "String" - } - } - } - } -}; - -export const HealthBotProperties: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "HealthBotProperties", - modelProperties: { - provisioningState: { - serializedName: "provisioningState", - readOnly: true, - type: { - name: "String" - } - }, - botManagementPortalLink: { - serializedName: "botManagementPortalLink", - readOnly: 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 ErrorModel: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ErrorModel", - modelProperties: { - error: { - serializedName: "error", - type: { - name: "Composite", - className: "ErrorError" - } - } - } - } -}; - -export const ErrorError: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ErrorError", - 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: "ErrorModel" - } - } - } - }, - 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 HealthBotUpdateParameters: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "HealthBotUpdateParameters", - modelProperties: { - tags: { - serializedName: "tags", - type: { - name: "Dictionary", - value: { type: { name: "String" } } - } - }, - sku: { - serializedName: "sku", - type: { - name: "Composite", - className: "Sku" - } - }, - identity: { - serializedName: "identity", - type: { - name: "Composite", - className: "Identity" - } - }, - location: { - serializedName: "location", - type: { - name: "String" - } - } - } - } -}; - -export const BotResponseList: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "BotResponseList", - modelProperties: { - nextLink: { - serializedName: "nextLink", - readOnly: true, - type: { - name: "String" - } - }, - value: { - serializedName: "value", - readOnly: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "HealthBot" - } - } - } - } - } - } -}; - -export const AvailableOperations: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "AvailableOperations", - modelProperties: { - value: { - serializedName: "value", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "OperationDetail" - } - } - } - }, - nextLink: { - serializedName: "nextLink", - type: { - name: "String" - } - } - } - } -}; - -export const OperationDetail: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "OperationDetail", - modelProperties: { - name: { - serializedName: "name", - type: { - name: "String" - } - }, - isDataAction: { - serializedName: "isDataAction", - type: { - name: "Boolean" - } - }, - display: { - serializedName: "display", - type: { - name: "Composite", - className: "OperationDisplay" - } - }, - origin: { - serializedName: "origin", - type: { - name: "String" - } - }, - properties: { - serializedName: "properties", - type: { - name: "Dictionary", - value: { type: { name: "any" } } - } - } - } - } -}; - -export const OperationDisplay: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "OperationDisplay", - modelProperties: { - provider: { - serializedName: "provider", - type: { - name: "String" - } - }, - resource: { - serializedName: "resource", - type: { - name: "String" - } - }, - operation: { - serializedName: "operation", - type: { - name: "String" - } - }, - description: { - serializedName: "description", - type: { - name: "String" - } - } - } - } -}; - -export const ValidationResult: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ValidationResult", - modelProperties: { - status: { - serializedName: "status", - type: { - name: "String" - } - } - } - } -}; - -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 HealthBot: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "HealthBot", - modelProperties: { - ...TrackedResource.type.modelProperties, - sku: { - serializedName: "sku", - type: { - name: "Composite", - className: "Sku" - } - }, - identity: { - serializedName: "identity", - type: { - name: "Composite", - className: "Identity" - } - }, - properties: { - serializedName: "properties", - type: { - name: "Composite", - className: "HealthBotProperties" - } - } - } - } -}; diff --git a/sdk/healthbot/arm-healthbot/src/models/models.ts b/sdk/healthbot/arm-healthbot/src/models/models.ts new file mode 100644 index 000000000000..296ec422a82c --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/models/models.ts @@ -0,0 +1,545 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** Available operations of the service. */ +export interface _AvailableOperations { + /** Collection of available operation details. */ + value: OperationDetail[]; + /** + * URL client should use to fetch the next page (per server side paging). + * It's null for now, added for future use. + */ + nextLink?: string; +} + +export function _availableOperationsDeserializer(item: any): _AvailableOperations { + return { + value: operationDetailArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function operationDetailArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return operationDetailDeserializer(item); + }); +} + +/** Operation detail payload */ +export interface OperationDetail { + /** Name of the operation */ + name?: string; + /** Indicates whether the operation is a data action */ + isDataAction?: boolean; + /** Display of the operation */ + display?: OperationDisplay; + /** Origin of the operation */ + origin?: string; + /** Additional properties. */ + properties?: any; +} + +export function operationDetailDeserializer(item: any): OperationDetail { + return { + name: item["name"], + isDataAction: item["isDataAction"], + display: !item["display"] ? item["display"] : operationDisplayDeserializer(item["display"]), + origin: item["origin"], + properties: item["properties"], + }; +} + +/** Operation display payload */ +export interface OperationDisplay { + /** Resource provider of the operation */ + provider?: string; + /** Resource of the operation */ + resource?: string; + /** Localized friendly name for the operation */ + operation?: string; + /** Localized friendly description for the operation */ + description?: string; +} + +export function operationDisplayDeserializer(item: any): OperationDisplay { + return { + provider: item["provider"], + resource: item["resource"], + operation: item["operation"], + description: item["description"], + }; +} + +/** The resource management error response. */ +export interface ErrorModel { + /** The error object. */ + error?: ErrorError; +} + +export function errorDeserializer(item: any): ErrorModel { + return { + error: !item["error"] ? item["error"] : errorErrorDeserializer(item["error"]), + }; +} + +/** The error object. */ +export interface ErrorError { + /** The error code. */ + readonly code?: string; + /** The error message. */ + readonly message?: string; + /** The error target. */ + readonly target?: string; + /** The error details. */ + readonly details?: ErrorModel[]; + /** The error additional info. */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +export function errorErrorDeserializer(item: any): ErrorError { + return { + code: item["code"], + message: item["message"], + target: item["target"], + details: !item["details"] ? item["details"] : errorArrayDeserializer(item["details"]), + additionalInfo: !item["additionalInfo"] + ? item["additionalInfo"] + : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]), + }; +} + +export function errorArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorDeserializer(item); + }); +} + +export function errorAdditionalInfoArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorAdditionalInfoDeserializer(item); + }); +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** The additional info type. */ + readonly type?: string; + /** The additional info. */ + readonly info?: any; +} + +export function errorAdditionalInfoDeserializer(item: any): ErrorAdditionalInfo { + return { + type: item["type"], + info: item["info"], + }; +} + +/** Azure Health Bot resource definition */ +export interface HealthBot extends TrackedResource { + /** The set of properties specific to Azure Health Bot resource. */ + properties?: HealthBotProperties; + /** SKU of the Azure Health Bot. */ + sku: Sku; + /** The identity of the Azure Health Bot. */ + identity?: Identity; +} + +export function healthBotSerializer(item: HealthBot): any { + return { + tags: item["tags"], + location: item["location"], + properties: !item["properties"] + ? item["properties"] + : healthBotPropertiesSerializer(item["properties"]), + sku: skuSerializer(item["sku"]), + identity: !item["identity"] ? item["identity"] : identitySerializer(item["identity"]), + }; +} + +export function healthBotDeserializer(item: any): HealthBot { + return { + tags: !item["tags"] + ? item["tags"] + : Object.fromEntries(Object.entries(item["tags"]).map(([k, p]: [string, any]) => [k, p])), + location: item["location"], + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : healthBotPropertiesDeserializer(item["properties"]), + sku: skuDeserializer(item["sku"]), + identity: !item["identity"] ? item["identity"] : identityDeserializer(item["identity"]), + }; +} + +/** The properties of a Azure Health Bot. The Health Bot Service is a cloud platform that empowers developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual health assistants and health bots, that help them improve processes and reduce costs. */ +export interface HealthBotProperties { + /** The provisioning state of the Azure Health Bot resource. */ + readonly provisioningState?: string; + /** The link. */ + readonly botManagementPortalLink?: string; + /** KeyVault properties for the resource encryption. */ + keyVaultProperties?: KeyVaultProperties; + /** The access control method for the Azure Health Bot resource. */ + readonly accessControlMethod?: string; +} + +export function healthBotPropertiesSerializer(item: HealthBotProperties): any { + return { + keyVaultProperties: !item["keyVaultProperties"] + ? item["keyVaultProperties"] + : keyVaultPropertiesSerializer(item["keyVaultProperties"]), + }; +} + +export function healthBotPropertiesDeserializer(item: any): HealthBotProperties { + return { + provisioningState: item["provisioningState"], + botManagementPortalLink: item["botManagementPortalLink"], + keyVaultProperties: !item["keyVaultProperties"] + ? item["keyVaultProperties"] + : keyVaultPropertiesDeserializer(item["keyVaultProperties"]), + accessControlMethod: item["accessControlMethod"], + }; +} + +/** Properties of the key vault. */ +export interface KeyVaultProperties { + /** The name of the key vault key. */ + keyName: string; + /** The version of the key vault key. */ + keyVersion?: string; + /** The Uri of the key vault. */ + keyVaultUri: string; + /** The user assigned identity (ARM resource id) that has access to the key. */ + userIdentity?: string; +} + +export function keyVaultPropertiesSerializer(item: KeyVaultProperties): any { + return { + keyName: item["keyName"], + keyVersion: item["keyVersion"], + keyVaultUri: item["keyVaultUri"], + userIdentity: item["userIdentity"], + }; +} + +export function keyVaultPropertiesDeserializer(item: any): KeyVaultProperties { + return { + keyName: item["keyName"], + keyVersion: item["keyVersion"], + keyVaultUri: item["keyVaultUri"], + userIdentity: item["userIdentity"], + }; +} + +/** The resource model definition representing SKU */ +export interface Sku { + /** The name of the Azure Health Bot SKU */ + name: SkuName; +} + +export function skuSerializer(item: Sku): any { + return { name: item["name"] }; +} + +export function skuDeserializer(item: any): Sku { + return { + name: item["name"], + }; +} + +/** The name of the Azure Health Bot SKU */ +export type SkuName = "F0" | "C0" | "PES" | "C1"; + +/** Identity for the resource. */ +export interface Identity { + /** The principal ID of resource identity. This property will only be provided for a system assigned identity. */ + readonly principalId?: string; + /** The tenant ID of resource. This property will only be provided for a system assigned identity. */ + readonly tenantId?: string; + /** The identity type. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the Azure Health Bot */ + type?: ResourceIdentityType; + /** + * The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: + * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + */ + userAssignedIdentities?: Record; +} + +export function identitySerializer(item: Identity): any { + return { + type: item["type"], + userAssignedIdentities: !item["userAssignedIdentities"] + ? item["userAssignedIdentities"] + : userAssignedIdentityRecordSerializer(item["userAssignedIdentities"]), + }; +} + +export function identityDeserializer(item: any): Identity { + return { + principalId: item["principalId"], + tenantId: item["tenantId"], + type: item["type"], + userAssignedIdentities: !item["userAssignedIdentities"] + ? item["userAssignedIdentities"] + : userAssignedIdentityRecordDeserializer(item["userAssignedIdentities"]), + }; +} + +/** The identity type. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the Azure Health Bot */ +export type ResourceIdentityType = + | "SystemAssigned" + | "UserAssigned" + | "SystemAssigned, UserAssigned" + | "None"; + +export function userAssignedIdentityRecordSerializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] ? item[key] : userAssignedIdentitySerializer(item[key]); + }); + return result; +} + +export function userAssignedIdentityRecordDeserializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] ? item[key] : userAssignedIdentityDeserializer(item[key]); + }); + return result; +} + +/** The details of the user assigned managed identity used by the Video Analyzer resource. */ +export interface UserAssignedIdentity { + /** The principal ID of user assigned identity. */ + readonly principalId?: string; + /** The client ID of user assigned identity. */ + readonly clientId?: string; +} + +export function userAssignedIdentitySerializer(item: UserAssignedIdentity): any { + return item; +} + +export function userAssignedIdentityDeserializer(item: any): UserAssignedIdentity { + return { + principalId: item["principalId"], + clientId: item["clientId"], + }; +} + +/** 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?: Record; + /** The geo-location where the resource lives */ + location: string; +} + +export function trackedResourceSerializer(item: TrackedResource): any { + return { tags: item["tags"], location: item["location"] }; +} + +export function trackedResourceDeserializer(item: any): TrackedResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + tags: !item["tags"] + ? item["tags"] + : Object.fromEntries(Object.entries(item["tags"]).map(([k, p]: [string, any]) => [k, p])), + location: item["location"], + }; +} + +/** 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} */ + readonly id?: string; + /** The name of the resource */ + readonly name?: string; + /** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */ + readonly type?: string; + /** Azure Resource Manager metadata containing createdBy and modifiedBy information. */ + readonly systemData?: SystemData; +} + +export function resourceSerializer(item: Resource): any { + return item; +} + +export function resourceDeserializer(item: any): Resource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["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; +} + +export function systemDataDeserializer(item: any): SystemData { + return { + createdBy: item["createdBy"], + createdByType: item["createdByType"], + createdAt: !item["createdAt"] ? item["createdAt"] : new Date(item["createdAt"]), + lastModifiedBy: item["lastModifiedBy"], + lastModifiedByType: item["lastModifiedByType"], + lastModifiedAt: !item["lastModifiedAt"] + ? item["lastModifiedAt"] + : new Date(item["lastModifiedAt"]), + }; +} + +/** The kind of entity that created the resource. */ +export enum KnownCreatedByType { + /** The entity was created by a user. */ + User = "User", + /** The entity was created by an application. */ + Application = "Application", + /** The entity was created by a managed identity. */ + ManagedIdentity = "ManagedIdentity", + /** The entity was created by a key. */ + Key = "Key", +} + +/** + * The kind of entity that created the resource. \ + * {@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**: The entity was created by a user. \ + * **Application**: The entity was created by an application. \ + * **ManagedIdentity**: The entity was created by a managed identity. \ + * **Key**: The entity was created by a key. + */ +export type CreatedByType = string; + +/** Parameters for updating a Azure Health Bot. */ +export interface HealthBotUpdateParameters { + /** Properties of Azure Health Bot. */ + properties?: HealthBotProperties; + /** Tags for a Azure Health Bot. */ + tags?: Record; + /** SKU of the Azure Health Bot. */ + sku?: Sku; + /** The identity of the Azure Health Bot. */ + identity?: Identity; + location?: string; +} + +export function healthBotUpdateParametersSerializer(item: HealthBotUpdateParameters): any { + return { + properties: !item["properties"] + ? item["properties"] + : healthBotPropertiesSerializer(item["properties"]), + tags: item["tags"], + sku: !item["sku"] ? item["sku"] : skuSerializer(item["sku"]), + identity: !item["identity"] ? item["identity"] : identitySerializer(item["identity"]), + location: item["location"], + }; +} + +/** The list of Azure Health Bot operation response. */ +export interface _BotResponseList { + /** The HealthBot items on this page */ + readonly value: HealthBot[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _botResponseListDeserializer(item: any): _BotResponseList { + return { + value: healthBotArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function healthBotArraySerializer(result: Array): any[] { + return result.map((item) => { + return healthBotSerializer(item); + }); +} + +export function healthBotArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return healthBotDeserializer(item); + }); +} + +/** Health Bot Keys Response. */ +export interface HealthBotKeysResponse { + /** Array of Azure Health Bot Secrets. */ + secrets?: HealthBotKey[]; +} + +export function healthBotKeysResponseDeserializer(item: any): HealthBotKeysResponse { + return { + secrets: !item["secrets"] ? item["secrets"] : healthBotKeyArrayDeserializer(item["secrets"]), + }; +} + +export function healthBotKeyArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return healthBotKeyDeserializer(item); + }); +} + +/** An entry of HealthBotKeysResponse */ +export interface HealthBotKey { + /** The name of the key. */ + keyName?: string; + /** The value of the key. */ + value?: string; +} + +export function healthBotKeyDeserializer(item: any): HealthBotKey { + return { + keyName: item["keyName"], + value: item["value"], + }; +} + +/** The available API versions. */ +export enum KnownVersions { + /** The API versions. */ + V20250525 = "2025-05-25", + /** 2025-11-01 */ + V20251101 = "2025-11-01", +} diff --git a/sdk/healthbot/arm-healthbot/src/models/parameters.ts b/sdk/healthbot/arm-healthbot/src/models/parameters.ts deleted file mode 100644 index c83883c968d4..000000000000 --- a/sdk/healthbot/arm-healthbot/src/models/parameters.ts +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { - OperationParameter, - OperationURLParameter, - OperationQueryParameter -} from "@azure/core-client"; -import { - HealthBot as HealthBotMapper, - HealthBotUpdateParameters as HealthBotUpdateParametersMapper -} from "../models/mappers.js"; - -export const contentType: OperationParameter = { - parameterPath: ["options", "contentType"], - mapper: { - defaultValue: "application/json", - isConstant: true, - serializedName: "Content-Type", - type: { - name: "String" - } - } -}; - -export const parameters: OperationParameter = { - parameterPath: "parameters", - mapper: HealthBotMapper -}; - -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 subscriptionId: OperationURLParameter = { - parameterPath: "subscriptionId", - mapper: { - serializedName: "subscriptionId", - required: true, - type: { - name: "String" - } - } -}; - -export const resourceGroupName: OperationURLParameter = { - parameterPath: "resourceGroupName", - mapper: { - constraints: { - Pattern: new RegExp("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$"), - MaxLength: 64, - MinLength: 2 - }, - serializedName: "resourceGroupName", - required: true, - type: { - name: "String" - } - } -}; - -export const botName: OperationURLParameter = { - parameterPath: "botName", - mapper: { - constraints: { - Pattern: new RegExp("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$"), - MaxLength: 64, - MinLength: 2 - }, - serializedName: "botName", - required: true, - type: { - name: "String" - } - } -}; - -export const apiVersion: OperationQueryParameter = { - parameterPath: "apiVersion", - mapper: { - defaultValue: "2021-06-10", - isConstant: true, - serializedName: "api-version", - type: { - name: "String" - } - } -}; - -export const parameters1: OperationParameter = { - parameterPath: "parameters", - mapper: HealthBotUpdateParametersMapper -}; - -export const nextLink: OperationURLParameter = { - parameterPath: "nextLink", - mapper: { - serializedName: "nextLink", - required: true, - type: { - name: "String" - } - }, - skipEncoding: true -}; diff --git a/sdk/healthbot/arm-healthbot/src/operations/bots.ts b/sdk/healthbot/arm-healthbot/src/operations/bots.ts deleted file mode 100644 index 0c0b09613357..000000000000 --- a/sdk/healthbot/arm-healthbot/src/operations/bots.ts +++ /dev/null @@ -1,619 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; -import { setContinuationToken } from "../pagingHelper.js"; -import { Bots } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import { HealthbotClient } from "../healthbotClient.js"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl.js"; -import { - HealthBot, - BotsListByResourceGroupNextOptionalParams, - BotsListByResourceGroupOptionalParams, - BotsListByResourceGroupResponse, - BotsListNextOptionalParams, - BotsListOptionalParams, - BotsListResponse, - BotsCreateOptionalParams, - BotsCreateResponse, - BotsGetOptionalParams, - BotsGetResponse, - HealthBotUpdateParameters, - BotsUpdateOptionalParams, - BotsUpdateResponse, - BotsDeleteOptionalParams, - BotsListByResourceGroupNextResponse, - BotsListNextResponse -} from "../models/index.js"; - -/// -/** Class containing Bots operations. */ -export class BotsImpl implements Bots { - private readonly client: HealthbotClient; - - /** - * Initialize a new instance of the class Bots class. - * @param client Reference to the service client - */ - constructor(client: HealthbotClient) { - this.client = client; - } - - /** - * Returns all the resources of a particular type belonging to a resource group - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param options The options parameters. - */ - public listByResourceGroup( - resourceGroupName: string, - options?: BotsListByResourceGroupOptionalParams - ): 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?: BotsListByResourceGroupOptionalParams, - settings?: PageSettings - ): AsyncIterableIterator { - let result: BotsListByResourceGroupResponse; - 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?: BotsListByResourceGroupOptionalParams - ): AsyncIterableIterator { - for await (const page of this.listByResourceGroupPagingPage( - resourceGroupName, - options - )) { - yield* page; - } - } - - /** - * Returns all the resources of a particular type belonging to a subscription. - * @param options The options parameters. - */ - public list( - options?: BotsListOptionalParams - ): 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?: BotsListOptionalParams, - settings?: PageSettings - ): AsyncIterableIterator { - let result: BotsListResponse; - 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?: BotsListOptionalParams - ): AsyncIterableIterator { - for await (const page of this.listPagingPage(options)) { - yield* page; - } - } - - /** - * Create a new Azure Health Bot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param parameters The parameters to provide for the created Azure Health Bot. - * @param options The options parameters. - */ - async beginCreate( - resourceGroupName: string, - botName: string, - parameters: HealthBot, - options?: BotsCreateOptionalParams - ): Promise< - PollerLike, BotsCreateResponse> - > { - const directSendOperation = async ( - args: coreClient.OperationArguments, - spec: coreClient.OperationSpec - ): Promise => { - return this.client.sendOperationRequest(args, spec); - }; - const sendOperation = 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 = new LroImpl( - sendOperation, - { resourceGroupName, botName, parameters, options }, - createOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, - intervalInMs: options?.updateIntervalInMs, - lroResourceLocationConfig: "azure-async-operation" - }); - await poller.poll(); - return poller; - } - - /** - * Create a new Azure Health Bot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param parameters The parameters to provide for the created Azure Health Bot. - * @param options The options parameters. - */ - async beginCreateAndWait( - resourceGroupName: string, - botName: string, - parameters: HealthBot, - options?: BotsCreateOptionalParams - ): Promise { - const poller = await this.beginCreate( - resourceGroupName, - botName, - parameters, - options - ); - return poller.pollUntilDone(); - } - - /** - * Get a HealthBot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param options The options parameters. - */ - get( - resourceGroupName: string, - botName: string, - options?: BotsGetOptionalParams - ): Promise { - return this.client.sendOperationRequest( - { resourceGroupName, botName, options }, - getOperationSpec - ); - } - - /** - * Patch a HealthBot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param parameters The parameters to provide for the required Azure Health Bot. - * @param options The options parameters. - */ - update( - resourceGroupName: string, - botName: string, - parameters: HealthBotUpdateParameters, - options?: BotsUpdateOptionalParams - ): Promise { - return this.client.sendOperationRequest( - { resourceGroupName, botName, parameters, options }, - updateOperationSpec - ); - } - - /** - * Delete a HealthBot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param options The options parameters. - */ - async beginDelete( - resourceGroupName: string, - botName: string, - options?: BotsDeleteOptionalParams - ): Promise, void>> { - const directSendOperation = async ( - args: coreClient.OperationArguments, - spec: coreClient.OperationSpec - ): Promise => { - return this.client.sendOperationRequest(args, spec); - }; - const sendOperation = 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 = new LroImpl( - sendOperation, - { resourceGroupName, botName, options }, - deleteOperationSpec - ); - const poller = new LroEngine(lro, { - resumeFrom: options?.resumeFrom, - intervalInMs: options?.updateIntervalInMs - }); - await poller.poll(); - return poller; - } - - /** - * Delete a HealthBot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param options The options parameters. - */ - async beginDeleteAndWait( - resourceGroupName: string, - botName: string, - options?: BotsDeleteOptionalParams - ): Promise { - const poller = await this.beginDelete(resourceGroupName, botName, options); - return poller.pollUntilDone(); - } - - /** - * Returns all the resources of a particular type belonging to a resource group - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param options The options parameters. - */ - private _listByResourceGroup( - resourceGroupName: string, - options?: BotsListByResourceGroupOptionalParams - ): Promise { - return this.client.sendOperationRequest( - { resourceGroupName, options }, - listByResourceGroupOperationSpec - ); - } - - /** - * Returns all the resources of a particular type belonging to a subscription. - * @param options The options parameters. - */ - private _list(options?: BotsListOptionalParams): Promise { - return this.client.sendOperationRequest({ options }, listOperationSpec); - } - - /** - * ListByResourceGroupNext - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @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?: BotsListByResourceGroupNextOptionalParams - ): Promise { - return this.client.sendOperationRequest( - { resourceGroupName, nextLink, options }, - listByResourceGroupNextOperationSpec - ); - } - - /** - * ListNext - * @param nextLink The nextLink from the previous successful call to the List method. - * @param options The options parameters. - */ - private _listNext( - nextLink: string, - options?: BotsListNextOptionalParams - ): Promise { - return this.client.sendOperationRequest( - { nextLink, options }, - listNextOperationSpec - ); - } -} -// Operation Specifications -const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); - -const createOperationSpec: coreClient.OperationSpec = { - path: - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}", - httpMethod: "PUT", - responses: { - 200: { - bodyMapper: Mappers.HealthBot - }, - 201: { - bodyMapper: Mappers.HealthBot - }, - 202: { - bodyMapper: Mappers.HealthBot - }, - 204: { - bodyMapper: Mappers.HealthBot - }, - default: { - bodyMapper: Mappers.ErrorModel - } - }, - requestBody: Parameters.parameters, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.resourceGroupName, - Parameters.botName - ], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer -}; -const getOperationSpec: coreClient.OperationSpec = { - path: - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.HealthBot - }, - default: { - bodyMapper: Mappers.ErrorModel - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.resourceGroupName, - Parameters.botName - ], - headerParameters: [Parameters.accept], - serializer -}; -const updateOperationSpec: coreClient.OperationSpec = { - path: - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}", - httpMethod: "PATCH", - responses: { - 200: { - bodyMapper: Mappers.HealthBot - }, - 201: { - bodyMapper: Mappers.HealthBot - }, - default: { - bodyMapper: Mappers.ErrorModel - } - }, - requestBody: Parameters.parameters1, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.resourceGroupName, - Parameters.botName - ], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer -}; -const deleteOperationSpec: coreClient.OperationSpec = { - path: - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}", - httpMethod: "DELETE", - responses: { - 200: {}, - 201: {}, - 202: {}, - 204: {}, - default: { - bodyMapper: Mappers.ErrorModel - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.resourceGroupName, - Parameters.botName - ], - headerParameters: [Parameters.accept], - serializer -}; -const listByResourceGroupOperationSpec: coreClient.OperationSpec = { - path: - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.BotResponseList - }, - default: { - bodyMapper: Mappers.ErrorModel - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.resourceGroupName - ], - headerParameters: [Parameters.accept], - serializer -}; -const listOperationSpec: coreClient.OperationSpec = { - path: - "/subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.BotResponseList - }, - default: { - bodyMapper: Mappers.ErrorModel - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.subscriptionId], - headerParameters: [Parameters.accept], - serializer -}; -const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.BotResponseList - }, - default: { - bodyMapper: Mappers.ErrorModel - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.resourceGroupName, - Parameters.nextLink - ], - headerParameters: [Parameters.accept], - serializer -}; -const listNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.BotResponseList - }, - default: { - bodyMapper: Mappers.ErrorModel - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [ - Parameters.$host, - Parameters.subscriptionId, - Parameters.nextLink - ], - headerParameters: [Parameters.accept], - serializer -}; diff --git a/sdk/healthbot/arm-healthbot/src/operations/index.ts b/sdk/healthbot/arm-healthbot/src/operations/index.ts deleted file mode 100644 index 58a93f03f1c6..000000000000 --- a/sdk/healthbot/arm-healthbot/src/operations/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export * from "./bots.js"; -export * from "./operations.js"; diff --git a/sdk/healthbot/arm-healthbot/src/operations/operations.ts b/sdk/healthbot/arm-healthbot/src/operations/operations.ts deleted file mode 100644 index aa55aa737159..000000000000 --- a/sdk/healthbot/arm-healthbot/src/operations/operations.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; -import { setContinuationToken } from "../pagingHelper.js"; -import { Operations } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import { HealthbotClient } from "../healthbotClient.js"; -import { - OperationDetail, - OperationsListNextOptionalParams, - OperationsListOptionalParams, - OperationsListResponse, - OperationsListNextResponse -} from "../models/index.js"; - -/// -/** Class containing Operations operations. */ -export class OperationsImpl implements Operations { - private readonly client: HealthbotClient; - - /** - * Initialize a new instance of the class Operations class. - * @param client Reference to the service client - */ - constructor(client: HealthbotClient) { - this.client = client; - } - - /** - * Lists all the available Azure Health Bot operations. - * @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; - } - } - - /** - * Lists all the available Azure Health Bot operations. - * @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.HealthBot/operations", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.AvailableOperations - }, - default: { - bodyMapper: Mappers.ErrorModel - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host], - headerParameters: [Parameters.accept], - serializer -}; -const listNextOperationSpec: coreClient.OperationSpec = { - path: "{nextLink}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.AvailableOperations - }, - default: { - bodyMapper: Mappers.ErrorModel - } - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.nextLink], - headerParameters: [Parameters.accept], - serializer -}; diff --git a/sdk/healthbot/arm-healthbot/src/operationsInterfaces/bots.ts b/sdk/healthbot/arm-healthbot/src/operationsInterfaces/bots.ts deleted file mode 100644 index 41fd043293cf..000000000000 --- a/sdk/healthbot/arm-healthbot/src/operationsInterfaces/bots.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { PollerLike, PollOperationState } from "@azure/core-lro"; -import { - HealthBot, - BotsListByResourceGroupOptionalParams, - BotsListOptionalParams, - BotsCreateOptionalParams, - BotsCreateResponse, - BotsGetOptionalParams, - BotsGetResponse, - HealthBotUpdateParameters, - BotsUpdateOptionalParams, - BotsUpdateResponse, - BotsDeleteOptionalParams -} from "../models/index.js"; - -/// -/** Interface representing a Bots. */ -export interface Bots { - /** - * Returns all the resources of a particular type belonging to a resource group - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param options The options parameters. - */ - listByResourceGroup( - resourceGroupName: string, - options?: BotsListByResourceGroupOptionalParams - ): PagedAsyncIterableIterator; - /** - * Returns all the resources of a particular type belonging to a subscription. - * @param options The options parameters. - */ - list(options?: BotsListOptionalParams): PagedAsyncIterableIterator; - /** - * Create a new Azure Health Bot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param parameters The parameters to provide for the created Azure Health Bot. - * @param options The options parameters. - */ - beginCreate( - resourceGroupName: string, - botName: string, - parameters: HealthBot, - options?: BotsCreateOptionalParams - ): Promise< - PollerLike, BotsCreateResponse> - >; - /** - * Create a new Azure Health Bot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param parameters The parameters to provide for the created Azure Health Bot. - * @param options The options parameters. - */ - beginCreateAndWait( - resourceGroupName: string, - botName: string, - parameters: HealthBot, - options?: BotsCreateOptionalParams - ): Promise; - /** - * Get a HealthBot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param options The options parameters. - */ - get( - resourceGroupName: string, - botName: string, - options?: BotsGetOptionalParams - ): Promise; - /** - * Patch a HealthBot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param parameters The parameters to provide for the required Azure Health Bot. - * @param options The options parameters. - */ - update( - resourceGroupName: string, - botName: string, - parameters: HealthBotUpdateParameters, - options?: BotsUpdateOptionalParams - ): Promise; - /** - * Delete a HealthBot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param options The options parameters. - */ - beginDelete( - resourceGroupName: string, - botName: string, - options?: BotsDeleteOptionalParams - ): Promise, void>>; - /** - * Delete a HealthBot. - * @param resourceGroupName The name of the Bot resource group in the user subscription. - * @param botName The name of the Bot resource. - * @param options The options parameters. - */ - beginDeleteAndWait( - resourceGroupName: string, - botName: string, - options?: BotsDeleteOptionalParams - ): Promise; -} diff --git a/sdk/healthbot/arm-healthbot/src/operationsInterfaces/index.ts b/sdk/healthbot/arm-healthbot/src/operationsInterfaces/index.ts deleted file mode 100644 index 58a93f03f1c6..000000000000 --- a/sdk/healthbot/arm-healthbot/src/operationsInterfaces/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export * from "./bots.js"; -export * from "./operations.js"; diff --git a/sdk/healthbot/arm-healthbot/src/operationsInterfaces/operations.ts b/sdk/healthbot/arm-healthbot/src/operationsInterfaces/operations.ts deleted file mode 100644 index 83e4f54fea4c..000000000000 --- a/sdk/healthbot/arm-healthbot/src/operationsInterfaces/operations.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { PagedAsyncIterableIterator } from "@azure/core-paging"; -import { OperationDetail, OperationsListOptionalParams } from "../models/index.js"; - -/// -/** Interface representing a Operations. */ -export interface Operations { - /** - * Lists all the available Azure Health Bot operations. - * @param options The options parameters. - */ - list( - options?: OperationsListOptionalParams - ): PagedAsyncIterableIterator; -} diff --git a/sdk/healthbot/arm-healthbot/src/pagingHelper.ts b/sdk/healthbot/arm-healthbot/src/pagingHelper.ts deleted file mode 100644 index d85fc13bce1e..000000000000 --- a/sdk/healthbot/arm-healthbot/src/pagingHelper.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export interface PageInfo { - continuationToken?: string; -} - -const pageMap = new WeakMap(); - -/** - * Given a result page from a pageable operation, returns a - * continuation token that can be used to begin paging from - * that point later. - * @param page A result object from calling .byPage() on a paged operation. - * @returns The continuation token that can be passed into byPage(). - */ -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/healthbot/arm-healthbot/src/restorePollerHelpers.ts b/sdk/healthbot/arm-healthbot/src/restorePollerHelpers.ts new file mode 100644 index 000000000000..e55442961466 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/restorePollerHelpers.ts @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { HealthbotClient } from "./healthbotClient.js"; +import { + _$deleteDeserialize, + _updateDeserialize, + _createDeserialize, +} from "./api/bots/operations.js"; +import { getLongRunningPoller } from "./static-helpers/pollingHelpers.js"; +import type { OperationOptions, PathUncheckedResponse } from "@azure-rest/core-client"; +import type { AbortSignalLike } from "@azure/abort-controller"; +import type { PollerLike, OperationState, ResourceLocationConfig } from "@azure/core-lro"; +import { deserializeState } from "@azure/core-lro"; + +export interface RestorePollerOptions< + TResult, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +> extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** + * The signal which can be used to abort requests. + */ + abortSignal?: AbortSignalLike; + /** Deserialization function for raw response body */ + processResponseBody?: (result: TResponse) => Promise; +} + +/** + * Creates a poller from the serialized state of another poller. This can be + * useful when you want to create pollers on a different host or a poller + * needs to be constructed after the original one is not in scope. + */ +export function restorePoller( + client: HealthbotClient, + serializedState: string, + sourceOperation: (...args: any[]) => PollerLike, TResult>, + options?: RestorePollerOptions, +): PollerLike, TResult> { + const pollerConfig = deserializeState(serializedState).config; + const { initialRequestUrl, requestMethod, metadata } = pollerConfig; + if (!initialRequestUrl || !requestMethod) { + throw new Error( + `Invalid serialized state: ${serializedState} for sourceOperation ${sourceOperation?.name}`, + ); + } + const resourceLocationConfig = metadata?.["resourceLocationConfig"] as + | ResourceLocationConfig + | undefined; + const { deserializer, expectedStatuses = [] } = + getDeserializationHelper(initialRequestUrl, requestMethod) ?? {}; + const deserializeHelper = options?.processResponseBody ?? deserializer; + if (!deserializeHelper) { + throw new Error( + `Please ensure the operation is in this client! We can't find its deserializeHelper for ${sourceOperation?.name}.`, + ); + } + return getLongRunningPoller( + (client as any)["_client"] ?? client, + deserializeHelper as (result: TResponse) => Promise, + expectedStatuses, + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + resourceLocationConfig, + restoreFrom: serializedState, + initialRequestUrl, + }, + ); +} + +interface DeserializationHelper { + deserializer: (result: PathUncheckedResponse) => Promise; + expectedStatuses: string[]; +} + +const deserializeMap: Record = { + "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}": + { deserializer: _$deleteDeserialize, expectedStatuses: ["200", "202", "204", "201"] }, + "PATCH /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}": + { deserializer: _updateDeserialize, expectedStatuses: ["200", "201", "202"] }, + "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}": + { deserializer: _createDeserialize, expectedStatuses: ["200", "201", "202"] }, +}; + +function getDeserializationHelper( + urlStr: string, + method: string, +): DeserializationHelper | undefined { + const path = new URL(urlStr).pathname; + const pathParts = path.split("/"); + + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: DeserializationHelper | undefined; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(deserializeMap)) { + // Extracting the path from the map key which is in format + // GET /path/foo + if (!key.startsWith(method)) { + continue; + } + const candidatePath = getPathFromMapKey(key); + // Get each part of the url path + const candidateParts = candidatePath.split("/"); + + // track if we have found a match to return the values found. + let found = true; + for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) { + if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test( + pathParts[j] || "", + ); + + if (!isMatched) { + found = false; + break; + } + continue; + } + + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; + } + } + + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } + + return matchedValue; +} + +function getPathFromMapKey(mapKey: string): string { + const pathStart = mapKey.indexOf("/"); + return mapKey.slice(pathStart); +} diff --git a/sdk/healthbot/arm-healthbot/src/static-helpers/cloudSettingHelpers.ts b/sdk/healthbot/arm-healthbot/src/static-helpers/cloudSettingHelpers.ts new file mode 100644 index 000000000000..613112c6e397 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/static-helpers/cloudSettingHelpers.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * An enum to describe Azure Cloud environments. + * @enum {string} + */ +export enum AzureClouds { + /** Azure public cloud, which is the default cloud for Azure SDKs. */ + AZURE_PUBLIC_CLOUD = "AZURE_PUBLIC_CLOUD", + /** Azure China cloud */ + AZURE_CHINA_CLOUD = "AZURE_CHINA_CLOUD", + /** Azure US government cloud */ + AZURE_US_GOVERNMENT = "AZURE_US_GOVERNMENT", +} + +/** The supported values for cloud setting as a string literal type */ +export type AzureSupportedClouds = `${AzureClouds}`; + +/** + * Gets the Azure Resource Manager endpoint URL for the specified cloud setting. + * @param cloudSetting - The Azure cloud environment setting. Use one of the AzureClouds enum values. + * @returns The ARM endpoint URL for the specified cloud, or undefined if cloudSetting is undefined. + * @throws {Error} Throws an error if an unknown cloud setting is provided. + */ +export function getArmEndpoint(cloudSetting?: AzureSupportedClouds): string | undefined { + if (cloudSetting === undefined) { + return undefined; + } + const cloudEndpoints: Record = { + AZURE_CHINA_CLOUD: "https://management.chinacloudapi.cn/", + AZURE_US_GOVERNMENT: "https://management.usgovcloudapi.net/", + AZURE_PUBLIC_CLOUD: "https://management.azure.com/", + }; + if (cloudSetting in cloudEndpoints) { + return cloudEndpoints[cloudSetting]; + } else { + throw new Error( + `Unknown cloud setting: ${cloudSetting}. Please refer to the enum AzureClouds for possible values.`, + ); + } +} diff --git a/sdk/healthbot/arm-healthbot/src/static-helpers/pagingHelpers.ts b/sdk/healthbot/arm-healthbot/src/static-helpers/pagingHelpers.ts new file mode 100644 index 000000000000..6f219e3c88cf --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/static-helpers/pagingHelpers.ts @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { Client, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError } from "@azure-rest/core-client"; +import { RestError } from "@azure/core-rest-pipeline"; + +/** + * Options for the byPage method + */ +export interface PageSettings { + /** + * A reference to a specific page to start iterating from. + */ + continuationToken?: string; +} + +/** + * An interface that describes a page of results. + */ +export type ContinuablePage = TPage & { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +}; + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; +} + +/** + * An interface that describes how to communicate with the service. + */ +export interface PagedResult< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * Link to the first page of results. + */ + firstPageLink?: string; + /** + * A method that returns a page of results. + */ + getPage: (pageLink?: string) => Promise<{ page: TPage; nextPageLink?: string } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: (settings?: TPageSettings) => AsyncIterableIterator>; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => TElement[]; +} + +/** + * Options for the paging helper + */ +export interface BuildPagedAsyncIteratorOptions { + itemName?: string; + nextLinkName?: string; + nextLinkMethod?: "GET" | "POST"; +} + +/** + * Helper to paginate results in a generic way and return a PagedAsyncIterableIterator + */ +export function buildPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +>( + client: Client, + getInitialResponse: () => PromiseLike, + processResponseBody: (result: TResponse) => PromiseLike, + expectedStatuses: string[], + options: BuildPagedAsyncIteratorOptions = {}, +): PagedAsyncIterableIterator { + const itemName = options.itemName ?? "value"; + const nextLinkName = options.nextLinkName ?? "nextLink"; + const nextLinkMethod = options.nextLinkMethod ?? "GET"; + const pagedResult: PagedResult = { + getPage: async (pageLink?: string) => { + const result = + pageLink === undefined + ? await getInitialResponse() + : nextLinkMethod === "POST" + ? await client.pathUnchecked(pageLink).post() + : await client.pathUnchecked(pageLink).get(); + checkPagingRequest(result, expectedStatuses); + const results = await processResponseBody(result as TResponse); + const nextLink = getNextLink(results, nextLinkName); + const values = getElements(results, itemName) as TPage; + return { + page: values, + nextPageLink: nextLink, + }; + }, + byPage: (settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }, + }; + return getPagedAsyncIterator(pagedResult); +} + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ + +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator(pagedResult); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + ((settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + for await (const page of pages) { + yield* page as unknown as TElement[]; + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: string; + } = {}, +): AsyncIterableIterator> { + const { pageLink } = options; + let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); + if (!response) { + return; + } + let result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + } +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined" && nextLink !== null) { + throw new RestError( + `Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`, + ); + } + + if (nextLink === null) { + return undefined; + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + if (!Array.isArray(value)) { + throw new RestError( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`, + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse, expectedStatuses: string[]): void { + if (!expectedStatuses.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response, + ); + } +} diff --git a/sdk/healthbot/arm-healthbot/src/static-helpers/pollingHelpers.ts b/sdk/healthbot/arm-healthbot/src/static-helpers/pollingHelpers.ts new file mode 100644 index 000000000000..63b3c201e5a8 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/static-helpers/pollingHelpers.ts @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { + PollerLike, + OperationState, + ResourceLocationConfig, + RunningOperation, + OperationResponse, +} from "@azure/core-lro"; +import { createHttpPoller } from "@azure/core-lro"; + +import type { Client, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError } from "@azure-rest/core-client"; +import type { AbortSignalLike } from "@azure/abort-controller"; + +export interface GetLongRunningPollerOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** + * The signal which can be used to abort requests. + */ + abortSignal?: AbortSignalLike; + /** + * The potential location of the result of the LRO if specified by the LRO extension in the swagger. + */ + resourceLocationConfig?: ResourceLocationConfig; + /** + * The original url of the LRO + * Should not be null when restoreFrom is set + */ + initialRequestUrl?: string; + /** + * A serialized poller which can be used to resume an existing paused Long-Running-Operation. + */ + restoreFrom?: string; + /** + * The function to get the initial response + */ + getInitialResponse?: () => PromiseLike; +} +export function getLongRunningPoller( + client: Client, + processResponseBody: (result: TResponse) => Promise, + expectedStatuses: string[], + options: GetLongRunningPollerOptions, +): PollerLike, TResult> { + const { restoreFrom, getInitialResponse } = options; + if (!restoreFrom && !getInitialResponse) { + throw new Error("Either restoreFrom or getInitialResponse must be specified"); + } + let initialResponse: TResponse | undefined = undefined; + const pollAbortController = new AbortController(); + const poller: RunningOperation = { + sendInitialRequest: async () => { + if (!getInitialResponse) { + throw new Error("getInitialResponse is required when initializing a new poller"); + } + initialResponse = await getInitialResponse(); + return getLroResponse(initialResponse, expectedStatuses); + }, + sendPollRequest: async ( + path: string, + pollOptions?: { + abortSignal?: AbortSignalLike; + }, + ) => { + // The poll request would both listen to the user provided abort signal and the poller's own abort signal + function abortListener(): void { + pollAbortController.abort(); + } + const abortSignal = pollAbortController.signal; + if (options.abortSignal?.aborted) { + pollAbortController.abort(); + } else if (pollOptions?.abortSignal?.aborted) { + pollAbortController.abort(); + } else if (!abortSignal.aborted) { + options.abortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + pollOptions?.abortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + } + let response; + try { + response = await client.pathUnchecked(path).get({ abortSignal }); + } finally { + options.abortSignal?.removeEventListener("abort", abortListener); + pollOptions?.abortSignal?.removeEventListener("abort", abortListener); + } + + return getLroResponse(response as TResponse, expectedStatuses); + }, + }; + return createHttpPoller(poller, { + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: options?.resourceLocationConfig, + restoreFrom: options?.restoreFrom, + processResult: (result: unknown) => { + return processResponseBody(result as TResponse); + }, + }); +} +/** + * Converts a Rest Client response to a response that the LRO implementation understands + * @param response - a rest client http response + * @param deserializeFn - deserialize function to convert Rest response to modular output + * @returns - An LRO response that the LRO implementation understands + */ +function getLroResponse( + response: TResponse, + expectedStatuses: string[], +): OperationResponse { + if (!expectedStatuses.includes(response.status)) { + throw createRestError(response); + } + + return { + flatResponse: response, + rawResponse: { + ...response, + statusCode: Number.parseInt(response.status), + body: response.body, + }, + }; +} diff --git a/sdk/healthbot/arm-healthbot/src/static-helpers/simplePollerHelpers.ts b/sdk/healthbot/arm-healthbot/src/static-helpers/simplePollerHelpers.ts new file mode 100644 index 000000000000..f6996f3cee67 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/static-helpers/simplePollerHelpers.ts @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { PollerLike, OperationState, CancelOnProgress } from "@azure/core-lro"; +import type { AbortSignalLike } from "@azure/abort-controller"; + +/** + * A simple poller that can be used to poll a long running operation. + */ +export interface SimplePollerLike, TResult> { + /** + * Returns true if the poller has finished polling. + */ + isDone(): boolean; + /** + * Returns the state of the operation. + */ + getOperationState(): TState; + /** + * Returns the result value of the operation, + * regardless of the state of the poller. + * It can return undefined or an incomplete form of the final TResult value + * depending on the implementation. + */ + getResult(): TResult | undefined; + /** + * Returns a promise that will resolve once a single polling request finishes. + * It does this by calling the update method of the Poller's operation. + */ + poll(options?: { abortSignal?: AbortSignalLike }): Promise; + /** + * Returns a promise that will resolve once the underlying operation is completed. + */ + pollUntilDone(pollOptions?: { abortSignal?: AbortSignalLike }): Promise; + /** + * Invokes the provided callback after each polling is completed, + * sending the current state of the poller's operation. + * + * It returns a method that can be used to stop receiving updates on the given callback function. + */ + onProgress(callback: (state: TState) => void): CancelOnProgress; + + /** + * Returns a promise that could be used for serialized version of the poller's operation + * by invoking the operation's serialize method. + */ + serialize(): Promise; + + /** + * Wait the poller to be submitted. + */ + submitted(): Promise; + + /** + * Returns a string representation of the poller's operation. Similar to serialize but returns a string. + * @deprecated Use serialize() instead. + */ + toString(): string; + + /** + * Stops the poller from continuing to poll. Please note this will only stop the client-side polling + * @deprecated Use abortSignal to stop polling instead. + */ + stopPolling(): void; + + /** + * Returns true if the poller is stopped. + * @deprecated Use abortSignal status to track this instead. + */ + isStopped(): boolean; +} + +/** + * Create the deprecated SimplePollerLike from PollerLike + * @param poller PollerLike to convert + * @returns SimplePollerLike + */ +export function getSimplePoller( + poller: PollerLike, TResult>, +): SimplePollerLike, TResult> { + const simplePoller: SimplePollerLike, TResult> = { + isDone() { + return poller.isDone; + }, + isStopped() { + throw new Error("isStopped is deprecated. Use abortSignal status to track this instead."); + }, + getOperationState() { + if (!poller.operationState) { + throw new Error( + "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().", + ); + } + return poller.operationState; + }, + getResult() { + return poller.result; + }, + toString() { + if (!poller.operationState) { + throw new Error( + "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().", + ); + } + return JSON.stringify({ + state: poller.operationState, + }); + }, + stopPolling() { + throw new Error("stopPolling is deprecated. Use abortSignal to stop polling instead."); + }, + onProgress: poller.onProgress, + poll: poller.poll, + pollUntilDone: poller.pollUntilDone, + serialize: poller.serialize, + submitted: poller.submitted, + }; + return simplePoller; +} diff --git a/sdk/healthbot/arm-healthbot/src/static-helpers/urlTemplate.ts b/sdk/healthbot/arm-healthbot/src/static-helpers/urlTemplate.ts new file mode 100644 index 000000000000..c7109898692a --- /dev/null +++ b/sdk/healthbot/arm-healthbot/src/static-helpers/urlTemplate.ts @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// --------------------- +// interfaces +// --------------------- +interface ValueOptions { + isFirst: boolean; // is first value in the expression + op?: string; // operator + varValue?: any; // variable value + varName?: string; // variable name + modifier?: string; // modifier e.g * + reserved?: boolean; // if true we'll keep reserved words with not encoding +} + +export interface UrlTemplateOptions { + // if set to true, reserved characters will not be encoded + allowReserved?: boolean; +} + +// --------------------- +// helpers +// --------------------- +function encodeComponent(val: string, reserved?: boolean, op?: string): string { + return (reserved ?? op === "+") || op === "#" + ? encodeReservedComponent(val) + : encodeRFC3986URIComponent(val); +} + +function encodeReservedComponent(str: string): string { + return str + .split(/(%[0-9A-Fa-f]{2})/g) + .map((part) => (!/%[0-9A-Fa-f]/.test(part) ? encodeURI(part) : part)) + .join(""); +} + +function encodeRFC3986URIComponent(str: string): string { + return encodeURIComponent(str).replace( + /[!'()*]/g, + (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`, + ); +} + +function isDefined(val: any): boolean { + return val !== undefined && val !== null; +} + +function getNamedAndIfEmpty(op?: string): [boolean, string] { + return [!!op && [";", "?", "&"].includes(op), !!op && ["?", "&"].includes(op) ? "=" : ""]; +} + +function getFirstOrSep(op?: string, isFirst = false): string { + if (isFirst) { + return !op || op === "+" ? "" : op; + } else if (!op || op === "+" || op === "#") { + return ","; + } else if (op === "?") { + return "&"; + } else { + return op; + } +} + +function getExpandedValue(option: ValueOptions): string { + let isFirst = option.isFirst; + const { op, varName, varValue: value, reserved } = option; + const vals: string[] = []; + const [named, ifEmpty] = getNamedAndIfEmpty(op); + + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + // prepare the following parts: separator, varName, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (named && varName) { + vals.push(`${encodeURIComponent(varName)}`); + if (val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + const val = value[key]; + if (!isDefined(val)) { + continue; + } + // prepare the following parts: separator, key, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (key) { + vals.push(`${encodeURIComponent(key)}`); + if (named && val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } + return vals.join(""); +} + +function getNonExpandedValue(option: ValueOptions): string | undefined { + const { op, varName, varValue: value, isFirst, reserved } = option; + const vals: string[] = []; + const first = getFirstOrSep(op, isFirst); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + if (named && varName) { + vals.push(encodeComponent(varName, reserved, op)); + if (value === "") { + if (!ifEmpty) { + vals.push(ifEmpty); + } + return !vals.join("") ? undefined : `${first}${vals.join("")}`; + } + vals.push("="); + } + + const items = []; + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + items.push(encodeComponent(val, reserved, op)); + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + if (!isDefined(value[key])) { + continue; + } + items.push(encodeRFC3986URIComponent(key)); + items.push(encodeComponent(value[key], reserved, op)); + } + } + vals.push(items.join(",")); + return !vals.join(",") ? undefined : `${first}${vals.join("")}`; +} + +function getVarValue(option: ValueOptions): string | undefined { + const { op, varName, modifier, isFirst, reserved, varValue: value } = option; + + if (!isDefined(value)) { + return undefined; + } else if (["string", "number", "boolean"].includes(typeof value)) { + let val = value.toString(); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + const vals: string[] = [getFirstOrSep(op, isFirst)]; + if (named && varName) { + // No need to encode varName considering it is already encoded + vals.push(varName); + if (val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + if (modifier && modifier !== "*") { + val = val.substring(0, parseInt(modifier, 10)); + } + vals.push(encodeComponent(val, reserved, op)); + return vals.join(""); + } else if (modifier === "*") { + return getExpandedValue(option); + } else { + return getNonExpandedValue(option); + } +} + +// --------------------------------------------------------------------------------------------------- +// This is an implementation of RFC 6570 URI Template: https://datatracker.ietf.org/doc/html/rfc6570. +// --------------------------------------------------------------------------------------------------- +export function expandUrlTemplate( + template: string, + context: Record, + option?: UrlTemplateOptions, +): string { + const result = template.replace(/\{([^{}]+)\}|([^{}]+)/g, (_, expr, text) => { + if (!expr) { + return encodeReservedComponent(text); + } + let op; + if (["+", "#", ".", "/", ";", "?", "&"].includes(expr[0])) { + op = expr[0]; + expr = expr.slice(1); + } + const varList = expr.split(/,/g); + const result = []; + for (const varSpec of varList) { + const varMatch = /([^:*]*)(?::(\d+)|(\*))?/.exec(varSpec); + if (!varMatch || !varMatch[1]) { + continue; + } + const varValue = getVarValue({ + isFirst: result.length === 0, + op, + varValue: context[varMatch[1]], + varName: varMatch[1], + modifier: varMatch[2] || varMatch[3], + reserved: option?.allowReserved, + }); + if (varValue) { + result.push(varValue); + } + } + return result.join(""); + }); + + return normalizeUnreserved(result); +} + +/** + * Normalize an expanded URI by decoding percent-encoded unreserved characters. + * RFC 3986 unreserved: "-" / "." / "~" + */ +function normalizeUnreserved(uri: string): string { + return uri.replace(/%([0-9A-Fa-f]{2})/g, (match, hex) => { + const char = String.fromCharCode(parseInt(hex, 16)); + // Decode only if it's unreserved + if (/[\-.~]/.test(char)) { + return char; + } + return match; // leave other encodings intact + }); +} diff --git a/sdk/healthbot/arm-healthbot/test/healthbot.spec.ts b/sdk/healthbot/arm-healthbot/test/healthbot.spec.ts deleted file mode 100644 index f8c36cf35a5b..000000000000 --- a/sdk/healthbot/arm-healthbot/test/healthbot.spec.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import type { RecorderStartOptions } from "@azure-tools/test-recorder"; -import { Recorder } from "@azure-tools/test-recorder"; -import { describe, it, assert, beforeEach, afterEach } from "vitest"; - -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, - removeCentralSanitizers: [ - "AZSDK3493", // .name in the body is not a secret and is listed below in the beforeEach section - "AZSDK3430", // .id in the body is not a secret and is listed below in the beforeEach section - ], -}; - -describe("My test", () => { - let recorder: Recorder; - - beforeEach(async (ctx) => { - recorder = new Recorder(ctx); - await recorder.start(recorderOptions); - }); - - afterEach(async () => { - await recorder.stop(); - }); - - it("sample test", async function () { - assert(true); - }); -}); diff --git a/sdk/healthbot/arm-healthbot/test/public/sampleTest.spec.ts b/sdk/healthbot/arm-healthbot/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..19cf10ee4956 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/test/public/sampleTest.spec.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// import { Recorder } from "@azure-tools/test-recorder"; +// import { createRecorder } from "./utils/recordedClient.js"; +import { + assert, + // beforeEach, + // afterEach, + it, + describe, +} from "vitest"; + +describe("My test", () => { + // let recorder: Recorder; + + // beforeEach(async function(ctx) { + // recorder = await createRecorder(ctx); + // }); + + // afterEach(async function() { + // await recorder.stop(); + // ); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/healthbot/arm-healthbot/test/public/utils/recordedClient.ts b/sdk/healthbot/arm-healthbot/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..285e4643c45e --- /dev/null +++ b/sdk/healthbot/arm-healthbot/test/public/utils/recordedClient.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { RecorderStartOptions, VitestTestContext } from "@azure-tools/test-recorder"; +import { Recorder } from "@azure-tools/test-recorder"; + +const replaceableVariables: Record = { + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables, +}; + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export async function createRecorder(context: VitestTestContext): Promise { + const recorder = new Recorder(context); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/healthbot/arm-healthbot/test/snippets.spec.ts b/sdk/healthbot/arm-healthbot/test/snippets.spec.ts index b352998fb706..396b110cf583 100644 --- a/sdk/healthbot/arm-healthbot/test/snippets.spec.ts +++ b/sdk/healthbot/arm-healthbot/test/snippets.spec.ts @@ -13,11 +13,11 @@ describe("snippets", () => { }); it("ReadmeSampleCreateClient_Browser", async () => { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; const credential = new InteractiveBrowserCredential({ tenantId: "", clientId: "", }); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; const client = new HealthbotClient(credential, subscriptionId); }); diff --git a/sdk/healthbot/arm-healthbot/tsconfig.json b/sdk/healthbot/arm-healthbot/tsconfig.json index d466f1460665..0e57dbd186e5 100644 --- a/sdk/healthbot/arm-healthbot/tsconfig.json +++ b/sdk/healthbot/arm-healthbot/tsconfig.json @@ -12,6 +12,5 @@ { "path": "./tsconfig.snippets.json" } - ], - "files": [] + ] } diff --git a/sdk/healthbot/arm-healthbot/tsp-location.yaml b/sdk/healthbot/arm-healthbot/tsp-location.yaml new file mode 100644 index 000000000000..10589e8f8eb8 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/healthbot/HealthBot.Management +commit: 2035ed86db7ae475d5378f332cf96b069c6ea320 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/healthbot/arm-healthbot/vitest.esm.config.ts b/sdk/healthbot/arm-healthbot/vitest.esm.config.ts new file mode 100644 index 000000000000..5e9735e9b144 --- /dev/null +++ b/sdk/healthbot/arm-healthbot/vitest.esm.config.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { mergeConfig } from "vitest/config"; +import vitestConfig from "./vitest.config.ts"; +import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; + +export default mergeConfig(vitestConfig, vitestEsmConfig); diff --git a/sdk/healthbot/ci.mgmt.yml b/sdk/healthbot/ci.mgmt.yml index 66dbf81e1210..507f451b3e2b 100644 --- a/sdk/healthbot/ci.mgmt.yml +++ b/sdk/healthbot/ci.mgmt.yml @@ -1,11 +1,13 @@ # NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. - + trigger: branches: include: - main - release/* - hotfix/* + exclude: + - feature/v4 paths: include: - sdk/healthbot/ci.mgmt.yml