diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fc7d4e856d72..e42a08d9e397 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9149,15 +9149,21 @@ importers: sdk/databoundaries/arm-databoundaries: dependencies: + '@azure-rest/core-client': + specifier: ^2.3.1 + version: link:../../core/core-client-rest '@azure/core-auth': specifier: ^1.9.0 version: link:../../core/core-auth - '@azure/core-client': - specifier: ^1.9.2 - version: link:../../core/core-client '@azure/core-rest-pipeline': - specifier: ^1.18.2 + specifier: ^1.20.0 version: link:../../core/core-rest-pipeline + '@azure/core-util': + specifier: ^1.12.0 + version: link:../../core/core-util + '@azure/logger': + specifier: ^1.2.0 + version: link:../../core/logger tslib: specifier: ^2.8.1 version: 2.8.1 @@ -9174,12 +9180,12 @@ importers: '@azure/dev-tool': specifier: workspace:^ version: link:../../../common/tools/dev-tool + '@azure/eslint-plugin-azure-sdk': + specifier: workspace:^ + version: link:../../../common/tools/eslint-plugin-azure-sdk '@azure/identity': specifier: catalog:internal version: 4.13.0 - '@azure/logger': - specifier: ^1.1.4 - version: link:../../core/logger '@types/node': specifier: 'catalog:' version: 20.19.37 @@ -9195,9 +9201,15 @@ importers: dotenv: specifier: catalog:testing version: 16.6.1 + eslint: + specifier: 'catalog:' + version: 9.39.4 playwright: specifier: catalog:testing version: 1.58.2 + prettier: + specifier: 'catalog:' + version: 3.8.1 rimraf: specifier: 'catalog:' version: 6.1.3 diff --git a/sdk/databoundaries/arm-databoundaries/CHANGELOG.md b/sdk/databoundaries/arm-databoundaries/CHANGELOG.md index df91ce64ec5a..0555080e161d 100644 --- a/sdk/databoundaries/arm-databoundaries/CHANGELOG.md +++ b/sdk/databoundaries/arm-databoundaries/CHANGELOG.md @@ -1,23 +1,7 @@ # Release History - -## 1.0.0-beta.3 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - -## 1.0.0-beta.2 (2025-08-22) - -### Other Changes - - - Other fixes - -## 1.0.0-beta.1 (2024-10-25) + +## 1.0.0 (2026-03-25) ### Features Added -The package of @azure/arm-databoundaries is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/js/mgmt/quickstart). +This is the first stable version with the package of @azure/arm-databoundaries diff --git a/sdk/databoundaries/arm-databoundaries/LICENSE b/sdk/databoundaries/arm-databoundaries/LICENSE index b2f52a2bad4e..63447fd8bbbf 100644 --- a/sdk/databoundaries/arm-databoundaries/LICENSE +++ b/sdk/databoundaries/arm-databoundaries/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/sdk/databoundaries/arm-databoundaries/README.md b/sdk/databoundaries/arm-databoundaries/README.md index ace8a27c81d4..2e0787eac897 100644 --- a/sdk/databoundaries/arm-databoundaries/README.md +++ b/sdk/databoundaries/arm-databoundaries/README.md @@ -4,10 +4,12 @@ This package contains an isomorphic SDK (runs both in Node.js and in browsers) f Provides APIs for data boundary operations. -[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databoundaries/arm-databoundaries) | -[Package (NPM)](https://www.npmjs.com/package/@azure/arm-databoundaries) | -[API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-databoundaries?view=azure-node-preview) | -[Samples](https://github.com/Azure-Samples/azure-samples-js-management) +Key links: + +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databoundaries/arm-databoundaries) +- [Package (NPM)](https://www.npmjs.com/package/@azure/arm-databoundaries) +- [API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-databoundaries) +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databoundaries/arm-databoundaries/samples) ## Getting started @@ -35,7 +37,7 @@ npm install @azure/arm-databoundaries To create a client object to access the Azure DataboundariesManegement API, you will need the `endpoint` of your Azure DataboundariesManegement resource and a `credential`. The Azure DataboundariesManegement client can use Azure Active Directory credentials to authenticate. You can find the endpoint for your Azure DataboundariesManegement resource in the [Azure Portal][azure_portal]. -You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). +You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: @@ -44,7 +46,6 @@ npm install @azure/identity ``` You will also need to **register a new AAD application and grant access to Azure DataboundariesManegement** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). -Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. For more information about how to create an Azure AD Application check out [this guide](https://learn.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). @@ -70,8 +71,8 @@ const credential = new InteractiveBrowserCredential({ const client = new DataboundariesManegementClient(credential); ``` -### JavaScript Bundle +### JavaScript Bundle To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). ## Key concepts @@ -96,7 +97,7 @@ For more detailed instructions on how to enable logs, you can look at the [@azur ## Next steps -Please take a look at the [samples](https://github.com/Azure-Samples/azure-samples-js-management) directory for detailed examples on how to use this library. +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databoundaries/arm-databoundaries/samples) directory for detailed examples on how to use this library. ## Contributing @@ -106,10 +107,6 @@ If you'd like to contribute to this library, please read the [contributing guide - [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) - - -[azure_cli]: https://learn.microsoft.com/cli/azure -[azure_sub]: https://azure.microsoft.com/free/ [azure_sub]: https://azure.microsoft.com/free/ [azure_portal]: https://portal.azure.com [azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity diff --git a/sdk/databoundaries/arm-databoundaries/_meta.json b/sdk/databoundaries/arm-databoundaries/_meta.json deleted file mode 100644 index ded7b86c8a32..000000000000 --- a/sdk/databoundaries/arm-databoundaries/_meta.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "commit": "bc3aa2bbc4494553649019585c3bc8a4229a25d0", - "readme": "specification/resources/resource-manager/readme.md", - "autorest_command": "autorest --version=3.9.7 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.27 --generate-sample=true", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.7.15", - "use": "@autorest/typescript@6.0.27" -} diff --git a/sdk/databoundaries/arm-databoundaries/api-extractor.json b/sdk/databoundaries/arm-databoundaries/api-extractor.json index 16d81e2eb512..870d6d399477 100644 --- a/sdk/databoundaries/arm-databoundaries/api-extractor.json +++ b/sdk/databoundaries/arm-databoundaries/api-extractor.json @@ -1,3 +1 @@ -{ - "extends": "../../../api-extractor-base.json" -} +{ "extends": "../../../api-extractor-base.json" } diff --git a/sdk/databoundaries/arm-databoundaries/eslint.config.mjs b/sdk/databoundaries/arm-databoundaries/eslint.config.mjs new file mode 100644 index 000000000000..6d2f8a5914c3 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/eslint.config.mjs @@ -0,0 +1,14 @@ +import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; + +export default azsdkEslint.config([ + { + rules: { + "@azure/azure-sdk/ts-modules-only-named": "warn", + "@azure/azure-sdk/ts-package-json-types": "warn", + "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", + "@azure/azure-sdk/ts-package-json-files-required": "off", + "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", + "tsdoc/syntax": "warn", + }, + }, +]); diff --git a/sdk/databoundaries/arm-databoundaries/metadata.json b/sdk/databoundaries/arm-databoundaries/metadata.json new file mode 100644 index 000000000000..a518e204166a --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/metadata.json @@ -0,0 +1,33 @@ +{ + "apiVersions": { + "Microsoft.Resources": "2024-08-01" + }, + "emitterVersion": "0.51.0", + "crossLanguageDefinitions": { + "CrossLanguagePackageId": "Microsoft.Resources", + "CrossLanguageDefinitionId": { + "@azure/arm-databoundaries!OperationListResult:interface": "Azure.ResourceManager.CommonTypes.OperationListResult", + "@azure/arm-databoundaries!Operation:interface": "Azure.ResourceManager.CommonTypes.Operation", + "@azure/arm-databoundaries!OperationDisplay:interface": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "@azure/arm-databoundaries!ErrorResponse:interface": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "@azure/arm-databoundaries!ErrorDetail:interface": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "@azure/arm-databoundaries!ErrorAdditionalInfo:interface": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "@azure/arm-databoundaries!DataBoundaryDefinition:interface": "Microsoft.Resources.DataBoundaryDefinition", + "@azure/arm-databoundaries!DataBoundaryProperties:interface": "Microsoft.Resources.DataBoundaryProperties", + "@azure/arm-databoundaries!ProxyResource:interface": "Azure.ResourceManager.CommonTypes.ProxyResource", + "@azure/arm-databoundaries!Resource:interface": "Azure.ResourceManager.CommonTypes.Resource", + "@azure/arm-databoundaries!SystemData:interface": "Azure.ResourceManager.CommonTypes.SystemData", + "@azure/arm-databoundaries!KnownOrigin:enum": "Azure.ResourceManager.CommonTypes.Origin", + "@azure/arm-databoundaries!KnownActionType:enum": "Azure.ResourceManager.CommonTypes.ActionType", + "@azure/arm-databoundaries!KnownDefaultName:enum": "Microsoft.Resources.DefaultName", + "@azure/arm-databoundaries!KnownDataBoundary:enum": "Microsoft.Resources.DataBoundary", + "@azure/arm-databoundaries!KnownProvisioningState:enum": "Microsoft.Resources.ProvisioningState", + "@azure/arm-databoundaries!KnowncreatedByType:enum": "Azure.ResourceManager.CommonTypes.createdByType", + "@azure/arm-databoundaries!KnownVersions:enum": "Microsoft.Resources.Versions", + "@azure/arm-databoundaries!DataBoundariesOperations#put:member": "Microsoft.Resources.DataBoundaryDefinitions.put", + "@azure/arm-databoundaries!DataBoundariesOperations#getTenant:member": "Microsoft.Resources.DataBoundaryDefinitions.getTenant", + "@azure/arm-databoundaries!DataBoundariesOperations#getScope:member": "Microsoft.Resources.DataBoundaries.getScope", + "@azure/arm-databoundaries!OperationsOperations#list:member": "Azure.ResourceManager.Operations.list" + } + } +} diff --git a/sdk/databoundaries/arm-databoundaries/package.json b/sdk/databoundaries/arm-databoundaries/package.json index fa513415fa53..ca0ac1d4fd4d 100644 --- a/sdk/databoundaries/arm-databoundaries/package.json +++ b/sdk/databoundaries/arm-databoundaries/package.json @@ -1,114 +1,193 @@ { "name": "@azure/arm-databoundaries", - "sdk-type": "mgmt", - "author": "Microsoft Corporation", + "version": "1.0.0", "description": "A generated SDK for DataboundariesManegementClient.", - "version": "1.0.0-beta.3", "engines": { "node": ">=20.0.0" }, - "dependencies": { - "@azure/core-auth": "^1.9.0", - "@azure/core-client": "^1.9.2", - "@azure/core-rest-pipeline": "^1.18.2", - "tslib": "^2.8.1" + "sideEffects": false, + "autoPublish": false, + "type": "module", + "main": "./dist/commonjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/commonjs/index.d.ts", + "browser": "./dist/browser/index.js", + "react-native": "./dist/react-native/index.js", + "exports": { + "./package.json": "./package.json", + ".": { + "browser": { + "types": "./dist/browser/index.d.ts", + "default": "./dist/browser/index.js" + }, + "react-native": { + "types": "./dist/react-native/index.d.ts", + "default": "./dist/react-native/index.js" + }, + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + }, + "./api": { + "browser": { + "types": "./dist/browser/api/index.d.ts", + "default": "./dist/browser/api/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/index.d.ts", + "default": "./dist/react-native/api/index.js" + }, + "import": { + "types": "./dist/esm/api/index.d.ts", + "default": "./dist/esm/api/index.js" + }, + "require": { + "types": "./dist/commonjs/api/index.d.ts", + "default": "./dist/commonjs/api/index.js" + } + }, + "./api/dataBoundaries": { + "browser": { + "types": "./dist/browser/api/dataBoundaries/index.d.ts", + "default": "./dist/browser/api/dataBoundaries/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/dataBoundaries/index.d.ts", + "default": "./dist/react-native/api/dataBoundaries/index.js" + }, + "import": { + "types": "./dist/esm/api/dataBoundaries/index.d.ts", + "default": "./dist/esm/api/dataBoundaries/index.js" + }, + "require": { + "types": "./dist/commonjs/api/dataBoundaries/index.d.ts", + "default": "./dist/commonjs/api/dataBoundaries/index.js" + } + }, + "./api/operations": { + "browser": { + "types": "./dist/browser/api/operations/index.d.ts", + "default": "./dist/browser/api/operations/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/operations/index.d.ts", + "default": "./dist/react-native/api/operations/index.js" + }, + "import": { + "types": "./dist/esm/api/operations/index.d.ts", + "default": "./dist/esm/api/operations/index.js" + }, + "require": { + "types": "./dist/commonjs/api/operations/index.d.ts", + "default": "./dist/commonjs/api/operations/index.js" + } + }, + "./models": { + "browser": { + "types": "./dist/browser/models/index.d.ts", + "default": "./dist/browser/models/index.js" + }, + "react-native": { + "types": "./dist/react-native/models/index.d.ts", + "default": "./dist/react-native/models/index.js" + }, + "import": { + "types": "./dist/esm/models/index.d.ts", + "default": "./dist/esm/models/index.js" + }, + "require": { + "types": "./dist/commonjs/models/index.d.ts", + "default": "./dist/commonjs/models/index.js" + } + } }, "keywords": [ "node", "azure", + "cloud", "typescript", "browser", - "isomorphic", - "cloud" + "isomorphic" ], + "author": "Microsoft Corporation", "license": "MIT", - "main": "./dist/commonjs/index.js", - "module": "./dist/esm/index.js", - "types": "./dist/commonjs/index.d.ts", + "files": [ + "dist/", + "!dist/**/*.d.*ts.map", + "README.md", + "LICENSE" + ], + "sdk-type": "mgmt", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databoundaries/arm-databoundaries/README.md", + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "//metadata": { + "constantPaths": [ + { + "path": "src/api/databoundariesManegementContext.ts", + "prefix": "userAgentInfo" + } + ] + }, + "dependencies": { + "@azure/core-util": "^1.12.0", + "@azure-rest/core-client": "^2.3.1", + "@azure/core-auth": "^1.9.0", + "@azure/core-rest-pipeline": "^1.20.0", + "@azure/logger": "^1.2.0", + "tslib": "^2.8.1" + }, "devDependencies": { "@azure-tools/test-credential": "workspace:^", "@azure-tools/test-recorder": "workspace:^", "@azure-tools/test-utils-vitest": "workspace:^", "@azure/dev-tool": "workspace:^", + "@azure/eslint-plugin-azure-sdk": "workspace:^", "@azure/identity": "catalog:internal", - "@azure/logger": "^1.1.4", "@types/node": "catalog:", + "cross-env": "catalog:", + "eslint": "catalog:", + "prettier": "catalog:", + "rimraf": "catalog:", "@vitest/browser-playwright": "catalog:testing", "@vitest/coverage-istanbul": "catalog:testing", - "cross-env": "catalog:", "dotenv": "catalog:testing", "playwright": "catalog:testing", - "rimraf": "catalog:", "typescript": "catalog:", "vitest": "catalog:testing" }, - "repository": "github:Azure/azure-sdk-for-js", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "files": [ - "dist/", - "README.md", - "LICENSE", - "review/", - "CHANGELOG.md" - ], "scripts": { - "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", - "build:samples": "tsc -p tsconfig.samples.json && dev-tool samples publish -f", - "check-format": "echo skipped", "clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", - "execute:samples": "echo skipped", - "extract-api": "dev-tool run extract-api", - "format": "echo skipped", - "lint": "echo skipped", + "extract-api": "rimraf review && dev-tool run extract-api", "pack": "pnpm pack 2>&1", + "lint": "echo skipped", + "lint:fix": "echo skipped", + "build:samples": "tsc -p tsconfig.samples.json && dev-tool samples publish -f", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "execute:samples": "dev-tool samples run samples-dev", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "generate:client": "echo skipped", + "test:browser": "dev-tool run build-test && dev-tool run test:vitest --browser", + "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", + "test:node": "dev-tool run test:vitest", + "test:node:esm": "dev-tool run test:vitest --esm", "test": "npm run test:node && npm run test:browser", - "test:browser": "echo skipped", - "test:node": "dev-tool run build-test --no-browser-test && dev-tool run test:vitest", "update-snippets": "dev-tool run update-snippets" }, - "sideEffects": false, - "//metadata": { - "constantPaths": [ - { - "path": "src/databoundariesManegementClient.ts", - "prefix": "packageDetails" - } - ] - }, - "autoPublish": true, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databoundaries/arm-databoundaries", "//sampleConfiguration": { - "productName": "", + "productName": "@azure/arm-databoundaries", "productSlugs": [ "azure" ], "disableDocsMs": true, "apiRefLink": "https://learn.microsoft.com/javascript/api/@azure/arm-databoundaries?view=azure-node-preview" - }, - "type": "module", - "browser": "./dist/browser/index.js", - "react-native": "./dist/react-native/index.js", - "exports": { - "./package.json": "./package.json", - ".": { - "browser": { - "types": "./dist/browser/index.d.ts", - "default": "./dist/browser/index.js" - }, - "react-native": { - "types": "./dist/react-native/index.d.ts", - "default": "./dist/react-native/index.js" - }, - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/commonjs/index.d.ts", - "default": "./dist/commonjs/index.js" - } - } } } diff --git a/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-api-dataBoundaries-node.api.md b/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-api-dataBoundaries-node.api.md new file mode 100644 index 000000000000..a2d0d5101216 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-api-dataBoundaries-node.api.md @@ -0,0 +1,33 @@ +## API Report File for "@azure/arm-databoundaries" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export interface DataBoundariesGetScopeOptionalParams extends OperationOptions { +} + +// @public +export interface DataBoundariesGetTenantOptionalParams extends OperationOptions { +} + +// @public +export interface DataBoundariesPutOptionalParams extends OperationOptions { +} + +// @public +export function getScope(context: DataboundariesManegementContext, scope: string, defaultParam: DefaultName, options?: DataBoundariesGetScopeOptionalParams): Promise; + +// @public +export function getTenant(context: DataboundariesManegementContext, defaultParam: DefaultName, options?: DataBoundariesGetTenantOptionalParams): Promise; + +// @public +export function put(context: DataboundariesManegementContext, defaultParam: DefaultName, dataBoundaryDefinition: DataBoundaryDefinition, options?: DataBoundariesPutOptionalParams): Promise; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-api-node.api.md b/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-api-node.api.md new file mode 100644 index 000000000000..8c32b16bfcc3 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-api-node.api.md @@ -0,0 +1,27 @@ +## API Report File for "@azure/arm-databoundaries" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { ClientOptions } from '@azure-rest/core-client'; +import type { TokenCredential } from '@azure/core-auth'; + +// @public +export function createDataboundariesManegement(credential: TokenCredential, options?: DataboundariesManegementClientOptionalParams): DataboundariesManegementContext; + +// @public +export interface DataboundariesManegementClientOptionalParams extends ClientOptions { + apiVersion?: string; + cloudSetting?: AzureSupportedClouds; +} + +// @public +export interface DataboundariesManegementContext extends Client { + apiVersion?: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-api-operations-node.api.md b/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-api-operations-node.api.md new file mode 100644 index 000000000000..89e97195ebeb --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-api-operations-node.api.md @@ -0,0 +1,19 @@ +## API Report File for "@azure/arm-databoundaries" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { Client } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; + +// @public +export function list(context: DataboundariesManegementContext, options?: OperationsListOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface OperationsListOptionalParams extends OperationOptions { +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-models-node.api.md b/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-models-node.api.md new file mode 100644 index 000000000000..04c4cf3dd2c8 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-models-node.api.md @@ -0,0 +1,145 @@ +## API Report File for "@azure/arm-databoundaries" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +// @public +export type ActionType = string; + +// @public +export type CreatedByType = string; + +// @public +export type DataBoundary = string; + +// @public +export interface DataBoundaryDefinition extends ProxyResource { + properties?: DataBoundaryProperties; +} + +// @public +export interface DataBoundaryProperties { + dataBoundary?: DataBoundary; + readonly provisioningState?: ProvisioningState; +} + +// @public +export type DefaultName = string; + +// @public +export interface ErrorAdditionalInfo { + readonly info?: any; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export enum KnownActionType { + Internal = "Internal" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownDataBoundary { + EU = "EU", + Global = "Global", + NotDefined = "NotDefined" +} + +// @public +export enum KnownDefaultName { + Default = "default" +} + +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + +// @public +export enum KnownProvisioningState { + Accepted = "Accepted", + Canceled = "Canceled", + Creating = "Creating", + Failed = "Failed", + Running = "Running", + Succeeded = "Succeeded", + Updating = "Updating" +} + +// @public +export enum KnownVersions { + V20240801 = "2024-08-01" +} + +// @public +export interface Operation { + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; +} + +// @public +export interface OperationDisplay { + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; +} + +// @public +export type Origin = string; + +// @public +export type ProvisioningState = string; + +// @public +export interface ProxyResource extends Resource { +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-node.api.md b/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-node.api.md index d23a5c8294e3..2b0097b72699 100644 --- a/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-node.api.md +++ b/sdk/databoundaries/arm-databoundaries/review/arm-databoundaries-node.api.md @@ -4,57 +4,64 @@ ```ts -import * as coreAuth from '@azure/core-auth'; -import * as coreClient from '@azure/core-client'; +import type { ClientOptions } from '@azure-rest/core-client'; +import type { OperationOptions } from '@azure-rest/core-client'; +import type { Pipeline } from '@azure/core-rest-pipeline'; +import type { TokenCredential } from '@azure/core-auth'; // @public -export type CreatedByType = string; +export type ActionType = string; // @public -export interface DataBoundaries { - getScope(scope: string, defaultParam: DefaultName, options?: DataBoundariesGetScopeOptionalParams): Promise; - getTenant(defaultParam: DefaultName, options?: DataBoundariesGetTenantOptionalParams): Promise; - put(defaultParam: DefaultName, dataBoundaryDefinition: DataBoundaryDefinition, options?: DataBoundariesPutOptionalParams): Promise; +export enum AzureClouds { + AZURE_CHINA_CLOUD = "AZURE_CHINA_CLOUD", + AZURE_PUBLIC_CLOUD = "AZURE_PUBLIC_CLOUD", + AZURE_US_GOVERNMENT = "AZURE_US_GOVERNMENT" } // @public -export interface DataBoundariesGetScopeOptionalParams extends coreClient.OperationOptions { -} +export type AzureSupportedClouds = `${AzureClouds}`; // @public -export type DataBoundariesGetScopeResponse = DataBoundaryDefinition; +export type ContinuablePage = TPage & { + continuationToken?: string; +}; + +// @public +export type CreatedByType = string; // @public -export interface DataBoundariesGetTenantOptionalParams extends coreClient.OperationOptions { +export interface DataBoundariesGetScopeOptionalParams extends OperationOptions { } // @public -export type DataBoundariesGetTenantResponse = DataBoundaryDefinition; +export interface DataBoundariesGetTenantOptionalParams extends OperationOptions { +} // @public (undocumented) -export class DataboundariesManegementClient extends coreClient.ServiceClient { - // (undocumented) - $host: string; - constructor(credentials: coreAuth.TokenCredential, options?: DataboundariesManegementClientOptionalParams); - // (undocumented) - apiVersion: string; - // (undocumented) - dataBoundaries: DataBoundaries; +export class DataboundariesManegementClient { + constructor(credential: TokenCredential, options?: DataboundariesManegementClientOptionalParams); + readonly dataBoundaries: DataBoundariesOperations; + readonly operations: OperationsOperations; + readonly pipeline: Pipeline; } // @public -export interface DataboundariesManegementClientOptionalParams extends coreClient.ServiceClientOptions { - $host?: string; +export interface DataboundariesManegementClientOptionalParams extends ClientOptions { apiVersion?: string; - endpoint?: string; + cloudSetting?: AzureSupportedClouds; } // @public -export interface DataBoundariesPutOptionalParams extends coreClient.OperationOptions { +export interface DataBoundariesOperations { + getScope: (scope: string, defaultParam: DefaultName, options?: DataBoundariesGetScopeOptionalParams) => Promise; + getTenant: (defaultParam: DefaultName, options?: DataBoundariesGetTenantOptionalParams) => Promise; + put: (defaultParam: DefaultName, dataBoundaryDefinition: DataBoundaryDefinition, options?: DataBoundariesPutOptionalParams) => Promise; } // @public -export type DataBoundariesPutResponse = DataBoundaryDefinition; +export interface DataBoundariesPutOptionalParams extends OperationOptions { +} // @public export type DataBoundary = string; @@ -75,7 +82,7 @@ export type DefaultName = string; // @public export interface ErrorAdditionalInfo { - readonly info?: Record; + readonly info?: any; readonly type?: string; } @@ -93,6 +100,11 @@ export interface ErrorResponse { error?: ErrorDetail; } +// @public +export enum KnownActionType { + Internal = "Internal" +} + // @public export enum KnownCreatedByType { Application = "Application", @@ -113,6 +125,13 @@ export enum KnownDefaultName { Default = "default" } +// @public +export enum KnownOrigin { + System = "system", + User = "user", + UserSystem = "user,system" +} + // @public export enum KnownProvisioningState { Accepted = "Accepted", @@ -124,6 +143,52 @@ export enum KnownProvisioningState { Updating = "Updating" } +// @public +export enum KnownVersions { + V20240801 = "2024-08-01" +} + +// @public +export interface Operation { + readonly actionType?: ActionType; + display?: OperationDisplay; + readonly isDataAction?: boolean; + readonly name?: string; + readonly origin?: Origin; +} + +// @public +export interface OperationDisplay { + readonly description?: string; + readonly operation?: string; + readonly provider?: string; + readonly resource?: string; +} + +// @public +export interface OperationsListOptionalParams extends OperationOptions { +} + +// @public +export interface OperationsOperations { + list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; +} + +// @public +export type Origin = string; + +// @public +export interface PagedAsyncIterableIterator { + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; + next(): Promise>; +} + +// @public +export interface PageSettings { + continuationToken?: string; +} + // @public export type ProvisioningState = string; diff --git a/sdk/databoundaries/arm-databoundaries/sample.env b/sdk/databoundaries/arm-databoundaries/sample.env index efbc7787bd3b..508439fc7d62 100644 --- a/sdk/databoundaries/arm-databoundaries/sample.env +++ b/sdk/databoundaries/arm-databoundaries/sample.env @@ -1 +1 @@ -# Feel free to add your own environment variables. +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesGetScopeSample.ts b/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesGetScopeSample.ts index c916d22786e4..b67da9db4073 100644 --- a/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesGetScopeSample.ts +++ b/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesGetScopeSample.ts @@ -1,24 +1,22 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to Get data boundary at specified scope - * - * @summary Get data boundary at specified scope - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetScopedDataBoundary.json - */ - import { DataboundariesManegementClient } from "@azure/arm-databoundaries"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to get data boundary at specified scope + * + * @summary get data boundary at specified scope + * x-ms-original-file: 2024-08-01/GetScopedDataBoundary.json + */ async function getDataBoundaryAtScope(): Promise { - const scope = - "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group"; - const defaultParam = "default"; const credential = new DefaultAzureCredential(); const client = new DataboundariesManegementClient(credential); - const result = await client.dataBoundaries.getScope(scope, defaultParam); + const result = await client.dataBoundaries.getScope( + "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group", + "default", + ); console.log(result); } diff --git a/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesGetTenantSample.ts b/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesGetTenantSample.ts index d85729db4201..3cab43964e15 100644 --- a/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesGetTenantSample.ts +++ b/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesGetTenantSample.ts @@ -1,22 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to Get data boundary of tenant. - * - * @summary Get data boundary of tenant. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetTenantDataBoundary.json - */ - import { DataboundariesManegementClient } from "@azure/arm-databoundaries"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to get data boundary of tenant. + * + * @summary get data boundary of tenant. + * x-ms-original-file: 2024-08-01/GetTenantDataBoundary.json + */ async function getDataBoundaryForTenant(): Promise { - const defaultParam = "default"; const credential = new DefaultAzureCredential(); const client = new DataboundariesManegementClient(credential); - const result = await client.dataBoundaries.getTenant(defaultParam); + const result = await client.dataBoundaries.getTenant("default"); console.log(result); } diff --git a/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesPutSample.ts b/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesPutSample.ts index 283eb0d060cf..18c57797db2e 100644 --- a/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesPutSample.ts +++ b/sdk/databoundaries/arm-databoundaries/samples-dev/dataBoundariesPutSample.ts @@ -1,26 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** - * This sample demonstrates how to Opt-in tenant to data boundary. - * - * @summary Opt-in tenant to data boundary. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/PutDataBoundary.json - */ - -import type { DataBoundaryDefinition } from "@azure/arm-databoundaries"; import { DataboundariesManegementClient } from "@azure/arm-databoundaries"; import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; +/** + * This sample demonstrates how to opt-in tenant to data boundary. + * + * @summary opt-in tenant to data boundary. + * x-ms-original-file: 2024-08-01/PutDataBoundary.json + */ async function optInToDataBoundary(): Promise { - const defaultParam = "default"; - const dataBoundaryDefinition: DataBoundaryDefinition = { - properties: { dataBoundary: "EU" }, - }; const credential = new DefaultAzureCredential(); const client = new DataboundariesManegementClient(credential); - const result = await client.dataBoundaries.put(defaultParam, dataBoundaryDefinition); + const result = await client.dataBoundaries.put("default", { properties: { dataBoundary: "EU" } }); console.log(result); } diff --git a/sdk/databoundaries/arm-databoundaries/samples-dev/operationsListSample.ts b/sdk/databoundaries/arm-databoundaries/samples-dev/operationsListSample.ts new file mode 100644 index 000000000000..aad479cd80bd --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples-dev/operationsListSample.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DataboundariesManegementClient } from "@azure/arm-databoundaries"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2024-08-01/Operations_List.json + */ +async function operationList(): Promise { + const credential = new DefaultAzureCredential(); + const client = new DataboundariesManegementClient(credential); + const resArray = new Array(); + for await (const item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await operationList(); +} + +main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesGetScopeSample.js b/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesGetScopeSample.js deleted file mode 100644 index bdffbf320788..000000000000 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesGetScopeSample.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { DataboundariesManegementClient } = require("@azure/arm-databoundaries"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Get data boundary at specified scope - * - * @summary Get data boundary at specified scope - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetScopedDataBoundary.json - */ -async function getDataBoundaryAtScope() { - const scope = - "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group"; - const defaultParam = "default"; - const credential = new DefaultAzureCredential(); - const client = new DataboundariesManegementClient(credential); - const result = await client.dataBoundaries.getScope(scope, defaultParam); - console.log(result); -} - -async function main() { - getDataBoundaryAtScope(); -} - -main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesGetTenantSample.js b/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesGetTenantSample.js deleted file mode 100644 index 0d0a8d84c1a1..000000000000 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesGetTenantSample.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { DataboundariesManegementClient } = require("@azure/arm-databoundaries"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Get data boundary of tenant. - * - * @summary Get data boundary of tenant. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetTenantDataBoundary.json - */ -async function getDataBoundaryForTenant() { - const defaultParam = "default"; - const credential = new DefaultAzureCredential(); - const client = new DataboundariesManegementClient(credential); - const result = await client.dataBoundaries.getTenant(defaultParam); - console.log(result); -} - -async function main() { - getDataBoundaryForTenant(); -} - -main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesPutSample.js b/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesPutSample.js deleted file mode 100644 index 5039de951b27..000000000000 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesPutSample.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { DataboundariesManegementClient } = require("@azure/arm-databoundaries"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Opt-in tenant to data boundary. - * - * @summary Opt-in tenant to data boundary. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/PutDataBoundary.json - */ -async function optInToDataBoundary() { - const defaultParam = "default"; - const dataBoundaryDefinition = { - properties: { dataBoundary: "EU" }, - }; - const credential = new DefaultAzureCredential(); - const client = new DataboundariesManegementClient(credential); - const result = await client.dataBoundaries.put(defaultParam, dataBoundaryDefinition); - console.log(result); -} - -async function main() { - optInToDataBoundary(); -} - -main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/sample.env b/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/sample.env deleted file mode 100644 index 672847a3fea0..000000000000 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/sample.env +++ /dev/null @@ -1,4 +0,0 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/sample.env b/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/sample.env deleted file mode 100644 index 672847a3fea0..000000000000 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/sample.env +++ /dev/null @@ -1,4 +0,0 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesGetScopeSample.ts b/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesGetScopeSample.ts deleted file mode 100644 index b70a9366459d..000000000000 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesGetScopeSample.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -import { DataboundariesManegementClient } from "@azure/arm-databoundaries"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Get data boundary at specified scope - * - * @summary Get data boundary at specified scope - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetScopedDataBoundary.json - */ -async function getDataBoundaryAtScope(): Promise { - const scope = - "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group"; - const defaultParam = "default"; - const credential = new DefaultAzureCredential(); - const client = new DataboundariesManegementClient(credential); - const result = await client.dataBoundaries.getScope(scope, defaultParam); - console.log(result); -} - -async function main(): Promise { - getDataBoundaryAtScope(); -} - -main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesGetTenantSample.ts b/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesGetTenantSample.ts deleted file mode 100644 index 424898c0e303..000000000000 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesGetTenantSample.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -import { DataboundariesManegementClient } from "@azure/arm-databoundaries"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Get data boundary of tenant. - * - * @summary Get data boundary of tenant. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetTenantDataBoundary.json - */ -async function getDataBoundaryForTenant(): Promise { - const defaultParam = "default"; - const credential = new DefaultAzureCredential(); - const client = new DataboundariesManegementClient(credential); - const result = await client.dataBoundaries.getTenant(defaultParam); - console.log(result); -} - -async function main(): Promise { - getDataBoundaryForTenant(); -} - -main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesPutSample.ts b/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesPutSample.ts deleted file mode 100644 index c3d849a0a906..000000000000 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesPutSample.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -import { - DataBoundaryDefinition, - DataboundariesManegementClient, -} from "@azure/arm-databoundaries"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Opt-in tenant to data boundary. - * - * @summary Opt-in tenant to data boundary. - * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/PutDataBoundary.json - */ -async function optInToDataBoundary(): Promise { - const defaultParam = "default"; - const dataBoundaryDefinition: DataBoundaryDefinition = { - properties: { dataBoundary: "EU" }, - }; - const credential = new DefaultAzureCredential(); - const client = new DataboundariesManegementClient(credential); - const result = await client.dataBoundaries.put( - defaultParam, - dataBoundaryDefinition, - ); - console.log(result); -} - -async function main(): Promise { - optInToDataBoundary(); -} - -main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/tsconfig.json b/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/tsconfig.json deleted file mode 100644 index 984eed535aa8..000000000000 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "module": "commonjs", - "moduleResolution": "node", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "alwaysStrict": true, - "outDir": "dist", - "rootDir": "src" - }, - "include": [ - "src/**/*.ts" - ] -} diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/README.md b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/README.md similarity index 65% rename from sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/README.md rename to sdk/databoundaries/arm-databoundaries/samples/v1/javascript/README.md index dfc1f40761dc..fe6978045f67 100644 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/README.md +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/README.md @@ -1,12 +1,13 @@ -# client library samples for JavaScript (Beta) +# @azure/arm-databoundaries client library samples for JavaScript -These sample programs show how to use the JavaScript client libraries for in some common scenarios. +These sample programs show how to use the JavaScript client libraries for @azure/arm-databoundaries in some common scenarios. -| **File Name** | **Description** | -| ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [dataBoundariesGetScopeSample.js][databoundariesgetscopesample] | Get data boundary at specified scope x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetScopedDataBoundary.json | -| [dataBoundariesGetTenantSample.js][databoundariesgettenantsample] | Get data boundary of tenant. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetTenantDataBoundary.json | -| [dataBoundariesPutSample.js][databoundariesputsample] | Opt-in tenant to data boundary. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/PutDataBoundary.json | +| **File Name** | **Description** | +| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| [dataBoundariesGetScopeSample.js][databoundariesgetscopesample] | get data boundary at specified scope x-ms-original-file: 2024-08-01/GetScopedDataBoundary.json | +| [dataBoundariesGetTenantSample.js][databoundariesgettenantsample] | get data boundary of tenant. x-ms-original-file: 2024-08-01/GetTenantDataBoundary.json | +| [dataBoundariesPutSample.js][databoundariesputsample] | opt-in tenant to data boundary. x-ms-original-file: 2024-08-01/PutDataBoundary.json | +| [operationsListSample.js][operationslistsample] | list the operations for the provider x-ms-original-file: 2024-08-01/Operations_List.json | ## Prerequisites @@ -36,19 +37,20 @@ npm install node dataBoundariesGetScopeSample.js ``` -Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): +Alternatively, run a single sample with the required environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): ```bash -cross-env node dataBoundariesGetScopeSample.js +node dataBoundariesGetScopeSample.js ``` ## Next Steps Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. -[databoundariesgetscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesGetScopeSample.js -[databoundariesgettenantsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesGetTenantSample.js -[databoundariesputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/dataBoundariesPutSample.js +[databoundariesgetscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesGetScopeSample.js +[databoundariesgettenantsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesGetTenantSample.js +[databoundariesputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesPutSample.js +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/operationsListSample.js [apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-databoundaries?view=azure-node-preview [freesub]: https://azure.microsoft.com/free/ [package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databoundaries/arm-databoundaries/README.md diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesGetScopeSample.js b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesGetScopeSample.js new file mode 100644 index 000000000000..5ab3e455db9c --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesGetScopeSample.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DataboundariesManegementClient } = require("@azure/arm-databoundaries"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get data boundary at specified scope + * + * @summary get data boundary at specified scope + * x-ms-original-file: 2024-08-01/GetScopedDataBoundary.json + */ +async function getDataBoundaryAtScope() { + const credential = new DefaultAzureCredential(); + const client = new DataboundariesManegementClient(credential); + const result = await client.dataBoundaries.getScope( + "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group", + "default", + ); + console.log(result); +} + +async function main() { + await getDataBoundaryAtScope(); +} + +main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesGetTenantSample.js b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesGetTenantSample.js new file mode 100644 index 000000000000..922628574348 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesGetTenantSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DataboundariesManegementClient } = require("@azure/arm-databoundaries"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get data boundary of tenant. + * + * @summary get data boundary of tenant. + * x-ms-original-file: 2024-08-01/GetTenantDataBoundary.json + */ +async function getDataBoundaryForTenant() { + const credential = new DefaultAzureCredential(); + const client = new DataboundariesManegementClient(credential); + const result = await client.dataBoundaries.getTenant("default"); + console.log(result); +} + +async function main() { + await getDataBoundaryForTenant(); +} + +main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesPutSample.js b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesPutSample.js new file mode 100644 index 000000000000..97de843078df --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/dataBoundariesPutSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DataboundariesManegementClient } = require("@azure/arm-databoundaries"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to opt-in tenant to data boundary. + * + * @summary opt-in tenant to data boundary. + * x-ms-original-file: 2024-08-01/PutDataBoundary.json + */ +async function optInToDataBoundary() { + const credential = new DefaultAzureCredential(); + const client = new DataboundariesManegementClient(credential); + const result = await client.dataBoundaries.put("default", { properties: { dataBoundary: "EU" } }); + console.log(result); +} + +async function main() { + await optInToDataBoundary(); +} + +main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/operationsListSample.js b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/operationsListSample.js new file mode 100644 index 000000000000..39c776788503 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/operationsListSample.js @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { DataboundariesManegementClient } = require("@azure/arm-databoundaries"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2024-08-01/Operations_List.json + */ +async function operationList() { + const credential = new DefaultAzureCredential(); + const client = new DataboundariesManegementClient(credential); + const resArray = new Array(); + for await (const item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await operationList(); +} + +main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/package.json b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/package.json similarity index 69% rename from sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/package.json rename to sdk/databoundaries/arm-databoundaries/samples/v1/javascript/package.json index 79983f1d1680..7504388d5b8a 100644 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/javascript/package.json +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/package.json @@ -1,8 +1,8 @@ { - "name": "@azure-samples/arm-databoundaries-js-beta", + "name": "@azure-samples/arm-databoundaries-js", "private": true, "version": "1.0.0", - "description": " client library samples for JavaScript (Beta)", + "description": "@azure/arm-databoundaries client library samples for JavaScript", "engines": { "node": ">=20.0.0" }, @@ -14,6 +14,7 @@ "keywords": [ "node", "azure", + "cloud", "typescript", "browser", "isomorphic" @@ -25,8 +26,11 @@ }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databoundaries/arm-databoundaries", "dependencies": { - "@azure/arm-databoundaries": "next", + "@azure/arm-databoundaries": "latest", "dotenv": "latest", - "@azure/identity": "^4.2.1" + "@azure/identity": "^4.13.0" + }, + "devDependencies": { + "cross-env": "latest" } } diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/sample.env b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/javascript/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/README.md b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/README.md similarity index 68% rename from sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/README.md rename to sdk/databoundaries/arm-databoundaries/samples/v1/typescript/README.md index 3f68a1655480..aa24495f0cf7 100644 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/README.md +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/README.md @@ -1,12 +1,13 @@ -# client library samples for TypeScript (Beta) +# @azure/arm-databoundaries client library samples for TypeScript -These sample programs show how to use the TypeScript client libraries for in some common scenarios. +These sample programs show how to use the TypeScript client libraries for @azure/arm-databoundaries in some common scenarios. -| **File Name** | **Description** | -| ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [dataBoundariesGetScopeSample.ts][databoundariesgetscopesample] | Get data boundary at specified scope x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetScopedDataBoundary.json | -| [dataBoundariesGetTenantSample.ts][databoundariesgettenantsample] | Get data boundary of tenant. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetTenantDataBoundary.json | -| [dataBoundariesPutSample.ts][databoundariesputsample] | Opt-in tenant to data boundary. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/PutDataBoundary.json | +| **File Name** | **Description** | +| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| [dataBoundariesGetScopeSample.ts][databoundariesgetscopesample] | get data boundary at specified scope x-ms-original-file: 2024-08-01/GetScopedDataBoundary.json | +| [dataBoundariesGetTenantSample.ts][databoundariesgettenantsample] | get data boundary of tenant. x-ms-original-file: 2024-08-01/GetTenantDataBoundary.json | +| [dataBoundariesPutSample.ts][databoundariesputsample] | opt-in tenant to data boundary. x-ms-original-file: 2024-08-01/PutDataBoundary.json | +| [operationsListSample.ts][operationslistsample] | list the operations for the provider x-ms-original-file: 2024-08-01/Operations_List.json | ## Prerequisites @@ -48,19 +49,20 @@ npm run build node dist/dataBoundariesGetScopeSample.js ``` -Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): +Alternatively, run a single sample with the required environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): ```bash -cross-env node dist/dataBoundariesGetScopeSample.js +node dist/dataBoundariesGetScopeSample.js ``` ## Next Steps Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. -[databoundariesgetscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesGetScopeSample.ts -[databoundariesgettenantsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesGetTenantSample.ts -[databoundariesputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/src/dataBoundariesPutSample.ts +[databoundariesgetscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesGetScopeSample.ts +[databoundariesgettenantsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesGetTenantSample.ts +[databoundariesputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesPutSample.ts +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/operationsListSample.ts [apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-databoundaries?view=azure-node-preview [freesub]: https://azure.microsoft.com/free/ [package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databoundaries/arm-databoundaries/README.md diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/package.json b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/package.json similarity index 71% rename from sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/package.json rename to sdk/databoundaries/arm-databoundaries/samples/v1/typescript/package.json index c25e4f5d60c8..d76192084473 100644 --- a/sdk/databoundaries/arm-databoundaries/samples/v1-beta/typescript/package.json +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/package.json @@ -1,8 +1,8 @@ { - "name": "@azure-samples/arm-databoundaries-ts-beta", + "name": "@azure-samples/arm-databoundaries-ts", "private": true, "version": "1.0.0", - "description": " client library samples for TypeScript (Beta)", + "description": "@azure/arm-databoundaries client library samples for TypeScript", "engines": { "node": ">=20.0.0" }, @@ -18,6 +18,7 @@ "keywords": [ "node", "azure", + "cloud", "typescript", "browser", "isomorphic" @@ -29,13 +30,14 @@ }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/databoundaries/arm-databoundaries", "dependencies": { - "@azure/arm-databoundaries": "next", + "@azure/arm-databoundaries": "latest", "dotenv": "latest", - "@azure/identity": "^4.2.1" + "@azure/identity": "^4.13.0" }, "devDependencies": { "@types/node": "^20.0.0", - "typescript": "~5.8.2", - "rimraf": "latest" + "cross-env": "latest", + "rimraf": "latest", + "typescript": "~5.9.3" } } diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/sample.env b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/sample.env new file mode 100644 index 000000000000..508439fc7d62 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/sample.env @@ -0,0 +1 @@ +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesGetScopeSample.ts b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesGetScopeSample.ts new file mode 100644 index 000000000000..b67da9db4073 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesGetScopeSample.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DataboundariesManegementClient } from "@azure/arm-databoundaries"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get data boundary at specified scope + * + * @summary get data boundary at specified scope + * x-ms-original-file: 2024-08-01/GetScopedDataBoundary.json + */ +async function getDataBoundaryAtScope(): Promise { + const credential = new DefaultAzureCredential(); + const client = new DataboundariesManegementClient(credential); + const result = await client.dataBoundaries.getScope( + "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group", + "default", + ); + console.log(result); +} + +async function main(): Promise { + await getDataBoundaryAtScope(); +} + +main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesGetTenantSample.ts b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesGetTenantSample.ts new file mode 100644 index 000000000000..3cab43964e15 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesGetTenantSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DataboundariesManegementClient } from "@azure/arm-databoundaries"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get data boundary of tenant. + * + * @summary get data boundary of tenant. + * x-ms-original-file: 2024-08-01/GetTenantDataBoundary.json + */ +async function getDataBoundaryForTenant(): Promise { + const credential = new DefaultAzureCredential(); + const client = new DataboundariesManegementClient(credential); + const result = await client.dataBoundaries.getTenant("default"); + console.log(result); +} + +async function main(): Promise { + await getDataBoundaryForTenant(); +} + +main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesPutSample.ts b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesPutSample.ts new file mode 100644 index 000000000000..18c57797db2e --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/dataBoundariesPutSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DataboundariesManegementClient } from "@azure/arm-databoundaries"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to opt-in tenant to data boundary. + * + * @summary opt-in tenant to data boundary. + * x-ms-original-file: 2024-08-01/PutDataBoundary.json + */ +async function optInToDataBoundary(): Promise { + const credential = new DefaultAzureCredential(); + const client = new DataboundariesManegementClient(credential); + const result = await client.dataBoundaries.put("default", { properties: { dataBoundary: "EU" } }); + console.log(result); +} + +async function main(): Promise { + await optInToDataBoundary(); +} + +main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/operationsListSample.ts b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/operationsListSample.ts new file mode 100644 index 000000000000..aad479cd80bd --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/src/operationsListSample.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DataboundariesManegementClient } from "@azure/arm-databoundaries"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list the operations for the provider + * + * @summary list the operations for the provider + * x-ms-original-file: 2024-08-01/Operations_List.json + */ +async function operationList(): Promise { + const credential = new DefaultAzureCredential(); + const client = new DataboundariesManegementClient(credential); + const resArray = new Array(); + for await (const item of client.operations.list()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await operationList(); +} + +main().catch(console.error); diff --git a/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/tsconfig.json b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/tsconfig.json new file mode 100644 index 000000000000..400db87cf648 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/samples/v1/typescript/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ES2023", + "module": "commonjs", + "lib": [], + "importHelpers": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node10", + "esModuleInterop": true, + "outDir": "./dist", + "resolveJsonModule": true + }, + "include": [ + "./src" + ] +} diff --git a/sdk/databoundaries/arm-databoundaries/src/api/dataBoundaries/index.ts b/sdk/databoundaries/arm-databoundaries/src/api/dataBoundaries/index.ts new file mode 100644 index 000000000000..7c863dabd843 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/api/dataBoundaries/index.ts @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { put, getTenant, getScope } from "./operations.js"; +export type { + DataBoundariesPutOptionalParams, + DataBoundariesGetTenantOptionalParams, + DataBoundariesGetScopeOptionalParams, +} from "./options.js"; diff --git a/sdk/databoundaries/arm-databoundaries/src/api/dataBoundaries/operations.ts b/sdk/databoundaries/arm-databoundaries/src/api/dataBoundaries/operations.ts new file mode 100644 index 000000000000..1eadbd1de6fa --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/api/dataBoundaries/operations.ts @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { DataboundariesManegementContext as Client } from "../index.js"; +import type { DataBoundaryDefinition, DefaultName } from "../../models/models.js"; +import { + errorResponseDeserializer, + dataBoundaryDefinitionSerializer, + dataBoundaryDefinitionDeserializer, +} from "../../models/models.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { + DataBoundariesPutOptionalParams, + DataBoundariesGetTenantOptionalParams, + DataBoundariesGetScopeOptionalParams, +} from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _putSend( + context: Client, + defaultParam: DefaultName, + dataBoundaryDefinition: DataBoundaryDefinition, + options: DataBoundariesPutOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Resources/dataBoundaries/{default}{?api%2Dversion}", + { + default: defaultParam, + "api%2Dversion": context.apiVersion ?? "2024-08-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { accept: "application/json", ...options.requestOptions?.headers }, + body: dataBoundaryDefinitionSerializer(dataBoundaryDefinition), + }); +} + +export async function _putDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + + throw error; + } + + return dataBoundaryDefinitionDeserializer(result.body); +} + +/** Opt-in tenant to data boundary. */ +export async function put( + context: Client, + defaultParam: DefaultName, + dataBoundaryDefinition: DataBoundaryDefinition, + options: DataBoundariesPutOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _putSend(context, defaultParam, dataBoundaryDefinition, options); + return _putDeserialize(result); +} + +export function _getTenantSend( + context: Client, + defaultParam: DefaultName, + options: DataBoundariesGetTenantOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Resources/dataBoundaries/{default}{?api%2Dversion}", + { + default: defaultParam, + "api%2Dversion": context.apiVersion ?? "2024-08-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getTenantDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + + throw error; + } + + return dataBoundaryDefinitionDeserializer(result.body); +} + +/** Get data boundary of tenant. */ +export async function getTenant( + context: Client, + defaultParam: DefaultName, + options: DataBoundariesGetTenantOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getTenantSend(context, defaultParam, options); + return _getTenantDeserialize(result); +} + +export function _getScopeSend( + context: Client, + scope: string, + defaultParam: DefaultName, + options: DataBoundariesGetScopeOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/{+scope}/providers/Microsoft.Resources/dataBoundaries/{default}{?api%2Dversion}", + { + scope: scope, + default: defaultParam, + "api%2Dversion": context.apiVersion ?? "2024-08-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _getScopeDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + + throw error; + } + + return dataBoundaryDefinitionDeserializer(result.body); +} + +/** Get data boundary at specified scope */ +export async function getScope( + context: Client, + scope: string, + defaultParam: DefaultName, + options: DataBoundariesGetScopeOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getScopeSend(context, scope, defaultParam, options); + return _getScopeDeserialize(result); +} diff --git a/sdk/databoundaries/arm-databoundaries/src/api/dataBoundaries/options.ts b/sdk/databoundaries/arm-databoundaries/src/api/dataBoundaries/options.ts new file mode 100644 index 000000000000..be285e4e49b4 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/api/dataBoundaries/options.ts @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface DataBoundariesPutOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface DataBoundariesGetTenantOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface DataBoundariesGetScopeOptionalParams extends OperationOptions {} diff --git a/sdk/databoundaries/arm-databoundaries/src/api/databoundariesManegementContext.ts b/sdk/databoundaries/arm-databoundaries/src/api/databoundariesManegementContext.ts new file mode 100644 index 000000000000..4189d65f40a6 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/api/databoundariesManegementContext.ts @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { logger } from "../logger.js"; +import { KnownVersions } from "../models/models.js"; +import type { AzureSupportedClouds } from "../static-helpers/cloudSettingHelpers.js"; +import { getArmEndpoint } from "../static-helpers/cloudSettingHelpers.js"; +import type { Client, ClientOptions } from "@azure-rest/core-client"; +import { getClient } from "@azure-rest/core-client"; +import type { TokenCredential } from "@azure/core-auth"; + +/** Provides APIs for data boundary operations. */ +export interface DataboundariesManegementContext extends Client { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion?: string; +} + +/** Optional parameters for the client. */ +export interface DataboundariesManegementClientOptionalParams extends ClientOptions { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion?: string; + /** Specifies the Azure cloud environment for the client. */ + cloudSetting?: AzureSupportedClouds; +} + +/** Provides APIs for data boundary operations. */ +export function createDataboundariesManegement( + credential: TokenCredential, + options: DataboundariesManegementClientOptionalParams = {}, +): DataboundariesManegementContext { + const endpointUrl = + options.endpoint ?? getArmEndpoint(options.cloudSetting) ?? "https://management.azure.com"; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentInfo = `azsdk-js-arm-databoundaries/1.0.0`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}` + : `azsdk-js-api ${userAgentInfo}`; + const { apiVersion: _, ...updatedOptions } = { + ...options, + userAgentOptions: { userAgentPrefix }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + credentials: { scopes: options.credentials?.scopes ?? [`${endpointUrl}/.default`] }, + }; + const clientContext = getClient(endpointUrl, credential, updatedOptions); + const apiVersion = options.apiVersion; + return { ...clientContext, apiVersion } as DataboundariesManegementContext; +} diff --git a/sdk/databoundaries/arm-databoundaries/src/api/index.ts b/sdk/databoundaries/arm-databoundaries/src/api/index.ts new file mode 100644 index 000000000000..94d823524769 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/api/index.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export type { + DataboundariesManegementContext, + DataboundariesManegementClientOptionalParams, +} from "./databoundariesManegementContext.js"; +export { createDataboundariesManegement } from "./databoundariesManegementContext.js"; diff --git a/sdk/databoundaries/arm-databoundaries/src/api/operations/index.ts b/sdk/databoundaries/arm-databoundaries/src/api/operations/index.ts new file mode 100644 index 000000000000..de883c05d2f1 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/api/operations/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { list } from "./operations.js"; +export type { OperationsListOptionalParams } from "./options.js"; diff --git a/sdk/databoundaries/arm-databoundaries/src/api/operations/operations.ts b/sdk/databoundaries/arm-databoundaries/src/api/operations/operations.ts new file mode 100644 index 000000000000..0e54ab031a69 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/api/operations/operations.ts @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { DataboundariesManegementContext as Client } from "../index.js"; +import type { _OperationListResult, Operation } from "../../models/models.js"; +import { + _operationListResultDeserializer, + errorResponseDeserializer, +} from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; +import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import type { OperationsListOptionalParams } from "./options.js"; +import type { StreamableMethod, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; + +export function _listSend( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/providers/Microsoft.Resources/operations{?api%2Dversion}", + { + "api%2Dversion": context.apiVersion ?? "2024-08-01", + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { accept: "application/json", ...options.requestOptions?.headers }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_OperationListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + + throw error; + } + + return _operationListResultDeserializer(result.body); +} + +/** List the operations for the provider */ +export function list( + context: Client, + options: OperationsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion ?? "2024-08-01" }, + ); +} diff --git a/sdk/databoundaries/arm-databoundaries/src/api/operations/options.ts b/sdk/databoundaries/arm-databoundaries/src/api/operations/options.ts new file mode 100644 index 000000000000..b9a3fd9758a3 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/api/operations/options.ts @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface OperationsListOptionalParams extends OperationOptions {} diff --git a/sdk/databoundaries/arm-databoundaries/src/classic/dataBoundaries/index.ts b/sdk/databoundaries/arm-databoundaries/src/classic/dataBoundaries/index.ts new file mode 100644 index 000000000000..4afdb91ad0ef --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/classic/dataBoundaries/index.ts @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { DataboundariesManegementContext } from "../../api/databoundariesManegementContext.js"; +import { put, getTenant, getScope } from "../../api/dataBoundaries/operations.js"; +import type { + DataBoundariesPutOptionalParams, + DataBoundariesGetTenantOptionalParams, + DataBoundariesGetScopeOptionalParams, +} from "../../api/dataBoundaries/options.js"; +import type { DataBoundaryDefinition, DefaultName } from "../../models/models.js"; + +/** Interface representing a DataBoundaries operations. */ +export interface DataBoundariesOperations { + /** Opt-in tenant to data boundary. */ + put: ( + defaultParam: DefaultName, + dataBoundaryDefinition: DataBoundaryDefinition, + options?: DataBoundariesPutOptionalParams, + ) => Promise; + /** Get data boundary of tenant. */ + getTenant: ( + defaultParam: DefaultName, + options?: DataBoundariesGetTenantOptionalParams, + ) => Promise; + /** Get data boundary at specified scope */ + getScope: ( + scope: string, + defaultParam: DefaultName, + options?: DataBoundariesGetScopeOptionalParams, + ) => Promise; +} + +function _getDataBoundaries(context: DataboundariesManegementContext) { + return { + put: ( + defaultParam: DefaultName, + dataBoundaryDefinition: DataBoundaryDefinition, + options?: DataBoundariesPutOptionalParams, + ) => put(context, defaultParam, dataBoundaryDefinition, options), + getTenant: (defaultParam: DefaultName, options?: DataBoundariesGetTenantOptionalParams) => + getTenant(context, defaultParam, options), + getScope: ( + scope: string, + defaultParam: DefaultName, + options?: DataBoundariesGetScopeOptionalParams, + ) => getScope(context, scope, defaultParam, options), + }; +} + +export function _getDataBoundariesOperations( + context: DataboundariesManegementContext, +): DataBoundariesOperations { + return { + ..._getDataBoundaries(context), + }; +} diff --git a/sdk/databoundaries/arm-databoundaries/src/classic/index.ts b/sdk/databoundaries/arm-databoundaries/src/classic/index.ts new file mode 100644 index 000000000000..b6124253a2e3 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/classic/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export type { DataBoundariesOperations } from "./dataBoundaries/index.js"; +export type { OperationsOperations } from "./operations/index.js"; diff --git a/sdk/databoundaries/arm-databoundaries/src/classic/operations/index.ts b/sdk/databoundaries/arm-databoundaries/src/classic/operations/index.ts new file mode 100644 index 000000000000..a4e7ca546eb9 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/classic/operations/index.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { DataboundariesManegementContext } from "../../api/databoundariesManegementContext.js"; +import { list } from "../../api/operations/operations.js"; +import type { OperationsListOptionalParams } from "../../api/operations/options.js"; +import type { Operation } from "../../models/models.js"; +import type { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Operations operations. */ +export interface OperationsOperations { + /** List the operations for the provider */ + list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator; +} + +function _getOperations(context: DataboundariesManegementContext) { + return { + list: (options?: OperationsListOptionalParams) => list(context, options), + }; +} + +export function _getOperationsOperations( + context: DataboundariesManegementContext, +): OperationsOperations { + return { + ..._getOperations(context), + }; +} diff --git a/sdk/databoundaries/arm-databoundaries/src/databoundariesManegementClient.ts b/sdk/databoundaries/arm-databoundaries/src/databoundariesManegementClient.ts index b5327234515b..52f57e8f620a 100644 --- a/sdk/databoundaries/arm-databoundaries/src/databoundariesManegementClient.ts +++ b/sdk/databoundaries/arm-databoundaries/src/databoundariesManegementClient.ts @@ -1,133 +1,45 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import * as coreClient from "@azure/core-client"; -import * as coreRestPipeline from "@azure/core-rest-pipeline"; -import { - PipelineRequest, - PipelineResponse, - SendRequest, -} from "@azure/core-rest-pipeline"; -import * as coreAuth from "@azure/core-auth"; -import { DataBoundariesImpl } from "./operations/index.js"; -import { DataBoundaries } from "./operationsInterfaces/index.js"; -import { DataboundariesManegementClientOptionalParams } from "./models/index.js"; - -export class DataboundariesManegementClient extends coreClient.ServiceClient { - $host: string; - apiVersion: string; - - /** - * Initializes a new instance of the DataboundariesManegementClient class. - * @param credentials Subscription credentials which uniquely identify client subscription. - * @param options The parameter options - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { + DataboundariesManegementContext, + DataboundariesManegementClientOptionalParams, +} from "./api/index.js"; +import { createDataboundariesManegement } from "./api/index.js"; +import type { DataBoundariesOperations } from "./classic/dataBoundaries/index.js"; +import { _getDataBoundariesOperations } from "./classic/dataBoundaries/index.js"; +import type { OperationsOperations } from "./classic/operations/index.js"; +import { _getOperationsOperations } from "./classic/operations/index.js"; +import type { TokenCredential } from "@azure/core-auth"; +import type { Pipeline } from "@azure/core-rest-pipeline"; + +export type { DataboundariesManegementClientOptionalParams } from "./api/databoundariesManegementContext.js"; + +export class DataboundariesManegementClient { + private _client: DataboundariesManegementContext; + /** The pipeline used by this client to make requests */ + public readonly pipeline: Pipeline; + + /** Provides APIs for data boundary operations. */ constructor( - credentials: coreAuth.TokenCredential, - options?: DataboundariesManegementClientOptionalParams, + credential: TokenCredential, + options: DataboundariesManegementClientOptionalParams = {}, ) { - if (credentials === undefined) { - throw new Error("'credentials' cannot be null"); - } - - // Initializing default values for options - if (!options) { - options = {}; - } - const defaults: DataboundariesManegementClientOptionalParams = { - requestContentType: "application/json; charset=utf-8", - credential: credentials, - }; - - const packageDetails = `azsdk-js-arm-databoundaries/1.0.0-beta.3`; - const userAgentPrefix = - options.userAgentOptions && options.userAgentOptions.userAgentPrefix - ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` - : `${packageDetails}`; - - const optionsWithDefaults = { - ...defaults, + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-client` + : `azsdk-js-client`; + this._client = createDataboundariesManegement(credential, { ...options, - userAgentOptions: { - userAgentPrefix, - }, - endpoint: - options.endpoint ?? options.baseUri ?? "https://management.azure.com", - }; - super(optionsWithDefaults); - - let bearerTokenAuthenticationPolicyFound: boolean = false; - if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { - const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = - options.pipeline.getOrderedPolicies(); - bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( - (pipelinePolicy) => - pipelinePolicy.name === - coreRestPipeline.bearerTokenAuthenticationPolicyName, - ); - } - if ( - !options || - !options.pipeline || - options.pipeline.getOrderedPolicies().length == 0 || - !bearerTokenAuthenticationPolicyFound - ) { - this.pipeline.removePolicy({ - name: coreRestPipeline.bearerTokenAuthenticationPolicyName, - }); - this.pipeline.addPolicy( - coreRestPipeline.bearerTokenAuthenticationPolicy({ - credential: credentials, - scopes: - optionsWithDefaults.credentialScopes ?? - `${optionsWithDefaults.endpoint}/.default`, - challengeCallbacks: { - authorizeRequestOnChallenge: - coreClient.authorizeRequestOnClaimChallenge, - }, - }), - ); - } - - // Assigning values to Constant parameters - this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2024-08-01"; - this.dataBoundaries = new DataBoundariesImpl(this); - this.addCustomApiVersionPolicy(options.apiVersion); - } - - /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ - private addCustomApiVersionPolicy(apiVersion?: string) { - if (!apiVersion) { - return; - } - const apiVersionPolicy = { - name: "CustomApiVersionPolicy", - async sendRequest( - request: PipelineRequest, - next: SendRequest, - ): Promise { - const param = request.url.split("?"); - if (param.length > 1) { - const newParams = param[1].split("&").map((item) => { - if (item.indexOf("api-version") > -1) { - return "api-version=" + apiVersion; - } else { - return item; - } - }); - request.url = param[0] + "?" + newParams.join("&"); - } - return next(request); - }, - }; - this.pipeline.addPolicy(apiVersionPolicy); + userAgentOptions: { userAgentPrefix }, + }); + this.pipeline = this._client.pipeline; + this.dataBoundaries = _getDataBoundariesOperations(this._client); + this.operations = _getOperationsOperations(this._client); } - dataBoundaries: DataBoundaries; + /** The operation groups for dataBoundaries */ + public readonly dataBoundaries: DataBoundariesOperations; + /** The operation groups for operations */ + public readonly operations: OperationsOperations; } diff --git a/sdk/databoundaries/arm-databoundaries/src/index.ts b/sdk/databoundaries/arm-databoundaries/src/index.ts index bf041645a17c..d00e31838b74 100644 --- a/sdk/databoundaries/arm-databoundaries/src/index.ts +++ b/sdk/databoundaries/arm-databoundaries/src/index.ts @@ -1,11 +1,50 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { AzureSupportedClouds } from "./static-helpers/cloudSettingHelpers.js"; +import { AzureClouds } from "./static-helpers/cloudSettingHelpers.js"; +import type { + PageSettings, + ContinuablePage, + PagedAsyncIterableIterator, +} from "./static-helpers/pagingHelpers.js"; -export * from "./models/index.js"; export { DataboundariesManegementClient } from "./databoundariesManegementClient.js"; -export * from "./operationsInterfaces/index.js"; +export type { + Operation, + OperationDisplay, + Origin, + ActionType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + DataBoundaryDefinition, + DataBoundaryProperties, + DataBoundary, + ProvisioningState, + DefaultName, + ProxyResource, + Resource, + SystemData, + CreatedByType, +} from "./models/index.js"; +export { + KnownOrigin, + KnownActionType, + KnownDataBoundary, + KnownProvisioningState, + KnownDefaultName, + KnownCreatedByType, + KnownVersions, +} from "./models/index.js"; +export type { DataboundariesManegementClientOptionalParams } from "./api/index.js"; +export type { + DataBoundariesPutOptionalParams, + DataBoundariesGetTenantOptionalParams, + DataBoundariesGetScopeOptionalParams, +} from "./api/dataBoundaries/index.js"; +export type { OperationsListOptionalParams } from "./api/operations/index.js"; +export type { DataBoundariesOperations, OperationsOperations } from "./classic/index.js"; +export type { PageSettings, ContinuablePage, PagedAsyncIterableIterator }; +export { AzureClouds }; +export type { AzureSupportedClouds }; diff --git a/sdk/databoundaries/arm-databoundaries/src/logger.ts b/sdk/databoundaries/arm-databoundaries/src/logger.ts new file mode 100644 index 000000000000..d44a4720fd12 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; +export const logger = createClientLogger("arm-databoundaries"); diff --git a/sdk/databoundaries/arm-databoundaries/src/models/index.ts b/sdk/databoundaries/arm-databoundaries/src/models/index.ts index f2a0c67411cb..5c5975a8bb35 100644 --- a/sdk/databoundaries/arm-databoundaries/src/models/index.ts +++ b/sdk/databoundaries/arm-databoundaries/src/models/index.ts @@ -1,243 +1,30 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import * as coreClient from "@azure/core-client"; - -/** Data boundary properties */ -export interface DataBoundaryProperties { - /** The data boundary definition. */ - dataBoundary?: DataBoundary; - /** - * Denotes the state of provisioning. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly provisioningState?: ProvisioningState; -} - -/** Common fields that are returned in the response for all Azure Resource Manager resources */ -export interface Resource { - /** - * Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** - * The name of the resource - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly name?: string; - /** - * The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly type?: string; - /** - * Azure Resource Manager metadata containing createdBy and modifiedBy information. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly systemData?: SystemData; -} - -/** Metadata pertaining to creation and last modification of the resource. */ -export interface SystemData { - /** The identity that created the resource. */ - createdBy?: string; - /** The type of identity that created the resource. */ - createdByType?: CreatedByType; - /** The timestamp of resource creation (UTC). */ - createdAt?: Date; - /** The identity that last modified the resource. */ - lastModifiedBy?: string; - /** The type of identity that last modified the resource. */ - lastModifiedByType?: CreatedByType; - /** The timestamp of resource last modification (UTC) */ - lastModifiedAt?: Date; -} - -/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */ -export interface ErrorResponse { - /** The error object. */ - error?: ErrorDetail; -} - -/** The error detail. */ -export interface ErrorDetail { - /** - * The error code. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly code?: string; - /** - * The error message. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly message?: string; - /** - * The error target. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly target?: string; - /** - * The error details. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly details?: ErrorDetail[]; - /** - * The error additional info. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly additionalInfo?: ErrorAdditionalInfo[]; -} - -/** The resource management error additional info. */ -export interface ErrorAdditionalInfo { - /** - * The additional info type. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly type?: string; - /** - * The additional info. - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly info?: Record; -} - -/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */ -export interface ProxyResource extends Resource {} - -/** A data boundary definition. */ -export interface DataBoundaryDefinition extends ProxyResource { - /** Data boundary properties */ - properties?: DataBoundaryProperties; -} - -/** Known values of {@link DefaultName} that the service accepts. */ -export enum KnownDefaultName { - /** Default */ - Default = "default", -} - -/** - * Defines values for DefaultName. \ - * {@link KnownDefaultName} can be used interchangeably with DefaultName, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **default** - */ -export type DefaultName = string; - -/** Known values of {@link DataBoundary} that the service accepts. */ -export enum KnownDataBoundary { - /** NotDefined */ - NotDefined = "NotDefined", - /** Global */ - Global = "Global", - /** EU */ - EU = "EU", -} - -/** - * Defines values for DataBoundary. \ - * {@link KnownDataBoundary} can be used interchangeably with DataBoundary, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **NotDefined** \ - * **Global** \ - * **EU** - */ -export type DataBoundary = string; - -/** Known values of {@link ProvisioningState} that the service accepts. */ -export enum KnownProvisioningState { - /** Accepted */ - Accepted = "Accepted", - /** Running */ - Running = "Running", - /** Creating */ - Creating = "Creating", - /** Canceled */ - Canceled = "Canceled", - /** Failed */ - Failed = "Failed", - /** Succeeded */ - Succeeded = "Succeeded", - /** Updating */ - Updating = "Updating", -} - -/** - * Defines values for ProvisioningState. \ - * {@link KnownProvisioningState} can be used interchangeably with ProvisioningState, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **Accepted** \ - * **Running** \ - * **Creating** \ - * **Canceled** \ - * **Failed** \ - * **Succeeded** \ - * **Updating** - */ -export type ProvisioningState = string; - -/** Known values of {@link CreatedByType} that the service accepts. */ -export enum KnownCreatedByType { - /** User */ - User = "User", - /** Application */ - Application = "Application", - /** ManagedIdentity */ - ManagedIdentity = "ManagedIdentity", - /** Key */ - Key = "Key", -} - -/** - * Defines values for CreatedByType. \ - * {@link KnownCreatedByType} can be used interchangeably with CreatedByType, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **User** \ - * **Application** \ - * **ManagedIdentity** \ - * **Key** - */ -export type CreatedByType = string; - -/** Optional parameters. */ -export interface DataBoundariesPutOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the put operation. */ -export type DataBoundariesPutResponse = DataBoundaryDefinition; - -/** Optional parameters. */ -export interface DataBoundariesGetTenantOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getTenant operation. */ -export type DataBoundariesGetTenantResponse = DataBoundaryDefinition; - -/** Optional parameters. */ -export interface DataBoundariesGetScopeOptionalParams - extends coreClient.OperationOptions {} - -/** Contains response data for the getScope operation. */ -export type DataBoundariesGetScopeResponse = DataBoundaryDefinition; - -/** Optional parameters. */ -export interface DataboundariesManegementClientOptionalParams - extends coreClient.ServiceClientOptions { - /** server parameter */ - $host?: string; - /** Api Version */ - apiVersion?: string; - /** Overrides client endpoint. */ - endpoint?: string; -} +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export type { + Operation, + OperationDisplay, + Origin, + ActionType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + DataBoundaryDefinition, + DataBoundaryProperties, + DataBoundary, + ProvisioningState, + DefaultName, + ProxyResource, + Resource, + SystemData, + CreatedByType, +} from "./models.js"; +export { + KnownOrigin, + KnownActionType, + KnownDataBoundary, + KnownProvisioningState, + KnownDefaultName, + KnownCreatedByType, + KnownVersions, +} from "./models.js"; diff --git a/sdk/databoundaries/arm-databoundaries/src/models/mappers.ts b/sdk/databoundaries/arm-databoundaries/src/models/mappers.ts deleted file mode 100644 index 9c5363c70d88..000000000000 --- a/sdk/databoundaries/arm-databoundaries/src/models/mappers.ts +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import * as coreClient from "@azure/core-client"; - -export const DataBoundaryProperties: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "DataBoundaryProperties", - modelProperties: { - dataBoundary: { - serializedName: "dataBoundary", - type: { - name: "String", - }, - }, - provisioningState: { - serializedName: "provisioningState", - readOnly: true, - type: { - name: "String", - }, - }, - }, - }, -}; - -export const Resource: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "Resource", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String", - }, - }, - name: { - serializedName: "name", - readOnly: true, - type: { - name: "String", - }, - }, - type: { - serializedName: "type", - readOnly: true, - type: { - name: "String", - }, - }, - systemData: { - serializedName: "systemData", - type: { - name: "Composite", - className: "SystemData", - }, - }, - }, - }, -}; - -export const SystemData: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "SystemData", - modelProperties: { - createdBy: { - serializedName: "createdBy", - type: { - name: "String", - }, - }, - createdByType: { - serializedName: "createdByType", - type: { - name: "String", - }, - }, - createdAt: { - serializedName: "createdAt", - type: { - name: "DateTime", - }, - }, - lastModifiedBy: { - serializedName: "lastModifiedBy", - type: { - name: "String", - }, - }, - lastModifiedByType: { - serializedName: "lastModifiedByType", - type: { - name: "String", - }, - }, - lastModifiedAt: { - serializedName: "lastModifiedAt", - type: { - name: "DateTime", - }, - }, - }, - }, -}; - -export const ErrorResponse: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ErrorResponse", - modelProperties: { - error: { - serializedName: "error", - type: { - name: "Composite", - className: "ErrorDetail", - }, - }, - }, - }, -}; - -export const ErrorDetail: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ErrorDetail", - modelProperties: { - code: { - serializedName: "code", - readOnly: true, - type: { - name: "String", - }, - }, - message: { - serializedName: "message", - readOnly: true, - type: { - name: "String", - }, - }, - target: { - serializedName: "target", - readOnly: true, - type: { - name: "String", - }, - }, - details: { - serializedName: "details", - readOnly: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ErrorDetail", - }, - }, - }, - }, - additionalInfo: { - serializedName: "additionalInfo", - readOnly: true, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ErrorAdditionalInfo", - }, - }, - }, - }, - }, - }, -}; - -export const ErrorAdditionalInfo: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ErrorAdditionalInfo", - modelProperties: { - type: { - serializedName: "type", - readOnly: true, - type: { - name: "String", - }, - }, - info: { - serializedName: "info", - readOnly: true, - type: { - name: "Dictionary", - value: { type: { name: "any" } }, - }, - }, - }, - }, -}; - -export const ProxyResource: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "ProxyResource", - modelProperties: { - ...Resource.type.modelProperties, - }, - }, -}; - -export const DataBoundaryDefinition: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "DataBoundaryDefinition", - modelProperties: { - ...ProxyResource.type.modelProperties, - properties: { - serializedName: "properties", - type: { - name: "Composite", - className: "DataBoundaryProperties", - }, - }, - }, - }, -}; diff --git a/sdk/databoundaries/arm-databoundaries/src/models/models.ts b/sdk/databoundaries/arm-databoundaries/src/models/models.ts new file mode 100644 index 000000000000..2d7d19dddaa9 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/models/models.ts @@ -0,0 +1,389 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This file contains only generated model types and their (de)serializers. + * Disable the following rules for internal models with '_' prefix and deserializers which require 'any' for raw JSON input. + */ +/* eslint-disable @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/** 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 */ + value: Operation[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _operationListResultDeserializer(item: any): _OperationListResult { + return { + value: operationArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function operationArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return operationDeserializer(item); + }); +} + +/** Details of a REST API operation, returned from the Resource Provider Operations API */ +export interface Operation { + /** The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" */ + 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. */ + display?: OperationDisplay; + /** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */ + readonly origin?: Origin; + /** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ + readonly actionType?: ActionType; +} + +export function operationDeserializer(item: any): Operation { + return { + name: item["name"], + isDataAction: item["isDataAction"], + display: !item["display"] ? item["display"] : operationDisplayDeserializer(item["display"]), + origin: item["origin"], + actionType: item["actionType"], + }; +} + +/** Localized display information for an operation. */ +export interface OperationDisplay { + /** 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; +} + +export function operationDisplayDeserializer(item: any): OperationDisplay { + return { + provider: item["provider"], + resource: item["resource"], + operation: item["operation"], + description: item["description"], + }; +} + +/** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */ +export enum KnownOrigin { + /** Indicates the operation is initiated by a user. */ + User = "user", + /** Indicates the operation is initiated by a system. */ + System = "system", + /** Indicates the operation is initiated by a user or system. */ + UserSystem = "user,system", +} + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" \ + * {@link KnownOrigin} can be used interchangeably with Origin, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **user**: Indicates the operation is initiated by a user. \ + * **system**: Indicates the operation is initiated by a system. \ + * **user,system**: Indicates the operation is initiated by a user or system. + */ +export type Origin = string; + +/** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ +export enum KnownActionType { + /** Actions are for internal-only APIs. */ + Internal = "Internal", +} + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. \ + * {@link KnownActionType} can be used interchangeably with ActionType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Internal**: Actions are for internal-only APIs. + */ +export type ActionType = 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 errorResponseDeserializer(item: any): ErrorResponse { + return { + error: !item["error"] ? item["error"] : errorDetailDeserializer(item["error"]), + }; +} + +/** 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[]; +} + +export function errorDetailDeserializer(item: any): ErrorDetail { + return { + code: item["code"], + message: item["message"], + target: item["target"], + details: !item["details"] ? item["details"] : errorDetailArrayDeserializer(item["details"]), + additionalInfo: !item["additionalInfo"] + ? item["additionalInfo"] + : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]), + }; +} + +export function errorDetailArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorDetailDeserializer(item); + }); +} + +export function errorAdditionalInfoArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorAdditionalInfoDeserializer(item); + }); +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** The additional info type. */ + readonly type?: string; + /** The additional info. */ + readonly info?: any; +} + +export function errorAdditionalInfoDeserializer(item: any): ErrorAdditionalInfo { + return { + type: item["type"], + info: item["info"], + }; +} + +/** A data boundary definition. */ +export interface DataBoundaryDefinition extends ProxyResource { + /** Data boundary properties */ + properties?: DataBoundaryProperties; +} + +export function dataBoundaryDefinitionSerializer(item: DataBoundaryDefinition): any { + return { + properties: !item["properties"] + ? item["properties"] + : dataBoundaryPropertiesSerializer(item["properties"]), + }; +} + +export function dataBoundaryDefinitionDeserializer(item: any): DataBoundaryDefinition { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : dataBoundaryPropertiesDeserializer(item["properties"]), + }; +} + +/** Data boundary properties */ +export interface DataBoundaryProperties { + /** The data boundary definition. */ + dataBoundary?: DataBoundary; + /** Denotes the state of provisioning. */ + readonly provisioningState?: ProvisioningState; +} + +export function dataBoundaryPropertiesSerializer(item: DataBoundaryProperties): any { + return { dataBoundary: item["dataBoundary"] }; +} + +export function dataBoundaryPropertiesDeserializer(item: any): DataBoundaryProperties { + return { + dataBoundary: item["dataBoundary"], + provisioningState: item["provisioningState"], + }; +} + +/** The data boundary definition. */ +export enum KnownDataBoundary { + /** NotDefined */ + NotDefined = "NotDefined", + /** Global */ + Global = "Global", + /** EU */ + EU = "EU", +} + +/** + * The data boundary definition. \ + * {@link KnownDataBoundary} can be used interchangeably with DataBoundary, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **NotDefined**: NotDefined \ + * **Global**: Global \ + * **EU**: EU + */ +export type DataBoundary = string; + +/** Denotes the state of provisioning. */ +export enum KnownProvisioningState { + /** Accepted */ + Accepted = "Accepted", + /** Running */ + Running = "Running", + /** Creating */ + Creating = "Creating", + /** Canceled */ + Canceled = "Canceled", + /** Failed */ + Failed = "Failed", + /** Succeeded */ + Succeeded = "Succeeded", + /** Updating */ + Updating = "Updating", +} + +/** + * Denotes the state of provisioning. \ + * {@link KnownProvisioningState} can be used interchangeably with ProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Accepted**: Accepted \ + * **Running**: Running \ + * **Creating**: Creating \ + * **Canceled**: Canceled \ + * **Failed**: Failed \ + * **Succeeded**: Succeeded \ + * **Updating**: Updating + */ +export type ProvisioningState = string; + +/** Known values of {@link DefaultName} that the service accepts. */ +export enum KnownDefaultName { + /** default */ + Default = "default", +} + +/** Type of DefaultName */ +export type DefaultName = 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 {} + +export function proxyResourceSerializer(item: ProxyResource): any { + return item; +} + +export function proxyResourceDeserializer(item: any): ProxyResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + }; +} + +/** Common fields that are returned in the response for all Azure Resource Manager resources */ +export interface Resource { + /** Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} */ + readonly id?: string; + /** The name of the resource */ + readonly name?: string; + /** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */ + readonly type?: string; + /** Azure Resource Manager metadata containing createdBy and modifiedBy information. */ + readonly systemData?: SystemData; +} + +export function resourceSerializer(item: Resource): any { + return item; +} + +export function resourceDeserializer(item: any): Resource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + }; +} + +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemData { + /** The identity that created the resource. */ + createdBy?: string; + /** The type of identity that created the resource. */ + createdByType?: CreatedByType; + /** The timestamp of resource creation (UTC). */ + createdAt?: Date; + /** The identity that last modified the resource. */ + lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + lastModifiedByType?: CreatedByType; + /** The timestamp of resource last modification (UTC) */ + lastModifiedAt?: Date; +} + +export function systemDataDeserializer(item: any): SystemData { + return { + createdBy: item["createdBy"], + createdByType: item["createdByType"], + createdAt: !item["createdAt"] ? item["createdAt"] : new Date(item["createdAt"]), + lastModifiedBy: item["lastModifiedBy"], + lastModifiedByType: item["lastModifiedByType"], + lastModifiedAt: !item["lastModifiedAt"] + ? item["lastModifiedAt"] + : new Date(item["lastModifiedAt"]), + }; +} + +/** The kind of entity that created the resource. */ +export enum KnownCreatedByType { + /** The entity was created by a user. */ + User = "User", + /** The entity was created by an application. */ + Application = "Application", + /** The entity was created by a managed identity. */ + ManagedIdentity = "ManagedIdentity", + /** The entity was created by a key. */ + Key = "Key", +} + +/** + * The kind of entity that created the resource. \ + * {@link KnownCreatedByType} can be used interchangeably with CreatedByType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **User**: The entity was created by a user. \ + * **Application**: The entity was created by an application. \ + * **ManagedIdentity**: The entity was created by a managed identity. \ + * **Key**: The entity was created by a key. + */ +export type CreatedByType = string; + +/** The available API versions. */ +export enum KnownVersions { + /** The 2024-08-01 API version. */ + V20240801 = "2024-08-01", +} diff --git a/sdk/databoundaries/arm-databoundaries/src/models/parameters.ts b/sdk/databoundaries/arm-databoundaries/src/models/parameters.ts deleted file mode 100644 index 2db1a66c3a60..000000000000 --- a/sdk/databoundaries/arm-databoundaries/src/models/parameters.ts +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import { - OperationParameter, - OperationURLParameter, - OperationQueryParameter, -} from "@azure/core-client"; -import { DataBoundaryDefinition as DataBoundaryDefinitionMapper } from "../models/mappers.js"; - -export const contentType: OperationParameter = { - parameterPath: ["options", "contentType"], - mapper: { - defaultValue: "application/json", - isConstant: true, - serializedName: "Content-Type", - type: { - name: "String", - }, - }, -}; - -export const dataBoundaryDefinition: OperationParameter = { - parameterPath: "dataBoundaryDefinition", - mapper: DataBoundaryDefinitionMapper, -}; - -export const accept: OperationParameter = { - parameterPath: "accept", - mapper: { - defaultValue: "application/json", - isConstant: true, - serializedName: "Accept", - type: { - name: "String", - }, - }, -}; - -export const $host: OperationURLParameter = { - parameterPath: "$host", - mapper: { - serializedName: "$host", - required: true, - type: { - name: "String", - }, - }, - skipEncoding: true, -}; - -export const apiVersion: OperationQueryParameter = { - parameterPath: "apiVersion", - mapper: { - defaultValue: "2024-08-01", - isConstant: true, - serializedName: "api-version", - type: { - name: "String", - }, - }, -}; - -export const defaultParam: OperationURLParameter = { - parameterPath: "defaultParam", - mapper: { - serializedName: "default", - required: true, - type: { - name: "String", - }, - }, -}; - -export const scope: OperationURLParameter = { - parameterPath: "scope", - mapper: { - constraints: { - MinLength: 1, - }, - serializedName: "scope", - required: true, - type: { - name: "String", - }, - }, - skipEncoding: true, -}; diff --git a/sdk/databoundaries/arm-databoundaries/src/operations/dataBoundaries.ts b/sdk/databoundaries/arm-databoundaries/src/operations/dataBoundaries.ts deleted file mode 100644 index ae770e3fe9bc..000000000000 --- a/sdk/databoundaries/arm-databoundaries/src/operations/dataBoundaries.ts +++ /dev/null @@ -1,141 +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 { DataBoundaries } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import { DataboundariesManegementClient } from "../databoundariesManegementClient.js"; -import { - DataBoundaryDefinition, - DefaultName, - DataBoundariesPutOptionalParams, - DataBoundariesPutResponse, - DataBoundariesGetTenantOptionalParams, - DataBoundariesGetTenantResponse, - DataBoundariesGetScopeOptionalParams, - DataBoundariesGetScopeResponse, -} from "../models/index.js"; - -/** Class containing DataBoundaries operations. */ -export class DataBoundariesImpl implements DataBoundaries { - private readonly client: DataboundariesManegementClient; - - /** - * Initialize a new instance of the class DataBoundaries class. - * @param client Reference to the service client - */ - constructor(client: DataboundariesManegementClient) { - this.client = client; - } - - /** - * Opt-in tenant to data boundary. - * @param defaultParam Default string modeled as parameter for auto generation to work correctly. - * @param dataBoundaryDefinition The data boundary to opt the tenant to. - * @param options The options parameters. - */ - put( - defaultParam: DefaultName, - dataBoundaryDefinition: DataBoundaryDefinition, - options?: DataBoundariesPutOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { defaultParam, dataBoundaryDefinition, options }, - putOperationSpec, - ); - } - - /** - * Get data boundary of tenant. - * @param defaultParam Default string modeled as parameter for auto generation to work correctly. - * @param options The options parameters. - */ - getTenant( - defaultParam: DefaultName, - options?: DataBoundariesGetTenantOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { defaultParam, options }, - getTenantOperationSpec, - ); - } - - /** - * Get data boundary at specified scope - * @param scope The scope at which the operation is performed. - * @param defaultParam Default string modeled as parameter for auto generation to work correctly. - * @param options The options parameters. - */ - getScope( - scope: string, - defaultParam: DefaultName, - options?: DataBoundariesGetScopeOptionalParams, - ): Promise { - return this.client.sendOperationRequest( - { scope, defaultParam, options }, - getScopeOperationSpec, - ); - } -} -// Operation Specifications -const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); - -const putOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Resources/dataBoundaries/{default}", - httpMethod: "PUT", - responses: { - 200: { - bodyMapper: Mappers.DataBoundaryDefinition, - }, - 201: { - bodyMapper: Mappers.DataBoundaryDefinition, - }, - default: { - bodyMapper: Mappers.ErrorResponse, - }, - }, - requestBody: Parameters.dataBoundaryDefinition, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.defaultParam], - headerParameters: [Parameters.contentType, Parameters.accept], - mediaType: "json", - serializer, -}; -const getTenantOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Resources/dataBoundaries/{default}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.DataBoundaryDefinition, - }, - default: { - bodyMapper: Mappers.ErrorResponse, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.defaultParam], - headerParameters: [Parameters.accept], - serializer, -}; -const getScopeOperationSpec: coreClient.OperationSpec = { - path: "/{scope}/providers/Microsoft.Resources/dataBoundaries/{default}", - httpMethod: "GET", - responses: { - 200: { - bodyMapper: Mappers.DataBoundaryDefinition, - }, - default: { - bodyMapper: Mappers.ErrorResponse, - }, - }, - queryParameters: [Parameters.apiVersion], - urlParameters: [Parameters.$host, Parameters.defaultParam, Parameters.scope], - headerParameters: [Parameters.accept], - serializer, -}; diff --git a/sdk/databoundaries/arm-databoundaries/src/operations/index.ts b/sdk/databoundaries/arm-databoundaries/src/operations/index.ts deleted file mode 100644 index 35498d6399ac..000000000000 --- a/sdk/databoundaries/arm-databoundaries/src/operations/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export * from "./dataBoundaries.js"; diff --git a/sdk/databoundaries/arm-databoundaries/src/operationsInterfaces/dataBoundaries.ts b/sdk/databoundaries/arm-databoundaries/src/operationsInterfaces/dataBoundaries.ts deleted file mode 100644 index fd8f6a893eae..000000000000 --- a/sdk/databoundaries/arm-databoundaries/src/operationsInterfaces/dataBoundaries.ts +++ /dev/null @@ -1,53 +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 { - DataBoundaryDefinition, - DefaultName, - DataBoundariesPutOptionalParams, - DataBoundariesPutResponse, - DataBoundariesGetTenantOptionalParams, - DataBoundariesGetTenantResponse, - DataBoundariesGetScopeOptionalParams, - DataBoundariesGetScopeResponse, -} from "../models/index.js"; - -/** Interface representing a DataBoundaries. */ -export interface DataBoundaries { - /** - * Opt-in tenant to data boundary. - * @param defaultParam Default string modeled as parameter for auto generation to work correctly. - * @param dataBoundaryDefinition The data boundary to opt the tenant to. - * @param options The options parameters. - */ - put( - defaultParam: DefaultName, - dataBoundaryDefinition: DataBoundaryDefinition, - options?: DataBoundariesPutOptionalParams, - ): Promise; - /** - * Get data boundary of tenant. - * @param defaultParam Default string modeled as parameter for auto generation to work correctly. - * @param options The options parameters. - */ - getTenant( - defaultParam: DefaultName, - options?: DataBoundariesGetTenantOptionalParams, - ): Promise; - /** - * Get data boundary at specified scope - * @param scope The scope at which the operation is performed. - * @param defaultParam Default string modeled as parameter for auto generation to work correctly. - * @param options The options parameters. - */ - getScope( - scope: string, - defaultParam: DefaultName, - options?: DataBoundariesGetScopeOptionalParams, - ): Promise; -} diff --git a/sdk/databoundaries/arm-databoundaries/src/operationsInterfaces/index.ts b/sdk/databoundaries/arm-databoundaries/src/operationsInterfaces/index.ts deleted file mode 100644 index 35498d6399ac..000000000000 --- a/sdk/databoundaries/arm-databoundaries/src/operationsInterfaces/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export * from "./dataBoundaries.js"; diff --git a/sdk/databoundaries/arm-databoundaries/src/static-helpers/cloudSettingHelpers.ts b/sdk/databoundaries/arm-databoundaries/src/static-helpers/cloudSettingHelpers.ts new file mode 100644 index 000000000000..613112c6e397 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/static-helpers/cloudSettingHelpers.ts @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * An enum to describe Azure Cloud environments. + * @enum {string} + */ +export enum AzureClouds { + /** Azure public cloud, which is the default cloud for Azure SDKs. */ + AZURE_PUBLIC_CLOUD = "AZURE_PUBLIC_CLOUD", + /** Azure China cloud */ + AZURE_CHINA_CLOUD = "AZURE_CHINA_CLOUD", + /** Azure US government cloud */ + AZURE_US_GOVERNMENT = "AZURE_US_GOVERNMENT", +} + +/** The supported values for cloud setting as a string literal type */ +export type AzureSupportedClouds = `${AzureClouds}`; + +/** + * Gets the Azure Resource Manager endpoint URL for the specified cloud setting. + * @param cloudSetting - The Azure cloud environment setting. Use one of the AzureClouds enum values. + * @returns The ARM endpoint URL for the specified cloud, or undefined if cloudSetting is undefined. + * @throws {Error} Throws an error if an unknown cloud setting is provided. + */ +export function getArmEndpoint(cloudSetting?: AzureSupportedClouds): string | undefined { + if (cloudSetting === undefined) { + return undefined; + } + const cloudEndpoints: Record = { + AZURE_CHINA_CLOUD: "https://management.chinacloudapi.cn/", + AZURE_US_GOVERNMENT: "https://management.usgovcloudapi.net/", + AZURE_PUBLIC_CLOUD: "https://management.azure.com/", + }; + if (cloudSetting in cloudEndpoints) { + return cloudEndpoints[cloudSetting]; + } else { + throw new Error( + `Unknown cloud setting: ${cloudSetting}. Please refer to the enum AzureClouds for possible values.`, + ); + } +} diff --git a/sdk/databoundaries/arm-databoundaries/src/static-helpers/pagingHelpers.ts b/sdk/databoundaries/arm-databoundaries/src/static-helpers/pagingHelpers.ts new file mode 100644 index 000000000000..9258ba95eda8 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/static-helpers/pagingHelpers.ts @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { Client, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError } from "@azure-rest/core-client"; +import { RestError } from "@azure/core-rest-pipeline"; + +/** + * Options for the byPage method + */ +export interface PageSettings { + /** + * A reference to a specific page to start iterating from. + */ + continuationToken?: string; +} + +/** + * An interface that describes a page of results. + */ +export type ContinuablePage = TPage & { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +}; + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; +} + +/** + * An interface that describes how to communicate with the service. + */ +export interface PagedResult< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * Link to the first page of results. + */ + firstPageLink?: string; + /** + * A method that returns a page of results. + */ + getPage: (pageLink?: string) => Promise<{ page: TPage; nextPageLink?: string } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: (settings?: TPageSettings) => AsyncIterableIterator>; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => TElement[]; +} + +/** + * Options for the paging helper + */ +export interface BuildPagedAsyncIteratorOptions { + itemName?: string; + nextLinkName?: string; + nextLinkMethod?: "GET" | "POST"; + apiVersion?: string; +} + +/** + * Helper to paginate results in a generic way and return a PagedAsyncIterableIterator + */ +export function buildPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +>( + client: Client, + getInitialResponse: () => PromiseLike, + processResponseBody: (result: TResponse) => PromiseLike, + expectedStatuses: string[], + options: BuildPagedAsyncIteratorOptions = {}, +): PagedAsyncIterableIterator { + const itemName = options.itemName ?? "value"; + const nextLinkName = options.nextLinkName ?? "nextLink"; + const nextLinkMethod = options.nextLinkMethod ?? "GET"; + const apiVersion = options.apiVersion; + const pagedResult: PagedResult = { + getPage: async (pageLink?: string) => { + let result; + if (pageLink === undefined) { + result = await getInitialResponse(); + } else { + const resolvedPageLink = apiVersion ? addApiVersionToUrl(pageLink, apiVersion) : pageLink; + result = + nextLinkMethod === "POST" + ? await client.pathUnchecked(resolvedPageLink).post() + : await client.pathUnchecked(resolvedPageLink).get(); + } + checkPagingRequest(result, expectedStatuses); + const results = await processResponseBody(result as TResponse); + const nextLink = getNextLink(results, nextLinkName); + const values = getElements(results, itemName) as TPage; + return { + page: values, + nextPageLink: nextLink, + }; + }, + byPage: (settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }, + }; + return getPagedAsyncIterator(pagedResult); +} + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ + +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator(pagedResult); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + ((settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + for await (const page of pages) { + yield* page as unknown as TElement[]; + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: string; + } = {}, +): AsyncIterableIterator> { + const { pageLink } = options; + let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); + if (!response) { + return; + } + let result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + } +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined" && nextLink !== null) { + throw new RestError( + `Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`, + ); + } + + if (nextLink === null) { + return undefined; + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + if (!Array.isArray(value)) { + throw new RestError( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`, + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse, expectedStatuses: string[]): void { + if (!expectedStatuses.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response, + ); + } +} + +/** + * Adds the api-version query parameter on a URL if it's not present. + * @param url - the URL to modify + * @param apiVersion - the API version to set + * @returns - the URL with the api-version query parameter set + */ +function addApiVersionToUrl(url: string, apiVersion: string): string { + // The base URL is only used for parsing and won't appear in the returned URL + const urlObj = new URL(url, "https://microsoft.com"); + if (!urlObj.searchParams.get("api-version")) { + // Append one if there is no apiVersion + return `${url}${ + Array.from(urlObj.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + return url; +} diff --git a/sdk/databoundaries/arm-databoundaries/src/static-helpers/urlTemplate.ts b/sdk/databoundaries/arm-databoundaries/src/static-helpers/urlTemplate.ts new file mode 100644 index 000000000000..e8af8cd3ab73 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/src/static-helpers/urlTemplate.ts @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// --------------------- +// interfaces +// --------------------- +interface ValueOptions { + isFirst: boolean; // is first value in the expression + op?: string; // operator + varValue?: any; // variable value + varName?: string; // variable name + modifier?: string; // modifier e.g * + reserved?: boolean; // if true we'll keep reserved words with not encoding +} + +export interface UrlTemplateOptions { + // if set to true, reserved characters will not be encoded + allowReserved?: boolean; +} + +// --------------------- +// helpers +// --------------------- +function encodeComponent(val: string, reserved?: boolean, op?: string): string { + return (reserved ?? op === "+") || op === "#" + ? encodeReservedComponent(val) + : encodeRFC3986URIComponent(val); +} + +function encodeReservedComponent(str: string): string { + return str + .split(/(%[0-9A-Fa-f]{2})/g) + .map((part) => (!/%[0-9A-Fa-f]/.test(part) ? encodeURI(part) : part)) + .join(""); +} + +function encodeRFC3986URIComponent(str: string): string { + return encodeURIComponent(str).replace( + /[!'()*]/g, + (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`, + ); +} + +function isDefined(val: any): boolean { + return val !== undefined && val !== null; +} + +function getNamedAndIfEmpty(op?: string): [boolean, string] { + return [!!op && [";", "?", "&"].includes(op), !!op && ["?", "&"].includes(op) ? "=" : ""]; +} + +function getFirstOrSep(op?: string, isFirst = false): string { + if (isFirst) { + return !op || op === "+" ? "" : op; + } else if (!op || op === "+" || op === "#") { + return ","; + } else if (op === "?") { + return "&"; + } else { + return op; + } +} + +function getExpandedValue(option: ValueOptions): string { + let isFirst = option.isFirst; + const { op, varName, varValue: value, reserved } = option; + const vals: string[] = []; + const [named, ifEmpty] = getNamedAndIfEmpty(op); + + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + // prepare the following parts: separator, varName, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (named && varName) { + vals.push(`${encodeURIComponent(varName)}`); + if (val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + const val = value[key]; + if (!isDefined(val)) { + continue; + } + // prepare the following parts: separator, key, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (key) { + vals.push(`${encodeURIComponent(key)}`); + if (named && val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } + return vals.join(""); +} + +function getNonExpandedValue(option: ValueOptions): string | undefined { + const { op, varName, varValue: value, isFirst, reserved } = option; + const vals: string[] = []; + const first = getFirstOrSep(op, isFirst); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + if (named && varName) { + vals.push(encodeComponent(varName, reserved, op)); + if (value === "") { + if (!ifEmpty) { + vals.push(ifEmpty); + } + return !vals.join("") ? undefined : `${first}${vals.join("")}`; + } + vals.push("="); + } + + const items = []; + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + items.push(encodeComponent(val, reserved, op)); + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + if (!isDefined(value[key])) { + continue; + } + items.push(encodeRFC3986URIComponent(key)); + items.push(encodeComponent(value[key], reserved, op)); + } + } + vals.push(items.join(",")); + return !vals.join(",") ? undefined : `${first}${vals.join("")}`; +} + +function getVarValue(option: ValueOptions): string | undefined { + const { op, varName, modifier, isFirst, reserved, varValue: value } = option; + + if (!isDefined(value)) { + return undefined; + } else if (["string", "number", "boolean"].includes(typeof value)) { + let val = value.toString(); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + const vals: string[] = [getFirstOrSep(op, isFirst)]; + if (named && varName) { + // No need to encode varName considering it is already encoded + vals.push(varName); + if (val === "") { + vals.push(ifEmpty); + } else { + vals.push("="); + } + } + if (modifier && modifier !== "*") { + val = val.substring(0, parseInt(modifier, 10)); + } + vals.push(encodeComponent(val, reserved, op)); + return vals.join(""); + } else if (modifier === "*") { + return getExpandedValue(option); + } else { + return getNonExpandedValue(option); + } +} + +// --------------------------------------------------------------------------------------------------- +// This is an implementation of RFC 6570 URI Template: https://datatracker.ietf.org/doc/html/rfc6570. +// --------------------------------------------------------------------------------------------------- +export function expandUrlTemplate( + template: string, + context: Record, + option?: UrlTemplateOptions, +): string { + const result = template.replace(/\{([^{}]+)\}|([^{}]+)/g, (_, expr, text) => { + if (!expr) { + return encodeReservedComponent(text); + } + let op; + if (["+", "#", ".", "/", ";", "?", "&"].includes(expr[0])) { + op = expr[0]; + expr = expr.slice(1); + } + const varList = expr.split(/,/g); + const innerResult = []; + for (const varSpec of varList) { + const varMatch = /([^:*]*)(?::(\d+)|(\*))?/.exec(varSpec); + if (!varMatch || !varMatch[1]) { + continue; + } + const varValue = getVarValue({ + isFirst: innerResult.length === 0, + op, + varValue: context[varMatch[1]], + varName: varMatch[1], + modifier: varMatch[2] || varMatch[3], + reserved: option?.allowReserved, + }); + if (varValue) { + innerResult.push(varValue); + } + } + return innerResult.join(""); + }); + + return normalizeUnreserved(result); +} + +/** + * Normalize an expanded URI by decoding percent-encoded unreserved characters. + * RFC 3986 unreserved: "-" / "." / "~" + */ +function normalizeUnreserved(uri: string): string { + return uri.replace(/%([0-9A-Fa-f]{2})/g, (match, hex) => { + const char = String.fromCharCode(parseInt(hex, 16)); + // Decode only if it's unreserved + if (/[.~-]/.test(char)) { + return char; + } + return match; // leave other encodings intact + }); +} diff --git a/sdk/databoundaries/arm-databoundaries/test/snippets.spec.ts b/sdk/databoundaries/arm-databoundaries/test/snippets.spec.ts index 18b146521ace..584351a4e734 100644 --- a/sdk/databoundaries/arm-databoundaries/test/snippets.spec.ts +++ b/sdk/databoundaries/arm-databoundaries/test/snippets.spec.ts @@ -22,4 +22,4 @@ describe("snippets", () => { it("SetLogLevel", async () => { setLogLevel("info"); }); -}); \ No newline at end of file +}); diff --git a/sdk/databoundaries/arm-databoundaries/tsconfig.json b/sdk/databoundaries/arm-databoundaries/tsconfig.json index d466f1460665..0e57dbd186e5 100644 --- a/sdk/databoundaries/arm-databoundaries/tsconfig.json +++ b/sdk/databoundaries/arm-databoundaries/tsconfig.json @@ -12,6 +12,5 @@ { "path": "./tsconfig.snippets.json" } - ], - "files": [] + ] } diff --git a/sdk/databoundaries/arm-databoundaries/tsconfig.samples.json b/sdk/databoundaries/arm-databoundaries/tsconfig.samples.json index e8b99452c64b..5bb762594557 100644 --- a/sdk/databoundaries/arm-databoundaries/tsconfig.samples.json +++ b/sdk/databoundaries/arm-databoundaries/tsconfig.samples.json @@ -2,9 +2,7 @@ "extends": "../../../tsconfig.samples.base.json", "compilerOptions": { "paths": { - "@azure/arm-databoundaries": [ - "./dist/esm" - ] + "@azure/arm-databoundaries": ["./dist/esm"] } } } diff --git a/sdk/databoundaries/arm-databoundaries/tsp-location.yaml b/sdk/databoundaries/arm-databoundaries/tsp-location.yaml new file mode 100644 index 000000000000..a82bc64b85d1 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/resources/resource-manager/Microsoft.Resources/databoundaries +commit: 1b5aec77bb93b4b413676e6191a8fe5d9c8266da +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/databoundaries/arm-databoundaries/vitest.config.ts b/sdk/databoundaries/arm-databoundaries/vitest.config.ts index cc5cd85d4131..0dfa15cc4498 100644 --- a/sdk/databoundaries/arm-databoundaries/vitest.config.ts +++ b/sdk/databoundaries/arm-databoundaries/vitest.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. diff --git a/sdk/databoundaries/arm-databoundaries/vitest.esm.config.ts b/sdk/databoundaries/arm-databoundaries/vitest.esm.config.ts new file mode 100644 index 000000000000..5e9735e9b144 --- /dev/null +++ b/sdk/databoundaries/arm-databoundaries/vitest.esm.config.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { mergeConfig } from "vitest/config"; +import vitestConfig from "./vitest.config.ts"; +import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; + +export default mergeConfig(vitestConfig, vitestEsmConfig); diff --git a/sdk/databoundaries/arm-databoundaries/warp.config.yml b/sdk/databoundaries/arm-databoundaries/warp.config.yml index f90f8c2646b0..5ec3aceccd17 100644 --- a/sdk/databoundaries/arm-databoundaries/warp.config.yml +++ b/sdk/databoundaries/arm-databoundaries/warp.config.yml @@ -1,15 +1,26 @@ +# warp.config.yml — build configuration + exports: "./package.json": "./package.json" ".": "./src/index.ts" + "./api": "./src/api/index.ts" + "./api/dataBoundaries": "src/api/dataBoundaries/index.ts" + "./api/operations": "src/api/operations/index.ts" + "./models": "./src/models/index.ts" targets: - name: browser tsconfig: "../../../tsconfig.src.browser.json" + polyfillSuffix: "-browser" + - name: react-native tsconfig: "../../../tsconfig.src.react-native.json" + polyfillSuffix: "-react-native" + - name: esm condition: import tsconfig: "../../../tsconfig.src.esm.json" + - name: commonjs condition: require tsconfig: "../../../tsconfig.src.cjs.json" diff --git a/sdk/databoundaries/ci.mgmt.yml b/sdk/databoundaries/ci.mgmt.yml index b048e71665a9..964507a7fa1b 100644 --- a/sdk/databoundaries/ci.mgmt.yml +++ b/sdk/databoundaries/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/databoundaries/arm-databoundaries - sdk/databoundaries/ci.mgmt.yml - pr: branches: include: @@ -27,7 +26,6 @@ pr: include: - sdk/databoundaries/arm-databoundaries - sdk/databoundaries/ci.mgmt.yml - extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: @@ -35,4 +33,3 @@ extends: Artifacts: - name: azure-arm-databoundaries safeName: azurearmdataboundaries - \ No newline at end of file