From ba2f28f71a3f04d8bb6e24273989b6f085a7f707 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 10 Dec 2021 03:08:43 +0000 Subject: [PATCH] CodeGen from PR 17000 in Azure/azure-rest-api-specs [Go] Track2 modify readme.go.md 9 (#17000) * [Go] Track2 modify readme.go.md 9 * fix --- common/config/rush/pnpm-lock.yaml | 27 +- rush.json | 5 + .../arm-subscriptions/CHANGELOG.md | 11 + .../{LICENSE.txt => LICENSE} | 4 +- sdk/subscription/arm-subscriptions/README.md | 145 ++- sdk/subscription/arm-subscriptions/_meta.json | 7 + .../arm-subscriptions/api-extractor.json | 18 + .../arm-subscriptions/package.json | 94 +- .../review/arm-subscriptions.api.md | 446 ++++++++ .../arm-subscriptions/rollup.config.js | 211 +++- .../arm-subscriptions/src/index.ts | 12 + .../arm-subscriptions/src/lroImpl.ts | 34 + .../src/models/aliasMappers.ts | 18 - .../arm-subscriptions/src/models/index.ts | 1004 ++++++++--------- .../arm-subscriptions/src/models/mappers.ts | 756 +++++++++---- .../src/models/operationsMappers.ts | 14 - .../src/models/parameters.ts | 109 +- .../models/subscriptionOperationsMappers.ts | 15 - .../src/models/subscriptionsMappers.ts | 16 - .../src/models/tenantsMappers.ts | 13 - .../arm-subscriptions/src/operations/alias.ts | 340 +++--- .../src/operations/billingAccount.ts | 65 ++ .../arm-subscriptions/src/operations/index.ts | 14 +- .../src/operations/operations.ts | 143 ++- .../src/operations/subscription.ts | 289 +++++ .../src/operations/subscriptionOperations.ts | 194 ---- .../src/operations/subscriptionPolicy.ts | 207 ++++ .../src/operations/subscriptions.ts | 227 ---- .../src/operations/tenants.ts | 123 -- .../src/operationsInterfaces/alias.ts | 75 ++ .../operationsInterfaces/billingAccount.ts | 25 + .../src/operationsInterfaces/index.ts | 13 + .../src/operationsInterfaces/operations.ts | 22 + .../src/operationsInterfaces/subscription.ts | 92 ++ .../subscriptionPolicy.ts | 46 + .../src/subscriptionClient.ts | 112 +- .../src/subscriptionClientContext.ts | 54 - .../arm-subscriptions/test/sampleTest.ts | 48 + .../arm-subscriptions/tsconfig.json | 6 +- sdk/subscription/ci.yml | 29 + 40 files changed, 3181 insertions(+), 1902 deletions(-) create mode 100644 sdk/subscription/arm-subscriptions/CHANGELOG.md rename sdk/subscription/arm-subscriptions/{LICENSE.txt => LICENSE} (96%) create mode 100644 sdk/subscription/arm-subscriptions/_meta.json create mode 100644 sdk/subscription/arm-subscriptions/api-extractor.json create mode 100644 sdk/subscription/arm-subscriptions/review/arm-subscriptions.api.md create mode 100644 sdk/subscription/arm-subscriptions/src/index.ts create mode 100644 sdk/subscription/arm-subscriptions/src/lroImpl.ts delete mode 100644 sdk/subscription/arm-subscriptions/src/models/aliasMappers.ts delete mode 100644 sdk/subscription/arm-subscriptions/src/models/operationsMappers.ts delete mode 100644 sdk/subscription/arm-subscriptions/src/models/subscriptionOperationsMappers.ts delete mode 100644 sdk/subscription/arm-subscriptions/src/models/subscriptionsMappers.ts delete mode 100644 sdk/subscription/arm-subscriptions/src/models/tenantsMappers.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operations/billingAccount.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operations/subscription.ts delete mode 100644 sdk/subscription/arm-subscriptions/src/operations/subscriptionOperations.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operations/subscriptionPolicy.ts delete mode 100644 sdk/subscription/arm-subscriptions/src/operations/subscriptions.ts delete mode 100644 sdk/subscription/arm-subscriptions/src/operations/tenants.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operationsInterfaces/alias.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operationsInterfaces/billingAccount.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operationsInterfaces/index.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operationsInterfaces/operations.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscription.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptionPolicy.ts delete mode 100644 sdk/subscription/arm-subscriptions/src/subscriptionClientContext.ts create mode 100644 sdk/subscription/arm-subscriptions/test/sampleTest.ts create mode 100644 sdk/subscription/ci.yml diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 6cf0e93679e3..3adee67c2c01 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -64,6 +64,7 @@ specifiers: '@rush-temp/arm-sqlvirtualmachine': file:./projects/arm-sqlvirtualmachine.tgz '@rush-temp/arm-storage': file:./projects/arm-storage.tgz '@rush-temp/arm-streamanalytics': file:./projects/arm-streamanalytics.tgz + '@rush-temp/arm-subscriptions': file:./projects/arm-subscriptions.tgz '@rush-temp/arm-templatespecs': file:./projects/arm-templatespecs.tgz '@rush-temp/arm-videoanalyzer': file:./projects/arm-videoanalyzer.tgz '@rush-temp/arm-webpubsub': file:./projects/arm-webpubsub.tgz @@ -233,6 +234,7 @@ dependencies: '@rush-temp/arm-sqlvirtualmachine': file:projects/arm-sqlvirtualmachine.tgz '@rush-temp/arm-storage': file:projects/arm-storage.tgz '@rush-temp/arm-streamanalytics': file:projects/arm-streamanalytics.tgz + '@rush-temp/arm-subscriptions': file:projects/arm-subscriptions.tgz '@rush-temp/arm-templatespecs': file:projects/arm-templatespecs.tgz '@rush-temp/arm-videoanalyzer': file:projects/arm-videoanalyzer.tgz '@rush-temp/arm-webpubsub': file:projects/arm-webpubsub.tgz @@ -8648,7 +8650,7 @@ packages: dev: false file:projects/app-configuration.tgz: - resolution: {integrity: sha512-HBZl2EancfACeRLK2hWk+nCAgXrptXnS9hX5E5SLleYzlPHovsJRBWf3bv0NopaHCgFPdRcAw5xwKa1C2tPz2g==, tarball: file:projects/app-configuration.tgz} + resolution: {integrity: sha512-h9nLQwnEqw1OjRBrG2YmgFUD/wOCQe+fC+/45l/Kpeh2QBkLKXeJslgi5fme0YsUC0wmSsZqYaQZtn9mOCLjlw==, tarball: file:projects/app-configuration.tgz} name: '@rush-temp/app-configuration' version: 0.0.0 dependencies: @@ -9122,7 +9124,7 @@ packages: dev: false file:projects/arm-eventhub.tgz: - resolution: {integrity: sha512-u7elK+VQEh/PpmETDYomvdkwVxKVjIPOb6dELGwpNB2cuTV0/nkZUEKeWux+36A8Lhwo5Lyc/XAkKWWlLixwWw==, tarball: file:projects/arm-eventhub.tgz} + resolution: {integrity: sha512-cWryEMqcziFmqSkDI9ZMhEhjBmX3UEdauByCW1fFHAJ9XGHISFxr8jpJ1hKOj+c6mbp5JBD0UIU2MyceWk/OMg==, tarball: file:projects/arm-eventhub.tgz} name: '@rush-temp/arm-eventhub' version: 0.0.0 dependencies: @@ -9851,6 +9853,27 @@ packages: uglify-js: 3.14.3 dev: false + file:projects/arm-subscriptions.tgz: + resolution: {integrity: sha512-+WHfAMiKSndfe4bSl8jXJEa53S1Vv+5IDGDJBkmcaIJ36eADiMFaEsdd6GqJ9gPFeZLGv0v55CiTCUbszEoIqA==, tarball: file:projects/arm-subscriptions.tgz} + name: '@rush-temp/arm-subscriptions' + version: 0.0.0 + dependencies: + '@microsoft/api-extractor': 7.18.19 + '@rollup/plugin-commonjs': 11.0.2_rollup@1.32.1 + '@rollup/plugin-json': 4.1.0_rollup@1.32.1 + '@rollup/plugin-multi-entry': 3.0.1_rollup@1.32.1 + '@rollup/plugin-node-resolve': 8.4.0_rollup@1.32.1 + cross-env: 7.0.3 + mkdirp: 1.0.4 + mocha: 7.2.0 + rimraf: 3.0.2 + rollup: 1.32.1 + rollup-plugin-sourcemaps: 0.4.2_rollup@1.32.1 + tslib: 2.3.1 + typescript: 4.2.4 + uglify-js: 3.14.3 + dev: false + file:projects/arm-templatespecs.tgz: resolution: {integrity: sha512-RgFlqAwnq0UphGTsIEF+hkpnM8jej+SkZtCk9SNx58wLRKIVX9+CDqYOXqtsHgKwYSP+vIopZcyKqYefF7/VPg==, tarball: file:projects/arm-templatespecs.tgz} name: '@rush-temp/arm-templatespecs' diff --git a/rush.json b/rush.json index a7e20ebf1c9d..6235afbbc795 100644 --- a/rush.json +++ b/rush.json @@ -1155,6 +1155,11 @@ "packageName": "@azure/arm-loadtestservice", "projectFolder": "sdk/loadtestservice/arm-loadtestservice", "versionPolicyName": "management" + }, + { + "packageName": "@azure/arm-subscriptions", + "projectFolder": "sdk/subscription/arm-subscriptions", + "versionPolicyName": "management" } ] } \ No newline at end of file diff --git a/sdk/subscription/arm-subscriptions/CHANGELOG.md b/sdk/subscription/arm-subscriptions/CHANGELOG.md new file mode 100644 index 000000000000..9e4493d91d06 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 4.0.0 (2021-12-10) + +The package of @azure/arm-subscriptions is using our next generation design principles since version 4.0.0, which contains breaking changes. + +To understand the detail of the change, please refer to [Changelog](https://aka.ms/js-track2-changelog). + +To migrate the existing applications to the latest version, please refer to [Migration Guide](https://aka.ms/js-track2-migration-guide). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/js-track2-quickstart). diff --git a/sdk/subscription/arm-subscriptions/LICENSE.txt b/sdk/subscription/arm-subscriptions/LICENSE similarity index 96% rename from sdk/subscription/arm-subscriptions/LICENSE.txt rename to sdk/subscription/arm-subscriptions/LICENSE index ea8fb1516028..ccb63b166732 100644 --- a/sdk/subscription/arm-subscriptions/LICENSE.txt +++ b/sdk/subscription/arm-subscriptions/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 Microsoft +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 @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/sdk/subscription/arm-subscriptions/README.md b/sdk/subscription/arm-subscriptions/README.md index ae830c030239..fca45a751d00 100644 --- a/sdk/subscription/arm-subscriptions/README.md +++ b/sdk/subscription/arm-subscriptions/README.md @@ -1,101 +1,98 @@ -## Azure SubscriptionClient SDK for JavaScript +# Azure Subscription client library for JavaScript -This package contains an isomorphic SDK for SubscriptionClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure Subscription client. + +The subscription client + +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/subscription/arm-subscriptions) | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-subscriptions) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-subscriptions) | +[Samples](https://github.com/Azure-Samples/azure-samples-js-management) + +## Getting started ### Currently supported environments - [LTS versions of Node.js](https://nodejs.org/about/releases/) -- Latest versions of Safari, Chrome, Edge, and Firefox. +- Latest versions of Safari, Chrome, Edge and Firefox. + +### Prerequisites + +- An [Azure subscription][azure_sub]. + +### Install the `@azure/arm-subscriptions` package -### How to Install +Install the Azure Subscription client library for JavaScript with `npm`: ```bash npm install @azure/arm-subscriptions ``` -### How to use +### Create and authenticate a `SubscriptionClient` -#### nodejs - Authentication, client creation and listLocations subscriptions as an example written in TypeScript. +To create a client object to access the Azure Subscription API, you will need the `endpoint` of your Azure Subscription resource and a `credential`. The Azure Subscription client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure Subscription resource in the [Azure Portal][azure_portal]. -##### Install @azure/ms-rest-nodeauth +You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). + +To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. ```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" +npm install @azure/identity ``` -##### Sample code - -```typescript -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { SubscriptionClient, SubscriptionModels, SubscriptionMappers } from "@azure/arm-subscriptions"; -const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; - -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new SubscriptionClient(creds, subscriptionId); - const subscriptionId = "testsubscriptionId"; - client.subscriptions.listLocations(subscriptionId).then((result) => { - console.log("The result is:"); - console.log(result); - }); -}).catch((err) => { - console.error(err); -}); +You will also need to **register a new AAD application and grant access to Azure Subscription** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. + +For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). + +```javascript +const { SubscriptionClient } = require("@azure/arm-subscriptions"); +const { DefaultAzureCredential } = require("@azure/identity"); +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new SubscriptionClient(new DefaultAzureCredential(), subscriptionId); ``` -#### browser - Authentication, client creation and listLocations subscriptions as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth +### JavaScript Bundle +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). -```bash -npm install @azure/ms-rest-browserauth -``` +## Key concepts -##### Sample code - -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - -- index.html -```html - - - - @azure/arm-subscriptions sample - - - - - - - - +### SubscriptionClient + +`SubscriptionClient` is the primary interface for developers using the Azure Subscription client library. Explore the methods on this client object to understand the different features of the Azure Subscription service that you can access. + +## Troubleshooting + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: + +```javascript +const { setLogLevel } = require("@azure/logger"); +setLogLevel("info"); ``` +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). + +## Next steps + +Please take a look at the [samples](https://github.com/Azure-Samples/azure-samples-js-management) directory for detailed examples on how to use this library. + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. + ## Related projects -- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) +- [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%2Fsubscription%2Farm-subscriptions%2FREADME.png) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/subscription/arm-subscriptions/README.png) +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_sub]: https://azure.microsoft.com/free/ +[azure_sub]: https://azure.microsoft.com/free/ +[azure_portal]: https://portal.azure.com +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential diff --git a/sdk/subscription/arm-subscriptions/_meta.json b/sdk/subscription/arm-subscriptions/_meta.json new file mode 100644 index 000000000000..ad98e1e21bfd --- /dev/null +++ b/sdk/subscription/arm-subscriptions/_meta.json @@ -0,0 +1,7 @@ +{ + "commit": "2ab4371edba33c23e8d680ed2bf6f98705b5cadb", + "readme": "specification/subscription/resource-manager/readme.md", + "autorest_command": "autorest --version=3.1.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/subscription/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211130.1", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "use": "@autorest/typescript@6.0.0-alpha.16.20211130.1" +} \ No newline at end of file diff --git a/sdk/subscription/arm-subscriptions/api-extractor.json b/sdk/subscription/arm-subscriptions/api-extractor.json new file mode 100644 index 000000000000..e1f72ad999fb --- /dev/null +++ b/sdk/subscription/arm-subscriptions/api-extractor.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", + "docModel": { "enabled": true }, + "apiReport": { "enabled": true, "reportFolder": "./review" }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/arm-subscriptions.d.ts" + }, + "messages": { + "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "extractorMessageReporting": { + "ae-missing-release-tag": { "logLevel": "none" }, + "ae-unresolved-link": { "logLevel": "none" } + } + } +} diff --git a/sdk/subscription/arm-subscriptions/package.json b/sdk/subscription/arm-subscriptions/package.json index 6f56ecd0b90b..2f173f0b92fe 100644 --- a/sdk/subscription/arm-subscriptions/package.json +++ b/sdk/subscription/arm-subscriptions/package.json @@ -1,57 +1,91 @@ { "name": "@azure/arm-subscriptions", + "sdk-type": "mgmt", "author": "Microsoft Corporation", - "description": "SubscriptionClient Library with typescript type definitions for node.js and browser.", - "version": "3.0.0", + "description": "A generated SDK for SubscriptionClient.", + "version": "4.0.0", + "engines": { "node": ">=12.0.0" }, "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.1", - "@azure/ms-rest-js": "^2.0.4", - "tslib": "^1.10.0" + "@azure/core-lro": "^2.2.0", + "@azure/abort-controller": "^1.0.0", + "@azure/core-paging": "^1.2.0", + "@azure/core-client": "^1.0.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.1.0", + "tslib": "^2.2.0" }, - "keywords": [ - "node", - "azure", - "typescript", - "browser", - "isomorphic" - ], + "keywords": ["node", "azure", "typescript", "browser", "isomorphic"], "license": "MIT", - "main": "./dist/arm-subscriptions.js", - "module": "./esm/subscriptionClient.js", - "types": "./esm/subscriptionClient.d.ts", + "main": "./dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/arm-subscriptions.d.ts", "devDependencies": { - "typescript": "^3.5.3", - "rollup": "^1.18.0", - "rollup-plugin-node-resolve": "^5.2.0", + "@microsoft/api-extractor": "^7.18.11", + "@rollup/plugin-commonjs": "11.0.2", + "@rollup/plugin-json": "^4.0.0", + "@rollup/plugin-multi-entry": "^3.0.0", + "@rollup/plugin-node-resolve": "^8.0.0", + "mkdirp": "^1.0.4", + "rollup": "^1.16.3", "rollup-plugin-sourcemaps": "^0.4.2", - "uglify-js": "^3.6.0" + "typescript": "~4.2.0", + "uglify-js": "^3.4.9", + "rimraf": "^3.0.0", + "@azure/identity": "^2.0.1", + "@azure-tools/test-recorder": "^1.0.0", + "mocha": "^7.1.1", + "cross-env": "^7.0.2" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/subscription/arm-subscriptions", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" }, - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, + "bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, "files": [ "dist/**/*.js", "dist/**/*.js.map", "dist/**/*.d.ts", "dist/**/*.d.ts.map", - "esm/**/*.js", - "esm/**/*.js.map", - "esm/**/*.d.ts", - "esm/**/*.d.ts.map", + "dist-esm/**/*.js", + "dist-esm/**/*.js.map", + "dist-esm/**/*.d.ts", + "dist-esm/**/*.d.ts.map", "src/**/*.ts", "README.md", + "LICENSE", "rollup.config.js", - "tsconfig.json" + "tsconfig.json", + "review/*", + "CHANGELOG.md", + "types/*" ], "scripts": { - "build": "tsc && rollup -c rollup.config.js && npm run minify", - "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/arm-subscriptions.js.map'\" -o ./dist/arm-subscriptions.min.js ./dist/arm-subscriptions.js", - "prepack": "npm install && npm run build" + "build": "npm run clean && tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "prepack": "npm run build", + "pack": "npm pack 2>&1", + "extract-api": "api-extractor run --local", + "lint": "echo skipped", + "audit": "echo skipped", + "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "build:node": "echo skipped", + "build:browser": "echo skipped", + "build:test": "echo skipped", + "build:samples": "echo skipped.", + "check-format": "echo skipped", + "execute:samples": "echo skipped", + "format": "echo skipped", + "test": "npm run integration-test", + "test:node": "echo skipped", + "test:browser": "echo skipped", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", + "unit-test:browser": "echo skipped", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", + "integration-test:browser": "echo skipped", + "docs": "echo skipped" }, "sideEffects": false, "autoPublish": true diff --git a/sdk/subscription/arm-subscriptions/review/arm-subscriptions.api.md b/sdk/subscription/arm-subscriptions/review/arm-subscriptions.api.md new file mode 100644 index 000000000000..463fa0ebfa9e --- /dev/null +++ b/sdk/subscription/arm-subscriptions/review/arm-subscriptions.api.md @@ -0,0 +1,446 @@ +## API Report File for "@azure/arm-subscriptions" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import * as coreAuth from '@azure/core-auth'; +import * as coreClient from '@azure/core-client'; +import { PagedAsyncIterableIterator } from '@azure/core-paging'; +import { PollerLike } from '@azure/core-lro'; +import { PollOperationState } from '@azure/core-lro'; + +// @public +export type AcceptOwnership = string; + +// @public +export interface AcceptOwnershipRequest { + properties?: AcceptOwnershipRequestProperties; +} + +// @public +export interface AcceptOwnershipRequestProperties { + displayName: string; + managementGroupId?: string; + tags?: { + [propertyName: string]: string; + }; +} + +// @public +export interface AcceptOwnershipStatusResponse { + readonly acceptOwnershipState?: AcceptOwnership; + readonly billingOwner?: string; + displayName?: string; + readonly subscriptionId?: string; + subscriptionTenantId?: string; + tags?: { + [propertyName: string]: string; + }; +} + +// @public +export interface Alias { + beginCreate(aliasName: string, body: PutAliasRequest, options?: AliasCreateOptionalParams): Promise, AliasCreateResponse>>; + beginCreateAndWait(aliasName: string, body: PutAliasRequest, options?: AliasCreateOptionalParams): Promise; + delete(aliasName: string, options?: AliasDeleteOptionalParams): Promise; + get(aliasName: string, options?: AliasGetOptionalParams): Promise; + list(options?: AliasListOptionalParams): Promise; +} + +// @public +export interface AliasCreateOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type AliasCreateResponse = SubscriptionAliasResponse; + +// @public +export interface AliasDeleteOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface AliasGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AliasGetResponse = SubscriptionAliasResponse; + +// @public +export interface AliasListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type AliasListResponse = SubscriptionAliasListResult; + +// @public +export interface BillingAccount { + getPolicy(billingAccountId: string, options?: BillingAccountGetPolicyOptionalParams): Promise; +} + +// @public +export interface BillingAccountGetPolicyOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type BillingAccountGetPolicyResponse = BillingAccountPoliciesResponse; + +// @public +export interface BillingAccountPoliciesResponse { + readonly id?: string; + readonly name?: string; + properties?: BillingAccountPoliciesResponseProperties; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export interface BillingAccountPoliciesResponseProperties { + allowTransfers?: boolean; + serviceTenants?: ServiceTenantResponse[]; +} + +// @public +export interface CanceledSubscriptionId { + readonly value?: string; +} + +// @public +export type CreatedByType = string; + +// @public +export interface EnabledSubscriptionId { + readonly value?: string; +} + +// @public +export interface ErrorResponse { + code?: string; + message?: string; +} + +// @public +export interface ErrorResponseBody { + code?: string; + error?: ErrorResponse; + message?: string; +} + +// @public +export interface GetTenantPolicyListResponse { + readonly nextLink?: string; + readonly value?: GetTenantPolicyResponse[]; +} + +// @public +export interface GetTenantPolicyResponse { + readonly id?: string; + readonly name?: string; + properties?: TenantPolicy; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export enum KnownAcceptOwnership { + // (undocumented) + Completed = "Completed", + // (undocumented) + Expired = "Expired", + // (undocumented) + Pending = "Pending" +} + +// @public +export enum KnownCreatedByType { + // (undocumented) + Application = "Application", + // (undocumented) + Key = "Key", + // (undocumented) + ManagedIdentity = "ManagedIdentity", + // (undocumented) + User = "User" +} + +// @public +export enum KnownProvisioningState { + // (undocumented) + Accepted = "Accepted", + // (undocumented) + Failed = "Failed", + // (undocumented) + Succeeded = "Succeeded" +} + +// @public +export enum KnownWorkload { + // (undocumented) + DevTest = "DevTest", + // (undocumented) + Production = "Production" +} + +// @public +export interface Operation { + display?: OperationDisplay; + isDataAction?: boolean; + name?: string; +} + +// @public +export interface OperationDisplay { + description?: string; + operation?: string; + provider?: string; + resource?: string; +} + +// @public +export interface OperationListResult { + nextLink?: string; + value?: Operation[]; +} + +// @public +export interface Operations { + list(options?: OperationsListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface OperationsListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListNextResponse = OperationListResult; + +// @public +export interface OperationsListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListResponse = OperationListResult; + +// @public +export type ProvisioningState = string; + +// @public +export interface PutAliasRequest { + properties?: PutAliasRequestProperties; +} + +// @public +export interface PutAliasRequestAdditionalProperties { + managementGroupId?: string; + subscriptionOwnerId?: string; + subscriptionTenantId?: string; + tags?: { + [propertyName: string]: string; + }; +} + +// @public +export interface PutAliasRequestProperties { + additionalProperties?: PutAliasRequestAdditionalProperties; + billingScope?: string; + displayName?: string; + resellerId?: string; + subscriptionId?: string; + workload?: Workload; +} + +// @public +export interface PutTenantPolicyRequestProperties { + blockSubscriptionsIntoTenant?: boolean; + blockSubscriptionsLeavingTenant?: boolean; + exemptedPrincipals?: string[]; +} + +// @public +export interface RenamedSubscriptionId { + readonly value?: string; +} + +// @public +export interface ServiceTenantResponse { + tenantId?: string; + tenantName?: string; +} + +// @public +export interface Subscription { + acceptOwnershipStatus(subscriptionId: string, options?: SubscriptionAcceptOwnershipStatusOptionalParams): Promise; + beginAcceptOwnership(subscriptionId: string, body: AcceptOwnershipRequest, options?: SubscriptionAcceptOwnershipOptionalParams): Promise, SubscriptionAcceptOwnershipResponse>>; + beginAcceptOwnershipAndWait(subscriptionId: string, body: AcceptOwnershipRequest, options?: SubscriptionAcceptOwnershipOptionalParams): Promise; + cancel(subscriptionId: string, options?: SubscriptionCancelOptionalParams): Promise; + enable(subscriptionId: string, options?: SubscriptionEnableOptionalParams): Promise; + rename(subscriptionId: string, body: SubscriptionName, options?: SubscriptionRenameOptionalParams): Promise; +} + +// @public +export interface SubscriptionAcceptOwnershipHeaders { + location?: string; + retryAfter?: number; +} + +// @public +export interface SubscriptionAcceptOwnershipOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type SubscriptionAcceptOwnershipResponse = SubscriptionAcceptOwnershipHeaders; + +// @public +export interface SubscriptionAcceptOwnershipStatusOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionAcceptOwnershipStatusResponse = AcceptOwnershipStatusResponse; + +// @public +export interface SubscriptionAliasListResult { + readonly nextLink?: string; + readonly value?: SubscriptionAliasResponse[]; +} + +// @public +export interface SubscriptionAliasResponse { + readonly id?: string; + readonly name?: string; + properties?: SubscriptionAliasResponseProperties; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export interface SubscriptionAliasResponseProperties { + readonly acceptOwnershipState?: AcceptOwnership; + readonly acceptOwnershipUrl?: string; + billingScope?: string; + displayName?: string; + managementGroupId?: string; + provisioningState?: ProvisioningState; + resellerId?: string; + readonly subscriptionId?: string; + subscriptionOwnerId?: string; + tags?: { + [propertyName: string]: string; + }; + workload?: Workload; +} + +// @public +export interface SubscriptionCancelOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionCancelResponse = CanceledSubscriptionId; + +// @public (undocumented) +export class SubscriptionClient extends coreClient.ServiceClient { + // (undocumented) + $host: string; + constructor(credentials: coreAuth.TokenCredential, options?: SubscriptionClientOptionalParams); + // (undocumented) + alias: Alias; + // (undocumented) + apiVersion: string; + // (undocumented) + billingAccount: BillingAccount; + // (undocumented) + operations: Operations; + // (undocumented) + subscription: Subscription; + // (undocumented) + subscriptionPolicy: SubscriptionPolicy; +} + +// @public +export interface SubscriptionClientOptionalParams extends coreClient.ServiceClientOptions { + $host?: string; + apiVersion?: string; + endpoint?: string; +} + +// @public +export interface SubscriptionEnableOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionEnableResponse = EnabledSubscriptionId; + +// @public +export interface SubscriptionName { + subscriptionName?: string; +} + +// @public +export interface SubscriptionPolicy { + addUpdatePolicyForTenant(body: PutTenantPolicyRequestProperties, options?: SubscriptionPolicyAddUpdatePolicyForTenantOptionalParams): Promise; + getPolicyForTenant(options?: SubscriptionPolicyGetPolicyForTenantOptionalParams): Promise; + listPolicyForTenant(options?: SubscriptionPolicyListPolicyForTenantOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface SubscriptionPolicyAddUpdatePolicyForTenantOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionPolicyAddUpdatePolicyForTenantResponse = GetTenantPolicyResponse; + +// @public +export interface SubscriptionPolicyGetPolicyForTenantOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionPolicyGetPolicyForTenantResponse = GetTenantPolicyResponse; + +// @public +export interface SubscriptionPolicyListPolicyForTenantNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionPolicyListPolicyForTenantNextResponse = GetTenantPolicyListResponse; + +// @public +export interface SubscriptionPolicyListPolicyForTenantOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionPolicyListPolicyForTenantResponse = GetTenantPolicyListResponse; + +// @public +export interface SubscriptionRenameOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionRenameResponse = RenamedSubscriptionId; + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export interface TenantPolicy { + blockSubscriptionsIntoTenant?: boolean; + blockSubscriptionsLeavingTenant?: boolean; + exemptedPrincipals?: string[]; + readonly policyId?: string; +} + +// @public +export type Workload = string; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/subscription/arm-subscriptions/rollup.config.js b/sdk/subscription/arm-subscriptions/rollup.config.js index 31cf8990d22c..9be1955eb7f1 100644 --- a/sdk/subscription/arm-subscriptions/rollup.config.js +++ b/sdk/subscription/arm-subscriptions/rollup.config.js @@ -1,37 +1,188 @@ -import rollup from "rollup"; -import nodeResolve from "rollup-plugin-node-resolve"; +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import nodeResolve from "@rollup/plugin-node-resolve"; +import cjs from "@rollup/plugin-commonjs"; import sourcemaps from "rollup-plugin-sourcemaps"; +import multiEntry from "@rollup/plugin-multi-entry"; +import json from "@rollup/plugin-json"; + +import nodeBuiltins from "builtin-modules"; + +/** + * Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api. + * + * NOTE: this manual configuration is only needed because OpenTelemetry uses an + * __exportStar downleveled helper function to declare its exports which confuses + * rollup's automatic discovery mechanism. + * + * @returns an object reference that can be `...`'d into your cjs() configuration. + */ +export function openTelemetryCommonJs() { + const namedExports = {}; + + for (const key of [ + "@opentelemetry/api", + "@azure/core-tracing/node_modules/@opentelemetry/api" + ]) { + namedExports[key] = [ + "SpanKind", + "TraceFlags", + "getSpan", + "setSpan", + "SpanStatusCode", + "getSpanContext", + "setSpanContext" + ]; + } + + const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"]; + + for (const version of releasedOpenTelemetryVersions) { + namedExports[ + // working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path. + `../../../common/temp/node_modules/.pnpm/@opentelemetry/api@${version}/node_modules/@opentelemetry/api/build/src/index.js` + ] = [ + "SpanKind", + "TraceFlags", + "getSpan", + "setSpan", + "StatusCode", + "CanonicalCode", + "getSpanContext", + "setSpanContext" + ]; + } + + return namedExports; +} + +// #region Warning Handler /** - * @type {rollup.RollupFileOptions} + * A function that can determine whether a rollupwarning should be ignored. If + * the function returns `true`, then the warning will not be displayed. */ -const config = { - input: "./esm/subscriptionClient.js", - external: [ - "@azure/ms-rest-js", - "@azure/ms-rest-azure-js" - ], - output: { - file: "./dist/arm-subscriptions.js", - format: "umd", - name: "Azure.ArmSubscriptions", - sourcemap: true, - globals: { - "@azure/ms-rest-js": "msRest", - "@azure/ms-rest-azure-js": "msRestAzure" + +function ignoreNiseSinonEvalWarnings(warning) { + return ( + warning.code === "EVAL" && + warning.id && + (warning.id.includes("node_modules/nise") || + warning.id.includes("node_modules/sinon")) === true + ); +} + +function ignoreChaiCircularDependencyWarnings(warning) { + return ( + warning.code === "CIRCULAR_DEPENDENCY" && + warning.importer && warning.importer.includes("node_modules/chai") === true + ); +} + +const warningInhibitors = [ + ignoreChaiCircularDependencyWarnings, + ignoreNiseSinonEvalWarnings +]; + +/** + * Construct a warning handler for the shared rollup configuration + * that ignores certain warnings that are not relevant to testing. + */ +function makeOnWarnForTesting() { + return (warning, warn) => { + // If every inhibitor returns false (i.e. no inhibitors), then show the warning + if (warningInhibitors.every((inhib) => !inhib(warning))) { + warn(warning); + } + }; +} + +// #endregion + +function makeBrowserTestConfig() { + const config = { + input: { + include: ["dist-esm/test/**/*.spec.js"], + exclude: ["dist-esm/test/**/node/**"] }, - banner: `/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */` - }, - plugins: [ - nodeResolve({ mainFields: ['module', 'main'] }), - sourcemaps() - ] + output: { + file: `dist-test/index.browser.js`, + format: "umd", + sourcemap: true + }, + preserveSymlinks: false, + plugins: [ + multiEntry({ exports: false }), + nodeResolve({ + mainFields: ["module", "browser"] + }), + cjs({ + namedExports: { + // Chai's strange internal architecture makes it impossible to statically + // analyze its exports. + chai: [ + "version", + "use", + "util", + "config", + "expect", + "should", + "assert" + ], + ...openTelemetryCommonJs() + } + }), + json(), + sourcemaps() + //viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) + ], + onwarn: makeOnWarnForTesting(), + // Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, + // rollup started respecting the "sideEffects" field in package.json. Since + // our package.json sets "sideEffects=false", this also applies to test + // code, which causes all tests to be removed by tree-shaking. + treeshake: false + }; + + return config; +} + +const defaultConfigurationOptions = { + disableBrowserBundle: false }; -export default config; +export function makeConfig(pkg, options) { + options = { + ...defaultConfigurationOptions, + ...(options || {}) + }; + + const baseConfig = { + // Use the package's module field if it has one + input: pkg["module"] || "dist-esm/src/index.js", + external: [ + ...nodeBuiltins, + ...Object.keys(pkg.dependencies), + ...Object.keys(pkg.devDependencies) + ], + output: { file: "dist/index.js", format: "cjs", sourcemap: true }, + preserveSymlinks: false, + plugins: [sourcemaps(), nodeResolve(), cjs()] + }; + + const config = [baseConfig]; + + if (!options.disableBrowserBundle) { + config.push(makeBrowserTestConfig()); + } + + return config; +} + +export default makeConfig(require("./package.json")); diff --git a/sdk/subscription/arm-subscriptions/src/index.ts b/sdk/subscription/arm-subscriptions/src/index.ts new file mode 100644 index 000000000000..e21d9f74104f --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/index.ts @@ -0,0 +1,12 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +/// +export * from "./models"; +export { SubscriptionClient } from "./subscriptionClient"; +export * from "./operationsInterfaces"; diff --git a/sdk/subscription/arm-subscriptions/src/lroImpl.ts b/sdk/subscription/arm-subscriptions/src/lroImpl.ts new file mode 100644 index 000000000000..518d5f053b4e --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/lroImpl.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { LongRunningOperation, LroResponse } from "@azure/core-lro"; + +export class LroImpl implements LongRunningOperation { + constructor( + private sendOperationFn: (args: any, spec: any) => Promise>, + private args: Record, + private spec: { + readonly requestBody?: unknown; + readonly path?: string; + readonly httpMethod: string; + } & Record, + public requestPath: string = spec.path!, + public requestMethod: string = spec.httpMethod + ) {} + public async sendInitialRequest(): Promise> { + return this.sendOperationFn(this.args, this.spec); + } + public async sendPollRequest(path: string): Promise> { + const { requestBody, ...restSpec } = this.spec; + return this.sendOperationFn(this.args, { + ...restSpec, + path, + httpMethod: "GET" + }); + } +} diff --git a/sdk/subscription/arm-subscriptions/src/models/aliasMappers.ts b/sdk/subscription/arm-subscriptions/src/models/aliasMappers.ts deleted file mode 100644 index ecda8fcc7595..000000000000 --- a/sdk/subscription/arm-subscriptions/src/models/aliasMappers.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export { - BaseResource, - ErrorResponse, - ErrorResponseBody, - PutAliasListResult, - PutAliasRequest, - PutAliasRequestProperties, - PutAliasResponse, - PutAliasResponseProperties -} from "../models/mappers"; diff --git a/sdk/subscription/arm-subscriptions/src/models/index.ts b/sdk/subscription/arm-subscriptions/src/models/index.ts index 91d12eedaaf2..e76afd65ee4c 100644 --- a/sdk/subscription/arm-subscriptions/src/models/index.ts +++ b/sdk/subscription/arm-subscriptions/src/models/index.ts @@ -1,686 +1,580 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { BaseResource, CloudError, AzureServiceClientOptions } from "@azure/ms-rest-azure-js"; -import * as msRest from "@azure/ms-rest-js"; +import * as coreClient from "@azure/core-client"; -export { BaseResource, CloudError }; - -/** - * Location information. - */ -export interface Location { - /** - * The fully qualified ID of the location. For example, - * /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly id?: string; - /** - * The subscription ID. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly subscriptionId?: string; - /** - * The location name. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly name?: string; - /** - * The display name of the location. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly displayName?: string; - /** - * The latitude of the location. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly latitude?: string; - /** - * The longitude of the location. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly longitude?: string; -} - -/** - * Subscription policies. - */ -export interface SubscriptionPolicies { - /** - * The subscription location placement ID. The ID indicates which regions are visible for a - * subscription. For example, a subscription with a location placement Id of Public_2014-09-01 - * has access to Azure public regions. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly locationPlacementId?: string; - /** - * The subscription quota ID. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly quotaId?: string; - /** - * The subscription spending limit. Possible values include: 'On', 'Off', 'CurrentPeriodOff' - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly spendingLimit?: SpendingLimit; -} - -/** - * Subscription information. - */ -export interface Subscription { - /** - * The fully qualified ID for the subscription. For example, - * /subscriptions/00000000-0000-0000-0000-000000000000. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly id?: string; - /** - * The subscription ID. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly subscriptionId?: string; - /** - * The subscription display name. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly displayName?: string; - /** - * The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. - * Possible values include: 'Enabled', 'Warned', 'PastDue', 'Disabled', 'Deleted' - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly state?: SubscriptionState; - /** - * The subscription policies. - */ - subscriptionPolicies?: SubscriptionPolicies; +/** The ID of the canceled subscription */ +export interface CanceledSubscriptionId { /** - * The authorization source of the request. Valid values are one or more combinations of Legacy, - * RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. + * The ID of the canceled subscription + * NOTE: This property will not be serialized. It can only be populated by the server. */ - authorizationSource?: string; + readonly value?: string; } -/** - * Tenant Id information. - */ -export interface TenantIdDescription { - /** - * The fully qualified ID of the tenant. For example, - * /tenants/00000000-0000-0000-0000-000000000000. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly id?: string; - /** - * The tenant ID. For example, 00000000-0000-0000-0000-000000000000. - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly tenantId?: string; +/** Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. */ +export interface ErrorResponseBody { + /** The details of the error. */ + error?: ErrorResponse; + /** Error code */ + code?: string; + /** Error message indicating why the operation failed. */ + message?: string; } -/** - * Describes the format of Error response. - */ +/** Describes the format of Error response. */ export interface ErrorResponse { - /** - * Error code - */ + /** Error code */ code?: string; - /** - * Error message indicating why the operation failed. - */ + /** Error message indicating why the operation failed. */ message?: string; } -/** - * Error response indicates that the service is not able to process the incoming request. The - * reason is provided in the error message. - */ -export interface ErrorResponseBody { - /** - * The details of the error. - */ - error?: ErrorResponse; -} - -/** - * The ID of the canceled subscription - */ -export interface CanceledSubscriptionId { - /** - * The ID of the canceled subscription - * **NOTE: This property will not be serialized. It can only be populated by the server.** - */ - readonly value?: string; +/** The new name of the subscription. */ +export interface SubscriptionName { + /** New subscription name */ + subscriptionName?: string; } -/** - * The ID of the subscriptions that is being renamed - */ +/** The ID of the subscriptions that is being renamed */ export interface RenamedSubscriptionId { /** * The ID of the subscriptions that is being renamed - * **NOTE: This property will not be serialized. It can only be populated by the server.** + * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly value?: string; } -/** - * The ID of the subscriptions that is being enabled - */ +/** The ID of the subscriptions that is being enabled */ export interface EnabledSubscriptionId { /** * The ID of the subscriptions that is being enabled - * **NOTE: This property will not be serialized. It can only be populated by the server.** + * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly value?: string; } -/** - * The new name of the subscription. - */ -export interface SubscriptionName { - /** - * New subscription name - */ - subscriptionName?: string; +/** Result of the request to list operations. It contains a list of operations and a URL link to get the next set of results. */ +export interface OperationListResult { + /** List of operations. */ + value?: Operation[]; + /** URL to get the next set of operation list results if there are any. */ + nextLink?: string; } -/** - * The object that represents the operation. - */ +/** REST API operation */ +export interface Operation { + /** Operation name: {provider}/{resource}/{operation} */ + name?: string; + /** Indicates whether the operation is a data action */ + isDataAction?: boolean; + /** The object that represents the operation. */ + display?: OperationDisplay; +} + +/** The object that represents the operation. */ export interface OperationDisplay { - /** - * Service provider: Microsoft.Subscription - */ + /** Service provider: Microsoft.Subscription */ provider?: string; - /** - * Resource on which the operation is performed: Profile, endpoint, etc. - */ + /** Resource on which the operation is performed: Profile, endpoint, etc. */ resource?: string; + /** Operation type: Read, write, delete, etc. */ + operation?: string; + /** Localized friendly description for the operation */ + description?: string; +} + +/** The parameters required to create a new subscription. */ +export interface PutAliasRequest { + /** Put alias request properties. */ + properties?: PutAliasRequestProperties; +} + +/** Put subscription properties. */ +export interface PutAliasRequestProperties { + /** The friendly name of the subscription. */ + displayName?: string; + /** The workload type of the subscription. It can be either Production or DevTest. */ + workload?: Workload; /** - * Operation type: Read, write, delete, etc. + * Billing scope of the subscription. + * For CustomerLed and FieldLed - /billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName} + * For PartnerLed - /billingAccounts/{billingAccountName}/customers/{customerName} + * For Legacy EA - /billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName} */ - operation?: string; + billingScope?: string; + /** This parameter can be used to create alias for existing subscription Id */ + subscriptionId?: string; + /** Reseller Id */ + resellerId?: string; + /** Put alias request additional properties. */ + additionalProperties?: PutAliasRequestAdditionalProperties; } -/** - * REST API operation - */ -export interface Operation { +/** Put subscription additional properties. */ +export interface PutAliasRequestAdditionalProperties { + /** Management group Id for the subscription. */ + managementGroupId?: string; + /** Tenant Id of the subscription */ + subscriptionTenantId?: string; + /** Owner Id of the subscription */ + subscriptionOwnerId?: string; + /** Tags for the subscription */ + tags?: { [propertyName: string]: string }; +} + +/** Subscription Information with the alias. */ +export interface SubscriptionAliasResponse { /** - * Operation name: {provider}/{resource}/{operation} + * Fully qualified ID for the alias resource. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - name?: string; + readonly id?: string; /** - * The object that represents the operation. + * Alias ID. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - display?: OperationDisplay; -} - -/** - * Result of the request to list operations. It contains a list of operations and a URL link to get - * the next set of results. - */ -export interface OperationListResult { + readonly name?: string; /** - * List of operations. + * Resource type, Microsoft.Subscription/aliases. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - value?: Operation[]; + readonly type?: string; + /** Subscription Alias response properties. */ + properties?: SubscriptionAliasResponseProperties; /** - * URL to get the next set of operation list results if there are any. + * Metadata pertaining to creation and last modification of the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - nextLink?: string; + readonly systemData?: SystemData; } -/** - * Put subscription properties. - */ -export interface PutAliasRequestProperties { +/** Put subscription creation result properties. */ +export interface SubscriptionAliasResponseProperties { /** - * The friendly name of the subscription. + * Newly created subscription Id. + * NOTE: This property will not be serialized. It can only be populated by the server. */ + readonly subscriptionId?: string; + /** The display name of the subscription. */ displayName?: string; + /** The provisioning state of the resource. */ + provisioningState?: ProvisioningState; /** - * The workload type of the subscription. It can be either Production or DevTest. Possible values - * include: 'Production', 'DevTest' + * Url to accept ownership of the subscription. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - workload?: Workload; + readonly acceptOwnershipUrl?: string; /** - * Determines whether subscription is fieldLed, partnerLed or LegacyEA + * The accept ownership state of the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - billingScope?: string; + readonly acceptOwnershipState?: AcceptOwnership; /** - * This parameter can be used to create alias for existing subscription Id - */ - subscriptionId?: string; - /** - * Reseller ID, basically MPN Id + * Billing scope of the subscription. + * For CustomerLed and FieldLed - /billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName} + * For PartnerLed - /billingAccounts/{billingAccountName}/customers/{customerName} + * For Legacy EA - /billingAccounts/{billingAccountName}/enrollmentAccounts/{enrollmentAccountName} */ + billingScope?: string; + /** The workload type of the subscription. It can be either Production or DevTest. */ + workload?: Workload; + /** Reseller Id */ resellerId?: string; + /** Owner Id of the subscription */ + subscriptionOwnerId?: string; + /** The Management Group Id. */ + managementGroupId?: string; + /** Tags for the subscription */ + tags?: { [propertyName: string]: string }; } -/** - * The parameters required to create a new subscription. - */ -export interface PutAliasRequest { +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemData { + /** The identity that created the resource. */ + createdBy?: string; + /** The type of identity that created the resource. */ + createdByType?: CreatedByType; + /** The timestamp of resource creation (UTC). */ + createdAt?: Date; + /** The identity that last modified the resource. */ + lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + lastModifiedByType?: CreatedByType; + /** The timestamp of resource last modification (UTC) */ + lastModifiedAt?: Date; +} + +/** The list of aliases. */ +export interface SubscriptionAliasListResult { /** - * Put alias request properties. + * The list of alias. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - properties: PutAliasRequestProperties; + readonly value?: SubscriptionAliasResponse[]; + /** + * The link (url) to the next page of results. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nextLink?: string; } -/** - * Put subscription creation result properties. - */ -export interface PutAliasResponseProperties { +/** The parameters required to accept subscription ownership. */ +export interface AcceptOwnershipRequest { + /** Accept subscription ownership request properties. */ + properties?: AcceptOwnershipRequestProperties; +} + +/** Accept subscription ownership request properties. */ +export interface AcceptOwnershipRequestProperties { + /** The friendly name of the subscription. */ + displayName: string; + /** Management group Id for the subscription. */ + managementGroupId?: string; + /** Tags for the subscription */ + tags?: { [propertyName: string]: string }; +} + +/** Subscription Accept Ownership Response */ +export interface AcceptOwnershipStatusResponse { /** * Newly created subscription Id. - * **NOTE: This property will not be serialized. It can only be populated by the server.** + * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly subscriptionId?: string; /** - * The provisioning state of the resource. Possible values include: 'Accepted', 'Succeeded', - * 'Failed' + * The accept ownership state of the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - provisioningState?: ProvisioningState; + readonly acceptOwnershipState?: AcceptOwnership; + /** + * UPN of the billing owner + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly billingOwner?: string; + /** Tenant Id of the subscription */ + subscriptionTenantId?: string; + /** The display name of the subscription. */ + displayName?: string; + /** Tags for the subscription */ + tags?: { [propertyName: string]: string }; } -/** - * Subscription Information with the alias. - */ -export interface PutAliasResponse extends BaseResource { +/** Put tenant policy request properties. */ +export interface PutTenantPolicyRequestProperties { + /** Blocks the leaving of subscriptions from user's tenant. */ + blockSubscriptionsLeavingTenant?: boolean; + /** Blocks the entering of subscriptions into user's tenant. */ + blockSubscriptionsIntoTenant?: boolean; + /** List of user objectIds that are exempted from the set subscription tenant policies for the user's tenant. */ + exemptedPrincipals?: string[]; +} + +/** Tenant policy Information. */ +export interface GetTenantPolicyResponse { /** - * Fully qualified ID for the alias resource. - * **NOTE: This property will not be serialized. It can only be populated by the server.** + * Policy Id. + * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly id?: string; /** - * Alias ID. - * **NOTE: This property will not be serialized. It can only be populated by the server.** + * Policy name. + * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly name?: string; /** - * Resource type, Microsoft.Subscription/aliases. - * **NOTE: This property will not be serialized. It can only be populated by the server.** + * Resource type. + * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly type?: string; + /** Tenant policy properties. */ + properties?: TenantPolicy; /** - * Put Alias response properties. + * Metadata pertaining to creation and last modification of the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - properties?: PutAliasResponseProperties; + readonly systemData?: SystemData; } -/** - * The list of aliases. - */ -export interface PutAliasListResult { +/** Tenant policy. */ +export interface TenantPolicy { /** - * The list of alias. - * **NOTE: This property will not be serialized. It can only be populated by the server.** + * Policy Id. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly value?: PutAliasResponse[]; + readonly policyId?: string; + /** Blocks the leaving of subscriptions from user's tenant. */ + blockSubscriptionsLeavingTenant?: boolean; + /** Blocks the entering of subscriptions into user's tenant. */ + blockSubscriptionsIntoTenant?: boolean; + /** List of user objectIds that are exempted from the set subscription tenant policies for the user's tenant. */ + exemptedPrincipals?: string[]; +} + +/** Tenant policy information list. */ +export interface GetTenantPolicyListResponse { + /** + * The list of tenant policies. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: GetTenantPolicyResponse[]; /** * The link (url) to the next page of results. - * **NOTE: This property will not be serialized. It can only be populated by the server.** + * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly nextLink?: string; } -/** - * An interface representing SubscriptionClientOptions. - */ -export interface SubscriptionClientOptions extends AzureServiceClientOptions { - baseUri?: string; +/** Billing account policies information. */ +export interface BillingAccountPoliciesResponse { + /** + * Fully qualified ID for the policy. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * Policy name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * Resource type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** Billing account policies response properties. */ + properties?: BillingAccountPoliciesResponseProperties; + /** + * Metadata pertaining to creation and last modification of the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly systemData?: SystemData; } -/** - * @interface - * Location list operation response. - * @extends Array - */ -export interface LocationListResult extends Array { +/** Put billing account policies response properties. */ +export interface BillingAccountPoliciesResponseProperties { + /** Service tenant for the billing account. */ + serviceTenants?: ServiceTenantResponse[]; + /** Determine if the transfers are allowed for the billing account */ + allowTransfers?: boolean; } -/** - * @interface - * Subscription list operation response. - * @extends Array - */ -export interface SubscriptionListResult extends Array { - /** - * The URL to get the next set of results. - */ - nextLink: string; +/** Billing account service tenant. */ +export interface ServiceTenantResponse { + /** Service tenant id. */ + tenantId?: string; + /** Service tenant name. */ + tenantName?: string; } -/** - * @interface - * Tenant Ids information. - * @extends Array - */ -export interface TenantListResult extends Array { - /** - * The URL to use for getting the next set of results. - */ - nextLink: string; +/** Defines headers for Subscription_acceptOwnership operation. */ +export interface SubscriptionAcceptOwnershipHeaders { + /** GET this URL to retrieve the status of the asynchronous operation. */ + location?: string; + /** The amount of delay to use while the status of the operation is checked. The value is expressed in seconds. */ + retryAfter?: number; } -/** - * Defines values for SubscriptionState. - * Possible values include: 'Enabled', 'Warned', 'PastDue', 'Disabled', 'Deleted' - * @readonly - * @enum {string} - */ -export type SubscriptionState = 'Enabled' | 'Warned' | 'PastDue' | 'Disabled' | 'Deleted'; +/** Known values of {@link Workload} that the service accepts. */ +export enum KnownWorkload { + Production = "Production", + DevTest = "DevTest" +} /** - * Defines values for SpendingLimit. - * Possible values include: 'On', 'Off', 'CurrentPeriodOff' - * @readonly - * @enum {string} + * Defines values for Workload. \ + * {@link KnownWorkload} can be used interchangeably with Workload, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Production** \ + * **DevTest** */ -export type SpendingLimit = 'On' | 'Off' | 'CurrentPeriodOff'; +export type Workload = string; -/** - * Defines values for Workload. - * Possible values include: 'Production', 'DevTest' - * @readonly - * @enum {string} - */ -export type Workload = 'Production' | 'DevTest'; +/** Known values of {@link ProvisioningState} that the service accepts. */ +export enum KnownProvisioningState { + Accepted = "Accepted", + Succeeded = "Succeeded", + Failed = "Failed" +} /** - * Defines values for ProvisioningState. - * Possible values include: 'Accepted', 'Succeeded', 'Failed' - * @readonly - * @enum {string} + * Defines values for ProvisioningState. \ + * {@link KnownProvisioningState} can be used interchangeably with ProvisioningState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Accepted** \ + * **Succeeded** \ + * **Failed** */ -export type ProvisioningState = 'Accepted' | 'Succeeded' | 'Failed'; +export type ProvisioningState = string; -/** - * Contains response data for the listLocations operation. - */ -export type SubscriptionsListLocationsResponse = LocationListResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: LocationListResult; - }; -}; +/** Known values of {@link AcceptOwnership} that the service accepts. */ +export enum KnownAcceptOwnership { + Pending = "Pending", + Completed = "Completed", + Expired = "Expired" +} /** - * Contains response data for the get operation. + * Defines values for AcceptOwnership. \ + * {@link KnownAcceptOwnership} can be used interchangeably with AcceptOwnership, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Pending** \ + * **Completed** \ + * **Expired** */ -export type SubscriptionsGetResponse = Subscription & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: Subscription; - }; -}; +export type AcceptOwnership = string; -/** - * Contains response data for the list operation. - */ -export type SubscriptionsListResponse = SubscriptionListResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: SubscriptionListResult; - }; -}; +/** Known values of {@link CreatedByType} that the service accepts. */ +export enum KnownCreatedByType { + User = "User", + Application = "Application", + ManagedIdentity = "ManagedIdentity", + Key = "Key" +} /** - * Contains response data for the listNext operation. + * Defines values for CreatedByType. \ + * {@link KnownCreatedByType} can be used interchangeably with CreatedByType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **User** \ + * **Application** \ + * **ManagedIdentity** \ + * **Key** */ -export type SubscriptionsListNextResponse = SubscriptionListResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: SubscriptionListResult; - }; -}; +export type CreatedByType = string; -/** - * Contains response data for the list operation. - */ -export type TenantsListResponse = TenantListResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: TenantListResult; - }; -}; +/** Optional parameters. */ +export interface SubscriptionCancelOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the listNext operation. - */ -export type TenantsListNextResponse = TenantListResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: TenantListResult; - }; -}; +/** Contains response data for the cancel operation. */ +export type SubscriptionCancelResponse = CanceledSubscriptionId; -/** - * Contains response data for the cancel operation. - */ -export type SubscriptionCancelResponse = CanceledSubscriptionId & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: CanceledSubscriptionId; - }; -}; +/** Optional parameters. */ +export interface SubscriptionRenameOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the rename operation. - */ -export type SubscriptionRenameResponse = RenamedSubscriptionId & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: RenamedSubscriptionId; - }; -}; +/** Contains response data for the rename operation. */ +export type SubscriptionRenameResponse = RenamedSubscriptionId; -/** - * Contains response data for the enable operation. - */ -export type SubscriptionEnableResponse = EnabledSubscriptionId & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: EnabledSubscriptionId; - }; -}; +/** Optional parameters. */ +export interface SubscriptionEnableOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the list operation. - */ -export type OperationsListResponse = OperationListResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: OperationListResult; - }; -}; +/** Contains response data for the enable operation. */ +export type SubscriptionEnableResponse = EnabledSubscriptionId; -/** - * Contains response data for the create operation. - */ -export type AliasCreateResponse = PutAliasResponse & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: PutAliasResponse; - }; -}; +/** Optional parameters. */ +export interface SubscriptionAcceptOwnershipOptionalParams + extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} -/** - * Contains response data for the get operation. - */ -export type AliasGetResponse = PutAliasResponse & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: PutAliasResponse; - }; -}; +/** Contains response data for the acceptOwnership operation. */ +export type SubscriptionAcceptOwnershipResponse = SubscriptionAcceptOwnershipHeaders; -/** - * Contains response data for the list operation. - */ -export type AliasListResponse = PutAliasListResult & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: PutAliasListResult; - }; -}; +/** Optional parameters. */ +export interface SubscriptionAcceptOwnershipStatusOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the beginCreate operation. - */ -export type AliasBeginCreateResponse = PutAliasResponse & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: PutAliasResponse; - }; -}; +/** Contains response data for the acceptOwnershipStatus operation. */ +export type SubscriptionAcceptOwnershipStatusResponse = AcceptOwnershipStatusResponse; + +/** Optional parameters. */ +export interface OperationsListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type OperationsListResponse = OperationListResult; + +/** Optional parameters. */ +export interface OperationsListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type OperationsListNextResponse = OperationListResult; + +/** Optional parameters. */ +export interface AliasCreateOptionalParams extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the create operation. */ +export type AliasCreateResponse = SubscriptionAliasResponse; + +/** Optional parameters. */ +export interface AliasGetOptionalParams extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type AliasGetResponse = SubscriptionAliasResponse; + +/** Optional parameters. */ +export interface AliasDeleteOptionalParams + extends coreClient.OperationOptions {} + +/** Optional parameters. */ +export interface AliasListOptionalParams extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type AliasListResponse = SubscriptionAliasListResult; + +/** Optional parameters. */ +export interface SubscriptionPolicyAddUpdatePolicyForTenantOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the addUpdatePolicyForTenant operation. */ +export type SubscriptionPolicyAddUpdatePolicyForTenantResponse = GetTenantPolicyResponse; + +/** Optional parameters. */ +export interface SubscriptionPolicyGetPolicyForTenantOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getPolicyForTenant operation. */ +export type SubscriptionPolicyGetPolicyForTenantResponse = GetTenantPolicyResponse; + +/** Optional parameters. */ +export interface SubscriptionPolicyListPolicyForTenantOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listPolicyForTenant operation. */ +export type SubscriptionPolicyListPolicyForTenantResponse = GetTenantPolicyListResponse; + +/** Optional parameters. */ +export interface SubscriptionPolicyListPolicyForTenantNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listPolicyForTenantNext operation. */ +export type SubscriptionPolicyListPolicyForTenantNextResponse = GetTenantPolicyListResponse; + +/** Optional parameters. */ +export interface BillingAccountGetPolicyOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getPolicy operation. */ +export type BillingAccountGetPolicyResponse = BillingAccountPoliciesResponse; + +/** Optional parameters. */ +export interface SubscriptionClientOptionalParams + extends coreClient.ServiceClientOptions { + /** server parameter */ + $host?: string; + /** Api Version */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/subscription/arm-subscriptions/src/models/mappers.ts b/sdk/subscription/arm-subscriptions/src/models/mappers.ts index cbf65acfac67..bd0e0f1c2216 100644 --- a/sdk/subscription/arm-subscriptions/src/models/mappers.ts +++ b/sdk/subscription/arm-subscriptions/src/models/mappers.ts @@ -1,61 +1,70 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { CloudErrorMapper, BaseResourceMapper } from "@azure/ms-rest-azure-js"; -import * as msRest from "@azure/ms-rest-js"; +import * as coreClient from "@azure/core-client"; -export const CloudError = CloudErrorMapper; -export const BaseResource = BaseResourceMapper; - -export const Location: msRest.CompositeMapper = { - serializedName: "Location", +export const CanceledSubscriptionId: coreClient.CompositeMapper = { type: { name: "Composite", - className: "Location", + className: "CanceledSubscriptionId", modelProperties: { - id: { + value: { + serializedName: "value", readOnly: true, - serializedName: "id", type: { name: "String" } - }, - subscriptionId: { - readOnly: true, - serializedName: "subscriptionId", + } + } + } +}; + +export const ErrorResponseBody: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorResponseBody", + modelProperties: { + error: { + serializedName: "error", type: { - name: "String" + name: "Composite", + className: "ErrorResponse" } }, - name: { - readOnly: true, - serializedName: "name", + code: { + serializedName: "code", type: { name: "String" } }, - displayName: { - readOnly: true, - serializedName: "displayName", + message: { + serializedName: "message", type: { name: "String" } - }, - latitude: { - readOnly: true, - serializedName: "latitude", + } + } + } +}; + +export const ErrorResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + code: { + serializedName: "code", type: { name: "String" } }, - longitude: { - readOnly: true, - serializedName: "longitude", + message: { + serializedName: "message", type: { name: "String" } @@ -64,138 +73,133 @@ export const Location: msRest.CompositeMapper = { } }; -export const SubscriptionPolicies: msRest.CompositeMapper = { - serializedName: "SubscriptionPolicies", +export const SubscriptionName: coreClient.CompositeMapper = { type: { name: "Composite", - className: "SubscriptionPolicies", + className: "SubscriptionName", modelProperties: { - locationPlacementId: { - readOnly: true, - serializedName: "locationPlacementId", + subscriptionName: { + serializedName: "subscriptionName", type: { name: "String" } - }, - quotaId: { + } + } + } +}; + +export const RenamedSubscriptionId: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "RenamedSubscriptionId", + modelProperties: { + value: { + serializedName: "value", readOnly: true, - serializedName: "quotaId", type: { name: "String" } - }, - spendingLimit: { + } + } + } +}; + +export const EnabledSubscriptionId: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "EnabledSubscriptionId", + modelProperties: { + value: { + serializedName: "value", readOnly: true, - serializedName: "spendingLimit", type: { - name: "Enum", - allowedValues: [ - "On", - "Off", - "CurrentPeriodOff" - ] + name: "String" } } } } }; -export const Subscription: msRest.CompositeMapper = { - serializedName: "Subscription", +export const OperationListResult: coreClient.CompositeMapper = { type: { name: "Composite", - className: "Subscription", + className: "OperationListResult", modelProperties: { - id: { - readOnly: true, - serializedName: "id", + value: { + serializedName: "value", type: { - name: "String" + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Operation" + } + } } }, - subscriptionId: { - readOnly: true, - serializedName: "subscriptionId", + nextLink: { + serializedName: "nextLink", type: { name: "String" } - }, - displayName: { - readOnly: true, - serializedName: "displayName", + } + } + } +}; + +export const Operation: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Operation", + modelProperties: { + name: { + serializedName: "name", type: { name: "String" } }, - state: { - readOnly: true, - serializedName: "state", + isDataAction: { + serializedName: "isDataAction", type: { - name: "Enum", - allowedValues: [ - "Enabled", - "Warned", - "PastDue", - "Disabled", - "Deleted" - ] + name: "Boolean" } }, - subscriptionPolicies: { - serializedName: "subscriptionPolicies", + display: { + serializedName: "display", type: { name: "Composite", - className: "SubscriptionPolicies" - } - }, - authorizationSource: { - serializedName: "authorizationSource", - type: { - name: "String" + className: "OperationDisplay" } } } } }; -export const TenantIdDescription: msRest.CompositeMapper = { - serializedName: "TenantIdDescription", +export const OperationDisplay: coreClient.CompositeMapper = { type: { name: "Composite", - className: "TenantIdDescription", + className: "OperationDisplay", modelProperties: { - id: { - readOnly: true, - serializedName: "id", + provider: { + serializedName: "provider", type: { name: "String" } }, - tenantId: { - readOnly: true, - serializedName: "tenantId", + resource: { + serializedName: "resource", type: { name: "String" } - } - } - } -}; - -export const ErrorResponse: msRest.CompositeMapper = { - serializedName: "ErrorResponse", - type: { - name: "Composite", - className: "ErrorResponse", - modelProperties: { - code: { - serializedName: "code", + }, + operation: { + serializedName: "operation", type: { name: "String" } }, - message: { - serializedName: "message", + description: { + serializedName: "description", type: { name: "String" } @@ -204,161 +208,291 @@ export const ErrorResponse: msRest.CompositeMapper = { } }; -export const ErrorResponseBody: msRest.CompositeMapper = { - serializedName: "ErrorResponseBody", +export const PutAliasRequest: coreClient.CompositeMapper = { type: { name: "Composite", - className: "ErrorResponseBody", + className: "PutAliasRequest", modelProperties: { - error: { - serializedName: "error", + properties: { + serializedName: "properties", type: { name: "Composite", - className: "ErrorResponse" + className: "PutAliasRequestProperties" } } } } }; -export const CanceledSubscriptionId: msRest.CompositeMapper = { - serializedName: "CanceledSubscriptionId", +export const PutAliasRequestProperties: coreClient.CompositeMapper = { type: { name: "Composite", - className: "CanceledSubscriptionId", + className: "PutAliasRequestProperties", modelProperties: { - value: { - readOnly: true, - serializedName: "value", + displayName: { + serializedName: "displayName", + type: { + name: "String" + } + }, + workload: { + serializedName: "workload", + type: { + name: "String" + } + }, + billingScope: { + serializedName: "billingScope", type: { name: "String" } + }, + subscriptionId: { + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + resellerId: { + serializedName: "resellerId", + type: { + name: "String" + } + }, + additionalProperties: { + serializedName: "additionalProperties", + type: { + name: "Composite", + className: "PutAliasRequestAdditionalProperties" + } } } } }; -export const RenamedSubscriptionId: msRest.CompositeMapper = { - serializedName: "RenamedSubscriptionId", +export const PutAliasRequestAdditionalProperties: coreClient.CompositeMapper = { type: { name: "Composite", - className: "RenamedSubscriptionId", + className: "PutAliasRequestAdditionalProperties", modelProperties: { - value: { - readOnly: true, - serializedName: "value", + managementGroupId: { + serializedName: "managementGroupId", + type: { + name: "String" + } + }, + subscriptionTenantId: { + serializedName: "subscriptionTenantId", + type: { + name: "String" + } + }, + subscriptionOwnerId: { + serializedName: "subscriptionOwnerId", type: { name: "String" } + }, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } } } } }; -export const EnabledSubscriptionId: msRest.CompositeMapper = { - serializedName: "EnabledSubscriptionId", +export const SubscriptionAliasResponse: coreClient.CompositeMapper = { type: { name: "Composite", - className: "EnabledSubscriptionId", + className: "SubscriptionAliasResponse", modelProperties: { - value: { + id: { + serializedName: "id", readOnly: true, - serializedName: "value", type: { name: "String" } - } - } - } -}; - -export const SubscriptionName: msRest.CompositeMapper = { - serializedName: "SubscriptionName", - type: { - name: "Composite", - className: "SubscriptionName", - modelProperties: { - subscriptionName: { - serializedName: "subscriptionName", + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, type: { name: "String" } + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "SubscriptionAliasResponseProperties" + } + }, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" + } } } } }; -export const OperationDisplay: msRest.CompositeMapper = { - serializedName: "Operation_display", +export const SubscriptionAliasResponseProperties: coreClient.CompositeMapper = { type: { name: "Composite", - className: "OperationDisplay", + className: "SubscriptionAliasResponseProperties", modelProperties: { - provider: { - serializedName: "provider", + subscriptionId: { + serializedName: "subscriptionId", + readOnly: true, type: { name: "String" } }, - resource: { - serializedName: "resource", + displayName: { + serializedName: "displayName", type: { name: "String" } }, - operation: { - serializedName: "operation", + provisioningState: { + serializedName: "provisioningState", + type: { + name: "String" + } + }, + acceptOwnershipUrl: { + serializedName: "acceptOwnershipUrl", + readOnly: true, + type: { + name: "String" + } + }, + acceptOwnershipState: { + serializedName: "acceptOwnershipState", + readOnly: true, + type: { + name: "String" + } + }, + billingScope: { + serializedName: "billingScope", + type: { + name: "String" + } + }, + workload: { + serializedName: "workload", + type: { + name: "String" + } + }, + resellerId: { + serializedName: "resellerId", type: { name: "String" } + }, + subscriptionOwnerId: { + serializedName: "subscriptionOwnerId", + type: { + name: "String" + } + }, + managementGroupId: { + serializedName: "managementGroupId", + type: { + name: "String" + } + }, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } } } } }; -export const Operation: msRest.CompositeMapper = { - serializedName: "Operation", +export const SystemData: coreClient.CompositeMapper = { type: { name: "Composite", - className: "Operation", + className: "SystemData", modelProperties: { - name: { - serializedName: "name", + createdBy: { + serializedName: "createdBy", type: { name: "String" } }, - display: { - serializedName: "display", + createdByType: { + serializedName: "createdByType", type: { - name: "Composite", - className: "OperationDisplay" + name: "String" + } + }, + createdAt: { + serializedName: "createdAt", + type: { + name: "DateTime" + } + }, + lastModifiedBy: { + serializedName: "lastModifiedBy", + type: { + name: "String" + } + }, + lastModifiedByType: { + serializedName: "lastModifiedByType", + type: { + name: "String" + } + }, + lastModifiedAt: { + serializedName: "lastModifiedAt", + type: { + name: "DateTime" } } } } }; -export const OperationListResult: msRest.CompositeMapper = { - serializedName: "OperationListResult", +export const SubscriptionAliasListResult: coreClient.CompositeMapper = { type: { name: "Composite", - className: "OperationListResult", + className: "SubscriptionAliasListResult", modelProperties: { value: { serializedName: "value", + readOnly: true, type: { name: "Sequence", element: { type: { name: "Composite", - className: "Operation" + className: "SubscriptionAliasResponse" } } } }, nextLink: { serializedName: "nextLink", + readOnly: true, type: { name: "String" } @@ -367,147 +501,236 @@ export const OperationListResult: msRest.CompositeMapper = { } }; -export const PutAliasRequestProperties: msRest.CompositeMapper = { - serializedName: "PutAliasRequestProperties", +export const AcceptOwnershipRequest: coreClient.CompositeMapper = { type: { name: "Composite", - className: "PutAliasRequestProperties", + className: "AcceptOwnershipRequest", + modelProperties: { + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "AcceptOwnershipRequestProperties" + } + } + } + } +}; + +export const AcceptOwnershipRequestProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AcceptOwnershipRequestProperties", modelProperties: { displayName: { serializedName: "displayName", + required: true, type: { name: "String" } }, - workload: { - serializedName: "workload", + managementGroupId: { + serializedName: "managementGroupId", type: { name: "String" } }, - billingScope: { - serializedName: "billingScope", + tags: { + serializedName: "tags", type: { - name: "String" + name: "Dictionary", + value: { type: { name: "String" } } } - }, + } + } + } +}; + +export const AcceptOwnershipStatusResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "AcceptOwnershipStatusResponse", + modelProperties: { subscriptionId: { serializedName: "subscriptionId", + readOnly: true, type: { name: "String" } }, - resellerId: { - serializedName: "resellerId", + acceptOwnershipState: { + serializedName: "acceptOwnershipState", + readOnly: true, + type: { + name: "String" + } + }, + billingOwner: { + serializedName: "billingOwner", + readOnly: true, + type: { + name: "String" + } + }, + subscriptionTenantId: { + serializedName: "subscriptionTenantId", type: { name: "String" } + }, + displayName: { + serializedName: "displayName", + type: { + name: "String" + } + }, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } } } } }; -export const PutAliasRequest: msRest.CompositeMapper = { - serializedName: "PutAliasRequest", +export const PutTenantPolicyRequestProperties: coreClient.CompositeMapper = { type: { name: "Composite", - className: "PutAliasRequest", + className: "PutTenantPolicyRequestProperties", modelProperties: { - properties: { - required: true, - serializedName: "properties", + blockSubscriptionsLeavingTenant: { + serializedName: "blockSubscriptionsLeavingTenant", type: { - name: "Composite", - className: "PutAliasRequestProperties" + name: "Boolean" + } + }, + blockSubscriptionsIntoTenant: { + serializedName: "blockSubscriptionsIntoTenant", + type: { + name: "Boolean" + } + }, + exemptedPrincipals: { + serializedName: "exemptedPrincipals", + type: { + name: "Sequence", + element: { + type: { + name: "Uuid" + } + } } } } } }; -export const PutAliasResponseProperties: msRest.CompositeMapper = { - serializedName: "PutAliasResponseProperties", +export const GetTenantPolicyResponse: coreClient.CompositeMapper = { type: { name: "Composite", - className: "PutAliasResponseProperties", + className: "GetTenantPolicyResponse", modelProperties: { - subscriptionId: { + id: { + serializedName: "id", readOnly: true, - serializedName: "subscriptionId", type: { name: "String" } }, - provisioningState: { - serializedName: "provisioningState", + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, type: { name: "String" } + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "TenantPolicy" + } + }, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" + } } } } }; -export const PutAliasResponse: msRest.CompositeMapper = { - serializedName: "PutAliasResponse", +export const TenantPolicy: coreClient.CompositeMapper = { type: { name: "Composite", - className: "PutAliasResponse", + className: "TenantPolicy", modelProperties: { - id: { + policyId: { + serializedName: "policyId", readOnly: true, - serializedName: "id", type: { name: "String" } }, - name: { - readOnly: true, - serializedName: "name", + blockSubscriptionsLeavingTenant: { + serializedName: "blockSubscriptionsLeavingTenant", type: { - name: "String" + name: "Boolean" } }, - type: { - readOnly: true, - serializedName: "type", + blockSubscriptionsIntoTenant: { + serializedName: "blockSubscriptionsIntoTenant", type: { - name: "String" + name: "Boolean" } }, - properties: { - serializedName: "properties", + exemptedPrincipals: { + serializedName: "exemptedPrincipals", type: { - name: "Composite", - className: "PutAliasResponseProperties" + name: "Sequence", + element: { + type: { + name: "Uuid" + } + } } } } } }; -export const PutAliasListResult: msRest.CompositeMapper = { - serializedName: "PutAliasListResult", +export const GetTenantPolicyListResponse: coreClient.CompositeMapper = { type: { name: "Composite", - className: "PutAliasListResult", + className: "GetTenantPolicyListResponse", modelProperties: { value: { - readOnly: true, serializedName: "value", + readOnly: true, type: { name: "Sequence", element: { type: { name: "Composite", - className: "PutAliasResponse" + className: "GetTenantPolicyResponse" } } } }, nextLink: { - readOnly: true, serializedName: "nextLink", + readOnly: true, type: { name: "String" } @@ -516,78 +739,90 @@ export const PutAliasListResult: msRest.CompositeMapper = { } }; -export const LocationListResult: msRest.CompositeMapper = { - serializedName: "LocationListResult", +export const BillingAccountPoliciesResponse: coreClient.CompositeMapper = { type: { name: "Composite", - className: "LocationListResult", + className: "BillingAccountPoliciesResponse", modelProperties: { - value: { - serializedName: "", + id: { + serializedName: "id", + readOnly: true, type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "Location" - } - } + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "BillingAccountPoliciesResponseProperties" + } + }, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" } } } } }; -export const SubscriptionListResult: msRest.CompositeMapper = { - serializedName: "SubscriptionListResult", +export const BillingAccountPoliciesResponseProperties: coreClient.CompositeMapper = { type: { name: "Composite", - className: "SubscriptionListResult", + className: "BillingAccountPoliciesResponseProperties", modelProperties: { - value: { - serializedName: "", + serviceTenants: { + serializedName: "serviceTenants", type: { name: "Sequence", element: { type: { name: "Composite", - className: "Subscription" + className: "ServiceTenantResponse" } } } }, - nextLink: { - required: true, - serializedName: "nextLink", + allowTransfers: { + serializedName: "allowTransfers", type: { - name: "String" + name: "Boolean" } } } } }; -export const TenantListResult: msRest.CompositeMapper = { - serializedName: "TenantListResult", +export const ServiceTenantResponse: coreClient.CompositeMapper = { type: { name: "Composite", - className: "TenantListResult", + className: "ServiceTenantResponse", modelProperties: { - value: { - serializedName: "", + tenantId: { + serializedName: "tenantId", type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "TenantIdDescription" - } - } + name: "String" } }, - nextLink: { - required: true, - serializedName: "nextLink", + tenantName: { + serializedName: "tenantName", type: { name: "String" } @@ -595,3 +830,24 @@ export const TenantListResult: msRest.CompositeMapper = { } } }; + +export const SubscriptionAcceptOwnershipHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SubscriptionAcceptOwnershipHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + }, + retryAfter: { + serializedName: "retry-after", + type: { + name: "Number" + } + } + } + } +}; diff --git a/sdk/subscription/arm-subscriptions/src/models/operationsMappers.ts b/sdk/subscription/arm-subscriptions/src/models/operationsMappers.ts deleted file mode 100644 index b8de8606cf9d..000000000000 --- a/sdk/subscription/arm-subscriptions/src/models/operationsMappers.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export { - ErrorResponse, - Operation, - OperationDisplay, - OperationListResult -} from "../models/mappers"; diff --git a/sdk/subscription/arm-subscriptions/src/models/parameters.ts b/sdk/subscription/arm-subscriptions/src/models/parameters.ts index eb9a9a83971a..447b3f3ffb4d 100644 --- a/sdk/subscription/arm-subscriptions/src/models/parameters.ts +++ b/sdk/subscription/arm-subscriptions/src/models/parameters.ts @@ -1,75 +1,130 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; +import { + OperationParameter, + OperationURLParameter, + OperationQueryParameter +} from "@azure/core-client"; +import { + SubscriptionName as SubscriptionNameMapper, + AcceptOwnershipRequest as AcceptOwnershipRequestMapper, + PutAliasRequest as PutAliasRequestMapper, + PutTenantPolicyRequestProperties as PutTenantPolicyRequestPropertiesMapper +} from "../models/mappers"; -export const acceptLanguage: msRest.OperationParameter = { - parameterPath: "acceptLanguage", +export const accept: OperationParameter = { + parameterPath: "accept", mapper: { - serializedName: "accept-language", - defaultValue: 'en-US', + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", type: { name: "String" } } }; -export const aliasName: msRest.OperationURLParameter = { - parameterPath: "aliasName", + +export const $host: OperationURLParameter = { + parameterPath: "$host", mapper: { + serializedName: "$host", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const subscriptionId: OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + serializedName: "subscriptionId", required: true, - serializedName: "aliasName", type: { name: "String" } } }; -export const apiVersion0: msRest.OperationQueryParameter = { + +export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - required: true, + defaultValue: "2021-10-01", isConstant: true, serializedName: "api-version", - defaultValue: '2016-06-01', type: { name: "String" } } }; -export const apiVersion1: msRest.OperationQueryParameter = { - parameterPath: "apiVersion", + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], mapper: { - required: true, + defaultValue: "application/json", isConstant: true, - serializedName: "api-version", - defaultValue: '2020-09-01', + serializedName: "Content-Type", type: { name: "String" } } }; -export const nextPageLink: msRest.OperationURLParameter = { - parameterPath: "nextPageLink", + +export const body: OperationParameter = { + parameterPath: "body", + mapper: SubscriptionNameMapper +}; + +export const body1: OperationParameter = { + parameterPath: "body", + mapper: AcceptOwnershipRequestMapper +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", mapper: { - required: true, serializedName: "nextLink", + required: true, type: { name: "String" } }, skipEncoding: true }; -export const subscriptionId: msRest.OperationURLParameter = { - parameterPath: "subscriptionId", + +export const body2: OperationParameter = { + parameterPath: "body", + mapper: PutAliasRequestMapper +}; + +export const aliasName: OperationURLParameter = { + parameterPath: "aliasName", + mapper: { + serializedName: "aliasName", + required: true, + type: { + name: "String" + } + } +}; + +export const body3: OperationParameter = { + parameterPath: "body", + mapper: PutTenantPolicyRequestPropertiesMapper +}; + +export const billingAccountId: OperationURLParameter = { + parameterPath: "billingAccountId", mapper: { + serializedName: "billingAccountId", required: true, - serializedName: "subscriptionId", type: { name: "String" } diff --git a/sdk/subscription/arm-subscriptions/src/models/subscriptionOperationsMappers.ts b/sdk/subscription/arm-subscriptions/src/models/subscriptionOperationsMappers.ts deleted file mode 100644 index 3e331654cb51..000000000000 --- a/sdk/subscription/arm-subscriptions/src/models/subscriptionOperationsMappers.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export { - CanceledSubscriptionId, - EnabledSubscriptionId, - ErrorResponse, - RenamedSubscriptionId, - SubscriptionName -} from "../models/mappers"; diff --git a/sdk/subscription/arm-subscriptions/src/models/subscriptionsMappers.ts b/sdk/subscription/arm-subscriptions/src/models/subscriptionsMappers.ts deleted file mode 100644 index 496058988f35..000000000000 --- a/sdk/subscription/arm-subscriptions/src/models/subscriptionsMappers.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export { - CloudError, - Location, - LocationListResult, - Subscription, - SubscriptionListResult, - SubscriptionPolicies -} from "../models/mappers"; diff --git a/sdk/subscription/arm-subscriptions/src/models/tenantsMappers.ts b/sdk/subscription/arm-subscriptions/src/models/tenantsMappers.ts deleted file mode 100644 index 3bb2cb4ae153..000000000000 --- a/sdk/subscription/arm-subscriptions/src/models/tenantsMappers.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -export { - CloudError, - TenantIdDescription, - TenantListResult -} from "../models/mappers"; diff --git a/sdk/subscription/arm-subscriptions/src/operations/alias.ts b/sdk/subscription/arm-subscriptions/src/operations/alias.ts index d05c98805c1f..711fe95a5f6b 100644 --- a/sdk/subscription/arm-subscriptions/src/operations/alias.ts +++ b/sdk/subscription/arm-subscriptions/src/operations/alias.ts @@ -1,239 +1,239 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; -import * as Models from "../models"; -import * as Mappers from "../models/aliasMappers"; +import { Alias } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { SubscriptionClientContext } from "../subscriptionClientContext"; +import { SubscriptionClient } from "../subscriptionClient"; +import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; +import { LroImpl } from "../lroImpl"; +import { + PutAliasRequest, + AliasCreateOptionalParams, + AliasCreateResponse, + AliasGetOptionalParams, + AliasGetResponse, + AliasDeleteOptionalParams, + AliasListOptionalParams, + AliasListResponse +} from "../models"; -/** Class representing a Alias. */ -export class Alias { - private readonly client: SubscriptionClientContext; +/** Class containing Alias operations. */ +export class AliasImpl implements Alias { + private readonly client: SubscriptionClient; /** - * Create a Alias. - * @param {SubscriptionClientContext} client Reference to the service client. + * Initialize a new instance of the class Alias class. + * @param client Reference to the service client */ - constructor(client: SubscriptionClientContext) { + constructor(client: SubscriptionClient) { this.client = client; } /** * Create Alias Subscription. - * @param aliasName Alias Name - * @param body - * @param [options] The optional parameters - * @returns Promise + * @param aliasName AliasName is the name for the subscription creation request. Note that this is not + * the same as subscription name and this doesn’t have any other lifecycle need beyond the request for + * subscription creation. + * @param body The parameters required to create a new subscription. + * @param options The options parameters. */ - create(aliasName: string, body: Models.PutAliasRequest, options?: msRest.RequestOptionsBase): Promise { - return this.beginCreate(aliasName,body,options) - .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; + async beginCreate( + aliasName: string, + body: PutAliasRequest, + options?: AliasCreateOptionalParams + ): Promise< + PollerLike, AliasCreateResponse> + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ) => { + let currentRawResponse: + | coreClient.FullOperationResponse + | undefined = undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback + } + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON() + } + }; + }; + + const lro = new LroImpl( + sendOperation, + { aliasName, body, options }, + createOperationSpec + ); + return new LroEngine(lro, { + resumeFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs + }); } /** - * Get Alias Subscription. - * @param aliasName Alias Name - * @param [options] The optional parameters - * @returns Promise - */ - get(aliasName: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param aliasName Alias Name - * @param callback The callback - */ - get(aliasName: string, callback: msRest.ServiceCallback): void; - /** - * @param aliasName Alias Name - * @param options The optional parameters - * @param callback The callback + * Create Alias Subscription. + * @param aliasName AliasName is the name for the subscription creation request. Note that this is not + * the same as subscription name and this doesn’t have any other lifecycle need beyond the request for + * subscription creation. + * @param body The parameters required to create a new subscription. + * @param options The options parameters. */ - get(aliasName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - get(aliasName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - aliasName, - options - }, - getOperationSpec, - callback) as Promise; + async beginCreateAndWait( + aliasName: string, + body: PutAliasRequest, + options?: AliasCreateOptionalParams + ): Promise { + const poller = await this.beginCreate(aliasName, body, options); + return poller.pollUntilDone(); } /** - * Delete Alias. - * @param aliasName Alias Name - * @param [options] The optional parameters - * @returns Promise - */ - deleteMethod(aliasName: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param aliasName Alias Name - * @param callback The callback - */ - deleteMethod(aliasName: string, callback: msRest.ServiceCallback): void; - /** - * @param aliasName Alias Name - * @param options The optional parameters - * @param callback The callback + * Get Alias Subscription. + * @param aliasName AliasName is the name for the subscription creation request. Note that this is not + * the same as subscription name and this doesn’t have any other lifecycle need beyond the request for + * subscription creation. + * @param options The options parameters. */ - deleteMethod(aliasName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - deleteMethod(aliasName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + get( + aliasName: string, + options?: AliasGetOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - aliasName, - options - }, - deleteMethodOperationSpec, - callback); + { aliasName, options }, + getOperationSpec + ); } /** - * Get Alias Subscription. - * @param [options] The optional parameters - * @returns Promise - */ - list(options?: msRest.RequestOptionsBase): Promise; - /** - * @param callback The callback - */ - list(callback: msRest.ServiceCallback): void; - /** - * @param options The optional parameters - * @param callback The callback + * Delete Alias. + * @param aliasName AliasName is the name for the subscription creation request. Note that this is not + * the same as subscription name and this doesn’t have any other lifecycle need beyond the request for + * subscription creation. + * @param options The options parameters. */ - list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + delete( + aliasName: string, + options?: AliasDeleteOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - options - }, - listOperationSpec, - callback) as Promise; + { aliasName, options }, + deleteOperationSpec + ); } /** - * Create Alias Subscription. - * @param aliasName Alias Name - * @param body - * @param [options] The optional parameters - * @returns Promise + * List Alias Subscription. + * @param options The options parameters. */ - beginCreate(aliasName: string, body: Models.PutAliasRequest, options?: msRest.RequestOptionsBase): Promise { - return this.client.sendLRORequest( - { - aliasName, - body, - options - }, - beginCreateOperationSpec, - options); + list(options?: AliasListOptionalParams): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); } } - // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const getOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - path: "providers/Microsoft.Subscription/aliases/{aliasName}", - urlParameters: [ - Parameters.aliasName - ], - queryParameters: [ - Parameters.apiVersion1 - ], - headerParameters: [ - Parameters.acceptLanguage - ], +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const createOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Subscription/aliases/{aliasName}", + httpMethod: "PUT", responses: { 200: { - bodyMapper: Mappers.PutAliasResponse + bodyMapper: Mappers.SubscriptionAliasResponse + }, + 201: { + bodyMapper: Mappers.SubscriptionAliasResponse + }, + 202: { + bodyMapper: Mappers.SubscriptionAliasResponse + }, + 204: { + bodyMapper: Mappers.SubscriptionAliasResponse }, default: { bodyMapper: Mappers.ErrorResponseBody } }, + requestBody: Parameters.body2, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.aliasName], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", serializer }; - -const deleteMethodOperationSpec: msRest.OperationSpec = { - httpMethod: "DELETE", - path: "providers/Microsoft.Subscription/aliases/{aliasName}", - urlParameters: [ - Parameters.aliasName - ], - queryParameters: [ - Parameters.apiVersion1 - ], - headerParameters: [ - Parameters.acceptLanguage - ], +const getOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Subscription/aliases/{aliasName}", + httpMethod: "GET", responses: { - 200: {}, - 204: {}, + 200: { + bodyMapper: Mappers.SubscriptionAliasResponse + }, default: { bodyMapper: Mappers.ErrorResponseBody } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.aliasName], + headerParameters: [Parameters.accept], serializer }; - -const listOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - path: "providers/Microsoft.Subscription/aliases", - queryParameters: [ - Parameters.apiVersion1 - ], - headerParameters: [ - Parameters.acceptLanguage - ], +const deleteOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Subscription/aliases/{aliasName}", + httpMethod: "DELETE", responses: { - 200: { - bodyMapper: Mappers.PutAliasListResult - }, + 200: {}, + 204: {}, default: { bodyMapper: Mappers.ErrorResponseBody } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.aliasName], + headerParameters: [Parameters.accept], serializer }; - -const beginCreateOperationSpec: msRest.OperationSpec = { - httpMethod: "PUT", - path: "providers/Microsoft.Subscription/aliases/{aliasName}", - urlParameters: [ - Parameters.aliasName - ], - queryParameters: [ - Parameters.apiVersion1 - ], - headerParameters: [ - Parameters.acceptLanguage - ], - requestBody: { - parameterPath: "body", - mapper: { - ...Mappers.PutAliasRequest, - required: true - } - }, +const listOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Subscription/aliases", + httpMethod: "GET", responses: { 200: { - bodyMapper: Mappers.PutAliasResponse - }, - 201: { - bodyMapper: Mappers.PutAliasResponse + bodyMapper: Mappers.SubscriptionAliasListResult }, default: { bodyMapper: Mappers.ErrorResponseBody } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], serializer }; diff --git a/sdk/subscription/arm-subscriptions/src/operations/billingAccount.ts b/sdk/subscription/arm-subscriptions/src/operations/billingAccount.ts new file mode 100644 index 000000000000..0e96f93ac594 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operations/billingAccount.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { BillingAccount } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClient } from "../subscriptionClient"; +import { + BillingAccountGetPolicyOptionalParams, + BillingAccountGetPolicyResponse +} from "../models"; + +/** Class containing BillingAccount operations. */ +export class BillingAccountImpl implements BillingAccount { + private readonly client: SubscriptionClient; + + /** + * Initialize a new instance of the class BillingAccount class. + * @param client Reference to the service client + */ + constructor(client: SubscriptionClient) { + this.client = client; + } + + /** + * Get Billing Account Policy. + * @param billingAccountId Billing Account Id. + * @param options The options parameters. + */ + getPolicy( + billingAccountId: string, + options?: BillingAccountGetPolicyOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { billingAccountId, options }, + getPolicyOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const getPolicyOperationSpec: coreClient.OperationSpec = { + path: + "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Subscription/policies/default", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.BillingAccountPoliciesResponse + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.billingAccountId], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/subscription/arm-subscriptions/src/operations/index.ts b/sdk/subscription/arm-subscriptions/src/operations/index.ts index c08f9c29d393..c39ebaa92543 100644 --- a/sdk/subscription/arm-subscriptions/src/operations/index.ts +++ b/sdk/subscription/arm-subscriptions/src/operations/index.ts @@ -1,15 +1,13 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -export * from "./subscriptions"; -export * from "./tenants"; -export * from "./subscriptionOperations"; +export * from "./subscription"; export * from "./operations"; export * from "./alias"; +export * from "./subscriptionPolicy"; +export * from "./billingAccount"; diff --git a/sdk/subscription/arm-subscriptions/src/operations/operations.ts b/sdk/subscription/arm-subscriptions/src/operations/operations.ts index a3eb16df3104..9a7bf4146673 100644 --- a/sdk/subscription/arm-subscriptions/src/operations/operations.ts +++ b/sdk/subscription/arm-subscriptions/src/operations/operations.ts @@ -1,74 +1,137 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; -import * as Models from "../models"; -import * as Mappers from "../models/operationsMappers"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Operations } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { SubscriptionClientContext } from "../subscriptionClientContext"; +import { SubscriptionClient } from "../subscriptionClient"; +import { + Operation, + OperationsListNextOptionalParams, + OperationsListOptionalParams, + OperationsListResponse, + OperationsListNextResponse +} from "../models"; -/** Class representing a Operations. */ -export class Operations { - private readonly client: SubscriptionClientContext; +/// +/** Class containing Operations operations. */ +export class OperationsImpl implements Operations { + private readonly client: SubscriptionClient; /** - * Create a Operations. - * @param {SubscriptionClientContext} client Reference to the service client. + * Initialize a new instance of the class Operations class. + * @param client Reference to the service client */ - constructor(client: SubscriptionClientContext) { + constructor(client: SubscriptionClient) { this.client = client; } /** * Lists all of the available Microsoft.Subscription API operations. - * @param [options] The optional parameters - * @returns Promise + * @param options The options parameters. */ - list(options?: msRest.RequestOptionsBase): Promise; + public list( + options?: OperationsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(options); + } + }; + } + + private async *listPagingPage( + options?: OperationsListOptionalParams + ): AsyncIterableIterator { + let result = await this._list(options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listPagingAll( + options?: OperationsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + /** - * @param callback The callback + * Lists all of the available Microsoft.Subscription API operations. + * @param options The options parameters. */ - list(callback: msRest.ServiceCallback): void; + private _list( + options?: OperationsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + /** - * @param options The optional parameters - * @param callback The callback + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. */ - list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listNext( + nextLink: string, + options?: OperationsListNextOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - options - }, - listOperationSpec, - callback) as Promise; + { nextLink, options }, + listNextOperationSpec + ); } } - // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const listOperationSpec: msRest.OperationSpec = { +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Subscription/operations", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", httpMethod: "GET", - path: "providers/Microsoft.Subscription/operations", - queryParameters: [ - Parameters.apiVersion1 - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.OperationListResult }, default: { - bodyMapper: Mappers.ErrorResponse + bodyMapper: Mappers.ErrorResponseBody } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], serializer }; diff --git a/sdk/subscription/arm-subscriptions/src/operations/subscription.ts b/sdk/subscription/arm-subscriptions/src/operations/subscription.ts new file mode 100644 index 000000000000..18d58f8d7fcd --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operations/subscription.ts @@ -0,0 +1,289 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { Subscription } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClient } from "../subscriptionClient"; +import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; +import { LroImpl } from "../lroImpl"; +import { + SubscriptionCancelOptionalParams, + SubscriptionCancelResponse, + SubscriptionName, + SubscriptionRenameOptionalParams, + SubscriptionRenameResponse, + SubscriptionEnableOptionalParams, + SubscriptionEnableResponse, + AcceptOwnershipRequest, + SubscriptionAcceptOwnershipOptionalParams, + SubscriptionAcceptOwnershipResponse, + SubscriptionAcceptOwnershipStatusOptionalParams, + SubscriptionAcceptOwnershipStatusResponse +} from "../models"; + +/** Class containing Subscription operations. */ +export class SubscriptionImpl implements Subscription { + private readonly client: SubscriptionClient; + + /** + * Initialize a new instance of the class Subscription class. + * @param client Reference to the service client + */ + constructor(client: SubscriptionClient) { + this.client = client; + } + + /** + * The operation to cancel a subscription + * @param subscriptionId Subscription Id. + * @param options The options parameters. + */ + cancel( + subscriptionId: string, + options?: SubscriptionCancelOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { subscriptionId, options }, + cancelOperationSpec + ); + } + + /** + * The operation to rename a subscription + * @param subscriptionId Subscription Id. + * @param body Subscription Name + * @param options The options parameters. + */ + rename( + subscriptionId: string, + body: SubscriptionName, + options?: SubscriptionRenameOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { subscriptionId, body, options }, + renameOperationSpec + ); + } + + /** + * The operation to enable a subscription + * @param subscriptionId Subscription Id. + * @param options The options parameters. + */ + enable( + subscriptionId: string, + options?: SubscriptionEnableOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { subscriptionId, options }, + enableOperationSpec + ); + } + + /** + * Accept subscription ownership. + * @param subscriptionId Subscription Id. + * @param body The parameters required to accept subscription ownership. + * @param options The options parameters. + */ + async beginAcceptOwnership( + subscriptionId: string, + body: AcceptOwnershipRequest, + options?: SubscriptionAcceptOwnershipOptionalParams + ): Promise< + PollerLike< + PollOperationState, + SubscriptionAcceptOwnershipResponse + > + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ) => { + let currentRawResponse: + | coreClient.FullOperationResponse + | undefined = undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback + } + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON() + } + }; + }; + + const lro = new LroImpl( + sendOperation, + { subscriptionId, body, options }, + acceptOwnershipOperationSpec + ); + return new LroEngine(lro, { + resumeFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs + }); + } + + /** + * Accept subscription ownership. + * @param subscriptionId Subscription Id. + * @param body The parameters required to accept subscription ownership. + * @param options The options parameters. + */ + async beginAcceptOwnershipAndWait( + subscriptionId: string, + body: AcceptOwnershipRequest, + options?: SubscriptionAcceptOwnershipOptionalParams + ): Promise { + const poller = await this.beginAcceptOwnership( + subscriptionId, + body, + options + ); + return poller.pollUntilDone(); + } + + /** + * Accept subscription ownership status. + * @param subscriptionId Subscription Id. + * @param options The options parameters. + */ + acceptOwnershipStatus( + subscriptionId: string, + options?: SubscriptionAcceptOwnershipStatusOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { subscriptionId, options }, + acceptOwnershipStatusOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const cancelOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.CanceledSubscriptionId + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer +}; +const renameOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.RenamedSubscriptionId + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + requestBody: Parameters.body, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const enableOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.EnabledSubscriptionId + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer +}; +const acceptOwnershipOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnership", + httpMethod: "POST", + responses: { + 200: { + headersMapper: Mappers.SubscriptionAcceptOwnershipHeaders + }, + 201: { + headersMapper: Mappers.SubscriptionAcceptOwnershipHeaders + }, + 202: { + headersMapper: Mappers.SubscriptionAcceptOwnershipHeaders + }, + 204: { + headersMapper: Mappers.SubscriptionAcceptOwnershipHeaders + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + requestBody: Parameters.body1, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const acceptOwnershipStatusOperationSpec: coreClient.OperationSpec = { + path: + "/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnershipStatus", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.AcceptOwnershipStatusResponse + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/subscription/arm-subscriptions/src/operations/subscriptionOperations.ts b/sdk/subscription/arm-subscriptions/src/operations/subscriptionOperations.ts deleted file mode 100644 index 324515769845..000000000000 --- a/sdk/subscription/arm-subscriptions/src/operations/subscriptionOperations.ts +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as msRest from "@azure/ms-rest-js"; -import * as Models from "../models"; -import * as Mappers from "../models/subscriptionOperationsMappers"; -import * as Parameters from "../models/parameters"; -import { SubscriptionClientContext } from "../subscriptionClientContext"; - -/** Class representing a SubscriptionOperations. */ -export class SubscriptionOperations { - private readonly client: SubscriptionClientContext; - - /** - * Create a SubscriptionOperations. - * @param {SubscriptionClientContext} client Reference to the service client. - */ - constructor(client: SubscriptionClientContext) { - this.client = client; - } - - /** - * The operation to cancel a subscription - * @param subscriptionId Subscription Id. - * @param [options] The optional parameters - * @returns Promise - */ - cancel(subscriptionId: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param subscriptionId Subscription Id. - * @param callback The callback - */ - cancel(subscriptionId: string, callback: msRest.ServiceCallback): void; - /** - * @param subscriptionId Subscription Id. - * @param options The optional parameters - * @param callback The callback - */ - cancel(subscriptionId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - cancel(subscriptionId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - subscriptionId, - options - }, - cancelOperationSpec, - callback) as Promise; - } - - /** - * The operation to rename a subscription - * @param subscriptionId Subscription Id. - * @param body Subscription Name - * @param [options] The optional parameters - * @returns Promise - */ - rename(subscriptionId: string, body: Models.SubscriptionName, options?: msRest.RequestOptionsBase): Promise; - /** - * @param subscriptionId Subscription Id. - * @param body Subscription Name - * @param callback The callback - */ - rename(subscriptionId: string, body: Models.SubscriptionName, callback: msRest.ServiceCallback): void; - /** - * @param subscriptionId Subscription Id. - * @param body Subscription Name - * @param options The optional parameters - * @param callback The callback - */ - rename(subscriptionId: string, body: Models.SubscriptionName, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - rename(subscriptionId: string, body: Models.SubscriptionName, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - subscriptionId, - body, - options - }, - renameOperationSpec, - callback) as Promise; - } - - /** - * The operation to enable a subscription - * @param subscriptionId Subscription Id. - * @param [options] The optional parameters - * @returns Promise - */ - enable(subscriptionId: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param subscriptionId Subscription Id. - * @param callback The callback - */ - enable(subscriptionId: string, callback: msRest.ServiceCallback): void; - /** - * @param subscriptionId Subscription Id. - * @param options The optional parameters - * @param callback The callback - */ - enable(subscriptionId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - enable(subscriptionId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - subscriptionId, - options - }, - enableOperationSpec, - callback) as Promise; - } -} - -// Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const cancelOperationSpec: msRest.OperationSpec = { - httpMethod: "POST", - path: "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel", - urlParameters: [ - Parameters.subscriptionId - ], - queryParameters: [ - Parameters.apiVersion1 - ], - headerParameters: [ - Parameters.acceptLanguage - ], - responses: { - 200: { - bodyMapper: Mappers.CanceledSubscriptionId - }, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; - -const renameOperationSpec: msRest.OperationSpec = { - httpMethod: "POST", - path: "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename", - urlParameters: [ - Parameters.subscriptionId - ], - queryParameters: [ - Parameters.apiVersion1 - ], - headerParameters: [ - Parameters.acceptLanguage - ], - requestBody: { - parameterPath: "body", - mapper: { - ...Mappers.SubscriptionName, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.RenamedSubscriptionId - }, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; - -const enableOperationSpec: msRest.OperationSpec = { - httpMethod: "POST", - path: "subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable", - urlParameters: [ - Parameters.subscriptionId - ], - queryParameters: [ - Parameters.apiVersion1 - ], - headerParameters: [ - Parameters.acceptLanguage - ], - responses: { - 200: { - bodyMapper: Mappers.EnabledSubscriptionId - }, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; diff --git a/sdk/subscription/arm-subscriptions/src/operations/subscriptionPolicy.ts b/sdk/subscription/arm-subscriptions/src/operations/subscriptionPolicy.ts new file mode 100644 index 000000000000..f905b1b6ea8a --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operations/subscriptionPolicy.ts @@ -0,0 +1,207 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { SubscriptionPolicy } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClient } from "../subscriptionClient"; +import { + GetTenantPolicyResponse, + SubscriptionPolicyListPolicyForTenantNextOptionalParams, + SubscriptionPolicyListPolicyForTenantOptionalParams, + PutTenantPolicyRequestProperties, + SubscriptionPolicyAddUpdatePolicyForTenantOptionalParams, + SubscriptionPolicyAddUpdatePolicyForTenantResponse, + SubscriptionPolicyGetPolicyForTenantOptionalParams, + SubscriptionPolicyGetPolicyForTenantResponse, + SubscriptionPolicyListPolicyForTenantResponse, + SubscriptionPolicyListPolicyForTenantNextResponse +} from "../models"; + +/// +/** Class containing SubscriptionPolicy operations. */ +export class SubscriptionPolicyImpl implements SubscriptionPolicy { + private readonly client: SubscriptionClient; + + /** + * Initialize a new instance of the class SubscriptionPolicy class. + * @param client Reference to the service client + */ + constructor(client: SubscriptionClient) { + this.client = client; + } + + /** + * Get the subscription tenant policy for the user's tenant. + * @param options The options parameters. + */ + public listPolicyForTenant( + options?: SubscriptionPolicyListPolicyForTenantOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPolicyForTenantPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPolicyForTenantPagingPage(options); + } + }; + } + + private async *listPolicyForTenantPagingPage( + options?: SubscriptionPolicyListPolicyForTenantOptionalParams + ): AsyncIterableIterator { + let result = await this._listPolicyForTenant(options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listPolicyForTenantNext(continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listPolicyForTenantPagingAll( + options?: SubscriptionPolicyListPolicyForTenantOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPolicyForTenantPagingPage(options)) { + yield* page; + } + } + + /** + * Create or Update Subscription tenant policy for user's tenant. + * @param body Put tenant policy request properties. + * @param options The options parameters. + */ + addUpdatePolicyForTenant( + body: PutTenantPolicyRequestProperties, + options?: SubscriptionPolicyAddUpdatePolicyForTenantOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { body, options }, + addUpdatePolicyForTenantOperationSpec + ); + } + + /** + * Get the subscription tenant policy for the user's tenant. + * @param options The options parameters. + */ + getPolicyForTenant( + options?: SubscriptionPolicyGetPolicyForTenantOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { options }, + getPolicyForTenantOperationSpec + ); + } + + /** + * Get the subscription tenant policy for the user's tenant. + * @param options The options parameters. + */ + private _listPolicyForTenant( + options?: SubscriptionPolicyListPolicyForTenantOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { options }, + listPolicyForTenantOperationSpec + ); + } + + /** + * ListPolicyForTenantNext + * @param nextLink The nextLink from the previous successful call to the ListPolicyForTenant method. + * @param options The options parameters. + */ + private _listPolicyForTenantNext( + nextLink: string, + options?: SubscriptionPolicyListPolicyForTenantNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listPolicyForTenantNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const addUpdatePolicyForTenantOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Subscription/policies/default", + httpMethod: "PUT", + responses: { + 201: { + bodyMapper: Mappers.GetTenantPolicyResponse + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + requestBody: Parameters.body3, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const getPolicyForTenantOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Subscription/policies/default", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.GetTenantPolicyResponse + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listPolicyForTenantOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Subscription/policies", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.GetTenantPolicyListResponse + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listPolicyForTenantNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.GetTenantPolicyListResponse + }, + default: { + bodyMapper: Mappers.ErrorResponseBody + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/subscription/arm-subscriptions/src/operations/subscriptions.ts b/sdk/subscription/arm-subscriptions/src/operations/subscriptions.ts deleted file mode 100644 index bc8b22a21b5d..000000000000 --- a/sdk/subscription/arm-subscriptions/src/operations/subscriptions.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as msRest from "@azure/ms-rest-js"; -import * as Models from "../models"; -import * as Mappers from "../models/subscriptionsMappers"; -import * as Parameters from "../models/parameters"; -import { SubscriptionClientContext } from "../subscriptionClientContext"; - -/** Class representing a Subscriptions. */ -export class Subscriptions { - private readonly client: SubscriptionClientContext; - - /** - * Create a Subscriptions. - * @param {SubscriptionClientContext} client Reference to the service client. - */ - constructor(client: SubscriptionClientContext) { - this.client = client; - } - - /** - * This operation provides all the locations that are available for resource providers; however, - * each resource provider may support a subset of this list. - * @summary Gets all available geo-locations. - * @param subscriptionId The ID of the target subscription. - * @param [options] The optional parameters - * @returns Promise - */ - listLocations(subscriptionId: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param subscriptionId The ID of the target subscription. - * @param callback The callback - */ - listLocations(subscriptionId: string, callback: msRest.ServiceCallback): void; - /** - * @param subscriptionId The ID of the target subscription. - * @param options The optional parameters - * @param callback The callback - */ - listLocations(subscriptionId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listLocations(subscriptionId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - subscriptionId, - options - }, - listLocationsOperationSpec, - callback) as Promise; - } - - /** - * Gets details about a specified subscription. - * @param subscriptionId The ID of the target subscription. - * @param [options] The optional parameters - * @returns Promise - */ - get(subscriptionId: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param subscriptionId The ID of the target subscription. - * @param callback The callback - */ - get(subscriptionId: string, callback: msRest.ServiceCallback): void; - /** - * @param subscriptionId The ID of the target subscription. - * @param options The optional parameters - * @param callback The callback - */ - get(subscriptionId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - get(subscriptionId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - subscriptionId, - options - }, - getOperationSpec, - callback) as Promise; - } - - /** - * Gets all subscriptions for a tenant. - * @param [options] The optional parameters - * @returns Promise - */ - list(options?: msRest.RequestOptionsBase): Promise; - /** - * @param callback The callback - */ - list(callback: msRest.ServiceCallback): void; - /** - * @param options The optional parameters - * @param callback The callback - */ - list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - options - }, - listOperationSpec, - callback) as Promise; - } - - /** - * Gets all subscriptions for a tenant. - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param [options] The optional parameters - * @returns Promise - */ - listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param callback The callback - */ - listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; - /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param options The optional parameters - * @param callback The callback - */ - listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - nextPageLink, - options - }, - listNextOperationSpec, - callback) as Promise; - } -} - -// Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const listLocationsOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - path: "subscriptions/{subscriptionId}/locations", - urlParameters: [ - Parameters.subscriptionId - ], - queryParameters: [ - Parameters.apiVersion0 - ], - headerParameters: [ - Parameters.acceptLanguage - ], - responses: { - 200: { - bodyMapper: Mappers.LocationListResult - }, - default: { - bodyMapper: Mappers.CloudError - } - }, - serializer -}; - -const getOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - path: "subscriptions/{subscriptionId}", - urlParameters: [ - Parameters.subscriptionId - ], - queryParameters: [ - Parameters.apiVersion0 - ], - headerParameters: [ - Parameters.acceptLanguage - ], - responses: { - 200: { - bodyMapper: Mappers.Subscription - }, - default: { - bodyMapper: Mappers.CloudError - } - }, - serializer -}; - -const listOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - path: "subscriptions", - queryParameters: [ - Parameters.apiVersion0 - ], - headerParameters: [ - Parameters.acceptLanguage - ], - responses: { - 200: { - bodyMapper: Mappers.SubscriptionListResult - }, - default: { - bodyMapper: Mappers.CloudError - } - }, - serializer -}; - -const listNextOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - baseUrl: "https://management.azure.com", - path: "{nextLink}", - urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptLanguage - ], - responses: { - 200: { - bodyMapper: Mappers.SubscriptionListResult - }, - default: { - bodyMapper: Mappers.CloudError - } - }, - serializer -}; diff --git a/sdk/subscription/arm-subscriptions/src/operations/tenants.ts b/sdk/subscription/arm-subscriptions/src/operations/tenants.ts deleted file mode 100644 index 2c8fe0e433ec..000000000000 --- a/sdk/subscription/arm-subscriptions/src/operations/tenants.ts +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as msRest from "@azure/ms-rest-js"; -import * as Models from "../models"; -import * as Mappers from "../models/tenantsMappers"; -import * as Parameters from "../models/parameters"; -import { SubscriptionClientContext } from "../subscriptionClientContext"; - -/** Class representing a Tenants. */ -export class Tenants { - private readonly client: SubscriptionClientContext; - - /** - * Create a Tenants. - * @param {SubscriptionClientContext} client Reference to the service client. - */ - constructor(client: SubscriptionClientContext) { - this.client = client; - } - - /** - * Gets the tenants for your account. - * @param [options] The optional parameters - * @returns Promise - */ - list(options?: msRest.RequestOptionsBase): Promise; - /** - * @param callback The callback - */ - list(callback: msRest.ServiceCallback): void; - /** - * @param options The optional parameters - * @param callback The callback - */ - list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - options - }, - listOperationSpec, - callback) as Promise; - } - - /** - * Gets the tenants for your account. - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param [options] The optional parameters - * @returns Promise - */ - listNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param callback The callback - */ - listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; - /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param options The optional parameters - * @param callback The callback - */ - listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - nextPageLink, - options - }, - listNextOperationSpec, - callback) as Promise; - } -} - -// Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const listOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - path: "tenants", - queryParameters: [ - Parameters.apiVersion0 - ], - headerParameters: [ - Parameters.acceptLanguage - ], - responses: { - 200: { - bodyMapper: Mappers.TenantListResult - }, - default: { - bodyMapper: Mappers.CloudError - } - }, - serializer -}; - -const listNextOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - baseUrl: "https://management.azure.com", - path: "{nextLink}", - urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptLanguage - ], - responses: { - 200: { - bodyMapper: Mappers.TenantListResult - }, - default: { - bodyMapper: Mappers.CloudError - } - }, - serializer -}; diff --git a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/alias.ts b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/alias.ts new file mode 100644 index 000000000000..6cc57ed29fa6 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/alias.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { + PutAliasRequest, + AliasCreateOptionalParams, + AliasCreateResponse, + AliasGetOptionalParams, + AliasGetResponse, + AliasDeleteOptionalParams, + AliasListOptionalParams, + AliasListResponse +} from "../models"; + +/** Interface representing a Alias. */ +export interface Alias { + /** + * Create Alias Subscription. + * @param aliasName AliasName is the name for the subscription creation request. Note that this is not + * the same as subscription name and this doesn’t have any other lifecycle need beyond the request for + * subscription creation. + * @param body The parameters required to create a new subscription. + * @param options The options parameters. + */ + beginCreate( + aliasName: string, + body: PutAliasRequest, + options?: AliasCreateOptionalParams + ): Promise< + PollerLike, AliasCreateResponse> + >; + /** + * Create Alias Subscription. + * @param aliasName AliasName is the name for the subscription creation request. Note that this is not + * the same as subscription name and this doesn’t have any other lifecycle need beyond the request for + * subscription creation. + * @param body The parameters required to create a new subscription. + * @param options The options parameters. + */ + beginCreateAndWait( + aliasName: string, + body: PutAliasRequest, + options?: AliasCreateOptionalParams + ): Promise; + /** + * Get Alias Subscription. + * @param aliasName AliasName is the name for the subscription creation request. Note that this is not + * the same as subscription name and this doesn’t have any other lifecycle need beyond the request for + * subscription creation. + * @param options The options parameters. + */ + get( + aliasName: string, + options?: AliasGetOptionalParams + ): Promise; + /** + * Delete Alias. + * @param aliasName AliasName is the name for the subscription creation request. Note that this is not + * the same as subscription name and this doesn’t have any other lifecycle need beyond the request for + * subscription creation. + * @param options The options parameters. + */ + delete(aliasName: string, options?: AliasDeleteOptionalParams): Promise; + /** + * List Alias Subscription. + * @param options The options parameters. + */ + list(options?: AliasListOptionalParams): Promise; +} diff --git a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/billingAccount.ts b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/billingAccount.ts new file mode 100644 index 000000000000..75c7b5bec609 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/billingAccount.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + BillingAccountGetPolicyOptionalParams, + BillingAccountGetPolicyResponse +} from "../models"; + +/** Interface representing a BillingAccount. */ +export interface BillingAccount { + /** + * Get Billing Account Policy. + * @param billingAccountId Billing Account Id. + * @param options The options parameters. + */ + getPolicy( + billingAccountId: string, + options?: BillingAccountGetPolicyOptionalParams + ): Promise; +} diff --git a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/index.ts b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/index.ts new file mode 100644 index 000000000000..c39ebaa92543 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export * from "./subscription"; +export * from "./operations"; +export * from "./alias"; +export * from "./subscriptionPolicy"; +export * from "./billingAccount"; diff --git a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/operations.ts b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/operations.ts new file mode 100644 index 000000000000..16f3fa3210aa --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/operations.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Operation, OperationsListOptionalParams } from "../models"; + +/// +/** Interface representing a Operations. */ +export interface Operations { + /** + * Lists all of the available Microsoft.Subscription API operations. + * @param options The options parameters. + */ + list( + options?: OperationsListOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscription.ts b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscription.ts new file mode 100644 index 000000000000..783273102e86 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscription.ts @@ -0,0 +1,92 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { + SubscriptionCancelOptionalParams, + SubscriptionCancelResponse, + SubscriptionName, + SubscriptionRenameOptionalParams, + SubscriptionRenameResponse, + SubscriptionEnableOptionalParams, + SubscriptionEnableResponse, + AcceptOwnershipRequest, + SubscriptionAcceptOwnershipOptionalParams, + SubscriptionAcceptOwnershipResponse, + SubscriptionAcceptOwnershipStatusOptionalParams, + SubscriptionAcceptOwnershipStatusResponse +} from "../models"; + +/** Interface representing a Subscription. */ +export interface Subscription { + /** + * The operation to cancel a subscription + * @param subscriptionId Subscription Id. + * @param options The options parameters. + */ + cancel( + subscriptionId: string, + options?: SubscriptionCancelOptionalParams + ): Promise; + /** + * The operation to rename a subscription + * @param subscriptionId Subscription Id. + * @param body Subscription Name + * @param options The options parameters. + */ + rename( + subscriptionId: string, + body: SubscriptionName, + options?: SubscriptionRenameOptionalParams + ): Promise; + /** + * The operation to enable a subscription + * @param subscriptionId Subscription Id. + * @param options The options parameters. + */ + enable( + subscriptionId: string, + options?: SubscriptionEnableOptionalParams + ): Promise; + /** + * Accept subscription ownership. + * @param subscriptionId Subscription Id. + * @param body The parameters required to accept subscription ownership. + * @param options The options parameters. + */ + beginAcceptOwnership( + subscriptionId: string, + body: AcceptOwnershipRequest, + options?: SubscriptionAcceptOwnershipOptionalParams + ): Promise< + PollerLike< + PollOperationState, + SubscriptionAcceptOwnershipResponse + > + >; + /** + * Accept subscription ownership. + * @param subscriptionId Subscription Id. + * @param body The parameters required to accept subscription ownership. + * @param options The options parameters. + */ + beginAcceptOwnershipAndWait( + subscriptionId: string, + body: AcceptOwnershipRequest, + options?: SubscriptionAcceptOwnershipOptionalParams + ): Promise; + /** + * Accept subscription ownership status. + * @param subscriptionId Subscription Id. + * @param options The options parameters. + */ + acceptOwnershipStatus( + subscriptionId: string, + options?: SubscriptionAcceptOwnershipStatusOptionalParams + ): Promise; +} diff --git a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptionPolicy.ts b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptionPolicy.ts new file mode 100644 index 000000000000..3fe24d85cc59 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptionPolicy.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + GetTenantPolicyResponse, + SubscriptionPolicyListPolicyForTenantOptionalParams, + PutTenantPolicyRequestProperties, + SubscriptionPolicyAddUpdatePolicyForTenantOptionalParams, + SubscriptionPolicyAddUpdatePolicyForTenantResponse, + SubscriptionPolicyGetPolicyForTenantOptionalParams, + SubscriptionPolicyGetPolicyForTenantResponse +} from "../models"; + +/// +/** Interface representing a SubscriptionPolicy. */ +export interface SubscriptionPolicy { + /** + * Get the subscription tenant policy for the user's tenant. + * @param options The options parameters. + */ + listPolicyForTenant( + options?: SubscriptionPolicyListPolicyForTenantOptionalParams + ): PagedAsyncIterableIterator; + /** + * Create or Update Subscription tenant policy for user's tenant. + * @param body Put tenant policy request properties. + * @param options The options parameters. + */ + addUpdatePolicyForTenant( + body: PutTenantPolicyRequestProperties, + options?: SubscriptionPolicyAddUpdatePolicyForTenantOptionalParams + ): Promise; + /** + * Get the subscription tenant policy for the user's tenant. + * @param options The options parameters. + */ + getPolicyForTenant( + options?: SubscriptionPolicyGetPolicyForTenantOptionalParams + ): Promise; +} diff --git a/sdk/subscription/arm-subscriptions/src/subscriptionClient.ts b/sdk/subscription/arm-subscriptions/src/subscriptionClient.ts index e09ea265f1f4..69e99e301383 100644 --- a/sdk/subscription/arm-subscriptions/src/subscriptionClient.ts +++ b/sdk/subscription/arm-subscriptions/src/subscriptionClient.ts @@ -1,49 +1,87 @@ /* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import * as msRest from "@azure/ms-rest-js"; -import * as Models from "./models"; -import * as Mappers from "./models/mappers"; -import * as operations from "./operations"; -import { SubscriptionClientContext } from "./subscriptionClientContext"; +import * as coreClient from "@azure/core-client"; +import * as coreAuth from "@azure/core-auth"; +import { + SubscriptionImpl, + OperationsImpl, + AliasImpl, + SubscriptionPolicyImpl, + BillingAccountImpl +} from "./operations"; +import { + Subscription, + Operations, + Alias, + SubscriptionPolicy, + BillingAccount +} from "./operationsInterfaces"; +import { SubscriptionClientOptionalParams } from "./models"; - -class SubscriptionClient extends SubscriptionClientContext { - // Operation groups - subscriptions: operations.Subscriptions; - tenants: operations.Tenants; - subscription: operations.SubscriptionOperations; - operations: operations.Operations; - alias: operations.Alias; +export class SubscriptionClient extends coreClient.ServiceClient { + $host: string; + apiVersion: string; /** * Initializes a new instance of the SubscriptionClient class. - * @param credentials Credentials needed for the client to connect to Azure. - * @param [options] The parameter options + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param options The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.SubscriptionClientOptions) { - super(credentials, options); - this.subscriptions = new operations.Subscriptions(this); - this.tenants = new operations.Tenants(this); - this.subscription = new operations.SubscriptionOperations(this); - this.operations = new operations.Operations(this); - this.alias = new operations.Alias(this); - } -} + constructor( + credentials: coreAuth.TokenCredential, + options?: SubscriptionClientOptionalParams + ) { + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: SubscriptionClientOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; -// Operation Specifications + const packageDetails = `azsdk-js-arm-subscriptions/4.0.0`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; -export { - SubscriptionClient, - SubscriptionClientContext, - Models as SubscriptionModels, - Mappers as SubscriptionMappers -}; -export * from "./operations"; + if (!options.credentialScopes) { + options.credentialScopes = ["https://management.azure.com/.default"]; + } + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix + }, + baseUri: options.endpoint || "https://management.azure.com" + }; + super(optionsWithDefaults); + + // Assigning values to Constant parameters + this.$host = options.$host || "https://management.azure.com"; + this.apiVersion = options.apiVersion || "2021-10-01"; + this.subscription = new SubscriptionImpl(this); + this.operations = new OperationsImpl(this); + this.alias = new AliasImpl(this); + this.subscriptionPolicy = new SubscriptionPolicyImpl(this); + this.billingAccount = new BillingAccountImpl(this); + } + + subscription: Subscription; + operations: Operations; + alias: Alias; + subscriptionPolicy: SubscriptionPolicy; + billingAccount: BillingAccount; +} diff --git a/sdk/subscription/arm-subscriptions/src/subscriptionClientContext.ts b/sdk/subscription/arm-subscriptions/src/subscriptionClientContext.ts deleted file mode 100644 index e04e4ea0027c..000000000000 --- a/sdk/subscription/arm-subscriptions/src/subscriptionClientContext.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -import * as Models from "./models"; -import * as msRest from "@azure/ms-rest-js"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; - -const packageName = "@azure/arm-subscriptions"; -const packageVersion = "3.0.0"; - -export class SubscriptionClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; - - /** - * Initializes a new instance of the SubscriptionClient class. - * @param credentials Credentials needed for the client to connect to Azure. - * @param [options] The parameter options - */ - constructor(credentials: msRest.ServiceClientCredentials, options?: Models.SubscriptionClientOptions) { - if (credentials == undefined) { - throw new Error('\'credentials\' cannot be null.'); - } - - if (!options) { - options = {}; - } - if(!options.userAgent) { - const defaultUserAgent = msRestAzure.getDefaultUserAgentValue(); - options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; - } - - super(credentials, options); - - this.acceptLanguage = 'en-US'; - this.longRunningOperationRetryTimeout = 30; - this.baseUri = options.baseUri || this.baseUri || "https://management.azure.com"; - this.requestContentType = "application/json; charset=utf-8"; - this.credentials = credentials; - - if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { - this.acceptLanguage = options.acceptLanguage; - } - if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { - this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; - } - } -} diff --git a/sdk/subscription/arm-subscriptions/test/sampleTest.ts b/sdk/subscription/arm-subscriptions/test/sampleTest.ts new file mode 100644 index 000000000000..7ed89b043e1b --- /dev/null +++ b/sdk/subscription/arm-subscriptions/test/sampleTest.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + env, + record, + RecorderEnvironmentSetup, + Recorder +} from "@azure-tools/test-recorder"; +import * as assert from "assert"; + +const recorderEnvSetup: RecorderEnvironmentSetup = { + replaceableVariables: { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" + }, + customizationsOnRecordings: [ + (recording: any): any => + recording.replace( + /"access_token":"[^"]*"/g, + `"access_token":"access_token"` + ) + ], + queryParametersToSkip: [] +}; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function() { + recorder = record(this, recorderEnvSetup); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("sample test", async function() { + console.log("Hi, I'm a test!"); + }); +}); diff --git a/sdk/subscription/arm-subscriptions/tsconfig.json b/sdk/subscription/arm-subscriptions/tsconfig.json index 422b584abd5e..6e3251194117 100644 --- a/sdk/subscription/arm-subscriptions/tsconfig.json +++ b/sdk/subscription/arm-subscriptions/tsconfig.json @@ -3,7 +3,7 @@ "module": "es6", "moduleResolution": "node", "strict": true, - "target": "es5", + "target": "es6", "sourceMap": true, "declarationMap": true, "esModuleInterop": true, @@ -11,9 +11,9 @@ "forceConsistentCasingInFileNames": true, "lib": ["es6", "dom"], "declaration": true, - "outDir": "./esm", + "outDir": "./dist-esm", "importHelpers": true }, - "include": ["./src/**/*.ts"], + "include": ["./src/**/*.ts", "./test/**/*.ts"], "exclude": ["node_modules"] } diff --git a/sdk/subscription/ci.yml b/sdk/subscription/ci.yml new file mode 100644 index 000000000000..5b69fcc70944 --- /dev/null +++ b/sdk/subscription/ci.yml @@ -0,0 +1,29 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - release/* + - hotfix/* + paths: + include: + - sdk/subscription/ + +pr: + branches: + include: + - main + - release/* + - hotfix/* + paths: + include: + - sdk/subscription/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: subscription + Artifacts: + - name: azure-arm-subscriptions + safeName: azurearmsubscriptions + \ No newline at end of file