From 19b70199046355afa47f8cad34597e53c4e1b99b Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 28 Dec 2021 08:32:28 +0000 Subject: [PATCH] CodeGen from PR 17182 in Azure/azure-rest-api-specs Merge ce54fabea3dd873404b8eb111f519d942e611552 into 707a573aa91722b19bec059a36ee68a19885c16a --- common/config/rush/pnpm-lock.yaml | 24 + rush.json | 5 + sdk/advisor/arm-advisor/CHANGELOG.md | 11 + sdk/advisor/arm-advisor/LICENSE | 21 + sdk/advisor/arm-advisor/README.md | 150 ++- sdk/advisor/arm-advisor/_meta.json | 7 + sdk/advisor/arm-advisor/api-extractor.json | 18 + sdk/advisor/arm-advisor/package.json | 93 +- .../arm-advisor/review/arm-advisor.api.md | 466 +++++++ sdk/advisor/arm-advisor/rollup.config.js | 211 +++- .../src/advisorManagementClient.ts | 125 +- .../src/advisorManagementClientContext.ts | 68 - sdk/advisor/arm-advisor/src/index.ts | 12 + .../src/models/configurationsMappers.ts | 21 - sdk/advisor/arm-advisor/src/models/index.ts | 1099 ++++++----------- sdk/advisor/arm-advisor/src/models/mappers.ts | 593 +++++---- .../src/models/operationsMappers.ts | 14 - .../arm-advisor/src/models/parameters.ts | 167 ++- .../models/recommendationMetadataMappers.ts | 15 - .../src/models/recommendationsMappers.ts | 21 - .../src/models/suppressionsMappers.ts | 20 - .../src/operations/configurations.ts | 412 +++--- .../arm-advisor/src/operations/index.ts | 8 +- .../arm-advisor/src/operations/operations.ts | 164 +-- .../src/operations/recommendationMetadata.ts | 225 ++-- .../src/operations/recommendations.ts | 375 +++--- .../src/operations/suppressions.ts | 440 +++---- .../operationsInterfaces/configurations.ts | 65 + .../src/operationsInterfaces/index.ts | 13 + .../src/operationsInterfaces/operations.ts | 22 + .../recommendationMetadata.ts | 36 + .../operationsInterfaces/recommendations.ts | 63 + .../src/operationsInterfaces/suppressions.ts | 78 ++ sdk/advisor/arm-advisor/test/sampleTest.ts | 48 + sdk/advisor/arm-advisor/tsconfig.json | 6 +- sdk/advisor/ci.yml | 29 + 36 files changed, 2938 insertions(+), 2207 deletions(-) create mode 100644 sdk/advisor/arm-advisor/CHANGELOG.md create mode 100644 sdk/advisor/arm-advisor/LICENSE create mode 100644 sdk/advisor/arm-advisor/_meta.json create mode 100644 sdk/advisor/arm-advisor/api-extractor.json create mode 100644 sdk/advisor/arm-advisor/review/arm-advisor.api.md delete mode 100644 sdk/advisor/arm-advisor/src/advisorManagementClientContext.ts create mode 100644 sdk/advisor/arm-advisor/src/index.ts delete mode 100644 sdk/advisor/arm-advisor/src/models/configurationsMappers.ts delete mode 100644 sdk/advisor/arm-advisor/src/models/operationsMappers.ts delete mode 100644 sdk/advisor/arm-advisor/src/models/recommendationMetadataMappers.ts delete mode 100644 sdk/advisor/arm-advisor/src/models/recommendationsMappers.ts delete mode 100644 sdk/advisor/arm-advisor/src/models/suppressionsMappers.ts create mode 100644 sdk/advisor/arm-advisor/src/operationsInterfaces/configurations.ts create mode 100644 sdk/advisor/arm-advisor/src/operationsInterfaces/index.ts create mode 100644 sdk/advisor/arm-advisor/src/operationsInterfaces/operations.ts create mode 100644 sdk/advisor/arm-advisor/src/operationsInterfaces/recommendationMetadata.ts create mode 100644 sdk/advisor/arm-advisor/src/operationsInterfaces/recommendations.ts create mode 100644 sdk/advisor/arm-advisor/src/operationsInterfaces/suppressions.ts create mode 100644 sdk/advisor/arm-advisor/test/sampleTest.ts create mode 100644 sdk/advisor/ci.yml diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index dde760827160..3238d4bc43e4 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -9,6 +9,7 @@ specifiers: '@rush-temp/ai-metrics-advisor': file:./projects/ai-metrics-advisor.tgz '@rush-temp/ai-text-analytics': file:./projects/ai-text-analytics.tgz '@rush-temp/app-configuration': file:./projects/app-configuration.tgz + '@rush-temp/arm-advisor': file:./projects/arm-advisor.tgz '@rush-temp/arm-analysisservices': file:./projects/arm-analysisservices.tgz '@rush-temp/arm-apimanagement': file:./projects/arm-apimanagement.tgz '@rush-temp/arm-appplatform': file:./projects/arm-appplatform.tgz @@ -183,6 +184,7 @@ dependencies: '@rush-temp/ai-metrics-advisor': file:projects/ai-metrics-advisor.tgz '@rush-temp/ai-text-analytics': file:projects/ai-text-analytics.tgz '@rush-temp/app-configuration': file:projects/app-configuration.tgz + '@rush-temp/arm-advisor': file:projects/arm-advisor.tgz '@rush-temp/arm-analysisservices': file:projects/arm-analysisservices.tgz '@rush-temp/arm-apimanagement': file:projects/arm-apimanagement.tgz '@rush-temp/arm-appplatform': file:projects/arm-appplatform.tgz @@ -1408,6 +1410,7 @@ packages: /@opentelemetry/node/0.22.0_@opentelemetry+api@1.0.3: resolution: {integrity: sha512-+HhGbDruQ7cwejVOIYyxRa28uosnG8W95NiQZ6qE8PXXPsDSyGeftAPbtYpGit0H2f5hrVcMlwmWHeAo9xkSLA==} engines: {node: '>=8.0.0'} + deprecated: Package renamed to @opentelemetry/sdk-trace-node peerDependencies: '@opentelemetry/api': ^1.0.0 dependencies: @@ -7963,6 +7966,27 @@ packages: - utf-8-validate dev: false + file:projects/arm-advisor.tgz: + resolution: {integrity: sha512-sXLZvgEK3M/0EB9904jwVVIMnEZmc/NGhojlcJ0SprVlvz4syC8LQywjnworwQH90arrpiG+1hcsVKiPG+lGqg==, tarball: file:projects/arm-advisor.tgz} + name: '@rush-temp/arm-advisor' + version: 0.0.0 + dependencies: + '@microsoft/api-extractor': 7.19.2 + '@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.5 + dev: false + file:projects/arm-analysisservices.tgz: resolution: {integrity: sha512-yadXxpeaoCaSs2kXugUgnMRlelZKJFJiXqJaqkgvnUuSGtknGjx7V+gFpHCKo9GtvVzeATtEnmQlYnYoZoAHkg==, tarball: file:projects/arm-analysisservices.tgz} name: '@rush-temp/arm-analysisservices' diff --git a/rush.json b/rush.json index 7812bad5af0c..97f8bfd12270 100644 --- a/rush.json +++ b/rush.json @@ -1180,6 +1180,11 @@ "packageName": "@azure/arm-subscriptions", "projectFolder": "sdk/subscription/arm-subscriptions", "versionPolicyName": "management" + }, + { + "packageName": "@azure/arm-advisor", + "projectFolder": "sdk/advisor/arm-advisor", + "versionPolicyName": "management" } ] } \ No newline at end of file diff --git a/sdk/advisor/arm-advisor/CHANGELOG.md b/sdk/advisor/arm-advisor/CHANGELOG.md new file mode 100644 index 000000000000..7a9c22c087ed --- /dev/null +++ b/sdk/advisor/arm-advisor/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 3.0.0 (2021-12-28) + +The package of @azure/arm-advisor is using our next generation design principles since version 3.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/advisor/arm-advisor/LICENSE b/sdk/advisor/arm-advisor/LICENSE new file mode 100644 index 000000000000..ccb63b166732 --- /dev/null +++ b/sdk/advisor/arm-advisor/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/advisor/arm-advisor/README.md b/sdk/advisor/arm-advisor/README.md index c78a674a386d..8b9d3963ffe6 100644 --- a/sdk/advisor/arm-advisor/README.md +++ b/sdk/advisor/arm-advisor/README.md @@ -1,110 +1,98 @@ -## Azure AdvisorManagementClient SDK for JavaScript +# Azure AdvisorManagement client library for JavaScript -This package contains an isomorphic SDK (runs both in Node.js and in browsers) for AdvisorManagementClient. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure AdvisorManagement client. + +REST APIs for Azure Advisor + +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/advisor/arm-advisor) | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-advisor) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-advisor) | +[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 -You must have an [Azure subscription](https://azure.microsoft.com/free/). +- An [Azure subscription][azure_sub]. -### How to install +### Install the `@azure/arm-advisor` package -To use this SDK in your project, you will need to install two packages. -- `@azure/arm-advisor` that contains the client. -- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. +Install the Azure AdvisorManagement client library for JavaScript with `npm`: -Install both packages using the below command: ```bash -npm install --save @azure/arm-advisor @azure/identity +npm install @azure/arm-advisor ``` -> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. -If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. +### Create and authenticate a `AdvisorManagementClient` -### How to use +To create a client object to access the Azure AdvisorManagement API, you will need the `endpoint` of your Azure AdvisorManagement resource and a `credential`. The Azure AdvisorManagement client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure AdvisorManagement resource in the [Azure Portal][azure_portal]. -- If you are writing a client side browser application, - - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. - - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. -- If you are writing a server side application, - - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) - - Complete the set up steps required by the credential if any. - - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. +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). -In the below samples, we pass the credential and the Azure subscription id to instantiate the client. -Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. +To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: + +```bash +npm install @azure/identity +``` -#### nodejs - Authentication, client creation, and get recommendationMetadata as an example written in JavaScript. +You will also need to **register a new AAD application and grant access to Azure AdvisorManagement** 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`. -##### Sample code +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 { DefaultAzureCredential } = require("@azure/identity"); const { AdvisorManagementClient } = require("@azure/arm-advisor"); -const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; - -// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples -// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. -const creds = new DefaultAzureCredential(); -const client = new AdvisorManagementClient(creds, subscriptionId); -const name = "testname"; -client.recommendationMetadata.get(name).then((result) => { - console.log("The result is:"); - console.log(result); -}).catch((err) => { - console.log("An error occurred:"); - console.error(err); -}); +const { DefaultAzureCredential } = require("@azure/identity"); +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new AdvisorManagementClient(new DefaultAzureCredential(), subscriptionId); ``` -#### browser - Authentication, client creation, and get recommendationMetadata as an example written in JavaScript. - -In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. - - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. - - Note down the client Id from the previous step and use it in the browser sample below. - -##### Sample code - -- index.html - -```html - - - - @azure/arm-advisor sample - - - - - - - + +### JavaScript Bundle +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). + +## Key concepts + +### AdvisorManagementClient + +`AdvisorManagementClient` is the primary interface for developers using the Azure AdvisorManagement client library. Explore the methods on this client object to understand the different features of the Azure AdvisorManagement 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%2Fadvisor%2Farm-advisor%2FREADME.png) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/advisor/arm-advisor/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/advisor/arm-advisor/_meta.json b/sdk/advisor/arm-advisor/_meta.json new file mode 100644 index 000000000000..a56b5e529235 --- /dev/null +++ b/sdk/advisor/arm-advisor/_meta.json @@ -0,0 +1,7 @@ +{ + "commit": "8dada797091fbaa3793f9bedd3c6f1a5d19a20c6", + "readme": "specification/advisor/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/advisor/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/advisor/arm-advisor/api-extractor.json b/sdk/advisor/arm-advisor/api-extractor.json new file mode 100644 index 000000000000..073fa59ae2ad --- /dev/null +++ b/sdk/advisor/arm-advisor/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-advisor.d.ts" + }, + "messages": { + "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "extractorMessageReporting": { + "ae-missing-release-tag": { "logLevel": "none" }, + "ae-unresolved-link": { "logLevel": "none" } + } + } +} diff --git a/sdk/advisor/arm-advisor/package.json b/sdk/advisor/arm-advisor/package.json index a877ba90191e..cb599c725a49 100644 --- a/sdk/advisor/arm-advisor/package.json +++ b/sdk/advisor/arm-advisor/package.json @@ -1,58 +1,89 @@ { "name": "@azure/arm-advisor", + "sdk-type": "mgmt", "author": "Microsoft Corporation", - "description": "AdvisorManagementClient Library with typescript type definitions for node.js and browser.", - "version": "2.1.0", + "description": "A generated SDK for AdvisorManagementClient.", + "version": "3.0.0", + "engines": { "node": ">=12.0.0" }, "dependencies": { - "@azure/ms-rest-azure-js": "^2.1.0", - "@azure/ms-rest-js": "^2.2.0", - "@azure/core-auth": "^1.1.4", - "tslib": "^1.10.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-advisor.js", - "module": "./esm/advisorManagementClient.js", - "types": "./esm/advisorManagementClient.d.ts", + "main": "./dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/arm-advisor.d.ts", "devDependencies": { - "typescript": "^3.6.0", - "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/advisor/arm-advisor", "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-advisor.js.map'\" -o ./dist/arm-advisor.min.js ./dist/arm-advisor.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/advisor/arm-advisor/review/arm-advisor.api.md b/sdk/advisor/arm-advisor/review/arm-advisor.api.md new file mode 100644 index 000000000000..f854eaf8258c --- /dev/null +++ b/sdk/advisor/arm-advisor/review/arm-advisor.api.md @@ -0,0 +1,466 @@ +## API Report File for "@azure/arm-advisor" + +> 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'; + +// @public (undocumented) +export class AdvisorManagementClient extends coreClient.ServiceClient { + // (undocumented) + $host: string; + constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: AdvisorManagementClientOptionalParams); + // (undocumented) + apiVersion: string; + // (undocumented) + configurations: Configurations; + // (undocumented) + operations: Operations; + // (undocumented) + recommendationMetadata: RecommendationMetadata; + // (undocumented) + recommendations: Recommendations; + // (undocumented) + subscriptionId: string; + // (undocumented) + suppressions: Suppressions; +} + +// @public +export interface AdvisorManagementClientOptionalParams extends coreClient.ServiceClientOptions { + $host?: string; + apiVersion?: string; + endpoint?: string; +} + +// @public (undocumented) +export interface ArmErrorResponse { + error?: ARMErrorResponseBody; +} + +// @public +export interface ARMErrorResponseBody { + code?: string; + message?: string; +} + +// @public +export type Category = string; + +// @public +export type ConfigData = Resource & { + exclude?: boolean; + lowCpuThreshold?: CpuThreshold; + digests?: DigestConfig[]; +}; + +// @public +export interface ConfigurationListResult { + nextLink?: string; + value?: ConfigData[]; +} + +// @public +export type ConfigurationName = string; + +// @public +export interface Configurations { + createInResourceGroup(configurationName: ConfigurationName, resourceGroup: string, configContract: ConfigData, options?: ConfigurationsCreateInResourceGroupOptionalParams): Promise; + createInSubscription(configurationName: ConfigurationName, configContract: ConfigData, options?: ConfigurationsCreateInSubscriptionOptionalParams): Promise; + listByResourceGroup(resourceGroup: string, options?: ConfigurationsListByResourceGroupOptionalParams): PagedAsyncIterableIterator; + listBySubscription(options?: ConfigurationsListBySubscriptionOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface ConfigurationsCreateInResourceGroupOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ConfigurationsCreateInResourceGroupResponse = ConfigData; + +// @public +export interface ConfigurationsCreateInSubscriptionOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ConfigurationsCreateInSubscriptionResponse = ConfigData; + +// @public +export interface ConfigurationsListByResourceGroupOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ConfigurationsListByResourceGroupResponse = ConfigurationListResult; + +// @public +export interface ConfigurationsListBySubscriptionNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ConfigurationsListBySubscriptionNextResponse = ConfigurationListResult; + +// @public +export interface ConfigurationsListBySubscriptionOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ConfigurationsListBySubscriptionResponse = ConfigurationListResult; + +// @public +export type CpuThreshold = string; + +// @public +export interface DigestConfig { + actionGroupResourceId?: string; + categories?: Category[]; + frequency?: number; + language?: string; + name?: string; + state?: DigestConfigState; +} + +// @public +export type DigestConfigState = string; + +// @public +export type Impact = string; + +// @public +export enum KnownCategory { + // (undocumented) + Cost = "Cost", + // (undocumented) + HighAvailability = "HighAvailability", + // (undocumented) + OperationalExcellence = "OperationalExcellence", + // (undocumented) + Performance = "Performance", + // (undocumented) + Security = "Security" +} + +// @public +export enum KnownConfigurationName { + // (undocumented) + Default = "default" +} + +// @public +export enum KnownCpuThreshold { + // (undocumented) + Fifteen = "15", + // (undocumented) + Five = "5", + // (undocumented) + Ten = "10", + // (undocumented) + Twenty = "20" +} + +// @public +export enum KnownDigestConfigState { + // (undocumented) + Active = "Active", + // (undocumented) + Disabled = "Disabled" +} + +// @public +export enum KnownImpact { + // (undocumented) + High = "High", + // (undocumented) + Low = "Low", + // (undocumented) + Medium = "Medium" +} + +// @public +export enum KnownRisk { + // (undocumented) + Error = "Error", + // (undocumented) + None = "None", + // (undocumented) + Warning = "Warning" +} + +// @public +export enum KnownScenario { + // (undocumented) + Alerts = "Alerts" +} + +// @public +export interface MetadataEntity { + applicableScenarios?: Scenario[]; + dependsOn?: string[]; + displayName?: string; + id?: string; + name?: string; + supportedValues?: MetadataSupportedValueDetail[]; + type?: string; +} + +// @public +export interface MetadataEntityListResult { + nextLink?: string; + value?: MetadataEntity[]; +} + +// @public +export interface MetadataSupportedValueDetail { + displayName?: string; + id?: string; +} + +// @public +export interface OperationDisplayInfo { + description?: string; + operation?: string; + provider?: string; + resource?: string; +} + +// @public +export interface OperationEntity { + display?: OperationDisplayInfo; + name?: string; +} + +// @public +export interface OperationEntityListResult { + nextLink?: string; + value?: OperationEntity[]; +} + +// @public +export interface Operations { + list(options?: OperationsListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface OperationsListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListNextResponse = OperationEntityListResult; + +// @public +export interface OperationsListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationsListResponse = OperationEntityListResult; + +// @public +export interface RecommendationMetadata { + get(name: string, options?: RecommendationMetadataGetOptionalParams): Promise; + list(options?: RecommendationMetadataListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface RecommendationMetadataGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type RecommendationMetadataGetResponse = MetadataEntity; + +// @public +export interface RecommendationMetadataListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type RecommendationMetadataListNextResponse = MetadataEntityListResult; + +// @public +export interface RecommendationMetadataListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type RecommendationMetadataListResponse = MetadataEntityListResult; + +// @public +export interface Recommendations { + generate(options?: RecommendationsGenerateOptionalParams): Promise; + get(resourceUri: string, recommendationId: string, options?: RecommendationsGetOptionalParams): Promise; + getGenerateStatus(operationId: string, options?: RecommendationsGetGenerateStatusOptionalParams): Promise; + list(options?: RecommendationsListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface RecommendationsGenerateHeaders { + location?: string; + retryAfter?: string; +} + +// @public +export interface RecommendationsGenerateOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type RecommendationsGenerateResponse = RecommendationsGenerateHeaders; + +// @public +export interface RecommendationsGetGenerateStatusOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface RecommendationsGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type RecommendationsGetResponse = ResourceRecommendationBase; + +// @public +export interface RecommendationsListNextOptionalParams extends coreClient.OperationOptions { + filter?: string; + skipToken?: string; + top?: number; +} + +// @public +export type RecommendationsListNextResponse = ResourceRecommendationBaseListResult; + +// @public +export interface RecommendationsListOptionalParams extends coreClient.OperationOptions { + filter?: string; + skipToken?: string; + top?: number; +} + +// @public +export type RecommendationsListResponse = ResourceRecommendationBaseListResult; + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly type?: string; +} + +// @public +export interface ResourceMetadata { + action?: { + [propertyName: string]: Record; + }; + plural?: string; + resourceId?: string; + singular?: string; + source?: string; +} + +// @public +export type ResourceRecommendationBase = Resource & { + category?: Category; + impact?: Impact; + impactedField?: string; + impactedValue?: string; + lastUpdated?: Date; + metadata?: { + [propertyName: string]: Record; + }; + recommendationTypeId?: string; + risk?: Risk; + shortDescription?: ShortDescription; + suppressionIds?: string[]; + extendedProperties?: { + [propertyName: string]: string; + }; + resourceMetadata?: ResourceMetadata; + description?: string; + label?: string; + learnMoreLink?: string; + potentialBenefits?: string; + actions?: { + [propertyName: string]: Record; + }[]; + remediation?: { + [propertyName: string]: Record; + }; + exposedMetadataProperties?: { + [propertyName: string]: Record; + }; +}; + +// @public +export interface ResourceRecommendationBaseListResult { + nextLink?: string; + value?: ResourceRecommendationBase[]; +} + +// @public +export type Risk = string; + +// @public +export type Scenario = string; + +// @public +export interface ShortDescription { + problem?: string; + solution?: string; +} + +// @public +export type SuppressionContract = Resource & { + suppressionId?: string; + ttl?: string; + readonly expirationTimeStamp?: Date; +}; + +// @public +export interface SuppressionContractListResult { + nextLink?: string; + value?: SuppressionContract[]; +} + +// @public +export interface Suppressions { + create(resourceUri: string, recommendationId: string, name: string, suppressionContract: SuppressionContract, options?: SuppressionsCreateOptionalParams): Promise; + delete(resourceUri: string, recommendationId: string, name: string, options?: SuppressionsDeleteOptionalParams): Promise; + get(resourceUri: string, recommendationId: string, name: string, options?: SuppressionsGetOptionalParams): Promise; + list(options?: SuppressionsListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface SuppressionsCreateOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SuppressionsCreateResponse = SuppressionContract; + +// @public +export interface SuppressionsDeleteOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface SuppressionsGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SuppressionsGetResponse = SuppressionContract; + +// @public +export interface SuppressionsListNextOptionalParams extends coreClient.OperationOptions { + skipToken?: string; + top?: number; +} + +// @public +export type SuppressionsListNextResponse = SuppressionContractListResult; + +// @public +export interface SuppressionsListOptionalParams extends coreClient.OperationOptions { + skipToken?: string; + top?: number; +} + +// @public +export type SuppressionsListResponse = SuppressionContractListResult; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/advisor/arm-advisor/rollup.config.js b/sdk/advisor/arm-advisor/rollup.config.js index 6d406ff2ce84..9be1955eb7f1 100644 --- a/sdk/advisor/arm-advisor/rollup.config.js +++ b/sdk/advisor/arm-advisor/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/advisorManagementClient.js", - external: [ - "@azure/ms-rest-js", - "@azure/ms-rest-azure-js" - ], - output: { - file: "./dist/arm-advisor.js", - format: "umd", - name: "Azure.ArmAdvisor", - 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/advisor/arm-advisor/src/advisorManagementClient.ts b/sdk/advisor/arm-advisor/src/advisorManagementClient.ts index 4b888955a6a0..ff8b013702d1 100644 --- a/sdk/advisor/arm-advisor/src/advisorManagementClient.ts +++ b/sdk/advisor/arm-advisor/src/advisorManagementClient.ts @@ -1,56 +1,95 @@ /* - * 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 { TokenCredential } from "@azure/core-auth"; -import * as Models from "./models"; -import * as Mappers from "./models/mappers"; -import * as operations from "./operations"; -import { AdvisorManagementClientContext } from "./advisorManagementClientContext"; +import * as coreClient from "@azure/core-client"; +import * as coreAuth from "@azure/core-auth"; +import { + RecommendationMetadataImpl, + ConfigurationsImpl, + RecommendationsImpl, + OperationsImpl, + SuppressionsImpl +} from "./operations"; +import { + RecommendationMetadata, + Configurations, + Recommendations, + Operations, + Suppressions +} from "./operationsInterfaces"; +import { AdvisorManagementClientOptionalParams } from "./models"; - -class AdvisorManagementClient extends AdvisorManagementClientContext { - // Operation groups - recommendationMetadata: operations.RecommendationMetadata; - configurations: operations.Configurations; - recommendations: operations.Recommendations; - operations: operations.Operations; - suppressions: operations.Suppressions; +export class AdvisorManagementClient extends coreClient.ServiceClient { + $host: string; + apiVersion: string; + subscriptionId: string; /** * Initializes a new instance of the AdvisorManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. Credentials - * implementing the TokenCredential interface from the @azure/identity package are recommended. For - * more information about these credentials, see - * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the - * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and - * @azure/ms-rest-browserauth are also supported. + * @param credentials Subscription credentials which uniquely identify client subscription. * @param subscriptionId The Azure subscription ID. - * @param [options] The parameter options + * @param options The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AdvisorManagementClientOptions) { - super(credentials, subscriptionId, options); - this.recommendationMetadata = new operations.RecommendationMetadata(this); - this.configurations = new operations.Configurations(this); - this.recommendations = new operations.Recommendations(this); - this.operations = new operations.Operations(this); - this.suppressions = new operations.Suppressions(this); - } -} + constructor( + credentials: coreAuth.TokenCredential, + subscriptionId: string, + options?: AdvisorManagementClientOptionalParams + ) { + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + if (subscriptionId === undefined) { + throw new Error("'subscriptionId' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: AdvisorManagementClientOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; -// Operation Specifications + const packageDetails = `azsdk-js-arm-advisor/3.0.0`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; -export { - AdvisorManagementClient, - AdvisorManagementClientContext, - Models as AdvisorManagementModels, - Mappers as AdvisorManagementMappers -}; -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); + // Parameter assignments + this.subscriptionId = subscriptionId; + + // Assigning values to Constant parameters + this.$host = options.$host || "https://management.azure.com"; + this.apiVersion = options.apiVersion || "2020-01-01"; + this.recommendationMetadata = new RecommendationMetadataImpl(this); + this.configurations = new ConfigurationsImpl(this); + this.recommendations = new RecommendationsImpl(this); + this.operations = new OperationsImpl(this); + this.suppressions = new SuppressionsImpl(this); + } + + recommendationMetadata: RecommendationMetadata; + configurations: Configurations; + recommendations: Recommendations; + operations: Operations; + suppressions: Suppressions; +} diff --git a/sdk/advisor/arm-advisor/src/advisorManagementClientContext.ts b/sdk/advisor/arm-advisor/src/advisorManagementClientContext.ts deleted file mode 100644 index 7c8e091f169e..000000000000 --- a/sdk/advisor/arm-advisor/src/advisorManagementClientContext.ts +++ /dev/null @@ -1,68 +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 { TokenCredential } from "@azure/core-auth"; -import * as msRestAzure from "@azure/ms-rest-azure-js"; - -const packageName = "@azure/arm-advisor"; -const packageVersion = "2.1.0"; - -export class AdvisorManagementClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials | TokenCredential; - subscriptionId: string; - apiVersion?: string; - - /** - * Initializes a new instance of the AdvisorManagementClient class. - * @param credentials Credentials needed for the client to connect to Azure. Credentials - * implementing the TokenCredential interface from the @azure/identity package are recommended. For - * more information about these credentials, see - * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the - * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and - * @azure/ms-rest-browserauth are also supported. - * @param subscriptionId The Azure subscription ID. - * @param [options] The parameter options - */ - constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AdvisorManagementClientOptions) { - if (credentials == undefined) { - throw new Error('\'credentials\' cannot be null.'); - } - if (subscriptionId == undefined) { - throw new Error('\'subscriptionId\' cannot be null.'); - } - - if (!options) { - options = {}; - } - if(!options.userAgent) { - const defaultUserAgent = msRestAzure.getDefaultUserAgentValue(); - options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; - } - - super(credentials, options); - - this.apiVersion = '2020-01-01'; - 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; - this.subscriptionId = subscriptionId; - - 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/advisor/arm-advisor/src/index.ts b/sdk/advisor/arm-advisor/src/index.ts new file mode 100644 index 000000000000..a2d4c891ee0f --- /dev/null +++ b/sdk/advisor/arm-advisor/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 { AdvisorManagementClient } from "./advisorManagementClient"; +export * from "./operationsInterfaces"; diff --git a/sdk/advisor/arm-advisor/src/models/configurationsMappers.ts b/sdk/advisor/arm-advisor/src/models/configurationsMappers.ts deleted file mode 100644 index ff165cd05db1..000000000000 --- a/sdk/advisor/arm-advisor/src/models/configurationsMappers.ts +++ /dev/null @@ -1,21 +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 { - ArmErrorResponse, - ARMErrorResponseBody, - BaseResource, - ConfigData, - ConfigurationListResult, - DigestConfig, - Resource, - ResourceMetadata, - ResourceRecommendationBase, - ShortDescription, - SuppressionContract -} from "../models/mappers"; diff --git a/sdk/advisor/arm-advisor/src/models/index.ts b/sdk/advisor/arm-advisor/src/models/index.ts index aef287075a97..de8f51d30e8f 100644 --- a/sdk/advisor/arm-advisor/src/models/index.ts +++ b/sdk/advisor/arm-advisor/src/models/index.ts @@ -1,814 +1,531 @@ /* - * 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 }; - -/** - * The metadata supported value detail. - */ -export interface MetadataSupportedValueDetail { - /** - * The id. - */ - id?: string; - /** - * The display name. - */ - displayName?: string; -} - -/** - * The metadata entity contract. - */ +/** The metadata entity contract. */ export interface MetadataEntity { - /** - * The resource Id of the metadata entity. - */ + /** The resource Id of the metadata entity. */ id?: string; - /** - * The type of the metadata entity. - */ + /** The type of the metadata entity. */ type?: string; - /** - * The name of the metadata entity. - */ + /** The name of the metadata entity. */ name?: string; - /** - * The display name. - */ + /** The display name. */ displayName?: string; - /** - * The list of keys on which this entity depends on. - */ + /** The list of keys on which this entity depends on. */ dependsOn?: string[]; - /** - * The list of scenarios applicable to this metadata entity. - */ + /** The list of scenarios applicable to this metadata entity. */ applicableScenarios?: Scenario[]; - /** - * The list of supported values. - */ + /** The list of supported values. */ supportedValues?: MetadataSupportedValueDetail[]; } -/** - * Advisor Digest configuration entity - */ +/** The metadata supported value detail. */ +export interface MetadataSupportedValueDetail { + /** The id. */ + id?: string; + /** The display name. */ + displayName?: string; +} + +/** ARM error response body. */ +export interface ARMErrorResponseBody { + /** Gets or sets the string that describes the error in detail and provides debugging information. */ + message?: string; + /** Gets or sets the string that can be used to programmatically identify the error. */ + code?: string; +} + +export interface ArmErrorResponse { + /** ARM error response body. */ + error?: ARMErrorResponseBody; +} + +/** The list of metadata entities */ +export interface MetadataEntityListResult { + /** The list of metadata entities. */ + value?: MetadataEntity[]; + /** The link used to get the next page of metadata. */ + nextLink?: string; +} + +/** The list of Advisor configurations. */ +export interface ConfigurationListResult { + /** The list of configurations. */ + value?: ConfigData[]; + /** The link used to get the next page of configurations. */ + nextLink?: string; +} + +/** Advisor Digest configuration entity */ export interface DigestConfig { - /** - * Name of digest configuration. Value is case-insensitive and must be unique within a - * subscription. - */ + /** Name of digest configuration. Value is case-insensitive and must be unique within a subscription. */ name?: string; - /** - * Action group resource id used by digest. - */ + /** Action group resource id used by digest. */ actionGroupResourceId?: string; - /** - * Frequency that digest will be triggered, in days. Value must be between 7 and 30 days - * inclusive. - */ + /** Frequency that digest will be triggered, in days. Value must be between 7 and 30 days inclusive. */ frequency?: number; - /** - * Categories to send digest for. If categories are not provided, then digest will be sent for - * all categories. - */ + /** Categories to send digest for. If categories are not provided, then digest will be sent for all categories. */ categories?: Category[]; - /** - * Language for digest content body. Value must be ISO 639-1 code for one of Azure portal - * supported languages. Otherwise, it will be converted into one. Default value is English (en). - */ + /** Language for digest content body. Value must be ISO 639-1 code for one of Azure portal supported languages. Otherwise, it will be converted into one. Default value is English (en). */ language?: string; - /** - * State of digest configuration. Possible values include: 'Active', 'Disabled' - */ + /** State of digest configuration. */ state?: DigestConfigState; } -/** - * An Azure resource. - */ -export interface Resource extends BaseResource { +/** An Azure resource. */ +export interface Resource { /** * The resource 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 id?: string; /** * The name of the resource. - * **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 name?: string; /** * The type of the resource. - * **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 type?: string; } -/** - * The Advisor configuration data structure. - */ -export interface ConfigData extends Resource { - /** - * Exclude the resource from Advisor evaluations. Valid values: False (default) or True. - */ - exclude?: boolean; - /** - * Minimum percentage threshold for Advisor low CPU utilization evaluation. Valid only for - * subscriptions. Valid values: 5 (default), 10, 15 or 20. Possible values include: '5', '10', - * '15', '20' - */ - lowCpuThreshold?: CpuThreshold; - /** - * Advisor digest configuration. Valid only for subscriptions - */ - digests?: DigestConfig[]; -} - -/** - * ARM error response body. - */ -export interface ARMErrorResponseBody { - /** - * Gets or sets the string that describes the error in detail and provides debugging information. - */ - message?: string; - /** - * Gets or sets the string that can be used to programmatically identify the error. - */ - code?: string; -} - -/** - * An interface representing ArmErrorResponse. - */ -export interface ArmErrorResponse { - error?: ARMErrorResponseBody; +/** The list of Advisor recommendations. */ +export interface ResourceRecommendationBaseListResult { + /** The link used to get the next page of recommendations. */ + nextLink?: string; + /** The list of recommendations. */ + value?: ResourceRecommendationBase[]; } -/** - * A summary of the recommendation. - */ +/** A summary of the recommendation. */ export interface ShortDescription { - /** - * The issue or opportunity identified by the recommendation. - */ + /** The issue or opportunity identified by the recommendation. */ problem?: string; - /** - * The remediation action suggested by the recommendation. - */ + /** The remediation action suggested by the recommendation. */ solution?: string; } -/** - * Recommendation resource metadata - */ +/** Recommendation resource metadata */ export interface ResourceMetadata { - /** - * Azure resource Id of the assessed resource - */ + /** Azure resource Id of the assessed resource */ resourceId?: string; - /** - * Source from which recommendation is generated - */ + /** Source from which recommendation is generated */ source?: string; + /** The action to view resource. */ + action?: { [propertyName: string]: Record }; + /** The singular user friendly name of resource type. eg: virtual machine */ + singular?: string; + /** The plural user friendly name of resource type. eg: virtual machines */ + plural?: string; } -/** - * Advisor Recommendation. - */ -export interface ResourceRecommendationBase extends Resource { - /** - * The category of the recommendation. Possible values include: 'HighAvailability', 'Security', - * 'Performance', 'Cost', 'OperationalExcellence' - */ +/** The list of Advisor operations. */ +export interface OperationEntityListResult { + /** The link used to get the next page of operations. */ + nextLink?: string; + /** The list of operations. */ + value?: OperationEntity[]; +} + +/** The operation supported by Advisor. */ +export interface OperationEntity { + /** Operation name: {provider}/{resource}/{operation}. */ + name?: string; + /** The operation supported by Advisor. */ + display?: OperationDisplayInfo; +} + +/** The operation supported by Advisor. */ +export interface OperationDisplayInfo { + /** The description of the operation. */ + description?: string; + /** The action that users can perform, based on their permission level. */ + operation?: string; + /** Service provider: Microsoft Advisor. */ + provider?: string; + /** Resource on which the operation is performed. */ + resource?: string; +} + +/** The list of Advisor suppressions. */ +export interface SuppressionContractListResult { + /** The link used to get the next page of suppressions. */ + nextLink?: string; + /** The list of suppressions. */ + value?: SuppressionContract[]; +} + +/** The Advisor configuration data structure. */ +export type ConfigData = Resource & { + /** Exclude the resource from Advisor evaluations. Valid values: False (default) or True. */ + exclude?: boolean; + /** Minimum percentage threshold for Advisor low CPU utilization evaluation. Valid only for subscriptions. Valid values: 5 (default), 10, 15 or 20. */ + lowCpuThreshold?: CpuThreshold; + /** Advisor digest configuration. Valid only for subscriptions */ + digests?: DigestConfig[]; +}; + +/** Advisor Recommendation. */ +export type ResourceRecommendationBase = Resource & { + /** The category of the recommendation. */ category?: Category; - /** - * The business impact of the recommendation. Possible values include: 'High', 'Medium', 'Low' - */ + /** The business impact of the recommendation. */ impact?: Impact; - /** - * The resource type identified by Advisor. - */ + /** The resource type identified by Advisor. */ impactedField?: string; - /** - * The resource identified by Advisor. - */ + /** The resource identified by Advisor. */ impactedValue?: string; - /** - * The most recent time that Advisor checked the validity of the recommendation. - */ + /** The most recent time that Advisor checked the validity of the recommendation. */ lastUpdated?: Date; - /** - * The recommendation metadata. - */ - metadata?: { [propertyName: string]: any }; - /** - * The recommendation-type GUID. - */ + /** The recommendation metadata. */ + metadata?: { [propertyName: string]: Record }; + /** The recommendation-type GUID. */ recommendationTypeId?: string; - /** - * The potential risk of not implementing the recommendation. Possible values include: 'Error', - * 'Warning', 'None' - */ + /** The potential risk of not implementing the recommendation. */ risk?: Risk; - /** - * A summary of the recommendation. - */ + /** A summary of the recommendation. */ shortDescription?: ShortDescription; - /** - * The list of snoozed and dismissed rules for the recommendation. - */ + /** The list of snoozed and dismissed rules for the recommendation. */ suppressionIds?: string[]; - /** - * Extended properties - */ + /** Extended properties */ extendedProperties?: { [propertyName: string]: string }; - /** - * Metadata of resource that was assessed - */ + /** Metadata of resource that was assessed */ resourceMetadata?: ResourceMetadata; -} - -/** - * The operation supported by Advisor. - */ -export interface OperationDisplayInfo { - /** - * The description of the operation. - */ + /** The detailed description of recommendation. */ description?: string; - /** - * The action that users can perform, based on their permission level. - */ - operation?: string; - /** - * Service provider: Microsoft Advisor. - */ - provider?: string; - /** - * Resource on which the operation is performed. - */ - resource?: string; -} - -/** - * The operation supported by Advisor. - */ -export interface OperationEntity { - /** - * Operation name: {provider}/{resource}/{operation}. - */ - name?: string; - /** - * The operation supported by Advisor. - */ - display?: OperationDisplayInfo; -} + /** The label of recommendation. */ + label?: string; + /** The link to learn more about recommendation and generation logic. */ + learnMoreLink?: string; + /** The potential benefit of implementing recommendation. */ + potentialBenefits?: string; + /** The list of recommended actions to implement recommendation. */ + actions?: { [propertyName: string]: Record }[]; + /** The automated way to apply recommendation. */ + remediation?: { [propertyName: string]: Record }; + /** The recommendation metadata properties exposed to customer to provide additional information. */ + exposedMetadataProperties?: { + [propertyName: string]: Record; + }; +}; -/** - * The details of the snoozed or dismissed rule; for example, the duration, name, and GUID - * associated with the rule. - */ -export interface SuppressionContract extends Resource { - /** - * The GUID of the suppression. - */ +/** The details of the snoozed or dismissed rule; for example, the duration, name, and GUID associated with the rule. */ +export type SuppressionContract = Resource & { + /** The GUID of the suppression. */ suppressionId?: string; - /** - * The duration for which the suppression is valid. - */ + /** The duration for which the suppression is valid. */ ttl?: string; -} - -/** - * Optional Parameters. - */ -export interface RecommendationsListOptionalParams extends msRest.RequestOptionsBase { - /** - * The filter to apply to the recommendations. - */ - filter?: string; - /** - * The number of recommendations per page if a paged version of this API is being used. - */ - top?: number; /** - * The page-continuation token to use with a paged version of this API. + * Gets or sets the expiration time stamp. + * NOTE: This property will not be serialized. It can only be populated by the server. */ - skipToken?: string; -} + readonly expirationTimeStamp?: Date; +}; -/** - * Optional Parameters. - */ -export interface SuppressionsListOptionalParams extends msRest.RequestOptionsBase { - /** - * The number of suppressions per page if a paged version of this API is being used. - */ - top?: number; - /** - * The page-continuation token to use with a paged version of this API. - */ - skipToken?: string; +/** Defines headers for Recommendations_generate operation. */ +export interface RecommendationsGenerateHeaders { + /** The URL where the status of the asynchronous operation can be checked. */ + location?: string; + /** The amount of delay to use while the status of the operation is checked. The value is expressed in seconds. */ + retryAfter?: string; } -/** - * An interface representing AdvisorManagementClientOptions. - */ -export interface AdvisorManagementClientOptions extends AzureServiceClientOptions { - baseUri?: string; +/** Known values of {@link Scenario} that the service accepts. */ +export enum KnownScenario { + Alerts = "Alerts" } /** - * Defines headers for Generate operation. + * Defines values for Scenario. \ + * {@link KnownScenario} can be used interchangeably with Scenario, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Alerts** */ -export interface RecommendationsGenerateHeaders { - /** - * The URL where the status of the asynchronous operation can be checked. - */ - location: string; - /** - * The amount of delay to use while the status of the operation is checked. The value is - * expressed in seconds. - */ - retryAfter: string; +export type Scenario = string; + +/** Known values of {@link CpuThreshold} that the service accepts. */ +export enum KnownCpuThreshold { + Five = "5", + Ten = "10", + Fifteen = "15", + Twenty = "20" } /** - * @interface - * The list of metadata entities - * @extends Array - */ -export interface MetadataEntityListResult extends Array { - /** - * The link used to get the next page of metadata. - */ - nextLink?: string; + * Defines values for CpuThreshold. \ + * {@link KnownCpuThreshold} can be used interchangeably with CpuThreshold, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **5** \ + * **10** \ + * **15** \ + * **20** + */ +export type CpuThreshold = string; + +/** Known values of {@link Category} that the service accepts. */ +export enum KnownCategory { + HighAvailability = "HighAvailability", + Security = "Security", + Performance = "Performance", + Cost = "Cost", + OperationalExcellence = "OperationalExcellence" } /** - * @interface - * The list of Advisor configurations. - * @extends Array + * Defines values for Category. \ + * {@link KnownCategory} can be used interchangeably with Category, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **HighAvailability** \ + * **Security** \ + * **Performance** \ + * **Cost** \ + * **OperationalExcellence** */ -export interface ConfigurationListResult extends Array { - /** - * The link used to get the next page of configurations. - */ - nextLink?: string; +export type Category = string; + +/** Known values of {@link DigestConfigState} that the service accepts. */ +export enum KnownDigestConfigState { + Active = "Active", + Disabled = "Disabled" } /** - * @interface - * The list of Advisor recommendations. - * @extends Array + * Defines values for DigestConfigState. \ + * {@link KnownDigestConfigState} can be used interchangeably with DigestConfigState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Active** \ + * **Disabled** */ -export interface ResourceRecommendationBaseListResult extends Array { - /** - * The link used to get the next page of recommendations. - */ - nextLink?: string; +export type DigestConfigState = string; + +/** Known values of {@link ConfigurationName} that the service accepts. */ +export enum KnownConfigurationName { + Default = "default" } /** - * @interface - * The list of Advisor operations. - * @extends Array + * Defines values for ConfigurationName. \ + * {@link KnownConfigurationName} can be used interchangeably with ConfigurationName, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **default** */ -export interface OperationEntityListResult extends Array { - /** - * The link used to get the next page of operations. - */ - nextLink?: string; +export type ConfigurationName = string; + +/** Known values of {@link Impact} that the service accepts. */ +export enum KnownImpact { + High = "High", + Medium = "Medium", + Low = "Low" } /** - * @interface - * The list of Advisor suppressions. - * @extends Array + * Defines values for Impact. \ + * {@link KnownImpact} can be used interchangeably with Impact, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **High** \ + * **Medium** \ + * **Low** */ -export interface SuppressionContractListResult extends Array { - /** - * The link used to get the next page of suppressions. - */ - nextLink?: string; +export type Impact = string; + +/** Known values of {@link Risk} that the service accepts. */ +export enum KnownRisk { + Error = "Error", + Warning = "Warning", + None = "None" } /** - * Defines values for Scenario. - * Possible values include: 'Alerts' - * @readonly - * @enum {string} + * Defines values for Risk. \ + * {@link KnownRisk} can be used interchangeably with Risk, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Error** \ + * **Warning** \ + * **None** */ -export type Scenario = 'Alerts'; +export type Risk = string; -/** - * Defines values for CpuThreshold. - * Possible values include: '5', '10', '15', '20' - * @readonly - * @enum {string} - */ -export type CpuThreshold = '5' | '10' | '15' | '20'; +/** Optional parameters. */ +export interface RecommendationMetadataGetOptionalParams + extends coreClient.OperationOptions {} -/** - * Defines values for Category. - * Possible values include: 'HighAvailability', 'Security', 'Performance', 'Cost', - * 'OperationalExcellence' - * @readonly - * @enum {string} - */ -export type Category = 'HighAvailability' | 'Security' | 'Performance' | 'Cost' | 'OperationalExcellence'; +/** Contains response data for the get operation. */ +export type RecommendationMetadataGetResponse = MetadataEntity; -/** - * Defines values for DigestConfigState. - * Possible values include: 'Active', 'Disabled' - * @readonly - * @enum {string} - */ -export type DigestConfigState = 'Active' | 'Disabled'; +/** Optional parameters. */ +export interface RecommendationMetadataListOptionalParams + extends coreClient.OperationOptions {} -/** - * Defines values for Impact. - * Possible values include: 'High', 'Medium', 'Low' - * @readonly - * @enum {string} - */ -export type Impact = 'High' | 'Medium' | 'Low'; +/** Contains response data for the list operation. */ +export type RecommendationMetadataListResponse = MetadataEntityListResult; -/** - * Defines values for Risk. - * Possible values include: 'Error', 'Warning', 'None' - * @readonly - * @enum {string} - */ -export type Risk = 'Error' | 'Warning' | 'None'; +/** Optional parameters. */ +export interface RecommendationMetadataListNextOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the get operation. - */ -export type RecommendationMetadataGetResponse = { - /** - * The parsed response body. - */ - body: any; +/** Contains response data for the listNext operation. */ +export type RecommendationMetadataListNextResponse = MetadataEntityListResult; - /** - * 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: any; - }; -}; +/** Optional parameters. */ +export interface ConfigurationsListBySubscriptionOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the list operation. - */ -export type RecommendationMetadataListResponse = MetadataEntityListResult & { - /** - * 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: MetadataEntityListResult; - }; -}; +/** Contains response data for the listBySubscription operation. */ +export type ConfigurationsListBySubscriptionResponse = ConfigurationListResult; -/** - * Contains response data for the listNext operation. - */ -export type RecommendationMetadataListNextResponse = MetadataEntityListResult & { - /** - * 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: MetadataEntityListResult; - }; -}; +/** Optional parameters. */ +export interface ConfigurationsCreateInSubscriptionOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the listBySubscription operation. - */ -export type ConfigurationsListBySubscriptionResponse = ConfigurationListResult & { - /** - * 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: ConfigurationListResult; - }; -}; +/** Contains response data for the createInSubscription operation. */ +export type ConfigurationsCreateInSubscriptionResponse = ConfigData; -/** - * Contains response data for the createInSubscription operation. - */ -export type ConfigurationsCreateInSubscriptionResponse = ConfigData & { - /** - * 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: ConfigData; - }; -}; +/** Optional parameters. */ +export interface ConfigurationsListByResourceGroupOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the listByResourceGroup operation. - */ -export type ConfigurationsListByResourceGroupResponse = ConfigurationListResult & { - /** - * 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: ConfigurationListResult; - }; -}; +/** Contains response data for the listByResourceGroup operation. */ +export type ConfigurationsListByResourceGroupResponse = ConfigurationListResult; -/** - * Contains response data for the createInResourceGroup operation. - */ -export type ConfigurationsCreateInResourceGroupResponse = ConfigData & { - /** - * 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: ConfigData; - }; -}; +/** Optional parameters. */ +export interface ConfigurationsCreateInResourceGroupOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the listBySubscriptionNext operation. - */ -export type ConfigurationsListBySubscriptionNextResponse = ConfigurationListResult & { - /** - * 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: ConfigurationListResult; - }; -}; +/** Contains response data for the createInResourceGroup operation. */ +export type ConfigurationsCreateInResourceGroupResponse = ConfigData; -/** - * Contains response data for the generate operation. - */ -export type RecommendationsGenerateResponse = RecommendationsGenerateHeaders & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: RecommendationsGenerateHeaders; - }; -}; +/** Optional parameters. */ +export interface ConfigurationsListBySubscriptionNextOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the list operation. - */ -export type RecommendationsListResponse = ResourceRecommendationBaseListResult & { - /** - * 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: ResourceRecommendationBaseListResult; - }; -}; +/** Contains response data for the listBySubscriptionNext operation. */ +export type ConfigurationsListBySubscriptionNextResponse = ConfigurationListResult; -/** - * Contains response data for the get operation. - */ -export type RecommendationsGetResponse = ResourceRecommendationBase & { - /** - * 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: ResourceRecommendationBase; - }; -}; +/** Optional parameters. */ +export interface RecommendationsGenerateOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the listNext operation. - */ -export type RecommendationsListNextResponse = ResourceRecommendationBaseListResult & { - /** - * 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: ResourceRecommendationBaseListResult; - }; -}; +/** Contains response data for the generate operation. */ +export type RecommendationsGenerateResponse = RecommendationsGenerateHeaders; -/** - * Contains response data for the list operation. - */ -export type OperationsListResponse = OperationEntityListResult & { - /** - * 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: OperationEntityListResult; - }; -}; +/** Optional parameters. */ +export interface RecommendationsGetGenerateStatusOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the listNext operation. - */ -export type OperationsListNextResponse = OperationEntityListResult & { - /** - * 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: OperationEntityListResult; - }; -}; +/** Optional parameters. */ +export interface RecommendationsListOptionalParams + extends coreClient.OperationOptions { + /** The filter to apply to the recommendations.
Filter can be applied to properties ['ResourceId', 'ResourceGroup', 'RecommendationTypeGuid', '[Category](#category)'] with operators ['eq', 'and', 'or'].
Example:
- $filter=Category eq 'Cost' and ResourceGroup eq 'MyResourceGroup' */ + filter?: string; + /** The number of recommendations per page if a paged version of this API is being used. */ + top?: number; + /** The page-continuation token to use with a paged version of this API. */ + skipToken?: string; +} -/** - * Contains response data for the get operation. - */ -export type SuppressionsGetResponse = SuppressionContract & { - /** - * 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: SuppressionContract; - }; -}; +/** Contains response data for the list operation. */ +export type RecommendationsListResponse = ResourceRecommendationBaseListResult; -/** - * Contains response data for the create operation. - */ -export type SuppressionsCreateResponse = SuppressionContract & { - /** - * 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: SuppressionContract; - }; -}; +/** Optional parameters. */ +export interface RecommendationsGetOptionalParams + extends coreClient.OperationOptions {} -/** - * Contains response data for the list operation. - */ -export type SuppressionsListResponse = SuppressionContractListResult & { - /** - * 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: SuppressionContractListResult; - }; -}; +/** Contains response data for the get operation. */ +export type RecommendationsGetResponse = ResourceRecommendationBase; -/** - * Contains response data for the listNext operation. - */ -export type SuppressionsListNextResponse = SuppressionContractListResult & { - /** - * 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: SuppressionContractListResult; - }; -}; +/** Optional parameters. */ +export interface RecommendationsListNextOptionalParams + extends coreClient.OperationOptions { + /** The filter to apply to the recommendations.
Filter can be applied to properties ['ResourceId', 'ResourceGroup', 'RecommendationTypeGuid', '[Category](#category)'] with operators ['eq', 'and', 'or'].
Example:
- $filter=Category eq 'Cost' and ResourceGroup eq 'MyResourceGroup' */ + filter?: string; + /** The number of recommendations per page if a paged version of this API is being used. */ + top?: number; + /** The page-continuation token to use with a paged version of this API. */ + skipToken?: string; +} + +/** Contains response data for the listNext operation. */ +export type RecommendationsListNextResponse = ResourceRecommendationBaseListResult; + +/** Optional parameters. */ +export interface OperationsListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type OperationsListResponse = OperationEntityListResult; + +/** Optional parameters. */ +export interface OperationsListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type OperationsListNextResponse = OperationEntityListResult; + +/** Optional parameters. */ +export interface SuppressionsGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type SuppressionsGetResponse = SuppressionContract; + +/** Optional parameters. */ +export interface SuppressionsCreateOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the create operation. */ +export type SuppressionsCreateResponse = SuppressionContract; + +/** Optional parameters. */ +export interface SuppressionsDeleteOptionalParams + extends coreClient.OperationOptions {} + +/** Optional parameters. */ +export interface SuppressionsListOptionalParams + extends coreClient.OperationOptions { + /** The number of suppressions per page if a paged version of this API is being used. */ + top?: number; + /** The page-continuation token to use with a paged version of this API. */ + skipToken?: string; +} + +/** Contains response data for the list operation. */ +export type SuppressionsListResponse = SuppressionContractListResult; + +/** Optional parameters. */ +export interface SuppressionsListNextOptionalParams + extends coreClient.OperationOptions { + /** The number of suppressions per page if a paged version of this API is being used. */ + top?: number; + /** The page-continuation token to use with a paged version of this API. */ + skipToken?: string; +} + +/** Contains response data for the listNext operation. */ +export type SuppressionsListNextResponse = SuppressionContractListResult; + +/** Optional parameters. */ +export interface AdvisorManagementClientOptionalParams + extends coreClient.ServiceClientOptions { + /** server parameter */ + $host?: string; + /** Api Version */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/advisor/arm-advisor/src/models/mappers.ts b/sdk/advisor/arm-advisor/src/models/mappers.ts index 38a96c10028f..50740e96e076 100644 --- a/sdk/advisor/arm-advisor/src/models/mappers.ts +++ b/sdk/advisor/arm-advisor/src/models/mappers.ts @@ -1,41 +1,14 @@ /* - * 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 MetadataSupportedValueDetail: msRest.CompositeMapper = { - serializedName: "MetadataSupportedValueDetail", - type: { - name: "Composite", - className: "MetadataSupportedValueDetail", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - displayName: { - serializedName: "displayName", - type: { - name: "String" - } - } - } - } -}; - -export const MetadataEntity: msRest.CompositeMapper = { - serializedName: "MetadataEntity", +export const MetadataEntity: coreClient.CompositeMapper = { type: { name: "Composite", className: "MetadataEntity", @@ -102,8 +75,119 @@ export const MetadataEntity: msRest.CompositeMapper = { } }; -export const DigestConfig: msRest.CompositeMapper = { - serializedName: "DigestConfig", +export const MetadataSupportedValueDetail: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "MetadataSupportedValueDetail", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + displayName: { + serializedName: "displayName", + type: { + name: "String" + } + } + } + } +}; + +export const ARMErrorResponseBody: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ARMErrorResponseBody", + modelProperties: { + message: { + serializedName: "message", + type: { + name: "String" + } + }, + code: { + serializedName: "code", + type: { + name: "String" + } + } + } + } +}; + +export const ArmErrorResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ArmErrorResponse", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ARMErrorResponseBody" + } + } + } + } +}; + +export const MetadataEntityListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "MetadataEntityListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "MetadataEntity" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const ConfigurationListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ConfigurationListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ConfigData" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const DigestConfig: coreClient.CompositeMapper = { type: { name: "Composite", className: "DigestConfig", @@ -153,29 +237,28 @@ export const DigestConfig: msRest.CompositeMapper = { } }; -export const Resource: msRest.CompositeMapper = { - serializedName: "Resource", +export const Resource: coreClient.CompositeMapper = { type: { name: "Composite", className: "Resource", modelProperties: { id: { - readOnly: true, serializedName: "id", + readOnly: true, type: { name: "String" } }, name: { - readOnly: true, serializedName: "name", + readOnly: true, type: { name: "String" } }, type: { - readOnly: true, serializedName: "type", + readOnly: true, type: { name: "String" } @@ -184,33 +267,25 @@ export const Resource: msRest.CompositeMapper = { } }; -export const ConfigData: msRest.CompositeMapper = { - serializedName: "ConfigData", +export const ResourceRecommendationBaseListResult: coreClient.CompositeMapper = { type: { name: "Composite", - className: "ConfigData", + className: "ResourceRecommendationBaseListResult", modelProperties: { - ...Resource.type.modelProperties, - exclude: { - serializedName: "properties.exclude", - type: { - name: "Boolean" - } - }, - lowCpuThreshold: { - serializedName: "properties.lowCpuThreshold", + nextLink: { + serializedName: "nextLink", type: { name: "String" } }, - digests: { - serializedName: "properties.digests", + value: { + serializedName: "value", type: { name: "Sequence", element: { type: { name: "Composite", - className: "DigestConfig" + className: "ResourceRecommendationBase" } } } @@ -219,20 +294,19 @@ export const ConfigData: msRest.CompositeMapper = { } }; -export const ARMErrorResponseBody: msRest.CompositeMapper = { - serializedName: "ARMErrorResponseBody", +export const ShortDescription: coreClient.CompositeMapper = { type: { name: "Composite", - className: "ARMErrorResponseBody", + className: "ShortDescription", modelProperties: { - message: { - serializedName: "message", + problem: { + serializedName: "problem", type: { name: "String" } }, - code: { - serializedName: "code", + solution: { + serializedName: "solution", type: { name: "String" } @@ -241,37 +315,122 @@ export const ARMErrorResponseBody: msRest.CompositeMapper = { } }; -export const ArmErrorResponse: msRest.CompositeMapper = { - serializedName: "ArmErrorResponse", +export const ResourceMetadata: coreClient.CompositeMapper = { type: { name: "Composite", - className: "ArmErrorResponse", + className: "ResourceMetadata", modelProperties: { - error: { - serializedName: "error", + resourceId: { + serializedName: "resourceId", + type: { + name: "String" + } + }, + source: { + serializedName: "source", + type: { + name: "String" + } + }, + action: { + serializedName: "action", + type: { + name: "Dictionary", + value: { + type: { name: "Dictionary", value: { type: { name: "any" } } } + } + } + }, + singular: { + serializedName: "singular", + type: { + name: "String" + } + }, + plural: { + serializedName: "plural", + type: { + name: "String" + } + } + } + } +}; + +export const OperationEntityListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationEntityListResult", + modelProperties: { + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + }, + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "OperationEntity" + } + } + } + } + } + } +}; + +export const OperationEntity: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationEntity", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + display: { + serializedName: "display", type: { name: "Composite", - className: "ARMErrorResponseBody" + className: "OperationDisplayInfo" } } } } }; -export const ShortDescription: msRest.CompositeMapper = { - serializedName: "ShortDescription", +export const OperationDisplayInfo: coreClient.CompositeMapper = { type: { name: "Composite", - className: "ShortDescription", + className: "OperationDisplayInfo", modelProperties: { - problem: { - serializedName: "problem", + description: { + serializedName: "description", type: { name: "String" } }, - solution: { - serializedName: "solution", + operation: { + serializedName: "operation", + type: { + name: "String" + } + }, + provider: { + serializedName: "provider", + type: { + name: "String" + } + }, + resource: { + serializedName: "resource", type: { name: "String" } @@ -280,30 +439,68 @@ export const ShortDescription: msRest.CompositeMapper = { } }; -export const ResourceMetadata: msRest.CompositeMapper = { - serializedName: "ResourceMetadata", +export const SuppressionContractListResult: coreClient.CompositeMapper = { type: { name: "Composite", - className: "ResourceMetadata", + className: "SuppressionContractListResult", modelProperties: { - resourceId: { - serializedName: "resourceId", + nextLink: { + serializedName: "nextLink", type: { name: "String" } }, - source: { - serializedName: "source", + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "SuppressionContract" + } + } + } + } + } + } +}; + +export const ConfigData: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ConfigData", + modelProperties: { + ...Resource.type.modelProperties, + exclude: { + serializedName: "properties.exclude", + type: { + name: "Boolean" + } + }, + lowCpuThreshold: { + serializedName: "properties.lowCpuThreshold", type: { name: "String" } + }, + digests: { + serializedName: "properties.digests", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "DigestConfig" + } + } + } } } } }; -export const ResourceRecommendationBase: msRest.CompositeMapper = { - serializedName: "ResourceRecommendationBase", +export const ResourceRecommendationBase: coreClient.CompositeMapper = { type: { name: "Composite", className: "ResourceRecommendationBase", @@ -344,9 +541,7 @@ export const ResourceRecommendationBase: msRest.CompositeMapper = { type: { name: "Dictionary", value: { - type: { - name: "Object" - } + type: { name: "Dictionary", value: { type: { name: "any" } } } } } }, @@ -384,11 +579,7 @@ export const ResourceRecommendationBase: msRest.CompositeMapper = { serializedName: "properties.extendedProperties", type: { name: "Dictionary", - value: { - type: { - name: "String" - } - } + value: { type: { name: "String" } } } }, resourceMetadata: { @@ -397,247 +588,111 @@ export const ResourceRecommendationBase: msRest.CompositeMapper = { name: "Composite", className: "ResourceMetadata" } - } - } - } -}; - -export const OperationDisplayInfo: msRest.CompositeMapper = { - serializedName: "OperationDisplayInfo", - type: { - name: "Composite", - className: "OperationDisplayInfo", - modelProperties: { + }, description: { - serializedName: "description", + serializedName: "properties.description", type: { name: "String" } }, - operation: { - serializedName: "operation", + label: { + serializedName: "properties.label", type: { name: "String" } }, - provider: { - serializedName: "provider", + learnMoreLink: { + serializedName: "properties.learnMoreLink", type: { name: "String" } }, - resource: { - serializedName: "resource", - type: { - name: "String" - } - } - } - } -}; - -export const OperationEntity: msRest.CompositeMapper = { - serializedName: "OperationEntity", - type: { - name: "Composite", - className: "OperationEntity", - modelProperties: { - name: { - serializedName: "name", - type: { - name: "String" - } - }, - display: { - serializedName: "display", - type: { - name: "Composite", - className: "OperationDisplayInfo" - } - } - } - } -}; - -export const SuppressionContract: msRest.CompositeMapper = { - serializedName: "SuppressionContract", - type: { - name: "Composite", - className: "SuppressionContract", - modelProperties: { - ...Resource.type.modelProperties, - suppressionId: { - serializedName: "properties.suppressionId", + potentialBenefits: { + serializedName: "properties.potentialBenefits", type: { name: "String" } }, - ttl: { - serializedName: "properties.ttl", - type: { - name: "String" - } - } - } - } -}; - -export const RecommendationsGenerateHeaders: msRest.CompositeMapper = { - serializedName: "recommendations-generate-headers", - type: { - name: "Composite", - className: "RecommendationsGenerateHeaders", - modelProperties: { - location: { - serializedName: "location", - type: { - name: "String" - } - }, - retryAfter: { - serializedName: "retry-after", - type: { - name: "String" - } - } - } - } -}; - -export const MetadataEntityListResult: msRest.CompositeMapper = { - serializedName: "MetadataEntityListResult", - type: { - name: "Composite", - className: "MetadataEntityListResult", - modelProperties: { - value: { - serializedName: "", + actions: { + serializedName: "properties.actions", type: { name: "Sequence", element: { type: { - name: "Composite", - className: "MetadataEntity" + name: "Dictionary", + value: { + type: { name: "Dictionary", value: { type: { name: "any" } } } + } } } } }, - nextLink: { - serializedName: "nextLink", - type: { - name: "String" - } - } - } - } -}; - -export const ConfigurationListResult: msRest.CompositeMapper = { - serializedName: "ConfigurationListResult", - type: { - name: "Composite", - className: "ConfigurationListResult", - modelProperties: { - value: { - serializedName: "", + remediation: { + serializedName: "properties.remediation", type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ConfigData" - } + name: "Dictionary", + value: { + type: { name: "Dictionary", value: { type: { name: "any" } } } } } }, - nextLink: { - serializedName: "nextLink", + exposedMetadataProperties: { + serializedName: "properties.exposedMetadataProperties", type: { - name: "String" + name: "Dictionary", + value: { + type: { name: "Dictionary", value: { type: { name: "any" } } } + } } } } } }; -export const ResourceRecommendationBaseListResult: msRest.CompositeMapper = { - serializedName: "ResourceRecommendationBaseListResult", +export const SuppressionContract: coreClient.CompositeMapper = { type: { name: "Composite", - className: "ResourceRecommendationBaseListResult", + className: "SuppressionContract", modelProperties: { - nextLink: { - serializedName: "nextLink", + ...Resource.type.modelProperties, + suppressionId: { + serializedName: "properties.suppressionId", type: { name: "String" } }, - value: { - serializedName: "", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "ResourceRecommendationBase" - } - } - } - } - } - } -}; - -export const OperationEntityListResult: msRest.CompositeMapper = { - serializedName: "OperationEntityListResult", - type: { - name: "Composite", - className: "OperationEntityListResult", - modelProperties: { - nextLink: { - serializedName: "nextLink", + ttl: { + serializedName: "properties.ttl", type: { name: "String" } }, - value: { - serializedName: "", + expirationTimeStamp: { + serializedName: "properties.expirationTimeStamp", + readOnly: true, type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "OperationEntity" - } - } + name: "DateTime" } } } } }; -export const SuppressionContractListResult: msRest.CompositeMapper = { - serializedName: "SuppressionContractListResult", +export const RecommendationsGenerateHeaders: coreClient.CompositeMapper = { type: { name: "Composite", - className: "SuppressionContractListResult", + className: "RecommendationsGenerateHeaders", modelProperties: { - nextLink: { - serializedName: "nextLink", + location: { + serializedName: "location", type: { name: "String" } }, - value: { - serializedName: "", + retryAfter: { + serializedName: "retry-after", type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "SuppressionContract" - } - } + name: "String" } } } diff --git a/sdk/advisor/arm-advisor/src/models/operationsMappers.ts b/sdk/advisor/arm-advisor/src/models/operationsMappers.ts deleted file mode 100644 index c83dbeabcc21..000000000000 --- a/sdk/advisor/arm-advisor/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 { - CloudError, - OperationDisplayInfo, - OperationEntity, - OperationEntityListResult -} from "../models/mappers"; diff --git a/sdk/advisor/arm-advisor/src/models/parameters.ts b/sdk/advisor/arm-advisor/src/models/parameters.ts index 0a32fd06e64c..3dbd23be6ada 100644 --- a/sdk/advisor/arm-advisor/src/models/parameters.ts +++ b/sdk/advisor/arm-advisor/src/models/parameters.ts @@ -1,125 +1,163 @@ /* - * 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 { + ConfigData as ConfigDataMapper, + SuppressionContract as SuppressionContractMapper +} 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 apiVersion: msRest.OperationQueryParameter = { - parameterPath: "apiVersion", + +export const $host: OperationURLParameter = { + parameterPath: "$host", mapper: { + serializedName: "$host", required: true, - serializedName: "api-version", type: { name: "String" } - } + }, + skipEncoding: true }; -export const configurationName: msRest.OperationURLParameter = { - parameterPath: "configurationName", + +export const name: OperationURLParameter = { + parameterPath: "name", mapper: { + serializedName: "name", required: true, - isConstant: true, - serializedName: "configurationName", - defaultValue: 'default', type: { name: "String" } } }; -export const filter: msRest.OperationQueryParameter = { - parameterPath: [ - "options", - "filter" - ], + +export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", mapper: { - serializedName: "$filter", + defaultValue: "2020-01-01", + isConstant: true, + serializedName: "api-version", type: { name: "String" } } }; -export const name: msRest.OperationURLParameter = { - parameterPath: "name", + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", mapper: { + serializedName: "nextLink", required: true, - serializedName: "name", type: { name: "String" } - } + }, + skipEncoding: true }; -export const nextPageLink: msRest.OperationURLParameter = { - parameterPath: "nextPageLink", + +export const subscriptionId: OperationURLParameter = { + parameterPath: "subscriptionId", mapper: { + serializedName: "subscriptionId", required: true, - serializedName: "nextLink", type: { name: "String" } - }, - skipEncoding: true + } }; -export const operationId: msRest.OperationURLParameter = { - parameterPath: "operationId", + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], mapper: { - required: true, - serializedName: "operationId", + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", type: { - name: "Uuid" + name: "String" } } }; -export const recommendationId: msRest.OperationURLParameter = { - parameterPath: "recommendationId", + +export const configContract: OperationParameter = { + parameterPath: "configContract", + mapper: ConfigDataMapper +}; + +export const configurationName: OperationURLParameter = { + parameterPath: "configurationName", mapper: { + serializedName: "configurationName", required: true, - serializedName: "recommendationId", type: { name: "String" } } }; -export const resourceGroup: msRest.OperationURLParameter = { + +export const resourceGroup: OperationURLParameter = { parameterPath: "resourceGroup", mapper: { - required: true, serializedName: "resourceGroup", + required: true, type: { name: "String" } } }; -export const resourceUri: msRest.OperationURLParameter = { - parameterPath: "resourceUri", + +export const operationId: OperationURLParameter = { + parameterPath: "operationId", mapper: { + serializedName: "operationId", required: true, - serializedName: "resourceUri", + type: { + name: "Uuid" + } + } +}; + +export const filter: OperationQueryParameter = { + parameterPath: ["options", "filter"], + mapper: { + serializedName: "$filter", type: { name: "String" } } }; -export const skipToken: msRest.OperationQueryParameter = { - parameterPath: [ - "options", - "skipToken" - ], + +export const top: OperationQueryParameter = { + parameterPath: ["options", "top"], + mapper: { + serializedName: "$top", + type: { + name: "Number" + } + } +}; + +export const skipToken: OperationQueryParameter = { + parameterPath: ["options", "skipToken"], mapper: { serializedName: "$skipToken", type: { @@ -127,25 +165,30 @@ export const skipToken: msRest.OperationQueryParameter = { } } }; -export const subscriptionId: msRest.OperationURLParameter = { - parameterPath: "subscriptionId", + +export const resourceUri: OperationURLParameter = { + parameterPath: "resourceUri", mapper: { + serializedName: "resourceUri", required: true, - serializedName: "subscriptionId", type: { name: "String" } } }; -export const top: msRest.OperationQueryParameter = { - parameterPath: [ - "options", - "top" - ], + +export const recommendationId: OperationURLParameter = { + parameterPath: "recommendationId", mapper: { - serializedName: "$top", + serializedName: "recommendationId", + required: true, type: { - name: "Number" + name: "String" } } }; + +export const suppressionContract: OperationParameter = { + parameterPath: "suppressionContract", + mapper: SuppressionContractMapper +}; diff --git a/sdk/advisor/arm-advisor/src/models/recommendationMetadataMappers.ts b/sdk/advisor/arm-advisor/src/models/recommendationMetadataMappers.ts deleted file mode 100644 index fca081125f33..000000000000 --- a/sdk/advisor/arm-advisor/src/models/recommendationMetadataMappers.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 { - ARMErrorResponseBody, - CloudError, - MetadataEntity, - MetadataEntityListResult, - MetadataSupportedValueDetail -} from "../models/mappers"; diff --git a/sdk/advisor/arm-advisor/src/models/recommendationsMappers.ts b/sdk/advisor/arm-advisor/src/models/recommendationsMappers.ts deleted file mode 100644 index d4cb0dcd832b..000000000000 --- a/sdk/advisor/arm-advisor/src/models/recommendationsMappers.ts +++ /dev/null @@ -1,21 +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, - CloudError, - ConfigData, - DigestConfig, - RecommendationsGenerateHeaders, - Resource, - ResourceMetadata, - ResourceRecommendationBase, - ResourceRecommendationBaseListResult, - ShortDescription, - SuppressionContract -} from "../models/mappers"; diff --git a/sdk/advisor/arm-advisor/src/models/suppressionsMappers.ts b/sdk/advisor/arm-advisor/src/models/suppressionsMappers.ts deleted file mode 100644 index b15519119bc5..000000000000 --- a/sdk/advisor/arm-advisor/src/models/suppressionsMappers.ts +++ /dev/null @@ -1,20 +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, - CloudError, - ConfigData, - DigestConfig, - Resource, - ResourceMetadata, - ResourceRecommendationBase, - ShortDescription, - SuppressionContract, - SuppressionContractListResult -} from "../models/mappers"; diff --git a/sdk/advisor/arm-advisor/src/operations/configurations.ts b/sdk/advisor/arm-advisor/src/operations/configurations.ts index 9ea34dae1bff..c7c2d2306d7c 100644 --- a/sdk/advisor/arm-advisor/src/operations/configurations.ts +++ b/sdk/advisor/arm-advisor/src/operations/configurations.ts @@ -1,192 +1,217 @@ /* - * 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/configurationsMappers"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Configurations } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AdvisorManagementClientContext } from "../advisorManagementClientContext"; +import { AdvisorManagementClient } from "../advisorManagementClient"; +import { + ConfigData, + ConfigurationsListBySubscriptionNextOptionalParams, + ConfigurationsListBySubscriptionOptionalParams, + ConfigurationsListByResourceGroupOptionalParams, + ConfigurationsListBySubscriptionResponse, + ConfigurationName, + ConfigurationsCreateInSubscriptionOptionalParams, + ConfigurationsCreateInSubscriptionResponse, + ConfigurationsListByResourceGroupResponse, + ConfigurationsCreateInResourceGroupOptionalParams, + ConfigurationsCreateInResourceGroupResponse, + ConfigurationsListBySubscriptionNextResponse +} from "../models"; -/** Class representing a Configurations. */ -export class Configurations { - private readonly client: AdvisorManagementClientContext; +/// +/** Class containing Configurations operations. */ +export class ConfigurationsImpl implements Configurations { + private readonly client: AdvisorManagementClient; /** - * Create a Configurations. - * @param {AdvisorManagementClientContext} client Reference to the service client. + * Initialize a new instance of the class Configurations class. + * @param client Reference to the service client */ - constructor(client: AdvisorManagementClientContext) { + constructor(client: AdvisorManagementClient) { this.client = client; } /** - * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource - * groups. - * @summary Retrieve Azure Advisor configurations. - * @param [options] The optional parameters - * @returns Promise + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * @param options The options parameters. */ - listBySubscription(options?: msRest.RequestOptionsBase): Promise; + public listBySubscription( + options?: ConfigurationsListBySubscriptionOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listBySubscriptionPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listBySubscriptionPagingPage(options); + } + }; + } + + private async *listBySubscriptionPagingPage( + options?: ConfigurationsListBySubscriptionOptionalParams + ): AsyncIterableIterator { + let result = await this._listBySubscription(options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listBySubscriptionNext(continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listBySubscriptionPagingAll( + options?: ConfigurationsListBySubscriptionOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listBySubscriptionPagingPage(options)) { + yield* page; + } + } + /** - * @param callback The callback + * Retrieve Azure Advisor configurations. + * @param resourceGroup The name of the Azure resource group. + * @param options The options parameters. */ - listBySubscription(callback: msRest.ServiceCallback): void; + public listByResourceGroup( + resourceGroup: string, + options?: ConfigurationsListByResourceGroupOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listByResourceGroupPagingAll(resourceGroup, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listByResourceGroupPagingPage(resourceGroup, options); + } + }; + } + + private async *listByResourceGroupPagingPage( + resourceGroup: string, + options?: ConfigurationsListByResourceGroupOptionalParams + ): AsyncIterableIterator { + let result = await this._listByResourceGroup(resourceGroup, options); + yield result.value || []; + } + + private async *listByResourceGroupPagingAll( + resourceGroup: string, + options?: ConfigurationsListByResourceGroupOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listByResourceGroupPagingPage( + resourceGroup, + options + )) { + yield* page; + } + } + /** - * @param options The optional parameters - * @param callback The callback + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * @param options The options parameters. */ - listBySubscription(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listBySubscription(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listBySubscription( + options?: ConfigurationsListBySubscriptionOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - options - }, - listBySubscriptionOperationSpec, - callback) as Promise; + { options }, + listBySubscriptionOperationSpec + ); } /** * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained * resource groups. - * @summary Create/Overwrite Azure Advisor configuration. - * @param configContract The Azure Advisor configuration data structure. - * @param [options] The optional parameters - * @returns Promise - */ - createInSubscription(configContract: Models.ConfigData, options?: msRest.RequestOptionsBase): Promise; - /** + * @param configurationName Advisor configuration name. Value must be 'default' * @param configContract The Azure Advisor configuration data structure. - * @param callback The callback + * @param options The options parameters. */ - createInSubscription(configContract: Models.ConfigData, callback: msRest.ServiceCallback): void; - /** - * @param configContract The Azure Advisor configuration data structure. - * @param options The optional parameters - * @param callback The callback - */ - createInSubscription(configContract: Models.ConfigData, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - createInSubscription(configContract: Models.ConfigData, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + createInSubscription( + configurationName: ConfigurationName, + configContract: ConfigData, + options?: ConfigurationsCreateInSubscriptionOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - configContract, - options - }, - createInSubscriptionOperationSpec, - callback) as Promise; + { configurationName, configContract, options }, + createInSubscriptionOperationSpec + ); } /** - * @summary Retrieve Azure Advisor configurations. + * Retrieve Azure Advisor configurations. * @param resourceGroup The name of the Azure resource group. - * @param [options] The optional parameters - * @returns Promise + * @param options The options parameters. */ - listByResourceGroup(resourceGroup: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param resourceGroup The name of the Azure resource group. - * @param callback The callback - */ - listByResourceGroup(resourceGroup: string, callback: msRest.ServiceCallback): void; - /** - * @param resourceGroup The name of the Azure resource group. - * @param options The optional parameters - * @param callback The callback - */ - listByResourceGroup(resourceGroup: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listByResourceGroup(resourceGroup: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listByResourceGroup( + resourceGroup: string, + options?: ConfigurationsListByResourceGroupOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - resourceGroup, - options - }, - listByResourceGroupOperationSpec, - callback) as Promise; + { resourceGroup, options }, + listByResourceGroupOperationSpec + ); } /** - * @summary Create/Overwrite Azure Advisor configuration. - * @param configContract The Azure Advisor configuration data structure. + * Create/Overwrite Azure Advisor configuration. + * @param configurationName Advisor configuration name. Value must be 'default' * @param resourceGroup The name of the Azure resource group. - * @param [options] The optional parameters - * @returns Promise - */ - createInResourceGroup(configContract: Models.ConfigData, resourceGroup: string, options?: msRest.RequestOptionsBase): Promise; - /** * @param configContract The Azure Advisor configuration data structure. - * @param resourceGroup The name of the Azure resource group. - * @param callback The callback + * @param options The options parameters. */ - createInResourceGroup(configContract: Models.ConfigData, resourceGroup: string, callback: msRest.ServiceCallback): void; - /** - * @param configContract The Azure Advisor configuration data structure. - * @param resourceGroup The name of the Azure resource group. - * @param options The optional parameters - * @param callback The callback - */ - createInResourceGroup(configContract: Models.ConfigData, resourceGroup: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - createInResourceGroup(configContract: Models.ConfigData, resourceGroup: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + createInResourceGroup( + configurationName: ConfigurationName, + resourceGroup: string, + configContract: ConfigData, + options?: ConfigurationsCreateInResourceGroupOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - configContract, - resourceGroup, - options - }, - createInResourceGroupOperationSpec, - callback) as Promise; + { configurationName, resourceGroup, configContract, options }, + createInResourceGroupOperationSpec + ); } /** - * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource - * groups. - * @summary Retrieve Azure Advisor configurations. - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param [options] The optional parameters - * @returns Promise - */ - listBySubscriptionNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param callback The callback - */ - listBySubscriptionNext(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 + * ListBySubscriptionNext + * @param nextLink The nextLink from the previous successful call to the ListBySubscription method. + * @param options The options parameters. */ - listBySubscriptionNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listBySubscriptionNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listBySubscriptionNext( + nextLink: string, + options?: ConfigurationsListBySubscriptionNextOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - nextPageLink, - options - }, - listBySubscriptionNextOperationSpec, - callback) as Promise; + { nextLink, options }, + listBySubscriptionNextOperationSpec + ); } } - // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const listBySubscriptionOperationSpec: msRest.OperationSpec = { +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listBySubscriptionOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations", httpMethod: "GET", - path: "subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations", - urlParameters: [ - Parameters.subscriptionId - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.ConfigurationListResult @@ -195,29 +220,15 @@ const listBySubscriptionOperationSpec: msRest.OperationSpec = { bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], serializer }; - -const createInSubscriptionOperationSpec: msRest.OperationSpec = { +const createInSubscriptionOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations/{configurationName}", httpMethod: "PUT", - path: "subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations/{configurationName}", - urlParameters: [ - Parameters.subscriptionId, - Parameters.configurationName - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], - requestBody: { - parameterPath: "configContract", - mapper: { - ...Mappers.ConfigData, - required: true - } - }, responses: { 200: { bodyMapper: Mappers.ConfigData @@ -226,22 +237,21 @@ const createInSubscriptionOperationSpec: msRest.OperationSpec = { bodyMapper: Mappers.ArmErrorResponse } }, - serializer -}; - -const listByResourceGroupOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations", + requestBody: Parameters.configContract, + queryParameters: [Parameters.apiVersion], urlParameters: [ + Parameters.$host, Parameters.subscriptionId, - Parameters.resourceGroup - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage + Parameters.configurationName ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const listByResourceGroupOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations", + httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ConfigurationListResult @@ -250,30 +260,19 @@ const listByResourceGroupOperationSpec: msRest.OperationSpec = { bodyMapper: Mappers.ArmErrorResponse } }, - serializer -}; - -const createInResourceGroupOperationSpec: msRest.OperationSpec = { - httpMethod: "PUT", - path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations/{configurationName}", + queryParameters: [Parameters.apiVersion], urlParameters: [ + Parameters.$host, Parameters.subscriptionId, - Parameters.configurationName, Parameters.resourceGroup ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], - requestBody: { - parameterPath: "configContract", - mapper: { - ...Mappers.ConfigData, - required: true - } - }, + headerParameters: [Parameters.accept], + serializer +}; +const createInResourceGroupOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations/{configurationName}", + httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.ConfigData @@ -282,19 +281,21 @@ const createInResourceGroupOperationSpec: msRest.OperationSpec = { bodyMapper: Mappers.ArmErrorResponse } }, + requestBody: Parameters.configContract, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.configurationName, + Parameters.resourceGroup + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", serializer }; - -const listBySubscriptionNextOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - baseUrl: "https://management.azure.com", +const listBySubscriptionNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", - urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptLanguage - ], + httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ConfigurationListResult @@ -303,5 +304,12 @@ const listBySubscriptionNextOperationSpec: msRest.OperationSpec = { bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId + ], + headerParameters: [Parameters.accept], serializer }; diff --git a/sdk/advisor/arm-advisor/src/operations/index.ts b/sdk/advisor/arm-advisor/src/operations/index.ts index 1b2399089695..9bb829013597 100644 --- a/sdk/advisor/arm-advisor/src/operations/index.ts +++ b/sdk/advisor/arm-advisor/src/operations/index.ts @@ -1,11 +1,9 @@ /* - * 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 "./recommendationMetadata"; diff --git a/sdk/advisor/arm-advisor/src/operations/operations.ts b/sdk/advisor/arm-advisor/src/operations/operations.ts index 8dccfa50fbeb..2eb2ca8ae462 100644 --- a/sdk/advisor/arm-advisor/src/operations/operations.ts +++ b/sdk/advisor/arm-advisor/src/operations/operations.ts @@ -1,123 +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 { AdvisorManagementClientContext } from "../advisorManagementClientContext"; +import { AdvisorManagementClient } from "../advisorManagementClient"; +import { + OperationEntity, + OperationsListNextOptionalParams, + OperationsListOptionalParams, + OperationsListResponse, + OperationsListNextResponse +} from "../models"; -/** Class representing a Operations. */ -export class Operations { - private readonly client: AdvisorManagementClientContext; +/// +/** Class containing Operations operations. */ +export class OperationsImpl implements Operations { + private readonly client: AdvisorManagementClient; /** - * Create a Operations. - * @param {AdvisorManagementClientContext} client Reference to the service client. + * Initialize a new instance of the class Operations class. + * @param client Reference to the service client */ - constructor(client: AdvisorManagementClientContext) { + constructor(client: AdvisorManagementClient) { this.client = client; } /** * Lists all the available Advisor REST API operations. - * @param [options] The optional parameters - * @returns Promise + * @param options The options parameters. */ - 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 + public list( + options?: OperationsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; }, - listOperationSpec, - callback) as Promise; + 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; + } } /** * Lists all the available Advisor REST API operations. - * @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 + * @param options The options parameters. */ - listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + private _list( + options?: OperationsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @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. */ - listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listNext( + nextLink: string, + options?: OperationsListNextOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - nextPageLink, - options - }, - listNextOperationSpec, - 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.Advisor/operations", httpMethod: "GET", - path: "providers/Microsoft.Advisor/operations", - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.OperationEntityListResult }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], serializer }; - -const listNextOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - baseUrl: "https://management.azure.com", +const listNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", - urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptLanguage - ], + httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OperationEntityListResult }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], serializer }; diff --git a/sdk/advisor/arm-advisor/src/operations/recommendationMetadata.ts b/sdk/advisor/arm-advisor/src/operations/recommendationMetadata.ts index 487abe86bdca..3529fe8c756b 100644 --- a/sdk/advisor/arm-advisor/src/operations/recommendationMetadata.ts +++ b/sdk/advisor/arm-advisor/src/operations/recommendationMetadata.ts @@ -1,177 +1,174 @@ /* - * 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/recommendationMetadataMappers"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { RecommendationMetadata } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AdvisorManagementClientContext } from "../advisorManagementClientContext"; +import { AdvisorManagementClient } from "../advisorManagementClient"; +import { + MetadataEntity, + RecommendationMetadataListNextOptionalParams, + RecommendationMetadataListOptionalParams, + RecommendationMetadataGetOptionalParams, + RecommendationMetadataGetResponse, + RecommendationMetadataListResponse, + RecommendationMetadataListNextResponse +} from "../models"; -/** Class representing a RecommendationMetadata. */ -export class RecommendationMetadata { - private readonly client: AdvisorManagementClientContext; +/// +/** Class containing RecommendationMetadata operations. */ +export class RecommendationMetadataImpl implements RecommendationMetadata { + private readonly client: AdvisorManagementClient; /** - * Create a RecommendationMetadata. - * @param {AdvisorManagementClientContext} client Reference to the service client. + * Initialize a new instance of the class RecommendationMetadata class. + * @param client Reference to the service client */ - constructor(client: AdvisorManagementClientContext) { + constructor(client: AdvisorManagementClient) { this.client = client; } /** - * @summary Gets the metadata entity. - * @param name Name of metadata entity. - * @param [options] The optional parameters - * @returns Promise - */ - get(name: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param name Name of metadata entity. - * @param callback The callback + * Gets the list of metadata entities. + * @param options The options parameters. */ - get(name: string, callback: msRest.ServiceCallback): void; - /** - * @param name Name of metadata entity. - * @param options The optional parameters - * @param callback The callback - */ - get(name: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - get(name: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - name, - options + public list( + options?: RecommendationMetadataListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); }, - getOperationSpec, - callback) as Promise; + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(options); + } + }; + } + + private async *listPagingPage( + options?: RecommendationMetadataListOptionalParams + ): 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?: RecommendationMetadataListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } } /** - * @summary Gets the list of metadata entities. - * @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 + * Gets the metadata entity. + * @param name Name of metadata entity. + * @param options The options parameters. */ - list(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - list(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + get( + name: string, + options?: RecommendationMetadataGetOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - options - }, - listOperationSpec, - callback) as Promise; + { name, options }, + getOperationSpec + ); } /** - * @summary Gets the list of metadata entities. - * @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 + * Gets the list of metadata entities. + * @param options The options parameters. */ - listNext(nextPageLink: string, callback: msRest.ServiceCallback): void; + private _list( + options?: RecommendationMetadataListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + /** - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @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. */ - listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listNext( + nextLink: string, + options?: RecommendationMetadataListNextOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - nextPageLink, - options - }, - listNextOperationSpec, - callback) as Promise; + { nextLink, options }, + listNextOperationSpec + ); } } - // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const getOperationSpec: msRest.OperationSpec = { +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const getOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Advisor/metadata/{name}", httpMethod: "GET", - path: "providers/Microsoft.Advisor/metadata/{name}", - urlParameters: [ - Parameters.name - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.MetadataEntity }, 404: { - bodyMapper: Mappers.ARMErrorResponseBody + bodyMapper: Mappers.ARMErrorResponseBody, + isError: true }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.name], + headerParameters: [Parameters.accept], serializer }; - -const listOperationSpec: msRest.OperationSpec = { +const listOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Advisor/metadata", httpMethod: "GET", - path: "providers/Microsoft.Advisor/metadata", - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.MetadataEntityListResult }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], serializer }; - -const listNextOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - baseUrl: "https://management.azure.com", +const listNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", - urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptLanguage - ], + httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.MetadataEntityListResult }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], serializer }; diff --git a/sdk/advisor/arm-advisor/src/operations/recommendations.ts b/sdk/advisor/arm-advisor/src/operations/recommendations.ts index 8ab48e349ad8..05b7ba5e3636 100644 --- a/sdk/advisor/arm-advisor/src/operations/recommendations.ts +++ b/sdk/advisor/arm-advisor/src/operations/recommendations.ts @@ -1,295 +1,264 @@ /* - * 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/recommendationsMappers"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Recommendations } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AdvisorManagementClientContext } from "../advisorManagementClientContext"; +import { AdvisorManagementClient } from "../advisorManagementClient"; +import { + ResourceRecommendationBase, + RecommendationsListNextOptionalParams, + RecommendationsListOptionalParams, + RecommendationsGenerateOptionalParams, + RecommendationsGenerateResponse, + RecommendationsGetGenerateStatusOptionalParams, + RecommendationsListResponse, + RecommendationsGetOptionalParams, + RecommendationsGetResponse, + RecommendationsListNextResponse +} from "../models"; -/** Class representing a Recommendations. */ -export class Recommendations { - private readonly client: AdvisorManagementClientContext; +/// +/** Class containing Recommendations operations. */ +export class RecommendationsImpl implements Recommendations { + private readonly client: AdvisorManagementClient; /** - * Create a Recommendations. - * @param {AdvisorManagementClientContext} client Reference to the service client. + * Initialize a new instance of the class Recommendations class. + * @param client Reference to the service client */ - constructor(client: AdvisorManagementClientContext) { + constructor(client: AdvisorManagementClient) { this.client = client; } /** - * Initiates the recommendation generation or computation process for a subscription. This - * operation is asynchronous. The generated recommendations are stored in a cache in the Advisor - * service. - * @param [options] The optional parameters - * @returns Promise + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by + * invoking generateRecommendations. + * @param options The options parameters. */ - generate(options?: msRest.RequestOptionsBase): Promise; - /** - * @param callback The callback - */ - generate(callback: msRest.ServiceCallback): void; - /** - * @param options The optional parameters - * @param callback The callback - */ - generate(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - generate(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - options + public list( + options?: RecommendationsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; }, - generateOperationSpec, - callback) as Promise; + byPage: () => { + return this.listPagingPage(options); + } + }; + } + + private async *listPagingPage( + options?: RecommendationsListOptionalParams + ): 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?: RecommendationsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } } /** - * Retrieves the status of the recommendation computation or generation process. Invoke this API - * after calling the generation recommendation. The URI of this API is returned in the Location - * field of the response header. - * @param operationId The operation ID, which can be found from the Location field in the generate - * recommendation response header. - * @param [options] The optional parameters - * @returns Promise - */ - getGenerateStatus(operationId: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param operationId The operation ID, which can be found from the Location field in the generate - * recommendation response header. - * @param callback The callback + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * @param options The options parameters. */ - getGenerateStatus(operationId: string, callback: msRest.ServiceCallback): void; + generate( + options?: RecommendationsGenerateOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, generateOperationSpec); + } + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after + * calling the generation recommendation. The URI of this API is returned in the Location field of the + * response header. * @param operationId The operation ID, which can be found from the Location field in the generate - * recommendation response header. - * @param options The optional parameters - * @param callback The callback + * recommendation response header. + * @param options The options parameters. */ - getGenerateStatus(operationId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - getGenerateStatus(operationId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getGenerateStatus( + operationId: string, + options?: RecommendationsGetGenerateStatusOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - operationId, - options - }, - getGenerateStatusOperationSpec, - callback); + { operationId, options }, + getGenerateStatusOperationSpec + ); } /** - * Obtains cached recommendations for a subscription. The recommendations are generated or computed - * by invoking generateRecommendations. - * @param [options] The optional parameters - * @returns Promise + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by + * invoking generateRecommendations. + * @param options The options parameters. */ - list(options?: Models.RecommendationsListOptionalParams): Promise; - /** - * @param callback The callback - */ - list(callback: msRest.ServiceCallback): void; - /** - * @param options The optional parameters - * @param callback The callback - */ - list(options: Models.RecommendationsListOptionalParams, callback: msRest.ServiceCallback): void; - list(options?: Models.RecommendationsListOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - options - }, - listOperationSpec, - callback) as Promise; + private _list( + options?: RecommendationsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); } /** * Obtains details of a cached recommendation. - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which + * the recommendation applies. * @param recommendationId The recommendation ID. - * @param [options] The optional parameters - * @returns Promise + * @param options The options parameters. */ - get(resourceUri: string, recommendationId: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. - * @param recommendationId The recommendation ID. - * @param callback The callback - */ - get(resourceUri: string, recommendationId: string, callback: msRest.ServiceCallback): void; - /** - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. - * @param recommendationId The recommendation ID. - * @param options The optional parameters - * @param callback The callback - */ - get(resourceUri: string, recommendationId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - get(resourceUri: string, recommendationId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + get( + resourceUri: string, + recommendationId: string, + options?: RecommendationsGetOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - resourceUri, - recommendationId, - options - }, - getOperationSpec, - callback) as Promise; + { resourceUri, recommendationId, options }, + getOperationSpec + ); } /** - * Obtains cached recommendations for a subscription. The recommendations are generated or computed - * by invoking generateRecommendations. - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param [options] The optional parameters - * @returns Promise + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. */ - 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 { + private _listNext( + nextLink: string, + options?: RecommendationsListNextOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - nextPageLink, - options - }, - listNextOperationSpec, - callback) as Promise; + { nextLink, options }, + listNextOperationSpec + ); } } - // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const generateOperationSpec: msRest.OperationSpec = { +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const generateOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations", httpMethod: "POST", - path: "subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations", - urlParameters: [ - Parameters.subscriptionId - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 202: { headersMapper: Mappers.RecommendationsGenerateHeaders }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], serializer }; - -const getGenerateStatusOperationSpec: msRest.OperationSpec = { +const getGenerateStatusOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}", httpMethod: "GET", - path: "subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}", - urlParameters: [ - Parameters.subscriptionId, - Parameters.operationId - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 202: {}, 204: {}, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.operationId + ], + headerParameters: [Parameters.accept], serializer }; - -const listOperationSpec: msRest.OperationSpec = { +const listOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/recommendations", httpMethod: "GET", - path: "subscriptions/{subscriptionId}/providers/Microsoft.Advisor/recommendations", - urlParameters: [ - Parameters.subscriptionId - ], - queryParameters: [ - Parameters.apiVersion, - Parameters.filter, - Parameters.top, - Parameters.skipToken - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.ResourceRecommendationBaseListResult }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [ + Parameters.apiVersion, + Parameters.filter, + Parameters.top, + Parameters.skipToken + ], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], serializer }; - -const getOperationSpec: msRest.OperationSpec = { +const getOperationSpec: coreClient.OperationSpec = { + path: + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}", httpMethod: "GET", - path: "{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}", - urlParameters: [ - Parameters.resourceUri, - Parameters.recommendationId - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.ResourceRecommendationBase }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.resourceUri, + Parameters.recommendationId + ], + headerParameters: [Parameters.accept], serializer }; - -const listNextOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - baseUrl: "https://management.azure.com", +const listNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", - urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptLanguage - ], + httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ResourceRecommendationBaseListResult }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [ + Parameters.apiVersion, + Parameters.filter, + Parameters.top, + Parameters.skipToken + ], + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId + ], + headerParameters: [Parameters.accept], serializer }; diff --git a/sdk/advisor/arm-advisor/src/operations/suppressions.ts b/sdk/advisor/arm-advisor/src/operations/suppressions.ts index e0ac5c30e4b7..5482938f0c64 100644 --- a/sdk/advisor/arm-advisor/src/operations/suppressions.ts +++ b/sdk/advisor/arm-advisor/src/operations/suppressions.ts @@ -1,334 +1,296 @@ /* - * 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/suppressionsMappers"; +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Suppressions } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AdvisorManagementClientContext } from "../advisorManagementClientContext"; +import { AdvisorManagementClient } from "../advisorManagementClient"; +import { + SuppressionContract, + SuppressionsListNextOptionalParams, + SuppressionsListOptionalParams, + SuppressionsGetOptionalParams, + SuppressionsGetResponse, + SuppressionsCreateOptionalParams, + SuppressionsCreateResponse, + SuppressionsDeleteOptionalParams, + SuppressionsListResponse, + SuppressionsListNextResponse +} from "../models"; -/** Class representing a Suppressions. */ -export class Suppressions { - private readonly client: AdvisorManagementClientContext; +/// +/** Class containing Suppressions operations. */ +export class SuppressionsImpl implements Suppressions { + private readonly client: AdvisorManagementClient; /** - * Create a Suppressions. - * @param {AdvisorManagementClientContext} client Reference to the service client. + * Initialize a new instance of the class Suppressions class. + * @param client Reference to the service client */ - constructor(client: AdvisorManagementClientContext) { + constructor(client: AdvisorManagementClient) { this.client = client; } /** - * Obtains the details of a suppression. - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. - * @param recommendationId The recommendation ID. - * @param name The name of the suppression. - * @param [options] The optional parameters - * @returns Promise - */ - get(resourceUri: string, recommendationId: string, name: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. - * @param recommendationId The recommendation ID. - * @param name The name of the suppression. - * @param callback The callback - */ - get(resourceUri: string, recommendationId: string, name: string, callback: msRest.ServiceCallback): void; - /** - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. - * @param recommendationId The recommendation ID. - * @param name The name of the suppression. - * @param options The optional parameters - * @param callback The callback + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed + * attribute of a recommendation is referred to as a suppression. + * @param options The options parameters. */ - get(resourceUri: string, recommendationId: string, name: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - get(resourceUri: string, recommendationId: string, name: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - resourceUri, - recommendationId, - name, - options + public list( + options?: SuppressionsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; }, - getOperationSpec, - callback) as Promise; + byPage: () => { + return this.listPagingPage(options); + } + }; + } + + private async *listPagingPage( + options?: SuppressionsListOptionalParams + ): 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?: SuppressionsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } } /** - * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed - * attribute is referred to as a suppression. Use this API to create or update the snoozed or - * dismissed status of a recommendation. - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. - * @param recommendationId The recommendation ID. - * @param name The name of the suppression. - * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. - * @param [options] The optional parameters - * @returns Promise - */ - create(resourceUri: string, recommendationId: string, name: string, suppressionContract: Models.SuppressionContract, options?: msRest.RequestOptionsBase): Promise; - /** - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. + * Obtains the details of a suppression. + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which + * the recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. - * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. - * @param callback The callback + * @param options The options parameters. */ - create(resourceUri: string, recommendationId: string, name: string, suppressionContract: Models.SuppressionContract, callback: msRest.ServiceCallback): void; + get( + resourceUri: string, + recommendationId: string, + name: string, + options?: SuppressionsGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceUri, recommendationId, name, options }, + getOperationSpec + ); + } + /** - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute + * is referred to as a suppression. Use this API to create or update the snoozed or dismissed status of + * a recommendation. + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which + * the recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. - * @param options The optional parameters - * @param callback The callback + * @param options The options parameters. */ - create(resourceUri: string, recommendationId: string, name: string, suppressionContract: Models.SuppressionContract, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - create(resourceUri: string, recommendationId: string, name: string, suppressionContract: Models.SuppressionContract, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + create( + resourceUri: string, + recommendationId: string, + name: string, + suppressionContract: SuppressionContract, + options?: SuppressionsCreateOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - resourceUri, - recommendationId, - name, - suppressionContract, - options - }, - createOperationSpec, - callback) as Promise; + { resourceUri, recommendationId, name, suppressionContract, options }, + createOperationSpec + ); } /** - * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed - * attribute of a recommendation is referred to as a suppression. - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. - * @param recommendationId The recommendation ID. - * @param name The name of the suppression. - * @param [options] The optional parameters - * @returns Promise - */ - deleteMethod(resourceUri: string, recommendationId: string, name: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute + * of a recommendation is referred to as a suppression. + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which + * the recommendation applies. * @param recommendationId The recommendation ID. * @param name The name of the suppression. - * @param callback The callback + * @param options The options parameters. */ - deleteMethod(resourceUri: string, recommendationId: string, name: string, callback: msRest.ServiceCallback): void; - /** - * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to - * which the recommendation applies. - * @param recommendationId The recommendation ID. - * @param name The name of the suppression. - * @param options The optional parameters - * @param callback The callback - */ - deleteMethod(resourceUri: string, recommendationId: string, name: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - deleteMethod(resourceUri: string, recommendationId: string, name: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + delete( + resourceUri: string, + recommendationId: string, + name: string, + options?: SuppressionsDeleteOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - resourceUri, - recommendationId, - name, - options - }, - deleteMethodOperationSpec, - callback); + { resourceUri, recommendationId, name, options }, + deleteOperationSpec + ); } /** - * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or - * dismissed attribute of a recommendation is referred to as a suppression. - * @param [options] The optional parameters - * @returns Promise - */ - list(options?: Models.SuppressionsListOptionalParams): Promise; - /** - * @param callback The callback - */ - list(callback: msRest.ServiceCallback): void; - /** - * @param options The optional parameters - * @param callback The callback + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed + * attribute of a recommendation is referred to as a suppression. + * @param options The options parameters. */ - list(options: Models.SuppressionsListOptionalParams, callback: msRest.ServiceCallback): void; - list(options?: Models.SuppressionsListOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - options - }, - listOperationSpec, - callback) as Promise; + private _list( + options?: SuppressionsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); } /** - * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or - * dismissed attribute of a recommendation is referred to as a suppression. - * @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 + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. */ - listNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - listNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + private _listNext( + nextLink: string, + options?: SuppressionsListNextOptionalParams + ): Promise { return this.client.sendOperationRequest( - { - nextPageLink, - options - }, - listNextOperationSpec, - callback) as Promise; + { nextLink, options }, + listNextOperationSpec + ); } } - // Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const getOperationSpec: msRest.OperationSpec = { +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const getOperationSpec: coreClient.OperationSpec = { + path: + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", httpMethod: "GET", - path: "{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", - urlParameters: [ - Parameters.resourceUri, - Parameters.recommendationId, - Parameters.name - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.SuppressionContract }, + 404: { + bodyMapper: Mappers.ArmErrorResponse, + isError: true + }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, - serializer -}; - -const createOperationSpec: msRest.OperationSpec = { - httpMethod: "PUT", - path: "{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + queryParameters: [Parameters.apiVersion], urlParameters: [ + Parameters.$host, + Parameters.name, Parameters.resourceUri, - Parameters.recommendationId, - Parameters.name + Parameters.recommendationId ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage - ], - requestBody: { - parameterPath: "suppressionContract", - mapper: { - ...Mappers.SuppressionContract, - required: true - } - }, + headerParameters: [Parameters.accept], + serializer +}; +const createOperationSpec: coreClient.OperationSpec = { + path: + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.SuppressionContract }, + 404: { + bodyMapper: Mappers.ArmErrorResponse, + isError: true + }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, - serializer -}; - -const deleteMethodOperationSpec: msRest.OperationSpec = { - httpMethod: "DELETE", - path: "{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + requestBody: Parameters.suppressionContract, + queryParameters: [Parameters.apiVersion], urlParameters: [ + Parameters.$host, + Parameters.name, Parameters.resourceUri, - Parameters.recommendationId, - Parameters.name - ], - queryParameters: [ - Parameters.apiVersion - ], - headerParameters: [ - Parameters.acceptLanguage + Parameters.recommendationId ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const deleteOperationSpec: coreClient.OperationSpec = { + path: + "/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}", + httpMethod: "DELETE", responses: { 204: {}, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.name, + Parameters.resourceUri, + Parameters.recommendationId + ], + headerParameters: [Parameters.accept], serializer }; - -const listOperationSpec: msRest.OperationSpec = { +const listOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/suppressions", httpMethod: "GET", - path: "subscriptions/{subscriptionId}/providers/Microsoft.Advisor/suppressions", - urlParameters: [ - Parameters.subscriptionId - ], - queryParameters: [ - Parameters.apiVersion, - Parameters.top, - Parameters.skipToken - ], - headerParameters: [ - Parameters.acceptLanguage - ], responses: { 200: { bodyMapper: Mappers.SuppressionContractListResult }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [ + Parameters.apiVersion, + Parameters.top, + Parameters.skipToken + ], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], serializer }; - -const listNextOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - baseUrl: "https://management.azure.com", +const listNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", - urlParameters: [ - Parameters.nextPageLink - ], - headerParameters: [ - Parameters.acceptLanguage - ], + httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.SuppressionContractListResult }, default: { - bodyMapper: Mappers.CloudError + bodyMapper: Mappers.ArmErrorResponse } }, + queryParameters: [ + Parameters.apiVersion, + Parameters.top, + Parameters.skipToken + ], + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId + ], + headerParameters: [Parameters.accept], serializer }; diff --git a/sdk/advisor/arm-advisor/src/operationsInterfaces/configurations.ts b/sdk/advisor/arm-advisor/src/operationsInterfaces/configurations.ts new file mode 100644 index 000000000000..6348b04fa796 --- /dev/null +++ b/sdk/advisor/arm-advisor/src/operationsInterfaces/configurations.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 { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + ConfigData, + ConfigurationsListBySubscriptionOptionalParams, + ConfigurationsListByResourceGroupOptionalParams, + ConfigurationName, + ConfigurationsCreateInSubscriptionOptionalParams, + ConfigurationsCreateInSubscriptionResponse, + ConfigurationsCreateInResourceGroupOptionalParams, + ConfigurationsCreateInResourceGroupResponse +} from "../models"; + +/// +/** Interface representing a Configurations. */ +export interface Configurations { + /** + * Retrieve Azure Advisor configurations and also retrieve configurations of contained resource groups. + * @param options The options parameters. + */ + listBySubscription( + options?: ConfigurationsListBySubscriptionOptionalParams + ): PagedAsyncIterableIterator; + /** + * Retrieve Azure Advisor configurations. + * @param resourceGroup The name of the Azure resource group. + * @param options The options parameters. + */ + listByResourceGroup( + resourceGroup: string, + options?: ConfigurationsListByResourceGroupOptionalParams + ): PagedAsyncIterableIterator; + /** + * Create/Overwrite Azure Advisor configuration and also delete all configurations of contained + * resource groups. + * @param configurationName Advisor configuration name. Value must be 'default' + * @param configContract The Azure Advisor configuration data structure. + * @param options The options parameters. + */ + createInSubscription( + configurationName: ConfigurationName, + configContract: ConfigData, + options?: ConfigurationsCreateInSubscriptionOptionalParams + ): Promise; + /** + * Create/Overwrite Azure Advisor configuration. + * @param configurationName Advisor configuration name. Value must be 'default' + * @param resourceGroup The name of the Azure resource group. + * @param configContract The Azure Advisor configuration data structure. + * @param options The options parameters. + */ + createInResourceGroup( + configurationName: ConfigurationName, + resourceGroup: string, + configContract: ConfigData, + options?: ConfigurationsCreateInResourceGroupOptionalParams + ): Promise; +} diff --git a/sdk/advisor/arm-advisor/src/operationsInterfaces/index.ts b/sdk/advisor/arm-advisor/src/operationsInterfaces/index.ts new file mode 100644 index 000000000000..9bb829013597 --- /dev/null +++ b/sdk/advisor/arm-advisor/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 "./recommendationMetadata"; +export * from "./configurations"; +export * from "./recommendations"; +export * from "./operations"; +export * from "./suppressions"; diff --git a/sdk/advisor/arm-advisor/src/operationsInterfaces/operations.ts b/sdk/advisor/arm-advisor/src/operationsInterfaces/operations.ts new file mode 100644 index 000000000000..fc17cdc3730d --- /dev/null +++ b/sdk/advisor/arm-advisor/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 { OperationEntity, OperationsListOptionalParams } from "../models"; + +/// +/** Interface representing a Operations. */ +export interface Operations { + /** + * Lists all the available Advisor REST API operations. + * @param options The options parameters. + */ + list( + options?: OperationsListOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/advisor/arm-advisor/src/operationsInterfaces/recommendationMetadata.ts b/sdk/advisor/arm-advisor/src/operationsInterfaces/recommendationMetadata.ts new file mode 100644 index 000000000000..25f10223c816 --- /dev/null +++ b/sdk/advisor/arm-advisor/src/operationsInterfaces/recommendationMetadata.ts @@ -0,0 +1,36 @@ +/* + * 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 { + MetadataEntity, + RecommendationMetadataListOptionalParams, + RecommendationMetadataGetOptionalParams, + RecommendationMetadataGetResponse +} from "../models"; + +/// +/** Interface representing a RecommendationMetadata. */ +export interface RecommendationMetadata { + /** + * Gets the list of metadata entities. + * @param options The options parameters. + */ + list( + options?: RecommendationMetadataListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Gets the metadata entity. + * @param name Name of metadata entity. + * @param options The options parameters. + */ + get( + name: string, + options?: RecommendationMetadataGetOptionalParams + ): Promise; +} diff --git a/sdk/advisor/arm-advisor/src/operationsInterfaces/recommendations.ts b/sdk/advisor/arm-advisor/src/operationsInterfaces/recommendations.ts new file mode 100644 index 000000000000..6a3311d189d0 --- /dev/null +++ b/sdk/advisor/arm-advisor/src/operationsInterfaces/recommendations.ts @@ -0,0 +1,63 @@ +/* + * 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 { + ResourceRecommendationBase, + RecommendationsListOptionalParams, + RecommendationsGenerateOptionalParams, + RecommendationsGenerateResponse, + RecommendationsGetGenerateStatusOptionalParams, + RecommendationsGetOptionalParams, + RecommendationsGetResponse +} from "../models"; + +/// +/** Interface representing a Recommendations. */ +export interface Recommendations { + /** + * Obtains cached recommendations for a subscription. The recommendations are generated or computed by + * invoking generateRecommendations. + * @param options The options parameters. + */ + list( + options?: RecommendationsListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Initiates the recommendation generation or computation process for a subscription. This operation is + * asynchronous. The generated recommendations are stored in a cache in the Advisor service. + * @param options The options parameters. + */ + generate( + options?: RecommendationsGenerateOptionalParams + ): Promise; + /** + * Retrieves the status of the recommendation computation or generation process. Invoke this API after + * calling the generation recommendation. The URI of this API is returned in the Location field of the + * response header. + * @param operationId The operation ID, which can be found from the Location field in the generate + * recommendation response header. + * @param options The options parameters. + */ + getGenerateStatus( + operationId: string, + options?: RecommendationsGetGenerateStatusOptionalParams + ): Promise; + /** + * Obtains details of a cached recommendation. + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which + * the recommendation applies. + * @param recommendationId The recommendation ID. + * @param options The options parameters. + */ + get( + resourceUri: string, + recommendationId: string, + options?: RecommendationsGetOptionalParams + ): Promise; +} diff --git a/sdk/advisor/arm-advisor/src/operationsInterfaces/suppressions.ts b/sdk/advisor/arm-advisor/src/operationsInterfaces/suppressions.ts new file mode 100644 index 000000000000..f2f0bae319d1 --- /dev/null +++ b/sdk/advisor/arm-advisor/src/operationsInterfaces/suppressions.ts @@ -0,0 +1,78 @@ +/* + * 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 { + SuppressionContract, + SuppressionsListOptionalParams, + SuppressionsGetOptionalParams, + SuppressionsGetResponse, + SuppressionsCreateOptionalParams, + SuppressionsCreateResponse, + SuppressionsDeleteOptionalParams +} from "../models"; + +/// +/** Interface representing a Suppressions. */ +export interface Suppressions { + /** + * Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed + * attribute of a recommendation is referred to as a suppression. + * @param options The options parameters. + */ + list( + options?: SuppressionsListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Obtains the details of a suppression. + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which + * the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param options The options parameters. + */ + get( + resourceUri: string, + recommendationId: string, + name: string, + options?: SuppressionsGetOptionalParams + ): Promise; + /** + * Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute + * is referred to as a suppression. Use this API to create or update the snoozed or dismissed status of + * a recommendation. + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which + * the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param suppressionContract The snoozed or dismissed attribute; for example, the snooze duration. + * @param options The options parameters. + */ + create( + resourceUri: string, + recommendationId: string, + name: string, + suppressionContract: SuppressionContract, + options?: SuppressionsCreateOptionalParams + ): Promise; + /** + * Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute + * of a recommendation is referred to as a suppression. + * @param resourceUri The fully qualified Azure Resource Manager identifier of the resource to which + * the recommendation applies. + * @param recommendationId The recommendation ID. + * @param name The name of the suppression. + * @param options The options parameters. + */ + delete( + resourceUri: string, + recommendationId: string, + name: string, + options?: SuppressionsDeleteOptionalParams + ): Promise; +} diff --git a/sdk/advisor/arm-advisor/test/sampleTest.ts b/sdk/advisor/arm-advisor/test/sampleTest.ts new file mode 100644 index 000000000000..7ed89b043e1b --- /dev/null +++ b/sdk/advisor/arm-advisor/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/advisor/arm-advisor/tsconfig.json b/sdk/advisor/arm-advisor/tsconfig.json index 422b584abd5e..6e3251194117 100644 --- a/sdk/advisor/arm-advisor/tsconfig.json +++ b/sdk/advisor/arm-advisor/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/advisor/ci.yml b/sdk/advisor/ci.yml new file mode 100644 index 000000000000..556451ec270c --- /dev/null +++ b/sdk/advisor/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/advisor/ + +pr: + branches: + include: + - main + - release/* + - hotfix/* + paths: + include: + - sdk/advisor/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: advisor + Artifacts: + - name: azure-arm-advisor + safeName: azurearmadvisor + \ No newline at end of file