diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 07a389eaa442..877aedf90420 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -2406,6 +2406,16 @@ packages: dev: false optional: true + /@eslint-community/eslint-utils@4.4.0(eslint@8.57.1): + resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + dependencies: + eslint: 8.57.1 + eslint-visitor-keys: 3.4.3 + dev: false + /@eslint-community/eslint-utils@4.4.0(eslint@9.11.0): resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2437,6 +2447,23 @@ packages: - supports-color dev: false + /@eslint/eslintrc@2.1.4: + resolution: {integrity: sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + ajv: 6.12.6 + debug: 4.3.7(supports-color@8.1.1) + espree: 9.6.1 + globals: 13.24.0 + ignore: 5.3.2 + import-fresh: 3.3.0 + js-yaml: 4.1.0 + minimatch: 3.1.2 + strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color + dev: false + /@eslint/eslintrc@3.1.0: resolution: {integrity: sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2454,6 +2481,11 @@ packages: - supports-color dev: false + /@eslint/js@8.57.1: + resolution: {integrity: sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dev: false + /@eslint/js@9.11.0: resolution: {integrity: sha512-LPkkenkDqyzTFauZLLAPhIb48fj6drrfMvRGSL9tS3AcZBSVTllemLSNyCvHNNL2t797S/6DJNSIwRwXgMO/eQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2495,11 +2527,28 @@ packages: yargs: 17.7.2 dev: false + /@humanwhocodes/config-array@0.13.0: + resolution: {integrity: sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==} + engines: {node: '>=10.10.0'} + deprecated: Use @eslint/config-array instead + dependencies: + '@humanwhocodes/object-schema': 2.0.3 + debug: 4.3.7(supports-color@8.1.1) + minimatch: 3.1.2 + transitivePeerDependencies: + - supports-color + dev: false + /@humanwhocodes/module-importer@1.0.1: resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} engines: {node: '>=12.22'} dev: false + /@humanwhocodes/object-schema@2.0.3: + resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} + deprecated: Use @eslint/object-schema instead + dev: false + /@humanwhocodes/retry@0.3.0: resolution: {integrity: sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==} engines: {node: '>=18.18'} @@ -4333,6 +4382,10 @@ packages: eslint-visitor-keys: 3.4.3 dev: false + /@ungap/structured-clone@1.2.0: + resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} + dev: false + /@vitest/browser@1.6.0(playwright@1.47.2)(vitest@1.6.0): resolution: {integrity: sha512-3Wpp9h1hf++rRVPvoXevkdHybLhJVn7MwIMKMIh08tVaoDMmT6fnNhbP222Z48V9PptpYeA5zvH9Ct/ZcaAzmQ==} peerDependencies: @@ -4667,7 +4720,7 @@ packages: /ajv-formats@3.0.1: resolution: {integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==} dependencies: - ajv: 8.13.0 + ajv: 8.17.1 dev: false /ajv@6.12.6: @@ -5840,6 +5893,13 @@ packages: path-type: 4.0.0 dev: false + /doctrine@3.0.0: + resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} + engines: {node: '>=6.0.0'} + dependencies: + esutils: 2.0.3 + dev: false + /dom-accessibility-api@0.5.16: resolution: {integrity: sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==} dev: false @@ -6178,6 +6238,14 @@ packages: '@microsoft/tsdoc-config': 0.16.2 dev: false + /eslint-scope@7.2.2: + resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + esrecurse: 4.3.0 + estraverse: 5.3.0 + dev: false + /eslint-scope@8.0.2: resolution: {integrity: sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -6196,6 +6264,53 @@ packages: engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} dev: false + /eslint@8.57.1: + resolution: {integrity: sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + hasBin: true + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.1) + '@eslint-community/regexpp': 4.11.1 + '@eslint/eslintrc': 2.1.4 + '@eslint/js': 8.57.1 + '@humanwhocodes/config-array': 0.13.0 + '@humanwhocodes/module-importer': 1.0.1 + '@nodelib/fs.walk': 1.2.8 + '@ungap/structured-clone': 1.2.0 + ajv: 6.12.6 + chalk: 4.1.2 + cross-spawn: 7.0.3 + debug: 4.3.7(supports-color@8.1.1) + doctrine: 3.0.0 + escape-string-regexp: 4.0.0 + eslint-scope: 7.2.2 + eslint-visitor-keys: 3.4.3 + espree: 9.6.1 + esquery: 1.6.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 6.0.1 + find-up: 5.0.0 + glob-parent: 6.0.2 + globals: 13.24.0 + graphemer: 1.4.0 + ignore: 5.3.2 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + is-path-inside: 3.0.3 + js-yaml: 4.1.0 + json-stable-stringify-without-jsonify: 1.0.1 + levn: 0.4.1 + lodash.merge: 4.6.2 + minimatch: 3.1.2 + natural-compare: 1.4.0 + optionator: 0.9.4 + strip-ansi: 6.0.1 + text-table: 0.2.0 + transitivePeerDependencies: + - supports-color + dev: false + /eslint@9.11.0: resolution: {integrity: sha512-yVS6XODx+tMFMDFcG4+Hlh+qG7RM6cCJXtQhCKLSsr3XkLvWggHjCqjfh0XsPPnt1c56oaT6PMgW9XWQQjdHXA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -6503,6 +6618,13 @@ packages: resolution: {integrity: sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==} dev: false + /file-entry-cache@6.0.1: + resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} + engines: {node: ^10.12.0 || >=12.0.0} + dependencies: + flat-cache: 3.2.0 + dev: false + /file-entry-cache@8.0.0: resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} engines: {node: '>=16.0.0'} @@ -6583,6 +6705,15 @@ packages: path-exists: 4.0.0 dev: false + /flat-cache@3.2.0: + resolution: {integrity: sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==} + engines: {node: ^10.12.0 || >=12.0.0} + dependencies: + flatted: 3.3.1 + keyv: 4.5.4 + rimraf: 3.0.2 + dev: false + /flat-cache@4.0.1: resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} engines: {node: '>=16'} @@ -6869,6 +7000,13 @@ packages: engines: {node: '>=4'} dev: false + /globals@13.24.0: + resolution: {integrity: sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==} + engines: {node: '>=8'} + dependencies: + type-fest: 0.20.2 + dev: false + /globals@14.0.0: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} @@ -10653,6 +10791,11 @@ packages: engines: {node: '>=4'} dev: false + /type-fest@0.20.2: + resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==} + engines: {node: '>=10'} + dev: false + /type-fest@0.21.3: resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} engines: {node: '>=10'} @@ -13742,7 +13885,7 @@ packages: dev: false file:projects/arm-containerservice-1.tgz: - resolution: {integrity: sha512-Wl42MhvqkSN9qt7aI2dq9MoSjUPhKs9Vd7ph4z1NDv/4+Tr5TThGfXEcF6li2/uyM/oej6wCchIOXcN+x5t8Ug==, tarball: file:projects/arm-containerservice-1.tgz} + resolution: {integrity: sha512-giEQbgQSPKX5IztgAepOuRLfULJTB4rv9RXCMFBYOh9cAjTSCfDW5HXmQ9KyPDtFJ1XAEtWRzIcIqEb+93rJ1A==, tarball: file:projects/arm-containerservice-1.tgz} name: '@rush-temp/arm-containerservice-1' version: 0.0.0 dependencies: @@ -16533,31 +16676,30 @@ packages: dev: false file:projects/arm-mongocluster.tgz: - resolution: {integrity: sha512-EaydTWm+MEgZWL76Jqdw/pJ+TjPdLLySvQ1g4rfmxwypTxKgeTriLM5Oa8M1HoOOHBG1pj/5WV0WdFrg2cI9Jg==, tarball: file:projects/arm-mongocluster.tgz} + resolution: {integrity: sha512-gzU7hw3eeNIaEsfuzs0If0tLLativST4RuErHQQQ3iQsLBP+dsTFVdQoRRxEKta03M6tyif03E9VJg07sDWIQw==, tarball: file:projects/arm-mongocluster.tgz} name: '@rush-temp/arm-mongocluster' version: 0.0.0 dependencies: '@azure/identity': 4.4.1 '@microsoft/api-extractor': 7.47.9(@types/node@18.19.50) '@types/node': 18.19.50 - '@vitest/browser': 2.1.1(playwright@1.47.2)(typescript@5.6.2)(vitest@2.1.1) + '@vitest/browser': 2.1.1(playwright@1.47.2)(typescript@5.5.4)(vitest@2.1.1) '@vitest/coverage-istanbul': 2.1.1(vitest@2.1.1) dotenv: 16.4.5 - eslint: 9.11.0 + eslint: 8.57.1 mkdirp: 3.0.1 playwright: 1.47.2 prettier: 3.3.3 rimraf: 5.0.10 - tshy: 2.0.1 + tshy: 1.18.0 tslib: 2.7.0 - typescript: 5.6.2 + typescript: 5.5.4 vitest: 2.1.1(@types/node@18.19.50)(@vitest/browser@2.1.1) transitivePeerDependencies: - '@edge-runtime/vm' - '@vitest/ui' - bufferutil - happy-dom - - jiti - jsdom - less - lightningcss diff --git a/sdk/mongocluster/arm-mongocluster/CHANGELOG.md b/sdk/mongocluster/arm-mongocluster/CHANGELOG.md index dbc91021ffb5..673ec9aa23fd 100644 --- a/sdk/mongocluster/arm-mongocluster/CHANGELOG.md +++ b/sdk/mongocluster/arm-mongocluster/CHANGELOG.md @@ -1,13 +1,7 @@ # Release History - -## 1.0.0-beta.2 (2024-07-30) - -### Features Added - -- disable hierarchy api subpath export and issue fix. - -## 1.0.0-beta.1 (2024-07-05) + +## 1.0.0 (2024-09-24) ### Features Added -Initial release of the Azure MongoCluster package +The package of @azure/arm-mongocluster is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/js/mgmt/quickstart). diff --git a/sdk/mongocluster/arm-mongocluster/README.md b/sdk/mongocluster/arm-mongocluster/README.md index 8bbefa478cf6..122e2ee1c563 100644 --- a/sdk/mongocluster/arm-mongocluster/README.md +++ b/sdk/mongocluster/arm-mongocluster/README.md @@ -4,7 +4,6 @@ This package contains an isomorphic SDK (runs both in Node.js and in browsers) f The Microsoft Azure management API provides create, read, update, and delete functionality for Azure Cosmos DB for MongoDB vCore resources including clusters and firewall rules. -[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/mongocluster/arm-mongocluster) | [Package (NPM)](https://www.npmjs.com/package/@azure/arm-mongocluster) | [API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-mongocluster?view=azure-node-preview) | @@ -29,7 +28,7 @@ Install the Azure MongoClusterManagement client library for JavaScript with `npm npm install @azure/arm-mongocluster ``` -### Create and authenticate a `MongoClusterManagementClient` +### Create and authenticate a `DocumentDBClient` To create a client object to access the Azure MongoClusterManagement API, you will need the `endpoint` of your Azure MongoClusterManagement resource and a `credential`. The Azure MongoClusterManagement client can use Azure Active Directory credentials to authenticate. You can find the endpoint for your Azure MongoClusterManagement resource in the [Azure Portal][azure_portal]. @@ -48,19 +47,19 @@ Set the values of the client ID, tenant ID, and client secret of the AAD applica For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). ```javascript -const { MongoClusterManagementClient } = require("@azure/arm-mongocluster"); +const { DocumentDBClient } = require("@azure/arm-mongocluster"); const { DefaultAzureCredential } = require("@azure/identity"); // For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. const subscriptionId = "00000000-0000-0000-0000-000000000000"; -const client = new MongoClusterManagementClient(new DefaultAzureCredential(), subscriptionId); +const client = new DocumentDBClient(new DefaultAzureCredential(), subscriptionId); // For client-side applications running in the browser, use this code instead: // const credential = new InteractiveBrowserCredential({ // tenantId: "", // clientId: "" // }); -// const client = new MongoClusterManagementClient(credential, subscriptionId); +// const client = new DocumentDBClient(credential, subscriptionId); ``` @@ -69,9 +68,9 @@ To use this client library in the browser, first you need to use a bundler. For ## Key concepts -### MongoClusterManagementClient +### DocumentDBClient -`MongoClusterManagementClient` is the primary interface for developers using the Azure MongoClusterManagement client library. Explore the methods on this client object to understand the different features of the Azure MongoClusterManagement service that you can access. +`DocumentDBClient` is the primary interface for developers using the Azure MongoClusterManagement client library. Explore the methods on this client object to understand the different features of the Azure MongoClusterManagement service that you can access. ## Troubleshooting diff --git a/sdk/mongocluster/arm-mongocluster/assets.json b/sdk/mongocluster/arm-mongocluster/assets.json deleted file mode 100644 index dec6c8bcc0ad..000000000000 --- a/sdk/mongocluster/arm-mongocluster/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "js", - "TagPrefix": "js/mongocluster/arm-mongocluster", - "Tag": "js/mongocluster/arm-mongocluster_bd7ef48fbb" -} diff --git a/sdk/mongocluster/arm-mongocluster/eslint.config.mjs b/sdk/mongocluster/arm-mongocluster/eslint.config.mjs index 68c02604a4c1..113bdc3eaf5f 100644 --- a/sdk/mongocluster/arm-mongocluster/eslint.config.mjs +++ b/sdk/mongocluster/arm-mongocluster/eslint.config.mjs @@ -8,10 +8,10 @@ export default [ "@azure/azure-sdk/ts-apiextractor-json-types": "warn", "@azure/azure-sdk/ts-package-json-types": "warn", "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", - "tsdoc/syntax": "warn", "@azure/azure-sdk/ts-package-json-module": "off", "@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/mongocluster/arm-mongocluster/package.json b/sdk/mongocluster/arm-mongocluster/package.json index 4353cc1284da..eaf858d0c95b 100644 --- a/sdk/mongocluster/arm-mongocluster/package.json +++ b/sdk/mongocluster/arm-mongocluster/package.json @@ -1,7 +1,7 @@ { "name": "@azure/arm-mongocluster", - "version": "1.0.0-beta.2", - "description": "DocumentDB MongoCluster Service", + "version": "1.0.0", + "description": "A generated SDK for DocumentDBClient.", "engines": { "node": ">=18.0.0" }, @@ -57,26 +57,25 @@ ] }, "dependencies": { + "@azure/core-util": "^1.9.2", "@azure-rest/core-client": "^2.1.0", "@azure/core-auth": "^1.6.0", "@azure/core-rest-pipeline": "^1.5.0", "@azure/logger": "^1.0.0", "tslib": "^2.6.2", "@azure/core-lro": "^3.0.0", - "@azure/abort-controller": "^2.1.2", - "@azure/core-paging": "^1.5.0" + "@azure/abort-controller": "^2.1.2" }, "devDependencies": { "dotenv": "^16.0.0", "@microsoft/api-extractor": "^7.40.3", "@types/node": "^18.0.0", - "eslint": "^9.9.0", + "eslint": "^8.55.0", "prettier": "^3.2.5", "rimraf": "^5.0.5", "mkdirp": "^3.0.1", - "typescript": "~5.6.2", - "tshy": "^2.0.0", - "@azure/core-util": "^1.0.0", + "typescript": "~5.5.3", + "tshy": "^1.11.1", "@azure/identity": "^4.2.1", "@vitest/browser": "^2.0.5", "@vitest/coverage-istanbul": "^2.0.5", @@ -85,15 +84,14 @@ "@azure-tools/test-credential": "^2.0.0", "@azure-tools/test-recorder": "^4.0.0", "@azure/dev-tool": "^1.0.0", - "@azure/eslint-plugin-azure-sdk": "^3.0.0", - "@azure/arm-network": "^33.2.0" + "@azure/eslint-plugin-azure-sdk": "^3.0.0" }, "scripts": { "clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", "extract-api": "rimraf review && mkdirp ./review && dev-tool run extract-api", "pack": "npm pack 2>&1", - "lint": "echo skipped", - "lint:fix": "echo skipped", + "lint": "eslint package.json api-extractor.json src test", + "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", "unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test:browser": "npm run build:test && dev-tool run test:vitest --browser", "unit-test:node": "dev-tool run test:vitest", @@ -102,9 +100,9 @@ "integration-test:node": "echo skipped", "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", "build:samples": "echo skipped", - "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\"", + "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", "execute:samples": "echo skipped", - "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\"", + "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", "generate:client": "echo skipped", "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", @@ -117,54 +115,66 @@ "./package.json": "./package.json", ".": { "browser": { + "source": "./src/index.ts", "types": "./dist/browser/index.d.ts", "default": "./dist/browser/index.js" }, "react-native": { + "source": "./src/index.ts", "types": "./dist/react-native/index.d.ts", "default": "./dist/react-native/index.js" }, "import": { + "source": "./src/index.ts", "types": "./dist/esm/index.d.ts", "default": "./dist/esm/index.js" }, "require": { + "source": "./src/index.ts", "types": "./dist/commonjs/index.d.ts", "default": "./dist/commonjs/index.js" } }, "./api": { "browser": { + "source": "./src/api/index.ts", "types": "./dist/browser/api/index.d.ts", "default": "./dist/browser/api/index.js" }, "react-native": { + "source": "./src/api/index.ts", "types": "./dist/react-native/api/index.d.ts", "default": "./dist/react-native/api/index.js" }, "import": { + "source": "./src/api/index.ts", "types": "./dist/esm/api/index.d.ts", "default": "./dist/esm/api/index.js" }, "require": { + "source": "./src/api/index.ts", "types": "./dist/commonjs/api/index.d.ts", "default": "./dist/commonjs/api/index.js" } }, "./models": { "browser": { + "source": "./src/models/index.ts", "types": "./dist/browser/models/index.d.ts", "default": "./dist/browser/models/index.js" }, "react-native": { + "source": "./src/models/index.ts", "types": "./dist/react-native/models/index.d.ts", "default": "./dist/react-native/models/index.js" }, "import": { + "source": "./src/models/index.ts", "types": "./dist/esm/models/index.d.ts", "default": "./dist/esm/models/index.js" }, "require": { + "source": "./src/models/index.ts", "types": "./dist/commonjs/models/index.d.ts", "default": "./dist/commonjs/models/index.js" } diff --git a/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster-api.api.md b/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster-api.api.md index 4383840fa91e..00d3bab3fe22 100644 --- a/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster-api.api.md +++ b/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster-api.api.md @@ -6,35 +6,29 @@ import { Client } from '@azure-rest/core-client'; import { ClientOptions } from '@azure-rest/core-client'; -import { HttpResponse } from '@azure-rest/core-client'; import { OperationOptions } from '@azure-rest/core-client'; import { OperationState } from '@azure/core-lro'; -import { Paged } from '@azure/core-paging'; import { PollerLike } from '@azure/core-lro'; -import { RawHttpHeaders } from '@azure/core-rest-pipeline'; -import { RequestParameters } from '@azure-rest/core-client'; -import { StreamableMethod } from '@azure-rest/core-client'; import { TokenCredential } from '@azure/core-auth'; // @public export function createMongoClusterManagement(credential: TokenCredential, options?: MongoClusterManagementClientOptionalParams): DocumentDBContext; // @public (undocumented) -export type DocumentDBContext = Client & { - path: Routes; -}; +export interface DocumentDBContext extends Client { +} // @public -export function firewallRulesCreateOrUpdate(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, firewallRuleName: string, resource: FirewallRule_2, options?: FirewallRulesCreateOrUpdateOptionalParams): PollerLike, FirewallRule_2>; +export function firewallRulesCreateOrUpdate(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, firewallRuleName: string, resource: FirewallRule, options?: FirewallRulesCreateOrUpdateOptionalParams): PollerLike, FirewallRule>; // @public export function firewallRulesDelete(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, firewallRuleName: string, options?: FirewallRulesDeleteOptionalParams): PollerLike, void>; // @public -export function firewallRulesGet(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, firewallRuleName: string, options?: FirewallRulesGetOptionalParams): Promise; +export function firewallRulesGet(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, firewallRuleName: string, options?: FirewallRulesGetOptionalParams): Promise; // @public -export function firewallRulesListByMongoCluster(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, options?: FirewallRulesListByMongoClusterOptionalParams): PagedAsyncIterableIterator; +export function firewallRulesListByMongoCluster(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, options?: FirewallRulesListByMongoClusterOptionalParams): PagedAsyncIterableIterator; // @public export interface MongoClusterManagementClientOptionalParams extends ClientOptions { @@ -42,47 +36,53 @@ export interface MongoClusterManagementClientOptionalParams extends ClientOption } // @public -export function mongoClustersCheckNameAvailability(context: DocumentDBContext, subscriptionId: string, location: string, body: CheckNameAvailabilityRequest_2, options?: MongoClustersCheckNameAvailabilityOptionalParams): Promise; +export function mongoClustersCheckNameAvailability(context: DocumentDBContext, subscriptionId: string, location: string, body: CheckNameAvailabilityRequest, options?: MongoClustersCheckNameAvailabilityOptionalParams): Promise; // @public -export function mongoClustersCreateOrUpdate(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, resource: MongoCluster_2, options?: MongoClustersCreateOrUpdateOptionalParams): PollerLike, MongoCluster_2>; +export function mongoClustersCreateOrUpdate(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, resource: MongoCluster, options?: MongoClustersCreateOrUpdateOptionalParams): PollerLike, MongoCluster>; // @public export function mongoClustersDelete(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, options?: MongoClustersDeleteOptionalParams): PollerLike, void>; // @public -export function mongoClustersGet(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, options?: MongoClustersGetOptionalParams): Promise; +export function mongoClustersGet(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, options?: MongoClustersGetOptionalParams): Promise; // @public -export function mongoClustersList(context: DocumentDBContext, subscriptionId: string, options?: MongoClustersListOptionalParams): PagedAsyncIterableIterator; +export function mongoClustersList(context: DocumentDBContext, subscriptionId: string, options?: MongoClustersListOptionalParams): PagedAsyncIterableIterator; // @public -export function mongoClustersListByResourceGroup(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, options?: MongoClustersListByResourceGroupOptionalParams): PagedAsyncIterableIterator; +export function mongoClustersListByResourceGroup(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, options?: MongoClustersListByResourceGroupOptionalParams): PagedAsyncIterableIterator; // @public export function mongoClustersListConnectionStrings(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, options?: MongoClustersListConnectionStringsOptionalParams): Promise; // @public -export function mongoClustersUpdate(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, properties: MongoClusterUpdate_2, options?: MongoClustersUpdateOptionalParams): PollerLike, MongoCluster_2>; +export function mongoClustersPromote(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, body: PromoteReplicaRequest, options?: MongoClustersPromoteOptionalParams): PollerLike, void>; + +// @public +export function mongoClustersUpdate(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, properties: MongoClusterUpdate, options?: MongoClustersUpdateOptionalParams): PollerLike, MongoCluster>; // @public export function operationsList(context: DocumentDBContext, options?: OperationsListOptionalParams): PagedAsyncIterableIterator; // @public -export function privateEndpointConnectionsCreate(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, privateEndpointConnectionName: string, resource: PrivateEndpointConnectionResource_2, options?: PrivateEndpointConnectionsCreateOptionalParams): PollerLike, PrivateEndpointConnectionResource_2>; +export function privateEndpointConnectionsCreate(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, privateEndpointConnectionName: string, resource: PrivateEndpointConnectionResource, options?: PrivateEndpointConnectionsCreateOptionalParams): PollerLike, PrivateEndpointConnectionResource>; // @public export function privateEndpointConnectionsDelete(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, privateEndpointConnectionName: string, options?: PrivateEndpointConnectionsDeleteOptionalParams): PollerLike, void>; // @public -export function privateEndpointConnectionsGet(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, privateEndpointConnectionName: string, options?: PrivateEndpointConnectionsGetOptionalParams): Promise; +export function privateEndpointConnectionsGet(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, privateEndpointConnectionName: string, options?: PrivateEndpointConnectionsGetOptionalParams): Promise; // @public -export function privateEndpointConnectionsListByMongoCluster(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, options?: PrivateEndpointConnectionsListByMongoClusterOptionalParams): PagedAsyncIterableIterator; +export function privateEndpointConnectionsListByMongoCluster(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, options?: PrivateEndpointConnectionsListByMongoClusterOptionalParams): PagedAsyncIterableIterator; // @public export function privateLinksListByMongoCluster(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, options?: PrivateLinksListByMongoClusterOptionalParams): PagedAsyncIterableIterator; +// @public +export function replicasListByParent(context: DocumentDBContext, subscriptionId: string, resourceGroupName: string, mongoClusterName: string, options?: ReplicasListByParentOptionalParams): PagedAsyncIterableIterator; + // (No @packageDocumentation comment for this package) ``` diff --git a/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster-models.api.md b/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster-models.api.md index a8ed8c2bf689..c283bece3c67 100644 --- a/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster-models.api.md +++ b/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster-models.api.md @@ -9,6 +9,17 @@ import { OperationOptions } from '@azure-rest/core-client'; // @public export type ActionType = string; +// @public +export interface AdministratorProperties { + password?: string; + userName?: string; +} + +// @public +export interface BackupProperties { + readonly earliestRestoreTime?: string; +} + // @public export type CheckNameAvailabilityReason = string; @@ -25,17 +36,18 @@ export interface CheckNameAvailabilityResponse { reason?: CheckNameAvailabilityReason; } +// @public +export interface ComputeProperties { + tier?: string; +} + // @public export interface ConnectionString { readonly connectionString?: string; readonly description?: string; + readonly name?: string; } -// @public -export type ContinuablePage = TPage & { - continuationToken?: string; -}; - // @public export type CreatedByType = string; @@ -92,6 +104,14 @@ export interface FirewallRulesGetOptionalParams extends OperationOptions { export interface FirewallRulesListByMongoClusterOptionalParams extends OperationOptions { } +// @public +export type HighAvailabilityMode = string; + +// @public +export interface HighAvailabilityProperties { + targetMode?: HighAvailabilityMode; +} + // @public export enum KnownActionType { Internal = "Internal" @@ -114,7 +134,16 @@ export enum KnownCreatedByType { // @public export enum KnownCreateMode { Default = "Default", - PointInTimeRestore = "PointInTimeRestore" + GeoReplica = "GeoReplica", + PointInTimeRestore = "PointInTimeRestore", + Replica = "Replica" +} + +// @public +export enum KnownHighAvailabilityMode { + Disabled = "Disabled", + SameZone = "SameZone", + ZoneRedundantPreferred = "ZoneRedundantPreferred" } // @public @@ -128,11 +157,6 @@ export enum KnownMongoClusterStatus { Updating = "Updating" } -// @public -export enum KnownNodeKind { - Shard = "Shard" -} - // @public export enum KnownOrigin { "user,system" = "user,system", @@ -140,6 +164,11 @@ export enum KnownOrigin { user = "user" } +// @public +export enum KnownPreviewFeature { + GeoReplicas = "GeoReplicas" +} + // @public export enum KnownPrivateEndpointConnectionProvisioningState { Creating = "Creating", @@ -155,12 +184,39 @@ export enum KnownPrivateEndpointServiceConnectionStatus { Rejected = "Rejected" } +// @public +export enum KnownPromoteMode { + Switchover = "Switchover" +} + +// @public +export enum KnownPromoteOption { + Forced = "Forced" +} + // @public export enum KnownPublicNetworkAccess { Disabled = "Disabled", Enabled = "Enabled" } +// @public +export enum KnownReplicationRole { + AsyncReplica = "AsyncReplica", + GeoAsyncReplica = "GeoAsyncReplica", + Primary = "Primary" +} + +// @public +export enum KnownReplicationState { + Active = "Active", + Broken = "Broken", + Catchup = "Catchup", + Provisioning = "Provisioning", + Reconfiguring = "Reconfiguring", + Updating = "Updating" +} + // @public export enum KnownResourceProvisioningState { Canceled = "Canceled", @@ -180,18 +236,30 @@ export interface MongoCluster extends TrackedResource { // @public export interface MongoClusterProperties { - administratorLogin?: string; - administratorLoginPassword?: string; + administrator?: AdministratorProperties; + backup?: BackupProperties; readonly clusterStatus?: MongoClusterStatus; + compute?: ComputeProperties; readonly connectionString?: string; createMode?: CreateMode; - readonly earliestRestoreTime?: string; - nodeGroupSpecs?: NodeGroupSpec[]; + highAvailability?: HighAvailabilityProperties; + readonly infrastructureVersion?: string; + previewFeatures?: PreviewFeature[]; readonly privateEndpointConnections?: PrivateEndpointConnection[]; readonly provisioningState?: ProvisioningState; publicNetworkAccess?: PublicNetworkAccess; + readonly replica?: ReplicationProperties; + replicaParameters?: MongoClusterReplicaParameters; restoreParameters?: MongoClusterRestoreParameters; serverVersion?: string; + sharding?: ShardingProperties; + storage?: StorageProperties; +} + +// @public +export interface MongoClusterReplicaParameters { + sourceLocation: string; + sourceResourceId: string; } // @public @@ -230,6 +298,11 @@ export interface MongoClustersListConnectionStringsOptionalParams extends Operat export interface MongoClustersListOptionalParams extends OperationOptions { } +// @public +export interface MongoClustersPromoteOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + // @public export type MongoClusterStatus = string; @@ -246,25 +319,17 @@ export interface MongoClusterUpdate { // @public export interface MongoClusterUpdateProperties { - administratorLogin?: string; - administratorLoginPassword?: string; - nodeGroupSpecs?: NodeGroupSpec[]; + administrator?: AdministratorProperties; + backup?: BackupProperties; + compute?: ComputeProperties; + highAvailability?: HighAvailabilityProperties; + previewFeatures?: PreviewFeature[]; publicNetworkAccess?: PublicNetworkAccess; serverVersion?: string; + sharding?: ShardingProperties; + storage?: StorageProperties; } -// @public -export interface NodeGroupSpec { - diskSizeGB?: number; - enableHa?: boolean; - kind?: NodeKind; - nodeCount?: number; - sku?: string; -} - -// @public -export type NodeKind = string; - // @public export interface Operation { actionType?: ActionType; @@ -290,16 +355,7 @@ export interface OperationsListOptionalParams extends OperationOptions { export type Origin = string; // @public -export interface PagedAsyncIterableIterator { - [Symbol.asyncIterator](): PagedAsyncIterableIterator; - byPage: (settings?: TPageSettings) => AsyncIterableIterator>; - next(): Promise>; -} - -// @public -export interface PageSettings { - continuationToken?: string; -} +export type PreviewFeature = string; // @public export interface PrivateEndpoint { @@ -371,6 +427,18 @@ export interface PrivateLinkServiceConnectionState { export interface PrivateLinksListByMongoClusterOptionalParams extends OperationOptions { } +// @public +export type PromoteMode = string; + +// @public +export type PromoteOption = string; + +// @public +export interface PromoteReplicaRequest { + mode?: PromoteMode; + promoteOption: PromoteOption; +} + // @public export type ProvisioningState = string | ResourceProvisioningState | "InProgress" | "Updating" | "Dropping"; @@ -381,6 +449,28 @@ export interface ProxyResource extends Resource { // @public export type PublicNetworkAccess = string; +// @public +export interface Replica extends ProxyResource { + properties?: MongoClusterProperties; +} + +// @public +export interface ReplicasListByParentOptionalParams extends OperationOptions { +} + +// @public +export interface ReplicationProperties { + readonly replicationState?: ReplicationState; + readonly role?: ReplicationRole; + readonly sourceResourceId?: string; +} + +// @public +export type ReplicationRole = string; + +// @public +export type ReplicationState = string; + // @public export interface Resource { readonly id?: string; @@ -392,6 +482,16 @@ export interface Resource { // @public export type ResourceProvisioningState = string; +// @public +export interface ShardingProperties { + shardCount?: number; +} + +// @public +export interface StorageProperties { + sizeGb?: number; +} + // @public export interface SystemData { createdAt?: Date; @@ -409,7 +509,7 @@ export interface TrackedResource extends Resource { } // @public -export type Versions = "2024-03-01-preview"; +export type Versions = "2024-03-01-preview" | "2024-06-01-preview" | "2024-07-01"; // (No @packageDocumentation comment for this package) diff --git a/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster.api.md b/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster.api.md index 5cf5c2decdde..42faa44fbf3e 100644 --- a/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster.api.md +++ b/sdk/mongocluster/arm-mongocluster/review/arm-mongocluster.api.md @@ -16,6 +16,17 @@ import { TokenCredential } from '@azure/core-auth'; // @public export type ActionType = string; +// @public +export interface AdministratorProperties { + password?: string; + userName?: string; +} + +// @public +export interface BackupProperties { + readonly earliestRestoreTime?: string; +} + // @public export type CheckNameAvailabilityReason = string; @@ -32,10 +43,16 @@ export interface CheckNameAvailabilityResponse { reason?: CheckNameAvailabilityReason; } +// @public +export interface ComputeProperties { + tier?: string; +} + // @public export interface ConnectionString { readonly connectionString?: string; readonly description?: string; + readonly name?: string; } // @public @@ -107,6 +124,14 @@ export interface FirewallRulesOperations { listByMongoCluster: (resourceGroupName: string, mongoClusterName: string, options?: FirewallRulesListByMongoClusterOptionalParams) => PagedAsyncIterableIterator; } +// @public +export type HighAvailabilityMode = string; + +// @public +export interface HighAvailabilityProperties { + targetMode?: HighAvailabilityMode; +} + // @public export enum KnownActionType { Internal = "Internal" @@ -129,7 +154,16 @@ export enum KnownCreatedByType { // @public export enum KnownCreateMode { Default = "Default", - PointInTimeRestore = "PointInTimeRestore" + GeoReplica = "GeoReplica", + PointInTimeRestore = "PointInTimeRestore", + Replica = "Replica" +} + +// @public +export enum KnownHighAvailabilityMode { + Disabled = "Disabled", + SameZone = "SameZone", + ZoneRedundantPreferred = "ZoneRedundantPreferred" } // @public @@ -143,11 +177,6 @@ export enum KnownMongoClusterStatus { Updating = "Updating" } -// @public -export enum KnownNodeKind { - Shard = "Shard" -} - // @public export enum KnownOrigin { "user,system" = "user,system", @@ -155,6 +184,11 @@ export enum KnownOrigin { user = "user" } +// @public +export enum KnownPreviewFeature { + GeoReplicas = "GeoReplicas" +} + // @public export enum KnownPrivateEndpointConnectionProvisioningState { Creating = "Creating", @@ -170,12 +204,39 @@ export enum KnownPrivateEndpointServiceConnectionStatus { Rejected = "Rejected" } +// @public +export enum KnownPromoteMode { + Switchover = "Switchover" +} + +// @public +export enum KnownPromoteOption { + Forced = "Forced" +} + // @public export enum KnownPublicNetworkAccess { Disabled = "Disabled", Enabled = "Enabled" } +// @public +export enum KnownReplicationRole { + AsyncReplica = "AsyncReplica", + GeoAsyncReplica = "GeoAsyncReplica", + Primary = "Primary" +} + +// @public +export enum KnownReplicationState { + Active = "Active", + Broken = "Broken", + Catchup = "Catchup", + Provisioning = "Provisioning", + Reconfiguring = "Reconfiguring", + Updating = "Updating" +} + // @public export enum KnownResourceProvisioningState { Canceled = "Canceled", @@ -202,6 +263,7 @@ export class MongoClusterManagementClient { readonly pipeline: Pipeline; readonly privateEndpointConnections: PrivateEndpointConnectionsOperations; readonly privateLinks: PrivateLinksOperations; + readonly replicas: ReplicasOperations; } // @public @@ -211,18 +273,30 @@ export interface MongoClusterManagementClientOptionalParams extends ClientOption // @public export interface MongoClusterProperties { - administratorLogin?: string; - administratorLoginPassword?: string; + administrator?: AdministratorProperties; + backup?: BackupProperties; readonly clusterStatus?: MongoClusterStatus; + compute?: ComputeProperties; readonly connectionString?: string; createMode?: CreateMode; - readonly earliestRestoreTime?: string; - nodeGroupSpecs?: NodeGroupSpec[]; + highAvailability?: HighAvailabilityProperties; + readonly infrastructureVersion?: string; + previewFeatures?: PreviewFeature[]; readonly privateEndpointConnections?: PrivateEndpointConnection[]; readonly provisioningState?: ProvisioningState; publicNetworkAccess?: PublicNetworkAccess; + readonly replica?: ReplicationProperties; + replicaParameters?: MongoClusterReplicaParameters; restoreParameters?: MongoClusterRestoreParameters; serverVersion?: string; + sharding?: ShardingProperties; + storage?: StorageProperties; +} + +// @public +export interface MongoClusterReplicaParameters { + sourceLocation: string; + sourceResourceId: string; } // @public @@ -270,9 +344,15 @@ export interface MongoClustersOperations { list: (options?: MongoClustersListOptionalParams) => PagedAsyncIterableIterator; listByResourceGroup: (resourceGroupName: string, options?: MongoClustersListByResourceGroupOptionalParams) => PagedAsyncIterableIterator; listConnectionStrings: (resourceGroupName: string, mongoClusterName: string, options?: MongoClustersListConnectionStringsOptionalParams) => Promise; + promote: (resourceGroupName: string, mongoClusterName: string, body: PromoteReplicaRequest, options?: MongoClustersPromoteOptionalParams) => PollerLike, void>; update: (resourceGroupName: string, mongoClusterName: string, properties: MongoClusterUpdate, options?: MongoClustersUpdateOptionalParams) => PollerLike, MongoCluster>; } +// @public +export interface MongoClustersPromoteOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + // @public export type MongoClusterStatus = string; @@ -289,25 +369,17 @@ export interface MongoClusterUpdate { // @public export interface MongoClusterUpdateProperties { - administratorLogin?: string; - administratorLoginPassword?: string; - nodeGroupSpecs?: NodeGroupSpec[]; + administrator?: AdministratorProperties; + backup?: BackupProperties; + compute?: ComputeProperties; + highAvailability?: HighAvailabilityProperties; + previewFeatures?: PreviewFeature[]; publicNetworkAccess?: PublicNetworkAccess; serverVersion?: string; + sharding?: ShardingProperties; + storage?: StorageProperties; } -// @public -export interface NodeGroupSpec { - diskSizeGB?: number; - enableHa?: boolean; - kind?: NodeKind; - nodeCount?: number; - sku?: string; -} - -// @public -export type NodeKind = string; - // @public export interface Operation { actionType?: ActionType; @@ -349,6 +421,9 @@ export interface PageSettings { continuationToken?: string; } +// @public +export type PreviewFeature = string; + // @public export interface PrivateEndpoint { readonly id?: string; @@ -432,6 +507,18 @@ export interface PrivateLinksOperations { listByMongoCluster: (resourceGroupName: string, mongoClusterName: string, options?: PrivateLinksListByMongoClusterOptionalParams) => PagedAsyncIterableIterator; } +// @public +export type PromoteMode = string; + +// @public +export type PromoteOption = string; + +// @public +export interface PromoteReplicaRequest { + mode?: PromoteMode; + promoteOption: PromoteOption; +} + // @public export type ProvisioningState = string | ResourceProvisioningState | "InProgress" | "Updating" | "Dropping"; @@ -442,6 +529,33 @@ export interface ProxyResource extends Resource { // @public export type PublicNetworkAccess = string; +// @public +export interface Replica extends ProxyResource { + properties?: MongoClusterProperties; +} + +// @public +export interface ReplicasListByParentOptionalParams extends OperationOptions { +} + +// @public +export interface ReplicasOperations { + listByParent: (resourceGroupName: string, mongoClusterName: string, options?: ReplicasListByParentOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export interface ReplicationProperties { + readonly replicationState?: ReplicationState; + readonly role?: ReplicationRole; + readonly sourceResourceId?: string; +} + +// @public +export type ReplicationRole = string; + +// @public +export type ReplicationState = string; + // @public export interface Resource { readonly id?: string; @@ -463,6 +577,16 @@ export interface RestorePollerOptions { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}", @@ -59,9 +46,10 @@ export function _firewallRulesGetSend( } export async function _firewallRulesGetDeserialize( - result: FirewallRulesGet200Response | FirewallRulesGetDefaultResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } @@ -123,13 +111,7 @@ export function _firewallRulesCreateOrUpdateSend( firewallRuleName: string, resource: FirewallRule, options: FirewallRulesCreateOrUpdateOptionalParams = { requestOptions: {} }, -): StreamableMethod< - | FirewallRulesCreateOrUpdate200Response - | FirewallRulesCreateOrUpdate201Response - | FirewallRulesCreateOrUpdate202Response - | FirewallRulesCreateOrUpdateDefaultResponse - | FirewallRulesCreateOrUpdateLogicalResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}", @@ -149,44 +131,39 @@ export function _firewallRulesCreateOrUpdateSend( } export async function _firewallRulesCreateOrUpdateDeserialize( - result: - | FirewallRulesCreateOrUpdate200Response - | FirewallRulesCreateOrUpdate201Response - | FirewallRulesCreateOrUpdate202Response - | FirewallRulesCreateOrUpdateDefaultResponse - | FirewallRulesCreateOrUpdateLogicalResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["200", "201", "202"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - const res = result as unknown as FirewallRulesCreateOrUpdateLogicalResponse; return { - id: res.body["id"], - name: res.body["name"], - type: res.body["type"], - systemData: !res.body.systemData + id: result.body["id"], + name: result.body["name"], + type: result.body["type"], + systemData: !result.body.systemData ? undefined : { - createdBy: res.body.systemData?.["createdBy"], - createdByType: res.body.systemData?.["createdByType"], + createdBy: result.body.systemData?.["createdBy"], + createdByType: result.body.systemData?.["createdByType"], createdAt: - res.body.systemData?.["createdAt"] !== undefined - ? new Date(res.body.systemData?.["createdAt"]) + result.body.systemData?.["createdAt"] !== undefined + ? new Date(result.body.systemData?.["createdAt"]) : undefined, - lastModifiedBy: res.body.systemData?.["lastModifiedBy"], - lastModifiedByType: res.body.systemData?.["lastModifiedByType"], + lastModifiedBy: result.body.systemData?.["lastModifiedBy"], + lastModifiedByType: result.body.systemData?.["lastModifiedByType"], lastModifiedAt: - res.body.systemData?.["lastModifiedAt"] !== undefined - ? new Date(res.body.systemData?.["lastModifiedAt"]) + result.body.systemData?.["lastModifiedAt"] !== undefined + ? new Date(result.body.systemData?.["lastModifiedAt"]) : undefined, }, - properties: !res.body.properties + properties: !result.body.properties ? undefined : { - provisioningState: res.body.properties?.["provisioningState"], - startIpAddress: res.body.properties?.["startIpAddress"], - endIpAddress: res.body.properties?.["endIpAddress"], + provisioningState: result.body.properties?.["provisioningState"], + startIpAddress: result.body.properties?.["startIpAddress"], + endIpAddress: result.body.properties?.["endIpAddress"], }, }; } @@ -201,20 +178,25 @@ export function firewallRulesCreateOrUpdate( resource: FirewallRule, options: FirewallRulesCreateOrUpdateOptionalParams = { requestOptions: {} }, ): PollerLike, FirewallRule> { - return getLongRunningPoller(context, _firewallRulesCreateOrUpdateDeserialize, { - updateIntervalInMs: options?.updateIntervalInMs, - abortSignal: options?.abortSignal, - getInitialResponse: () => - _firewallRulesCreateOrUpdateSend( - context, - subscriptionId, - resourceGroupName, - mongoClusterName, - firewallRuleName, - resource, - options, - ), - }) as PollerLike, FirewallRule>; + return getLongRunningPoller( + context, + _firewallRulesCreateOrUpdateDeserialize, + ["200", "201", "202"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _firewallRulesCreateOrUpdateSend( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + firewallRuleName, + resource, + options, + ), + }, + ) as PollerLike, FirewallRule>; } export function _firewallRulesDeleteSend( @@ -224,12 +206,7 @@ export function _firewallRulesDeleteSend( mongoClusterName: string, firewallRuleName: string, options: FirewallRulesDeleteOptionalParams = { requestOptions: {} }, -): StreamableMethod< - | FirewallRulesDelete202Response - | FirewallRulesDelete204Response - | FirewallRulesDeleteDefaultResponse - | FirewallRulesDeleteLogicalResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}", @@ -242,13 +219,10 @@ export function _firewallRulesDeleteSend( } export async function _firewallRulesDeleteDeserialize( - result: - | FirewallRulesDelete202Response - | FirewallRulesDelete204Response - | FirewallRulesDeleteDefaultResponse - | FirewallRulesDeleteLogicalResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["202", "204", "200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } @@ -264,19 +238,24 @@ export function firewallRulesDelete( firewallRuleName: string, options: FirewallRulesDeleteOptionalParams = { requestOptions: {} }, ): PollerLike, void> { - return getLongRunningPoller(context, _firewallRulesDeleteDeserialize, { - updateIntervalInMs: options?.updateIntervalInMs, - abortSignal: options?.abortSignal, - getInitialResponse: () => - _firewallRulesDeleteSend( - context, - subscriptionId, - resourceGroupName, - mongoClusterName, - firewallRuleName, - options, - ), - }) as PollerLike, void>; + return getLongRunningPoller( + context, + _firewallRulesDeleteDeserialize, + ["202", "204", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _firewallRulesDeleteSend( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + firewallRuleName, + options, + ), + }, + ) as PollerLike, void>; } export function _firewallRulesListByMongoClusterSend( @@ -287,9 +266,7 @@ export function _firewallRulesListByMongoClusterSend( options: FirewallRulesListByMongoClusterOptionalParams = { requestOptions: {}, }, -): StreamableMethod< - FirewallRulesListByMongoCluster200Response | FirewallRulesListByMongoClusterDefaultResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules", @@ -301,16 +278,15 @@ export function _firewallRulesListByMongoClusterSend( } export async function _firewallRulesListByMongoClusterDeserialize( - result: - | FirewallRulesListByMongoCluster200Response - | FirewallRulesListByMongoClusterDefaultResponse, + result: PathUncheckedResponse, ): Promise<_FirewallRuleListResult> { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } return { - value: result.body["value"].map((p) => { + value: result.body["value"].map((p: any) => { return { id: p["id"], name: p["name"], @@ -365,6 +341,7 @@ export function firewallRulesListByMongoCluster( options, ), _firewallRulesListByMongoClusterDeserialize, + ["200"], { itemName: "value", nextLinkName: "nextLink" }, ); } diff --git a/sdk/mongocluster/arm-mongocluster/src/api/index.ts b/sdk/mongocluster/arm-mongocluster/src/api/index.ts index b1746ac639db..f7dce8bfa6ad 100644 --- a/sdk/mongocluster/arm-mongocluster/src/api/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/api/index.ts @@ -3,8 +3,8 @@ export { createMongoClusterManagement, - MongoClusterManagementClientOptionalParams, DocumentDBContext, + MongoClusterManagementClientOptionalParams, } from "./mongoClusterManagementContext.js"; export { firewallRulesGet, @@ -21,6 +21,7 @@ export { mongoClustersList, mongoClustersListConnectionStrings, mongoClustersCheckNameAvailability, + mongoClustersPromote, } from "./mongoClusters/index.js"; export { operationsList } from "./operations/index.js"; export { @@ -30,3 +31,4 @@ export { privateEndpointConnectionsDelete, } from "./privateEndpointConnections/index.js"; export { privateLinksListByMongoCluster } from "./privateLinks/index.js"; +export { replicasListByParent } from "./replicas/index.js"; diff --git a/sdk/mongocluster/arm-mongocluster/src/api/mongoClusterManagementContext.ts b/sdk/mongocluster/arm-mongocluster/src/api/mongoClusterManagementContext.ts index e27668476243..9c5f871fd3af 100644 --- a/sdk/mongocluster/arm-mongocluster/src/api/mongoClusterManagementContext.ts +++ b/sdk/mongocluster/arm-mongocluster/src/api/mongoClusterManagementContext.ts @@ -2,29 +2,55 @@ // Licensed under the MIT License. import { TokenCredential } from "@azure/core-auth"; -import { ClientOptions } from "@azure-rest/core-client"; -import { DocumentDBContext } from "../rest/index.js"; -import getClient from "../rest/index.js"; +import { ClientOptions, Client, getClient } from "@azure-rest/core-client"; +import { logger } from "../logger.js"; + +export interface DocumentDBContext extends Client {} /** Optional parameters for the client. */ -export interface MongoClusterManagementClientOptionalParams extends ClientOptions { +export interface MongoClusterManagementClientOptionalParams + extends ClientOptions { /** The API version to use for this operation. */ apiVersion?: string; } -export { DocumentDBContext } from "../rest/index.js"; - /** The Microsoft Azure management API provides create, read, update, and delete functionality for Azure Cosmos DB for MongoDB vCore resources including clusters and firewall rules. */ export function createMongoClusterManagement( credential: TokenCredential, options: MongoClusterManagementClientOptionalParams = {}, ): DocumentDBContext { - const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; - const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api` : "azsdk-js-api"; + const endpointUrl = + options.endpoint ?? options.baseUrl ?? `https://management.azure.com`; - const clientContext = getClient(credential, { + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api` + : "azsdk-js-api"; + 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 ?? "2024-07-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; } diff --git a/sdk/mongocluster/arm-mongocluster/src/api/mongoClusters/index.ts b/sdk/mongocluster/arm-mongocluster/src/api/mongoClusters/index.ts index b24ba04bf02d..a9ce48baccfd 100644 --- a/sdk/mongocluster/arm-mongocluster/src/api/mongoClusters/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/api/mongoClusters/index.ts @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { getLongRunningPoller } from "../pollingHelpers.js"; -import { PollerLike, OperationState } from "@azure/core-lro"; import { mongoClusterPropertiesSerializer, mongoClusterUpdatePropertiesSerializer, @@ -11,42 +9,23 @@ import { ListConnectionStringsResult, CheckNameAvailabilityRequest, CheckNameAvailabilityResponse, + PromoteReplicaRequest, _MongoClusterListResult, } from "../../models/models.js"; -import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js"; -import { buildPagedAsyncIterator } from "../pagingHelpers.js"; -import { - isUnexpected, - DocumentDBContext as Client, - MongoClustersCheckNameAvailability200Response, - MongoClustersCheckNameAvailabilityDefaultResponse, - MongoClustersCreateOrUpdate200Response, - MongoClustersCreateOrUpdate201Response, - MongoClustersCreateOrUpdateDefaultResponse, - MongoClustersCreateOrUpdateLogicalResponse, - MongoClustersDelete202Response, - MongoClustersDelete204Response, - MongoClustersDeleteDefaultResponse, - MongoClustersDeleteLogicalResponse, - MongoClustersGet200Response, - MongoClustersGetDefaultResponse, - MongoClustersList200Response, - MongoClustersListByResourceGroup200Response, - MongoClustersListByResourceGroupDefaultResponse, - MongoClustersListConnectionStrings200Response, - MongoClustersListConnectionStringsDefaultResponse, - MongoClustersListDefaultResponse, - MongoClustersUpdate200Response, - MongoClustersUpdate202Response, - MongoClustersUpdateDefaultResponse, - MongoClustersUpdateLogicalResponse, -} from "../../rest/index.js"; +import { DocumentDBContext as Client } from "../index.js"; import { StreamableMethod, operationOptionsToRequestParameters, + PathUncheckedResponse, createRestError, } from "@azure-rest/core-client"; import { serializeRecord } from "../../helpers/serializerHelpers.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { PollerLike, OperationState } from "@azure/core-lro"; import { MongoClustersGetOptionalParams, MongoClustersCreateOrUpdateOptionalParams, @@ -56,6 +35,7 @@ import { MongoClustersListOptionalParams, MongoClustersListConnectionStringsOptionalParams, MongoClustersCheckNameAvailabilityOptionalParams, + MongoClustersPromoteOptionalParams, } from "../../models/options.js"; export function _mongoClustersGetSend( @@ -64,7 +44,7 @@ export function _mongoClustersGetSend( resourceGroupName: string, mongoClusterName: string, options: MongoClustersGetOptionalParams = { requestOptions: {} }, -): StreamableMethod { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}", @@ -76,9 +56,10 @@ export function _mongoClustersGetSend( } export async function _mongoClustersGetDeserialize( - result: MongoClustersGet200Response | MongoClustersGetDefaultResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } @@ -112,73 +93,127 @@ export async function _mongoClustersGetDeserialize( ? undefined : { pointInTimeUTC: - result.body.properties?.restoreParameters?.["pointInTimeUTC"] !== undefined - ? new Date(result.body.properties?.restoreParameters?.["pointInTimeUTC"]) + result.body.properties?.restoreParameters?.[ + "pointInTimeUTC" + ] !== undefined + ? new Date( + result.body.properties?.restoreParameters?.[ + "pointInTimeUTC" + ], + ) : undefined, - sourceResourceId: result.body.properties?.restoreParameters?.["sourceResourceId"], + sourceResourceId: + result.body.properties?.restoreParameters?.[ + "sourceResourceId" + ], + }, + replicaParameters: !result.body.properties?.replicaParameters + ? undefined + : { + sourceResourceId: + result.body.properties?.replicaParameters?.[ + "sourceResourceId" + ], + sourceLocation: + result.body.properties?.replicaParameters?.["sourceLocation"], + }, + administrator: !result.body.properties?.administrator + ? undefined + : { + userName: result.body.properties?.administrator?.["userName"], + password: result.body.properties?.administrator?.["password"], }, - administratorLogin: result.body.properties?.["administratorLogin"], - administratorLoginPassword: result.body.properties?.["administratorLoginPassword"], serverVersion: result.body.properties?.["serverVersion"], connectionString: result.body.properties?.["connectionString"], - earliestRestoreTime: result.body.properties?.["earliestRestoreTime"], provisioningState: result.body.properties?.["provisioningState"], clusterStatus: result.body.properties?.["clusterStatus"], publicNetworkAccess: result.body.properties?.["publicNetworkAccess"], - nodeGroupSpecs: - result.body.properties?.["nodeGroupSpecs"] === undefined - ? result.body.properties?.["nodeGroupSpecs"] - : result.body.properties?.["nodeGroupSpecs"].map((p) => { - return { - sku: p["sku"], - diskSizeGB: p["diskSizeGB"], - enableHa: p["enableHa"], - kind: p["kind"], - nodeCount: p["nodeCount"], - }; - }), + highAvailability: !result.body.properties?.highAvailability + ? undefined + : { + targetMode: + result.body.properties?.highAvailability?.["targetMode"], + }, + storage: !result.body.properties?.storage + ? undefined + : { sizeGb: result.body.properties?.storage?.["sizeGb"] }, + sharding: !result.body.properties?.sharding + ? undefined + : { shardCount: result.body.properties?.sharding?.["shardCount"] }, + compute: !result.body.properties?.compute + ? undefined + : { tier: result.body.properties?.compute?.["tier"] }, + backup: !result.body.properties?.backup + ? undefined + : { + earliestRestoreTime: + result.body.properties?.backup?.["earliestRestoreTime"], + }, privateEndpointConnections: result.body.properties?.["privateEndpointConnections"] === undefined ? result.body.properties?.["privateEndpointConnections"] - : result.body.properties?.["privateEndpointConnections"].map((p) => { - return { - id: p["id"], - name: p["name"], - type: p["type"], - systemData: !p.systemData - ? undefined - : { - createdBy: p.systemData?.["createdBy"], - createdByType: p.systemData?.["createdByType"], - createdAt: - p.systemData?.["createdAt"] !== undefined - ? new Date(p.systemData?.["createdAt"]) - : undefined, - lastModifiedBy: p.systemData?.["lastModifiedBy"], - lastModifiedByType: p.systemData?.["lastModifiedByType"], - lastModifiedAt: - p.systemData?.["lastModifiedAt"] !== undefined - ? new Date(p.systemData?.["lastModifiedAt"]) - : undefined, - }, - properties: !p.properties - ? undefined - : { - groupIds: p.properties?.["groupIds"], - privateEndpoint: !p.properties?.privateEndpoint - ? undefined - : { id: p.properties?.privateEndpoint?.["id"] }, - privateLinkServiceConnectionState: { - status: p.properties?.privateLinkServiceConnectionState["status"], - description: - p.properties?.privateLinkServiceConnectionState["description"], - actionsRequired: - p.properties?.privateLinkServiceConnectionState["actionsRequired"], + : result.body.properties?.["privateEndpointConnections"].map( + (p: any) => { + return { + id: p["id"], + name: p["name"], + type: p["type"], + systemData: !p.systemData + ? undefined + : { + createdBy: p.systemData?.["createdBy"], + createdByType: p.systemData?.["createdByType"], + createdAt: + p.systemData?.["createdAt"] !== undefined + ? new Date(p.systemData?.["createdAt"]) + : undefined, + lastModifiedBy: p.systemData?.["lastModifiedBy"], + lastModifiedByType: + p.systemData?.["lastModifiedByType"], + lastModifiedAt: + p.systemData?.["lastModifiedAt"] !== undefined + ? new Date(p.systemData?.["lastModifiedAt"]) + : undefined, + }, + properties: !p.properties + ? undefined + : { + groupIds: p.properties?.["groupIds"], + privateEndpoint: !p.properties?.privateEndpoint + ? undefined + : { id: p.properties?.privateEndpoint?.["id"] }, + privateLinkServiceConnectionState: { + status: + p.properties?.privateLinkServiceConnectionState[ + "status" + ], + description: + p.properties?.privateLinkServiceConnectionState[ + "description" + ], + actionsRequired: + p.properties?.privateLinkServiceConnectionState[ + "actionsRequired" + ], + }, + provisioningState: + p.properties?.["provisioningState"], }, - provisioningState: p.properties?.["provisioningState"], - }, - }; - }), + }; + }, + ), + previewFeatures: result.body.properties?.["previewFeatures"], + replica: !result.body.properties?.replica + ? undefined + : { + sourceResourceId: + result.body.properties?.replica?.["sourceResourceId"], + role: result.body.properties?.replica?.["role"], + replicationState: + result.body.properties?.replica?.["replicationState"], + }, + infrastructureVersion: + result.body.properties?.["infrastructureVersion"], }, }; } @@ -208,12 +243,7 @@ export function _mongoClustersCreateOrUpdateSend( mongoClusterName: string, resource: MongoCluster, options: MongoClustersCreateOrUpdateOptionalParams = { requestOptions: {} }, -): StreamableMethod< - | MongoClustersCreateOrUpdate200Response - | MongoClustersCreateOrUpdate201Response - | MongoClustersCreateOrUpdateDefaultResponse - | MongoClustersCreateOrUpdateLogicalResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}", @@ -224,7 +254,9 @@ export function _mongoClustersCreateOrUpdateSend( .put({ ...operationOptionsToRequestParameters(options), body: { - tags: !resource.tags ? resource.tags : (serializeRecord(resource.tags as any) as any), + tags: !resource.tags + ? resource.tags + : (serializeRecord(resource.tags as any) as any), location: resource["location"], properties: !resource.properties ? resource.properties @@ -234,114 +266,164 @@ export function _mongoClustersCreateOrUpdateSend( } export async function _mongoClustersCreateOrUpdateDeserialize( - result: - | MongoClustersCreateOrUpdate200Response - | MongoClustersCreateOrUpdate201Response - | MongoClustersCreateOrUpdateDefaultResponse - | MongoClustersCreateOrUpdateLogicalResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - const res = result as unknown as MongoClustersCreateOrUpdateLogicalResponse; return { - tags: res.body["tags"], - location: res.body["location"], - id: res.body["id"], - name: res.body["name"], - type: res.body["type"], - systemData: !res.body.systemData + tags: result.body["tags"], + location: result.body["location"], + id: result.body["id"], + name: result.body["name"], + type: result.body["type"], + systemData: !result.body.systemData ? undefined : { - createdBy: res.body.systemData?.["createdBy"], - createdByType: res.body.systemData?.["createdByType"], + createdBy: result.body.systemData?.["createdBy"], + createdByType: result.body.systemData?.["createdByType"], createdAt: - res.body.systemData?.["createdAt"] !== undefined - ? new Date(res.body.systemData?.["createdAt"]) + result.body.systemData?.["createdAt"] !== undefined + ? new Date(result.body.systemData?.["createdAt"]) : undefined, - lastModifiedBy: res.body.systemData?.["lastModifiedBy"], - lastModifiedByType: res.body.systemData?.["lastModifiedByType"], + lastModifiedBy: result.body.systemData?.["lastModifiedBy"], + lastModifiedByType: result.body.systemData?.["lastModifiedByType"], lastModifiedAt: - res.body.systemData?.["lastModifiedAt"] !== undefined - ? new Date(res.body.systemData?.["lastModifiedAt"]) + result.body.systemData?.["lastModifiedAt"] !== undefined + ? new Date(result.body.systemData?.["lastModifiedAt"]) : undefined, }, - properties: !res.body.properties + properties: !result.body.properties ? undefined : { - createMode: res.body.properties?.["createMode"], - restoreParameters: !res.body.properties?.restoreParameters + createMode: result.body.properties?.["createMode"], + restoreParameters: !result.body.properties?.restoreParameters ? undefined : { pointInTimeUTC: - res.body.properties?.restoreParameters?.["pointInTimeUTC"] !== undefined - ? new Date(res.body.properties?.restoreParameters?.["pointInTimeUTC"]) + result.body.properties?.restoreParameters?.[ + "pointInTimeUTC" + ] !== undefined + ? new Date( + result.body.properties?.restoreParameters?.[ + "pointInTimeUTC" + ], + ) : undefined, - sourceResourceId: res.body.properties?.restoreParameters?.["sourceResourceId"], + sourceResourceId: + result.body.properties?.restoreParameters?.[ + "sourceResourceId" + ], + }, + replicaParameters: !result.body.properties?.replicaParameters + ? undefined + : { + sourceResourceId: + result.body.properties?.replicaParameters?.[ + "sourceResourceId" + ], + sourceLocation: + result.body.properties?.replicaParameters?.["sourceLocation"], + }, + administrator: !result.body.properties?.administrator + ? undefined + : { + userName: result.body.properties?.administrator?.["userName"], + password: result.body.properties?.administrator?.["password"], + }, + serverVersion: result.body.properties?.["serverVersion"], + connectionString: result.body.properties?.["connectionString"], + provisioningState: result.body.properties?.["provisioningState"], + clusterStatus: result.body.properties?.["clusterStatus"], + publicNetworkAccess: result.body.properties?.["publicNetworkAccess"], + highAvailability: !result.body.properties?.highAvailability + ? undefined + : { + targetMode: + result.body.properties?.highAvailability?.["targetMode"], + }, + storage: !result.body.properties?.storage + ? undefined + : { sizeGb: result.body.properties?.storage?.["sizeGb"] }, + sharding: !result.body.properties?.sharding + ? undefined + : { shardCount: result.body.properties?.sharding?.["shardCount"] }, + compute: !result.body.properties?.compute + ? undefined + : { tier: result.body.properties?.compute?.["tier"] }, + backup: !result.body.properties?.backup + ? undefined + : { + earliestRestoreTime: + result.body.properties?.backup?.["earliestRestoreTime"], }, - administratorLogin: res.body.properties?.["administratorLogin"], - administratorLoginPassword: res.body.properties?.["administratorLoginPassword"], - serverVersion: res.body.properties?.["serverVersion"], - connectionString: res.body.properties?.["connectionString"], - earliestRestoreTime: res.body.properties?.["earliestRestoreTime"], - provisioningState: res.body.properties?.["provisioningState"], - clusterStatus: res.body.properties?.["clusterStatus"], - publicNetworkAccess: res.body.properties?.["publicNetworkAccess"], - nodeGroupSpecs: - res.body.properties?.["nodeGroupSpecs"] === undefined - ? res.body.properties?.["nodeGroupSpecs"] - : res.body.properties?.["nodeGroupSpecs"].map((p) => { - return { - sku: p["sku"], - diskSizeGB: p["diskSizeGB"], - enableHa: p["enableHa"], - kind: p["kind"], - nodeCount: p["nodeCount"], - }; - }), privateEndpointConnections: - res.body.properties?.["privateEndpointConnections"] === undefined - ? res.body.properties?.["privateEndpointConnections"] - : res.body.properties?.["privateEndpointConnections"].map((p) => { - return { - id: p["id"], - name: p["name"], - type: p["type"], - systemData: !p.systemData - ? undefined - : { - createdBy: p.systemData?.["createdBy"], - createdByType: p.systemData?.["createdByType"], - createdAt: - p.systemData?.["createdAt"] !== undefined - ? new Date(p.systemData?.["createdAt"]) - : undefined, - lastModifiedBy: p.systemData?.["lastModifiedBy"], - lastModifiedByType: p.systemData?.["lastModifiedByType"], - lastModifiedAt: - p.systemData?.["lastModifiedAt"] !== undefined - ? new Date(p.systemData?.["lastModifiedAt"]) - : undefined, - }, - properties: !p.properties - ? undefined - : { - groupIds: p.properties?.["groupIds"], - privateEndpoint: !p.properties?.privateEndpoint - ? undefined - : { id: p.properties?.privateEndpoint?.["id"] }, - privateLinkServiceConnectionState: { - status: p.properties?.privateLinkServiceConnectionState["status"], - description: - p.properties?.privateLinkServiceConnectionState["description"], - actionsRequired: - p.properties?.privateLinkServiceConnectionState["actionsRequired"], + result.body.properties?.["privateEndpointConnections"] === undefined + ? result.body.properties?.["privateEndpointConnections"] + : result.body.properties?.["privateEndpointConnections"].map( + (p: any) => { + return { + id: p["id"], + name: p["name"], + type: p["type"], + systemData: !p.systemData + ? undefined + : { + createdBy: p.systemData?.["createdBy"], + createdByType: p.systemData?.["createdByType"], + createdAt: + p.systemData?.["createdAt"] !== undefined + ? new Date(p.systemData?.["createdAt"]) + : undefined, + lastModifiedBy: p.systemData?.["lastModifiedBy"], + lastModifiedByType: + p.systemData?.["lastModifiedByType"], + lastModifiedAt: + p.systemData?.["lastModifiedAt"] !== undefined + ? new Date(p.systemData?.["lastModifiedAt"]) + : undefined, }, - provisioningState: p.properties?.["provisioningState"], - }, - }; - }), + properties: !p.properties + ? undefined + : { + groupIds: p.properties?.["groupIds"], + privateEndpoint: !p.properties?.privateEndpoint + ? undefined + : { id: p.properties?.privateEndpoint?.["id"] }, + privateLinkServiceConnectionState: { + status: + p.properties?.privateLinkServiceConnectionState[ + "status" + ], + description: + p.properties?.privateLinkServiceConnectionState[ + "description" + ], + actionsRequired: + p.properties?.privateLinkServiceConnectionState[ + "actionsRequired" + ], + }, + provisioningState: + p.properties?.["provisioningState"], + }, + }; + }, + ), + previewFeatures: result.body.properties?.["previewFeatures"], + replica: !result.body.properties?.replica + ? undefined + : { + sourceResourceId: + result.body.properties?.replica?.["sourceResourceId"], + role: result.body.properties?.replica?.["role"], + replicationState: + result.body.properties?.replica?.["replicationState"], + }, + infrastructureVersion: + result.body.properties?.["infrastructureVersion"], }, }; } @@ -355,19 +437,24 @@ export function mongoClustersCreateOrUpdate( resource: MongoCluster, options: MongoClustersCreateOrUpdateOptionalParams = { requestOptions: {} }, ): PollerLike, MongoCluster> { - return getLongRunningPoller(context, _mongoClustersCreateOrUpdateDeserialize, { - updateIntervalInMs: options?.updateIntervalInMs, - abortSignal: options?.abortSignal, - getInitialResponse: () => - _mongoClustersCreateOrUpdateSend( - context, - subscriptionId, - resourceGroupName, - mongoClusterName, - resource, - options, - ), - }) as PollerLike, MongoCluster>; + return getLongRunningPoller( + context, + _mongoClustersCreateOrUpdateDeserialize, + ["200", "201"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _mongoClustersCreateOrUpdateSend( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + resource, + options, + ), + }, + ) as PollerLike, MongoCluster>; } export function _mongoClustersUpdateSend( @@ -377,12 +464,7 @@ export function _mongoClustersUpdateSend( mongoClusterName: string, properties: MongoClusterUpdate, options: MongoClustersUpdateOptionalParams = { requestOptions: {} }, -): StreamableMethod< - | MongoClustersUpdate200Response - | MongoClustersUpdate202Response - | MongoClustersUpdateDefaultResponse - | MongoClustersUpdateLogicalResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}", @@ -393,7 +475,9 @@ export function _mongoClustersUpdateSend( .patch({ ...operationOptionsToRequestParameters(options), body: { - tags: !properties.tags ? properties.tags : (serializeRecord(properties.tags as any) as any), + tags: !properties.tags + ? properties.tags + : (serializeRecord(properties.tags as any) as any), properties: !properties.properties ? properties.properties : mongoClusterUpdatePropertiesSerializer(properties.properties), @@ -402,114 +486,164 @@ export function _mongoClustersUpdateSend( } export async function _mongoClustersUpdateDeserialize( - result: - | MongoClustersUpdate200Response - | MongoClustersUpdate202Response - | MongoClustersUpdateDefaultResponse - | MongoClustersUpdateLogicalResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["200", "202"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - const res = result as unknown as MongoClustersUpdateLogicalResponse; return { - tags: res.body["tags"], - location: res.body["location"], - id: res.body["id"], - name: res.body["name"], - type: res.body["type"], - systemData: !res.body.systemData + tags: result.body["tags"], + location: result.body["location"], + id: result.body["id"], + name: result.body["name"], + type: result.body["type"], + systemData: !result.body.systemData ? undefined : { - createdBy: res.body.systemData?.["createdBy"], - createdByType: res.body.systemData?.["createdByType"], + createdBy: result.body.systemData?.["createdBy"], + createdByType: result.body.systemData?.["createdByType"], createdAt: - res.body.systemData?.["createdAt"] !== undefined - ? new Date(res.body.systemData?.["createdAt"]) + result.body.systemData?.["createdAt"] !== undefined + ? new Date(result.body.systemData?.["createdAt"]) : undefined, - lastModifiedBy: res.body.systemData?.["lastModifiedBy"], - lastModifiedByType: res.body.systemData?.["lastModifiedByType"], + lastModifiedBy: result.body.systemData?.["lastModifiedBy"], + lastModifiedByType: result.body.systemData?.["lastModifiedByType"], lastModifiedAt: - res.body.systemData?.["lastModifiedAt"] !== undefined - ? new Date(res.body.systemData?.["lastModifiedAt"]) + result.body.systemData?.["lastModifiedAt"] !== undefined + ? new Date(result.body.systemData?.["lastModifiedAt"]) : undefined, }, - properties: !res.body.properties + properties: !result.body.properties ? undefined : { - createMode: res.body.properties?.["createMode"], - restoreParameters: !res.body.properties?.restoreParameters + createMode: result.body.properties?.["createMode"], + restoreParameters: !result.body.properties?.restoreParameters ? undefined : { pointInTimeUTC: - res.body.properties?.restoreParameters?.["pointInTimeUTC"] !== undefined - ? new Date(res.body.properties?.restoreParameters?.["pointInTimeUTC"]) + result.body.properties?.restoreParameters?.[ + "pointInTimeUTC" + ] !== undefined + ? new Date( + result.body.properties?.restoreParameters?.[ + "pointInTimeUTC" + ], + ) : undefined, - sourceResourceId: res.body.properties?.restoreParameters?.["sourceResourceId"], + sourceResourceId: + result.body.properties?.restoreParameters?.[ + "sourceResourceId" + ], + }, + replicaParameters: !result.body.properties?.replicaParameters + ? undefined + : { + sourceResourceId: + result.body.properties?.replicaParameters?.[ + "sourceResourceId" + ], + sourceLocation: + result.body.properties?.replicaParameters?.["sourceLocation"], + }, + administrator: !result.body.properties?.administrator + ? undefined + : { + userName: result.body.properties?.administrator?.["userName"], + password: result.body.properties?.administrator?.["password"], + }, + serverVersion: result.body.properties?.["serverVersion"], + connectionString: result.body.properties?.["connectionString"], + provisioningState: result.body.properties?.["provisioningState"], + clusterStatus: result.body.properties?.["clusterStatus"], + publicNetworkAccess: result.body.properties?.["publicNetworkAccess"], + highAvailability: !result.body.properties?.highAvailability + ? undefined + : { + targetMode: + result.body.properties?.highAvailability?.["targetMode"], + }, + storage: !result.body.properties?.storage + ? undefined + : { sizeGb: result.body.properties?.storage?.["sizeGb"] }, + sharding: !result.body.properties?.sharding + ? undefined + : { shardCount: result.body.properties?.sharding?.["shardCount"] }, + compute: !result.body.properties?.compute + ? undefined + : { tier: result.body.properties?.compute?.["tier"] }, + backup: !result.body.properties?.backup + ? undefined + : { + earliestRestoreTime: + result.body.properties?.backup?.["earliestRestoreTime"], }, - administratorLogin: res.body.properties?.["administratorLogin"], - administratorLoginPassword: res.body.properties?.["administratorLoginPassword"], - serverVersion: res.body.properties?.["serverVersion"], - connectionString: res.body.properties?.["connectionString"], - earliestRestoreTime: res.body.properties?.["earliestRestoreTime"], - provisioningState: res.body.properties?.["provisioningState"], - clusterStatus: res.body.properties?.["clusterStatus"], - publicNetworkAccess: res.body.properties?.["publicNetworkAccess"], - nodeGroupSpecs: - res.body.properties?.["nodeGroupSpecs"] === undefined - ? res.body.properties?.["nodeGroupSpecs"] - : res.body.properties?.["nodeGroupSpecs"].map((p) => { - return { - sku: p["sku"], - diskSizeGB: p["diskSizeGB"], - enableHa: p["enableHa"], - kind: p["kind"], - nodeCount: p["nodeCount"], - }; - }), privateEndpointConnections: - res.body.properties?.["privateEndpointConnections"] === undefined - ? res.body.properties?.["privateEndpointConnections"] - : res.body.properties?.["privateEndpointConnections"].map((p) => { - return { - id: p["id"], - name: p["name"], - type: p["type"], - systemData: !p.systemData - ? undefined - : { - createdBy: p.systemData?.["createdBy"], - createdByType: p.systemData?.["createdByType"], - createdAt: - p.systemData?.["createdAt"] !== undefined - ? new Date(p.systemData?.["createdAt"]) - : undefined, - lastModifiedBy: p.systemData?.["lastModifiedBy"], - lastModifiedByType: p.systemData?.["lastModifiedByType"], - lastModifiedAt: - p.systemData?.["lastModifiedAt"] !== undefined - ? new Date(p.systemData?.["lastModifiedAt"]) - : undefined, - }, - properties: !p.properties - ? undefined - : { - groupIds: p.properties?.["groupIds"], - privateEndpoint: !p.properties?.privateEndpoint - ? undefined - : { id: p.properties?.privateEndpoint?.["id"] }, - privateLinkServiceConnectionState: { - status: p.properties?.privateLinkServiceConnectionState["status"], - description: - p.properties?.privateLinkServiceConnectionState["description"], - actionsRequired: - p.properties?.privateLinkServiceConnectionState["actionsRequired"], + result.body.properties?.["privateEndpointConnections"] === undefined + ? result.body.properties?.["privateEndpointConnections"] + : result.body.properties?.["privateEndpointConnections"].map( + (p: any) => { + return { + id: p["id"], + name: p["name"], + type: p["type"], + systemData: !p.systemData + ? undefined + : { + createdBy: p.systemData?.["createdBy"], + createdByType: p.systemData?.["createdByType"], + createdAt: + p.systemData?.["createdAt"] !== undefined + ? new Date(p.systemData?.["createdAt"]) + : undefined, + lastModifiedBy: p.systemData?.["lastModifiedBy"], + lastModifiedByType: + p.systemData?.["lastModifiedByType"], + lastModifiedAt: + p.systemData?.["lastModifiedAt"] !== undefined + ? new Date(p.systemData?.["lastModifiedAt"]) + : undefined, + }, + properties: !p.properties + ? undefined + : { + groupIds: p.properties?.["groupIds"], + privateEndpoint: !p.properties?.privateEndpoint + ? undefined + : { id: p.properties?.privateEndpoint?.["id"] }, + privateLinkServiceConnectionState: { + status: + p.properties?.privateLinkServiceConnectionState[ + "status" + ], + description: + p.properties?.privateLinkServiceConnectionState[ + "description" + ], + actionsRequired: + p.properties?.privateLinkServiceConnectionState[ + "actionsRequired" + ], + }, + provisioningState: + p.properties?.["provisioningState"], }, - provisioningState: p.properties?.["provisioningState"], - }, - }; - }), + }; + }, + ), + previewFeatures: result.body.properties?.["previewFeatures"], + replica: !result.body.properties?.replica + ? undefined + : { + sourceResourceId: + result.body.properties?.replica?.["sourceResourceId"], + role: result.body.properties?.replica?.["role"], + replicationState: + result.body.properties?.replica?.["replicationState"], + }, + infrastructureVersion: + result.body.properties?.["infrastructureVersion"], }, }; } @@ -523,19 +657,24 @@ export function mongoClustersUpdate( properties: MongoClusterUpdate, options: MongoClustersUpdateOptionalParams = { requestOptions: {} }, ): PollerLike, MongoCluster> { - return getLongRunningPoller(context, _mongoClustersUpdateDeserialize, { - updateIntervalInMs: options?.updateIntervalInMs, - abortSignal: options?.abortSignal, - getInitialResponse: () => - _mongoClustersUpdateSend( - context, - subscriptionId, - resourceGroupName, - mongoClusterName, - properties, - options, - ), - }) as PollerLike, MongoCluster>; + return getLongRunningPoller( + context, + _mongoClustersUpdateDeserialize, + ["200", "202"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _mongoClustersUpdateSend( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + properties, + options, + ), + }, + ) as PollerLike, MongoCluster>; } export function _mongoClustersDeleteSend( @@ -544,12 +683,7 @@ export function _mongoClustersDeleteSend( resourceGroupName: string, mongoClusterName: string, options: MongoClustersDeleteOptionalParams = { requestOptions: {} }, -): StreamableMethod< - | MongoClustersDelete202Response - | MongoClustersDelete204Response - | MongoClustersDeleteDefaultResponse - | MongoClustersDeleteLogicalResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}", @@ -561,13 +695,10 @@ export function _mongoClustersDeleteSend( } export async function _mongoClustersDeleteDeserialize( - result: - | MongoClustersDelete202Response - | MongoClustersDelete204Response - | MongoClustersDeleteDefaultResponse - | MongoClustersDeleteLogicalResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["202", "204", "200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } @@ -582,18 +713,23 @@ export function mongoClustersDelete( mongoClusterName: string, options: MongoClustersDeleteOptionalParams = { requestOptions: {} }, ): PollerLike, void> { - return getLongRunningPoller(context, _mongoClustersDeleteDeserialize, { - updateIntervalInMs: options?.updateIntervalInMs, - abortSignal: options?.abortSignal, - getInitialResponse: () => - _mongoClustersDeleteSend( - context, - subscriptionId, - resourceGroupName, - mongoClusterName, - options, - ), - }) as PollerLike, void>; + return getLongRunningPoller( + context, + _mongoClustersDeleteDeserialize, + ["202", "204", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _mongoClustersDeleteSend( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + options, + ), + }, + ) as PollerLike, void>; } export function _mongoClustersListByResourceGroupSend( @@ -603,9 +739,7 @@ export function _mongoClustersListByResourceGroupSend( options: MongoClustersListByResourceGroupOptionalParams = { requestOptions: {}, }, -): StreamableMethod< - MongoClustersListByResourceGroup200Response | MongoClustersListByResourceGroupDefaultResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters", @@ -616,16 +750,15 @@ export function _mongoClustersListByResourceGroupSend( } export async function _mongoClustersListByResourceGroupDeserialize( - result: - | MongoClustersListByResourceGroup200Response - | MongoClustersListByResourceGroupDefaultResponse, + result: PathUncheckedResponse, ): Promise<_MongoClusterListResult> { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } return { - value: result.body["value"].map((p) => { + value: result.body["value"].map((p: any) => { return { tags: p["tags"], location: p["location"], @@ -656,75 +789,124 @@ export async function _mongoClustersListByResourceGroupDeserialize( ? undefined : { pointInTimeUTC: - p.properties?.restoreParameters?.["pointInTimeUTC"] !== undefined - ? new Date(p.properties?.restoreParameters?.["pointInTimeUTC"]) + p.properties?.restoreParameters?.["pointInTimeUTC"] !== + undefined + ? new Date( + p.properties?.restoreParameters?.["pointInTimeUTC"], + ) : undefined, - sourceResourceId: p.properties?.restoreParameters?.["sourceResourceId"], + sourceResourceId: + p.properties?.restoreParameters?.["sourceResourceId"], + }, + replicaParameters: !p.properties?.replicaParameters + ? undefined + : { + sourceResourceId: + p.properties?.replicaParameters?.["sourceResourceId"], + sourceLocation: + p.properties?.replicaParameters?.["sourceLocation"], + }, + administrator: !p.properties?.administrator + ? undefined + : { + userName: p.properties?.administrator?.["userName"], + password: p.properties?.administrator?.["password"], }, - administratorLogin: p.properties?.["administratorLogin"], - administratorLoginPassword: p.properties?.["administratorLoginPassword"], serverVersion: p.properties?.["serverVersion"], connectionString: p.properties?.["connectionString"], - earliestRestoreTime: p.properties?.["earliestRestoreTime"], provisioningState: p.properties?.["provisioningState"], clusterStatus: p.properties?.["clusterStatus"], publicNetworkAccess: p.properties?.["publicNetworkAccess"], - nodeGroupSpecs: - p.properties?.["nodeGroupSpecs"] === undefined - ? p.properties?.["nodeGroupSpecs"] - : p.properties?.["nodeGroupSpecs"].map((p) => { - return { - sku: p["sku"], - diskSizeGB: p["diskSizeGB"], - enableHa: p["enableHa"], - kind: p["kind"], - nodeCount: p["nodeCount"], - }; - }), + highAvailability: !p.properties?.highAvailability + ? undefined + : { + targetMode: p.properties?.highAvailability?.["targetMode"], + }, + storage: !p.properties?.storage + ? undefined + : { sizeGb: p.properties?.storage?.["sizeGb"] }, + sharding: !p.properties?.sharding + ? undefined + : { shardCount: p.properties?.sharding?.["shardCount"] }, + compute: !p.properties?.compute + ? undefined + : { tier: p.properties?.compute?.["tier"] }, + backup: !p.properties?.backup + ? undefined + : { + earliestRestoreTime: + p.properties?.backup?.["earliestRestoreTime"], + }, privateEndpointConnections: p.properties?.["privateEndpointConnections"] === undefined ? p.properties?.["privateEndpointConnections"] - : p.properties?.["privateEndpointConnections"].map((p) => { - return { - id: p["id"], - name: p["name"], - type: p["type"], - systemData: !p.systemData - ? undefined - : { - createdBy: p.systemData?.["createdBy"], - createdByType: p.systemData?.["createdByType"], - createdAt: - p.systemData?.["createdAt"] !== undefined - ? new Date(p.systemData?.["createdAt"]) - : undefined, - lastModifiedBy: p.systemData?.["lastModifiedBy"], - lastModifiedByType: p.systemData?.["lastModifiedByType"], - lastModifiedAt: - p.systemData?.["lastModifiedAt"] !== undefined - ? new Date(p.systemData?.["lastModifiedAt"]) - : undefined, - }, - properties: !p.properties - ? undefined - : { - groupIds: p.properties?.["groupIds"], - privateEndpoint: !p.properties?.privateEndpoint - ? undefined - : { id: p.properties?.privateEndpoint?.["id"] }, - privateLinkServiceConnectionState: { - status: p.properties?.privateLinkServiceConnectionState["status"], - description: - p.properties?.privateLinkServiceConnectionState["description"], - actionsRequired: - p.properties?.privateLinkServiceConnectionState[ - "actionsRequired" - ], + : p.properties?.["privateEndpointConnections"].map( + (p: any) => { + return { + id: p["id"], + name: p["name"], + type: p["type"], + systemData: !p.systemData + ? undefined + : { + createdBy: p.systemData?.["createdBy"], + createdByType: p.systemData?.["createdByType"], + createdAt: + p.systemData?.["createdAt"] !== undefined + ? new Date(p.systemData?.["createdAt"]) + : undefined, + lastModifiedBy: + p.systemData?.["lastModifiedBy"], + lastModifiedByType: + p.systemData?.["lastModifiedByType"], + lastModifiedAt: + p.systemData?.["lastModifiedAt"] !== undefined + ? new Date(p.systemData?.["lastModifiedAt"]) + : undefined, }, - provisioningState: p.properties?.["provisioningState"], - }, - }; - }), + properties: !p.properties + ? undefined + : { + groupIds: p.properties?.["groupIds"], + privateEndpoint: !p.properties?.privateEndpoint + ? undefined + : { + id: p.properties?.privateEndpoint?.["id"], + }, + privateLinkServiceConnectionState: { + status: + p.properties + ?.privateLinkServiceConnectionState[ + "status" + ], + description: + p.properties + ?.privateLinkServiceConnectionState[ + "description" + ], + actionsRequired: + p.properties + ?.privateLinkServiceConnectionState[ + "actionsRequired" + ], + }, + provisioningState: + p.properties?.["provisioningState"], + }, + }; + }, + ), + previewFeatures: p.properties?.["previewFeatures"], + replica: !p.properties?.replica + ? undefined + : { + sourceResourceId: + p.properties?.replica?.["sourceResourceId"], + role: p.properties?.replica?.["role"], + replicationState: + p.properties?.replica?.["replicationState"], + }, + infrastructureVersion: p.properties?.["infrastructureVersion"], }, }; }), @@ -744,8 +926,14 @@ export function mongoClustersListByResourceGroup( return buildPagedAsyncIterator( context, () => - _mongoClustersListByResourceGroupSend(context, subscriptionId, resourceGroupName, options), + _mongoClustersListByResourceGroupSend( + context, + subscriptionId, + resourceGroupName, + options, + ), _mongoClustersListByResourceGroupDeserialize, + ["200"], { itemName: "value", nextLinkName: "nextLink" }, ); } @@ -754,7 +942,7 @@ export function _mongoClustersListSend( context: Client, subscriptionId: string, options: MongoClustersListOptionalParams = { requestOptions: {} }, -): StreamableMethod { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/mongoClusters", @@ -764,14 +952,15 @@ export function _mongoClustersListSend( } export async function _mongoClustersListDeserialize( - result: MongoClustersList200Response | MongoClustersListDefaultResponse, + result: PathUncheckedResponse, ): Promise<_MongoClusterListResult> { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } return { - value: result.body["value"].map((p) => { + value: result.body["value"].map((p: any) => { return { tags: p["tags"], location: p["location"], @@ -802,75 +991,124 @@ export async function _mongoClustersListDeserialize( ? undefined : { pointInTimeUTC: - p.properties?.restoreParameters?.["pointInTimeUTC"] !== undefined - ? new Date(p.properties?.restoreParameters?.["pointInTimeUTC"]) + p.properties?.restoreParameters?.["pointInTimeUTC"] !== + undefined + ? new Date( + p.properties?.restoreParameters?.["pointInTimeUTC"], + ) : undefined, - sourceResourceId: p.properties?.restoreParameters?.["sourceResourceId"], + sourceResourceId: + p.properties?.restoreParameters?.["sourceResourceId"], + }, + replicaParameters: !p.properties?.replicaParameters + ? undefined + : { + sourceResourceId: + p.properties?.replicaParameters?.["sourceResourceId"], + sourceLocation: + p.properties?.replicaParameters?.["sourceLocation"], + }, + administrator: !p.properties?.administrator + ? undefined + : { + userName: p.properties?.administrator?.["userName"], + password: p.properties?.administrator?.["password"], }, - administratorLogin: p.properties?.["administratorLogin"], - administratorLoginPassword: p.properties?.["administratorLoginPassword"], serverVersion: p.properties?.["serverVersion"], connectionString: p.properties?.["connectionString"], - earliestRestoreTime: p.properties?.["earliestRestoreTime"], provisioningState: p.properties?.["provisioningState"], clusterStatus: p.properties?.["clusterStatus"], publicNetworkAccess: p.properties?.["publicNetworkAccess"], - nodeGroupSpecs: - p.properties?.["nodeGroupSpecs"] === undefined - ? p.properties?.["nodeGroupSpecs"] - : p.properties?.["nodeGroupSpecs"].map((p) => { - return { - sku: p["sku"], - diskSizeGB: p["diskSizeGB"], - enableHa: p["enableHa"], - kind: p["kind"], - nodeCount: p["nodeCount"], - }; - }), + highAvailability: !p.properties?.highAvailability + ? undefined + : { + targetMode: p.properties?.highAvailability?.["targetMode"], + }, + storage: !p.properties?.storage + ? undefined + : { sizeGb: p.properties?.storage?.["sizeGb"] }, + sharding: !p.properties?.sharding + ? undefined + : { shardCount: p.properties?.sharding?.["shardCount"] }, + compute: !p.properties?.compute + ? undefined + : { tier: p.properties?.compute?.["tier"] }, + backup: !p.properties?.backup + ? undefined + : { + earliestRestoreTime: + p.properties?.backup?.["earliestRestoreTime"], + }, privateEndpointConnections: p.properties?.["privateEndpointConnections"] === undefined ? p.properties?.["privateEndpointConnections"] - : p.properties?.["privateEndpointConnections"].map((p) => { - return { - id: p["id"], - name: p["name"], - type: p["type"], - systemData: !p.systemData - ? undefined - : { - createdBy: p.systemData?.["createdBy"], - createdByType: p.systemData?.["createdByType"], - createdAt: - p.systemData?.["createdAt"] !== undefined - ? new Date(p.systemData?.["createdAt"]) - : undefined, - lastModifiedBy: p.systemData?.["lastModifiedBy"], - lastModifiedByType: p.systemData?.["lastModifiedByType"], - lastModifiedAt: - p.systemData?.["lastModifiedAt"] !== undefined - ? new Date(p.systemData?.["lastModifiedAt"]) - : undefined, - }, - properties: !p.properties - ? undefined - : { - groupIds: p.properties?.["groupIds"], - privateEndpoint: !p.properties?.privateEndpoint - ? undefined - : { id: p.properties?.privateEndpoint?.["id"] }, - privateLinkServiceConnectionState: { - status: p.properties?.privateLinkServiceConnectionState["status"], - description: - p.properties?.privateLinkServiceConnectionState["description"], - actionsRequired: - p.properties?.privateLinkServiceConnectionState[ - "actionsRequired" - ], + : p.properties?.["privateEndpointConnections"].map( + (p: any) => { + return { + id: p["id"], + name: p["name"], + type: p["type"], + systemData: !p.systemData + ? undefined + : { + createdBy: p.systemData?.["createdBy"], + createdByType: p.systemData?.["createdByType"], + createdAt: + p.systemData?.["createdAt"] !== undefined + ? new Date(p.systemData?.["createdAt"]) + : undefined, + lastModifiedBy: + p.systemData?.["lastModifiedBy"], + lastModifiedByType: + p.systemData?.["lastModifiedByType"], + lastModifiedAt: + p.systemData?.["lastModifiedAt"] !== undefined + ? new Date(p.systemData?.["lastModifiedAt"]) + : undefined, }, - provisioningState: p.properties?.["provisioningState"], - }, - }; - }), + properties: !p.properties + ? undefined + : { + groupIds: p.properties?.["groupIds"], + privateEndpoint: !p.properties?.privateEndpoint + ? undefined + : { + id: p.properties?.privateEndpoint?.["id"], + }, + privateLinkServiceConnectionState: { + status: + p.properties + ?.privateLinkServiceConnectionState[ + "status" + ], + description: + p.properties + ?.privateLinkServiceConnectionState[ + "description" + ], + actionsRequired: + p.properties + ?.privateLinkServiceConnectionState[ + "actionsRequired" + ], + }, + provisioningState: + p.properties?.["provisioningState"], + }, + }; + }, + ), + previewFeatures: p.properties?.["previewFeatures"], + replica: !p.properties?.replica + ? undefined + : { + sourceResourceId: + p.properties?.replica?.["sourceResourceId"], + role: p.properties?.replica?.["role"], + replicationState: + p.properties?.replica?.["replicationState"], + }, + infrastructureVersion: p.properties?.["infrastructureVersion"], }, }; }), @@ -888,6 +1126,7 @@ export function mongoClustersList( context, () => _mongoClustersListSend(context, subscriptionId, options), _mongoClustersListDeserialize, + ["200"], { itemName: "value", nextLinkName: "nextLink" }, ); } @@ -900,9 +1139,7 @@ export function _mongoClustersListConnectionStringsSend( options: MongoClustersListConnectionStringsOptionalParams = { requestOptions: {}, }, -): StreamableMethod< - MongoClustersListConnectionStrings200Response | MongoClustersListConnectionStringsDefaultResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/listConnectionStrings", @@ -914,11 +1151,10 @@ export function _mongoClustersListConnectionStringsSend( } export async function _mongoClustersListConnectionStringsDeserialize( - result: - | MongoClustersListConnectionStrings200Response - | MongoClustersListConnectionStringsDefaultResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } @@ -926,10 +1162,11 @@ export async function _mongoClustersListConnectionStringsDeserialize( connectionStrings: result.body["connectionStrings"] === undefined ? result.body["connectionStrings"] - : result.body["connectionStrings"].map((p) => { + : result.body["connectionStrings"].map((p: any) => { return { connectionString: p["connectionString"], description: p["description"], + name: p["name"], }; }), }; @@ -963,9 +1200,7 @@ export function _mongoClustersCheckNameAvailabilitySend( options: MongoClustersCheckNameAvailabilityOptionalParams = { requestOptions: {}, }, -): StreamableMethod< - MongoClustersCheckNameAvailability200Response | MongoClustersCheckNameAvailabilityDefaultResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/checkMongoClusterNameAvailability", @@ -979,11 +1214,10 @@ export function _mongoClustersCheckNameAvailabilitySend( } export async function _mongoClustersCheckNameAvailabilityDeserialize( - result: - | MongoClustersCheckNameAvailability200Response - | MongoClustersCheckNameAvailabilityDefaultResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } @@ -1013,3 +1247,64 @@ export async function mongoClustersCheckNameAvailability( ); return _mongoClustersCheckNameAvailabilityDeserialize(result); } + +export function _mongoClustersPromoteSend( + context: Client, + subscriptionId: string, + resourceGroupName: string, + mongoClusterName: string, + body: PromoteReplicaRequest, + options: MongoClustersPromoteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/promote", + subscriptionId, + resourceGroupName, + mongoClusterName, + ) + .post({ + ...operationOptionsToRequestParameters(options), + body: { promoteOption: body["promoteOption"], mode: body["mode"] }, + }); +} + +export async function _mongoClustersPromoteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["202", "200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return; +} + +/** Promotes a replica mongo cluster to a primary role. */ +export function mongoClustersPromote( + context: Client, + subscriptionId: string, + resourceGroupName: string, + mongoClusterName: string, + body: PromoteReplicaRequest, + options: MongoClustersPromoteOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller( + context, + _mongoClustersPromoteDeserialize, + ["202", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _mongoClustersPromoteSend( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + body, + options, + ), + }, + ) as PollerLike, void>; +} diff --git a/sdk/mongocluster/arm-mongocluster/src/api/operations/index.ts b/sdk/mongocluster/arm-mongocluster/src/api/operations/index.ts index 6bb963f4b86d..0b20535b1576 100644 --- a/sdk/mongocluster/arm-mongocluster/src/api/operations/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/api/operations/index.ts @@ -2,39 +2,38 @@ // Licensed under the MIT License. import { Operation, _OperationListResult } from "../../models/models.js"; -import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js"; -import { buildPagedAsyncIterator } from "../pagingHelpers.js"; -import { - isUnexpected, - DocumentDBContext as Client, - OperationsList200Response, - OperationsListDefaultResponse, -} from "../../rest/index.js"; +import { DocumentDBContext as Client } from "../index.js"; import { StreamableMethod, operationOptionsToRequestParameters, + PathUncheckedResponse, createRestError, } from "@azure-rest/core-client"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; import { OperationsListOptionalParams } from "../../models/options.js"; export function _operationsListSend( context: Client, options: OperationsListOptionalParams = { requestOptions: {} }, -): StreamableMethod { +): StreamableMethod { return context .path("/providers/Microsoft.DocumentDB/operations") .get({ ...operationOptionsToRequestParameters(options) }); } export async function _operationsListDeserialize( - result: OperationsList200Response | OperationsListDefaultResponse, + result: PathUncheckedResponse, ): Promise<_OperationListResult> { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } return { - value: result.body["value"].map((p) => { + value: result.body["value"].map((p: any) => { return { name: p["name"], isDataAction: p["isDataAction"], @@ -63,6 +62,7 @@ export function operationsList( context, () => _operationsListSend(context, options), _operationsListDeserialize, + ["200"], { itemName: "value", nextLinkName: "nextLink" }, ); } diff --git a/sdk/mongocluster/arm-mongocluster/src/api/privateEndpointConnections/index.ts b/sdk/mongocluster/arm-mongocluster/src/api/privateEndpointConnections/index.ts index db014fb9148b..9e310b33dac0 100644 --- a/sdk/mongocluster/arm-mongocluster/src/api/privateEndpointConnections/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/api/privateEndpointConnections/index.ts @@ -1,37 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { getLongRunningPoller } from "../pollingHelpers.js"; -import { PollerLike, OperationState } from "@azure/core-lro"; import { privateEndpointConnectionPropertiesSerializer, PrivateEndpointConnectionResource, _PrivateEndpointConnectionResourceListResult, } from "../../models/models.js"; -import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js"; -import { buildPagedAsyncIterator } from "../pagingHelpers.js"; -import { - isUnexpected, - DocumentDBContext as Client, - PrivateEndpointConnectionsCreate200Response, - PrivateEndpointConnectionsCreate201Response, - PrivateEndpointConnectionsCreate202Response, - PrivateEndpointConnectionsCreateDefaultResponse, - PrivateEndpointConnectionsCreateLogicalResponse, - PrivateEndpointConnectionsDelete202Response, - PrivateEndpointConnectionsDelete204Response, - PrivateEndpointConnectionsDeleteDefaultResponse, - PrivateEndpointConnectionsDeleteLogicalResponse, - PrivateEndpointConnectionsGet200Response, - PrivateEndpointConnectionsGetDefaultResponse, - PrivateEndpointConnectionsListByMongoCluster200Response, - PrivateEndpointConnectionsListByMongoClusterDefaultResponse, -} from "../../rest/index.js"; +import { DocumentDBContext as Client } from "../index.js"; import { StreamableMethod, operationOptionsToRequestParameters, + PathUncheckedResponse, createRestError, } from "@azure-rest/core-client"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js"; +import { PollerLike, OperationState } from "@azure/core-lro"; import { PrivateEndpointConnectionsListByMongoClusterOptionalParams, PrivateEndpointConnectionsGetOptionalParams, @@ -47,10 +34,7 @@ export function _privateEndpointConnectionsListByMongoClusterSend( options: PrivateEndpointConnectionsListByMongoClusterOptionalParams = { requestOptions: {}, }, -): StreamableMethod< - | PrivateEndpointConnectionsListByMongoCluster200Response - | PrivateEndpointConnectionsListByMongoClusterDefaultResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections", @@ -62,16 +46,15 @@ export function _privateEndpointConnectionsListByMongoClusterSend( } export async function _privateEndpointConnectionsListByMongoClusterDeserialize( - result: - | PrivateEndpointConnectionsListByMongoCluster200Response - | PrivateEndpointConnectionsListByMongoClusterDefaultResponse, + result: PathUncheckedResponse, ): Promise<_PrivateEndpointConnectionResourceListResult> { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } return { - value: result.body["value"].map((p) => { + value: result.body["value"].map((p: any) => { return { id: p["id"], name: p["name"], @@ -100,9 +83,16 @@ export async function _privateEndpointConnectionsListByMongoClusterDeserialize( ? undefined : { id: p.properties?.privateEndpoint?.["id"] }, privateLinkServiceConnectionState: { - status: p.properties?.privateLinkServiceConnectionState["status"], - description: p.properties?.privateLinkServiceConnectionState["description"], - actionsRequired: p.properties?.privateLinkServiceConnectionState["actionsRequired"], + status: + p.properties?.privateLinkServiceConnectionState["status"], + description: + p.properties?.privateLinkServiceConnectionState[ + "description" + ], + actionsRequired: + p.properties?.privateLinkServiceConnectionState[ + "actionsRequired" + ], }, provisioningState: p.properties?.["provisioningState"], }, @@ -133,6 +123,7 @@ export function privateEndpointConnectionsListByMongoCluster( options, ), _privateEndpointConnectionsListByMongoClusterDeserialize, + ["200"], { itemName: "value", nextLinkName: "nextLink" }, ); } @@ -144,9 +135,7 @@ export function _privateEndpointConnectionsGetSend( mongoClusterName: string, privateEndpointConnectionName: string, options: PrivateEndpointConnectionsGetOptionalParams = { requestOptions: {} }, -): StreamableMethod< - PrivateEndpointConnectionsGet200Response | PrivateEndpointConnectionsGetDefaultResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}", @@ -159,9 +148,10 @@ export function _privateEndpointConnectionsGetSend( } export async function _privateEndpointConnectionsGetDeserialize( - result: PrivateEndpointConnectionsGet200Response | PrivateEndpointConnectionsGetDefaultResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } @@ -193,10 +183,18 @@ export async function _privateEndpointConnectionsGetDeserialize( ? undefined : { id: result.body.properties?.privateEndpoint?.["id"] }, privateLinkServiceConnectionState: { - status: result.body.properties?.privateLinkServiceConnectionState["status"], - description: result.body.properties?.privateLinkServiceConnectionState["description"], + status: + result.body.properties?.privateLinkServiceConnectionState[ + "status" + ], + description: + result.body.properties?.privateLinkServiceConnectionState[ + "description" + ], actionsRequired: - result.body.properties?.privateLinkServiceConnectionState["actionsRequired"], + result.body.properties?.privateLinkServiceConnectionState[ + "actionsRequired" + ], }, provisioningState: result.body.properties?.["provisioningState"], }, @@ -233,13 +231,7 @@ export function _privateEndpointConnectionsCreateSend( options: PrivateEndpointConnectionsCreateOptionalParams = { requestOptions: {}, }, -): StreamableMethod< - | PrivateEndpointConnectionsCreate200Response - | PrivateEndpointConnectionsCreate201Response - | PrivateEndpointConnectionsCreate202Response - | PrivateEndpointConnectionsCreateDefaultResponse - | PrivateEndpointConnectionsCreateLogicalResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}", @@ -259,52 +251,55 @@ export function _privateEndpointConnectionsCreateSend( } export async function _privateEndpointConnectionsCreateDeserialize( - result: - | PrivateEndpointConnectionsCreate200Response - | PrivateEndpointConnectionsCreate201Response - | PrivateEndpointConnectionsCreate202Response - | PrivateEndpointConnectionsCreateDefaultResponse - | PrivateEndpointConnectionsCreateLogicalResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["200", "201", "202"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - const res = result as unknown as PrivateEndpointConnectionsCreateLogicalResponse; return { - id: res.body["id"], - name: res.body["name"], - type: res.body["type"], - systemData: !res.body.systemData + id: result.body["id"], + name: result.body["name"], + type: result.body["type"], + systemData: !result.body.systemData ? undefined : { - createdBy: res.body.systemData?.["createdBy"], - createdByType: res.body.systemData?.["createdByType"], + createdBy: result.body.systemData?.["createdBy"], + createdByType: result.body.systemData?.["createdByType"], createdAt: - res.body.systemData?.["createdAt"] !== undefined - ? new Date(res.body.systemData?.["createdAt"]) + result.body.systemData?.["createdAt"] !== undefined + ? new Date(result.body.systemData?.["createdAt"]) : undefined, - lastModifiedBy: res.body.systemData?.["lastModifiedBy"], - lastModifiedByType: res.body.systemData?.["lastModifiedByType"], + lastModifiedBy: result.body.systemData?.["lastModifiedBy"], + lastModifiedByType: result.body.systemData?.["lastModifiedByType"], lastModifiedAt: - res.body.systemData?.["lastModifiedAt"] !== undefined - ? new Date(res.body.systemData?.["lastModifiedAt"]) + result.body.systemData?.["lastModifiedAt"] !== undefined + ? new Date(result.body.systemData?.["lastModifiedAt"]) : undefined, }, - properties: !res.body.properties + properties: !result.body.properties ? undefined : { - groupIds: res.body.properties?.["groupIds"], - privateEndpoint: !res.body.properties?.privateEndpoint + groupIds: result.body.properties?.["groupIds"], + privateEndpoint: !result.body.properties?.privateEndpoint ? undefined - : { id: res.body.properties?.privateEndpoint?.["id"] }, + : { id: result.body.properties?.privateEndpoint?.["id"] }, privateLinkServiceConnectionState: { - status: res.body.properties?.privateLinkServiceConnectionState["status"], - description: res.body.properties?.privateLinkServiceConnectionState["description"], + status: + result.body.properties?.privateLinkServiceConnectionState[ + "status" + ], + description: + result.body.properties?.privateLinkServiceConnectionState[ + "description" + ], actionsRequired: - res.body.properties?.privateLinkServiceConnectionState["actionsRequired"], + result.body.properties?.privateLinkServiceConnectionState[ + "actionsRequired" + ], }, - provisioningState: res.body.properties?.["provisioningState"], + provisioningState: result.body.properties?.["provisioningState"], }, }; } @@ -324,20 +319,25 @@ export function privateEndpointConnectionsCreate( OperationState, PrivateEndpointConnectionResource > { - return getLongRunningPoller(context, _privateEndpointConnectionsCreateDeserialize, { - updateIntervalInMs: options?.updateIntervalInMs, - abortSignal: options?.abortSignal, - getInitialResponse: () => - _privateEndpointConnectionsCreateSend( - context, - subscriptionId, - resourceGroupName, - mongoClusterName, - privateEndpointConnectionName, - resource, - options, - ), - }) as PollerLike< + return getLongRunningPoller( + context, + _privateEndpointConnectionsCreateDeserialize, + ["200", "201", "202"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _privateEndpointConnectionsCreateSend( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + privateEndpointConnectionName, + resource, + options, + ), + }, + ) as PollerLike< OperationState, PrivateEndpointConnectionResource >; @@ -352,12 +352,7 @@ export function _privateEndpointConnectionsDeleteSend( options: PrivateEndpointConnectionsDeleteOptionalParams = { requestOptions: {}, }, -): StreamableMethod< - | PrivateEndpointConnectionsDelete202Response - | PrivateEndpointConnectionsDelete204Response - | PrivateEndpointConnectionsDeleteDefaultResponse - | PrivateEndpointConnectionsDeleteLogicalResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}", @@ -370,13 +365,10 @@ export function _privateEndpointConnectionsDeleteSend( } export async function _privateEndpointConnectionsDeleteDeserialize( - result: - | PrivateEndpointConnectionsDelete202Response - | PrivateEndpointConnectionsDelete204Response - | PrivateEndpointConnectionsDeleteDefaultResponse - | PrivateEndpointConnectionsDeleteLogicalResponse, + result: PathUncheckedResponse, ): Promise { - if (isUnexpected(result)) { + const expectedStatuses = ["202", "204", "200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } @@ -394,17 +386,22 @@ export function privateEndpointConnectionsDelete( requestOptions: {}, }, ): PollerLike, void> { - return getLongRunningPoller(context, _privateEndpointConnectionsDeleteDeserialize, { - updateIntervalInMs: options?.updateIntervalInMs, - abortSignal: options?.abortSignal, - getInitialResponse: () => - _privateEndpointConnectionsDeleteSend( - context, - subscriptionId, - resourceGroupName, - mongoClusterName, - privateEndpointConnectionName, - options, - ), - }) as PollerLike, void>; + return getLongRunningPoller( + context, + _privateEndpointConnectionsDeleteDeserialize, + ["202", "204", "200"], + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _privateEndpointConnectionsDeleteSend( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + privateEndpointConnectionName, + options, + ), + }, + ) as PollerLike, void>; } diff --git a/sdk/mongocluster/arm-mongocluster/src/api/privateLinks/index.ts b/sdk/mongocluster/arm-mongocluster/src/api/privateLinks/index.ts index 645a11bd879e..ae3e65e8b38c 100644 --- a/sdk/mongocluster/arm-mongocluster/src/api/privateLinks/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/api/privateLinks/index.ts @@ -1,20 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { PrivateLinkResource, _PrivateLinkResourceListResult } from "../../models/models.js"; -import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js"; -import { buildPagedAsyncIterator } from "../pagingHelpers.js"; import { - isUnexpected, - DocumentDBContext as Client, - PrivateLinksListByMongoCluster200Response, - PrivateLinksListByMongoClusterDefaultResponse, -} from "../../rest/index.js"; + PrivateLinkResource, + _PrivateLinkResourceListResult, +} from "../../models/models.js"; +import { DocumentDBContext as Client } from "../index.js"; import { StreamableMethod, operationOptionsToRequestParameters, + PathUncheckedResponse, createRestError, } from "@azure-rest/core-client"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; import { PrivateLinksListByMongoClusterOptionalParams } from "../../models/options.js"; export function _privateLinksListByMongoClusterSend( @@ -25,9 +26,7 @@ export function _privateLinksListByMongoClusterSend( options: PrivateLinksListByMongoClusterOptionalParams = { requestOptions: {}, }, -): StreamableMethod< - PrivateLinksListByMongoCluster200Response | PrivateLinksListByMongoClusterDefaultResponse -> { +): StreamableMethod { return context .path( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateLinkResources", @@ -39,14 +38,15 @@ export function _privateLinksListByMongoClusterSend( } export async function _privateLinksListByMongoClusterDeserialize( - result: PrivateLinksListByMongoCluster200Response | PrivateLinksListByMongoClusterDefaultResponse, + result: PathUncheckedResponse, ): Promise<_PrivateLinkResourceListResult> { - if (isUnexpected(result)) { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } return { - value: result.body["value"].map((p) => { + value: result.body["value"].map((p: any) => { return { id: p["id"], name: p["name"], @@ -101,6 +101,7 @@ export function privateLinksListByMongoCluster( options, ), _privateLinksListByMongoClusterDeserialize, + ["200"], { itemName: "value", nextLinkName: "nextLink" }, ); } diff --git a/sdk/mongocluster/arm-mongocluster/src/api/replicas/index.ts b/sdk/mongocluster/arm-mongocluster/src/api/replicas/index.ts new file mode 100644 index 000000000000..45018f69c007 --- /dev/null +++ b/sdk/mongocluster/arm-mongocluster/src/api/replicas/index.ts @@ -0,0 +1,220 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Replica, _ReplicaListResult } from "../../models/models.js"; +import { DocumentDBContext as Client } from "../index.js"; +import { + StreamableMethod, + operationOptionsToRequestParameters, + PathUncheckedResponse, + createRestError, +} from "@azure-rest/core-client"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { ReplicasListByParentOptionalParams } from "../../models/options.js"; + +export function _replicasListByParentSend( + context: Client, + subscriptionId: string, + resourceGroupName: string, + mongoClusterName: string, + options: ReplicasListByParentOptionalParams = { requestOptions: {} }, +): StreamableMethod { + return context + .path( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/replicas", + subscriptionId, + resourceGroupName, + mongoClusterName, + ) + .get({ ...operationOptionsToRequestParameters(options) }); +} + +export async function _replicasListByParentDeserialize( + result: PathUncheckedResponse, +): Promise<_ReplicaListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return { + value: result.body["value"].map((p: any) => { + return { + id: p["id"], + name: p["name"], + type: p["type"], + systemData: !p.systemData + ? undefined + : { + createdBy: p.systemData?.["createdBy"], + createdByType: p.systemData?.["createdByType"], + createdAt: + p.systemData?.["createdAt"] !== undefined + ? new Date(p.systemData?.["createdAt"]) + : undefined, + lastModifiedBy: p.systemData?.["lastModifiedBy"], + lastModifiedByType: p.systemData?.["lastModifiedByType"], + lastModifiedAt: + p.systemData?.["lastModifiedAt"] !== undefined + ? new Date(p.systemData?.["lastModifiedAt"]) + : undefined, + }, + properties: !p.properties + ? undefined + : { + createMode: p.properties?.["createMode"], + restoreParameters: !p.properties?.restoreParameters + ? undefined + : { + pointInTimeUTC: + p.properties?.restoreParameters?.["pointInTimeUTC"] !== + undefined + ? new Date( + p.properties?.restoreParameters?.["pointInTimeUTC"], + ) + : undefined, + sourceResourceId: + p.properties?.restoreParameters?.["sourceResourceId"], + }, + replicaParameters: !p.properties?.replicaParameters + ? undefined + : { + sourceResourceId: + p.properties?.replicaParameters?.["sourceResourceId"], + sourceLocation: + p.properties?.replicaParameters?.["sourceLocation"], + }, + administrator: !p.properties?.administrator + ? undefined + : { + userName: p.properties?.administrator?.["userName"], + password: p.properties?.administrator?.["password"], + }, + serverVersion: p.properties?.["serverVersion"], + connectionString: p.properties?.["connectionString"], + provisioningState: p.properties?.["provisioningState"], + clusterStatus: p.properties?.["clusterStatus"], + publicNetworkAccess: p.properties?.["publicNetworkAccess"], + highAvailability: !p.properties?.highAvailability + ? undefined + : { + targetMode: p.properties?.highAvailability?.["targetMode"], + }, + storage: !p.properties?.storage + ? undefined + : { sizeGb: p.properties?.storage?.["sizeGb"] }, + sharding: !p.properties?.sharding + ? undefined + : { shardCount: p.properties?.sharding?.["shardCount"] }, + compute: !p.properties?.compute + ? undefined + : { tier: p.properties?.compute?.["tier"] }, + backup: !p.properties?.backup + ? undefined + : { + earliestRestoreTime: + p.properties?.backup?.["earliestRestoreTime"], + }, + privateEndpointConnections: + p.properties?.["privateEndpointConnections"] === undefined + ? p.properties?.["privateEndpointConnections"] + : p.properties?.["privateEndpointConnections"].map( + (p: any) => { + return { + id: p["id"], + name: p["name"], + type: p["type"], + systemData: !p.systemData + ? undefined + : { + createdBy: p.systemData?.["createdBy"], + createdByType: p.systemData?.["createdByType"], + createdAt: + p.systemData?.["createdAt"] !== undefined + ? new Date(p.systemData?.["createdAt"]) + : undefined, + lastModifiedBy: + p.systemData?.["lastModifiedBy"], + lastModifiedByType: + p.systemData?.["lastModifiedByType"], + lastModifiedAt: + p.systemData?.["lastModifiedAt"] !== undefined + ? new Date(p.systemData?.["lastModifiedAt"]) + : undefined, + }, + properties: !p.properties + ? undefined + : { + groupIds: p.properties?.["groupIds"], + privateEndpoint: !p.properties?.privateEndpoint + ? undefined + : { + id: p.properties?.privateEndpoint?.["id"], + }, + privateLinkServiceConnectionState: { + status: + p.properties + ?.privateLinkServiceConnectionState[ + "status" + ], + description: + p.properties + ?.privateLinkServiceConnectionState[ + "description" + ], + actionsRequired: + p.properties + ?.privateLinkServiceConnectionState[ + "actionsRequired" + ], + }, + provisioningState: + p.properties?.["provisioningState"], + }, + }; + }, + ), + previewFeatures: p.properties?.["previewFeatures"], + replica: !p.properties?.replica + ? undefined + : { + sourceResourceId: + p.properties?.replica?.["sourceResourceId"], + role: p.properties?.replica?.["role"], + replicationState: + p.properties?.replica?.["replicationState"], + }, + infrastructureVersion: p.properties?.["infrastructureVersion"], + }, + }; + }), + nextLink: result.body["nextLink"], + }; +} + +/** List all the replicas for the mongo cluster. */ +export function replicasListByParent( + context: Client, + subscriptionId: string, + resourceGroupName: string, + mongoClusterName: string, + options: ReplicasListByParentOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => + _replicasListByParentSend( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + options, + ), + _replicasListByParentDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} diff --git a/sdk/mongocluster/arm-mongocluster/src/classic/firewallRules/index.ts b/sdk/mongocluster/arm-mongocluster/src/classic/firewallRules/index.ts index ca0d147f5f1e..1f317d481c38 100644 --- a/sdk/mongocluster/arm-mongocluster/src/classic/firewallRules/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/classic/firewallRules/index.ts @@ -9,7 +9,7 @@ import { firewallRulesDelete, firewallRulesListByMongoCluster, } from "../../api/firewallRules/index.js"; -import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; import { PollerLike, OperationState } from "@azure/core-lro"; import { FirewallRulesGetOptionalParams, @@ -50,7 +50,10 @@ export interface FirewallRulesOperations { ) => PagedAsyncIterableIterator; } -export function getFirewallRules(context: DocumentDBContext, subscriptionId: string) { +export function getFirewallRules( + context: DocumentDBContext, + subscriptionId: string, +) { return { get: ( resourceGroupName: string, diff --git a/sdk/mongocluster/arm-mongocluster/src/classic/index.ts b/sdk/mongocluster/arm-mongocluster/src/classic/index.ts index 8964ac4fe199..1d258c12c12c 100644 --- a/sdk/mongocluster/arm-mongocluster/src/classic/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/classic/index.ts @@ -6,3 +6,4 @@ export { MongoClustersOperations } from "./mongoClusters/index.js"; export { OperationsOperations } from "./operations/index.js"; export { PrivateEndpointConnectionsOperations } from "./privateEndpointConnections/index.js"; export { PrivateLinksOperations } from "./privateLinks/index.js"; +export { ReplicasOperations } from "./replicas/index.js"; diff --git a/sdk/mongocluster/arm-mongocluster/src/classic/mongoClusters/index.ts b/sdk/mongocluster/arm-mongocluster/src/classic/mongoClusters/index.ts index 412cc17c1e37..ba71bc7aa5ba 100644 --- a/sdk/mongocluster/arm-mongocluster/src/classic/mongoClusters/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/classic/mongoClusters/index.ts @@ -8,6 +8,7 @@ import { ListConnectionStringsResult, CheckNameAvailabilityRequest, CheckNameAvailabilityResponse, + PromoteReplicaRequest, } from "../../models/models.js"; import { mongoClustersGet, @@ -18,8 +19,9 @@ import { mongoClustersList, mongoClustersListConnectionStrings, mongoClustersCheckNameAvailability, + mongoClustersPromote, } from "../../api/mongoClusters/index.js"; -import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; import { PollerLike, OperationState } from "@azure/core-lro"; import { MongoClustersGetOptionalParams, @@ -30,6 +32,7 @@ import { MongoClustersListOptionalParams, MongoClustersListConnectionStringsOptionalParams, MongoClustersCheckNameAvailabilityOptionalParams, + MongoClustersPromoteOptionalParams, } from "../../models/options.js"; /** Interface representing a MongoClusters operations. */ @@ -66,7 +69,9 @@ export interface MongoClustersOperations { options?: MongoClustersListByResourceGroupOptionalParams, ) => PagedAsyncIterableIterator; /** List all the mongo clusters in a given subscription. */ - list: (options?: MongoClustersListOptionalParams) => PagedAsyncIterableIterator; + list: ( + options?: MongoClustersListOptionalParams, + ) => PagedAsyncIterableIterator; /** List mongo cluster connection strings. This includes the default connection string using SCRAM-SHA-256, as well as other connection strings supported by the cluster. */ listConnectionStrings: ( resourceGroupName: string, @@ -79,15 +84,32 @@ export interface MongoClustersOperations { body: CheckNameAvailabilityRequest, options?: MongoClustersCheckNameAvailabilityOptionalParams, ) => Promise; + /** Promotes a replica mongo cluster to a primary role. */ + promote: ( + resourceGroupName: string, + mongoClusterName: string, + body: PromoteReplicaRequest, + options?: MongoClustersPromoteOptionalParams, + ) => PollerLike, void>; } -export function getMongoClusters(context: DocumentDBContext, subscriptionId: string) { +export function getMongoClusters( + context: DocumentDBContext, + subscriptionId: string, +) { return { get: ( resourceGroupName: string, mongoClusterName: string, options?: MongoClustersGetOptionalParams, - ) => mongoClustersGet(context, subscriptionId, resourceGroupName, mongoClusterName, options), + ) => + mongoClustersGet( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + options, + ), createOrUpdate: ( resourceGroupName: string, mongoClusterName: string, @@ -120,11 +142,24 @@ export function getMongoClusters(context: DocumentDBContext, subscriptionId: str resourceGroupName: string, mongoClusterName: string, options?: MongoClustersDeleteOptionalParams, - ) => mongoClustersDelete(context, subscriptionId, resourceGroupName, mongoClusterName, options), + ) => + mongoClustersDelete( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + options, + ), listByResourceGroup: ( resourceGroupName: string, options?: MongoClustersListByResourceGroupOptionalParams, - ) => mongoClustersListByResourceGroup(context, subscriptionId, resourceGroupName, options), + ) => + mongoClustersListByResourceGroup( + context, + subscriptionId, + resourceGroupName, + options, + ), list: (options?: MongoClustersListOptionalParams) => mongoClustersList(context, subscriptionId, options), listConnectionStrings: ( @@ -143,7 +178,28 @@ export function getMongoClusters(context: DocumentDBContext, subscriptionId: str location: string, body: CheckNameAvailabilityRequest, options?: MongoClustersCheckNameAvailabilityOptionalParams, - ) => mongoClustersCheckNameAvailability(context, subscriptionId, location, body, options), + ) => + mongoClustersCheckNameAvailability( + context, + subscriptionId, + location, + body, + options, + ), + promote: ( + resourceGroupName: string, + mongoClusterName: string, + body: PromoteReplicaRequest, + options?: MongoClustersPromoteOptionalParams, + ) => + mongoClustersPromote( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + body, + options, + ), }; } diff --git a/sdk/mongocluster/arm-mongocluster/src/classic/operations/index.ts b/sdk/mongocluster/arm-mongocluster/src/classic/operations/index.ts index c643fb028067..89092f5188e5 100644 --- a/sdk/mongocluster/arm-mongocluster/src/classic/operations/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/classic/operations/index.ts @@ -4,22 +4,27 @@ import { DocumentDBContext } from "../../api/mongoClusterManagementContext.js"; import { Operation } from "../../models/models.js"; import { operationsList } from "../../api/operations/index.js"; -import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; import { OperationsListOptionalParams } from "../../models/options.js"; /** Interface representing a Operations operations. */ export interface OperationsOperations { /** List the operations for the provider */ - list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; + list: ( + options?: OperationsListOptionalParams, + ) => PagedAsyncIterableIterator; } export function getOperations(context: DocumentDBContext) { return { - list: (options?: OperationsListOptionalParams) => operationsList(context, options), + list: (options?: OperationsListOptionalParams) => + operationsList(context, options), }; } -export function getOperationsOperations(context: DocumentDBContext): OperationsOperations { +export function getOperationsOperations( + context: DocumentDBContext, +): OperationsOperations { return { ...getOperations(context), }; diff --git a/sdk/mongocluster/arm-mongocluster/src/classic/privateEndpointConnections/index.ts b/sdk/mongocluster/arm-mongocluster/src/classic/privateEndpointConnections/index.ts index f7ced62ad913..51f9313a1ec9 100644 --- a/sdk/mongocluster/arm-mongocluster/src/classic/privateEndpointConnections/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/classic/privateEndpointConnections/index.ts @@ -9,7 +9,7 @@ import { privateEndpointConnectionsCreate, privateEndpointConnectionsDelete, } from "../../api/privateEndpointConnections/index.js"; -import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; import { PollerLike, OperationState } from "@azure/core-lro"; import { PrivateEndpointConnectionsListByMongoClusterOptionalParams, @@ -53,7 +53,10 @@ export interface PrivateEndpointConnectionsOperations { ) => PollerLike, void>; } -export function getPrivateEndpointConnections(context: DocumentDBContext, subscriptionId: string) { +export function getPrivateEndpointConnections( + context: DocumentDBContext, + subscriptionId: string, +) { return { listByMongoCluster: ( resourceGroupName: string, diff --git a/sdk/mongocluster/arm-mongocluster/src/classic/privateLinks/index.ts b/sdk/mongocluster/arm-mongocluster/src/classic/privateLinks/index.ts index 46bcdf27f4e2..9fbf6acfbf50 100644 --- a/sdk/mongocluster/arm-mongocluster/src/classic/privateLinks/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/classic/privateLinks/index.ts @@ -4,7 +4,7 @@ import { DocumentDBContext } from "../../api/mongoClusterManagementContext.js"; import { PrivateLinkResource } from "../../models/models.js"; import { privateLinksListByMongoCluster } from "../../api/privateLinks/index.js"; -import { PagedAsyncIterableIterator } from "../../models/pagingTypes.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; import { PrivateLinksListByMongoClusterOptionalParams } from "../../models/options.js"; /** Interface representing a PrivateLinks operations. */ @@ -17,7 +17,10 @@ export interface PrivateLinksOperations { ) => PagedAsyncIterableIterator; } -export function getPrivateLinks(context: DocumentDBContext, subscriptionId: string) { +export function getPrivateLinks( + context: DocumentDBContext, + subscriptionId: string, +) { return { listByMongoCluster: ( resourceGroupName: string, diff --git a/sdk/mongocluster/arm-mongocluster/src/classic/replicas/index.ts b/sdk/mongocluster/arm-mongocluster/src/classic/replicas/index.ts new file mode 100644 index 000000000000..a655beef2936 --- /dev/null +++ b/sdk/mongocluster/arm-mongocluster/src/classic/replicas/index.ts @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DocumentDBContext } from "../../api/mongoClusterManagementContext.js"; +import { Replica } from "../../models/models.js"; +import { replicasListByParent } from "../../api/replicas/index.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { ReplicasListByParentOptionalParams } from "../../models/options.js"; + +/** Interface representing a Replicas operations. */ +export interface ReplicasOperations { + /** List all the replicas for the mongo cluster. */ + listByParent: ( + resourceGroupName: string, + mongoClusterName: string, + options?: ReplicasListByParentOptionalParams, + ) => PagedAsyncIterableIterator; +} + +export function getReplicas( + context: DocumentDBContext, + subscriptionId: string, +) { + return { + listByParent: ( + resourceGroupName: string, + mongoClusterName: string, + options?: ReplicasListByParentOptionalParams, + ) => + replicasListByParent( + context, + subscriptionId, + resourceGroupName, + mongoClusterName, + options, + ), + }; +} + +export function getReplicasOperations( + context: DocumentDBContext, + subscriptionId: string, +): ReplicasOperations { + return { + ...getReplicas(context, subscriptionId), + }; +} diff --git a/sdk/mongocluster/arm-mongocluster/src/helpers/serializerHelpers.ts b/sdk/mongocluster/arm-mongocluster/src/helpers/serializerHelpers.ts index 7518a16c2ee9..4baaac77c8be 100644 --- a/sdk/mongocluster/arm-mongocluster/src/helpers/serializerHelpers.ts +++ b/sdk/mongocluster/arm-mongocluster/src/helpers/serializerHelpers.ts @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export function serializeRecord( - item: Record, -): Record; +export function serializeRecord< + T extends string | number | boolean | Date | null, + R, +>(item: Record): Record; export function serializeRecord( item: Record, serializer: (item: T) => R, @@ -32,5 +33,8 @@ export function serializeRecord( } function isSupportedRecordType(t: any) { - return ["number", "string", "boolean", "null"].includes(typeof t) || t instanceof Date; + return ( + ["number", "string", "boolean", "null"].includes(typeof t) || + t instanceof Date + ); } diff --git a/sdk/mongocluster/arm-mongocluster/src/index.ts b/sdk/mongocluster/arm-mongocluster/src/index.ts index 38964ecb8eef..6f0a45c1c724 100644 --- a/sdk/mongocluster/arm-mongocluster/src/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/index.ts @@ -1,6 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +import { + PageSettings, + ContinuablePage, + PagedAsyncIterableIterator, +} from "./static-helpers/pagingHelpers.js"; + export { MongoClusterManagementClient, MongoClusterManagementClientOptionalParams, @@ -12,12 +18,27 @@ export { KnownCreatedByType, CreatedByType, ProxyResource, - PrivateLinkResource, - PrivateLinkResourceProperties, - ErrorResponse, - ErrorDetail, - ErrorAdditionalInfo, - PrivateEndpointConnectionResource, + Replica, + MongoClusterProperties, + KnownCreateMode, + CreateMode, + MongoClusterRestoreParameters, + MongoClusterReplicaParameters, + AdministratorProperties, + KnownResourceProvisioningState, + ResourceProvisioningState, + KnownMongoClusterStatus, + MongoClusterStatus, + KnownPublicNetworkAccess, + PublicNetworkAccess, + HighAvailabilityProperties, + KnownHighAvailabilityMode, + HighAvailabilityMode, + StorageProperties, + ShardingProperties, + ComputeProperties, + BackupProperties, + PrivateEndpointConnection, PrivateEndpointConnectionProperties, PrivateEndpoint, PrivateLinkServiceConnectionState, @@ -25,24 +46,23 @@ export { PrivateEndpointServiceConnectionStatus, KnownPrivateEndpointConnectionProvisioningState, PrivateEndpointConnectionProvisioningState, + KnownPreviewFeature, + PreviewFeature, + ReplicationProperties, + KnownReplicationRole, + ReplicationRole, + KnownReplicationState, + ReplicationState, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + PrivateLinkResource, + PrivateLinkResourceProperties, + PrivateEndpointConnectionResource, FirewallRule, FirewallRuleProperties, - KnownResourceProvisioningState, - ResourceProvisioningState, TrackedResource, MongoCluster, - MongoClusterProperties, - KnownCreateMode, - CreateMode, - MongoClusterRestoreParameters, - KnownMongoClusterStatus, - MongoClusterStatus, - KnownPublicNetworkAccess, - PublicNetworkAccess, - NodeGroupSpec, - KnownNodeKind, - NodeKind, - PrivateEndpointConnection, MongoClusterUpdate, MongoClusterUpdateProperties, ListConnectionStringsResult, @@ -51,6 +71,11 @@ export { CheckNameAvailabilityResponse, KnownCheckNameAvailabilityReason, CheckNameAvailabilityReason, + PromoteReplicaRequest, + KnownPromoteOption, + PromoteOption, + KnownPromoteMode, + PromoteMode, Operation, OperationDisplay, KnownOrigin, @@ -68,6 +93,7 @@ export { MongoClustersListOptionalParams, MongoClustersListConnectionStringsOptionalParams, MongoClustersCheckNameAvailabilityOptionalParams, + MongoClustersPromoteOptionalParams, FirewallRulesGetOptionalParams, FirewallRulesCreateOrUpdateOptionalParams, FirewallRulesDeleteOptionalParams, @@ -77,9 +103,7 @@ export { PrivateEndpointConnectionsCreateOptionalParams, PrivateEndpointConnectionsDeleteOptionalParams, PrivateLinksListByMongoClusterOptionalParams, - PageSettings, - ContinuablePage, - PagedAsyncIterableIterator, + ReplicasListByParentOptionalParams, } from "./models/index.js"; export { FirewallRulesOperations, @@ -87,4 +111,6 @@ export { OperationsOperations, PrivateEndpointConnectionsOperations, PrivateLinksOperations, + ReplicasOperations, } from "./classic/index.js"; +export { PageSettings, ContinuablePage, PagedAsyncIterableIterator }; diff --git a/sdk/mongocluster/arm-mongocluster/src/models/index.ts b/sdk/mongocluster/arm-mongocluster/src/models/index.ts index 7b4c7692e0f3..999ce408ad64 100644 --- a/sdk/mongocluster/arm-mongocluster/src/models/index.ts +++ b/sdk/mongocluster/arm-mongocluster/src/models/index.ts @@ -7,12 +7,27 @@ export { KnownCreatedByType, CreatedByType, ProxyResource, - PrivateLinkResource, - PrivateLinkResourceProperties, - ErrorResponse, - ErrorDetail, - ErrorAdditionalInfo, - PrivateEndpointConnectionResource, + Replica, + MongoClusterProperties, + KnownCreateMode, + CreateMode, + MongoClusterRestoreParameters, + MongoClusterReplicaParameters, + AdministratorProperties, + KnownResourceProvisioningState, + ResourceProvisioningState, + KnownMongoClusterStatus, + MongoClusterStatus, + KnownPublicNetworkAccess, + PublicNetworkAccess, + HighAvailabilityProperties, + KnownHighAvailabilityMode, + HighAvailabilityMode, + StorageProperties, + ShardingProperties, + ComputeProperties, + BackupProperties, + PrivateEndpointConnection, PrivateEndpointConnectionProperties, PrivateEndpoint, PrivateLinkServiceConnectionState, @@ -20,24 +35,23 @@ export { PrivateEndpointServiceConnectionStatus, KnownPrivateEndpointConnectionProvisioningState, PrivateEndpointConnectionProvisioningState, + KnownPreviewFeature, + PreviewFeature, + ReplicationProperties, + KnownReplicationRole, + ReplicationRole, + KnownReplicationState, + ReplicationState, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + PrivateLinkResource, + PrivateLinkResourceProperties, + PrivateEndpointConnectionResource, FirewallRule, FirewallRuleProperties, - KnownResourceProvisioningState, - ResourceProvisioningState, TrackedResource, MongoCluster, - MongoClusterProperties, - KnownCreateMode, - CreateMode, - MongoClusterRestoreParameters, - KnownMongoClusterStatus, - MongoClusterStatus, - KnownPublicNetworkAccess, - PublicNetworkAccess, - NodeGroupSpec, - KnownNodeKind, - NodeKind, - PrivateEndpointConnection, MongoClusterUpdate, MongoClusterUpdateProperties, ListConnectionStringsResult, @@ -46,6 +60,11 @@ export { CheckNameAvailabilityResponse, KnownCheckNameAvailabilityReason, CheckNameAvailabilityReason, + PromoteReplicaRequest, + KnownPromoteOption, + PromoteOption, + KnownPromoteMode, + PromoteMode, Operation, OperationDisplay, KnownOrigin, @@ -65,6 +84,7 @@ export { MongoClustersListOptionalParams, MongoClustersListConnectionStringsOptionalParams, MongoClustersCheckNameAvailabilityOptionalParams, + MongoClustersPromoteOptionalParams, FirewallRulesGetOptionalParams, FirewallRulesCreateOrUpdateOptionalParams, FirewallRulesDeleteOptionalParams, @@ -74,5 +94,5 @@ export { PrivateEndpointConnectionsCreateOptionalParams, PrivateEndpointConnectionsDeleteOptionalParams, PrivateLinksListByMongoClusterOptionalParams, + ReplicasListByParentOptionalParams, } from "./options.js"; -export { PageSettings, ContinuablePage, PagedAsyncIterableIterator } from "./pagingTypes.js"; diff --git a/sdk/mongocluster/arm-mongocluster/src/models/models.ts b/sdk/mongocluster/arm-mongocluster/src/models/models.ts index e6f865d161ad..02e350cfd2f2 100644 --- a/sdk/mongocluster/arm-mongocluster/src/models/models.ts +++ b/sdk/mongocluster/arm-mongocluster/src/models/models.ts @@ -2,26 +2,11 @@ // Licensed under the MIT License. import { serializeRecord } from "../helpers/serializerHelpers.js"; -import { - PrivateEndpointConnectionResource as PrivateEndpointConnectionResourceRest, - PrivateEndpointConnectionProperties as PrivateEndpointConnectionPropertiesRest, - PrivateLinkServiceConnectionState as PrivateLinkServiceConnectionStateRest, - FirewallRule as FirewallRuleRest, - FirewallRuleProperties as FirewallRulePropertiesRest, - TrackedResource as TrackedResourceRest, - MongoCluster as MongoClusterRest, - MongoClusterProperties as MongoClusterPropertiesRest, - MongoClusterRestoreParameters as MongoClusterRestoreParametersRest, - NodeGroupSpec as NodeGroupSpecRest, - MongoClusterUpdate as MongoClusterUpdateRest, - MongoClusterUpdateProperties as MongoClusterUpdatePropertiesRest, - CheckNameAvailabilityRequest as CheckNameAvailabilityRequestRest, -} from "../rest/index.js"; -/** The response of a PrivateLinkResource list operation. */ -export interface _PrivateLinkResourceListResult { - /** The PrivateLinkResource items on this page */ - value: PrivateLinkResource[]; +/** The response of a Replica list operation. */ +export interface _ReplicaListResult { + /** The Replica items on this page */ + value: Replica[]; /** The link to the next page of items */ nextLink?: string; } @@ -89,74 +74,327 @@ export function proxyResourceSerializer(item: ProxyResource) { return item as any; } -/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ -export interface PrivateLinkResource extends ProxyResource { +/** Represents a mongo cluster replica. */ +export interface Replica extends ProxyResource { /** The resource-specific properties for this resource. */ - properties?: PrivateLinkResourceProperties; + properties?: MongoClusterProperties; } -/** Properties of a private link resource. */ -export interface PrivateLinkResourceProperties { - /** The private link resource group id. */ - readonly groupId?: string; - /** The private link resource required member names. */ - readonly requiredMembers?: string[]; - /** The private link resource private link DNS zone name. */ - requiredZoneNames?: string[]; +/** The properties of a mongo cluster. */ +export interface MongoClusterProperties { + /** The mode to create a mongo cluster. */ + createMode?: CreateMode; + /** The parameters to create a point-in-time restore mongo cluster. */ + restoreParameters?: MongoClusterRestoreParameters; + /** The parameters to create a replica mongo cluster. */ + replicaParameters?: MongoClusterReplicaParameters; + /** The local administrator properties for the mongo cluster. */ + administrator?: AdministratorProperties; + /** The Mongo DB server version. Defaults to the latest available version if not specified. */ + serverVersion?: string; + /** The default mongo connection string for the cluster. */ + readonly connectionString?: string; + /** The provisioning state of the mongo cluster. */ + readonly provisioningState?: ProvisioningState; + /** The status of the mongo cluster. */ + readonly clusterStatus?: MongoClusterStatus; + /** Whether or not public endpoint access is allowed for this mongo cluster. */ + publicNetworkAccess?: PublicNetworkAccess; + /** The high availability properties of the mongo cluster. */ + highAvailability?: HighAvailabilityProperties; + /** The storage properties of the mongo cluster. */ + storage?: StorageProperties; + /** The sharding properties of the mongo cluster. */ + sharding?: ShardingProperties; + /** The compute properties of the mongo cluster. */ + compute?: ComputeProperties; + /** The backup properties of the mongo cluster. */ + backup?: BackupProperties; + /** List of private endpoint connections. */ + readonly privateEndpointConnections?: PrivateEndpointConnection[]; + /** List of private endpoint connections. */ + previewFeatures?: PreviewFeature[]; + /** The replication properties for the mongo cluster */ + readonly replica?: ReplicationProperties; + /** The infrastructure version the cluster is provisioned on. */ + readonly infrastructureVersion?: string; } -/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. */ -export interface ErrorResponse { - /** The error object. */ - error?: ErrorDetail; +export function mongoClusterPropertiesSerializer( + item: MongoClusterProperties, +): Record { + return { + createMode: item["createMode"], + restoreParameters: !item.restoreParameters + ? item.restoreParameters + : mongoClusterRestoreParametersSerializer(item.restoreParameters), + replicaParameters: !item.replicaParameters + ? item.replicaParameters + : mongoClusterReplicaParametersSerializer(item.replicaParameters), + administrator: !item.administrator + ? item.administrator + : administratorPropertiesSerializer(item.administrator), + serverVersion: item["serverVersion"], + publicNetworkAccess: item["publicNetworkAccess"], + highAvailability: !item.highAvailability + ? item.highAvailability + : highAvailabilityPropertiesSerializer(item.highAvailability), + storage: !item.storage + ? item.storage + : storagePropertiesSerializer(item.storage), + sharding: !item.sharding + ? item.sharding + : shardingPropertiesSerializer(item.sharding), + compute: !item.compute + ? item.compute + : computePropertiesSerializer(item.compute), + backup: !item.backup + ? item.backup + : backupPropertiesSerializer(item.backup), + previewFeatures: item["previewFeatures"], + }; } -/** The error detail. */ -export interface ErrorDetail { - /** The error code. */ - readonly code?: string; - /** The error message. */ - readonly message?: string; - /** The error target. */ - readonly target?: string; - /** The error details. */ - readonly details?: ErrorDetail[]; - /** The error additional info. */ - readonly additionalInfo?: ErrorAdditionalInfo[]; +/** Known values of {@link CreateMode} that the service accepts. */ +export enum KnownCreateMode { + /** Default */ + Default = "Default", + /** PointInTimeRestore */ + PointInTimeRestore = "PointInTimeRestore", + /** GeoReplica */ + GeoReplica = "GeoReplica", + /** Replica */ + Replica = "Replica", } -/** The resource management error additional info. */ -export interface ErrorAdditionalInfo { - /** The additional info type. */ - readonly type?: string; - /** The additional info. */ - readonly info?: Record; +/** + * The mode that the Mongo Cluster is created with. \ + * {@link KnownCreateMode} can be used interchangeably with CreateMode, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Default** \ + * **PointInTimeRestore** \ + * **GeoReplica** \ + * **Replica** + */ +export type CreateMode = string; + +/** Parameters used for restore operations */ +export interface MongoClusterRestoreParameters { + /** UTC point in time to restore a mongo cluster */ + pointInTimeUTC?: Date; + /** Resource ID to locate the source cluster to restore */ + sourceResourceId?: string; } -/** The response of a PrivateEndpointConnectionResource list operation. */ -export interface _PrivateEndpointConnectionResourceListResult { - /** The PrivateEndpointConnectionResource items on this page */ - value: PrivateEndpointConnectionResource[]; - /** The link to the next page of items */ - nextLink?: string; +export function mongoClusterRestoreParametersSerializer( + item: MongoClusterRestoreParameters, +): Record { + return { + pointInTimeUTC: item["pointInTimeUTC"]?.toISOString(), + sourceResourceId: item["sourceResourceId"], + }; } -/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ -export interface PrivateEndpointConnectionResource extends ProxyResource { - /** The resource-specific properties for this resource. */ - properties?: PrivateEndpointConnectionProperties; +/** Parameters used for replica operations. */ +export interface MongoClusterReplicaParameters { + /** The id of the replication source cluster. */ + sourceResourceId: string; + /** The location of the source cluster */ + sourceLocation: string; } -export function privateEndpointConnectionResourceSerializer( - item: PrivateEndpointConnectionResource, -): PrivateEndpointConnectionResourceRest { +export function mongoClusterReplicaParametersSerializer( + item: MongoClusterReplicaParameters, +): Record { return { - properties: !item.properties - ? item.properties - : privateEndpointConnectionPropertiesSerializer(item.properties), + sourceResourceId: item["sourceResourceId"], + sourceLocation: item["sourceLocation"], + }; +} + +/** The local administrator login properties. */ +export interface AdministratorProperties { + /** The administrator user name. */ + userName?: string; + /** The administrator password. */ + password?: string; +} + +export function administratorPropertiesSerializer( + item: AdministratorProperties, +): Record { + return { + userName: item["userName"], + password: item["password"], + }; +} + +/** Known values of {@link ResourceProvisioningState} that the service accepts. */ +export enum KnownResourceProvisioningState { + /** Succeeded */ + Succeeded = "Succeeded", + /** Failed */ + Failed = "Failed", + /** Canceled */ + Canceled = "Canceled", +} + +/** + * The provisioning state of a resource type. \ + * {@link KnownResourceProvisioningState} can be used interchangeably with ResourceProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Succeeded** \ + * **Failed** \ + * **Canceled** + */ +export type ResourceProvisioningState = string; + +/** Known values of {@link MongoClusterStatus} that the service accepts. */ +export enum KnownMongoClusterStatus { + /** Ready */ + Ready = "Ready", + /** Provisioning */ + Provisioning = "Provisioning", + /** Updating */ + Updating = "Updating", + /** Starting */ + Starting = "Starting", + /** Stopping */ + Stopping = "Stopping", + /** Stopped */ + Stopped = "Stopped", + /** Dropping */ + Dropping = "Dropping", +} + +/** + * The status of the Mongo cluster resource. \ + * {@link KnownMongoClusterStatus} can be used interchangeably with MongoClusterStatus, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Ready** \ + * **Provisioning** \ + * **Updating** \ + * **Starting** \ + * **Stopping** \ + * **Stopped** \ + * **Dropping** + */ +export type MongoClusterStatus = string; + +/** Known values of {@link PublicNetworkAccess} that the service accepts. */ +export enum KnownPublicNetworkAccess { + /** Enabled */ + Enabled = "Enabled", + /** Disabled */ + Disabled = "Disabled", +} + +/** + * Whether or not public endpoint access is allowed for this Mongo cluster. Value is optional and default value is 'Enabled' \ + * {@link KnownPublicNetworkAccess} can be used interchangeably with PublicNetworkAccess, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Enabled** \ + * **Disabled** + */ +export type PublicNetworkAccess = string; + +/** The high availability properties of the cluster. */ +export interface HighAvailabilityProperties { + /** The target high availability mode requested for the cluster. */ + targetMode?: HighAvailabilityMode; +} + +export function highAvailabilityPropertiesSerializer( + item: HighAvailabilityProperties, +): Record { + return { + targetMode: item["targetMode"], + }; +} + +/** Known values of {@link HighAvailabilityMode} that the service accepts. */ +export enum KnownHighAvailabilityMode { + /** Disabled */ + Disabled = "Disabled", + /** SameZone */ + SameZone = "SameZone", + /** ZoneRedundantPreferred */ + ZoneRedundantPreferred = "ZoneRedundantPreferred", +} + +/** + * The high availability modes for a cluster. \ + * {@link KnownHighAvailabilityMode} can be used interchangeably with HighAvailabilityMode, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Disabled** \ + * **SameZone** \ + * **ZoneRedundantPreferred** + */ +export type HighAvailabilityMode = string; + +/** The storage properties of the cluster. This includes the data storage size and scaling applied to servers in the cluster. */ +export interface StorageProperties { + /** The size of the data disk assigned to each server. */ + sizeGb?: number; +} + +export function storagePropertiesSerializer( + item: StorageProperties, +): Record { + return { + sizeGb: item["sizeGb"], + }; +} + +/** The sharding properties of the cluster. This includes the shard count and scaling options for the cluster. */ +export interface ShardingProperties { + /** Number of shards to provision on the cluster. */ + shardCount?: number; +} + +export function shardingPropertiesSerializer( + item: ShardingProperties, +): Record { + return { + shardCount: item["shardCount"], + }; +} + +/** The compute properties of the cluster. This includes the virtual-cores/memory and scaling options applied to servers in the cluster. */ +export interface ComputeProperties { + /** The compute tier to assign to the cluster, where each tier maps to a virtual-core and memory size. Example values: 'M30', 'M40'. */ + tier?: string; +} + +export function computePropertiesSerializer( + item: ComputeProperties, +): Record { + return { + tier: item["tier"], }; } +/** The backup properties of the cluster. This includes the earliest restore time and retention settings. */ +export interface BackupProperties { + /** Earliest restore timestamp in UTC ISO8601 format. */ + readonly earliestRestoreTime?: string; +} + +export function backupPropertiesSerializer(item: BackupProperties) { + return item as any; +} + +/** The private endpoint connection resource */ +export interface PrivateEndpointConnection extends Resource { + /** The private endpoint connection properties */ + properties?: PrivateEndpointConnectionProperties; +} + /** Properties of the private endpoint connection. */ export interface PrivateEndpointConnectionProperties { /** The group ids for the private endpoint resource. */ @@ -171,14 +409,15 @@ export interface PrivateEndpointConnectionProperties { export function privateEndpointConnectionPropertiesSerializer( item: PrivateEndpointConnectionProperties, -): PrivateEndpointConnectionPropertiesRest { +): Record { return { privateEndpoint: !item.privateEndpoint ? item.privateEndpoint : privateEndpointSerializer(item.privateEndpoint), - privateLinkServiceConnectionState: privateLinkServiceConnectionStateSerializer( - item.privateLinkServiceConnectionState, - ), + privateLinkServiceConnectionState: + privateLinkServiceConnectionStateSerializer( + item.privateLinkServiceConnectionState, + ), }; } @@ -204,7 +443,7 @@ export interface PrivateLinkServiceConnectionState { export function privateLinkServiceConnectionStateSerializer( item: PrivateLinkServiceConnectionState, -): PrivateLinkServiceConnectionStateRest { +): Record { return { status: item["status"], description: item["description"], @@ -257,275 +496,234 @@ export enum KnownPrivateEndpointConnectionProvisioningState { */ export type PrivateEndpointConnectionProvisioningState = string; -/** Represents a mongo cluster firewall rule. */ -export interface FirewallRule extends ProxyResource { - /** The resource-specific properties for this resource. */ - properties?: FirewallRuleProperties; +/** Known values of {@link PreviewFeature} that the service accepts. */ +export enum KnownPreviewFeature { + /** GeoReplicas */ + GeoReplicas = "GeoReplicas", } -export function firewallRuleSerializer(item: FirewallRule): FirewallRuleRest { - return { - properties: !item.properties - ? item.properties - : firewallRulePropertiesSerializer(item.properties), - }; +/** + * Preview features that can be enabled on a mongo cluster. \ + * {@link KnownPreviewFeature} can be used interchangeably with PreviewFeature, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **GeoReplicas** + */ +export type PreviewFeature = string; + +/** Replica properties of the mongo cluster. */ +export interface ReplicationProperties { + /** The resource id the source cluster for the replica cluster. */ + readonly sourceResourceId?: string; + /** The replication role of the cluster */ + readonly role?: ReplicationRole; + /** The replication link state of the replica cluster. */ + readonly replicationState?: ReplicationState; } -/** The properties of a mongo cluster firewall rule. */ -export interface FirewallRuleProperties { - /** The provisioning state of the firewall rule. */ - readonly provisioningState?: ProvisioningState; - /** The start IP address of the mongo cluster firewall rule. Must be IPv4 format. */ - startIpAddress: string; - /** The end IP address of the mongo cluster firewall rule. Must be IPv4 format. */ - endIpAddress: string; +/** Known values of {@link ReplicationRole} that the service accepts. */ +export enum KnownReplicationRole { + /** Primary */ + Primary = "Primary", + /** AsyncReplica */ + AsyncReplica = "AsyncReplica", + /** GeoAsyncReplica */ + GeoAsyncReplica = "GeoAsyncReplica", } -export function firewallRulePropertiesSerializer( - item: FirewallRuleProperties, -): FirewallRulePropertiesRest { - return { - startIpAddress: item["startIpAddress"], - endIpAddress: item["endIpAddress"], - }; -} - -/** Known values of {@link ResourceProvisioningState} that the service accepts. */ -export enum KnownResourceProvisioningState { - /** Succeeded */ - Succeeded = "Succeeded", - /** Failed */ - Failed = "Failed", - /** Canceled */ - Canceled = "Canceled", +/** + * Replication role of the mongo cluster. \ + * {@link KnownReplicationRole} can be used interchangeably with ReplicationRole, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Primary** \ + * **AsyncReplica** \ + * **GeoAsyncReplica** + */ +export type ReplicationRole = string; + +/** Known values of {@link ReplicationState} that the service accepts. */ +export enum KnownReplicationState { + /** Active */ + Active = "Active", + /** Catchup */ + Catchup = "Catchup", + /** Provisioning */ + Provisioning = "Provisioning", + /** Updating */ + Updating = "Updating", + /** Broken */ + Broken = "Broken", + /** Reconfiguring */ + Reconfiguring = "Reconfiguring", } /** - * The provisioning state of a resource type. \ - * {@link KnownResourceProvisioningState} can be used interchangeably with ResourceProvisioningState, + * The state of the replication link between the replica and source cluster. \ + * {@link KnownReplicationState} can be used interchangeably with ReplicationState, * this enum contains the known values that the service supports. * ### Known values supported by the service - * **Succeeded** \ - * **Failed** \ - * **Canceled** + * **Active** \ + * **Catchup** \ + * **Provisioning** \ + * **Updating** \ + * **Broken** \ + * **Reconfiguring** */ -export type ResourceProvisioningState = string; +export type ReplicationState = string; -/** The response of a FirewallRule list operation. */ -export interface _FirewallRuleListResult { - /** The FirewallRule items on this page */ - value: FirewallRule[]; +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +/** The error detail. */ +export interface ErrorDetail { + /** The error code. */ + readonly code?: string; + /** The error message. */ + readonly message?: string; + /** The error target. */ + readonly target?: string; + /** The error details. */ + readonly details?: ErrorDetail[]; + /** The error additional info. */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** The additional info type. */ + readonly type?: string; + /** The additional info. */ + readonly info?: Record; +} + +/** The response of a PrivateLinkResource list operation. */ +export interface _PrivateLinkResourceListResult { + /** The PrivateLinkResource items on this page */ + value: PrivateLinkResource[]; /** The link to the next page of items */ nextLink?: string; } -/** 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; +/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ +export interface PrivateLinkResource extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: PrivateLinkResourceProperties; } -export function trackedResourceSerializer(item: TrackedResource): TrackedResourceRest { - return { - tags: !item.tags ? item.tags : (serializeRecord(item.tags as any) as any), - location: item["location"], - }; +/** Properties of a private link resource. */ +export interface PrivateLinkResourceProperties { + /** The private link resource group id. */ + readonly groupId?: string; + /** The private link resource required member names. */ + readonly requiredMembers?: string[]; + /** The private link resource private link DNS zone name. */ + requiredZoneNames?: string[]; } -/** Represents a mongo cluster resource. */ -export interface MongoCluster extends TrackedResource { +/** The response of a PrivateEndpointConnectionResource list operation. */ +export interface _PrivateEndpointConnectionResourceListResult { + /** The PrivateEndpointConnectionResource items on this page */ + value: PrivateEndpointConnectionResource[]; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ +export interface PrivateEndpointConnectionResource extends ProxyResource { /** The resource-specific properties for this resource. */ - properties?: MongoClusterProperties; + properties?: PrivateEndpointConnectionProperties; } -export function mongoClusterSerializer(item: MongoCluster): MongoClusterRest { +export function privateEndpointConnectionResourceSerializer( + item: PrivateEndpointConnectionResource, +): Record { return { - tags: !item.tags ? item.tags : (serializeRecord(item.tags as any) as any), - location: item["location"], properties: !item.properties ? item.properties - : mongoClusterPropertiesSerializer(item.properties), + : privateEndpointConnectionPropertiesSerializer(item.properties), }; } -/** The properties of a mongo cluster. */ -export interface MongoClusterProperties { - /** The mode to create a mongo cluster. */ - createMode?: CreateMode; - /** The parameters to create a point-in-time restore mongo cluster. */ - restoreParameters?: MongoClusterRestoreParameters; - /** The administrator's login for the mongo cluster. */ - administratorLogin?: string; - /** The password of the administrator login. */ - administratorLoginPassword?: string; - /** The Mongo DB server version. Defaults to the latest available version if not specified. */ - serverVersion?: string; - /** The default mongo connection string for the cluster. */ - readonly connectionString?: string; - /** Earliest restore timestamp in UTC ISO8601 format. */ - readonly earliestRestoreTime?: string; - /** The provisioning state of the mongo cluster. */ - readonly provisioningState?: ProvisioningState; - /** The status of the mongo cluster. */ - readonly clusterStatus?: MongoClusterStatus; - /** Whether or not public endpoint access is allowed for this mongo cluster. */ - publicNetworkAccess?: PublicNetworkAccess; - /** The list of node group specs in the cluster. */ - nodeGroupSpecs?: NodeGroupSpec[]; - /** List of private endpoint connections. */ - readonly privateEndpointConnections?: PrivateEndpointConnection[]; +/** Represents a mongo cluster firewall rule. */ +export interface FirewallRule extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: FirewallRuleProperties; } -export function mongoClusterPropertiesSerializer( - item: MongoClusterProperties, -): MongoClusterPropertiesRest { +export function firewallRuleSerializer( + item: FirewallRule, +): Record { return { - createMode: item["createMode"], - restoreParameters: !item.restoreParameters - ? item.restoreParameters - : mongoClusterRestoreParametersSerializer(item.restoreParameters), - administratorLogin: item["administratorLogin"], - administratorLoginPassword: item["administratorLoginPassword"], - serverVersion: item["serverVersion"], - publicNetworkAccess: item["publicNetworkAccess"], - nodeGroupSpecs: - item["nodeGroupSpecs"] === undefined - ? item["nodeGroupSpecs"] - : item["nodeGroupSpecs"].map(nodeGroupSpecSerializer), + properties: !item.properties + ? item.properties + : firewallRulePropertiesSerializer(item.properties), }; } -/** Known values of {@link CreateMode} that the service accepts. */ -export enum KnownCreateMode { - /** Default */ - Default = "Default", - /** PointInTimeRestore */ - PointInTimeRestore = "PointInTimeRestore", -} - -/** - * The mode that the Mongo Cluster is created with. \ - * {@link KnownCreateMode} can be used interchangeably with CreateMode, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **Default** \ - * **PointInTimeRestore** - */ -export type CreateMode = string; - -/** Parameters used for restore operations */ -export interface MongoClusterRestoreParameters { - /** UTC point in time to restore a mongo cluster */ - pointInTimeUTC?: Date; - /** Resource ID to locate the source cluster to restore */ - sourceResourceId?: string; +/** The properties of a mongo cluster firewall rule. */ +export interface FirewallRuleProperties { + /** The provisioning state of the firewall rule. */ + readonly provisioningState?: ProvisioningState; + /** The start IP address of the mongo cluster firewall rule. Must be IPv4 format. */ + startIpAddress: string; + /** The end IP address of the mongo cluster firewall rule. Must be IPv4 format. */ + endIpAddress: string; } -export function mongoClusterRestoreParametersSerializer( - item: MongoClusterRestoreParameters, -): MongoClusterRestoreParametersRest { +export function firewallRulePropertiesSerializer( + item: FirewallRuleProperties, +): Record { return { - pointInTimeUTC: item["pointInTimeUTC"]?.toISOString(), - sourceResourceId: item["sourceResourceId"], + startIpAddress: item["startIpAddress"], + endIpAddress: item["endIpAddress"], }; } -/** Known values of {@link MongoClusterStatus} that the service accepts. */ -export enum KnownMongoClusterStatus { - /** Ready */ - Ready = "Ready", - /** Provisioning */ - Provisioning = "Provisioning", - /** Updating */ - Updating = "Updating", - /** Starting */ - Starting = "Starting", - /** Stopping */ - Stopping = "Stopping", - /** Stopped */ - Stopped = "Stopped", - /** Dropping */ - Dropping = "Dropping", +/** The response of a FirewallRule list operation. */ +export interface _FirewallRuleListResult { + /** The FirewallRule items on this page */ + value: FirewallRule[]; + /** The link to the next page of items */ + nextLink?: string; } -/** - * The status of the Mongo cluster resource. \ - * {@link KnownMongoClusterStatus} can be used interchangeably with MongoClusterStatus, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **Ready** \ - * **Provisioning** \ - * **Updating** \ - * **Starting** \ - * **Stopping** \ - * **Stopped** \ - * **Dropping** - */ -export type MongoClusterStatus = string; - -/** Known values of {@link PublicNetworkAccess} that the service accepts. */ -export enum KnownPublicNetworkAccess { - /** Enabled */ - Enabled = "Enabled", - /** Disabled */ - Disabled = "Disabled", +/** 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; } -/** - * Whether or not public endpoint access is allowed for this Mongo cluster. Value is optional and default value is 'Enabled' \ - * {@link KnownPublicNetworkAccess} can be used interchangeably with PublicNetworkAccess, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **Enabled** \ - * **Disabled** - */ -export type PublicNetworkAccess = string; - -/** Specification for a node group. */ -export interface NodeGroupSpec { - /** The resource sku for the node group. This defines the size of CPU and memory that is provisioned for each node. Example values: 'M30', 'M40'. */ - sku?: string; - /** The disk storage size for the node group in GB. Example values: 128, 256, 512, 1024. */ - diskSizeGB?: number; - /** Whether high availability is enabled on the node group. */ - enableHa?: boolean; - /** The node type deployed in the node group. */ - kind?: NodeKind; - /** The number of nodes in the node group. */ - nodeCount?: number; -} - -export function nodeGroupSpecSerializer(item: NodeGroupSpec): NodeGroupSpecRest { +export function trackedResourceSerializer( + item: TrackedResource, +): Record { return { - sku: item["sku"], - diskSizeGB: item["diskSizeGB"], - enableHa: item["enableHa"], - kind: item["kind"], - nodeCount: item["nodeCount"], + tags: !item.tags ? item.tags : (serializeRecord(item.tags as any) as any), + location: item["location"], }; } -/** Known values of {@link NodeKind} that the service accepts. */ -export enum KnownNodeKind { - /** Shard */ - Shard = "Shard", +/** Represents a mongo cluster resource. */ +export interface MongoCluster extends TrackedResource { + /** The resource-specific properties for this resource. */ + properties?: MongoClusterProperties; } -/** - * The kind of the node on the cluster. \ - * {@link KnownNodeKind} can be used interchangeably with NodeKind, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **Shard** - */ -export type NodeKind = string; - -/** The private endpoint connection resource */ -export interface PrivateEndpointConnection extends Resource { - /** The private endpoint connection properties */ - properties?: PrivateEndpointConnectionProperties; +export function mongoClusterSerializer( + item: MongoCluster, +): Record { + return { + tags: !item.tags ? item.tags : (serializeRecord(item.tags as any) as any), + location: item["location"], + properties: !item.properties + ? item.properties + : mongoClusterPropertiesSerializer(item.properties), + }; } /** The type used for update operations of the MongoCluster. */ @@ -536,7 +734,9 @@ export interface MongoClusterUpdate { properties?: MongoClusterUpdateProperties; } -export function mongoClusterUpdateSerializer(item: MongoClusterUpdate): MongoClusterUpdateRest { +export function mongoClusterUpdateSerializer( + item: MongoClusterUpdate, +): Record { return { tags: !item.tags ? item.tags : (serializeRecord(item.tags as any) as any), properties: !item.properties @@ -547,30 +747,51 @@ export function mongoClusterUpdateSerializer(item: MongoClusterUpdate): MongoClu /** The updatable properties of the MongoCluster. */ export interface MongoClusterUpdateProperties { - /** The administrator's login for the mongo cluster. */ - administratorLogin?: string; - /** The password of the administrator login. */ - administratorLoginPassword?: string; + /** The local administrator properties for the mongo cluster. */ + administrator?: AdministratorProperties; /** The Mongo DB server version. Defaults to the latest available version if not specified. */ serverVersion?: string; /** Whether or not public endpoint access is allowed for this mongo cluster. */ publicNetworkAccess?: PublicNetworkAccess; - /** The list of node group specs in the cluster. */ - nodeGroupSpecs?: NodeGroupSpec[]; + /** The high availability properties of the mongo cluster. */ + highAvailability?: HighAvailabilityProperties; + /** The storage properties of the mongo cluster. */ + storage?: StorageProperties; + /** The sharding properties of the mongo cluster. */ + sharding?: ShardingProperties; + /** The compute properties of the mongo cluster. */ + compute?: ComputeProperties; + /** The backup properties of the mongo cluster. */ + backup?: BackupProperties; + /** List of private endpoint connections. */ + previewFeatures?: PreviewFeature[]; } export function mongoClusterUpdatePropertiesSerializer( item: MongoClusterUpdateProperties, -): MongoClusterUpdatePropertiesRest { +): Record { return { - administratorLogin: item["administratorLogin"], - administratorLoginPassword: item["administratorLoginPassword"], + administrator: !item.administrator + ? item.administrator + : administratorPropertiesSerializer(item.administrator), serverVersion: item["serverVersion"], publicNetworkAccess: item["publicNetworkAccess"], - nodeGroupSpecs: - item["nodeGroupSpecs"] === undefined - ? item["nodeGroupSpecs"] - : item["nodeGroupSpecs"].map(nodeGroupSpecSerializer), + highAvailability: !item.highAvailability + ? item.highAvailability + : highAvailabilityPropertiesSerializer(item.highAvailability), + storage: !item.storage + ? item.storage + : storagePropertiesSerializer(item.storage), + sharding: !item.sharding + ? item.sharding + : shardingPropertiesSerializer(item.sharding), + compute: !item.compute + ? item.compute + : computePropertiesSerializer(item.compute), + backup: !item.backup + ? item.backup + : backupPropertiesSerializer(item.backup), + previewFeatures: item["previewFeatures"], }; } @@ -594,6 +815,8 @@ export interface ConnectionString { readonly connectionString?: string; /** Description of the connection string */ readonly description?: string; + /** Name of the connection string. */ + readonly name?: string; } /** The check availability request body. */ @@ -606,7 +829,7 @@ export interface CheckNameAvailabilityRequest { export function checkNameAvailabilityRequestSerializer( item: CheckNameAvailabilityRequest, -): CheckNameAvailabilityRequestRest { +): Record { return { name: item["name"], type: item["type"], @@ -641,6 +864,53 @@ export enum KnownCheckNameAvailabilityReason { */ export type CheckNameAvailabilityReason = string; +/** Promote replica request properties. */ +export interface PromoteReplicaRequest { + /** The promote option to apply to the operation. */ + promoteOption: PromoteOption; + /** The mode to apply to the promote operation. Value is optional and default value is 'Switchover'. */ + mode?: PromoteMode; +} + +export function promoteReplicaRequestSerializer( + item: PromoteReplicaRequest, +): Record { + return { + promoteOption: item["promoteOption"], + mode: item["mode"], + }; +} + +/** Known values of {@link PromoteOption} that the service accepts. */ +export enum KnownPromoteOption { + /** Forced */ + Forced = "Forced", +} + +/** + * The option to apply to a promote operation. \ + * {@link KnownPromoteOption} can be used interchangeably with PromoteOption, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Forced** + */ +export type PromoteOption = string; + +/** Known values of {@link PromoteMode} that the service accepts. */ +export enum KnownPromoteMode { + /** Switchover */ + Switchover = "Switchover", +} + +/** + * The mode to apply to a promote operation. \ + * {@link KnownPromoteMode} can be used interchangeably with PromoteMode, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Switchover** + */ +export type PromoteMode = string; + /** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */ export interface _OperationListResult { /** The Operation items on this page */ @@ -711,7 +981,10 @@ export enum KnownActionType { */ export type ActionType = string; /** The available API versions. */ -export type Versions = "2024-03-01-preview"; +export type Versions = + | "2024-03-01-preview" + | "2024-06-01-preview" + | "2024-07-01"; /** Alias for ProvisioningState */ export type ProvisioningState = | string diff --git a/sdk/mongocluster/arm-mongocluster/src/models/options.ts b/sdk/mongocluster/arm-mongocluster/src/models/options.ts index 217a63d2c30c..d4537ed300f0 100644 --- a/sdk/mongocluster/arm-mongocluster/src/models/options.ts +++ b/sdk/mongocluster/arm-mongocluster/src/models/options.ts @@ -10,7 +10,8 @@ export interface OperationsListOptionalParams extends OperationOptions {} export interface MongoClustersGetOptionalParams extends OperationOptions {} /** Optional parameters. */ -export interface MongoClustersCreateOrUpdateOptionalParams extends OperationOptions { +export interface MongoClustersCreateOrUpdateOptionalParams + extends OperationOptions { /** Delay to wait until next poll, in milliseconds. */ updateIntervalInMs?: number; } @@ -28,22 +29,32 @@ export interface MongoClustersDeleteOptionalParams extends OperationOptions { } /** Optional parameters. */ -export interface MongoClustersListByResourceGroupOptionalParams extends OperationOptions {} +export interface MongoClustersListByResourceGroupOptionalParams + extends OperationOptions {} /** Optional parameters. */ export interface MongoClustersListOptionalParams extends OperationOptions {} /** Optional parameters. */ -export interface MongoClustersListConnectionStringsOptionalParams extends OperationOptions {} +export interface MongoClustersListConnectionStringsOptionalParams + extends OperationOptions {} /** Optional parameters. */ -export interface MongoClustersCheckNameAvailabilityOptionalParams extends OperationOptions {} +export interface MongoClustersCheckNameAvailabilityOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface MongoClustersPromoteOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} /** Optional parameters. */ export interface FirewallRulesGetOptionalParams extends OperationOptions {} /** Optional parameters. */ -export interface FirewallRulesCreateOrUpdateOptionalParams extends OperationOptions { +export interface FirewallRulesCreateOrUpdateOptionalParams + extends OperationOptions { /** Delay to wait until next poll, in milliseconds. */ updateIntervalInMs?: number; } @@ -55,26 +66,34 @@ export interface FirewallRulesDeleteOptionalParams extends OperationOptions { } /** Optional parameters. */ -export interface FirewallRulesListByMongoClusterOptionalParams extends OperationOptions {} +export interface FirewallRulesListByMongoClusterOptionalParams + extends OperationOptions {} /** Optional parameters. */ export interface PrivateEndpointConnectionsListByMongoClusterOptionalParams extends OperationOptions {} /** Optional parameters. */ -export interface PrivateEndpointConnectionsGetOptionalParams extends OperationOptions {} +export interface PrivateEndpointConnectionsGetOptionalParams + extends OperationOptions {} /** Optional parameters. */ -export interface PrivateEndpointConnectionsCreateOptionalParams extends OperationOptions { +export interface PrivateEndpointConnectionsCreateOptionalParams + extends OperationOptions { /** Delay to wait until next poll, in milliseconds. */ updateIntervalInMs?: number; } /** Optional parameters. */ -export interface PrivateEndpointConnectionsDeleteOptionalParams extends OperationOptions { +export interface PrivateEndpointConnectionsDeleteOptionalParams + extends OperationOptions { /** Delay to wait until next poll, in milliseconds. */ updateIntervalInMs?: number; } /** Optional parameters. */ -export interface PrivateLinksListByMongoClusterOptionalParams extends OperationOptions {} +export interface PrivateLinksListByMongoClusterOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface ReplicasListByParentOptionalParams extends OperationOptions {} diff --git a/sdk/mongocluster/arm-mongocluster/src/models/pagingTypes.ts b/sdk/mongocluster/arm-mongocluster/src/models/pagingTypes.ts deleted file mode 100644 index c002c23f31eb..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/models/pagingTypes.ts +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * 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; -} diff --git a/sdk/mongocluster/arm-mongocluster/src/mongoClusterManagementClient.ts b/sdk/mongocluster/arm-mongocluster/src/mongoClusterManagementClient.ts index bc6ee52e5251..783c12624c26 100644 --- a/sdk/mongocluster/arm-mongocluster/src/mongoClusterManagementClient.ts +++ b/sdk/mongocluster/arm-mongocluster/src/mongoClusterManagementClient.ts @@ -3,7 +3,10 @@ import { TokenCredential } from "@azure/core-auth"; import { Pipeline } from "@azure/core-rest-pipeline"; -import { getOperationsOperations, OperationsOperations } from "./classic/operations/index.js"; +import { + getOperationsOperations, + OperationsOperations, +} from "./classic/operations/index.js"; import { getMongoClustersOperations, MongoClustersOperations, @@ -16,11 +19,18 @@ import { getPrivateEndpointConnectionsOperations, PrivateEndpointConnectionsOperations, } from "./classic/privateEndpointConnections/index.js"; -import { getPrivateLinksOperations, PrivateLinksOperations } from "./classic/privateLinks/index.js"; +import { + getPrivateLinksOperations, + PrivateLinksOperations, +} from "./classic/privateLinks/index.js"; +import { + getReplicasOperations, + ReplicasOperations, +} from "./classic/replicas/index.js"; import { createMongoClusterManagement, - MongoClusterManagementClientOptionalParams, DocumentDBContext, + MongoClusterManagementClientOptionalParams, } from "./api/index.js"; export { MongoClusterManagementClientOptionalParams } from "./api/mongoClusterManagementContext.js"; @@ -40,20 +50,26 @@ export class MongoClusterManagementClient { const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-client` : "azsdk-js-client"; - this._client = createMongoClusterManagement(credential, { ...options, userAgentOptions: { userAgentPrefix }, }); this.pipeline = this._client.pipeline; this.operations = getOperationsOperations(this._client); - this.mongoClusters = getMongoClustersOperations(this._client, subscriptionId); - this.firewallRules = getFirewallRulesOperations(this._client, subscriptionId); + this.mongoClusters = getMongoClustersOperations( + this._client, + subscriptionId, + ); + this.firewallRules = getFirewallRulesOperations( + this._client, + subscriptionId, + ); this.privateEndpointConnections = getPrivateEndpointConnectionsOperations( this._client, subscriptionId, ); this.privateLinks = getPrivateLinksOperations(this._client, subscriptionId); + this.replicas = getReplicasOperations(this._client, subscriptionId); } /** The operation groups for Operations */ @@ -66,4 +82,6 @@ export class MongoClusterManagementClient { public readonly privateEndpointConnections: PrivateEndpointConnectionsOperations; /** The operation groups for PrivateLinks */ public readonly privateLinks: PrivateLinksOperations; + /** The operation groups for Replicas */ + public readonly replicas: ReplicasOperations; } diff --git a/sdk/mongocluster/arm-mongocluster/src/rest/clientDefinitions.ts b/sdk/mongocluster/arm-mongocluster/src/rest/clientDefinitions.ts deleted file mode 100644 index 0742207c0143..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/rest/clientDefinitions.ts +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { - OperationsListParameters, - MongoClustersGetParameters, - MongoClustersCreateOrUpdateParameters, - MongoClustersUpdateParameters, - MongoClustersDeleteParameters, - MongoClustersListByResourceGroupParameters, - MongoClustersListParameters, - MongoClustersListConnectionStringsParameters, - MongoClustersCheckNameAvailabilityParameters, - FirewallRulesGetParameters, - FirewallRulesCreateOrUpdateParameters, - FirewallRulesDeleteParameters, - FirewallRulesListByMongoClusterParameters, - PrivateEndpointConnectionsListByMongoClusterParameters, - PrivateEndpointConnectionsGetParameters, - PrivateEndpointConnectionsCreateParameters, - PrivateEndpointConnectionsDeleteParameters, - PrivateLinksListByMongoClusterParameters, -} from "./parameters.js"; -import { - OperationsList200Response, - OperationsListDefaultResponse, - MongoClustersGet200Response, - MongoClustersGetDefaultResponse, - MongoClustersCreateOrUpdate200Response, - MongoClustersCreateOrUpdate201Response, - MongoClustersCreateOrUpdateDefaultResponse, - MongoClustersUpdate200Response, - MongoClustersUpdate202Response, - MongoClustersUpdateDefaultResponse, - MongoClustersDelete202Response, - MongoClustersDelete204Response, - MongoClustersDeleteDefaultResponse, - MongoClustersListByResourceGroup200Response, - MongoClustersListByResourceGroupDefaultResponse, - MongoClustersList200Response, - MongoClustersListDefaultResponse, - MongoClustersListConnectionStrings200Response, - MongoClustersListConnectionStringsDefaultResponse, - MongoClustersCheckNameAvailability200Response, - MongoClustersCheckNameAvailabilityDefaultResponse, - FirewallRulesGet200Response, - FirewallRulesGetDefaultResponse, - FirewallRulesCreateOrUpdate200Response, - FirewallRulesCreateOrUpdate201Response, - FirewallRulesCreateOrUpdate202Response, - FirewallRulesCreateOrUpdateDefaultResponse, - FirewallRulesDelete202Response, - FirewallRulesDelete204Response, - FirewallRulesDeleteDefaultResponse, - FirewallRulesListByMongoCluster200Response, - FirewallRulesListByMongoClusterDefaultResponse, - PrivateEndpointConnectionsListByMongoCluster200Response, - PrivateEndpointConnectionsListByMongoClusterDefaultResponse, - PrivateEndpointConnectionsGet200Response, - PrivateEndpointConnectionsGetDefaultResponse, - PrivateEndpointConnectionsCreate200Response, - PrivateEndpointConnectionsCreate201Response, - PrivateEndpointConnectionsCreate202Response, - PrivateEndpointConnectionsCreateDefaultResponse, - PrivateEndpointConnectionsDelete202Response, - PrivateEndpointConnectionsDelete204Response, - PrivateEndpointConnectionsDeleteDefaultResponse, - PrivateLinksListByMongoCluster200Response, - PrivateLinksListByMongoClusterDefaultResponse, -} from "./responses.js"; -import { Client, StreamableMethod } from "@azure-rest/core-client"; - -export interface OperationsList { - /** List the operations for the provider */ - get( - options?: OperationsListParameters, - ): StreamableMethod; -} - -export interface MongoClustersGet { - /** Gets information about a mongo cluster. */ - get( - options?: MongoClustersGetParameters, - ): StreamableMethod; - /** Create or update a mongo cluster. Update overwrites all properties for the resource. To only modify some of the properties, use PATCH. */ - put( - options: MongoClustersCreateOrUpdateParameters, - ): StreamableMethod< - | MongoClustersCreateOrUpdate200Response - | MongoClustersCreateOrUpdate201Response - | MongoClustersCreateOrUpdateDefaultResponse - >; - /** Updates an existing mongo cluster. The request body can contain one to many of the properties present in the normal mongo cluster definition. */ - patch( - options: MongoClustersUpdateParameters, - ): StreamableMethod< - | MongoClustersUpdate200Response - | MongoClustersUpdate202Response - | MongoClustersUpdateDefaultResponse - >; - /** Deletes a mongo cluster. */ - delete( - options?: MongoClustersDeleteParameters, - ): StreamableMethod< - | MongoClustersDelete202Response - | MongoClustersDelete204Response - | MongoClustersDeleteDefaultResponse - >; -} - -export interface MongoClustersListByResourceGroup { - /** List all the mongo clusters in a given resource group. */ - get( - options?: MongoClustersListByResourceGroupParameters, - ): StreamableMethod< - MongoClustersListByResourceGroup200Response | MongoClustersListByResourceGroupDefaultResponse - >; -} - -export interface MongoClustersList { - /** List all the mongo clusters in a given subscription. */ - get( - options?: MongoClustersListParameters, - ): StreamableMethod; -} - -export interface MongoClustersListConnectionStrings { - /** List mongo cluster connection strings. This includes the default connection string using SCRAM-SHA-256, as well as other connection strings supported by the cluster. */ - post( - options: MongoClustersListConnectionStringsParameters, - ): StreamableMethod< - | MongoClustersListConnectionStrings200Response - | MongoClustersListConnectionStringsDefaultResponse - >; -} - -export interface MongoClustersCheckNameAvailability { - /** Check if mongo cluster name is available for use. */ - post( - options: MongoClustersCheckNameAvailabilityParameters, - ): StreamableMethod< - | MongoClustersCheckNameAvailability200Response - | MongoClustersCheckNameAvailabilityDefaultResponse - >; -} - -export interface FirewallRulesGet { - /** Gets information about a mongo cluster firewall rule. */ - get( - options?: FirewallRulesGetParameters, - ): StreamableMethod; - /** Creates a new firewall rule or updates an existing firewall rule on a mongo cluster. */ - put( - options: FirewallRulesCreateOrUpdateParameters, - ): StreamableMethod< - | FirewallRulesCreateOrUpdate200Response - | FirewallRulesCreateOrUpdate201Response - | FirewallRulesCreateOrUpdate202Response - | FirewallRulesCreateOrUpdateDefaultResponse - >; - /** Deletes a mongo cluster firewall rule. */ - delete( - options?: FirewallRulesDeleteParameters, - ): StreamableMethod< - | FirewallRulesDelete202Response - | FirewallRulesDelete204Response - | FirewallRulesDeleteDefaultResponse - >; -} - -export interface FirewallRulesListByMongoCluster { - /** List all the firewall rules in a given mongo cluster. */ - get( - options?: FirewallRulesListByMongoClusterParameters, - ): StreamableMethod< - FirewallRulesListByMongoCluster200Response | FirewallRulesListByMongoClusterDefaultResponse - >; -} - -export interface PrivateEndpointConnectionsListByMongoCluster { - /** List existing private connections */ - get( - options?: PrivateEndpointConnectionsListByMongoClusterParameters, - ): StreamableMethod< - | PrivateEndpointConnectionsListByMongoCluster200Response - | PrivateEndpointConnectionsListByMongoClusterDefaultResponse - >; -} - -export interface PrivateEndpointConnectionsGet { - /** Get a specific private connection */ - get( - options?: PrivateEndpointConnectionsGetParameters, - ): StreamableMethod< - PrivateEndpointConnectionsGet200Response | PrivateEndpointConnectionsGetDefaultResponse - >; - /** Create a Private endpoint connection */ - put( - options: PrivateEndpointConnectionsCreateParameters, - ): StreamableMethod< - | PrivateEndpointConnectionsCreate200Response - | PrivateEndpointConnectionsCreate201Response - | PrivateEndpointConnectionsCreate202Response - | PrivateEndpointConnectionsCreateDefaultResponse - >; - /** Delete the private endpoint connection */ - delete( - options?: PrivateEndpointConnectionsDeleteParameters, - ): StreamableMethod< - | PrivateEndpointConnectionsDelete202Response - | PrivateEndpointConnectionsDelete204Response - | PrivateEndpointConnectionsDeleteDefaultResponse - >; -} - -export interface PrivateLinksListByMongoCluster { - /** list private links on the given resource */ - get( - options?: PrivateLinksListByMongoClusterParameters, - ): StreamableMethod< - PrivateLinksListByMongoCluster200Response | PrivateLinksListByMongoClusterDefaultResponse - >; -} - -export interface Routes { - /** Resource for '/providers/Microsoft.DocumentDB/operations' has methods for the following verbs: get */ - (path: "/providers/Microsoft.DocumentDB/operations"): OperationsList; - /** Resource for '/subscriptions/\{subscriptionId\}/resourceGroups/\{resourceGroupName\}/providers/Microsoft.DocumentDB/mongoClusters/\{mongoClusterName\}' has methods for the following verbs: get, put, patch, delete */ - ( - path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}", - subscriptionId: string, - resourceGroupName: string, - mongoClusterName: string, - ): MongoClustersGet; - /** Resource for '/subscriptions/\{subscriptionId\}/resourceGroups/\{resourceGroupName\}/providers/Microsoft.DocumentDB/mongoClusters' has methods for the following verbs: get */ - ( - path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters", - subscriptionId: string, - resourceGroupName: string, - ): MongoClustersListByResourceGroup; - /** Resource for '/subscriptions/\{subscriptionId\}/providers/Microsoft.DocumentDB/mongoClusters' has methods for the following verbs: get */ - ( - path: "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/mongoClusters", - subscriptionId: string, - ): MongoClustersList; - /** Resource for '/subscriptions/\{subscriptionId\}/resourceGroups/\{resourceGroupName\}/providers/Microsoft.DocumentDB/mongoClusters/\{mongoClusterName\}/listConnectionStrings' has methods for the following verbs: post */ - ( - path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/listConnectionStrings", - subscriptionId: string, - resourceGroupName: string, - mongoClusterName: string, - ): MongoClustersListConnectionStrings; - /** Resource for '/subscriptions/\{subscriptionId\}/providers/Microsoft.DocumentDB/locations/\{location\}/checkMongoClusterNameAvailability' has methods for the following verbs: post */ - ( - path: "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/checkMongoClusterNameAvailability", - subscriptionId: string, - location: string, - ): MongoClustersCheckNameAvailability; - /** Resource for '/subscriptions/\{subscriptionId\}/resourceGroups/\{resourceGroupName\}/providers/Microsoft.DocumentDB/mongoClusters/\{mongoClusterName\}/firewallRules/\{firewallRuleName\}' has methods for the following verbs: get, put, delete */ - ( - path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}", - subscriptionId: string, - resourceGroupName: string, - mongoClusterName: string, - firewallRuleName: string, - ): FirewallRulesGet; - /** Resource for '/subscriptions/\{subscriptionId\}/resourceGroups/\{resourceGroupName\}/providers/Microsoft.DocumentDB/mongoClusters/\{mongoClusterName\}/firewallRules' has methods for the following verbs: get */ - ( - path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules", - subscriptionId: string, - resourceGroupName: string, - mongoClusterName: string, - ): FirewallRulesListByMongoCluster; - /** Resource for '/subscriptions/\{subscriptionId\}/resourceGroups/\{resourceGroupName\}/providers/Microsoft.DocumentDB/mongoClusters/\{mongoClusterName\}/privateEndpointConnections' has methods for the following verbs: get */ - ( - path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections", - subscriptionId: string, - resourceGroupName: string, - mongoClusterName: string, - ): PrivateEndpointConnectionsListByMongoCluster; - /** Resource for '/subscriptions/\{subscriptionId\}/resourceGroups/\{resourceGroupName\}/providers/Microsoft.DocumentDB/mongoClusters/\{mongoClusterName\}/privateEndpointConnections/\{privateEndpointConnectionName\}' has methods for the following verbs: get, put, delete */ - ( - path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}", - subscriptionId: string, - resourceGroupName: string, - mongoClusterName: string, - privateEndpointConnectionName: string, - ): PrivateEndpointConnectionsGet; - /** Resource for '/subscriptions/\{subscriptionId\}/resourceGroups/\{resourceGroupName\}/providers/Microsoft.DocumentDB/mongoClusters/\{mongoClusterName\}/privateLinkResources' has methods for the following verbs: get */ - ( - path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateLinkResources", - subscriptionId: string, - resourceGroupName: string, - mongoClusterName: string, - ): PrivateLinksListByMongoCluster; -} - -export type DocumentDBContext = Client & { - path: Routes; -}; diff --git a/sdk/mongocluster/arm-mongocluster/src/rest/documentDBClient.ts b/sdk/mongocluster/arm-mongocluster/src/rest/documentDBClient.ts deleted file mode 100644 index 231d19a5d678..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/rest/documentDBClient.ts +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { getClient, ClientOptions } from "@azure-rest/core-client"; -import { logger } from "../logger.js"; -import { TokenCredential } from "@azure/core-auth"; -import { DocumentDBContext } from "./clientDefinitions.js"; - -/** The optional parameters for the client */ -export interface DocumentDBContextOptions extends ClientOptions { - /** The api version option of the client */ - apiVersion?: string; -} - -/** - * Initialize a new instance of `DocumentDBContext` - * @param credentials - uniquely identify client credential - * @param options - the parameter for all optional parameters - */ -export default function createClient( - credentials: TokenCredential, - { apiVersion = "2024-03-01-preview", ...options }: DocumentDBContextOptions = {}, -): DocumentDBContext { - const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://management.azure.com`; - const userAgentInfo = `azsdk-js-arm-mongocluster/1.0.0-beta.2`; - const userAgentPrefix = - options.userAgentOptions && options.userAgentOptions.userAgentPrefix - ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` - : `${userAgentInfo}`; - options = { - ...options, - userAgentOptions: { - userAgentPrefix, - }, - loggingOptions: { - logger: options.loggingOptions?.logger ?? logger.info, - }, - credentials: { - scopes: options.credentials?.scopes ?? [`${endpointUrl}/.default`], - }, - }; - const client = getClient(endpointUrl, credentials, options) as DocumentDBContext; - - client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); - client.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") && apiVersion) { - req.url = `${req.url}${ - Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" - }api-version=${apiVersion}`; - } - - return next(req); - }, - }); - return client; -} diff --git a/sdk/mongocluster/arm-mongocluster/src/rest/index.ts b/sdk/mongocluster/arm-mongocluster/src/rest/index.ts deleted file mode 100644 index b1b37a4fdfed..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/rest/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import DocumentDBClient from "./documentDBClient.js"; - -export * from "./documentDBClient.js"; -export * from "./parameters.js"; -export * from "./responses.js"; -export * from "./clientDefinitions.js"; -export * from "./isUnexpected.js"; -export * from "./models.js"; -export * from "./outputModels.js"; -export * from "./paginateHelper.js"; -export * from "./pollingHelper.js"; - -export default DocumentDBClient; diff --git a/sdk/mongocluster/arm-mongocluster/src/rest/isUnexpected.ts b/sdk/mongocluster/arm-mongocluster/src/rest/isUnexpected.ts deleted file mode 100644 index 5c889080fe97..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/rest/isUnexpected.ts +++ /dev/null @@ -1,339 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { - OperationsList200Response, - OperationsListDefaultResponse, - MongoClustersGet200Response, - MongoClustersGetDefaultResponse, - MongoClustersCreateOrUpdate200Response, - MongoClustersCreateOrUpdate201Response, - MongoClustersCreateOrUpdateLogicalResponse, - MongoClustersCreateOrUpdateDefaultResponse, - MongoClustersUpdate200Response, - MongoClustersUpdate202Response, - MongoClustersUpdateLogicalResponse, - MongoClustersUpdateDefaultResponse, - MongoClustersDelete202Response, - MongoClustersDelete204Response, - MongoClustersDeleteLogicalResponse, - MongoClustersDeleteDefaultResponse, - MongoClustersListByResourceGroup200Response, - MongoClustersListByResourceGroupDefaultResponse, - MongoClustersList200Response, - MongoClustersListDefaultResponse, - MongoClustersListConnectionStrings200Response, - MongoClustersListConnectionStringsDefaultResponse, - MongoClustersCheckNameAvailability200Response, - MongoClustersCheckNameAvailabilityDefaultResponse, - FirewallRulesGet200Response, - FirewallRulesGetDefaultResponse, - FirewallRulesCreateOrUpdate200Response, - FirewallRulesCreateOrUpdate201Response, - FirewallRulesCreateOrUpdate202Response, - FirewallRulesCreateOrUpdateLogicalResponse, - FirewallRulesCreateOrUpdateDefaultResponse, - FirewallRulesDelete202Response, - FirewallRulesDelete204Response, - FirewallRulesDeleteLogicalResponse, - FirewallRulesDeleteDefaultResponse, - FirewallRulesListByMongoCluster200Response, - FirewallRulesListByMongoClusterDefaultResponse, - PrivateEndpointConnectionsListByMongoCluster200Response, - PrivateEndpointConnectionsListByMongoClusterDefaultResponse, - PrivateEndpointConnectionsGet200Response, - PrivateEndpointConnectionsGetDefaultResponse, - PrivateEndpointConnectionsCreate200Response, - PrivateEndpointConnectionsCreate201Response, - PrivateEndpointConnectionsCreate202Response, - PrivateEndpointConnectionsCreateLogicalResponse, - PrivateEndpointConnectionsCreateDefaultResponse, - PrivateEndpointConnectionsDelete202Response, - PrivateEndpointConnectionsDelete204Response, - PrivateEndpointConnectionsDeleteLogicalResponse, - PrivateEndpointConnectionsDeleteDefaultResponse, - PrivateLinksListByMongoCluster200Response, - PrivateLinksListByMongoClusterDefaultResponse, -} from "./responses.js"; - -const responseMap: Record = { - "GET /providers/Microsoft.DocumentDB/operations": ["200"], - "GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}": - ["200"], - "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}": - ["200", "201"], - "PATCH /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}": - ["200", "202"], - "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}": - ["202", "204"], - "GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters": - ["200"], - "GET /subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/mongoClusters": ["200"], - "POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/listConnectionStrings": - ["200"], - "POST /subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/checkMongoClusterNameAvailability": - ["200"], - "GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}": - ["200"], - "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}": - ["200", "201", "202"], - "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}": - ["202", "204"], - "GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules": - ["200"], - "GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections": - ["200"], - "GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}": - ["200"], - "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}": - ["200", "201", "202"], - "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}": - ["202", "204"], - "GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateLinkResources": - ["200"], -}; - -export function isUnexpected( - response: OperationsList200Response | OperationsListDefaultResponse, -): response is OperationsListDefaultResponse; -export function isUnexpected( - response: MongoClustersGet200Response | MongoClustersGetDefaultResponse, -): response is MongoClustersGetDefaultResponse; -export function isUnexpected( - response: - | MongoClustersCreateOrUpdate200Response - | MongoClustersCreateOrUpdate201Response - | MongoClustersCreateOrUpdateLogicalResponse - | MongoClustersCreateOrUpdateDefaultResponse, -): response is MongoClustersCreateOrUpdateDefaultResponse; -export function isUnexpected( - response: - | MongoClustersUpdate200Response - | MongoClustersUpdate202Response - | MongoClustersUpdateLogicalResponse - | MongoClustersUpdateDefaultResponse, -): response is MongoClustersUpdateDefaultResponse; -export function isUnexpected( - response: - | MongoClustersDelete202Response - | MongoClustersDelete204Response - | MongoClustersDeleteLogicalResponse - | MongoClustersDeleteDefaultResponse, -): response is MongoClustersDeleteDefaultResponse; -export function isUnexpected( - response: - | MongoClustersListByResourceGroup200Response - | MongoClustersListByResourceGroupDefaultResponse, -): response is MongoClustersListByResourceGroupDefaultResponse; -export function isUnexpected( - response: MongoClustersList200Response | MongoClustersListDefaultResponse, -): response is MongoClustersListDefaultResponse; -export function isUnexpected( - response: - | MongoClustersListConnectionStrings200Response - | MongoClustersListConnectionStringsDefaultResponse, -): response is MongoClustersListConnectionStringsDefaultResponse; -export function isUnexpected( - response: - | MongoClustersCheckNameAvailability200Response - | MongoClustersCheckNameAvailabilityDefaultResponse, -): response is MongoClustersCheckNameAvailabilityDefaultResponse; -export function isUnexpected( - response: FirewallRulesGet200Response | FirewallRulesGetDefaultResponse, -): response is FirewallRulesGetDefaultResponse; -export function isUnexpected( - response: - | FirewallRulesCreateOrUpdate200Response - | FirewallRulesCreateOrUpdate201Response - | FirewallRulesCreateOrUpdate202Response - | FirewallRulesCreateOrUpdateLogicalResponse - | FirewallRulesCreateOrUpdateDefaultResponse, -): response is FirewallRulesCreateOrUpdateDefaultResponse; -export function isUnexpected( - response: - | FirewallRulesDelete202Response - | FirewallRulesDelete204Response - | FirewallRulesDeleteLogicalResponse - | FirewallRulesDeleteDefaultResponse, -): response is FirewallRulesDeleteDefaultResponse; -export function isUnexpected( - response: - | FirewallRulesListByMongoCluster200Response - | FirewallRulesListByMongoClusterDefaultResponse, -): response is FirewallRulesListByMongoClusterDefaultResponse; -export function isUnexpected( - response: - | PrivateEndpointConnectionsListByMongoCluster200Response - | PrivateEndpointConnectionsListByMongoClusterDefaultResponse, -): response is PrivateEndpointConnectionsListByMongoClusterDefaultResponse; -export function isUnexpected( - response: PrivateEndpointConnectionsGet200Response | PrivateEndpointConnectionsGetDefaultResponse, -): response is PrivateEndpointConnectionsGetDefaultResponse; -export function isUnexpected( - response: - | PrivateEndpointConnectionsCreate200Response - | PrivateEndpointConnectionsCreate201Response - | PrivateEndpointConnectionsCreate202Response - | PrivateEndpointConnectionsCreateLogicalResponse - | PrivateEndpointConnectionsCreateDefaultResponse, -): response is PrivateEndpointConnectionsCreateDefaultResponse; -export function isUnexpected( - response: - | PrivateEndpointConnectionsDelete202Response - | PrivateEndpointConnectionsDelete204Response - | PrivateEndpointConnectionsDeleteLogicalResponse - | PrivateEndpointConnectionsDeleteDefaultResponse, -): response is PrivateEndpointConnectionsDeleteDefaultResponse; -export function isUnexpected( - response: - | PrivateLinksListByMongoCluster200Response - | PrivateLinksListByMongoClusterDefaultResponse, -): response is PrivateLinksListByMongoClusterDefaultResponse; -export function isUnexpected( - response: - | OperationsList200Response - | OperationsListDefaultResponse - | MongoClustersGet200Response - | MongoClustersGetDefaultResponse - | MongoClustersCreateOrUpdate200Response - | MongoClustersCreateOrUpdate201Response - | MongoClustersCreateOrUpdateLogicalResponse - | MongoClustersCreateOrUpdateDefaultResponse - | MongoClustersUpdate200Response - | MongoClustersUpdate202Response - | MongoClustersUpdateLogicalResponse - | MongoClustersUpdateDefaultResponse - | MongoClustersDelete202Response - | MongoClustersDelete204Response - | MongoClustersDeleteLogicalResponse - | MongoClustersDeleteDefaultResponse - | MongoClustersListByResourceGroup200Response - | MongoClustersListByResourceGroupDefaultResponse - | MongoClustersList200Response - | MongoClustersListDefaultResponse - | MongoClustersListConnectionStrings200Response - | MongoClustersListConnectionStringsDefaultResponse - | MongoClustersCheckNameAvailability200Response - | MongoClustersCheckNameAvailabilityDefaultResponse - | FirewallRulesGet200Response - | FirewallRulesGetDefaultResponse - | FirewallRulesCreateOrUpdate200Response - | FirewallRulesCreateOrUpdate201Response - | FirewallRulesCreateOrUpdate202Response - | FirewallRulesCreateOrUpdateLogicalResponse - | FirewallRulesCreateOrUpdateDefaultResponse - | FirewallRulesDelete202Response - | FirewallRulesDelete204Response - | FirewallRulesDeleteLogicalResponse - | FirewallRulesDeleteDefaultResponse - | FirewallRulesListByMongoCluster200Response - | FirewallRulesListByMongoClusterDefaultResponse - | PrivateEndpointConnectionsListByMongoCluster200Response - | PrivateEndpointConnectionsListByMongoClusterDefaultResponse - | PrivateEndpointConnectionsGet200Response - | PrivateEndpointConnectionsGetDefaultResponse - | PrivateEndpointConnectionsCreate200Response - | PrivateEndpointConnectionsCreate201Response - | PrivateEndpointConnectionsCreate202Response - | PrivateEndpointConnectionsCreateLogicalResponse - | PrivateEndpointConnectionsCreateDefaultResponse - | PrivateEndpointConnectionsDelete202Response - | PrivateEndpointConnectionsDelete204Response - | PrivateEndpointConnectionsDeleteLogicalResponse - | PrivateEndpointConnectionsDeleteDefaultResponse - | PrivateLinksListByMongoCluster200Response - | PrivateLinksListByMongoClusterDefaultResponse, -): response is - | OperationsListDefaultResponse - | MongoClustersGetDefaultResponse - | MongoClustersCreateOrUpdateDefaultResponse - | MongoClustersUpdateDefaultResponse - | MongoClustersDeleteDefaultResponse - | MongoClustersListByResourceGroupDefaultResponse - | MongoClustersListDefaultResponse - | MongoClustersListConnectionStringsDefaultResponse - | MongoClustersCheckNameAvailabilityDefaultResponse - | FirewallRulesGetDefaultResponse - | FirewallRulesCreateOrUpdateDefaultResponse - | FirewallRulesDeleteDefaultResponse - | FirewallRulesListByMongoClusterDefaultResponse - | PrivateEndpointConnectionsListByMongoClusterDefaultResponse - | PrivateEndpointConnectionsGetDefaultResponse - | PrivateEndpointConnectionsCreateDefaultResponse - | PrivateEndpointConnectionsDeleteDefaultResponse - | PrivateLinksListByMongoClusterDefaultResponse { - const lroOriginal = response.headers["x-ms-original-url"]; - const url = new URL(lroOriginal ?? response.request.url); - const method = response.request.method; - let pathDetails = responseMap[`${method} ${url.pathname}`]; - if (!pathDetails) { - pathDetails = getParametrizedPathSuccess(method, url.pathname); - } - return !pathDetails.includes(response.status); -} - -function getParametrizedPathSuccess(method: string, path: string): string[] { - 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: string[] = []; - - // Iterate the responseMap to find a match - for (const [key, value] of Object.entries(responseMap)) { - // 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/mongocluster/arm-mongocluster/src/rest/models.ts b/sdk/mongocluster/arm-mongocluster/src/rest/models.ts deleted file mode 100644 index 56981ecbf0aa..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/rest/models.ts +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** Represents a mongo cluster resource. */ -export interface MongoCluster extends TrackedResource { - /** The resource-specific properties for this resource. */ - properties?: MongoClusterProperties; -} - -/** The properties of a mongo cluster. */ -export interface MongoClusterProperties { - /** - * The mode to create a mongo cluster. - * - * Possible values: "Default", "PointInTimeRestore" - */ - createMode?: CreateMode; - /** The parameters to create a point-in-time restore mongo cluster. */ - restoreParameters?: MongoClusterRestoreParameters; - /** The administrator's login for the mongo cluster. */ - administratorLogin?: string; - /** The password of the administrator login. */ - administratorLoginPassword?: string; - /** The Mongo DB server version. Defaults to the latest available version if not specified. */ - serverVersion?: string; - /** - * Whether or not public endpoint access is allowed for this mongo cluster. - * - * Possible values: "Enabled", "Disabled" - */ - publicNetworkAccess?: PublicNetworkAccess; - /** The list of node group specs in the cluster. */ - nodeGroupSpecs?: Array; -} - -/** Parameters used for restore operations */ -export interface MongoClusterRestoreParameters { - /** UTC point in time to restore a mongo cluster */ - pointInTimeUTC?: Date | string; - /** Resource ID to locate the source cluster to restore */ - sourceResourceId?: string; -} - -/** Specification for a node group. */ -export interface NodeGroupSpec { - /** The resource sku for the node group. This defines the size of CPU and memory that is provisioned for each node. Example values: 'M30', 'M40'. */ - sku?: string; - /** The disk storage size for the node group in GB. Example values: 128, 256, 512, 1024. */ - diskSizeGB?: number; - /** Whether high availability is enabled on the node group. */ - enableHa?: boolean; - /** - * The node type deployed in the node group. - * - * Possible values: "Shard" - */ - kind?: NodeKind; - /** The number of nodes in the node group. */ - nodeCount?: number; -} - -/** The private endpoint connection resource */ -export interface PrivateEndpointConnection extends Resource { - /** The private endpoint connection properties */ - properties?: PrivateEndpointConnectionProperties; -} - -/** Properties of the private endpoint connection. */ -export interface PrivateEndpointConnectionProperties { - /** The private endpoint resource. */ - privateEndpoint?: PrivateEndpoint; - /** A collection of information about the state of the connection between service consumer and provider. */ - privateLinkServiceConnectionState: PrivateLinkServiceConnectionState; -} - -/** The Private Endpoint resource. */ -export interface PrivateEndpoint {} - -/** A collection of information about the state of the connection between service consumer and provider. */ -export interface PrivateLinkServiceConnectionState { - /** - * Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. - * - * Possible values: "Pending", "Approved", "Rejected" - */ - status?: PrivateEndpointServiceConnectionStatus; - /** The reason for approval/rejection of the connection. */ - description?: string; - /** A message indicating if changes on the service provider require any updates on the consumer. */ - actionsRequired?: string; -} - -/** Common fields that are returned in the response for all Azure Resource Manager resources */ -export interface Resource {} - -/** 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. - * - * Possible values: "User", "Application", "ManagedIdentity", "Key" - */ - createdByType?: CreatedByType; - /** The timestamp of resource creation (UTC). */ - createdAt?: Date | string; - /** The identity that last modified the resource. */ - lastModifiedBy?: string; - /** - * The type of identity that last modified the resource. - * - * Possible values: "User", "Application", "ManagedIdentity", "Key" - */ - lastModifiedByType?: CreatedByType; - /** The timestamp of resource last modification (UTC) */ - lastModifiedAt?: Date | string; -} - -/** 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; -} - -/** The resource model definition containing the full set of allowed properties for a resource. Except properties bag, there cannot be a top level property outside of this set. */ -export interface ResourceModelWithAllowedPropertySet extends TrackedResource { - /** - * The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. - * If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. - */ - managedBy?: string; - /** - * Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. - * If supported, the resource provider must validate and persist this value. - */ - kind?: string; - /** - * The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. - * Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), - * If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. - */ - eTag?: string; - identity?: Identity; - sku?: Sku; - plan?: Plan; -} - -/** Identity for the resource. */ -export interface Identity { - /** The identity type. */ - type?: ResourceIdentityType; -} - -/** The resource model definition representing SKU */ -export interface Sku { - /** The name of the SKU. Ex - P3. It is typically a letter+number code */ - name: string; - /** This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. */ - tier?: SkuTier; - /** The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. */ - size?: string; - /** If the service has different generations of hardware, for the same SKU, then that can be captured here. */ - family?: string; - /** If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. */ - capacity?: number; -} - -/** Plan for the resource. */ -export interface Plan { - /** A user defined name of the 3rd Party Artifact that is being procured. */ - name: string; - /** The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic */ - publisher: string; - /** The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. */ - product: string; - /** A publisher provided promotion code as provisioned in Data Market for the said product/artifact. */ - promotionCode?: string; - /** The version of the desired product/artifact. */ - version?: string; -} - -/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */ -export interface ProxyResource extends Resource {} - -/** Represents a mongo cluster firewall rule. */ -export interface FirewallRule extends ProxyResource { - /** The resource-specific properties for this resource. */ - properties?: FirewallRuleProperties; -} - -/** The properties of a mongo cluster firewall rule. */ -export interface FirewallRuleProperties { - /** The start IP address of the mongo cluster firewall rule. Must be IPv4 format. */ - startIpAddress: string; - /** The end IP address of the mongo cluster firewall rule. Must be IPv4 format. */ - endIpAddress: string; -} - -/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ -export interface PrivateEndpointConnectionResource extends ProxyResource { - /** The resource-specific properties for this resource. */ - properties?: PrivateEndpointConnectionProperties; -} - -/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ -export interface PrivateLinkResource extends ProxyResource { - /** The resource-specific properties for this resource. */ - properties?: PrivateLinkResourceProperties; -} - -/** Properties of a private link resource. */ -export interface PrivateLinkResourceProperties { - /** The private link resource private link DNS zone name. */ - requiredZoneNames?: string[]; -} - -/** The base extension resource. */ -export interface ExtensionResource extends Resource {} - -/** The resource model definition for an Azure Resource Manager resource with an etag. */ -export interface AzureEntityResource extends Resource {} - -/** A private link resource. */ -export interface PrivateLinkResource extends Resource { - /** Resource properties. */ - properties?: PrivateLinkResourceProperties; -} - -/** The type used for update operations of the MongoCluster. */ -export interface MongoClusterUpdate { - /** Resource tags. */ - tags?: Record; - /** The resource-specific properties for this resource. */ - properties?: MongoClusterUpdateProperties; -} - -/** The updatable properties of the MongoCluster. */ -export interface MongoClusterUpdateProperties { - /** The administrator's login for the mongo cluster. */ - administratorLogin?: string; - /** The password of the administrator login. */ - administratorLoginPassword?: string; - /** The Mongo DB server version. Defaults to the latest available version if not specified. */ - serverVersion?: string; - /** - * Whether or not public endpoint access is allowed for this mongo cluster. - * - * Possible values: "Enabled", "Disabled" - */ - publicNetworkAccess?: PublicNetworkAccess; - /** The list of node group specs in the cluster. */ - nodeGroupSpecs?: Array; -} - -/** The check availability request body. */ -export interface CheckNameAvailabilityRequest { - /** The name of the resource for which availability needs to be checked. */ - name?: string; - /** The resource type. */ - type?: string; -} - -/** Alias for CreateMode */ -export type CreateMode = string; -/** Alias for ResourceProvisioningState */ -export type ResourceProvisioningState = string; -/** Alias for ProvisioningState */ -export type ProvisioningState = string; -/** Alias for MongoClusterStatus */ -export type MongoClusterStatus = string; -/** Alias for PublicNetworkAccess */ -export type PublicNetworkAccess = string; -/** Alias for NodeKind */ -export type NodeKind = string; -/** Alias for PrivateEndpointServiceConnectionStatus */ -export type PrivateEndpointServiceConnectionStatus = string; -/** Alias for PrivateEndpointConnectionProvisioningState */ -export type PrivateEndpointConnectionProvisioningState = string; -/** Alias for CreatedByType */ -export type CreatedByType = string; -/** Alias for ResourceIdentityType */ -export type ResourceIdentityType = "SystemAssigned"; -/** Alias for SkuTier */ -export type SkuTier = "Free" | "Basic" | "Standard" | "Premium"; diff --git a/sdk/mongocluster/arm-mongocluster/src/rest/outputModels.ts b/sdk/mongocluster/arm-mongocluster/src/rest/outputModels.ts deleted file mode 100644 index 6d5dd8b08685..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/rest/outputModels.ts +++ /dev/null @@ -1,417 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { Paged } from "@azure/core-paging"; - -/** Details of a REST API operation, returned from the Resource Provider Operations API */ -export interface OperationOutput { - /** The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" */ - readonly name?: string; - /** Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. */ - readonly isDataAction?: boolean; - /** Localized display information for this particular operation. */ - readonly display?: OperationDisplayOutput; - /** - * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" - * - * Possible values: "user", "system", "user,system" - */ - readonly origin?: OriginOutput; - /** - * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - * - * Possible values: "Internal" - */ - actionType?: ActionTypeOutput; -} - -/** Localized display information for and operation. */ -export interface OperationDisplayOutput { - /** The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". */ - readonly provider?: string; - /** The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". */ - readonly resource?: string; - /** The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". */ - readonly operation?: string; - /** The short, localized friendly description of the operation; suitable for tool tips and detailed views. */ - readonly description?: string; -} - -/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. */ -export interface ErrorResponseOutput { - /** The error object. */ - error?: ErrorDetailOutput; -} - -/** The error detail. */ -export interface ErrorDetailOutput { - /** The error code. */ - readonly code?: string; - /** The error message. */ - readonly message?: string; - /** The error target. */ - readonly target?: string; - /** The error details. */ - readonly details?: Array; - /** The error additional info. */ - readonly additionalInfo?: Array; -} - -/** The resource management error additional info. */ -export interface ErrorAdditionalInfoOutput { - /** The additional info type. */ - readonly type?: string; - /** The additional info. */ - readonly info?: Record; -} - -/** Represents a mongo cluster resource. */ -export interface MongoClusterOutput extends TrackedResourceOutput { - /** The resource-specific properties for this resource. */ - properties?: MongoClusterPropertiesOutput; -} - -/** The properties of a mongo cluster. */ -export interface MongoClusterPropertiesOutput { - /** - * The mode to create a mongo cluster. - * - * Possible values: "Default", "PointInTimeRestore" - */ - createMode?: CreateModeOutput; - /** The parameters to create a point-in-time restore mongo cluster. */ - restoreParameters?: MongoClusterRestoreParametersOutput; - /** The administrator's login for the mongo cluster. */ - administratorLogin?: string; - /** The password of the administrator login. */ - administratorLoginPassword?: string; - /** The Mongo DB server version. Defaults to the latest available version if not specified. */ - serverVersion?: string; - /** The default mongo connection string for the cluster. */ - readonly connectionString?: string; - /** Earliest restore timestamp in UTC ISO8601 format. */ - readonly earliestRestoreTime?: string; - /** - * The provisioning state of the mongo cluster. - * - * Possible values: "InProgress", "Updating", "Dropping" - */ - readonly provisioningState?: ProvisioningStateOutput; - /** - * The status of the mongo cluster. - * - * Possible values: "Ready", "Provisioning", "Updating", "Starting", "Stopping", "Stopped", "Dropping" - */ - readonly clusterStatus?: MongoClusterStatusOutput; - /** - * Whether or not public endpoint access is allowed for this mongo cluster. - * - * Possible values: "Enabled", "Disabled" - */ - publicNetworkAccess?: PublicNetworkAccessOutput; - /** The list of node group specs in the cluster. */ - nodeGroupSpecs?: Array; - /** List of private endpoint connections. */ - readonly privateEndpointConnections?: Array; -} - -/** Parameters used for restore operations */ -export interface MongoClusterRestoreParametersOutput { - /** UTC point in time to restore a mongo cluster */ - pointInTimeUTC?: string; - /** Resource ID to locate the source cluster to restore */ - sourceResourceId?: string; -} - -/** Specification for a node group. */ -export interface NodeGroupSpecOutput { - /** The resource sku for the node group. This defines the size of CPU and memory that is provisioned for each node. Example values: 'M30', 'M40'. */ - sku?: string; - /** The disk storage size for the node group in GB. Example values: 128, 256, 512, 1024. */ - diskSizeGB?: number; - /** Whether high availability is enabled on the node group. */ - enableHa?: boolean; - /** - * The node type deployed in the node group. - * - * Possible values: "Shard" - */ - kind?: NodeKindOutput; - /** The number of nodes in the node group. */ - nodeCount?: number; -} - -/** The private endpoint connection resource */ -export interface PrivateEndpointConnectionOutput extends ResourceOutput { - /** The private endpoint connection properties */ - properties?: PrivateEndpointConnectionPropertiesOutput; -} - -/** Properties of the private endpoint connection. */ -export interface PrivateEndpointConnectionPropertiesOutput { - /** The group ids for the private endpoint resource. */ - readonly groupIds?: string[]; - /** The private endpoint resource. */ - privateEndpoint?: PrivateEndpointOutput; - /** A collection of information about the state of the connection between service consumer and provider. */ - privateLinkServiceConnectionState: PrivateLinkServiceConnectionStateOutput; - /** - * The provisioning state of the private endpoint connection resource. - * - * Possible values: "Succeeded", "Creating", "Deleting", "Failed" - */ - readonly provisioningState?: PrivateEndpointConnectionProvisioningStateOutput; -} - -/** The Private Endpoint resource. */ -export interface PrivateEndpointOutput { - /** The resource identifier for private endpoint */ - readonly id?: string; -} - -/** A collection of information about the state of the connection between service consumer and provider. */ -export interface PrivateLinkServiceConnectionStateOutput { - /** - * Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. - * - * Possible values: "Pending", "Approved", "Rejected" - */ - status?: PrivateEndpointServiceConnectionStatusOutput; - /** The reason for approval/rejection of the connection. */ - description?: string; - /** A message indicating if changes on the service provider require any updates on the consumer. */ - actionsRequired?: string; -} - -/** Common fields that are returned in the response for all Azure Resource Manager resources */ -export interface ResourceOutput { - /** 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?: SystemDataOutput; -} - -/** Metadata pertaining to creation and last modification of the resource. */ -export interface SystemDataOutput { - /** The identity that created the resource. */ - createdBy?: string; - /** - * The type of identity that created the resource. - * - * Possible values: "User", "Application", "ManagedIdentity", "Key" - */ - createdByType?: CreatedByTypeOutput; - /** The timestamp of resource creation (UTC). */ - createdAt?: string; - /** The identity that last modified the resource. */ - lastModifiedBy?: string; - /** - * The type of identity that last modified the resource. - * - * Possible values: "User", "Application", "ManagedIdentity", "Key" - */ - lastModifiedByType?: CreatedByTypeOutput; - /** The timestamp of resource last modification (UTC) */ - lastModifiedAt?: string; -} - -/** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ -export interface TrackedResourceOutput extends ResourceOutput { - /** Resource tags. */ - tags?: Record; - /** The geo-location where the resource lives */ - location: string; -} - -/** The resource model definition containing the full set of allowed properties for a resource. Except properties bag, there cannot be a top level property outside of this set. */ -export interface ResourceModelWithAllowedPropertySetOutput extends TrackedResourceOutput { - /** - * The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. - * If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. - */ - managedBy?: string; - /** - * Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. - * If supported, the resource provider must validate and persist this value. - */ - kind?: string; - /** - * The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. - * Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), - * If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. - */ - eTag?: string; - identity?: IdentityOutput; - sku?: SkuOutput; - plan?: PlanOutput; -} - -/** Identity for the resource. */ -export interface IdentityOutput { - /** The principal ID of resource identity. The value must be an UUID. */ - readonly principalId?: string; - /** The tenant ID of resource. The value must be an UUID. */ - readonly tenantId?: string; - /** The identity type. */ - type?: ResourceIdentityTypeOutput; -} - -/** The resource model definition representing SKU */ -export interface SkuOutput { - /** The name of the SKU. Ex - P3. It is typically a letter+number code */ - name: string; - /** This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. */ - tier?: SkuTierOutput; - /** The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. */ - size?: string; - /** If the service has different generations of hardware, for the same SKU, then that can be captured here. */ - family?: string; - /** If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. */ - capacity?: number; -} - -/** Plan for the resource. */ -export interface PlanOutput { - /** A user defined name of the 3rd Party Artifact that is being procured. */ - name: string; - /** The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic */ - publisher: string; - /** The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. */ - product: string; - /** A publisher provided promotion code as provisioned in Data Market for the said product/artifact. */ - promotionCode?: string; - /** The version of the desired product/artifact. */ - version?: string; -} - -/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */ -export interface ProxyResourceOutput extends ResourceOutput {} - -/** Represents a mongo cluster firewall rule. */ -export interface FirewallRuleOutput extends ProxyResourceOutput { - /** The resource-specific properties for this resource. */ - properties?: FirewallRulePropertiesOutput; -} - -/** The properties of a mongo cluster firewall rule. */ -export interface FirewallRulePropertiesOutput { - /** - * The provisioning state of the firewall rule. - * - * Possible values: "InProgress", "Updating", "Dropping" - */ - readonly provisioningState?: ProvisioningStateOutput; - /** The start IP address of the mongo cluster firewall rule. Must be IPv4 format. */ - startIpAddress: string; - /** The end IP address of the mongo cluster firewall rule. Must be IPv4 format. */ - endIpAddress: string; -} - -/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ -export interface PrivateEndpointConnectionResourceOutput extends ProxyResourceOutput { - /** The resource-specific properties for this resource. */ - properties?: PrivateEndpointConnectionPropertiesOutput; -} - -/** Concrete proxy resource types can be created by aliasing this type using a specific property type. */ -export interface PrivateLinkResourceOutput extends ProxyResourceOutput { - /** The resource-specific properties for this resource. */ - properties?: PrivateLinkResourcePropertiesOutput; -} - -/** Properties of a private link resource. */ -export interface PrivateLinkResourcePropertiesOutput { - /** The private link resource group id. */ - readonly groupId?: string; - /** The private link resource required member names. */ - readonly requiredMembers?: string[]; - /** The private link resource private link DNS zone name. */ - requiredZoneNames?: string[]; -} - -/** The base extension resource. */ -export interface ExtensionResourceOutput extends ResourceOutput {} - -/** The resource model definition for an Azure Resource Manager resource with an etag. */ -export interface AzureEntityResourceOutput extends ResourceOutput { - /** Resource Etag. */ - readonly etag?: string; -} - -/** A private link resource. */ -export interface PrivateLinkResourceOutput extends ResourceOutput { - /** Resource properties. */ - properties?: PrivateLinkResourcePropertiesOutput; -} - -/** The connection strings for the given mongo cluster. */ -export interface ListConnectionStringsResultOutput { - /** An array that contains the connection strings for a mongo cluster. */ - readonly connectionStrings?: Array; -} - -/** Connection string for the mongo cluster */ -export interface ConnectionStringOutput { - /** Value of the connection string */ - readonly connectionString?: string; - /** Description of the connection string */ - readonly description?: string; -} - -/** The check availability result. */ -export interface CheckNameAvailabilityResponseOutput { - /** Indicates if the resource name is available. */ - nameAvailable?: boolean; - /** - * The reason why the given name is not available. - * - * Possible values: "Invalid", "AlreadyExists" - */ - reason?: CheckNameAvailabilityReasonOutput; - /** Detailed reason why the given name is not available. */ - message?: string; -} - -/** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */ -export type OperationListResultOutput = Paged; -/** Alias for OriginOutput */ -export type OriginOutput = string; -/** Alias for ActionTypeOutput */ -export type ActionTypeOutput = string; -/** Alias for CreateModeOutput */ -export type CreateModeOutput = string; -/** Alias for ResourceProvisioningStateOutput */ -export type ResourceProvisioningStateOutput = string; -/** Alias for ProvisioningStateOutput */ -export type ProvisioningStateOutput = string; -/** Alias for MongoClusterStatusOutput */ -export type MongoClusterStatusOutput = string; -/** Alias for PublicNetworkAccessOutput */ -export type PublicNetworkAccessOutput = string; -/** Alias for NodeKindOutput */ -export type NodeKindOutput = string; -/** Alias for PrivateEndpointServiceConnectionStatusOutput */ -export type PrivateEndpointServiceConnectionStatusOutput = string; -/** Alias for PrivateEndpointConnectionProvisioningStateOutput */ -export type PrivateEndpointConnectionProvisioningStateOutput = string; -/** Alias for CreatedByTypeOutput */ -export type CreatedByTypeOutput = string; -/** Alias for ResourceIdentityTypeOutput */ -export type ResourceIdentityTypeOutput = "SystemAssigned"; -/** Alias for SkuTierOutput */ -export type SkuTierOutput = "Free" | "Basic" | "Standard" | "Premium"; -/** The response of a MongoCluster list operation. */ -export type MongoClusterListResultOutput = Paged; -/** Alias for CheckNameAvailabilityReasonOutput */ -export type CheckNameAvailabilityReasonOutput = string; -/** The response of a FirewallRule list operation. */ -export type FirewallRuleListResultOutput = Paged; -/** The response of a PrivateEndpointConnectionResource list operation. */ -export type PrivateEndpointConnectionResourceListResultOutput = - Paged; -/** The response of a PrivateLinkResource list operation. */ -export type PrivateLinkResourceListResultOutput = Paged; diff --git a/sdk/mongocluster/arm-mongocluster/src/rest/paginateHelper.ts b/sdk/mongocluster/arm-mongocluster/src/rest/paginateHelper.ts deleted file mode 100644 index e27846d32a90..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/rest/paginateHelper.ts +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from "@azure/core-paging"; -import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; - -/** - * Helper type to extract the type of an array - */ -export type GetArrayType = T extends Array ? TData : never; - -/** - * The type of a custom function that defines how to get a page and a link to the next one if any. - */ -export type GetPage = ( - pageLink: string, - maxPageSize?: number, -) => Promise<{ - page: TPage; - nextPageLink?: string; -}>; - -/** - * Options for the paging helper - */ -export interface PagingOptions { - /** - * Custom function to extract pagination details for crating the PagedAsyncIterableIterator - */ - customGetPage?: GetPage[]>; -} - -/** - * Helper type to infer the Type of the paged elements from the response type - * This type is generated based on the swagger information for x-ms-pageable - * specifically on the itemName property which indicates the property of the response - * where the page items are found. The default value is `value`. - * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter - */ -export type PaginateReturn = TResult extends { - body: { value?: infer TPage }; -} - ? GetArrayType - : Array; - -/** - * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension - * @param client - Client to use for sending the next page requests - * @param initialResponse - Initial response containing the nextLink and current page of elements - * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results - * @returns - PagedAsyncIterableIterator to iterate the elements - */ -export function paginate( - client: Client, - initialResponse: TResponse, - options: PagingOptions = {}, -): PagedAsyncIterableIterator> { - // Extract element type from initial response - type TElement = PaginateReturn; - let firstRun = true; - const itemName = "value"; - const nextLinkName = "nextLink"; - const { customGetPage } = options; - const pagedResult: PagedResult = { - firstPageLink: "", - getPage: - typeof customGetPage === "function" - ? customGetPage - : async (pageLink: string) => { - const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get(); - firstRun = false; - checkPagingRequest(result); - const nextLink = getNextLink(result.body, nextLinkName); - const values = getElements(result.body, itemName); - return { - page: values, - nextPageLink: nextLink, - }; - }, - }; - - return getPagedAsyncIterator(pagedResult); -} - -/** - * 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") { - throw new Error(`Body Property ${nextLinkName} should be a string or 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[]; - - // value has to be an array according to the x-ms-pageable extension. - // The fact that this must be an array is used above to calculate the - // type of elements in the page in PaginateReturn - if (!Array.isArray(value)) { - throw new Error( - `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): void { - const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"]; - if (!Http2xxStatusCodes.includes(response.status)) { - throw createRestError( - `Pagination failed with unexpected statusCode ${response.status}`, - response, - ); - } -} diff --git a/sdk/mongocluster/arm-mongocluster/src/rest/parameters.ts b/sdk/mongocluster/arm-mongocluster/src/rest/parameters.ts deleted file mode 100644 index 5a57ef3d51f5..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/rest/parameters.ts +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { RequestParameters } from "@azure-rest/core-client"; -import { - MongoCluster, - MongoClusterUpdate, - CheckNameAvailabilityRequest, - FirewallRule, - PrivateEndpointConnectionResource, -} from "./models.js"; - -export type OperationsListParameters = RequestParameters; -export type MongoClustersGetParameters = RequestParameters; - -export interface MongoClustersCreateOrUpdateBodyParam { - /** Resource create parameters. */ - body: MongoCluster; -} - -export type MongoClustersCreateOrUpdateParameters = MongoClustersCreateOrUpdateBodyParam & - RequestParameters; - -export interface MongoClustersUpdateBodyParam { - /** The resource properties to be updated. */ - body: MongoClusterUpdate; -} - -export type MongoClustersUpdateParameters = MongoClustersUpdateBodyParam & RequestParameters; -export type MongoClustersDeleteParameters = RequestParameters; -export type MongoClustersListByResourceGroupParameters = RequestParameters; -export type MongoClustersListParameters = RequestParameters; -export type MongoClustersListConnectionStringsParameters = RequestParameters; - -export interface MongoClustersCheckNameAvailabilityBodyParam { - /** The CheckAvailability request */ - body: CheckNameAvailabilityRequest; -} - -export type MongoClustersCheckNameAvailabilityParameters = - MongoClustersCheckNameAvailabilityBodyParam & RequestParameters; -export type FirewallRulesGetParameters = RequestParameters; - -export interface FirewallRulesCreateOrUpdateBodyParam { - /** Resource create parameters. */ - body: FirewallRule; -} - -export type FirewallRulesCreateOrUpdateParameters = FirewallRulesCreateOrUpdateBodyParam & - RequestParameters; -export type FirewallRulesDeleteParameters = RequestParameters; -export type FirewallRulesListByMongoClusterParameters = RequestParameters; -export type PrivateEndpointConnectionsListByMongoClusterParameters = RequestParameters; -export type PrivateEndpointConnectionsGetParameters = RequestParameters; - -export interface PrivateEndpointConnectionsCreateBodyParam { - /** Resource create parameters. */ - body: PrivateEndpointConnectionResource; -} - -export type PrivateEndpointConnectionsCreateParameters = PrivateEndpointConnectionsCreateBodyParam & - RequestParameters; -export type PrivateEndpointConnectionsDeleteParameters = RequestParameters; -export type PrivateLinksListByMongoClusterParameters = RequestParameters; diff --git a/sdk/mongocluster/arm-mongocluster/src/rest/pollingHelper.ts b/sdk/mongocluster/arm-mongocluster/src/rest/pollingHelper.ts deleted file mode 100644 index f292ec20d8cf..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/rest/pollingHelper.ts +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { Client, HttpResponse } from "@azure-rest/core-client"; -import { AbortSignalLike } from "@azure/abort-controller"; -import { - CancelOnProgress, - CreateHttpPollerOptions, - RunningOperation, - OperationResponse, - OperationState, - createHttpPoller, -} from "@azure/core-lro"; -import { - MongoClustersCreateOrUpdate200Response, - MongoClustersCreateOrUpdate201Response, - MongoClustersCreateOrUpdateDefaultResponse, - MongoClustersCreateOrUpdateLogicalResponse, - MongoClustersUpdate200Response, - MongoClustersUpdate202Response, - MongoClustersUpdateDefaultResponse, - MongoClustersUpdateLogicalResponse, - MongoClustersDelete202Response, - MongoClustersDelete204Response, - MongoClustersDeleteDefaultResponse, - MongoClustersDeleteLogicalResponse, - FirewallRulesCreateOrUpdate200Response, - FirewallRulesCreateOrUpdate201Response, - FirewallRulesCreateOrUpdate202Response, - FirewallRulesCreateOrUpdateDefaultResponse, - FirewallRulesCreateOrUpdateLogicalResponse, - FirewallRulesDelete202Response, - FirewallRulesDelete204Response, - FirewallRulesDeleteDefaultResponse, - FirewallRulesDeleteLogicalResponse, - PrivateEndpointConnectionsCreate200Response, - PrivateEndpointConnectionsCreate201Response, - PrivateEndpointConnectionsCreate202Response, - PrivateEndpointConnectionsCreateDefaultResponse, - PrivateEndpointConnectionsCreateLogicalResponse, - PrivateEndpointConnectionsDelete202Response, - PrivateEndpointConnectionsDelete204Response, - PrivateEndpointConnectionsDeleteDefaultResponse, - PrivateEndpointConnectionsDeleteLogicalResponse, -} from "./responses.js"; - -/** - * 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; -} - -/** - * Helper function that builds a Poller object to help polling a long running operation. - * @param client - Client to use for sending the request to get additional pages. - * @param initialResponse - The initial response. - * @param options - Options to set a resume state or custom polling interval. - * @returns - A poller object to poll for operation state updates and eventually get the final response. - */ -export async function getLongRunningPoller< - TResult extends - | MongoClustersCreateOrUpdateLogicalResponse - | MongoClustersCreateOrUpdateDefaultResponse, ->( - client: Client, - initialResponse: - | MongoClustersCreateOrUpdate200Response - | MongoClustersCreateOrUpdate201Response - | MongoClustersCreateOrUpdateDefaultResponse, - options?: CreateHttpPollerOptions>, -): Promise, TResult>>; -export async function getLongRunningPoller< - TResult extends MongoClustersUpdateLogicalResponse | MongoClustersUpdateDefaultResponse, ->( - client: Client, - initialResponse: - | MongoClustersUpdate200Response - | MongoClustersUpdate202Response - | MongoClustersUpdateDefaultResponse, - options?: CreateHttpPollerOptions>, -): Promise, TResult>>; -export async function getLongRunningPoller< - TResult extends MongoClustersDeleteLogicalResponse | MongoClustersDeleteDefaultResponse, ->( - client: Client, - initialResponse: - | MongoClustersDelete202Response - | MongoClustersDelete204Response - | MongoClustersDeleteDefaultResponse, - options?: CreateHttpPollerOptions>, -): Promise, TResult>>; -export async function getLongRunningPoller< - TResult extends - | FirewallRulesCreateOrUpdateLogicalResponse - | FirewallRulesCreateOrUpdateDefaultResponse, ->( - client: Client, - initialResponse: - | FirewallRulesCreateOrUpdate200Response - | FirewallRulesCreateOrUpdate201Response - | FirewallRulesCreateOrUpdate202Response - | FirewallRulesCreateOrUpdateDefaultResponse, - options?: CreateHttpPollerOptions>, -): Promise, TResult>>; -export async function getLongRunningPoller< - TResult extends FirewallRulesDeleteLogicalResponse | FirewallRulesDeleteDefaultResponse, ->( - client: Client, - initialResponse: - | FirewallRulesDelete202Response - | FirewallRulesDelete204Response - | FirewallRulesDeleteDefaultResponse, - options?: CreateHttpPollerOptions>, -): Promise, TResult>>; -export async function getLongRunningPoller< - TResult extends - | PrivateEndpointConnectionsCreateLogicalResponse - | PrivateEndpointConnectionsCreateDefaultResponse, ->( - client: Client, - initialResponse: - | PrivateEndpointConnectionsCreate200Response - | PrivateEndpointConnectionsCreate201Response - | PrivateEndpointConnectionsCreate202Response - | PrivateEndpointConnectionsCreateDefaultResponse, - options?: CreateHttpPollerOptions>, -): Promise, TResult>>; -export async function getLongRunningPoller< - TResult extends - | PrivateEndpointConnectionsDeleteLogicalResponse - | PrivateEndpointConnectionsDeleteDefaultResponse, ->( - client: Client, - initialResponse: - | PrivateEndpointConnectionsDelete202Response - | PrivateEndpointConnectionsDelete204Response - | PrivateEndpointConnectionsDeleteDefaultResponse, - options?: CreateHttpPollerOptions>, -): Promise, TResult>>; -export async function getLongRunningPoller( - client: Client, - initialResponse: TResult, - options: CreateHttpPollerOptions> = {}, -): Promise, TResult>> { - const abortController = new AbortController(); - const poller: RunningOperation = { - sendInitialRequest: async () => { - // In the case of Rest Clients we are building the LRO poller object from a response that's the reason - // we are not triggering the initial request here, just extracting the information from the - // response we were provided. - return getLroResponse(initialResponse); - }, - sendPollRequest: async (path: string, pollOptions?: { abortSignal?: AbortSignalLike }) => { - // This is the callback that is going to be called to poll the service - // to get the latest status. We use the client provided and the polling path - // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location - // depending on the lro pattern that the service implements. If non is provided we default to the initial path. - function abortListener(): void { - abortController.abort(); - } - const inputAbortSignal = pollOptions?.abortSignal; - const abortSignal = abortController.signal; - if (inputAbortSignal?.aborted) { - abortController.abort(); - } else if (!abortSignal.aborted) { - inputAbortSignal?.addEventListener("abort", abortListener, { - once: true, - }); - } - let response; - try { - response = await client - .pathUnchecked(path ?? initialResponse.request.url) - .get({ abortSignal }); - } finally { - inputAbortSignal?.removeEventListener("abort", abortListener); - } - const lroResponse = getLroResponse(response as TResult); - lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url; - return lroResponse; - }, - }; - - options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true; - const httpPoller = createHttpPoller(poller, options); - const simplePoller: SimplePollerLike, TResult> = { - isDone() { - return httpPoller.isDone; - }, - isStopped() { - return abortController.signal.aborted; - }, - getOperationState() { - if (!httpPoller.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 httpPoller.operationState; - }, - getResult() { - return httpPoller.result; - }, - toString() { - if (!httpPoller.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: httpPoller.operationState, - }); - }, - stopPolling() { - abortController.abort(); - }, - onProgress: httpPoller.onProgress, - poll: httpPoller.poll, - pollUntilDone: httpPoller.pollUntilDone, - serialize: httpPoller.serialize, - submitted: httpPoller.submitted, - }; - return simplePoller; -} - -/** - * Converts a Rest Client response to a response that the LRO implementation understands - * @param response - a rest client http response - * @returns - An LRO response that the LRO implementation understands - */ -function getLroResponse( - response: TResult, -): OperationResponse { - if (Number.isNaN(response.status)) { - throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`); - } - - return { - flatResponse: response, - rawResponse: { - ...response, - statusCode: Number.parseInt(response.status), - body: response.body, - }, - }; -} diff --git a/sdk/mongocluster/arm-mongocluster/src/rest/responses.ts b/sdk/mongocluster/arm-mongocluster/src/rest/responses.ts deleted file mode 100644 index 8729c5bc7767..000000000000 --- a/sdk/mongocluster/arm-mongocluster/src/rest/responses.ts +++ /dev/null @@ -1,354 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { RawHttpHeaders } from "@azure/core-rest-pipeline"; -import { HttpResponse } from "@azure-rest/core-client"; -import { - OperationListResultOutput, - ErrorResponseOutput, - MongoClusterOutput, - MongoClusterListResultOutput, - ListConnectionStringsResultOutput, - CheckNameAvailabilityResponseOutput, - FirewallRuleOutput, - FirewallRuleListResultOutput, - PrivateEndpointConnectionResourceListResultOutput, - PrivateEndpointConnectionResourceOutput, - PrivateLinkResourceListResultOutput, -} from "./outputModels.js"; - -/** Azure operation completed successfully. */ -export interface OperationsList200Response extends HttpResponse { - status: "200"; - body: OperationListResultOutput; -} - -export interface OperationsListDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** Azure operation completed successfully. */ -export interface MongoClustersGet200Response extends HttpResponse { - status: "200"; - body: MongoClusterOutput; -} - -export interface MongoClustersGetDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** Resource 'MongoCluster' update operation succeeded */ -export interface MongoClustersCreateOrUpdate200Response extends HttpResponse { - status: "200"; - body: MongoClusterOutput; -} - -export interface MongoClustersCreateOrUpdate201Headers { - /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ - "retry-after"?: number; -} - -/** Resource 'MongoCluster' create operation succeeded */ -export interface MongoClustersCreateOrUpdate201Response extends HttpResponse { - status: "201"; - body: MongoClusterOutput; - headers: RawHttpHeaders & MongoClustersCreateOrUpdate201Headers; -} - -export interface MongoClustersCreateOrUpdateDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** The final response for long-running createOrUpdate operation */ -export interface MongoClustersCreateOrUpdateLogicalResponse extends HttpResponse { - status: "200"; - body: MongoClusterOutput; -} - -/** Azure operation completed successfully. */ -export interface MongoClustersUpdate200Response extends HttpResponse { - status: "200"; - body: MongoClusterOutput; -} - -export interface MongoClustersUpdate202Headers { - /** The Location header contains the URL where the status of the long running operation can be checked. */ - location?: string; - /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ - "retry-after"?: number; -} - -/** Resource update request accepted. */ -export interface MongoClustersUpdate202Response extends HttpResponse { - status: "202"; - headers: RawHttpHeaders & MongoClustersUpdate202Headers; -} - -export interface MongoClustersUpdateDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** The final response for long-running update operation */ -export interface MongoClustersUpdateLogicalResponse extends HttpResponse { - status: "200"; - body: MongoClusterOutput; -} - -export interface MongoClustersDelete202Headers { - /** The Location header contains the URL where the status of the long running operation can be checked. */ - location?: string; - /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ - "retry-after"?: number; -} - -/** Resource deletion accepted. */ -export interface MongoClustersDelete202Response extends HttpResponse { - status: "202"; - headers: RawHttpHeaders & MongoClustersDelete202Headers; -} - -/** Resource does not exist. */ -export interface MongoClustersDelete204Response extends HttpResponse { - status: "204"; -} - -export interface MongoClustersDeleteDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** The final response for long-running delete operation */ -export interface MongoClustersDeleteLogicalResponse extends HttpResponse { - status: "200"; -} - -/** Azure operation completed successfully. */ -export interface MongoClustersListByResourceGroup200Response extends HttpResponse { - status: "200"; - body: MongoClusterListResultOutput; -} - -export interface MongoClustersListByResourceGroupDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** Azure operation completed successfully. */ -export interface MongoClustersList200Response extends HttpResponse { - status: "200"; - body: MongoClusterListResultOutput; -} - -export interface MongoClustersListDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** Azure operation completed successfully. */ -export interface MongoClustersListConnectionStrings200Response extends HttpResponse { - status: "200"; - body: ListConnectionStringsResultOutput; -} - -export interface MongoClustersListConnectionStringsDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** The request has succeeded. */ -export interface MongoClustersCheckNameAvailability200Response extends HttpResponse { - status: "200"; - body: CheckNameAvailabilityResponseOutput; -} - -export interface MongoClustersCheckNameAvailabilityDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** Azure operation completed successfully. */ -export interface FirewallRulesGet200Response extends HttpResponse { - status: "200"; - body: FirewallRuleOutput; -} - -export interface FirewallRulesGetDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** Resource 'FirewallRule' update operation succeeded */ -export interface FirewallRulesCreateOrUpdate200Response extends HttpResponse { - status: "200"; - body: FirewallRuleOutput; -} - -/** Resource 'FirewallRule' create operation succeeded */ -export interface FirewallRulesCreateOrUpdate201Response extends HttpResponse { - status: "201"; - body: FirewallRuleOutput; -} - -export interface FirewallRulesCreateOrUpdate202Headers { - /** The Location header contains the URL where the status of the long running operation can be checked. */ - location?: string; - /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ - "retry-after"?: number; -} - -/** Resource operation accepted. */ -export interface FirewallRulesCreateOrUpdate202Response extends HttpResponse { - status: "202"; - headers: RawHttpHeaders & FirewallRulesCreateOrUpdate202Headers; -} - -export interface FirewallRulesCreateOrUpdateDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** The final response for long-running createOrUpdate operation */ -export interface FirewallRulesCreateOrUpdateLogicalResponse extends HttpResponse { - status: "200"; - body: FirewallRuleOutput; -} - -export interface FirewallRulesDelete202Headers { - /** The Location header contains the URL where the status of the long running operation can be checked. */ - location?: string; - /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ - "retry-after"?: number; -} - -/** Resource deletion accepted. */ -export interface FirewallRulesDelete202Response extends HttpResponse { - status: "202"; - headers: RawHttpHeaders & FirewallRulesDelete202Headers; -} - -/** Resource does not exist. */ -export interface FirewallRulesDelete204Response extends HttpResponse { - status: "204"; -} - -export interface FirewallRulesDeleteDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** The final response for long-running delete operation */ -export interface FirewallRulesDeleteLogicalResponse extends HttpResponse { - status: "200"; -} - -/** Azure operation completed successfully. */ -export interface FirewallRulesListByMongoCluster200Response extends HttpResponse { - status: "200"; - body: FirewallRuleListResultOutput; -} - -export interface FirewallRulesListByMongoClusterDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** Azure operation completed successfully. */ -export interface PrivateEndpointConnectionsListByMongoCluster200Response extends HttpResponse { - status: "200"; - body: PrivateEndpointConnectionResourceListResultOutput; -} - -export interface PrivateEndpointConnectionsListByMongoClusterDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** Azure operation completed successfully. */ -export interface PrivateEndpointConnectionsGet200Response extends HttpResponse { - status: "200"; - body: PrivateEndpointConnectionResourceOutput; -} - -export interface PrivateEndpointConnectionsGetDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** Resource 'PrivateEndpointConnectionResource' update operation succeeded */ -export interface PrivateEndpointConnectionsCreate200Response extends HttpResponse { - status: "200"; - body: PrivateEndpointConnectionResourceOutput; -} - -/** Resource 'PrivateEndpointConnectionResource' create operation succeeded */ -export interface PrivateEndpointConnectionsCreate201Response extends HttpResponse { - status: "201"; - body: PrivateEndpointConnectionResourceOutput; -} - -export interface PrivateEndpointConnectionsCreate202Headers { - /** The Location header contains the URL where the status of the long running operation can be checked. */ - location?: string; - /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ - "retry-after"?: number; -} - -/** Resource operation accepted. */ -export interface PrivateEndpointConnectionsCreate202Response extends HttpResponse { - status: "202"; - headers: RawHttpHeaders & PrivateEndpointConnectionsCreate202Headers; -} - -export interface PrivateEndpointConnectionsCreateDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** The final response for long-running create operation */ -export interface PrivateEndpointConnectionsCreateLogicalResponse extends HttpResponse { - status: "200"; - body: PrivateEndpointConnectionResourceOutput; -} - -export interface PrivateEndpointConnectionsDelete202Headers { - /** The Location header contains the URL where the status of the long running operation can be checked. */ - location?: string; - /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ - "retry-after"?: number; -} - -/** Resource deletion accepted. */ -export interface PrivateEndpointConnectionsDelete202Response extends HttpResponse { - status: "202"; - headers: RawHttpHeaders & PrivateEndpointConnectionsDelete202Headers; -} - -/** Resource does not exist. */ -export interface PrivateEndpointConnectionsDelete204Response extends HttpResponse { - status: "204"; -} - -export interface PrivateEndpointConnectionsDeleteDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} - -/** The final response for long-running delete operation */ -export interface PrivateEndpointConnectionsDeleteLogicalResponse extends HttpResponse { - status: "200"; -} - -/** Azure operation completed successfully. */ -export interface PrivateLinksListByMongoCluster200Response extends HttpResponse { - status: "200"; - body: PrivateLinkResourceListResultOutput; -} - -export interface PrivateLinksListByMongoClusterDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponseOutput; -} diff --git a/sdk/mongocluster/arm-mongocluster/src/restorePollerHelpers.ts b/sdk/mongocluster/arm-mongocluster/src/restorePollerHelpers.ts index f4dcf0ccc9e2..feb90d7aa41b 100644 --- a/sdk/mongocluster/arm-mongocluster/src/restorePollerHelpers.ts +++ b/sdk/mongocluster/arm-mongocluster/src/restorePollerHelpers.ts @@ -1,18 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { - PollerLike, - OperationState, - deserializeState, - ResourceLocationConfig, -} from "@azure/core-lro"; import { MongoClusterManagementClient } from "./mongoClusterManagementClient.js"; -import { getLongRunningPoller } from "./api/pollingHelpers.js"; import { _mongoClustersCreateOrUpdateDeserialize, _mongoClustersUpdateDeserialize, _mongoClustersDeleteDeserialize, + _mongoClustersPromoteDeserialize, } from "./api/mongoClusters/index.js"; import { _firewallRulesCreateOrUpdateDeserialize, @@ -22,8 +16,18 @@ import { _privateEndpointConnectionsCreateDeserialize, _privateEndpointConnectionsDeleteDeserialize, } from "./api/privateEndpointConnections/index.js"; -import { PathUncheckedResponse, OperationOptions } from "@azure-rest/core-client"; +import { getLongRunningPoller } from "./static-helpers/pollingHelpers.js"; +import { + OperationOptions, + PathUncheckedResponse, +} from "@azure-rest/core-client"; import { AbortSignalLike } from "@azure/abort-controller"; +import { + PollerLike, + OperationState, + deserializeState, + ResourceLocationConfig, +} from "@azure/core-lro"; export interface RestorePollerOptions< TResult, @@ -47,7 +51,9 @@ export interface RestorePollerOptions< export function restorePoller( client: MongoClusterManagementClient, serializedState: string, - sourceOperation: (...args: any[]) => PollerLike, TResult>, + sourceOperation: ( + ...args: any[] + ) => PollerLike, TResult>, options?: RestorePollerOptions, ): PollerLike, TResult> { const pollerConfig = deserializeState(serializedState).config; @@ -60,8 +66,9 @@ export function restorePoller( const resourceLocationConfig = metadata?.["resourceLocationConfig"] as | ResourceLocationConfig | undefined; - const deserializeHelper = - options?.processResponseBody ?? getDeserializationHelper(initialRequestUrl, requestMethod); + 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}.`, @@ -70,6 +77,7 @@ export function restorePoller( return getLongRunningPoller( (client as any)["_client"] ?? client, deserializeHelper as (result: TResponse) => Promise, + expectedStatuses, { updateIntervalInMs: options?.updateIntervalInMs, abortSignal: options?.abortSignal, @@ -80,27 +88,58 @@ export function restorePoller( ); } -const deserializeMap: Record = { +interface DeserializationHelper { + deserializer: Function; + expectedStatuses: string[]; +} + +const deserializeMap: Record = { "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}": - _mongoClustersCreateOrUpdateDeserialize, + { + deserializer: _mongoClustersCreateOrUpdateDeserialize, + expectedStatuses: ["200", "201"], + }, "PATCH /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}": - _mongoClustersUpdateDeserialize, + { + deserializer: _mongoClustersUpdateDeserialize, + expectedStatuses: ["200", "202"], + }, "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}": - _mongoClustersDeleteDeserialize, + { + deserializer: _mongoClustersDeleteDeserialize, + expectedStatuses: ["202", "204", "200"], + }, + "POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/promote": + { + deserializer: _mongoClustersPromoteDeserialize, + expectedStatuses: ["202", "200"], + }, "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}": - _firewallRulesCreateOrUpdateDeserialize, + { + deserializer: _firewallRulesCreateOrUpdateDeserialize, + expectedStatuses: ["200", "201", "202"], + }, "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}": - _firewallRulesDeleteDeserialize, + { + deserializer: _firewallRulesDeleteDeserialize, + expectedStatuses: ["202", "204", "200"], + }, "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}": - _privateEndpointConnectionsCreateDeserialize, + { + deserializer: _privateEndpointConnectionsCreateDeserialize, + expectedStatuses: ["200", "201", "202"], + }, "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}": - _privateEndpointConnectionsDeleteDeserialize, + { + deserializer: _privateEndpointConnectionsDeleteDeserialize, + expectedStatuses: ["202", "204", "200"], + }, }; function getDeserializationHelper( urlStr: string, method: string, -): ((result: unknown) => Promise) | undefined { +): DeserializationHelper | undefined { const path = new URL(urlStr).pathname; const pathParts = path.split("/"); @@ -108,7 +147,7 @@ function getDeserializationHelper( // matchedLen: the length of candidate path // matchedValue: the matched status code array let matchedLen = -1, - matchedValue: ((result: unknown) => Promise) | undefined; + matchedValue: DeserializationHelper | undefined; // Iterate the responseMap to find a match for (const [key, value] of Object.entries(deserializeMap)) { @@ -123,17 +162,24 @@ function getDeserializationHelper( // 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) { + 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] || "", - ); + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}`, + ).test(pathParts[j] || ""); if (!isMatched) { found = false; @@ -155,7 +201,7 @@ function getDeserializationHelper( // Update the matched value if and only if we found the longer pattern if (found && candidatePath.length > matchedLen) { matchedLen = candidatePath.length; - matchedValue = value as (result: unknown) => Promise; + matchedValue = value; } } diff --git a/sdk/mongocluster/arm-mongocluster/src/api/pagingHelpers.ts b/sdk/mongocluster/arm-mongocluster/src/static-helpers/pagingHelpers.ts similarity index 61% rename from sdk/mongocluster/arm-mongocluster/src/api/pagingHelpers.ts rename to sdk/mongocluster/arm-mongocluster/src/static-helpers/pagingHelpers.ts index 5342e57b798f..dc35b0af242d 100644 --- a/sdk/mongocluster/arm-mongocluster/src/api/pagingHelpers.ts +++ b/sdk/mongocluster/arm-mongocluster/src/static-helpers/pagingHelpers.ts @@ -1,16 +1,102 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; -import { RestError } from "@azure/core-rest-pipeline"; +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import { - BuildPagedAsyncIteratorOptions, - ContinuablePage, - PageSettings, - PagedAsyncIterableIterator, - PagedResult, -} from "../models/pagingTypes.js"; -import { isUnexpected } from "../rest/index.js"; + Client, + createRestError, + PathUncheckedResponse, +} 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< + TElement, + TPage, + TPageSettings + >; + /** + * 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; +} /** * Helper to paginate results in a generic way and return a PagedAsyncIterableIterator @@ -24,6 +110,7 @@ export function buildPagedAsyncIterator< client: Client, getInitialResponse: () => PromiseLike, processResponseBody: (result: TResponse) => PromiseLike, + expectedStatuses: string[], options: BuildPagedAsyncIteratorOptions = {}, ): PagedAsyncIterableIterator { const itemName = options.itemName ?? "value"; @@ -34,7 +121,7 @@ export function buildPagedAsyncIterator< pageLink === undefined ? await getInitialResponse() : await client.pathUnchecked(pageLink).get(); - checkPagingRequest(result); + checkPagingRequest(result, expectedStatuses); const results = await processResponseBody(result as TResponse); const nextLink = getNextLink(results, nextLinkName); const values = getElements(results, itemName) as TPage; @@ -68,7 +155,9 @@ function getPagedAsyncIterator< >( pagedResult: PagedResult, ): PagedAsyncIterableIterator { - const iter = getItemAsyncIterator(pagedResult); + const iter = getItemAsyncIterator( + pagedResult, + ); return { next() { return iter.next(); @@ -87,7 +176,11 @@ function getPagedAsyncIterator< }; } -async function* getItemAsyncIterator( +async function* getItemAsyncIterator< + TElement, + TPage, + TPageSettings extends PageSettings, +>( pagedResult: PagedResult, ): AsyncIterableIterator { const pages = getPageAsyncIterator(pagedResult); @@ -96,14 +189,20 @@ async function* getItemAsyncIterator( +async function* getPageAsyncIterator< + TElement, + TPage, + TPageSettings extends PageSettings, +>( pagedResult: PagedResult, options: { pageLink?: string; } = {}, ): AsyncIterableIterator> { const { pageLink } = options; - let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); + let response = await pagedResult.getPage( + pageLink ?? pagedResult.firstPageLink, + ); if (!response) { return; } @@ -131,7 +230,11 @@ function getNextLink(body: unknown, nextLinkName?: string): string | undefined { const nextLink = (body as Record)[nextLinkName]; - if (typeof nextLink !== "string" && typeof nextLink !== "undefined" && nextLink !== null) { + 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}`, ); @@ -161,8 +264,11 @@ function getElements(body: unknown, itemName: string): T[] { /** * Checks if a request failed */ -function checkPagingRequest(response: PathUncheckedResponse): void { - if (isUnexpected(response)) { +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/mongocluster/arm-mongocluster/src/api/pollingHelpers.ts b/sdk/mongocluster/arm-mongocluster/src/static-helpers/pollingHelpers.ts similarity index 83% rename from sdk/mongocluster/arm-mongocluster/src/api/pollingHelpers.ts rename to sdk/mongocluster/arm-mongocluster/src/static-helpers/pollingHelpers.ts index bfbeffa13669..87a63b1fc5d1 100644 --- a/sdk/mongocluster/arm-mongocluster/src/api/pollingHelpers.ts +++ b/sdk/mongocluster/arm-mongocluster/src/static-helpers/pollingHelpers.ts @@ -1,6 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import { PollerLike, OperationState, @@ -10,9 +13,12 @@ import { OperationResponse, } from "@azure/core-lro"; -import { Client, PathUncheckedResponse, createRestError } from "@azure-rest/core-client"; +import { + Client, + PathUncheckedResponse, + createRestError, +} from "@azure-rest/core-client"; import { AbortSignalLike } from "@azure/abort-controller"; -import { isUnexpected } from "../rest/index.js"; export interface GetLongRunningPollerOptions { /** Delay to wait until next poll, in milliseconds. */ @@ -39,24 +45,32 @@ export interface GetLongRunningPollerOptions { */ getInitialResponse?: () => PromiseLike; } -export function getLongRunningPoller( +export function getLongRunningPoller< + TResponse extends PathUncheckedResponse, + TResult = void, +>( 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"); + 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"); + throw new Error( + "getInitialResponse is required when initializing a new poller", + ); } initialResponse = await getInitialResponse(); - return getLroResponse(initialResponse); + return getLroResponse(initialResponse, expectedStatuses); }, sendPollRequest: async ( path: string, @@ -88,12 +102,8 @@ export function getLongRunningPoller( response: TResponse, + expectedStatuses: string[], ): OperationResponse { - if (isUnexpected(response as PathUncheckedResponse)) { + if (!expectedStatuses.includes(response.status)) { throw createRestError(response); } + return { flatResponse: response, rawResponse: { diff --git a/sdk/mongocluster/arm-mongocluster/test/public/mongoclusterOperations.spec.ts b/sdk/mongocluster/arm-mongocluster/test/public/mongoclusterOperations.spec.ts deleted file mode 100644 index 0aa1fd5b93c1..000000000000 --- a/sdk/mongocluster/arm-mongocluster/test/public/mongoclusterOperations.spec.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { env, Recorder, isPlaybackMode, delay } from "@azure-tools/test-recorder"; -import { createTestCredential } from "@azure-tools/test-credential"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; -import { MongoClusterManagementClient } from "../../src/mongoClusterManagementClient.js"; -import { createRecorder } from "./utils/recordedClient.js"; - -export const testPollingOptions = { - updateIntervalInMs: isPlaybackMode() ? 0 : undefined, -}; - -describe("MongoCluster test", () => { - let recorder: Recorder; - let subscriptionId: string; - let client: MongoClusterManagementClient; - let location: string; - let resourceGroup: string; - let resourcename: string; - let fireWallName: string; - - beforeEach(async (context) => { - process.env.SystemRoot = process.env.SystemRoot || "C:\\Windows"; - recorder = await createRecorder(context); - subscriptionId = env.SUBSCRIPTION_ID || ""; - // This is an example of how the environment variables are used - const credential = createTestCredential(); - client = new MongoClusterManagementClient( - credential, - subscriptionId, - recorder.configureClientOptions({}), - ); - location = "eastus"; - resourceGroup = "czwjstest"; - resourcename = "testmongocluster"; - fireWallName = "testfilerule"; - }); - - afterEach(async function () { - if (recorder?.recordingId) { - await recorder.stop(); - } - }); - - it("operations list test", async function () { - const resArray = new Array(); - for await (let item of client.operations.list()) { - resArray.push(item); - } - assert.notEqual(resArray.length, 0); - }); - - it("mongoClusters create test", async function () { - const res = await client.mongoClusters.createOrUpdate( - resourceGroup, - resourcename, - { - location, - properties: { - administratorLogin: "mongoAdmin", - administratorLoginPassword: "SecureString;", - nodeGroupSpecs: [ - { - diskSizeGB: 128, - enableHa: true, - kind: "Shard", - nodeCount: 1, - sku: "M30", - }, - ], - serverVersion: "5.0", - }, - }, - testPollingOptions, - ); - assert.equal(res.name, resourcename); - }); - - it("firerules create test", async function () { - const res = await client.firewallRules.createOrUpdate( - resourceGroup, - resourcename, - fireWallName, - { - properties: { - startIpAddress: "0.0.0.0", - endIpAddress: "255.255.255.255", - }, - }, - testPollingOptions, - ); - console.log(res); - assert.equal(res.name, fireWallName); - }); - - it("mongoClusters get test", async function () { - const res = await client.mongoClusters.get(resourceGroup, resourcename); - assert.equal(res.name, resourcename); - }); - - it("firerules get test", async function () { - const res = await client.firewallRules.get(resourceGroup, resourcename, fireWallName); - console.log(res); - assert.equal(res.name, fireWallName); - }); - - it("mongoClusters list test", async function () { - const resArray = new Array(); - for await (let item of client.mongoClusters.listByResourceGroup(resourceGroup)) { - resArray.push(item); - } - assert.equal(resArray.length, 1); - }); - - it("firewallRules list test", async function () { - const resArray = new Array(); - for await (let item of client.firewallRules.listByMongoCluster(resourceGroup, resourcename)) { - resArray.push(item); - } - assert.equal(resArray.length, 1); - }); - - it("mongoClusters update test", async function () { - const res = await client.mongoClusters.update(resourceGroup, resourcename, { - tags: {}, - }); - assert.equal(res.name, resourcename); - }); - - it("firewallRules delete test", async function () { - const resArray = new Array(); - const res = await client.firewallRules.delete(resourceGroup, resourcename, fireWallName); - for await (let item of client.firewallRules.listByMongoCluster(resourceGroup, resourcename)) { - resArray.push(item); - } - assert.equal(resArray.length, 0); - }); - - it("mongoClusters delete test", async function () { - const resArray = new Array(); - const res = await client.mongoClusters.delete(resourceGroup, resourcename); - for await (let item of client.mongoClusters.listByResourceGroup(resourceGroup)) { - resArray.push(item); - } - assert.equal(resArray.length, 0); - - await delay(isPlaybackMode() ? 1000 : 60000); - }); -}); diff --git a/sdk/mongocluster/arm-mongocluster/test/public/node/privateEndpointConnections.spec.ts b/sdk/mongocluster/arm-mongocluster/test/public/node/privateEndpointConnections.spec.ts deleted file mode 100644 index f3cc7c321ed4..000000000000 --- a/sdk/mongocluster/arm-mongocluster/test/public/node/privateEndpointConnections.spec.ts +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { env, Recorder, isPlaybackMode, delay } from "@azure-tools/test-recorder"; -import { createTestCredential } from "@azure-tools/test-credential"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; -import { MongoClusterManagementClient } from "../../../src/mongoClusterManagementClient.js"; -import { createRecorder } from "../utils/recordedClient.js"; -import { NetworkManagementClient } from "@azure/arm-network"; - -export const testPollingOptions = { - updateIntervalInMs: isPlaybackMode() ? 0 : undefined, -}; - -describe("MongoCluster test", () => { - let recorder: Recorder; - let subscriptionId: string; - let client: MongoClusterManagementClient; - let networkClient: NetworkManagementClient; - let location: string; - let resourceGroup: string; - let resourcename: string; - let connectionName: string; - let virtualNetworkName: string; - let privateEndpointName: string; - - beforeEach(async (context) => { - process.env.SystemRoot = process.env.SystemRoot || "C:\\Windows"; - recorder = await createRecorder(context); - subscriptionId = env.SUBSCRIPTION_ID || ""; - // This is an example of how the environment variables are used - const credential = createTestCredential(); - client = new MongoClusterManagementClient( - credential, - subscriptionId, - recorder.configureClientOptions({}), - ); - networkClient = new NetworkManagementClient( - credential, - subscriptionId, - recorder.configureClientOptions({}), - ); - location = "eastus"; - resourceGroup = "myjstest"; - resourcename = "resourcetest1"; - virtualNetworkName = "testvn"; - privateEndpointName = "testPEC"; - }); - - afterEach(async function () { - if (recorder?.recordingId) { - await recorder.stop(); - } - }); - - it("mongoClusters for private endpoint create test", async function () { - const res = await client.mongoClusters.createOrUpdate( - resourceGroup, - resourcename, - { - location, - properties: { - administratorLogin: "mongoAdmin", - administratorLoginPassword: "SecureString;", - nodeGroupSpecs: [ - { - diskSizeGB: 128, - enableHa: true, - kind: "Shard", - nodeCount: 1, - sku: "M30", - }, - ], - serverVersion: "5.0", - }, - }, - testPollingOptions, - ); - assert.equal(res.name, resourcename); - }); - - it("virtual network create test", async function () { - const res = await networkClient.virtualNetworks.beginCreateOrUpdateAndWait( - resourceGroup, - virtualNetworkName, - { - addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, - flowTimeoutInMinutes: 10, - location, - }, - ); - assert.equal(res.name, virtualNetworkName); - - const result = await networkClient.subnets.beginCreateOrUpdateAndWait( - resourceGroup, - virtualNetworkName, - "testsubnet", - { addressPrefix: "10.0.0.0/16" }, - ); - }); - - it("private endpoit create test", async function () { - const clusterRes = await client.mongoClusters.get(resourceGroup, resourcename); - const res = await networkClient.privateEndpoints.beginCreateOrUpdateAndWait( - resourceGroup, - privateEndpointName, - { - location, - customNetworkInterfaceName: privateEndpointName + "-nic", - privateLinkServiceConnections: [ - { - name: privateEndpointName, - groupIds: ["MongoCluster"], - privateLinkServiceId: clusterRes.id, - requestMessage: "Please approve my connection.", - }, - ], - subnet: { - id: - "/subscriptions/" + - subscriptionId + - "/resourceGroups/" + - resourceGroup + - "/providers/Microsoft.Network/virtualNetworks/" + - virtualNetworkName + - "/subnets/testsubnet", - }, - }, - testPollingOptions, - ); - assert.equal(res.name, privateEndpointName); - }); - - // need create a mongocluster first then create a private endpoint named testPEC with the mongocluster. - it("private endpoint connection create test", async function () { - for await (let item of client.privateEndpointConnections.listByMongoCluster( - resourceGroup, - resourcename, - )) { - connectionName = String(item.name); - } - const res = await client.privateEndpointConnections.create( - resourceGroup, - resourcename, - connectionName, - { - properties: { - privateLinkServiceConnectionState: { - status: "Rejected", - }, - }, - }, - testPollingOptions, - ); - console.log(res); - assert.equal(res.name, connectionName); - }); - - it("private endpoint connection get test", async function () { - const res = await client.privateEndpointConnections.get( - resourceGroup, - resourcename, - connectionName, - ); - console.log(res); - assert.equal(res.name, connectionName); - }); - it("private endpoint connection list test", async function () { - const resArray = new Array(); - for await (let item of client.privateEndpointConnections.listByMongoCluster( - resourceGroup, - resourcename, - )) { - resArray.push(item); - } - assert.equal(resArray.length, 1); - }); - - it("private endpoint connection delete test", async function () { - for await (let item of client.privateEndpointConnections.listByMongoCluster( - resourceGroup, - resourcename, - )) { - connectionName = String(item.name); - } - const resArray = new Array(); - const res = await client.privateEndpointConnections.delete( - resourceGroup, - resourcename, - connectionName, - ); - for await (let item of client.privateEndpointConnections.listByMongoCluster( - resourceGroup, - resourcename, - )) { - resArray.push(item); - } - assert.equal(resArray.length, 0); - }); - - it("private endpoint delete test", async function () { - const resArray = new Array(); - const res = await networkClient.privateEndpoints.beginDeleteAndWait( - resourceGroup, - privateEndpointName, - ); - for await (let item of networkClient.privateEndpoints.list(resourceGroup)) { - resArray.push(item); - } - assert.equal(resArray.length, 0); - }); - - it("virtual network delete test", async function () { - const resArray = new Array(); - const res = await networkClient.virtualNetworks.beginDeleteAndWait( - resourceGroup, - virtualNetworkName, - ); - for await (let item of networkClient.virtualNetworks.list(resourceGroup)) { - resArray.push(item); - } - assert.equal(resArray.length, 0); - }); - - it("mongoClusters for private endpoint delete test", async function () { - const resArray = new Array(); - const res = await client.mongoClusters.delete(resourceGroup, resourcename); - for await (let item of client.mongoClusters.listByResourceGroup(resourceGroup)) { - resArray.push(item); - } - assert.equal(resArray.length, 0); - - await delay(isPlaybackMode() ? 1000 : 60000); - }); -}); diff --git a/sdk/mongocluster/arm-mongocluster/test/public/sampleTest.spec.ts b/sdk/mongocluster/arm-mongocluster/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..d4919ac91ac5 --- /dev/null +++ b/sdk/mongocluster/arm-mongocluster/test/public/sampleTest.spec.ts @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createRecorder } from "./utils/recordedClient.js"; +import { assert, beforeEach, afterEach, it, describe } from "vitest"; + +describe("My test", () => { + // let recorder: Recorder; + + beforeEach(async function () { + // recorder = await createRecorder(this); + }); + + afterEach(async function () { + // await recorder.stop(); + }); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/mongocluster/arm-mongocluster/test/public/utils/recordedClient.ts b/sdk/mongocluster/arm-mongocluster/test/public/utils/recordedClient.ts index 527ccc9dee86..6e425fdcfdf9 100644 --- a/sdk/mongocluster/arm-mongocluster/test/public/utils/recordedClient.ts +++ b/sdk/mongocluster/arm-mongocluster/test/public/utils/recordedClient.ts @@ -1,7 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Recorder, RecorderStartOptions, VitestTestContext } from "@azure-tools/test-recorder"; +import { + Recorder, + RecorderStartOptions, + VitestTestContext, +} from "@azure-tools/test-recorder"; const replaceableVariables: Record = { SUBSCRIPTION_ID: "azure_subscription_id", @@ -9,10 +13,6 @@ const replaceableVariables: Record = { const recorderEnvSetup: 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 - ], }; /** @@ -20,7 +20,9 @@ const recorderEnvSetup: RecorderStartOptions = { * 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 { +export async function createRecorder( + context: VitestTestContext, +): Promise { const recorder = new Recorder(context); await recorder.start(recorderEnvSetup); return recorder; diff --git a/sdk/mongocluster/arm-mongocluster/tsconfig.json b/sdk/mongocluster/arm-mongocluster/tsconfig.json index a10f22a54c88..8c962911295c 100644 --- a/sdk/mongocluster/arm-mongocluster/tsconfig.json +++ b/sdk/mongocluster/arm-mongocluster/tsconfig.json @@ -3,7 +3,14 @@ "compilerOptions": { "module": "NodeNext", "moduleResolution": "NodeNext", - "rootDir": "." + "rootDir": ".", + "skipLibCheck": true }, - "include": ["./src/**/*.ts", "./src/**/*.mts", "./src/**/*.cts", "test/**/*.ts", "./test/**/*.ts"] + "include": [ + "./src/**/*.ts", + "./src/**/*.mts", + "./src/**/*.cts", + "test/**/*.ts", + "./test/**/*.ts" + ] } diff --git a/sdk/mongocluster/arm-mongocluster/tsp-location.yaml b/sdk/mongocluster/arm-mongocluster/tsp-location.yaml index ede05df0bd18..80d55ec7d66a 100644 --- a/sdk/mongocluster/arm-mongocluster/tsp-location.yaml +++ b/sdk/mongocluster/arm-mongocluster/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/mongocluster/DocumentDB.MongoCluster.Management -commit: abad0096677005817d2c19df2364663e5583c8fc +commit: 3ed4104d8ec3348ea20526aaeb11afd8c557ed1b repo: ../azure-rest-api-specs -additionalDirectories: +additionalDirectories: diff --git a/sdk/mongocluster/ci.mgmt.yml b/sdk/mongocluster/ci.mgmt.yml index 9b07c486fba5..9e2f2c4642f2 100644 --- a/sdk/mongocluster/ci.mgmt.yml +++ b/sdk/mongocluster/ci.mgmt.yml @@ -1,5 +1,5 @@ # NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. - + trigger: branches: include: @@ -13,7 +13,6 @@ trigger: include: - sdk/mongocluster/arm-mongocluster - sdk/mongocluster/ci.mgmt.yml - pr: branches: include: @@ -27,7 +26,6 @@ pr: include: - sdk/mongocluster/arm-mongocluster - sdk/mongocluster/ci.mgmt.yml - extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: @@ -35,4 +33,3 @@ extends: Artifacts: - name: azure-arm-mongocluster safeName: azurearmmongocluster - \ No newline at end of file