diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index a13fa0192357..7bf6b934d3d1 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -100,6 +100,7 @@ specifiers: '@rush-temp/perf-storage-file-datalake': file:./projects/perf-storage-file-datalake.tgz '@rush-temp/perf-storage-file-share': file:./projects/perf-storage-file-share.tgz '@rush-temp/purview-account': file:./projects/purview-account.tgz + '@rush-temp/purview-administration': file:./projects/purview-administration.tgz '@rush-temp/purview-catalog': file:./projects/purview-catalog.tgz '@rush-temp/purview-scanning': file:./projects/purview-scanning.tgz '@rush-temp/quantum-jobs': file:./projects/quantum-jobs.tgz @@ -228,6 +229,7 @@ dependencies: '@rush-temp/perf-storage-file-datalake': file:projects/perf-storage-file-datalake.tgz '@rush-temp/perf-storage-file-share': file:projects/perf-storage-file-share.tgz '@rush-temp/purview-account': file:projects/purview-account.tgz + '@rush-temp/purview-administration': file:projects/purview-administration.tgz '@rush-temp/purview-catalog': file:projects/purview-catalog.tgz '@rush-temp/purview-scanning': file:projects/purview-scanning.tgz '@rush-temp/quantum-jobs': file:projects/quantum-jobs.tgz @@ -11595,6 +11597,52 @@ packages: - utf-8-validate dev: false + file:projects/purview-administration.tgz: + resolution: {integrity: sha512-rdQEVy2YorOtxN8HfvBymLYcB+CkH06b/w7Ye5LGRSr4dJ9PbbQgaWb1eLM97x8izbfCvXV5jnPCebNSVVV2ZQ==, tarball: file:projects/purview-administration.tgz} + name: '@rush-temp/purview-administration' + version: 0.0.0 + dependencies: + '@azure/identity': 1.5.2 + '@microsoft/api-extractor': 7.18.11 + '@types/chai': 4.2.22 + '@types/mocha': 7.0.2 + '@types/node': 12.20.27 + chai: 4.3.4 + cross-env: 7.0.3 + dotenv: 8.6.0 + eslint: 7.32.0 + karma: 6.3.4 + karma-chrome-launcher: 3.1.0 + karma-coverage: 2.0.3 + karma-edge-launcher: 0.4.2_karma@6.3.4 + karma-env-preprocessor: 0.1.1 + karma-firefox-launcher: 1.3.0 + karma-ie-launcher: 1.0.0_karma@6.3.4 + karma-json-preprocessor: 0.3.3_karma@6.3.4 + karma-json-to-file-reporter: 1.0.1 + karma-junit-reporter: 2.0.1_karma@6.3.4 + karma-mocha: 2.0.1 + karma-mocha-reporter: 2.2.5_karma@6.3.4 + karma-source-map-support: 1.4.0 + karma-sourcemap-loader: 0.3.8 + mkdirp: 1.0.4 + mocha: 7.2.0 + mocha-junit-reporter: 1.23.3_mocha@7.2.0 + nyc: 14.1.1 + prettier: 2.2.1 + rimraf: 3.0.2 + rollup: 1.32.1 + source-map-support: 0.5.20 + tslib: 2.3.1 + typedoc: 0.15.2 + typescript: 4.2.4 + transitivePeerDependencies: + - bufferutil + - debug + - supports-color + - utf-8-validate + dev: false + file:projects/purview-catalog.tgz: resolution: {integrity: sha512-3FMBNLShCDqvunEG+r39NKhWJgrdEAH8bu7BG6o7R1clrDjcIdF7A40KhzupbzNFVivid4XVBIZu3g+teRscNw==, tarball: file:projects/purview-catalog.tgz} name: '@rush-temp/purview-catalog' diff --git a/rush.json b/rush.json index 38e447589ca5..639be28d04be 100644 --- a/rush.json +++ b/rush.json @@ -341,6 +341,11 @@ "projectFolder": "sdk/purview/purview-account-rest", "versionPolicyName": "client" }, + { + "packageName": "@azure-rest/purview-administration", + "projectFolder": "sdk/purview/purview-administration-rest", + "versionPolicyName": "client" + }, { "packageName": "@azure-rest/purview-catalog", "projectFolder": "sdk/purview/purview-catalog-rest", @@ -952,4 +957,4 @@ "versionPolicyName": "management" } ] -} \ No newline at end of file +} diff --git a/sdk/purview/ci.yml b/sdk/purview/ci.yml index a6beeb5bccb6..01bb60da46aa 100644 --- a/sdk/purview/ci.yml +++ b/sdk/purview/ci.yml @@ -31,5 +31,7 @@ extends: safeName: azurerestpurviewscanning - name: azure-rest-purview-account safeName: azurerestpurviewaccount + - name: azure-rest-purview-administration + safeName: azurerestpurviewadministration - name: azure-arm-purview safeName: azurearmpurview diff --git a/sdk/purview/purview-administration-rest/.eslintrc.json b/sdk/purview/purview-administration-rest/.eslintrc.json new file mode 100644 index 000000000000..5a518cf360b5 --- /dev/null +++ b/sdk/purview/purview-administration-rest/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "plugins": ["@azure/azure-sdk"], + "extends": ["plugin:@azure/azure-sdk/azure-sdk-base"], + "rules": { + "@azure/azure-sdk/ts-package-json-engine-is-present": [ + "error", + { "nodeVersionOverride": ">=14.0.0" } + ] + } +} diff --git a/sdk/purview/purview-administration-rest/CHANGELOG.md b/sdk/purview/purview-administration-rest/CHANGELOG.md new file mode 100644 index 000000000000..2238faf06c29 --- /dev/null +++ b/sdk/purview/purview-administration-rest/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (UNRELEASED) + +- First release of package, see README.md for details. diff --git a/sdk/purview/purview-administration-rest/LICENSE b/sdk/purview/purview-administration-rest/LICENSE new file mode 100644 index 000000000000..2d3163745319 --- /dev/null +++ b/sdk/purview/purview-administration-rest/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/purview/purview-administration-rest/README.md b/sdk/purview/purview-administration-rest/README.md new file mode 100644 index 000000000000..ad434e355c08 --- /dev/null +++ b/sdk/purview/purview-administration-rest/README.md @@ -0,0 +1,147 @@ +# Azure Purview Administration REST client library for JavaScript + +Azure Purview data plane administration. It supports data plane operations. It can manage account, collections, keys, resource set rule, metadata policy, metadata roles. + +## Azure Purview Metadata Policies + +**Please rely heavily on the [service's documentation][account_product_documentation] and our [REST client docs][rest_client] to use this library** + +Key links: + +- [Source code][source_code] +- [Package (NPM)][account_npm] +- [API reference documentation][account_ref_docs] +- [Product documentation][account_product_documentation] + +## Getting started + +### Currently supported environments + +- Node.js version 14.x.x or higher + +### Prerequisites + +- You must have an [Azure subscription][azure_subscription] and a [Purview][purview_resource] to use this package. + +#### Create a Purview Resource + +Follow [these][purview_resource] instructions to create your Purview resource + +### Install the `@azure-rest/purview-account` package + +Install the Azure Purview Account client library for JavaScript with `npm`: + +```bash +npm install @azure-rest/purview-account +``` + +### Create and authenticate a `PurviewAccount` + +To use an [Azure Active Directory (AAD) token credential][authenticate_with_token], +provide an instance of the desired credential type obtained from the +[@azure/identity][azure_identity_credentials] library. + +To authenticate with AAD, you must first `npm` install [`@azure/identity`][azure_identity_npm] and +[enable AAD authentication on your Purview resource][enable_aad] + +After setup, you can choose which type of [credential][azure_identity_credentials] from `@azure/identity` to use. +As an example, [DefaultAzureCredential][default_azure_credential] +can be used to authenticate the client: + +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 + +Use the returned token credential to authenticate the client: + +```typescript +import { + PurviewAccountClient, + PurviewMetadataPoliciesClient, +} from "@azure-rest/purview-administration"; +import { DefaultAzureCredential } from "@azure/identity"; +const accountClient = PurviewAccountClient( + "https://.purview.azure.com", + new DefaultAzureCredential() +); + +const metadataClient = PurviewAccountClient( + "https://.purview.azure.com", + new DefaultAzureCredential() +); +``` + +## Key concepts + +### REST Client + +This client is one of our REST clients. We highly recommend you read how to use a REST client [here][rest_client]. + +## Examples + +The following section shows you how to initialize and authenticate your client, then get all of your type-defs. + +- [Get A List of Collections](#get-a-list-of-collections "Get A List of Collections") + +```typescript +import { PurviewAccountClient } from "@azure-rest/purview-administration"; +import { DefaultAzureCredential } from "@azure/identity"; +import dotenv from "dotenv"; + +dotenv.config(); + +const endpoint = process.env["ENDPOINT"] || ""; + +async function main() { + console.log("== List collections sample =="); + const client = PurviewAccountClient(endpoint, new DefaultAzureCredential()); + + const response = await client.path("/collections").get(); + + if (response.status !== "200") { + console.log(`GET "/collections" failed with ${response.status}`); + } + + console.log(response.body); +} + +main().catch(console.error); +``` + +## Troubleshooting + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: + +```javascript +import { setLogLevel } from "@azure/logger"; + +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). + +## Next steps + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. + +## Related projects + +- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fpurview%2Fpurview-account-rest%2FREADME.png) + +[account_product_documentation]: https://azure.microsoft.com/services/purview/ +[rest_client]: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md +[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/purview/purview-catalog-rest +[account_npm]: https://www.npmjs.com/org/azure-rest +[account_ref_docs]: https://azure.github.io/azure-sdk-for-js +[azure_subscription]: https://azure.microsoft.com/free/ +[purview_resource]: https://docs.microsoft.com/azure/purview/create-catalog-portal +[authenticate_with_token]: https://docs.microsoft.com/azure/purview/tutorial-using-rest-apis#create-a-service-principal-application +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials +[azure_identity_npm]: https://www.npmjs.com/package/@azure/identity +[enable_aad]: https://docs.microsoft.com/azure/purview/create-catalog-portal#add-a-security-principal-to-a-data-plane-role +[default_azure_credential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential diff --git a/sdk/purview/purview-administration-rest/api-extractor.json b/sdk/purview/purview-administration-rest/api-extractor.json new file mode 100644 index 000000000000..41f6d1502ecb --- /dev/null +++ b/sdk/purview/purview-administration-rest/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "types/src/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/purview-administration-rest.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} diff --git a/sdk/purview/purview-administration-rest/karma.conf.js b/sdk/purview/purview-administration-rest/karma.conf.js new file mode 100644 index 000000000000..6f3632a5ce59 --- /dev/null +++ b/sdk/purview/purview-administration-rest/karma.conf.js @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// https://github.com/karma-runner/karma-chrome-launcher +process.env.CHROME_BIN = require("puppeteer").executablePath(); +require("dotenv").config(); +const { + jsonRecordingFilterFunction, + isPlaybackMode, + isSoftRecordMode, + isRecordMode, +} = require("@azure-tools/test-recorder"); + +module.exports = function (config) { + config.set({ + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: "./", + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ["source-map-support", "mocha"], + + plugins: [ + "karma-mocha", + "karma-mocha-reporter", + "karma-chrome-launcher", + "karma-edge-launcher", + "karma-firefox-launcher", + "karma-ie-launcher", + "karma-env-preprocessor", + "karma-coverage", + "karma-sourcemap-loader", + "karma-junit-reporter", + "karma-json-to-file-reporter", + "karma-source-map-support", + "karma-json-preprocessor", + ], + + // list of files / patterns to load in the browser + files: [ + "dist-test/index.browser.js", + { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true }, + ].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []), + + // list of files / patterns to exclude + exclude: [], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + "**/*.js": ["sourcemap", "env"], + "recordings/browsers/**/*.json": ["json"], + // IMPORTANT: COMMENT following line if you want to debug in your browsers!! + // Preprocess source file to calculate code coverage, however this will make source file unreadable + // "dist-test/index.js": ["coverage"] + }, + + envPreprocessor: [ + "TEST_MODE", + "ENDPOINT", + "AZURE_CLIENT_SECRET", + "AZURE_CLIENT_ID", + "AZURE_TENANT_ID", + ], + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ["mocha", "coverage", "junit", "json-to-file"], + + coverageReporter: { + // specify a common output directory + dir: "coverage-browser/", + reporters: [ + { type: "json", subdir: ".", file: "coverage.json" }, + { type: "lcovonly", subdir: ".", file: "lcov.info" }, + { type: "html", subdir: "html" }, + { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, + ], + }, + + junitReporter: { + outputDir: "", // results will be saved as $outputDir/$browserName.xml + outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile + suite: "", // suite will become the package name attribute in xml testsuite element + useBrowserName: false, // add browser name to report and classes names + nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element + classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element + properties: {}, // key value pair of properties to add to the section of the report + }, + + jsonToFileReporter: { + filter: jsonRecordingFilterFunction, + outputPath: ".", + }, + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: false, + + // --no-sandbox allows our tests to run in Linux without having to change the system. + // --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex. + browsers: ["ChromeHeadlessNoSandbox"], + customLaunchers: { + ChromeHeadlessNoSandbox: { + base: "ChromeHeadless", + flags: ["--no-sandbox", "--disable-web-security"], + }, + }, + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: 1, + + browserNoActivityTimeout: 60000000, + browserDisconnectTimeout: 10000, + browserDisconnectTolerance: 3, + browserConsoleLogOptions: { + terminal: !isRecordMode(), + }, + + client: { + mocha: { + // change Karma's debug.html to the mocha web reporter + reporter: "html", + timeout: "600000", + }, + }, + }); +}; diff --git a/sdk/purview/purview-administration-rest/package.json b/sdk/purview/purview-administration-rest/package.json new file mode 100644 index 000000000000..8b90f44a07eb --- /dev/null +++ b/sdk/purview/purview-administration-rest/package.json @@ -0,0 +1,130 @@ +{ + "name": "@azure-rest/purview-administration", + "sdk-type": "client", + "author": "Microsoft Corporation", + "description": "An isomorphic rest level client library for the Azure Purview Administration services.", + "version": "1.0.0-beta.1", + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/purview-administration-rest.d.ts", + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/purview/purview-administration-rest/README.md", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/", + "dist-esm/src/", + "types/purview-administration-rest.d.ts", + "README.md", + "LICENSE" + ], + "engines": { + "node": ">=14.0.0" + }, + "//metadata": { + "constantPaths": [ + { + "path": "swagger/README.md", + "prefix": "package-version" + } + ] + }, + "//sampleConfiguration": { + "productName": "Azure Purview Administration rest", + "productSlugs": [ + "azure" + ], + "requiredResources": { + "Azure Purview instance": "https://docs.microsoft.com/azure/purview/create-catalog-portal" + } + }, + "browser": { + "./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js" + }, + "scripts": { + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "regenerate": "autorest --typescript swagger/README.md && npm run format", + "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1", + "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1", + "build:samples": "echo Obsolete.", + "build:test": "tsc -p . && rollup -c 2>&1", + "build": "npm run clean && tsc -p . && rollup -c 2>&1 && mkdirp ./review && api-extractor run --local", + "build:debug": "tsc -p . && rollup -c 2>&1 && api-extractor run --local", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", + "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "execute:samples": "dev-tool samples run samples-dev", + "extract-api": "rimraf review && mkdirp ./review && api-extractor run --local", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", + "integration-test:browser": "karma start --single-run", + "integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace \"dist-esm/test/{,!(browser)/**/}*.spec.js\"", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]", + "lint": "eslint package.json api-extractor.json src test --ext .ts", + "pack": "npm pack 2>&1", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", + "test:node": "npm run clean && npm run build:test && npm run unit-test:node", + "test": "npm run clean && npm run build:test && npm run unit-test", + "unit-test:browser": "karma start --single-run", + "unit-test:node": "cross-env mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "docs": "typedoc --excludePrivate --excludeExternals --out ./dist/docs ./src" + }, + "sideEffects": false, + "autoPublish": false, + "dependencies": { + "@azure/core-paging": "^1.1.1", + "@azure/core-auth": "^1.3.0", + "@azure-rest/core-client": "1.0.0-beta.7", + "@azure/core-rest-pipeline": "^1.1.0", + "@azure/logger": "^1.0.0", + "tslib": "^2.2.0" + }, + "devDependencies": { + "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@azure/identity": "^1.1.0", + "@azure-tools/test-recorder": "^1.0.0", + "@microsoft/api-extractor": "^7.18.0", + "@types/chai": "^4.1.6", + "@types/mocha": "^7.0.2", + "@types/node": "^12.0.0", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "dotenv": "^8.2.0", + "eslint": "^7.15.0", + "karma-chrome-launcher": "^3.0.0", + "karma-coverage": "^2.0.0", + "karma-edge-launcher": "^0.4.2", + "karma-env-preprocessor": "^0.1.1", + "karma-firefox-launcher": "^1.1.0", + "karma-ie-launcher": "^1.0.0", + "karma-json-preprocessor": "^0.3.3", + "karma-json-to-file-reporter": "^1.0.1", + "karma-junit-reporter": "^2.0.1", + "karma-mocha-reporter": "^2.2.5", + "karma-mocha": "^2.0.1", + "karma-source-map-support": "~1.4.0", + "karma-sourcemap-loader": "^0.3.8", + "karma": "^6.2.0", + "mkdirp": "^1.0.4", + "mocha-junit-reporter": "^1.18.0", + "mocha": "^7.1.1", + "nyc": "^14.0.0", + "prettier": "2.2.1", + "rimraf": "^3.0.0", + "rollup": "^1.16.3", + "source-map-support": "^0.5.9", + "typedoc": "0.15.2", + "typescript": "~4.2.0" + } +} diff --git a/sdk/purview/purview-administration-rest/recordings/browsers/get_account_info/recording_should_get_the_account_info.json b/sdk/purview/purview-administration-rest/recordings/browsers/get_account_info/recording_should_get_the_account_info.json new file mode 100644 index 000000000000..298695f11574 --- /dev/null +++ b/sdk/purview/purview-administration-rest/recordings/browsers/get_account_info/recording_should_get_the_account_info.json @@ -0,0 +1,51 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token", + "query": {}, + "requestBody": "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fsanitized%2F", + "status": 200, + "response": "{\"token_type\":\"Bearer\",\"expires_in\":86399,\"ext_expires_in\":86399,\"access_token\":\"access_token\"}", + "responseHeaders": { + "cache-control": "no-store, no-cache", + "content-length": "1318", + "content-type": "application/json; charset=utf-8", + "date": "Wed, 29 Sep 2021 19:26:00 GMT", + "expires": "-1", + "nel": "{\"report_to\":\"network-errors\",\"max_age\":86400,\"success_fraction\":0.001,\"failure_fraction\":1.0}", + "p3p": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"", + "pragma": "no-cache", + "referrer-policy": "strict-origin-when-cross-origin", + "report-to": "{\"group\":\"network-errors\",\"max_age\":86400,\"endpoints\":[{\"url\":\"https://identity.nel.measure.office.net/api/report?catId=GW+estsfd+dms\"}]}", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-ms-ests-server": "2.1.12071.23 - EUS ProdSlices", + "x-ms-request-id": "53e1e5e1-6704-4abf-a639-db5fd91d0400" + } + }, + { + "method": "GET", + "url": "https://endpoint/", + "query": { + "api-version": "2019-11-01-preview" + }, + "requestBody": null, + "status": 200, + "response": "{\"sku\":{\"name\":\"Standard\",\"capacity\":1},\"properties\":{\"cloudConnectors\":{\"awsExternalId\":\"2c7d73eb-7327-4166-b30c-96167c7b7271\"},\"friendlyName\":\"newpurviewllc\",\"createdBy\":\"joheredi@microsoft.com\",\"createdByObjectId\":\"35ac9d32-a8ca-4324-9393-d4000746f07c\",\"createdAt\":\"2021-09-29T18:35:18.4761382Z\",\"endpoints\":{\"catalog\":\"https://endpoint/catalog\",\"scan\":\"https://endpoint/scan\",\"guardian\":\"https://endpoint/guardian\"},\"provisioningState\":\"Succeeded\",\"privateEndpointConnections\":[],\"managedResources\":{\"resourceGroup\":\"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/managed-rg-newpurviewllc\",\"storageAccount\":\"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/managed-rg-newpurviewllc/providers/Microsoft.Storage/storageAccounts/scaneastusopeznna\",\"eventHubNamespace\":\"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/managed-rg-newpurviewllc/providers/Microsoft.EventHub/namespaces/Atlas-169658be-bf24-44f9-9873-fd914892a4f6\"},\"publicNetworkAccess\":\"Enabled\",\"managedResourceGroupName\":\"managed-rg-newpurviewllc\"},\"id\":\"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/joheredi-test/providers/Microsoft.Purview/accounts/newpurviewllc\",\"name\":\"newpurviewllc\",\"type\":\"Microsoft.Purview/accounts\",\"location\":\"eastus\",\"identity\":{\"type\":\"SystemAssigned\",\"principalId\":\"cb046a1b-cf5b-4a43-b188-322568afb9d4\",\"tenantId\":\"88888888-8888-8888-8888-888888888888\"},\"tags\":{},\"systemData\":{\"createdBy\":\"joheredi@microsoft.com\",\"createdByType\":\"User\",\"createdAt\":\"2021-09-29T18:35:18.4761382Z\",\"lastModifiedBy\":\"joheredi@microsoft.com\",\"lastModifiedByType\":\"User\",\"lastModifiedAt\":\"2021-09-29T18:35:18.4761382Z\"}}", + "responseHeaders": { + "content-type": "application/json; charset=utf-8", + "date": "Wed, 29 Sep 2021 19:26:01 GMT", + "server": "Kestrel", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-account-status": "Succeeded", + "x-ms-correlation-request-id": "8bb375f2-df12-4674-b0e9-85439f56d9cf" + } + } + ], + "uniqueTestInfo": { + "uniqueName": {}, + "newDate": {} + }, + "hash": "03d082a1f2749c5f4c764dde8022fba8" +} \ No newline at end of file diff --git a/sdk/purview/purview-administration-rest/recordings/browsers/list_collections/recording_should_list_all_available_collections.json b/sdk/purview/purview-administration-rest/recordings/browsers/list_collections/recording_should_list_all_available_collections.json new file mode 100644 index 000000000000..aa54282a1997 --- /dev/null +++ b/sdk/purview/purview-administration-rest/recordings/browsers/list_collections/recording_should_list_all_available_collections.json @@ -0,0 +1,50 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token", + "query": {}, + "requestBody": "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fsanitized%2F", + "status": 200, + "response": "{\"token_type\":\"Bearer\",\"expires_in\":86399,\"ext_expires_in\":86399,\"access_token\":\"access_token\"}", + "responseHeaders": { + "cache-control": "no-store, no-cache", + "content-length": "1318", + "content-type": "application/json; charset=utf-8", + "date": "Wed, 29 Sep 2021 19:26:01 GMT", + "expires": "-1", + "nel": "{\"report_to\":\"network-errors\",\"max_age\":86400,\"success_fraction\":0.001,\"failure_fraction\":1.0}", + "p3p": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"", + "pragma": "no-cache", + "referrer-policy": "strict-origin-when-cross-origin", + "report-to": "{\"group\":\"network-errors\",\"max_age\":86400,\"endpoints\":[{\"url\":\"https://identity.nel.measure.office.net/api/report?catId=GW+estsfd+dms\"}]}", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-ms-ests-server": "2.1.12071.23 - SCUS ProdSlices", + "x-ms-request-id": "06c0c04b-f3c4-4e15-8d74-0639214f0800" + } + }, + { + "method": "GET", + "url": "https://endpoint/collections", + "query": { + "api-version": "2019-11-01-preview" + }, + "requestBody": null, + "status": 200, + "response": "{\"value\":[{\"name\":\"newpurviewllc\",\"friendlyName\":\"newpurviewllc\",\"description\":\"The root collection.\",\"systemData\":{\"createdBy\":\"35ac9d32-a8ca-4324-9393-d4000746f07c\",\"createdByType\":\"User\",\"createdAt\":\"2021-09-29T18:35:18.4761382Z\",\"lastModifiedBy\":\"35ac9d32-a8ca-4324-9393-d4000746f07c\",\"lastModifiedByType\":\"User\",\"lastModifiedAt\":\"2021-09-29T18:35:18.4761382Z\"},\"collectionProvisioningState\":\"Succeeded\"},{\"name\":\"la7eio\",\"friendlyName\":\"Foo\",\"description\":\"Test foo\",\"parentCollection\":{\"type\":\"CollectionReference\",\"referenceName\":\"newpurviewllc\"},\"systemData\":{\"createdBy\":\"35ac9d32-a8ca-4324-9393-d4000746f07c\",\"createdByType\":\"User\",\"createdAt\":\"2021-09-29T18:40:02.8364266Z\",\"lastModifiedBy\":\"35ac9d32-a8ca-4324-9393-d4000746f07c\",\"lastModifiedByType\":\"User\",\"lastModifiedAt\":\"2021-09-29T18:40:02.8364266Z\"},\"collectionProvisioningState\":\"Succeeded\"}],\"count\":2}", + "responseHeaders": { + "content-type": "application/json; charset=utf-8", + "date": "Wed, 29 Sep 2021 19:26:01 GMT", + "server": "Kestrel", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-correlation-request-id": "9451f361-5cc7-40eb-82ef-e3e79572e8f6" + } + } + ], + "uniqueTestInfo": { + "uniqueName": {}, + "newDate": {} + }, + "hash": "8621a4bca85ac35362a59cc9339b7f2a" +} \ No newline at end of file diff --git a/sdk/purview/purview-administration-rest/recordings/browsers/list_metadata/recording_should_list_all_available_metdatapolicies.json b/sdk/purview/purview-administration-rest/recordings/browsers/list_metadata/recording_should_list_all_available_metdatapolicies.json new file mode 100644 index 000000000000..3eb61305d9e5 --- /dev/null +++ b/sdk/purview/purview-administration-rest/recordings/browsers/list_metadata/recording_should_list_all_available_metdatapolicies.json @@ -0,0 +1,52 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token", + "query": {}, + "requestBody": "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fsanitized%2F", + "status": 200, + "response": "{\"token_type\":\"Bearer\",\"expires_in\":86399,\"ext_expires_in\":86399,\"access_token\":\"access_token\"}", + "responseHeaders": { + "cache-control": "no-store, no-cache", + "content-length": "1318", + "content-type": "application/json; charset=utf-8", + "date": "Wed, 29 Sep 2021 19:26:01 GMT", + "expires": "-1", + "nel": "{\"report_to\":\"network-errors\",\"max_age\":86400,\"success_fraction\":0.001,\"failure_fraction\":1.0}", + "p3p": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"", + "pragma": "no-cache", + "referrer-policy": "strict-origin-when-cross-origin", + "report-to": "{\"group\":\"network-errors\",\"max_age\":86400,\"endpoints\":[{\"url\":\"https://identity.nel.measure.office.net/api/report?catId=GW+estsfd+dms\"}]}", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-ms-ests-server": "2.1.12071.23 - SCUS ProdSlices", + "x-ms-request-id": "42816b71-3d53-481e-a425-abd364cc0800" + } + }, + { + "method": "GET", + "url": "https://endpoint/policyStore/metadataPolicies", + "query": { + "api-version": "2021-07-01" + }, + "requestBody": null, + "status": 200, + "response": "{\"values\":[{\"name\":\"policy_newpurviewllc\",\"id\":\"a4362b7c-071a-4e95-a68d-1d7ced1d3a43\",\"version\":4,\"properties\":{\"description\":\"\",\"decisionRules\":[{\"kind\":\"decisionrule\",\"effect\":\"Permit\",\"dnfCondition\":[[{\"attributeName\":\"resource.purview.collection\",\"attributeValueIncludes\":\"newpurviewllc\"},{\"fromRule\":\"permission:newpurviewllc\",\"attributeName\":\"derived.purview.permission\",\"attributeValueIncludes\":\"permission:newpurviewllc\"}]]}],\"attributeRules\":[{\"kind\":\"attributerule\",\"id\":\"purviewmetadatarole_builtin_collection-administrator:newpurviewllc\",\"name\":\"purviewmetadatarole_builtin_collection-administrator:newpurviewllc\",\"dnfCondition\":[[{\"attributeName\":\"principal.microsoft.id\",\"attributeValueIncludedIn\":[\"35ac9d32-a8ca-4324-9393-d4000746f07c\",\"f8cfe8ca-1f83-4deb-814c-ee49336fdebd\"]},{\"fromRule\":\"purviewmetadatarole_builtin_collection-administrator\",\"attributeName\":\"derived.purview.role\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_collection-administrator\"}]]},{\"kind\":\"attributerule\",\"id\":\"purviewmetadatarole_builtin_purview-reader:newpurviewllc\",\"name\":\"purviewmetadatarole_builtin_purview-reader:newpurviewllc\",\"dnfCondition\":[[{\"attributeName\":\"principal.microsoft.id\",\"attributeValueIncludedIn\":[\"35ac9d32-a8ca-4324-9393-d4000746f07c\",\"f8cfe8ca-1f83-4deb-814c-ee49336fdebd\"]},{\"fromRule\":\"purviewmetadatarole_builtin_purview-reader\",\"attributeName\":\"derived.purview.role\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_purview-reader\"}]]},{\"kind\":\"attributerule\",\"id\":\"purviewmetadatarole_builtin_data-curator:newpurviewllc\",\"name\":\"purviewmetadatarole_builtin_data-curator:newpurviewllc\",\"dnfCondition\":[[{\"attributeName\":\"principal.microsoft.id\",\"attributeValueIncludedIn\":[\"35ac9d32-a8ca-4324-9393-d4000746f07c\",\"f8cfe8ca-1f83-4deb-814c-ee49336fdebd\"]},{\"fromRule\":\"purviewmetadatarole_builtin_data-curator\",\"attributeName\":\"derived.purview.role\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_data-curator\"}]]},{\"kind\":\"attributerule\",\"id\":\"purviewmetadatarole_builtin_data-source-administrator:newpurviewllc\",\"name\":\"purviewmetadatarole_builtin_data-source-administrator:newpurviewllc\",\"dnfCondition\":[[{\"attributeName\":\"principal.microsoft.id\",\"attributeValueIncludedIn\":[\"35ac9d32-a8ca-4324-9393-d4000746f07c\",\"f8cfe8ca-1f83-4deb-814c-ee49336fdebd\"]},{\"fromRule\":\"purviewmetadatarole_builtin_data-source-administrator\",\"attributeName\":\"derived.purview.role\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_data-source-administrator\"}]]},{\"kind\":\"attributerule\",\"id\":\"permission:newpurviewllc\",\"name\":\"permission:newpurviewllc\",\"dnfCondition\":[[{\"fromRule\":\"purviewmetadatarole_builtin_collection-administrator:newpurviewllc\",\"attributeName\":\"derived.purview.permission\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_collection-administrator:newpurviewllc\"}],[{\"fromRule\":\"purviewmetadatarole_builtin_purview-reader:newpurviewllc\",\"attributeName\":\"derived.purview.permission\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_purview-reader:newpurviewllc\"}],[{\"fromRule\":\"purviewmetadatarole_builtin_data-curator:newpurviewllc\",\"attributeName\":\"derived.purview.permission\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_data-curator:newpurviewllc\"}],[{\"fromRule\":\"purviewmetadatarole_builtin_data-source-administrator:newpurviewllc\",\"attributeName\":\"derived.purview.permission\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_data-source-administrator:newpurviewllc\"}]]}],\"collection\":{\"type\":\"CollectionReference\",\"referenceName\":\"newpurviewllc\"}}},{\"name\":\"policy_la7eio\",\"id\":\"88ce2dc3-3573-4c9a-8111-14fc9bc548b4\",\"version\":1,\"properties\":{\"description\":\"\",\"decisionRules\":[{\"kind\":\"decisionrule\",\"effect\":\"Permit\",\"dnfCondition\":[[{\"attributeName\":\"resource.purview.collection\",\"attributeValueIncludes\":\"la7eio\"},{\"fromRule\":\"permission:la7eio\",\"attributeName\":\"derived.purview.permission\",\"attributeValueIncludes\":\"permission:la7eio\"}]]}],\"attributeRules\":[{\"kind\":\"attributerule\",\"id\":\"purviewmetadatarole_builtin_collection-administrator:la7eio\",\"name\":\"purviewmetadatarole_builtin_collection-administrator:la7eio\",\"dnfCondition\":[[{\"attributeName\":\"principal.microsoft.id\",\"attributeValueIncludedIn\":[\"f8cfe8ca-1f83-4deb-814c-ee49336fdebd\"]},{\"fromRule\":\"purviewmetadatarole_builtin_collection-administrator\",\"attributeName\":\"derived.purview.role\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_collection-administrator\"}],[{\"fromRule\":\"purviewmetadatarole_builtin_collection-administrator:newpurviewllc\",\"attributeName\":\"derived.purview.permission\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_collection-administrator:newpurviewllc\"}]]},{\"kind\":\"attributerule\",\"id\":\"permission:la7eio\",\"name\":\"permission:la7eio\",\"dnfCondition\":[[{\"fromRule\":\"purviewmetadatarole_builtin_collection-administrator:la7eio\",\"attributeName\":\"derived.purview.permission\",\"attributeValueIncludes\":\"purviewmetadatarole_builtin_collection-administrator:la7eio\"}],[{\"fromRule\":\"permission:newpurviewllc\",\"attributeName\":\"derived.purview.permission\",\"attributeValueIncludes\":\"permission:newpurviewllc\"}]]}],\"collection\":{\"type\":\"CollectionReference\",\"referenceName\":\"la7eio\"},\"parentCollectionName\":\"newpurviewllc\"}}]}", + "responseHeaders": { + "api-supported-versions": "2021-07-01", + "content-length": "5197", + "content-type": "application/json; charset=utf-8", + "date": "Wed, 29 Sep 2021 19:26:01 GMT", + "server": "Kestrel", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-ms-correlation-request-id": "0ac4304b-3180-45ba-b34b-8084cb4e71d5" + } + } + ], + "uniqueTestInfo": { + "uniqueName": {}, + "newDate": {} + }, + "hash": "a2c9182786497c58377f858d8a709c57" +} \ No newline at end of file diff --git a/sdk/purview/purview-administration-rest/recordings/node/get_account_info/recording_should_get_the_account_info.js b/sdk/purview/purview-administration-rest/recordings/node/get_account_info/recording_should_get_the_account_info.js new file mode 100644 index 000000000000..bdd431586500 --- /dev/null +++ b/sdk/purview/purview-administration-rest/recordings/node/get_account_info/recording_should_get_the_account_info.js @@ -0,0 +1,58 @@ +let nock = require('nock'); + +module.exports.hash = "2ff3b5a65daf079dc2f7d73b5d58f0de"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fsanitized%2F") + .reply(200, {"token_type":"Bearer","expires_in":86399,"ext_expires_in":86399,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '30de26ae-aea3-4b3c-8a27-cd0d537b1d00', + 'x-ms-ests-server', + '2.1.12071.23 - WUS2 ProdSlices', + 'Set-Cookie', + 'fpc=Amchb9QCC5BCnrTsTeEbCSv__1r8AQAAAL-05tgOAAAA; expires=Fri, 29-Oct-2021 19:25:52 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 29 Sep 2021 19:25:52 GMT', + 'Content-Length', + '1318' +]); + +nock('https://endpoint', {"encodedQueryParams":true}) + .get('/') + .query(true) + .reply(200, {"sku":{"name":"Standard","capacity":1},"properties":{"cloudConnectors":{"awsExternalId":"2c7d73eb-7327-4166-b30c-96167c7b7271"},"friendlyName":"newpurviewllc","createdBy":"joheredi@microsoft.com","createdByObjectId":"35ac9d32-a8ca-4324-9393-d4000746f07c","createdAt":"2021-09-29T18:35:18.4761382Z","endpoints":{"catalog":"https://endpoint/catalog","scan":"https://endpoint/scan","guardian":"https://endpoint/guardian"},"provisioningState":"Succeeded","privateEndpointConnections":[],"managedResources":{"resourceGroup":"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/managed-rg-newpurviewllc","storageAccount":"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/managed-rg-newpurviewllc/providers/Microsoft.Storage/storageAccounts/scaneastusopeznna","eventHubNamespace":"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/managed-rg-newpurviewllc/providers/Microsoft.EventHub/namespaces/Atlas-169658be-bf24-44f9-9873-fd914892a4f6"},"publicNetworkAccess":"Enabled","managedResourceGroupName":"managed-rg-newpurviewllc"},"id":"/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/joheredi-test/providers/Microsoft.Purview/accounts/newpurviewllc","name":"newpurviewllc","type":"Microsoft.Purview/accounts","location":"eastus","identity":{"type":"SystemAssigned","principalId":"cb046a1b-cf5b-4a43-b188-322568afb9d4","tenantId":"88888888-8888-8888-8888-888888888888"},"tags":{},"systemData":{"createdBy":"joheredi@microsoft.com","createdByType":"User","createdAt":"2021-09-29T18:35:18.4761382Z","lastModifiedBy":"joheredi@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2021-09-29T18:35:18.4761382Z"}}, [ + 'Date', + 'Wed, 29 Sep 2021 19:25:52 GMT', + 'Content-Type', + 'application/json; charset=utf-8', + 'Server', + 'Kestrel', + 'Transfer-Encoding', + 'chunked', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'x-ms-correlation-request-id', + '4eee233c-08a5-400c-9dc7-0d1a28bc6bc0', + 'x-ms-account-status', + 'Succeeded' +]); diff --git a/sdk/purview/purview-administration-rest/recordings/node/list_collections/recording_should_list_all_available_collections.js b/sdk/purview/purview-administration-rest/recordings/node/list_collections/recording_should_list_all_available_collections.js new file mode 100644 index 000000000000..567d4d88b7cf --- /dev/null +++ b/sdk/purview/purview-administration-rest/recordings/node/list_collections/recording_should_list_all_available_collections.js @@ -0,0 +1,56 @@ +let nock = require('nock'); + +module.exports.hash = "a47c9da37783992c50b69300fbc277f4"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fsanitized%2F") + .reply(200, {"token_type":"Bearer","expires_in":86399,"ext_expires_in":86399,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '3bbf0f5f-c50f-432d-a12e-05abb7240600', + 'x-ms-ests-server', + '2.1.12071.23 - NCUS ProdSlices', + 'Set-Cookie', + 'fpc=Ap5X-pE32ltKgODv9RJHp7E; expires=Fri, 29-Oct-2021 19:25:53 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 29 Sep 2021 19:25:52 GMT', + 'Content-Length', + '1318' +]); + +nock('https://endpoint', {"encodedQueryParams":true}) + .get('/collections') + .query(true) + .reply(200, {"value":[{"name":"newpurviewllc","friendlyName":"newpurviewllc","description":"The root collection.","systemData":{"createdBy":"35ac9d32-a8ca-4324-9393-d4000746f07c","createdByType":"User","createdAt":"2021-09-29T18:35:18.4761382Z","lastModifiedBy":"35ac9d32-a8ca-4324-9393-d4000746f07c","lastModifiedByType":"User","lastModifiedAt":"2021-09-29T18:35:18.4761382Z"},"collectionProvisioningState":"Succeeded"},{"name":"la7eio","friendlyName":"Foo","description":"Test foo","parentCollection":{"type":"CollectionReference","referenceName":"newpurviewllc"},"systemData":{"createdBy":"35ac9d32-a8ca-4324-9393-d4000746f07c","createdByType":"User","createdAt":"2021-09-29T18:40:02.8364266Z","lastModifiedBy":"35ac9d32-a8ca-4324-9393-d4000746f07c","lastModifiedByType":"User","lastModifiedAt":"2021-09-29T18:40:02.8364266Z"},"collectionProvisioningState":"Succeeded"}],"count":2}, [ + 'Date', + 'Wed, 29 Sep 2021 19:25:52 GMT', + 'Content-Type', + 'application/json; charset=utf-8', + 'Server', + 'Kestrel', + 'Transfer-Encoding', + 'chunked', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'x-ms-correlation-request-id', + '681c41a4-33f0-4c7d-8f92-6e43044d4732' +]); diff --git a/sdk/purview/purview-administration-rest/recordings/node/list_metadata/recording_should_list_all_available_metdatapolicies.js b/sdk/purview/purview-administration-rest/recordings/node/list_metadata/recording_should_list_all_available_metdatapolicies.js new file mode 100644 index 000000000000..8c58e41ad8b2 --- /dev/null +++ b/sdk/purview/purview-administration-rest/recordings/node/list_metadata/recording_should_list_all_available_metdatapolicies.js @@ -0,0 +1,58 @@ +let nock = require('nock'); + +module.exports.hash = "40459afcf596f53026872b296e2d98f8"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fsanitized%2F") + .reply(200, {"token_type":"Bearer","expires_in":86399,"ext_expires_in":86399,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + 'a0425497-5a69-4cb3-8e73-de1d700d0400', + 'x-ms-ests-server', + '2.1.12071.23 - EUS ProdSlices', + 'Set-Cookie', + 'fpc=AqGUTv6Wpn9NujfnawRWQEv__1r8AQAAAMG05tgOAAAA; expires=Fri, 29-Oct-2021 19:25:53 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 29 Sep 2021 19:25:53 GMT', + 'Content-Length', + '1318' +]); + +nock('https://endpoint', {"encodedQueryParams":true}) + .get('/policyStore/metadataPolicies') + .query(true) + .reply(200, {"values":[{"name":"policy_newpurviewllc","id":"a4362b7c-071a-4e95-a68d-1d7ced1d3a43","version":4,"properties":{"description":"","decisionRules":[{"kind":"decisionrule","effect":"Permit","dnfCondition":[[{"attributeName":"resource.purview.collection","attributeValueIncludes":"newpurviewllc"},{"fromRule":"permission:newpurviewllc","attributeName":"derived.purview.permission","attributeValueIncludes":"permission:newpurviewllc"}]]}],"attributeRules":[{"kind":"attributerule","id":"purviewmetadatarole_builtin_collection-administrator:newpurviewllc","name":"purviewmetadatarole_builtin_collection-administrator:newpurviewllc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["35ac9d32-a8ca-4324-9393-d4000746f07c","f8cfe8ca-1f83-4deb-814c-ee49336fdebd"]},{"fromRule":"purviewmetadatarole_builtin_collection-administrator","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_collection-administrator"}]]},{"kind":"attributerule","id":"purviewmetadatarole_builtin_purview-reader:newpurviewllc","name":"purviewmetadatarole_builtin_purview-reader:newpurviewllc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["35ac9d32-a8ca-4324-9393-d4000746f07c","f8cfe8ca-1f83-4deb-814c-ee49336fdebd"]},{"fromRule":"purviewmetadatarole_builtin_purview-reader","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_purview-reader"}]]},{"kind":"attributerule","id":"purviewmetadatarole_builtin_data-curator:newpurviewllc","name":"purviewmetadatarole_builtin_data-curator:newpurviewllc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["35ac9d32-a8ca-4324-9393-d4000746f07c","f8cfe8ca-1f83-4deb-814c-ee49336fdebd"]},{"fromRule":"purviewmetadatarole_builtin_data-curator","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_data-curator"}]]},{"kind":"attributerule","id":"purviewmetadatarole_builtin_data-source-administrator:newpurviewllc","name":"purviewmetadatarole_builtin_data-source-administrator:newpurviewllc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["35ac9d32-a8ca-4324-9393-d4000746f07c","f8cfe8ca-1f83-4deb-814c-ee49336fdebd"]},{"fromRule":"purviewmetadatarole_builtin_data-source-administrator","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_data-source-administrator"}]]},{"kind":"attributerule","id":"permission:newpurviewllc","name":"permission:newpurviewllc","dnfCondition":[[{"fromRule":"purviewmetadatarole_builtin_collection-administrator:newpurviewllc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_collection-administrator:newpurviewllc"}],[{"fromRule":"purviewmetadatarole_builtin_purview-reader:newpurviewllc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_purview-reader:newpurviewllc"}],[{"fromRule":"purviewmetadatarole_builtin_data-curator:newpurviewllc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_data-curator:newpurviewllc"}],[{"fromRule":"purviewmetadatarole_builtin_data-source-administrator:newpurviewllc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_data-source-administrator:newpurviewllc"}]]}],"collection":{"type":"CollectionReference","referenceName":"newpurviewllc"}}},{"name":"policy_la7eio","id":"88ce2dc3-3573-4c9a-8111-14fc9bc548b4","version":1,"properties":{"description":"","decisionRules":[{"kind":"decisionrule","effect":"Permit","dnfCondition":[[{"attributeName":"resource.purview.collection","attributeValueIncludes":"la7eio"},{"fromRule":"permission:la7eio","attributeName":"derived.purview.permission","attributeValueIncludes":"permission:la7eio"}]]}],"attributeRules":[{"kind":"attributerule","id":"purviewmetadatarole_builtin_collection-administrator:la7eio","name":"purviewmetadatarole_builtin_collection-administrator:la7eio","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["f8cfe8ca-1f83-4deb-814c-ee49336fdebd"]},{"fromRule":"purviewmetadatarole_builtin_collection-administrator","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_collection-administrator"}],[{"fromRule":"purviewmetadatarole_builtin_collection-administrator:newpurviewllc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_collection-administrator:newpurviewllc"}]]},{"kind":"attributerule","id":"permission:la7eio","name":"permission:la7eio","dnfCondition":[[{"fromRule":"purviewmetadatarole_builtin_collection-administrator:la7eio","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_collection-administrator:la7eio"}],[{"fromRule":"permission:newpurviewllc","attributeName":"derived.purview.permission","attributeValueIncludes":"permission:newpurviewllc"}]]}],"collection":{"type":"CollectionReference","referenceName":"la7eio"},"parentCollectionName":"newpurviewllc"}}]}, [ + 'Date', + 'Wed, 29 Sep 2021 19:25:53 GMT', + 'Content-Type', + 'application/json; charset=utf-8', + 'Server', + 'Kestrel', + 'Content-Length', + '5197', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'x-ms-correlation-request-id', + '6028adba-9533-4d8b-91fc-5a9631ab76b1', + 'api-supported-versions', + '2021-07-01' +]); diff --git a/sdk/purview/purview-administration-rest/review/purview-administration.api.md b/sdk/purview/purview-administration-rest/review/purview-administration.api.md new file mode 100644 index 000000000000..4cc9e2b69cf8 --- /dev/null +++ b/sdk/purview/purview-administration-rest/review/purview-administration.api.md @@ -0,0 +1,1314 @@ +## API Report File for "@azure-rest/purview-administration" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { Client } from '@azure-rest/core-client'; +import { ClientOptions } from '@azure-rest/core-client'; +import { HttpResponse } from '@azure-rest/core-client'; +import { PagedAsyncIterableIterator } from '@azure/core-paging'; +import { PathUncheckedResponse } from '@azure-rest/core-client'; +import { RawHttpHeaders } from '@azure/core-rest-pipeline'; +import { RequestParameters } from '@azure-rest/core-client'; +import { TokenCredential } from '@azure/core-auth'; + +// @public (undocumented) +interface AccessKeyOptions { + keyType?: "PrimaryAtlasKafkaKey" | "SecondaryAtlasKafkaKey"; +} + +// @public (undocumented) +interface AccessKeys { + atlasKafkaPrimaryEndpoint?: string; + atlasKafkaSecondaryEndpoint?: string; +} + +// @public (undocumented) +interface Account { + id?: string; + identity?: Identity; + location?: string; + name?: string; + properties?: AccountProperties; + sku?: AccountSku; + systemData?: AccountSystemData; + tags?: Record; + type?: string; +} + +// @public (undocumented) +interface AccountEndpoints { + catalog?: string; + guardian?: string; + scan?: string; +} + +// @public (undocumented) +interface AccountProperties { + cloudConnectors?: CloudConnectors; + createdAt?: Date; + createdBy?: string; + createdByObjectId?: string; + endpoints?: AccountPropertiesEndpoints; + friendlyName?: string; + managedResourceGroupName?: string; + managedResources?: AccountPropertiesManagedResources; + privateEndpointConnections?: Array; + provisioningState?: "Unknown" | "Creating" | "Moving" | "Deleting" | "SoftDeleting" | "SoftDeleted" | "Failed" | "Succeeded" | "Canceled"; + publicNetworkAccess?: "NotSpecified" | "Enabled" | "Disabled"; +} + +// @public (undocumented) +interface AccountPropertiesEndpoints extends AccountEndpoints { +} + +// @public (undocumented) +interface AccountPropertiesManagedResources extends ManagedResources { +} + +// @public (undocumented) +interface AccountsGetAccessKeys { + post(options?: AccountsGetAccessKeysParameters): Promise; +} + +// @public +interface AccountsGetAccessKeys200Response extends HttpResponse { + // (undocumented) + body: AccessKeys; + // (undocumented) + status: "200"; +} + +// @public +interface AccountsGetAccessKeysdefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type AccountsGetAccessKeysParameters = RequestParameters; + +// @public (undocumented) +interface AccountsGetAccountProperties { + get(options?: AccountsGetAccountPropertiesParameters): Promise; + patch(options: AccountsUpdateAccountPropertiesParameters): Promise; +} + +// @public +interface AccountsGetAccountProperties200Response extends HttpResponse { + // (undocumented) + body: Account; + // (undocumented) + status: "200"; +} + +// @public +interface AccountsGetAccountPropertiesdefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type AccountsGetAccountPropertiesParameters = RequestParameters; + +// @public (undocumented) +interface AccountSku { + capacity?: number; + name?: "Standard"; +} + +// @public (undocumented) +interface AccountsRegenerateAccessKey { + post(options: AccountsRegenerateAccessKeyParameters): Promise; +} + +// @public +interface AccountsRegenerateAccessKey200Response extends HttpResponse { + // (undocumented) + body: AccessKeys; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +interface AccountsRegenerateAccessKeyBodyParam { + // (undocumented) + body: AccessKeyOptions; +} + +// @public +interface AccountsRegenerateAccessKeydefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type AccountsRegenerateAccessKeyParameters = AccountsRegenerateAccessKeyBodyParam & RequestParameters; + +// @public +interface AccountsUpdateAccountProperties200Response extends HttpResponse { + // (undocumented) + body: Account; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +interface AccountsUpdateAccountPropertiesBodyParam { + // (undocumented) + body: DataPlaneAccountUpdateParameters; +} + +// @public +interface AccountsUpdateAccountPropertiesdefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type AccountsUpdateAccountPropertiesParameters = AccountsUpdateAccountPropertiesBodyParam & RequestParameters; + +// @public (undocumented) +interface AccountSystemData extends SystemData { +} + +// @public (undocumented) +interface AdvancedResourceSet { + modifiedAt?: Date; + resourceSetProcessing?: "Default" | "Advanced"; +} + +// @public (undocumented) +interface AttributeMatcher { + attributeName?: string; + attributeValueExcludedIn?: Array; + attributeValueExcludes?: string; + attributeValueIncludedIn?: Array; + attributeValueIncludes?: string; +} + +// @public (undocumented) +interface AttributeRule { + dnfCondition?: Array>; + id?: string; + kind?: "decisionrule" | "attributerule"; + name?: string; +} + +declare namespace Client_2 { + export { + AccountsGetAccountProperties, + AccountsGetAccessKeys, + AccountsRegenerateAccessKey, + CollectionsGetCollection, + CollectionsListCollections, + CollectionsListChildCollectionNames, + CollectionsGetCollectionPath, + ResourceSetRulesGetResourceSetRule, + ResourceSetRulesListResourceSetRules, + Routes, + PurviewAccountRestClient + } +} + +declare namespace Client_3 { + export { + MetadataRolesList, + MetadataPolicyListAll, + MetadataPolicyUpdate, + Routes_2 as Routes, + PurviewMetadataPoliciesRestClient + } +} + +// @public (undocumented) +interface CloudConnectors { + awsExternalId?: string; +} + +// @public (undocumented) +interface Collection { + collectionProvisioningState?: "Unknown" | "Creating" | "Moving" | "Deleting" | "Failed" | "Succeeded"; + description?: string; + friendlyName?: string; + name?: string; + parentCollection?: CollectionReference; + systemData?: CollectionSystemData; +} + +// @public (undocumented) +interface CollectionList { + count?: number; + nextLink?: string; + value: Array; +} + +// @public (undocumented) +interface CollectionNameResponse { + friendlyName?: string; + name?: string; +} + +// @public (undocumented) +interface CollectionNameResponseList { + count?: number; + nextLink?: string; + value: Array; +} + +// @public (undocumented) +interface CollectionPathResponse { + parentFriendlyNameChain?: Array; + parentNameChain?: Array; +} + +// @public (undocumented) +interface CollectionReference { + referenceName?: string; + type?: string; +} + +// @public (undocumented) +interface CollectionReference_2 { + referenceName?: string; + type?: string; +} + +// @public +interface CollectionsCreateOrUpdateCollection200Response extends HttpResponse { + // (undocumented) + body: Collection; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +interface CollectionsCreateOrUpdateCollectionBodyParam { + // (undocumented) + body: Collection; +} + +// @public +interface CollectionsCreateOrUpdateCollectiondefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type CollectionsCreateOrUpdateCollectionParameters = CollectionsCreateOrUpdateCollectionBodyParam & RequestParameters; + +// @public +interface CollectionsDeleteCollection204Response extends HttpResponse { + // (undocumented) + body: Record; + // (undocumented) + status: "204"; +} + +// @public +interface CollectionsDeleteCollectiondefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type CollectionsDeleteCollectionParameters = RequestParameters; + +// @public (undocumented) +interface CollectionsGetCollection { + delete(options?: CollectionsDeleteCollectionParameters): Promise; + get(options?: CollectionsGetCollectionParameters): Promise; + put(options: CollectionsCreateOrUpdateCollectionParameters): Promise; +} + +// @public +interface CollectionsGetCollection200Response extends HttpResponse { + // (undocumented) + body: Collection; + // (undocumented) + status: "200"; +} + +// @public +interface CollectionsGetCollectiondefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type CollectionsGetCollectionParameters = RequestParameters; + +// @public (undocumented) +interface CollectionsGetCollectionPath { + get(options?: CollectionsGetCollectionPathParameters): Promise; +} + +// @public +interface CollectionsGetCollectionPath200Response extends HttpResponse { + // (undocumented) + body: CollectionPathResponse; + // (undocumented) + status: "200"; +} + +// @public +interface CollectionsGetCollectionPathdefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type CollectionsGetCollectionPathParameters = RequestParameters; + +// @public (undocumented) +interface CollectionsListChildCollectionNames { + get(options?: CollectionsListChildCollectionNamesParameters): Promise; +} + +// @public +interface CollectionsListChildCollectionNames200Response extends HttpResponse { + // (undocumented) + body: CollectionNameResponseList; + // (undocumented) + status: "200"; +} + +// @public +interface CollectionsListChildCollectionNamesdefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type CollectionsListChildCollectionNamesParameters = CollectionsListChildCollectionNamesQueryParam & RequestParameters; + +// @public (undocumented) +interface CollectionsListChildCollectionNamesQueryParam { + // (undocumented) + queryParameters?: CollectionsListChildCollectionNamesQueryParamProperties; +} + +// @public (undocumented) +interface CollectionsListChildCollectionNamesQueryParamProperties { + // (undocumented) + $skipToken?: string; +} + +// @public (undocumented) +interface CollectionsListCollections { + get(options?: CollectionsListCollectionsParameters): Promise; +} + +// @public +interface CollectionsListCollections200Response extends HttpResponse { + // (undocumented) + body: CollectionList; + // (undocumented) + status: "200"; +} + +// @public +interface CollectionsListCollectionsdefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type CollectionsListCollectionsParameters = CollectionsListCollectionsQueryParam & RequestParameters; + +// @public (undocumented) +interface CollectionsListCollectionsQueryParam { + // (undocumented) + queryParameters?: CollectionsListCollectionsQueryParamProperties; +} + +// @public (undocumented) +interface CollectionsListCollectionsQueryParamProperties { + // (undocumented) + $skipToken?: string; +} + +// @public (undocumented) +interface CollectionSystemData extends SystemData { +} + +// @public (undocumented) +interface ComplexReplacerConfig { + // (undocumented) + createdBy?: string; + // (undocumented) + description?: string; + // (undocumented) + disabled?: boolean; + // (undocumented) + disableRecursiveReplacerApplication?: boolean; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + modifiedBy?: string; + // (undocumented) + name?: string; + // (undocumented) + typeName?: string; +} + +// @public (undocumented) +interface DataPlaneAccountUpdateParameters { + friendlyName?: string; +} + +// @public (undocumented) +interface DecisionRule { + dnfCondition?: Array>; + effect?: "Deny" | "Permit"; + kind?: "decisionrule" | "attributerule"; +} + +// @public (undocumented) +interface ErrorModel { + code?: string; + details?: Array; + message?: string; + target?: string; +} + +// @public (undocumented) +interface ErrorModel_2 { + code: string; + details?: Array; + message: string; + target?: string; +} + +// @public (undocumented) +interface ErrorResponseModel { + error?: ErrorResponseModelError; +} + +// @public (undocumented) +interface ErrorResponseModel_2 { + error: ErrorModel_2; +} + +// @public (undocumented) +interface ErrorResponseModelError extends ErrorModel { +} + +// @public (undocumented) +interface FastRegex { + // (undocumented) + maxDigits?: number; + // (undocumented) + maxLetters?: number; + // (undocumented) + minDashes?: number; + // (undocumented) + minDigits?: number; + // (undocumented) + minDigitsOrLetters?: number; + // (undocumented) + minDots?: number; + // (undocumented) + minHex?: number; + // (undocumented) + minLetters?: number; + // (undocumented) + minUnderscores?: number; + // (undocumented) + options?: number; + // (undocumented) + regexStr?: string; +} + +// @public (undocumented) +interface Filter { + // (undocumented) + createdBy?: string; + // (undocumented) + filterType?: "Pattern" | "Regex"; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + modifiedBy?: string; + // (undocumented) + name: string; + // (undocumented) + path: string; +} + +// @public +type GetArrayType = T extends Array ? TData : never; + +// @public +type GetArrayType_2 = T extends Array ? TData : never; + +// @public +type GetPage = (pageLink: string, maxPageSize?: number) => Promise<{ + page: TPage; + nextPageLink?: string; +}>; + +// @public +type GetPage_2 = (pageLink: string, maxPageSize?: number) => Promise<{ + page: TPage; + nextPageLink?: string; +}>; + +// @public (undocumented) +interface Identity { + principalId?: string; + tenantId?: string; + type?: "SystemAssigned"; +} + +// @public (undocumented) +interface ManagedResources { + eventHubNamespace?: string; + resourceGroup?: string; + storageAccount?: string; +} + +// @public (undocumented) +interface MetadataPolicy { + id?: string; + name?: string; + // (undocumented) + properties?: MetadataPolicyProperties; + version?: number; +} + +// @public +interface MetadataPolicyGet200Response extends HttpResponse { + // (undocumented) + body: MetadataPolicy; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +interface MetadataPolicyGetdefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public +interface MetadataPolicyGetdefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel_2; + // (undocumented) + headers: RawHttpHeaders & MetadataPolicyGetdefaultHeaders; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type MetadataPolicyGetParameters = RequestParameters; + +// @public (undocumented) +interface MetadataPolicyList { + // (undocumented) + nextLink?: string; + // (undocumented) + values: Array; +} + +// @public (undocumented) +interface MetadataPolicyListAll { + get(options?: MetadataPolicyListAllParameters): Promise; +} + +// @public +interface MetadataPolicyListAll200Response extends HttpResponse { + // (undocumented) + body: MetadataPolicyList; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +interface MetadataPolicyListAlldefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public +interface MetadataPolicyListAlldefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel_2; + // (undocumented) + headers: RawHttpHeaders & MetadataPolicyListAlldefaultHeaders; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type MetadataPolicyListAllParameters = MetadataPolicyListAllQueryParam & RequestParameters; + +// @public (undocumented) +interface MetadataPolicyListAllQueryParam { + // (undocumented) + queryParameters?: MetadataPolicyListAllQueryParamProperties; +} + +// @public (undocumented) +interface MetadataPolicyListAllQueryParamProperties { + collectionName?: string; +} + +// @public (undocumented) +interface MetadataPolicyProperties { + attributeRules?: Array; + collection?: CollectionReference_2; + decisionRules?: Array; + description?: string; + parentCollectionName?: string; +} + +// @public (undocumented) +interface MetadataPolicyUpdate { + get(options?: MetadataPolicyGetParameters): Promise; + put(options?: MetadataPolicyUpdateParameters): Promise; +} + +// @public +interface MetadataPolicyUpdate200Response extends HttpResponse { + // (undocumented) + body: MetadataPolicy; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +interface MetadataPolicyUpdateBodyParam { + body?: MetadataPolicy; +} + +// @public (undocumented) +interface MetadataPolicyUpdatedefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public +interface MetadataPolicyUpdatedefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel_2; + // (undocumented) + headers: RawHttpHeaders & MetadataPolicyUpdatedefaultHeaders; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type MetadataPolicyUpdateParameters = MetadataPolicyUpdateBodyParam & RequestParameters; + +// @public (undocumented) +interface MetadataRole { + id?: string; + name?: string; + // (undocumented) + properties?: MetadataRoleProperties; + type?: string; +} + +// @public (undocumented) +interface MetadataRoleList { + // (undocumented) + nextLink?: string; + // (undocumented) + values: Array; +} + +// @public (undocumented) +interface MetadataRoleProperties { + cnfCondition?: Array>; + description?: string; + dnfCondition?: Array>; + friendlyName?: string; + provisioningState?: string; + roleType?: string; + version?: number; +} + +// @public (undocumented) +interface MetadataRolesList { + get(options?: MetadataRolesListParameters): Promise; +} + +// @public +interface MetadataRolesList200Response extends HttpResponse { + // (undocumented) + body: MetadataRoleList; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +interface MetadataRolesListdefaultHeaders { + "x-ms-error-code"?: string; +} + +// @public +interface MetadataRolesListdefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel_2; + // (undocumented) + headers: RawHttpHeaders & MetadataRolesListdefaultHeaders; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type MetadataRolesListParameters = RequestParameters; + +declare namespace Models { + export { + Account, + Identity, + AccountProperties, + CloudConnectors, + AccountEndpoints, + AccountPropertiesEndpoints, + ManagedResources, + AccountPropertiesManagedResources, + PrivateEndpointConnection, + PrivateEndpointConnectionProperties, + PrivateEndpoint, + PrivateLinkServiceConnectionState, + AccountSku, + SystemData, + AccountSystemData, + ErrorResponseModel, + ErrorModel, + ErrorResponseModelError, + DataPlaneAccountUpdateParameters, + AccessKeys, + AccessKeyOptions, + Collection, + CollectionReference, + CollectionSystemData, + CollectionList, + CollectionNameResponseList, + CollectionNameResponse, + CollectionPathResponse, + ResourceSetRuleConfig, + AdvancedResourceSet, + PathPatternExtractorConfig, + Filter, + ComplexReplacerConfig, + NormalizationRule, + FastRegex, + RegexReplacer, + ScopedRule, + Rule, + ResourceSetRuleConfigList + } +} + +declare namespace Models_2 { + export { + MetadataRoleList, + MetadataRole, + MetadataRoleProperties, + AttributeMatcher, + ErrorResponseModel_2 as ErrorResponseModel, + ErrorModel_2 as ErrorModel, + MetadataPolicyList, + MetadataPolicy, + MetadataPolicyProperties, + DecisionRule, + AttributeRule, + CollectionReference_2 as CollectionReference + } +} + +// @public (undocumented) +interface NormalizationRule { + // (undocumented) + description?: string; + // (undocumented) + disabled?: boolean; + // (undocumented) + dynamicReplacement?: boolean; + // (undocumented) + entityTypes?: Array; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + name?: string; + // (undocumented) + regex?: FastRegex; + // (undocumented) + replaceWith?: string; + // (undocumented) + version?: number; +} + +// @public +function paginate(client: Client, initialResponse: TResponse, options?: PagingOptions): PagedAsyncIterableIterator>; + +// @public +function paginate_2(client: Client, initialResponse: TResponse, options?: PagingOptions_2): PagedAsyncIterableIterator>; + +// @public +type PaginateReturn = TResult extends { + body: { + value?: infer TPage; + }; +} ? GetArrayType : Array; + +// @public +type PaginateReturn_2 = TResult extends { + body: { + value?: infer TPage; + }; +} | { + body: { + values?: infer TPage; + }; +} ? GetArrayType_2 : Array; + +declare namespace Pagination { + export { + paginate, + GetArrayType, + GetPage, + PagingOptions, + PaginateReturn + } +} + +declare namespace Pagination_2 { + export { + paginate_2 as paginate, + GetArrayType_2 as GetArrayType, + GetPage_2 as GetPage, + PagingOptions_2 as PagingOptions, + PaginateReturn_2 as PaginateReturn + } +} + +// @public +interface PagingOptions { + customGetPage?: GetPage[]>; +} + +// @public +interface PagingOptions_2 { + customGetPage?: GetPage_2[]>; +} + +declare namespace Parameters_2 { + export { + AccountsGetAccountPropertiesParameters, + AccountsUpdateAccountPropertiesBodyParam, + AccountsUpdateAccountPropertiesParameters, + AccountsGetAccessKeysParameters, + AccountsRegenerateAccessKeyBodyParam, + AccountsRegenerateAccessKeyParameters, + CollectionsGetCollectionParameters, + CollectionsCreateOrUpdateCollectionBodyParam, + CollectionsCreateOrUpdateCollectionParameters, + CollectionsDeleteCollectionParameters, + CollectionsListCollectionsQueryParamProperties, + CollectionsListCollectionsQueryParam, + CollectionsListCollectionsParameters, + CollectionsListChildCollectionNamesQueryParamProperties, + CollectionsListChildCollectionNamesQueryParam, + CollectionsListChildCollectionNamesParameters, + CollectionsGetCollectionPathParameters, + ResourceSetRulesGetResourceSetRuleParameters, + ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam, + ResourceSetRulesCreateOrUpdateResourceSetRuleParameters, + ResourceSetRulesDeleteResourceSetRuleParameters, + ResourceSetRulesListResourceSetRulesQueryParamProperties, + ResourceSetRulesListResourceSetRulesQueryParam, + ResourceSetRulesListResourceSetRulesParameters + } +} + +declare namespace Parameters_3 { + export { + MetadataRolesListParameters, + MetadataPolicyListAllQueryParamProperties, + MetadataPolicyListAllQueryParam, + MetadataPolicyListAllParameters, + MetadataPolicyUpdateBodyParam, + MetadataPolicyUpdateParameters, + MetadataPolicyGetParameters + } +} + +// @public (undocumented) +interface PathPatternExtractorConfig { + // (undocumented) + acceptedPatterns?: Array; + // (undocumented) + complexReplacers?: Array; + // (undocumented) + createdBy: string; + // (undocumented) + enableDefaultPatterns: boolean; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + modifiedBy?: string; + // (undocumented) + normalizationRules?: Array; + // (undocumented) + regexReplacers?: Array; + // (undocumented) + rejectedPatterns?: Array; + // (undocumented) + scopedRules?: Array; + // (undocumented) + version?: number; +} + +// @public (undocumented) +interface PrivateEndpoint { + id?: string; +} + +// @public (undocumented) +interface PrivateEndpointConnection { + id?: string; + name?: string; + properties?: PrivateEndpointConnectionProperties; + type?: string; +} + +// @public (undocumented) +interface PrivateEndpointConnectionProperties { + privateEndpoint?: PrivateEndpoint; + privateLinkServiceConnectionState?: PrivateLinkServiceConnectionState; + provisioningState?: string; +} + +// @public (undocumented) +interface PrivateLinkServiceConnectionState { + actionsRequired?: string; + description?: string; + status?: "Unknown" | "Pending" | "Approved" | "Rejected" | "Disconnected"; +} + +declare namespace PurviewAccount { + export { + Models, + Pagination, + Parameters_2 as Parameters, + Client_2 as Client, + Responses, + PurviewAccountClient + } +} +export { PurviewAccount } + +// @public (undocumented) +export function PurviewAccountClient(endpoint: string, credentials: TokenCredential, options?: ClientOptions): PurviewAccountRestClient; + +// @public (undocumented) +type PurviewAccountRestClient = Client & { + path: Routes; +}; + +declare namespace PurviewMetadataPolicies { + export { + PurviewMetadataPoliciesClient, + Models_2 as Models, + Pagination_2 as Pagination, + Parameters_3 as Parameters, + Client_3 as Client, + Responses_2 as Responses + } +} +export { PurviewMetadataPolicies } + +// @public (undocumented) +export function PurviewMetadataPoliciesClient(Endpoint: string, credentials: TokenCredential, options?: ClientOptions): PurviewMetadataPoliciesRestClient; + +// @public (undocumented) +type PurviewMetadataPoliciesRestClient = Client & { + path: Routes_2; +}; + +// @public (undocumented) +interface RegexReplacer { + // (undocumented) + condition?: string; + // (undocumented) + createdBy?: string; + // (undocumented) + description?: string; + // (undocumented) + disabled: boolean; + // (undocumented) + disableRecursiveReplacerApplication?: boolean; + // (undocumented) + doNotReplaceRegex?: FastRegex; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + modifiedBy?: string; + // (undocumented) + name: string; + // (undocumented) + regex?: FastRegex; + // (undocumented) + replaceWith?: string; +} + +// @public (undocumented) +interface ResourceSetRuleConfig { + advancedResourceSet?: AdvancedResourceSet; + name?: string; + pathPatternConfig?: PathPatternExtractorConfig; +} + +// @public (undocumented) +interface ResourceSetRuleConfigList { + count?: number; + nextLink?: string; + value: Array; +} + +// @public +interface ResourceSetRulesCreateOrUpdateResourceSetRule200Response extends HttpResponse { + // (undocumented) + body: ResourceSetRuleConfig; + // (undocumented) + status: "200"; +} + +// @public (undocumented) +interface ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam { + // (undocumented) + body: ResourceSetRuleConfig; +} + +// @public +interface ResourceSetRulesCreateOrUpdateResourceSetRuledefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type ResourceSetRulesCreateOrUpdateResourceSetRuleParameters = ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam & RequestParameters; + +// @public +interface ResourceSetRulesDeleteResourceSetRule200Response extends HttpResponse { + // (undocumented) + body: Record; + // (undocumented) + status: "200"; +} + +// @public +interface ResourceSetRulesDeleteResourceSetRule204Response extends HttpResponse { + // (undocumented) + body: Record; + // (undocumented) + status: "204"; +} + +// @public +interface ResourceSetRulesDeleteResourceSetRuledefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type ResourceSetRulesDeleteResourceSetRuleParameters = RequestParameters; + +// @public (undocumented) +interface ResourceSetRulesGetResourceSetRule { + delete(options?: ResourceSetRulesDeleteResourceSetRuleParameters): Promise; + get(options?: ResourceSetRulesGetResourceSetRuleParameters): Promise; + put(options: ResourceSetRulesCreateOrUpdateResourceSetRuleParameters): Promise; +} + +// @public +interface ResourceSetRulesGetResourceSetRule200Response extends HttpResponse { + // (undocumented) + body: ResourceSetRuleConfig; + // (undocumented) + status: "200"; +} + +// @public +interface ResourceSetRulesGetResourceSetRuledefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type ResourceSetRulesGetResourceSetRuleParameters = RequestParameters; + +// @public (undocumented) +interface ResourceSetRulesListResourceSetRules { + get(options?: ResourceSetRulesListResourceSetRulesParameters): Promise; +} + +// @public +interface ResourceSetRulesListResourceSetRules200Response extends HttpResponse { + // (undocumented) + body: ResourceSetRuleConfigList; + // (undocumented) + status: "200"; +} + +// @public +interface ResourceSetRulesListResourceSetRulesdefaultResponse extends HttpResponse { + // (undocumented) + body: ErrorResponseModel; + // (undocumented) + status: "500"; +} + +// @public (undocumented) +type ResourceSetRulesListResourceSetRulesParameters = ResourceSetRulesListResourceSetRulesQueryParam & RequestParameters; + +// @public (undocumented) +interface ResourceSetRulesListResourceSetRulesQueryParam { + // (undocumented) + queryParameters?: ResourceSetRulesListResourceSetRulesQueryParamProperties; +} + +// @public (undocumented) +interface ResourceSetRulesListResourceSetRulesQueryParamProperties { + // (undocumented) + $skipToken?: string; +} + +declare namespace Responses { + export { + AccountsGetAccountProperties200Response, + AccountsGetAccountPropertiesdefaultResponse, + AccountsUpdateAccountProperties200Response, + AccountsUpdateAccountPropertiesdefaultResponse, + AccountsGetAccessKeys200Response, + AccountsGetAccessKeysdefaultResponse, + AccountsRegenerateAccessKey200Response, + AccountsRegenerateAccessKeydefaultResponse, + CollectionsGetCollection200Response, + CollectionsGetCollectiondefaultResponse, + CollectionsCreateOrUpdateCollection200Response, + CollectionsCreateOrUpdateCollectiondefaultResponse, + CollectionsDeleteCollection204Response, + CollectionsDeleteCollectiondefaultResponse, + CollectionsListCollections200Response, + CollectionsListCollectionsdefaultResponse, + CollectionsListChildCollectionNames200Response, + CollectionsListChildCollectionNamesdefaultResponse, + CollectionsGetCollectionPath200Response, + CollectionsGetCollectionPathdefaultResponse, + ResourceSetRulesGetResourceSetRule200Response, + ResourceSetRulesGetResourceSetRuledefaultResponse, + ResourceSetRulesCreateOrUpdateResourceSetRule200Response, + ResourceSetRulesCreateOrUpdateResourceSetRuledefaultResponse, + ResourceSetRulesDeleteResourceSetRule200Response, + ResourceSetRulesDeleteResourceSetRule204Response, + ResourceSetRulesDeleteResourceSetRuledefaultResponse, + ResourceSetRulesListResourceSetRules200Response, + ResourceSetRulesListResourceSetRulesdefaultResponse + } +} + +declare namespace Responses_2 { + export { + MetadataRolesList200Response, + MetadataRolesListdefaultHeaders, + MetadataRolesListdefaultResponse, + MetadataPolicyListAll200Response, + MetadataPolicyListAlldefaultHeaders, + MetadataPolicyListAlldefaultResponse, + MetadataPolicyUpdate200Response, + MetadataPolicyUpdatedefaultHeaders, + MetadataPolicyUpdatedefaultResponse, + MetadataPolicyGet200Response, + MetadataPolicyGetdefaultHeaders, + MetadataPolicyGetdefaultResponse + } +} + +// @public (undocumented) +interface Routes { + (path: "/"): AccountsGetAccountProperties; + (path: "/listkeys"): AccountsGetAccessKeys; + (path: "/regeneratekeys"): AccountsRegenerateAccessKey; + (path: "/collections/{collectionName}", collectionName: string): CollectionsGetCollection; + (path: "/collections"): CollectionsListCollections; + (path: "/collections/{collectionName}/getChildCollectionNames", collectionName: string): CollectionsListChildCollectionNames; + (path: "/collections/{collectionName}/getCollectionPath", collectionName: string): CollectionsGetCollectionPath; + (path: "/resourceSetRuleConfigs/defaultResourceSetRuleConfig"): ResourceSetRulesGetResourceSetRule; + (path: "/resourceSetRuleConfigs"): ResourceSetRulesListResourceSetRules; +} + +// @public (undocumented) +interface Routes_2 { + (path: "/metadataRoles"): MetadataRolesList; + (path: "/metadataPolicies"): MetadataPolicyListAll; + (path: "/metadataPolicies/{policyId}", policyId: string): MetadataPolicyUpdate; +} + +// @public (undocumented) +interface Rule { + // (undocumented) + displayName?: string; + // (undocumented) + isResourceSet?: boolean; + // (undocumented) + lastUpdatedTimestamp?: number; + // (undocumented) + name?: string; + // (undocumented) + qualifiedName: string; +} + +// @public (undocumented) +interface ScopedRule { + // (undocumented) + bindingUrl: string; + // (undocumented) + rules?: Array; + // (undocumented) + storeType: string; +} + +// @public (undocumented) +interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: "User" | "Application" | "ManagedIdentity" | "Key"; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: "User" | "Application" | "ManagedIdentity" | "Key"; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/purview/purview-administration-rest/rollup.config.js b/sdk/purview/purview-administration-rest/rollup.config.js new file mode 100644 index 000000000000..5d7deee44c14 --- /dev/null +++ b/sdk/purview/purview-administration-rest/rollup.config.js @@ -0,0 +1,3 @@ +import { makeConfig } from "@azure/dev-tool/shared-config/rollup"; + +export default makeConfig(require("./package.json")); diff --git a/sdk/purview/purview-administration-rest/sample.env b/sdk/purview/purview-administration-rest/sample.env new file mode 100644 index 000000000000..5c39228ebdd0 --- /dev/null +++ b/sdk/purview/purview-administration-rest/sample.env @@ -0,0 +1,7 @@ +# Purview Scanning resource endpoint +ENDPOINT= + +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= diff --git a/sdk/purview/purview-administration-rest/samples-dev/accountCollections.ts b/sdk/purview/purview-administration-rest/samples-dev/accountCollections.ts new file mode 100644 index 000000000000..e72124c09bbd --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples-dev/accountCollections.ts @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how get a list of collections + * + * @summary gets a list of collections + * @azsdk-weight 40 + */ + +import { PurviewAccount, PurviewAccountClient } from "@azure-rest/purview-administration"; +import { DefaultAzureCredential } from "@azure/identity"; +import dotenv from "dotenv"; + +dotenv.config(); + +const endpoint = process.env["ENDPOINT"] || ""; + +async function main() { + console.log("== List collections sample =="); + const client = PurviewAccountClient(endpoint, new DefaultAzureCredential()); + + const response = await client.path("/collections").get(); + + if (response.status !== "200") { + console.log(`GET "/collections" failed with ${response.status}`); + } + + const dataSources = PurviewAccount.Pagination.paginate(client, response); + + for await (const dataSource of dataSources) { + console.log(dataSource); + } +} + +main().catch(console.error); diff --git a/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts b/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts new file mode 100644 index 000000000000..a1c2f48fb9b2 --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples-dev/metadataPolicies.ts @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how get a list of metadata policies + * + * @summary gets a list of metadata policies + * @azsdk-weight 40 + */ + +import { + PurviewMetadataPolicies, + PurviewMetadataPoliciesClient, +} from "@azure-rest/purview-administration"; +import { DefaultAzureCredential } from "@azure/identity"; +import dotenv from "dotenv"; + +dotenv.config(); + +const endpoint = process.env["ENDPOINT"] || ""; + +async function main() { + console.log("== List metadata policies sample =="); + const client = PurviewMetadataPoliciesClient(endpoint, new DefaultAzureCredential()); + + const response = await client.path("/metadataPolicies").get(); + + if (response.status !== "200") { + const error = `GET "/metadataPolicies" failed with ${response.status}`; + console.log(); + throw new Error(error); + } + + const policies = PurviewMetadataPolicies.Pagination.paginate(client, response); + + for await (const policy of policies) { + console.log(policy.name); + } +} + +main().catch(console.error); diff --git a/sdk/purview/purview-administration-rest/samples/v1/javascript/README.md b/sdk/purview/purview-administration-rest/samples/v1/javascript/README.md new file mode 100644 index 000000000000..a87f9631152e --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/javascript/README.md @@ -0,0 +1,64 @@ +--- +page_type: sample +languages: + - javascript +products: + - azure +urlFragment: purview-administration-javascript +--- + +# Azure Purview Administration rest client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for Azure Purview Administration rest in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------- | -------------------------------- | +| [accountCollections.js][accountcollections] | gets a list of collections | +| [metadataPolicies.js][metadatapolicies] | gets a list of metadata policies | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +You need [an Azure subscription][freesub] and the following Azure resources to run these sample programs: + +- [Azure Purview instance][createinstance_azurepurviewinstance] + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node accountCollections.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env ENDPOINT="" node accountCollections.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[accountcollections]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1/javascript/accountCollections.js +[metadatapolicies]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1/javascript/metadataPolicies.js +[apiref]: https://docs.microsoft.com/azure/purview/tutorial-using-rest-apis +[freesub]: https://azure.microsoft.com/free/ +[createinstance_azurepurviewinstance]: https://docs.microsoft.com/azure/purview/create-catalog-portal +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/purview/purview-administration-rest/README.md diff --git a/sdk/purview/purview-administration-rest/samples/v1/javascript/accountCollections.js b/sdk/purview/purview-administration-rest/samples/v1/javascript/accountCollections.js new file mode 100644 index 000000000000..07930953a026 --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/javascript/accountCollections.js @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how get a list of collections + * + * @summary gets a list of collections + */ + +const { PurviewAccount, PurviewAccountClient } = require("@azure-rest/purview-administration"); +const { DefaultAzureCredential } = require("@azure/identity"); +const dotenv = require("dotenv"); + +dotenv.config(); + +const endpoint = process.env["ENDPOINT"] || ""; + +async function main() { + console.log("== List collections sample =="); + const client = PurviewAccountClient(endpoint, new DefaultAzureCredential()); + + const response = await client.path("/collections").get(); + + if (response.status !== "200") { + console.log(`GET "/collections" failed with ${response.status}`); + } + + const dataSources = PurviewAccount.Pagination.paginate(client, response); + + for await (const dataSource of dataSources) { + console.log(dataSource); + } +} + +main().catch(console.error); diff --git a/sdk/purview/purview-administration-rest/samples/v1/javascript/metadataPolicies.js b/sdk/purview/purview-administration-rest/samples/v1/javascript/metadataPolicies.js new file mode 100644 index 000000000000..e62269f25754 --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/javascript/metadataPolicies.js @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how get a list of metadata policies + * + * @summary gets a list of metadata policies + */ + +const { + PurviewMetadataPolicies, + PurviewMetadataPoliciesClient +} = require("@azure-rest/purview-administration"); +const { DefaultAzureCredential } = require("@azure/identity"); +const dotenv = require("dotenv"); + +dotenv.config(); + +const endpoint = process.env["ENDPOINT"] || ""; + +async function main() { + console.log("== List metadata policies sample =="); + const client = PurviewMetadataPoliciesClient(endpoint, new DefaultAzureCredential()); + + const response = await client.path("/metadataPolicies").get(); + + if (response.status !== "200") { + const error = `GET "/metadataPolicies" failed with ${response.status}`; + console.log(); + throw new Error(error); + } + + const policies = PurviewMetadataPolicies.Pagination.paginate(client, response); + + for await (const policy of policies) { + console.log(policy.name); + } +} + +main().catch(console.error); diff --git a/sdk/purview/purview-administration-rest/samples/v1/javascript/package.json b/sdk/purview/purview-administration-rest/samples/v1/javascript/package.json new file mode 100644 index 000000000000..260fcf933880 --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/javascript/package.json @@ -0,0 +1,33 @@ +{ + "name": "azure-purview-administration-samples-js", + "private": true, + "version": "1.0.0", + "description": "Azure Purview Administration rest client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/purview/purview-administration-rest" + }, + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/purview/purview-administration-rest", + "dependencies": { + "@azure-rest/purview-administration": "next", + "dotenv": "latest", + "@azure/identity": "^1.1.0" + } +} diff --git a/sdk/purview/purview-administration-rest/samples/v1/javascript/sample.env b/sdk/purview/purview-administration-rest/samples/v1/javascript/sample.env new file mode 100644 index 000000000000..5c39228ebdd0 --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/javascript/sample.env @@ -0,0 +1,7 @@ +# Purview Scanning resource endpoint +ENDPOINT= + +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/README.md b/sdk/purview/purview-administration-rest/samples/v1/typescript/README.md new file mode 100644 index 000000000000..4cc6c68c0f33 --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/typescript/README.md @@ -0,0 +1,77 @@ +--- +page_type: sample +languages: + - typescript +products: + - azure +urlFragment: purview-administration-typescript +--- + +# Azure Purview Administration rest client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for Azure Purview Administration rest in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------- | -------------------------------- | +| [accountCollections.ts][accountcollections] | gets a list of collections | +| [metadataPolicies.ts][metadatapolicies] | gets a list of metadata policies | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] and the following Azure resources to run these sample programs: + +- [Azure Purview instance][createinstance_azurepurviewinstance] + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/accountCollections.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env ENDPOINT="" node dist/accountCollections.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[accountcollections]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1/typescript/src/accountCollections.ts +[metadatapolicies]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/purview/purview-administration-rest/samples/v1/typescript/src/metadataPolicies.ts +[apiref]: https://docs.microsoft.com/azure/purview/tutorial-using-rest-apis +[freesub]: https://azure.microsoft.com/free/ +[createinstance_azurepurviewinstance]: https://docs.microsoft.com/azure/purview/create-catalog-portal +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/purview/purview-administration-rest/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/package.json b/sdk/purview/purview-administration-rest/samples/v1/typescript/package.json new file mode 100644 index 000000000000..b9097dd6f5ec --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "azure-purview-administration-samples-ts", + "private": true, + "version": "1.0.0", + "description": "Azure Purview Administration rest client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/purview/purview-administration-rest" + }, + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/purview/purview-administration-rest", + "dependencies": { + "@azure-rest/purview-administration": "next", + "dotenv": "latest", + "@azure/identity": "^1.1.0" + }, + "devDependencies": { + "typescript": "~4.2.0", + "rimraf": "latest" + } +} diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/sample.env b/sdk/purview/purview-administration-rest/samples/v1/typescript/sample.env new file mode 100644 index 000000000000..5c39228ebdd0 --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/typescript/sample.env @@ -0,0 +1,7 @@ +# Purview Scanning resource endpoint +ENDPOINT= + +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/src/accountCollections.ts b/sdk/purview/purview-administration-rest/samples/v1/typescript/src/accountCollections.ts new file mode 100644 index 000000000000..61edc8573d3e --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/typescript/src/accountCollections.ts @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how get a list of collections + * + * @summary gets a list of collections + */ + +import { PurviewAccount, PurviewAccountClient } from "@azure-rest/purview-administration"; +import { DefaultAzureCredential } from "@azure/identity"; +import dotenv from "dotenv"; + +dotenv.config(); + +const endpoint = process.env["ENDPOINT"] || ""; + +async function main() { + console.log("== List collections sample =="); + const client = PurviewAccountClient(endpoint, new DefaultAzureCredential()); + + const response = await client.path("/collections").get(); + + if (response.status !== "200") { + console.log(`GET "/collections" failed with ${response.status}`); + } + + const dataSources = PurviewAccount.Pagination.paginate(client, response); + + for await (const dataSource of dataSources) { + console.log(dataSource); + } +} + +main().catch(console.error); diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/src/metadataPolicies.ts b/sdk/purview/purview-administration-rest/samples/v1/typescript/src/metadataPolicies.ts new file mode 100644 index 000000000000..e5f89d5bad20 --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/typescript/src/metadataPolicies.ts @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how get a list of metadata policies + * + * @summary gets a list of metadata policies + */ + +import { + PurviewMetadataPolicies, + PurviewMetadataPoliciesClient, +} from "@azure-rest/purview-administration"; +import { DefaultAzureCredential } from "@azure/identity"; +import dotenv from "dotenv"; + +dotenv.config(); + +const endpoint = process.env["ENDPOINT"] || ""; + +async function main() { + console.log("== List metadata policies sample =="); + const client = PurviewMetadataPoliciesClient(endpoint, new DefaultAzureCredential()); + + const response = await client.path("/metadataPolicies").get(); + + if (response.status !== "200") { + const error = `GET "/metadataPolicies" failed with ${response.status}`; + console.log(); + throw new Error(error); + } + + const policies = PurviewMetadataPolicies.Pagination.paginate(client, response); + + for await (const policy of policies) { + console.log(policy.name); + } +} + +main().catch(console.error); diff --git a/sdk/purview/purview-administration-rest/samples/v1/typescript/tsconfig.json b/sdk/purview/purview-administration-rest/samples/v1/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/purview/purview-administration-rest/samples/v1/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**.ts" + ] +} diff --git a/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts b/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts new file mode 100644 index 000000000000..4ac2c3c2b19e --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/account/clientDefinitions.ts @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Client } from "@azure-rest/core-client"; +import { + AccountsGetAccessKeysParameters, + AccountsGetAccountPropertiesParameters, + AccountsRegenerateAccessKeyParameters, + AccountsUpdateAccountPropertiesParameters, + CollectionsCreateOrUpdateCollectionParameters, + CollectionsDeleteCollectionParameters, + CollectionsGetCollectionParameters, + CollectionsGetCollectionPathParameters, + CollectionsListChildCollectionNamesParameters, + CollectionsListCollectionsParameters, + ResourceSetRulesCreateOrUpdateResourceSetRuleParameters, + ResourceSetRulesDeleteResourceSetRuleParameters, + ResourceSetRulesGetResourceSetRuleParameters, + ResourceSetRulesListResourceSetRulesParameters, +} from "./parameters"; +import { + AccountsGetAccessKeys200Response, + AccountsGetAccessKeysdefaultResponse, + AccountsGetAccountProperties200Response, + AccountsGetAccountPropertiesdefaultResponse, + AccountsRegenerateAccessKey200Response, + AccountsRegenerateAccessKeydefaultResponse, + AccountsUpdateAccountProperties200Response, + AccountsUpdateAccountPropertiesdefaultResponse, + CollectionsCreateOrUpdateCollection200Response, + CollectionsCreateOrUpdateCollectiondefaultResponse, + CollectionsDeleteCollection204Response, + CollectionsDeleteCollectiondefaultResponse, + CollectionsGetCollection200Response, + CollectionsGetCollectiondefaultResponse, + CollectionsGetCollectionPath200Response, + CollectionsGetCollectionPathdefaultResponse, + CollectionsListChildCollectionNames200Response, + CollectionsListChildCollectionNamesdefaultResponse, + CollectionsListCollections200Response, + CollectionsListCollectionsdefaultResponse, + ResourceSetRulesCreateOrUpdateResourceSetRule200Response, + ResourceSetRulesCreateOrUpdateResourceSetRuledefaultResponse, + ResourceSetRulesDeleteResourceSetRule200Response, + ResourceSetRulesDeleteResourceSetRule204Response, + ResourceSetRulesDeleteResourceSetRuledefaultResponse, + ResourceSetRulesGetResourceSetRule200Response, + ResourceSetRulesGetResourceSetRuledefaultResponse, + ResourceSetRulesListResourceSetRules200Response, + ResourceSetRulesListResourceSetRulesdefaultResponse, +} from "./responses"; + +export interface AccountsGetAccountProperties { + /** Get an account */ + get( + options?: AccountsGetAccountPropertiesParameters + ): Promise; + /** Updates an account */ + patch( + options: AccountsUpdateAccountPropertiesParameters + ): Promise< + AccountsUpdateAccountProperties200Response | AccountsUpdateAccountPropertiesdefaultResponse + >; +} + +export interface AccountsGetAccessKeys { + /** List the authorization keys associated with this account. */ + post( + options?: AccountsGetAccessKeysParameters + ): Promise; +} + +export interface AccountsRegenerateAccessKey { + /** Regenerate the authorization keys associated with this data catalog. */ + post( + options: AccountsRegenerateAccessKeyParameters + ): Promise; +} + +export interface CollectionsGetCollection { + /** Get a collection */ + get( + options?: CollectionsGetCollectionParameters + ): Promise; + /** Creates or updates a collection entity. */ + put( + options: CollectionsCreateOrUpdateCollectionParameters + ): Promise< + | CollectionsCreateOrUpdateCollection200Response + | CollectionsCreateOrUpdateCollectiondefaultResponse + >; + /** Deletes a Collection entity. */ + delete( + options?: CollectionsDeleteCollectionParameters + ): Promise; +} + +export interface CollectionsListCollections { + /** List the collections in the account. */ + get( + options?: CollectionsListCollectionsParameters + ): Promise; +} + +export interface CollectionsListChildCollectionNames { + /** Lists the child collections names in the collection. */ + get( + options?: CollectionsListChildCollectionNamesParameters + ): Promise< + | CollectionsListChildCollectionNames200Response + | CollectionsListChildCollectionNamesdefaultResponse + >; +} + +export interface CollectionsGetCollectionPath { + /** Gets the parent name and parent friendly name chains that represent the collection path. */ + get( + options?: CollectionsGetCollectionPathParameters + ): Promise; +} + +export interface ResourceSetRulesGetResourceSetRule { + /** Get a resource set config service model. */ + get( + options?: ResourceSetRulesGetResourceSetRuleParameters + ): Promise< + | ResourceSetRulesGetResourceSetRule200Response + | ResourceSetRulesGetResourceSetRuledefaultResponse + >; + /** Creates or updates an resource set config. */ + put( + options: ResourceSetRulesCreateOrUpdateResourceSetRuleParameters + ): Promise< + | ResourceSetRulesCreateOrUpdateResourceSetRule200Response + | ResourceSetRulesCreateOrUpdateResourceSetRuledefaultResponse + >; + /** Deletes a ResourceSetRuleConfig resource. */ + delete( + options?: ResourceSetRulesDeleteResourceSetRuleParameters + ): Promise< + | ResourceSetRulesDeleteResourceSetRule200Response + | ResourceSetRulesDeleteResourceSetRule204Response + | ResourceSetRulesDeleteResourceSetRuledefaultResponse + >; +} + +export interface ResourceSetRulesListResourceSetRules { + /** Get a resource set config service model. */ + get( + options?: ResourceSetRulesListResourceSetRulesParameters + ): Promise< + | ResourceSetRulesListResourceSetRules200Response + | ResourceSetRulesListResourceSetRulesdefaultResponse + >; +} + +export interface Routes { + /** Resource for '/' has methods for the following verbs: get, patch */ + (path: "/"): AccountsGetAccountProperties; + /** Resource for '/listkeys' has methods for the following verbs: post */ + (path: "/listkeys"): AccountsGetAccessKeys; + /** Resource for '/regeneratekeys' has methods for the following verbs: post */ + (path: "/regeneratekeys"): AccountsRegenerateAccessKey; + /** Resource for '/collections/\{collectionName\}' has methods for the following verbs: get, put, delete */ + (path: "/collections/{collectionName}", collectionName: string): CollectionsGetCollection; + /** Resource for '/collections' has methods for the following verbs: get */ + (path: "/collections"): CollectionsListCollections; + /** Resource for '/collections/\{collectionName\}/getChildCollectionNames' has methods for the following verbs: get */ + ( + path: "/collections/{collectionName}/getChildCollectionNames", + collectionName: string + ): CollectionsListChildCollectionNames; + /** Resource for '/collections/\{collectionName\}/getCollectionPath' has methods for the following verbs: get */ + ( + path: "/collections/{collectionName}/getCollectionPath", + collectionName: string + ): CollectionsGetCollectionPath; + /** Resource for '/resourceSetRuleConfigs/defaultResourceSetRuleConfig' has methods for the following verbs: get, put, delete */ + ( + path: "/resourceSetRuleConfigs/defaultResourceSetRuleConfig" + ): ResourceSetRulesGetResourceSetRule; + /** Resource for '/resourceSetRuleConfigs' has methods for the following verbs: get */ + (path: "/resourceSetRuleConfigs"): ResourceSetRulesListResourceSetRules; +} + +export type PurviewAccountRestClient = Client & { + path: Routes; +}; diff --git a/sdk/purview/purview-administration-rest/src/account/index.ts b/sdk/purview/purview-administration-rest/src/account/index.ts new file mode 100644 index 000000000000..bc2a4455e7db --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/account/index.ts @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as Models from "./models"; +import * as Pagination from "./paginateHelper"; +import * as Parameters from "./parameters"; +import * as Client from "./clientDefinitions"; +import * as Responses from "./responses"; +export { Models, Pagination, Parameters, Client, Responses }; +export { PurviewAccountClient } from "./purviewAccount"; diff --git a/sdk/purview/purview-administration-rest/src/account/models.ts b/sdk/purview/purview-administration-rest/src/account/models.ts new file mode 100644 index 000000000000..de4b9b9277de --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/account/models.ts @@ -0,0 +1,367 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +export interface Account { + /** Gets or sets the identifier. */ + id?: string; + /** Identity Info on the tracked resource */ + identity?: Identity; + /** Gets or sets the location. */ + location?: string; + /** Gets or sets the name. */ + name?: string; + /** Gets or sets the properties. */ + properties?: AccountProperties; + /** Gets or sets the Sku. */ + sku?: AccountSku; + /** Metadata pertaining to creation and last modification of the resource. */ + systemData?: AccountSystemData; + /** Tags on the azure resource. */ + tags?: Record; + /** Gets or sets the type. */ + type?: string; +} + +export interface Identity { + /** Service principal object Id */ + principalId?: string; + /** Tenant Id */ + tenantId?: string; + /** Identity Type */ + type?: "SystemAssigned"; +} + +export interface AccountProperties { + /** + * Cloud connectors. + * External cloud identifier used as part of scanning configuration. + */ + cloudConnectors?: CloudConnectors; + /** Gets the time at which the entity was created. */ + createdAt?: Date; + /** Gets the creator of the entity. */ + createdBy?: string; + /** Gets the creators of the entity's object id. */ + createdByObjectId?: string; + /** The URIs that are the public endpoints of the account. */ + endpoints?: AccountPropertiesEndpoints; + /** Gets or sets the friendly name. */ + friendlyName?: string; + /** Gets or sets the managed resource group name */ + managedResourceGroupName?: string; + /** Gets the resource identifiers of the managed resources. */ + managedResources?: AccountPropertiesManagedResources; + /** Gets the private endpoint connections information. */ + privateEndpointConnections?: Array; + /** Gets or sets the state of the provisioning. */ + provisioningState?: + | "Unknown" + | "Creating" + | "Moving" + | "Deleting" + | "SoftDeleting" + | "SoftDeleted" + | "Failed" + | "Succeeded" + | "Canceled"; + /** Gets or sets the public network access. */ + publicNetworkAccess?: "NotSpecified" | "Enabled" | "Disabled"; +} + +export interface CloudConnectors { + /** + * AWS external identifier. + * Configured in AWS to allow use of the role arn used for scanning + */ + awsExternalId?: string; +} + +export interface AccountEndpoints { + /** Gets the catalog endpoint. */ + catalog?: string; + /** Gets the guardian endpoint. */ + guardian?: string; + /** Gets the scan endpoint. */ + scan?: string; +} + +export interface AccountPropertiesEndpoints extends AccountEndpoints {} + +export interface ManagedResources { + /** Gets the managed event hub namespace resource identifier. */ + eventHubNamespace?: string; + /** Gets the managed resource group resource identifier. This resource group will host resource dependencies for the account. */ + resourceGroup?: string; + /** Gets the managed storage account resource identifier. */ + storageAccount?: string; +} + +export interface AccountPropertiesManagedResources extends ManagedResources {} + +export interface PrivateEndpointConnection { + /** Gets or sets the identifier. */ + id?: string; + /** Gets or sets the name. */ + name?: string; + /** The connection identifier. */ + properties?: PrivateEndpointConnectionProperties; + /** Gets or sets the type. */ + type?: string; +} + +export interface PrivateEndpointConnectionProperties { + /** The private endpoint information. */ + privateEndpoint?: PrivateEndpoint; + /** The private link service connection state. */ + privateLinkServiceConnectionState?: PrivateLinkServiceConnectionState; + /** The provisioning state. */ + provisioningState?: string; +} + +export interface PrivateEndpoint { + /** The private endpoint identifier. */ + id?: string; +} + +export interface PrivateLinkServiceConnectionState { + /** The required actions. */ + actionsRequired?: string; + /** The description. */ + description?: string; + /** The status. */ + status?: "Unknown" | "Pending" | "Approved" | "Rejected" | "Disconnected"; +} + +export interface AccountSku { + /** Gets or sets the sku capacity. Possible values include: 4, 16 */ + capacity?: number; + /** Gets or sets the sku name. */ + name?: "Standard"; +} + +export interface SystemData { + /** The timestamp of resource creation (UTC). */ + createdAt?: Date; + /** The identity that created the resource. */ + createdBy?: string; + /** The type of identity that created the resource. */ + createdByType?: "User" | "Application" | "ManagedIdentity" | "Key"; + /** The timestamp of the last modification the resource (UTC). */ + lastModifiedAt?: Date; + /** The identity that last modified the resource. */ + lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + lastModifiedByType?: "User" | "Application" | "ManagedIdentity" | "Key"; +} + +export interface AccountSystemData extends SystemData {} + +export interface ErrorResponseModel { + /** Gets or sets the error. */ + error?: ErrorResponseModelError; +} + +export interface ErrorModel { + /** Gets or sets the code. */ + code?: string; + /** Gets or sets the details. */ + details?: Array; + /** Gets or sets the messages. */ + message?: string; + /** Gets or sets the target. */ + target?: string; +} + +export interface ErrorResponseModelError extends ErrorModel {} + +export interface DataPlaneAccountUpdateParameters { + /** The friendly name for the azure resource. */ + friendlyName?: string; +} + +export interface AccessKeys { + /** Gets or sets the primary connection string. */ + atlasKafkaPrimaryEndpoint?: string; + /** Gets or sets the secondary connection string. */ + atlasKafkaSecondaryEndpoint?: string; +} + +export interface AccessKeyOptions { + /** The access key type. */ + keyType?: "PrimaryAtlasKafkaKey" | "SecondaryAtlasKafkaKey"; +} + +export interface Collection { + /** Gets the state of the provisioning. */ + collectionProvisioningState?: + | "Unknown" + | "Creating" + | "Moving" + | "Deleting" + | "Failed" + | "Succeeded"; + /** Gets or sets the description. */ + description?: string; + /** Gets or sets the friendly name of the collection. */ + friendlyName?: string; + /** Gets the name. */ + name?: string; + /** Gets or sets the parent collection reference. */ + parentCollection?: CollectionReference; + /** Gets the system data that contains information about who and when created and updated the resource. */ + systemData?: CollectionSystemData; +} + +export interface CollectionReference { + /** Gets or sets the reference name. */ + referenceName?: string; + /** Gets the reference type property. */ + type?: string; +} + +export interface CollectionSystemData extends SystemData {} + +export interface CollectionList { + /** Total item count. */ + count?: number; + /** The Url of next result page. */ + nextLink?: string; + /** Collection of items of type results. */ + value: Array; +} + +export interface CollectionNameResponseList { + /** Total item count. */ + count?: number; + /** The Url of next result page. */ + nextLink?: string; + /** Collection of items of type results. */ + value: Array; +} + +export interface CollectionNameResponse { + /** Gets or sets the friendly name of the collection. */ + friendlyName?: string; + /** Gets the name. */ + name?: string; +} + +export interface CollectionPathResponse { + /** The friendly names of ancestors starting from the default (root) collection and ending with the immediate parent. */ + parentFriendlyNameChain?: Array; + /** The names of ancestors starting from the default (root) collection and ending with the immediate parent. */ + parentNameChain?: Array; +} + +export interface ResourceSetRuleConfig { + /** Gets or sets the advanced resource set property of the account. */ + advancedResourceSet?: AdvancedResourceSet; + /** The name of the rule */ + name?: string; + /** The configuration rules for path pattern extraction. */ + pathPatternConfig?: PathPatternExtractorConfig; +} + +export interface AdvancedResourceSet { + /** Date at which ResourceSetProcessing property of the account is updated. */ + modifiedAt?: Date; + /** The advanced resource property of the account. */ + resourceSetProcessing?: "Default" | "Advanced"; +} + +export interface PathPatternExtractorConfig { + acceptedPatterns?: Array; + complexReplacers?: Array; + createdBy: string; + enableDefaultPatterns: boolean; + lastUpdatedTimestamp?: number; + modifiedBy?: string; + normalizationRules?: Array; + regexReplacers?: Array; + rejectedPatterns?: Array; + scopedRules?: Array; + version?: number; +} + +export interface Filter { + createdBy?: string; + filterType?: "Pattern" | "Regex"; + lastUpdatedTimestamp?: number; + modifiedBy?: string; + name: string; + path: string; +} + +export interface ComplexReplacerConfig { + createdBy?: string; + description?: string; + disabled?: boolean; + disableRecursiveReplacerApplication?: boolean; + lastUpdatedTimestamp?: number; + modifiedBy?: string; + name?: string; + typeName?: string; +} + +export interface NormalizationRule { + description?: string; + disabled?: boolean; + dynamicReplacement?: boolean; + entityTypes?: Array; + lastUpdatedTimestamp?: number; + name?: string; + regex?: FastRegex; + replaceWith?: string; + version?: number; +} + +export interface FastRegex { + maxDigits?: number; + maxLetters?: number; + minDashes?: number; + minDigits?: number; + minDigitsOrLetters?: number; + minDots?: number; + minHex?: number; + minLetters?: number; + minUnderscores?: number; + options?: number; + regexStr?: string; +} + +export interface RegexReplacer { + condition?: string; + createdBy?: string; + description?: string; + disabled: boolean; + disableRecursiveReplacerApplication?: boolean; + doNotReplaceRegex?: FastRegex; + lastUpdatedTimestamp?: number; + modifiedBy?: string; + name: string; + regex?: FastRegex; + replaceWith?: string; +} + +export interface ScopedRule { + bindingUrl: string; + rules?: Array; + storeType: string; +} + +export interface Rule { + displayName?: string; + isResourceSet?: boolean; + lastUpdatedTimestamp?: number; + name?: string; + qualifiedName: string; +} + +export interface ResourceSetRuleConfigList { + /** Total item count. */ + count?: number; + /** The Url of next result page. */ + nextLink?: string; + /** Collection of items of type results. */ + value: Array; +} diff --git a/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts b/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts new file mode 100644 index 000000000000..477bace4a37f --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/account/paginateHelper.ts @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from "@azure/core-paging"; +import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; + +/** + * Helper type to extract the type of an array + */ +export type GetArrayType = T extends Array ? TData : never; + +/** + * The type of a custom function that defines how to get a page and a link to the next one if any. + */ +export type GetPage = ( + pageLink: string, + maxPageSize?: number +) => Promise<{ + page: TPage; + nextPageLink?: string; +}>; + +/** + * Options for the paging helper + */ +export interface PagingOptions { + /** + * Custom function to extract pagination details for crating the PagedAsyncIterableIterator + */ + customGetPage?: GetPage[]>; +} + +/** + * Helper type to infer the Type of the paged elements from the response type + * This type is generated based on the swagger information for x-ms-pageable + * specifically on the itemName property which indicates the property of the response + * where the page items are found. The default value is `value`. + * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter + */ +export type PaginateReturn = TResult extends { + body: { value?: infer TPage }; +} + ? GetArrayType + : Array; + +/** + * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension + * @param client - Client to use for sending the next page requests + * @param initialResponse - Initial response containing the nextLink and current page of elements + * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results + * @returns - PagedAsyncIterableIterator to iterate the elements + */ +export function paginate( + client: Client, + initialResponse: TResponse, + options: PagingOptions = {} +): PagedAsyncIterableIterator> { + // Extract element type from initial response + type TElement = PaginateReturn; + let firstRun = true; + const itemName = "value"; + const nextLinkName = "nextLink"; + const { customGetPage } = options; + const pagedResult: PagedResult = { + firstPageLink: "", + getPage: + typeof customGetPage === "function" + ? customGetPage + : async (pageLink: string) => { + const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get(); + firstRun = false; + checkPagingRequest(result); + const nextLink = getNextLink(result.body, nextLinkName); + const values = getElements(result.body, itemName); + return { + page: values, + nextPageLink: nextLink, + }; + }, + }; + + return getPagedAsyncIterator(pagedResult); +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { + throw new Error(`Body Property ${nextLinkName} should be a string or undefined`); + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + + // value has to be an array according to the x-ms-pageable extension. + // The fact that this must be an array is used above to calculate the + // type of elements in the page in PaginateReturn + if (!Array.isArray(value)) { + throw new Error( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}` + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse): void { + const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"]; + if (!Http2xxStatusCodes.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response + ); + } +} diff --git a/sdk/purview/purview-administration-rest/src/account/parameters.ts b/sdk/purview/purview-administration-rest/src/account/parameters.ts new file mode 100644 index 000000000000..27b79f1a0d7f --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/account/parameters.ts @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { RequestParameters } from "@azure-rest/core-client"; +import { + AccessKeyOptions, + Collection, + DataPlaneAccountUpdateParameters, + ResourceSetRuleConfig, +} from "./models"; + +export type AccountsGetAccountPropertiesParameters = RequestParameters; + +export interface AccountsUpdateAccountPropertiesBodyParam { + body: DataPlaneAccountUpdateParameters; +} + +export type AccountsUpdateAccountPropertiesParameters = AccountsUpdateAccountPropertiesBodyParam & + RequestParameters; +export type AccountsGetAccessKeysParameters = RequestParameters; + +export interface AccountsRegenerateAccessKeyBodyParam { + body: AccessKeyOptions; +} + +export type AccountsRegenerateAccessKeyParameters = AccountsRegenerateAccessKeyBodyParam & + RequestParameters; +export type CollectionsGetCollectionParameters = RequestParameters; + +export interface CollectionsCreateOrUpdateCollectionBodyParam { + body: Collection; +} + +export type CollectionsCreateOrUpdateCollectionParameters = CollectionsCreateOrUpdateCollectionBodyParam & + RequestParameters; +export type CollectionsDeleteCollectionParameters = RequestParameters; + +export interface CollectionsListCollectionsQueryParamProperties { + $skipToken?: string; +} + +export interface CollectionsListCollectionsQueryParam { + queryParameters?: CollectionsListCollectionsQueryParamProperties; +} + +export type CollectionsListCollectionsParameters = CollectionsListCollectionsQueryParam & + RequestParameters; + +export interface CollectionsListChildCollectionNamesQueryParamProperties { + $skipToken?: string; +} + +export interface CollectionsListChildCollectionNamesQueryParam { + queryParameters?: CollectionsListChildCollectionNamesQueryParamProperties; +} + +export type CollectionsListChildCollectionNamesParameters = CollectionsListChildCollectionNamesQueryParam & + RequestParameters; +export type CollectionsGetCollectionPathParameters = RequestParameters; +export type ResourceSetRulesGetResourceSetRuleParameters = RequestParameters; + +export interface ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam { + body: ResourceSetRuleConfig; +} + +export type ResourceSetRulesCreateOrUpdateResourceSetRuleParameters = ResourceSetRulesCreateOrUpdateResourceSetRuleBodyParam & + RequestParameters; +export type ResourceSetRulesDeleteResourceSetRuleParameters = RequestParameters; + +export interface ResourceSetRulesListResourceSetRulesQueryParamProperties { + $skipToken?: string; +} + +export interface ResourceSetRulesListResourceSetRulesQueryParam { + queryParameters?: ResourceSetRulesListResourceSetRulesQueryParamProperties; +} + +export type ResourceSetRulesListResourceSetRulesParameters = ResourceSetRulesListResourceSetRulesQueryParam & + RequestParameters; diff --git a/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts new file mode 100644 index 000000000000..b866f93c8e1b --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/account/purviewAccount.ts @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { TokenCredential } from "@azure/core-auth"; +import { PurviewAccountRestClient } from "./clientDefinitions"; + +export function PurviewAccountClient( + endpoint: string, + credentials: TokenCredential, + options: ClientOptions = {} +): PurviewAccountRestClient { + const baseUrl = options.baseUrl ?? `${endpoint}`; + options.apiVersion = options.apiVersion ?? "2019-11-01-preview"; + options = { + ...options, + credentials: { + scopes: ["https://purview.azure.net/.default"], + }, + }; + + return getClient(baseUrl, credentials, options) as PurviewAccountRestClient; +} diff --git a/sdk/purview/purview-administration-rest/src/account/responses.ts b/sdk/purview/purview-administration-rest/src/account/responses.ts new file mode 100644 index 000000000000..fa366cd4856c --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/account/responses.ts @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { HttpResponse } from "@azure-rest/core-client"; +import { + AccessKeys, + Account, + Collection, + CollectionList, + CollectionNameResponseList, + CollectionPathResponse, + ErrorResponseModel, + ResourceSetRuleConfig, + ResourceSetRuleConfigList, +} from "./models"; + +/** Get an account */ +export interface AccountsGetAccountProperties200Response extends HttpResponse { + status: "200"; + body: Account; +} + +/** Get an account */ +export interface AccountsGetAccountPropertiesdefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Updates an account */ +export interface AccountsUpdateAccountProperties200Response extends HttpResponse { + status: "200"; + body: Account; +} + +/** Updates an account */ +export interface AccountsUpdateAccountPropertiesdefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** List the authorization keys associated with this account. */ +export interface AccountsGetAccessKeys200Response extends HttpResponse { + status: "200"; + body: AccessKeys; +} + +/** List the authorization keys associated with this account. */ +export interface AccountsGetAccessKeysdefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Regenerate the authorization keys associated with this data catalog. */ +export interface AccountsRegenerateAccessKey200Response extends HttpResponse { + status: "200"; + body: AccessKeys; +} + +/** Regenerate the authorization keys associated with this data catalog. */ +export interface AccountsRegenerateAccessKeydefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Get a collection */ +export interface CollectionsGetCollection200Response extends HttpResponse { + status: "200"; + body: Collection; +} + +/** Get a collection */ +export interface CollectionsGetCollectiondefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Creates or updates a collection entity. */ +export interface CollectionsCreateOrUpdateCollection200Response extends HttpResponse { + status: "200"; + body: Collection; +} + +/** Creates or updates a collection entity. */ +export interface CollectionsCreateOrUpdateCollectiondefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Deletes a Collection entity. */ +export interface CollectionsDeleteCollection204Response extends HttpResponse { + status: "204"; + body: Record; +} + +/** Deletes a Collection entity. */ +export interface CollectionsDeleteCollectiondefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** List the collections in the account. */ +export interface CollectionsListCollections200Response extends HttpResponse { + status: "200"; + body: CollectionList; +} + +/** List the collections in the account. */ +export interface CollectionsListCollectionsdefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Lists the child collections names in the collection. */ +export interface CollectionsListChildCollectionNames200Response extends HttpResponse { + status: "200"; + body: CollectionNameResponseList; +} + +/** Lists the child collections names in the collection. */ +export interface CollectionsListChildCollectionNamesdefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Gets the parent name and parent friendly name chains that represent the collection path. */ +export interface CollectionsGetCollectionPath200Response extends HttpResponse { + status: "200"; + body: CollectionPathResponse; +} + +/** Gets the parent name and parent friendly name chains that represent the collection path. */ +export interface CollectionsGetCollectionPathdefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Get a resource set config service model. */ +export interface ResourceSetRulesGetResourceSetRule200Response extends HttpResponse { + status: "200"; + body: ResourceSetRuleConfig; +} + +/** Get a resource set config service model. */ +export interface ResourceSetRulesGetResourceSetRuledefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Creates or updates an resource set config. */ +export interface ResourceSetRulesCreateOrUpdateResourceSetRule200Response extends HttpResponse { + status: "200"; + body: ResourceSetRuleConfig; +} + +/** Creates or updates an resource set config. */ +export interface ResourceSetRulesCreateOrUpdateResourceSetRuledefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Deletes a ResourceSetRuleConfig resource. */ +export interface ResourceSetRulesDeleteResourceSetRule200Response extends HttpResponse { + status: "200"; + body: Record; +} + +/** Deletes a ResourceSetRuleConfig resource. */ +export interface ResourceSetRulesDeleteResourceSetRule204Response extends HttpResponse { + status: "204"; + body: Record; +} + +/** Deletes a ResourceSetRuleConfig resource. */ +export interface ResourceSetRulesDeleteResourceSetRuledefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} + +/** Get a resource set config service model. */ +export interface ResourceSetRulesListResourceSetRules200Response extends HttpResponse { + status: "200"; + body: ResourceSetRuleConfigList; +} + +/** Get a resource set config service model. */ +export interface ResourceSetRulesListResourceSetRulesdefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; +} diff --git a/sdk/purview/purview-administration-rest/src/index.ts b/sdk/purview/purview-administration-rest/src/index.ts new file mode 100644 index 000000000000..97915f77e2a3 --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/index.ts @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as PurviewAccount from "./account"; +import * as PurviewMetadataPolicies from "./metadataPolicies"; + +export { PurviewAccount }; +export { PurviewMetadataPolicies }; +export { PurviewAccountClient } from "./account/purviewAccount"; +export { PurviewMetadataPoliciesClient } from "./metadataPolicies/purviewMetadataPolicies"; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts new file mode 100644 index 000000000000..f37a290d23ca --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/clientDefinitions.ts @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { Client } from "@azure-rest/core-client"; +import { + MetadataPolicyGetParameters, + MetadataPolicyListAllParameters, + MetadataPolicyUpdateParameters, + MetadataRolesListParameters, +} from "./parameters"; +import { + MetadataPolicyGet200Response, + MetadataPolicyGetdefaultResponse, + MetadataPolicyListAll200Response, + MetadataPolicyListAlldefaultResponse, + MetadataPolicyUpdate200Response, + MetadataPolicyUpdatedefaultResponse, + MetadataRolesList200Response, + MetadataRolesListdefaultResponse, +} from "./responses"; + +export interface MetadataRolesList { + /** Lists roles for Purview Account */ + get( + options?: MetadataRolesListParameters + ): Promise; +} + +export interface MetadataPolicyListAll { + /** List or Get metadata policies */ + get( + options?: MetadataPolicyListAllParameters + ): Promise; +} + +export interface MetadataPolicyUpdate { + /** Updates a metadata policy */ + put( + options?: MetadataPolicyUpdateParameters + ): Promise; + /** Gets a metadata policy */ + get( + options?: MetadataPolicyGetParameters + ): Promise; +} + +export interface Routes { + /** Resource for '/metadataRoles' has methods for the following verbs: get */ + (path: "/metadataRoles"): MetadataRolesList; + /** Resource for '/metadataPolicies' has methods for the following verbs: get */ + (path: "/metadataPolicies"): MetadataPolicyListAll; + /** Resource for '/metadataPolicies/\{policyId\}' has methods for the following verbs: put, get */ + (path: "/metadataPolicies/{policyId}", policyId: string): MetadataPolicyUpdate; +} + +export type PurviewMetadataPoliciesRestClient = Client & { + path: Routes; +}; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts new file mode 100644 index 000000000000..a6b44170ceda --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/index.ts @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as Models from "./models"; +import * as Pagination from "./paginateHelper"; +import * as Parameters from "./parameters"; +import * as Client from "./clientDefinitions"; +import * as Responses from "./responses"; +export { PurviewMetadataPoliciesClient } from "./purviewMetadataPolicies"; +export { Models, Pagination, Parameters, Client, Responses }; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/models.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/models.ts new file mode 100644 index 000000000000..1487eb7769ba --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/models.ts @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +export interface MetadataRoleList { + values: Array; + nextLink?: string; +} + +export interface MetadataRole { + /** The Id of role */ + id?: string; + /** The name of role */ + name?: string; + /** The type of role */ + type?: string; + properties?: MetadataRoleProperties; +} + +export interface MetadataRoleProperties { + /** The provisioningState of role */ + provisioningState?: string; + /** The type of role */ + roleType?: string; + /** The friendly name of role */ + friendlyName?: string; + /** The description of role */ + description?: string; + /** The cnf Condition for a rule */ + cnfCondition?: Array>; + /** The dnf Condition for a rule */ + dnfCondition?: Array>; + /** The version of role */ + version?: number; +} + +export interface AttributeMatcher { + /** AttributeName */ + attributeName?: string; + /** Value for attribute */ + attributeValueIncludes?: string; + /** List of values for attribute */ + attributeValueIncludedIn?: Array; + /** Value excluded for attribute */ + attributeValueExcludes?: string; + /** List of values excluded for attribute */ + attributeValueExcludedIn?: Array; +} + +export interface ErrorResponseModel { + /** The error model for metadata policy */ + error: ErrorModel; +} + +export interface ErrorModel { + /** The error code */ + code: string; + /** The error message */ + message: string; + /** The error target */ + target?: string; + /** The error details */ + details?: Array; +} + +export interface MetadataPolicyList { + values: Array; + nextLink?: string; +} + +export interface MetadataPolicy { + /** The name of policy */ + name?: string; + /** The id of policy */ + id?: string; + /** The version of policy */ + version?: number; + properties?: MetadataPolicyProperties; +} + +export interface MetadataPolicyProperties { + /** The description of policy */ + description?: string; + /** The DecisionRules of policy */ + decisionRules?: Array; + /** The AttributeRules of policy */ + attributeRules?: Array; + /** The collection reference for a policy */ + collection?: CollectionReference; + /** The parent collection of the policy */ + parentCollectionName?: string; +} + +export interface DecisionRule { + /** The kind of rule */ + kind?: "decisionrule" | "attributerule"; + /** The effect for rule */ + effect?: "Deny" | "Permit"; + /** The dnf Condition for a rule */ + dnfCondition?: Array>; +} + +export interface AttributeRule { + /** The kind of rule */ + kind?: "decisionrule" | "attributerule"; + /** The id for rule */ + id?: string; + /** The name for rule */ + name?: string; + /** The dnf Condition for a rule */ + dnfCondition?: Array>; +} + +export interface CollectionReference { + /** The type of reference */ + type?: string; + /** The name of reference */ + referenceName?: string; +} diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts new file mode 100644 index 000000000000..dbf2a859f83a --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/paginateHelper.ts @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from "@azure/core-paging"; +import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; + +/** + * Helper type to extract the type of an array + */ +export type GetArrayType = T extends Array ? TData : never; + +/** + * The type of a custom function that defines how to get a page and a link to the next one if any. + */ +export type GetPage = ( + pageLink: string, + maxPageSize?: number +) => Promise<{ + page: TPage; + nextPageLink?: string; +}>; + +/** + * Options for the paging helper + */ +export interface PagingOptions { + /** + * Custom function to extract pagination details for crating the PagedAsyncIterableIterator + */ + customGetPage?: GetPage[]>; +} + +/** + * Helper type to infer the Type of the paged elements from the response type + * This type is generated based on the swagger information for x-ms-pageable + * specifically on the itemName property which indicates the property of the response + * where the page items are found. The default value is `value`. + * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter + */ +export type PaginateReturn = TResult extends + | { + body: { value?: infer TPage }; + } + | { + body: { values?: infer TPage }; + } + ? GetArrayType + : Array; + +/** + * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension + * @param client - Client to use for sending the next page requests + * @param initialResponse - Initial response containing the nextLink and current page of elements + * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results + * @returns - PagedAsyncIterableIterator to iterate the elements + */ +export function paginate( + client: Client, + initialResponse: TResponse, + options: PagingOptions = {} +): PagedAsyncIterableIterator> { + // Extract element type from initial response + type TElement = PaginateReturn; + let firstRun = true; + // We need to check the response for success before trying to inspect it looking for + // the properties to use for nextLink and itemName + checkPagingRequest(initialResponse); + const { itemName, nextLinkName } = getPaginationProperties(initialResponse); + const { customGetPage } = options; + const pagedResult: PagedResult = { + firstPageLink: "", + getPage: + typeof customGetPage === "function" + ? customGetPage + : async (pageLink: string) => { + const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get(); + firstRun = false; + checkPagingRequest(result); + const nextLink = getNextLink(result.body, nextLinkName); + const values = getElements(result.body, itemName); + return { + page: values, + nextPageLink: nextLink, + }; + }, + }; + + return getPagedAsyncIterator(pagedResult); +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { + throw new Error(`Body Property ${nextLinkName} should be a string or undefined`); + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + + // value has to be an array according to the x-ms-pageable extension. + // The fact that this must be an array is used above to calculate the + // type of elements in the page in PaginateReturn + if (!Array.isArray(value)) { + throw new Error( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}` + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse): void { + const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"]; + if (!Http2xxStatusCodes.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response + ); + } +} + +/** + * Extracts the itemName and nextLinkName from the initial response to use them for pagination + */ +function getPaginationProperties(initialResponse: PathUncheckedResponse) { + // Build a set with the passed custom nextLinkNames + const nextLinkNames = new Set(["nextLink"]); + + // Build a set with the passed custom set of itemNames + const itemNames = new Set(["value", "values"]); + + let nextLinkName: string | undefined; + let itemName: string | undefined; + + for (const name of nextLinkNames) { + const nextLink = (initialResponse.body as Record)[name] as string; + if (nextLink) { + nextLinkName = name; + break; + } + } + + for (const name of itemNames) { + const item = (initialResponse.body as Record)[name] as string; + if (item) { + itemName = name; + break; + } + } + + if (!itemName) { + throw new Error( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${[ + ...itemNames, + ].join(" OR ")}` + ); + } + + return { itemName, nextLinkName }; +} diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts new file mode 100644 index 000000000000..4a23773684c3 --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/parameters.ts @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { RequestParameters } from "@azure-rest/core-client"; +import { MetadataPolicy } from "./models"; + +export type MetadataRolesListParameters = RequestParameters; + +export interface MetadataPolicyListAllQueryParamProperties { + /** The name of an existing collection for which one policy needs to be fetched. */ + collectionName?: string; +} + +export interface MetadataPolicyListAllQueryParam { + queryParameters?: MetadataPolicyListAllQueryParamProperties; +} + +export type MetadataPolicyListAllParameters = MetadataPolicyListAllQueryParam & RequestParameters; + +export interface MetadataPolicyUpdateBodyParam { + /** Policy to be updated. */ + body?: MetadataPolicy; +} + +export type MetadataPolicyUpdateParameters = MetadataPolicyUpdateBodyParam & RequestParameters; +export type MetadataPolicyGetParameters = RequestParameters; diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts new file mode 100644 index 000000000000..5530a12a7bda --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/purviewMetadataPolicies.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { TokenCredential } from "@azure/core-auth"; +import { PurviewMetadataPoliciesRestClient } from "./clientDefinitions"; + +export function PurviewMetadataPoliciesClient( + Endpoint: string, + credentials: TokenCredential, + options: ClientOptions = {} +): PurviewMetadataPoliciesRestClient { + const baseUrl = options.baseUrl ?? `${Endpoint}/policyStore`; + options.apiVersion = options.apiVersion ?? "2021-07-01"; + options = { + ...options, + credentials: { + scopes: ["https://purview.azure.net/.default"], + }, + }; + + return getClient(baseUrl, credentials, options) as PurviewMetadataPoliciesRestClient; +} diff --git a/sdk/purview/purview-administration-rest/src/metadataPolicies/responses.ts b/sdk/purview/purview-administration-rest/src/metadataPolicies/responses.ts new file mode 100644 index 000000000000..6152e9cc879e --- /dev/null +++ b/sdk/purview/purview-administration-rest/src/metadataPolicies/responses.ts @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { HttpResponse } from "@azure-rest/core-client"; +import { RawHttpHeaders } from "@azure/core-rest-pipeline"; +import { ErrorResponseModel, MetadataPolicy, MetadataPolicyList, MetadataRoleList } from "./models"; + +/** Lists roles for Purview Account */ +export interface MetadataRolesList200Response extends HttpResponse { + status: "200"; + body: MetadataRoleList; +} + +export interface MetadataRolesListdefaultHeaders { + /** The error code */ + "x-ms-error-code"?: string; +} + +/** Lists roles for Purview Account */ +export interface MetadataRolesListdefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; + headers: RawHttpHeaders & MetadataRolesListdefaultHeaders; +} + +/** List or Get metadata policies */ +export interface MetadataPolicyListAll200Response extends HttpResponse { + status: "200"; + body: MetadataPolicyList; +} + +export interface MetadataPolicyListAlldefaultHeaders { + /** The error code */ + "x-ms-error-code"?: string; +} + +/** List or Get metadata policies */ +export interface MetadataPolicyListAlldefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; + headers: RawHttpHeaders & MetadataPolicyListAlldefaultHeaders; +} + +/** Updates a metadata policy */ +export interface MetadataPolicyUpdate200Response extends HttpResponse { + status: "200"; + body: MetadataPolicy; +} + +export interface MetadataPolicyUpdatedefaultHeaders { + /** The error code */ + "x-ms-error-code"?: string; +} + +/** Updates a metadata policy */ +export interface MetadataPolicyUpdatedefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; + headers: RawHttpHeaders & MetadataPolicyUpdatedefaultHeaders; +} + +/** Gets a metadata policy */ +export interface MetadataPolicyGet200Response extends HttpResponse { + status: "200"; + body: MetadataPolicy; +} + +export interface MetadataPolicyGetdefaultHeaders { + /** The error code */ + "x-ms-error-code"?: string; +} + +/** Gets a metadata policy */ +export interface MetadataPolicyGetdefaultResponse extends HttpResponse { + status: "500"; + body: ErrorResponseModel; + headers: RawHttpHeaders & MetadataPolicyGetdefaultHeaders; +} diff --git a/sdk/purview/purview-administration-rest/swagger/README.md b/sdk/purview/purview-administration-rest/swagger/README.md new file mode 100644 index 000000000000..b59f88059c81 --- /dev/null +++ b/sdk/purview/purview-administration-rest/swagger/README.md @@ -0,0 +1,35 @@ +# Azure Purview Catalog TypeScript Protocol Layer + +> see https://aka.ms/autorest + +## Configuration + +```yaml $(purview-account) == true +title: PurviewAccount +description: Purview Account Client +output-folder: ../src/account +source-code-folder-path: ./ +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/purview/data-plane/Azure.Analytics.Purview.Account/preview/2019-11-01-preview/account.json +``` + +```yaml $(purview-metadata) == true +title: PurviewMetadataPolicies +description: Purview Metadata Policies Client +output-folder: ../src/metadataPolicies +source-code-folder-path: ./ +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/47868932eb81378d95890594b596f09ce27b69e6/specification/purview/data-plane/Azure.Analytics.Purview.MetadataPolicies/preview/2021-07-01/purviewMetadataPolicy.json +``` + + +```yaml +modelerfour.lenient-model-deduplication: true +package-name: "@azure-rest/purview-administration" +generate-metadata: false +license-header: MICROSOFT_MIT_NO_VERSION +package-version: 1.0.0-beta.1 +rest-level-client: true +add-credentials: true +credential-scopes: "https://purview.azure.net/.default" +use-extension: + "@autorest/typescript": "latest" +``` diff --git a/sdk/purview/purview-administration-rest/test/public/account.spec.ts b/sdk/purview/purview-administration-rest/test/public/account.spec.ts new file mode 100644 index 000000000000..ce3d050fb692 --- /dev/null +++ b/sdk/purview/purview-administration-rest/test/public/account.spec.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { PurviewAccount } from "../../src"; +import { Recorder } from "@azure-tools/test-recorder"; + +import { assert } from "chai"; +import { createAccountClient, createRecorder } from "./utils/recordedClient"; +import { Context } from "mocha"; + +describe("Get account info", () => { + let recorder: Recorder; + let client: PurviewAccount.Client.PurviewAccountRestClient; + + beforeEach(function (this: Context) { + recorder = createRecorder(this); + client = createAccountClient(); + }); + + afterEach(async function () { + await recorder.stop(); + }); + + it("should get the account info", async () => { + const result = await client.path("/").get(); + + if (result.status !== "200") { + assert.fail(`GET "/" failed with ${result.status}`); + } + + assert.isDefined(result.body); + }); +}); diff --git a/sdk/purview/purview-administration-rest/test/public/collections.spec.ts b/sdk/purview/purview-administration-rest/test/public/collections.spec.ts new file mode 100644 index 000000000000..524d83d383f6 --- /dev/null +++ b/sdk/purview/purview-administration-rest/test/public/collections.spec.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { PurviewAccount } from "../../src"; +import { Recorder } from "@azure-tools/test-recorder"; + +import { assert } from "chai"; +import { createAccountClient, createRecorder } from "./utils/recordedClient"; +import { Context } from "mocha"; + +describe("List collections", () => { + let recorder: Recorder; + let client: PurviewAccount.Client.PurviewAccountRestClient; + + beforeEach(function (this: Context) { + recorder = createRecorder(this); + client = createAccountClient(); + }); + + afterEach(async function () { + await recorder.stop(); + }); + + it("should list all available collections", async () => { + const result = await client.path("/collections").get(); + + if (result.status !== "200") { + assert.fail(`GET "/collections" failed with ${result.status}`); + } + + assert.isDefined(result.body); + }); +}); diff --git a/sdk/purview/purview-administration-rest/test/public/metadataPolicies.spec.ts b/sdk/purview/purview-administration-rest/test/public/metadataPolicies.spec.ts new file mode 100644 index 000000000000..fbe548d2a1ae --- /dev/null +++ b/sdk/purview/purview-administration-rest/test/public/metadataPolicies.spec.ts @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { PurviewMetadataPolicies } from "../../src"; +import { Recorder } from "@azure-tools/test-recorder"; + +import { assert } from "chai"; +import { createMetadataClient, createRecorder } from "./utils/recordedClient"; +import { Context } from "mocha"; + +describe("List Metadata", () => { + let recorder: Recorder; + let client: PurviewMetadataPolicies.Client.PurviewMetadataPoliciesRestClient; + + beforeEach(function (this: Context) { + recorder = createRecorder(this); + client = createMetadataClient(); + }); + + afterEach(async function () { + await recorder.stop(); + }); + + it("should list all available metdataPolicies", async () => { + const result = await client.path("/metadataPolicies").get(); + + if (result.status !== "200") { + console.log(result.request.url); + assert.fail(`GET "/metadataPolicies" failed with ${result.status}`); + } + + assert.isDefined(result.body.values.length); + }); +}); diff --git a/sdk/purview/purview-administration-rest/test/public/utils/env.browser.ts b/sdk/purview/purview-administration-rest/test/public/utils/env.browser.ts new file mode 100644 index 000000000000..fd2aca680c7b --- /dev/null +++ b/sdk/purview/purview-administration-rest/test/public/utils/env.browser.ts @@ -0,0 +1,2 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. diff --git a/sdk/purview/purview-administration-rest/test/public/utils/env.ts b/sdk/purview/purview-administration-rest/test/public/utils/env.ts new file mode 100644 index 000000000000..0e06855b73ae --- /dev/null +++ b/sdk/purview/purview-administration-rest/test/public/utils/env.ts @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as dotenv from "dotenv"; + +dotenv.config(); diff --git a/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts b/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..217ac23dec3c --- /dev/null +++ b/sdk/purview/purview-administration-rest/test/public/utils/recordedClient.ts @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/// + +import { Context } from "mocha"; + +import { env, Recorder, record, RecorderEnvironmentSetup } from "@azure-tools/test-recorder"; +import { + PurviewAccount, + PurviewAccountClient, + PurviewMetadataPolicies, + PurviewMetadataPoliciesClient, +} from "../../../src"; +import { ClientSecretCredential } from "@azure/identity"; + +import "./env"; +import { ClientOptions } from "@azure-rest/core-client"; + +const replaceableVariables: { [k: string]: string } = { + ENDPOINT: "https://endpoint", + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", +}; + +export const environmentSetup: RecorderEnvironmentSetup = { + replaceableVariables, + customizationsOnRecordings: [ + (recording: string): string => + recording.replace(/"access_token"\s?:\s?"[^"]*"/g, `"access_token":"access_token"`), + // If we put ENDPOINT in replaceableVariables above, it will not capture + // the endpoint string used with nock, which will be expanded to + // https://:443/ and therefore will not match, so we have to do + // this instead. + (recording: string): string => { + const replaced = recording.replace("endpoint:443", "endpoint"); + return replaced; + }, + ], + queryParametersToSkip: [], +}; + +export function createAccountClient( + options?: ClientOptions +): PurviewAccount.Client.PurviewAccountRestClient { + const credential = new ClientSecretCredential( + env.AZURE_TENANT_ID, + env.AZURE_CLIENT_ID, + env.AZURE_CLIENT_SECRET + ); + return PurviewAccountClient(env.ENDPOINT, credential, options); +} + +export function createMetadataClient( + options?: ClientOptions +): PurviewMetadataPolicies.Client.PurviewMetadataPoliciesRestClient { + const credential = new ClientSecretCredential( + env.AZURE_TENANT_ID, + env.AZURE_CLIENT_ID, + env.AZURE_CLIENT_SECRET + ); + return PurviewMetadataPoliciesClient(env.ENDPOINT, credential, options); +} + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export function createRecorder(context: Context): Recorder { + return record(context, environmentSetup); +} diff --git a/sdk/purview/purview-administration-rest/tsconfig.json b/sdk/purview/purview-administration-rest/tsconfig.json new file mode 100644 index 000000000000..72dcb181734a --- /dev/null +++ b/sdk/purview/purview-administration-rest/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../tsconfig.package", + "compilerOptions": { + "outDir": "./dist-esm", + "declarationDir": "./types", + "paths": { + "@azure-rest/purview-administration": ["./src/index"] + } + }, + "include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"] +}