From cf242bf3a0ca76ed19ecbb1b808583e15647445b Mon Sep 17 00:00:00 2001 From: colawwj Date: Tue, 28 Sep 2021 17:31:35 +0800 Subject: [PATCH 1/2] quota-track2 --- common/config/rush/pnpm-lock.yaml | 26 + eng/ignore-links.txt | 2 + rush.json | 5 + sdk/quota/arm-quota/CHANGELOG.md | 3 + sdk/quota/arm-quota/LICENSE | 21 + sdk/quota/arm-quota/README.md | 94 ++ sdk/quota/arm-quota/_meta.json | 7 + sdk/quota/arm-quota/api-extractor.json | 18 + sdk/quota/arm-quota/package.json | 92 ++ sdk/quota/arm-quota/review/arm-quota.api.md | 474 +++++++ sdk/quota/arm-quota/rollup.config.js | 188 +++ .../arm-quota/src/azureQuotaExtensionAPI.ts | 46 + .../src/azureQuotaExtensionAPIContext.ts | 62 + sdk/quota/arm-quota/src/index.ts | 13 + sdk/quota/arm-quota/src/lroImpl.ts | 34 + sdk/quota/arm-quota/src/models/index.ts | 736 +++++++++++ sdk/quota/arm-quota/src/models/mappers.ts | 1128 +++++++++++++++++ sdk/quota/arm-quota/src/models/parameters.ts | 146 +++ sdk/quota/arm-quota/src/operations/index.ts | 12 + .../arm-quota/src/operations/operation.ts | 137 ++ sdk/quota/arm-quota/src/operations/quota.ts | 497 ++++++++ .../src/operations/quotaRequestStatus.ts | 213 ++++ sdk/quota/arm-quota/src/operations/usages.ts | 205 +++ .../src/operationsInterfaces/index.ts | 12 + .../src/operationsInterfaces/operation.ts | 22 + .../src/operationsInterfaces/quota.ts | 167 +++ .../quotaRequestStatus.ts | 51 + .../src/operationsInterfaces/usages.ts | 51 + sdk/quota/arm-quota/test/sampleTest.ts | 48 + sdk/quota/arm-quota/tsconfig.json | 19 + sdk/quota/ci.yml | 29 + 31 files changed, 4558 insertions(+) create mode 100644 sdk/quota/arm-quota/CHANGELOG.md create mode 100644 sdk/quota/arm-quota/LICENSE create mode 100644 sdk/quota/arm-quota/README.md create mode 100644 sdk/quota/arm-quota/_meta.json create mode 100644 sdk/quota/arm-quota/api-extractor.json create mode 100644 sdk/quota/arm-quota/package.json create mode 100644 sdk/quota/arm-quota/review/arm-quota.api.md create mode 100644 sdk/quota/arm-quota/rollup.config.js create mode 100644 sdk/quota/arm-quota/src/azureQuotaExtensionAPI.ts create mode 100644 sdk/quota/arm-quota/src/azureQuotaExtensionAPIContext.ts create mode 100644 sdk/quota/arm-quota/src/index.ts create mode 100644 sdk/quota/arm-quota/src/lroImpl.ts create mode 100644 sdk/quota/arm-quota/src/models/index.ts create mode 100644 sdk/quota/arm-quota/src/models/mappers.ts create mode 100644 sdk/quota/arm-quota/src/models/parameters.ts create mode 100644 sdk/quota/arm-quota/src/operations/index.ts create mode 100644 sdk/quota/arm-quota/src/operations/operation.ts create mode 100644 sdk/quota/arm-quota/src/operations/quota.ts create mode 100644 sdk/quota/arm-quota/src/operations/quotaRequestStatus.ts create mode 100644 sdk/quota/arm-quota/src/operations/usages.ts create mode 100644 sdk/quota/arm-quota/src/operationsInterfaces/index.ts create mode 100644 sdk/quota/arm-quota/src/operationsInterfaces/operation.ts create mode 100644 sdk/quota/arm-quota/src/operationsInterfaces/quota.ts create mode 100644 sdk/quota/arm-quota/src/operationsInterfaces/quotaRequestStatus.ts create mode 100644 sdk/quota/arm-quota/src/operationsInterfaces/usages.ts create mode 100644 sdk/quota/arm-quota/test/sampleTest.ts create mode 100644 sdk/quota/arm-quota/tsconfig.json create mode 100644 sdk/quota/ci.yml diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 213867055c6e..dcd00e7b85ef 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -23,6 +23,7 @@ specifiers: '@rush-temp/arm-network': file:./projects/arm-network.tgz '@rush-temp/arm-policy': file:./projects/arm-policy.tgz '@rush-temp/arm-purview': file:./projects/arm-purview.tgz + '@rush-temp/arm-quota': file:./projects/arm-quota.tgz '@rush-temp/arm-rediscache': file:./projects/arm-rediscache.tgz '@rush-temp/arm-resources': file:./projects/arm-resources.tgz '@rush-temp/arm-resources-subscriptions': file:./projects/arm-resources-subscriptions.tgz @@ -151,6 +152,7 @@ dependencies: '@rush-temp/arm-network': file:projects/arm-network.tgz '@rush-temp/arm-policy': file:projects/arm-policy.tgz '@rush-temp/arm-purview': file:projects/arm-purview.tgz + '@rush-temp/arm-quota': file:projects/arm-quota.tgz '@rush-temp/arm-rediscache': file:projects/arm-rediscache.tgz '@rush-temp/arm-resources': file:projects/arm-resources.tgz '@rush-temp/arm-resources-subscriptions': file:projects/arm-resources-subscriptions.tgz @@ -8708,6 +8710,30 @@ packages: uglify-js: 3.14.2 dev: false + file:projects/arm-quota.tgz: + resolution: {integrity: sha512-SRpBEql0y3kdYMhc1tEuEKjQuLnvAhhXyH46MA6wynnJ6G7nPX886kGcTsUFlENVZ3rN3aT7CFmSlX8ytYg8hw==, tarball: file:projects/arm-quota.tgz} + name: '@rush-temp/arm-quota' + version: 0.0.0 + dependencies: + '@azure/identity': 2.0.0-beta.6 + '@microsoft/api-extractor': 7.7.11 + '@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 + 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.2 + transitivePeerDependencies: + - debug + - supports-color + dev: false + file:projects/arm-rediscache.tgz: resolution: {integrity: sha512-vz7HvSxGxgPV2+zCKE1wL04XxeVFUhpqKkRbcvxlSSZJe3uCJSr3iqt9YqGM0SaV84IV3lv0MCrIeyOm1DX3bQ==, tarball: file:projects/arm-rediscache.tgz} name: '@rush-temp/arm-rediscache' diff --git a/eng/ignore-links.txt b/eng/ignore-links.txt index 90e33914775b..d2c9c8adb403 100644 --- a/eng/ignore-links.txt +++ b/eng/ignore-links.txt @@ -10,3 +10,5 @@ https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/storage-blob-cha https://github.com/Azure/azure-digital-twins/blob/private-preview/Documentation/how-to-manage-routes.md https://docs.microsoft.com/javascript/api/@azure/arm-purview https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/purview/arm-purview +https://docs.microsoft.com/javascript/api/@azure/arm-quota +https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/quota/arm-quota diff --git a/rush.json b/rush.json index 38e447589ca5..b00734c73228 100644 --- a/rush.json +++ b/rush.json @@ -950,6 +950,11 @@ "packageName": "@azure/arm-eventgrid", "projectFolder": "sdk/eventgrid/arm-eventgrid", "versionPolicyName": "management" + }, + { + "packageName": "@azure/arm-quota", + "projectFolder": "sdk/quota/arm-quota", + "versionPolicyName": "management" } ] } \ No newline at end of file diff --git a/sdk/quota/arm-quota/CHANGELOG.md b/sdk/quota/arm-quota/CHANGELOG.md new file mode 100644 index 000000000000..8dfa750aaba1 --- /dev/null +++ b/sdk/quota/arm-quota/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0-beta.1 (2021-09-28) + + - Initial Release diff --git a/sdk/quota/arm-quota/LICENSE b/sdk/quota/arm-quota/LICENSE new file mode 100644 index 000000000000..ccb63b166732 --- /dev/null +++ b/sdk/quota/arm-quota/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/quota/arm-quota/README.md b/sdk/quota/arm-quota/README.md new file mode 100644 index 000000000000..55eb603c2e18 --- /dev/null +++ b/sdk/quota/arm-quota/README.md @@ -0,0 +1,94 @@ +# Azure Service client library for JavaScript + +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure Service client. + +Microsoft Azure Quota Resource Provider + +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/quota/arm-quota) | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-quota) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-quota) | +[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. + +### Prerequisites + +- An [Azure subscription][azure_sub]. + +### Install the `@azure/arm-quota` package + +Install the Azure Service client library for JavaScript with `npm`: + +```bash +npm install @azure/arm-quota +``` + +### Create and authenticate a `AzureQuotaExtensionAPI` + +To create a client object to access the Azure Service API, you will need the `endpoint` of your Azure Service resource and a `credential`. The Azure Service client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure Service resource in the [Azure Portal][azure_portal]. + +You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). + +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 +``` + +You will also need to **register a new AAD application and grant access to Azure Service** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. + +For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). + +```javascript +const { AzureQuotaExtensionAPI } = require("@azure/arm-quota"); +const { DefaultAzureCredential } = require("@azure/identity"); +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new AzureQuotaExtensionAPI(new DefaultAzureCredential(), subscriptionId); +``` + +## Key concepts + +### AzureQuotaExtensionAPI + +`AzureQuotaExtensionAPI` is the primary interface for developers using the Azure Service client library. Explore the methods on this client object to understand the different features of the Azure Service 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) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fquota%2Farm-quota%2FREADME.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/quota/arm-quota/_meta.json b/sdk/quota/arm-quota/_meta.json new file mode 100644 index 000000000000..494149f8fe57 --- /dev/null +++ b/sdk/quota/arm-quota/_meta.json @@ -0,0 +1,7 @@ +{ + "commit": "a8e6d89a08f7b872be9da82b735274bc84199e8e", + "readme": "specification/quota/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=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/quota/resource-manager/readme.md --use=@autorest/typescript@6.0.0-beta.13", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "use": "@autorest/typescript@6.0.0-beta.13" +} \ No newline at end of file diff --git a/sdk/quota/arm-quota/api-extractor.json b/sdk/quota/arm-quota/api-extractor.json new file mode 100644 index 000000000000..38aa609451c2 --- /dev/null +++ b/sdk/quota/arm-quota/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-quota.d.ts" + }, + "messages": { + "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "extractorMessageReporting": { + "ae-missing-release-tag": { "logLevel": "none" }, + "ae-unresolved-link": { "logLevel": "none" } + } + } +} diff --git a/sdk/quota/arm-quota/package.json b/sdk/quota/arm-quota/package.json new file mode 100644 index 000000000000..766bd6f22a39 --- /dev/null +++ b/sdk/quota/arm-quota/package.json @@ -0,0 +1,92 @@ +{ + "name": "@azure/arm-quota", + "sdk-type": "mgmt", + "author": "Microsoft Corporation", + "description": "A generated SDK for AzureQuotaExtensionAPI.", + "version": "1.0.0-beta.1", + "engines": { "node": ">=12.0.0" }, + "dependencies": { + "@azure/core-lro": "^2.2.0", + "@azure/abort-controller": "^1.0.0", + "@azure/core-paging": "^1.1.1", + "@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"], + "license": "MIT", + "main": "./dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/arm-quota.d.ts", + "devDependencies": { + "@microsoft/api-extractor": "7.7.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", + "typescript": "~4.2.0", + "uglify-js": "^3.4.9", + "@azure/identity": "2.0.0-beta.6", + "@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/quota/arm-quota", + "repository": { + "type": "git", + "url": "https://github.com/Azure/azure-sdk-for-js.git" + }, + "bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, + "files": [ + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.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", + "review/*", + "CHANGELOG.md", + "types/*" + ], + "scripts": { + "build": "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": "echo skipped", + "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", + "prebuild": "echo skipped", + "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", + "integration-test:browser": "echo skipped", + "docs": "echo skipped" + }, + "sideEffects": false, + "autoPublish": true +} diff --git a/sdk/quota/arm-quota/review/arm-quota.api.md b/sdk/quota/arm-quota/review/arm-quota.api.md new file mode 100644 index 000000000000..193694b98d54 --- /dev/null +++ b/sdk/quota/arm-quota/review/arm-quota.api.md @@ -0,0 +1,474 @@ +## API Report File for "@azure/arm-quota" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import * as coreAuth from '@azure/core-auth'; +import * as coreClient from '@azure/core-client'; +import { PagedAsyncIterableIterator } from '@azure/core-paging'; +import { PollerLike } from '@azure/core-lro'; +import { PollOperationState } from '@azure/core-lro'; + +// @public (undocumented) +export class AzureQuotaExtensionAPI extends AzureQuotaExtensionAPIContext { + constructor(credentials: coreAuth.TokenCredential, options?: AzureQuotaExtensionAPIOptionalParams); + // (undocumented) + operation: Operation; + // (undocumented) + quota: Quota; + // (undocumented) + quotaRequestStatus: QuotaRequestStatus; + // (undocumented) + usages: Usages; +} + +// @public (undocumented) +export class AzureQuotaExtensionAPIContext extends coreClient.ServiceClient { + // (undocumented) + $host: string; + constructor(credentials: coreAuth.TokenCredential, options?: AzureQuotaExtensionAPIOptionalParams); + // (undocumented) + apiVersion: string; +} + +// @public +export interface AzureQuotaExtensionAPIOptionalParams extends coreClient.ServiceClientOptions { + $host?: string; + apiVersion?: string; + endpoint?: string; +} + +// @public +export interface CommonResourceProperties { + readonly id?: string; + readonly name?: string; + readonly type?: string; +} + +// @public +export interface CreateGenericQuotaRequestParameters { + value?: CurrentQuotaLimitBase[]; +} + +// @public +export interface CurrentQuotaLimitBase { + readonly id?: string; + readonly name?: string; + properties?: QuotaProperties; + readonly type?: string; +} + +// @public +export interface CurrentUsagesBase { + readonly id?: string; + readonly name?: string; + properties?: UsagesProperties; + readonly type?: string; +} + +// @public +export interface ExceptionResponse { + error?: ServiceError; +} + +// @public +export enum KnownLimitType { + // (undocumented) + LimitValue = "LimitValue" +} + +// @public +export enum KnownQuotaLimitTypes { + // (undocumented) + Independent = "Independent", + // (undocumented) + Shared = "Shared" +} + +// @public +export enum KnownQuotaRequestState { + // (undocumented) + Accepted = "Accepted", + // (undocumented) + Failed = "Failed", + // (undocumented) + InProgress = "InProgress", + // (undocumented) + Invalid = "Invalid", + // (undocumented) + Succeeded = "Succeeded" +} + +// @public +export enum KnownUsagesTypes { + // (undocumented) + Combined = "Combined", + // (undocumented) + Individual = "Individual" +} + +// @public +export interface LimitJsonObject { + limitObjectType: "LimitValue"; +} + +// @public (undocumented) +export type LimitJsonObjectUnion = LimitJsonObject | LimitValue; + +// @public +export interface LimitObject { + limitObjectType?: LimitType; + limitType?: QuotaLimitTypes; + value: number; +} + +// @public +export type LimitType = string; + +// @public +export type LimitValue = LimitJsonObject & LimitObject & { + limitObjectType: "LimitValue"; +}; + +// @public +export interface Operation { + list(options?: OperationListOptionalParams): PagedAsyncIterableIterator; +} + +// @public (undocumented) +export interface OperationDisplay { + description?: string; + operation?: string; + provider?: string; + resource?: string; +} + +// @public (undocumented) +export interface OperationList { + nextLink?: string; + // (undocumented) + value?: OperationResponse[]; +} + +// @public +export interface OperationListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationListNextResponse = OperationList; + +// @public +export interface OperationListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type OperationListResponse = OperationList; + +// @public (undocumented) +export interface OperationResponse { + // (undocumented) + display?: OperationDisplay; + // (undocumented) + name?: string; + // (undocumented) + origin?: string; +} + +// @public +export interface Quota { + beginCreateOrUpdate(resourceName: string, scope: string, createQuotaRequest: CurrentQuotaLimitBase, options?: QuotaCreateOrUpdateOptionalParams): Promise, QuotaCreateOrUpdateResponse>>; + beginCreateOrUpdateAndWait(resourceName: string, scope: string, createQuotaRequest: CurrentQuotaLimitBase, options?: QuotaCreateOrUpdateOptionalParams): Promise; + beginUpdate(resourceName: string, scope: string, createQuotaRequest: CurrentQuotaLimitBase, options?: QuotaUpdateOptionalParams): Promise, QuotaUpdateResponse>>; + beginUpdateAndWait(resourceName: string, scope: string, createQuotaRequest: CurrentQuotaLimitBase, options?: QuotaUpdateOptionalParams): Promise; + get(resourceName: string, scope: string, options?: QuotaGetOptionalParams): Promise; + list(scope: string, options?: QuotaListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface QuotaCreateOrUpdateOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type QuotaCreateOrUpdateResponse = CurrentQuotaLimitBase; + +// @public +export interface QuotaGetHeaders { + eTag?: string; +} + +// @public +export interface QuotaGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type QuotaGetResponse = QuotaGetHeaders & CurrentQuotaLimitBase; + +// @public +export interface QuotaLimits { + nextLink?: string; + value?: CurrentQuotaLimitBase[]; +} + +// @public +export interface QuotaLimitsResponse { + nextLink?: string; + value?: CurrentQuotaLimitBase[]; +} + +// @public +export type QuotaLimitTypes = string; + +// @public +export interface QuotaListHeaders { + eTag?: string; +} + +// @public +export interface QuotaListNextHeaders { + eTag?: string; +} + +// @public +export interface QuotaListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type QuotaListNextResponse = QuotaListNextHeaders & QuotaLimits; + +// @public +export interface QuotaListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type QuotaListResponse = QuotaListHeaders & QuotaLimits; + +// @public +export interface QuotaProperties { + readonly isQuotaApplicable?: boolean; + limit?: LimitJsonObjectUnion; + name?: ResourceName; + properties?: Record; + readonly quotaPeriod?: string; + resourceType?: string; + readonly unit?: string; +} + +// @public +export interface QuotaRequestDetails { + error?: ServiceErrorDetail; + readonly id?: string; + readonly message?: string; + readonly name?: string; + readonly provisioningState?: QuotaRequestState; + readonly requestSubmitTime?: Date; + readonly type?: string; + value?: SubRequest[]; +} + +// @public +export interface QuotaRequestDetailsList { + nextLink?: string; + value?: QuotaRequestDetails[]; +} + +// @public +export interface QuotaRequestOneResourceSubmitResponse { + readonly currentValue?: number; + error?: ServiceErrorDetail; + readonly id?: string; + readonly isQuotaApplicable?: boolean; + limit?: LimitObject; + readonly message?: string; + readonly name?: string; + namePropertiesName?: ResourceName; + properties?: Record; + readonly provisioningState?: QuotaRequestState; + readonly quotaPeriod?: string; + readonly requestSubmitTime?: Date; + resourceType?: string; + readonly type?: string; + unit?: string; +} + +// @public +export interface QuotaRequestProperties { + error?: ServiceErrorDetail; + readonly message?: string; + readonly provisioningState?: QuotaRequestState; + readonly requestSubmitTime?: Date; + value?: SubRequest[]; +} + +// @public +export type QuotaRequestState = string; + +// @public +export interface QuotaRequestStatus { + get(id: string, scope: string, options?: QuotaRequestStatusGetOptionalParams): Promise; + list(scope: string, options?: QuotaRequestStatusListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface QuotaRequestStatusGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type QuotaRequestStatusGetResponse = QuotaRequestDetails; + +// @public +export interface QuotaRequestStatusListNextOptionalParams extends coreClient.OperationOptions { + filter?: string; + skiptoken?: string; + top?: number; +} + +// @public +export type QuotaRequestStatusListNextResponse = QuotaRequestDetailsList; + +// @public +export interface QuotaRequestStatusListOptionalParams extends coreClient.OperationOptions { + filter?: string; + skiptoken?: string; + top?: number; +} + +// @public +export type QuotaRequestStatusListResponse = QuotaRequestDetailsList; + +// @public +export interface QuotaRequestSubmitResponse { + readonly id?: string; + readonly name?: string; + properties?: QuotaRequestProperties; + readonly type?: string; +} + +// @public +export interface QuotaRequestSubmitResponse202 { + readonly id?: string; + limit?: LimitObject; + readonly message?: string; + readonly name?: string; + namePropertiesName?: ResourceName; + properties?: Record; + readonly provisioningState?: QuotaRequestState; + readonly quotaPeriod?: string; + resourceType?: string; + readonly type?: string; + unit?: string; +} + +// @public +export interface QuotaUpdateOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type QuotaUpdateResponse = CurrentQuotaLimitBase; + +// @public +export interface ResourceName { + readonly localizedValue?: string; + value?: string; +} + +// @public +export interface ServiceError { + code?: string; + readonly details?: ServiceErrorDetail[]; + message?: string; +} + +// @public +export interface ServiceErrorDetail { + readonly code?: string; + readonly message?: string; +} + +// @public +export interface SubRequest { + limit?: LimitJsonObjectUnion; + readonly message?: string; + name?: ResourceName; + readonly provisioningState?: QuotaRequestState; + readonly resourceType?: string; + readonly subRequestId?: string; + unit?: string; +} + +// @public +export interface Usages { + get(resourceName: string, scope: string, options?: UsagesGetOptionalParams): Promise; + list(scope: string, options?: UsagesListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface UsagesGetHeaders { + eTag?: string; +} + +// @public +export interface UsagesGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type UsagesGetResponse = UsagesGetHeaders & CurrentUsagesBase; + +// @public +export interface UsagesLimits { + nextLink?: string; + value?: CurrentUsagesBase[]; +} + +// @public +export interface UsagesListHeaders { + eTag?: string; +} + +// @public +export interface UsagesListNextHeaders { + eTag?: string; +} + +// @public +export interface UsagesListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type UsagesListNextResponse = UsagesListNextHeaders & UsagesLimits; + +// @public +export interface UsagesListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type UsagesListResponse = UsagesListHeaders & UsagesLimits; + +// @public +export interface UsagesObject { + usagesType?: UsagesTypes; + value: number; +} + +// @public +export interface UsagesProperties { + readonly isQuotaApplicable?: boolean; + name?: ResourceName; + properties?: Record; + readonly quotaPeriod?: string; + resourceType?: string; + readonly unit?: string; + usages?: UsagesObject; +} + +// @public +export type UsagesTypes = string; + + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/quota/arm-quota/rollup.config.js b/sdk/quota/arm-quota/rollup.config.js new file mode 100644 index 000000000000..9be1955eb7f1 --- /dev/null +++ b/sdk/quota/arm-quota/rollup.config.js @@ -0,0 +1,188 @@ +/* + * 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 + +/** + * A function that can determine whether a rollupwarning should be ignored. If + * the function returns `true`, then the warning will not be displayed. + */ + +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/**"] + }, + 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 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/quota/arm-quota/src/azureQuotaExtensionAPI.ts b/sdk/quota/arm-quota/src/azureQuotaExtensionAPI.ts new file mode 100644 index 000000000000..b4d063c3a969 --- /dev/null +++ b/sdk/quota/arm-quota/src/azureQuotaExtensionAPI.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreAuth from "@azure/core-auth"; +import { + UsagesImpl, + QuotaImpl, + QuotaRequestStatusImpl, + OperationImpl +} from "./operations"; +import { + Usages, + Quota, + QuotaRequestStatus, + Operation +} from "./operationsInterfaces"; +import { AzureQuotaExtensionAPIContext } from "./azureQuotaExtensionAPIContext"; +import { AzureQuotaExtensionAPIOptionalParams } from "./models"; + +export class AzureQuotaExtensionAPI extends AzureQuotaExtensionAPIContext { + /** + * Initializes a new instance of the AzureQuotaExtensionAPI class. + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param options The parameter options + */ + constructor( + credentials: coreAuth.TokenCredential, + options?: AzureQuotaExtensionAPIOptionalParams + ) { + super(credentials, options); + this.usages = new UsagesImpl(this); + this.quota = new QuotaImpl(this); + this.quotaRequestStatus = new QuotaRequestStatusImpl(this); + this.operation = new OperationImpl(this); + } + + usages: Usages; + quota: Quota; + quotaRequestStatus: QuotaRequestStatus; + operation: Operation; +} diff --git a/sdk/quota/arm-quota/src/azureQuotaExtensionAPIContext.ts b/sdk/quota/arm-quota/src/azureQuotaExtensionAPIContext.ts new file mode 100644 index 000000000000..688da9f72579 --- /dev/null +++ b/sdk/quota/arm-quota/src/azureQuotaExtensionAPIContext.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; +import * as coreAuth from "@azure/core-auth"; +import { AzureQuotaExtensionAPIOptionalParams } from "./models"; + +export class AzureQuotaExtensionAPIContext extends coreClient.ServiceClient { + $host: string; + apiVersion: string; + + /** + * Initializes a new instance of the AzureQuotaExtensionAPIContext class. + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param options The parameter options + */ + constructor( + credentials: coreAuth.TokenCredential, + options?: AzureQuotaExtensionAPIOptionalParams + ) { + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: AzureQuotaExtensionAPIOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; + + const packageDetails = `azsdk-js-arm-quota/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; + + if (!options.credentialScopes) { + options.credentialScopes = ["https://management.azure.com/.default"]; + } + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix + }, + baseUri: options.endpoint || "https://management.azure.com" + }; + super(optionsWithDefaults); + + // Assigning values to Constant parameters + this.$host = options.$host || "https://management.azure.com"; + this.apiVersion = options.apiVersion || "2021-03-15-preview"; + } +} diff --git a/sdk/quota/arm-quota/src/index.ts b/sdk/quota/arm-quota/src/index.ts new file mode 100644 index 000000000000..137260e7be50 --- /dev/null +++ b/sdk/quota/arm-quota/src/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 "./models"; +export { AzureQuotaExtensionAPI } from "./azureQuotaExtensionAPI"; +export { AzureQuotaExtensionAPIContext } from "./azureQuotaExtensionAPIContext"; +export * from "./operationsInterfaces"; diff --git a/sdk/quota/arm-quota/src/lroImpl.ts b/sdk/quota/arm-quota/src/lroImpl.ts new file mode 100644 index 000000000000..518d5f053b4e --- /dev/null +++ b/sdk/quota/arm-quota/src/lroImpl.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { LongRunningOperation, LroResponse } from "@azure/core-lro"; + +export class LroImpl implements LongRunningOperation { + constructor( + private sendOperationFn: (args: any, spec: any) => Promise>, + private args: Record, + private spec: { + readonly requestBody?: unknown; + readonly path?: string; + readonly httpMethod: string; + } & Record, + public requestPath: string = spec.path!, + public requestMethod: string = spec.httpMethod + ) {} + public async sendInitialRequest(): Promise> { + return this.sendOperationFn(this.args, this.spec); + } + public async sendPollRequest(path: string): Promise> { + const { requestBody, ...restSpec } = this.spec; + return this.sendOperationFn(this.args, { + ...restSpec, + path, + httpMethod: "GET" + }); + } +} diff --git a/sdk/quota/arm-quota/src/models/index.ts b/sdk/quota/arm-quota/src/models/index.ts new file mode 100644 index 000000000000..d003075a0a75 --- /dev/null +++ b/sdk/quota/arm-quota/src/models/index.ts @@ -0,0 +1,736 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; + +export type LimitJsonObjectUnion = LimitJsonObject | LimitValue; + +/** Resource usage. */ +export interface CurrentUsagesBase { + /** + * The resource ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The resource type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * The resource name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** Usage properties for the specified resource. */ + properties?: UsagesProperties; +} + +/** Usage properties for the specified resource. */ +export interface UsagesProperties { + /** The quota limit properties for this resource. */ + usages?: UsagesObject; + /** + * The units for the quota usage, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly unit?: string; + /** Resource name provided by the resource provider. Use this property name when requesting quota. */ + name?: ResourceName; + /** The name of the resource type. */ + resourceType?: string; + /** + * The time period for the summary of the quota usage values. For example: + * *P1D (per one day) + * *PT1M (per one minute) + * *PT1S (per one second). + * This parameter is optional because it is not relevant for all resources such as compute. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly quotaPeriod?: string; + /** + * States if quota can be requested for this resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly isQuotaApplicable?: boolean; + /** Additional properties for the specific resource provider. */ + properties?: Record; +} + +/** The resource usages value. */ +export interface UsagesObject { + /** The usages value. */ + value: number; + /** The quota or usages limit types. */ + usagesType?: UsagesTypes; +} + +/** Name of the resource provided by the resource Provider. When requesting quota, use this property name. */ +export interface ResourceName { + /** Resource name. */ + value?: string; + /** + * Resource display name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly localizedValue?: string; +} + +/** Error. */ +export interface ExceptionResponse { + /** API error details. */ + error?: ServiceError; +} + +/** API error details. */ +export interface ServiceError { + /** Error code. */ + code?: string; + /** Error message. */ + message?: string; + /** + * List of error details. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly details?: ServiceErrorDetail[]; +} + +/** Error details. */ +export interface ServiceErrorDetail { + /** + * Error code. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly code?: string; + /** + * Error message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; +} + +/** Quota limits. */ +export interface UsagesLimits { + /** List of quota limits. */ + value?: CurrentUsagesBase[]; + /** The URI used to fetch the next page of quota limits. When there are no more pages, this is null. */ + nextLink?: string; +} + +/** Quota limit. */ +export interface CurrentQuotaLimitBase { + /** + * The resource ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The resource type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * The resource name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** Quota properties for the specified resource, based on the API called, Quotas or Usages. */ + properties?: QuotaProperties; +} + +/** Quota properties for the specified resource. */ +export interface QuotaProperties { + /** Resource quota limit properties. */ + limit?: LimitJsonObjectUnion; + /** + * The quota units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly unit?: string; + /** Resource name provided by the resource provider. Use this property name when requesting quota. */ + name?: ResourceName; + /** Resource type name. */ + resourceType?: string; + /** + * The time period over which the quota usage values are summarized. For example: + * *P1D (per one day) + * *PT1M (per one minute) + * *PT1S (per one second). + * This parameter is optional because, for some resources like compute, the period is irrelevant. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly quotaPeriod?: string; + /** + * States if quota can be requested for this resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly isQuotaApplicable?: boolean; + /** Additional properties for the specific resource provider. */ + properties?: Record; +} + +/** LimitJson abstract class. */ +export interface LimitJsonObject { + /** Polymorphic discriminator, which specifies the different types this object can be */ + limitObjectType: "LimitValue"; +} + +/** Quota limits. */ +export interface QuotaLimits { + /** List of quota limits. */ + value?: CurrentQuotaLimitBase[]; + /** The URI used to fetch the next page of quota limits. When there are no more pages, this string is null. */ + nextLink?: string; +} + +/** List of quota requests with details. */ +export interface QuotaRequestDetails { + /** + * Quota request ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * Quota request name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * Resource type. "Microsoft.Quota/quotas". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * The quota request status. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: QuotaRequestState; + /** + * User-friendly status message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** Error details of the quota request. */ + error?: ServiceErrorDetail; + /** + * The quota request submission time. The date conforms to the following format specified by the ISO 8601 standard: yyyy-MM-ddTHH:mm:ssZ + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly requestSubmitTime?: Date; + /** Quota request details. */ + value?: SubRequest[]; +} + +/** Quota request properties. */ +export interface QuotaRequestProperties { + /** + * The quota request status. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: QuotaRequestState; + /** + * User-friendly status message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** Error details of the quota request. */ + error?: ServiceErrorDetail; + /** + * The quota request submission time. The date conforms to the following format specified by the ISO 8601 standard: yyyy-MM-ddTHH:mm:ssZ + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly requestSubmitTime?: Date; + /** Quota request details. */ + value?: SubRequest[]; +} + +/** Request property. */ +export interface SubRequest { + /** Resource name. */ + name?: ResourceName; + /** + * Resource type for which the quota properties were requested. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly resourceType?: string; + /** Quota limit units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. */ + unit?: string; + /** + * The quota request status. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: QuotaRequestState; + /** + * User-friendly status message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** + * Quota request ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly subRequestId?: string; + /** Resource quota limit properties. */ + limit?: LimitJsonObjectUnion; +} + +/** Quota request information. */ +export interface QuotaRequestDetailsList { + /** Quota request details. */ + value?: QuotaRequestDetails[]; + /** The URI for fetching the next page of quota limits. When there are no more pages, this string is null. */ + nextLink?: string; +} + +export interface OperationList { + value?: OperationResponse[]; + /** URL to get the next page of items. */ + nextLink?: string; +} + +export interface OperationResponse { + name?: string; + display?: OperationDisplay; + origin?: string; +} + +export interface OperationDisplay { + /** Provider name. */ + provider?: string; + /** Resource name. */ + resource?: string; + /** Operation name. */ + operation?: string; + /** Operation description. */ + description?: string; +} + +/** Resource properties. */ +export interface CommonResourceProperties { + /** + * Resource ID + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * Resource name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * Resource type. Example: "Microsoft.Quota/quotas" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; +} + +/** Quota limits request response. */ +export interface QuotaLimitsResponse { + /** List of quota limits with the quota request status. */ + value?: CurrentQuotaLimitBase[]; + /** The URI used to fetch the next page of quota limits. When there are no more pages, this is null. */ + nextLink?: string; +} + +/** Quota change requests information. */ +export interface CreateGenericQuotaRequestParameters { + /** Quota change requests. */ + value?: CurrentQuotaLimitBase[]; +} + +/** The resource quota limit value. */ +export interface LimitObject { + /** The quota/limit value */ + value: number; + /** The limit object type. */ + limitObjectType?: LimitType; + /** The quota or usages limit types. */ + limitType?: QuotaLimitTypes; +} + +/** Quota request response. */ +export interface QuotaRequestOneResourceSubmitResponse { + /** + * Quota request ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The name of the quota request. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * Resource type. "Microsoft.Quota/ServiceLimitRequests" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * Quota request status. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: QuotaRequestState; + /** + * User-friendly status message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** + * Quota request submission time. The date conforms to the following ISO 8601 standard format: yyyy-MM-ddTHH:mm:ssZ. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly requestSubmitTime?: Date; + /** Resource quota limit properties. */ + limit?: LimitObject; + /** + * Usage information for the current resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly currentValue?: number; + /** The quota limit units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. */ + unit?: string; + /** Resource name provided by the resource provider. Use this property name when requesting quota. */ + namePropertiesName?: ResourceName; + /** Resource type name. */ + resourceType?: string; + /** + * The time period over which the quota usage values are summarized. For example: + * *P1D (per one day) + * *PT1M (per one minute) + * *PT1S (per one second). + * This parameter is optional because, for some resources like compute, the period is irrelevant. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly quotaPeriod?: string; + /** + * States if quota can be requested for this resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly isQuotaApplicable?: boolean; + /** Error details of the quota request. */ + error?: ServiceErrorDetail; + /** Additional properties for the specific resource provider. */ + properties?: Record; +} + +/** Quota request response. */ +export interface QuotaRequestSubmitResponse { + /** + * Quota request ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * Quota request name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** Quota request details. */ + properties?: QuotaRequestProperties; + /** + * Resource type. "Microsoft.Quota/quotas". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; +} + +/** The quota request response with the quota request ID. */ +export interface QuotaRequestSubmitResponse202 { + /** + * The quota request ID. To check the request status, use the **id** value in a [Quota Request Status](https://docs.microsoft.com/en-us/rest/api/reserved-vm-instances/quotarequeststatus/get) GET operation. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * Operation ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * Resource type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * Quota request status. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: QuotaRequestState; + /** + * User-friendly message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** Resource quota limit properties. */ + limit?: LimitObject; + /** The quota limit units, such as Count and Bytes. When requesting quota, use the **unit** value returned in the GET response in the request body of your PUT operation. */ + unit?: string; + /** Resource name provided by the resource provider. Use this property name when requesting quota. */ + namePropertiesName?: ResourceName; + /** Resource type name. */ + resourceType?: string; + /** + * The time period over which the quota usage values are summarized. For example: + * *P1D (per one day) + * *PT1M (per one minute) + * *PT1S (per one second). + * This parameter is optional because, for some resources like compute, the period is irrelevant. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly quotaPeriod?: string; + /** Additional properties for the specific resource provider. */ + properties?: Record; +} + +/** The resource quota limit. */ +export type LimitValue = LimitJsonObject & + LimitObject & { + /** Polymorphic discriminator, which specifies the different types this object can be */ + limitObjectType: "LimitValue"; + }; + +/** Defines headers for Usages_get operation. */ +export interface UsagesGetHeaders { + /** Current entity state version. Should be treated as opaque and used to make conditional HTTP requests. */ + eTag?: string; +} + +/** Defines headers for Usages_list operation. */ +export interface UsagesListHeaders { + /** Current entity state version. It should be treated as opaque and used to make conditional HTTP requests. */ + eTag?: string; +} + +/** Defines headers for Usages_listNext operation. */ +export interface UsagesListNextHeaders { + /** Current entity state version. It should be treated as opaque and used to make conditional HTTP requests. */ + eTag?: string; +} + +/** Defines headers for Quota_get operation. */ +export interface QuotaGetHeaders { + /** Current entity state version. Should be treated as opaque and used to make conditional HTTP requests. */ + eTag?: string; +} + +/** Defines headers for Quota_list operation. */ +export interface QuotaListHeaders { + /** Current entity state version. Should be treated as opaque and used to make conditional HTTP requests. */ + eTag?: string; +} + +/** Defines headers for Quota_listNext operation. */ +export interface QuotaListNextHeaders { + /** Current entity state version. Should be treated as opaque and used to make conditional HTTP requests. */ + eTag?: string; +} + +/** Known values of {@link UsagesTypes} that the service accepts. */ +export enum KnownUsagesTypes { + Individual = "Individual", + Combined = "Combined" +} + +/** + * Defines values for UsagesTypes. \ + * {@link KnownUsagesTypes} can be used interchangeably with UsagesTypes, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Individual** \ + * **Combined** + */ +export type UsagesTypes = string; + +/** Known values of {@link LimitType} that the service accepts. */ +export enum KnownLimitType { + LimitValue = "LimitValue" +} + +/** + * Defines values for LimitType. \ + * {@link KnownLimitType} can be used interchangeably with LimitType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **LimitValue** + */ +export type LimitType = string; + +/** Known values of {@link QuotaRequestState} that the service accepts. */ +export enum KnownQuotaRequestState { + Accepted = "Accepted", + Invalid = "Invalid", + Succeeded = "Succeeded", + Failed = "Failed", + InProgress = "InProgress" +} + +/** + * Defines values for QuotaRequestState. \ + * {@link KnownQuotaRequestState} can be used interchangeably with QuotaRequestState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Accepted** \ + * **Invalid** \ + * **Succeeded** \ + * **Failed** \ + * **InProgress** + */ +export type QuotaRequestState = string; + +/** Known values of {@link QuotaLimitTypes} that the service accepts. */ +export enum KnownQuotaLimitTypes { + Independent = "Independent", + Shared = "Shared" +} + +/** + * Defines values for QuotaLimitTypes. \ + * {@link KnownQuotaLimitTypes} can be used interchangeably with QuotaLimitTypes, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Independent** \ + * **Shared** + */ +export type QuotaLimitTypes = string; + +/** Optional parameters. */ +export interface UsagesGetOptionalParams extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type UsagesGetResponse = UsagesGetHeaders & CurrentUsagesBase; + +/** Optional parameters. */ +export interface UsagesListOptionalParams extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type UsagesListResponse = UsagesListHeaders & UsagesLimits; + +/** Optional parameters. */ +export interface UsagesListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type UsagesListNextResponse = UsagesListNextHeaders & UsagesLimits; + +/** Optional parameters. */ +export interface QuotaGetOptionalParams extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type QuotaGetResponse = QuotaGetHeaders & CurrentQuotaLimitBase; + +/** Optional parameters. */ +export interface QuotaCreateOrUpdateOptionalParams + extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the createOrUpdate operation. */ +export type QuotaCreateOrUpdateResponse = CurrentQuotaLimitBase; + +/** Optional parameters. */ +export interface QuotaUpdateOptionalParams extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the update operation. */ +export type QuotaUpdateResponse = CurrentQuotaLimitBase; + +/** Optional parameters. */ +export interface QuotaListOptionalParams extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type QuotaListResponse = QuotaListHeaders & QuotaLimits; + +/** Optional parameters. */ +export interface QuotaListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type QuotaListNextResponse = QuotaListNextHeaders & QuotaLimits; + +/** Optional parameters. */ +export interface QuotaRequestStatusGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type QuotaRequestStatusGetResponse = QuotaRequestDetails; + +/** Optional parameters. */ +export interface QuotaRequestStatusListOptionalParams + extends coreClient.OperationOptions { + /** + * | Field | Supported operators + * |---------------------|------------------------ + * + * |requestSubmitTime | ge, le, eq, gt, lt + * |provisioningState eq {QuotaRequestState} + * |resourceName eq {resourceName} + * + */ + filter?: string; + /** Number of records to return. */ + top?: number; + /** The **Skiptoken** parameter is used only if a previous operation returned a partial result. If a previous response contains a **nextLink** element, its value includes a **skiptoken** parameter that specifies a starting point to use for subsequent calls. */ + skiptoken?: string; +} + +/** Contains response data for the list operation. */ +export type QuotaRequestStatusListResponse = QuotaRequestDetailsList; + +/** Optional parameters. */ +export interface QuotaRequestStatusListNextOptionalParams + extends coreClient.OperationOptions { + /** + * | Field | Supported operators + * |---------------------|------------------------ + * + * |requestSubmitTime | ge, le, eq, gt, lt + * |provisioningState eq {QuotaRequestState} + * |resourceName eq {resourceName} + * + */ + filter?: string; + /** Number of records to return. */ + top?: number; + /** The **Skiptoken** parameter is used only if a previous operation returned a partial result. If a previous response contains a **nextLink** element, its value includes a **skiptoken** parameter that specifies a starting point to use for subsequent calls. */ + skiptoken?: string; +} + +/** Contains response data for the listNext operation. */ +export type QuotaRequestStatusListNextResponse = QuotaRequestDetailsList; + +/** Optional parameters. */ +export interface OperationListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type OperationListResponse = OperationList; + +/** Optional parameters. */ +export interface OperationListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type OperationListNextResponse = OperationList; + +/** Optional parameters. */ +export interface AzureQuotaExtensionAPIOptionalParams + extends coreClient.ServiceClientOptions { + /** server parameter */ + $host?: string; + /** Api Version */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/quota/arm-quota/src/models/mappers.ts b/sdk/quota/arm-quota/src/models/mappers.ts new file mode 100644 index 000000000000..9417b5a4f3b0 --- /dev/null +++ b/sdk/quota/arm-quota/src/models/mappers.ts @@ -0,0 +1,1128 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; + +export const CurrentUsagesBase: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CurrentUsagesBase", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "UsagesProperties" + } + } + } + } +}; + +export const UsagesProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UsagesProperties", + modelProperties: { + usages: { + serializedName: "usages", + type: { + name: "Composite", + className: "UsagesObject" + } + }, + unit: { + serializedName: "unit", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + type: { + name: "Composite", + className: "ResourceName" + } + }, + resourceType: { + serializedName: "resourceType", + type: { + name: "String" + } + }, + quotaPeriod: { + serializedName: "quotaPeriod", + readOnly: true, + type: { + name: "String" + } + }, + isQuotaApplicable: { + serializedName: "isQuotaApplicable", + readOnly: true, + type: { + name: "Boolean" + } + }, + properties: { + serializedName: "properties", + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + } + } + } +}; + +export const UsagesObject: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UsagesObject", + modelProperties: { + value: { + serializedName: "value", + required: true, + type: { + name: "Number" + } + }, + usagesType: { + serializedName: "usagesType", + type: { + name: "String" + } + } + } + } +}; + +export const ResourceName: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceName", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "String" + } + }, + localizedValue: { + serializedName: "localizedValue", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const ExceptionResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ExceptionResponse", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ServiceError" + } + } + } + } +}; + +export const ServiceError: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ServiceError", + modelProperties: { + code: { + serializedName: "code", + type: { + name: "String" + } + }, + message: { + serializedName: "message", + type: { + name: "String" + } + }, + details: { + serializedName: "details", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ServiceErrorDetail" + } + } + } + } + } + } +}; + +export const ServiceErrorDetail: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ServiceErrorDetail", + modelProperties: { + code: { + serializedName: "code", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const UsagesLimits: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UsagesLimits", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "CurrentUsagesBase" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const CurrentQuotaLimitBase: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CurrentQuotaLimitBase", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "QuotaProperties" + } + } + } + } +}; + +export const QuotaProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaProperties", + modelProperties: { + limit: { + serializedName: "limit", + type: { + name: "Composite", + className: "LimitJsonObject" + } + }, + unit: { + serializedName: "unit", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + type: { + name: "Composite", + className: "ResourceName" + } + }, + resourceType: { + serializedName: "resourceType", + type: { + name: "String" + } + }, + quotaPeriod: { + serializedName: "quotaPeriod", + readOnly: true, + type: { + name: "String" + } + }, + isQuotaApplicable: { + serializedName: "isQuotaApplicable", + readOnly: true, + type: { + name: "Boolean" + } + }, + properties: { + serializedName: "properties", + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + } + } + } +}; + +export const LimitJsonObject: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LimitJsonObject", + uberParent: "LimitJsonObject", + polymorphicDiscriminator: { + serializedName: "limitObjectType", + clientName: "limitObjectType" + }, + modelProperties: { + limitObjectType: { + serializedName: "limitObjectType", + required: true, + type: { + name: "String" + } + } + } + } +}; + +export const QuotaLimits: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaLimits", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "CurrentQuotaLimitBase" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const QuotaRequestDetails: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaRequestDetails", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + provisioningState: { + serializedName: "properties.provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "properties.message", + readOnly: true, + type: { + name: "String" + } + }, + error: { + serializedName: "properties.error", + type: { + name: "Composite", + className: "ServiceErrorDetail" + } + }, + requestSubmitTime: { + serializedName: "properties.requestSubmitTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + value: { + serializedName: "properties.value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "SubRequest" + } + } + } + } + } + } +}; + +export const QuotaRequestProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaRequestProperties", + modelProperties: { + provisioningState: { + serializedName: "provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + }, + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ServiceErrorDetail" + } + }, + requestSubmitTime: { + serializedName: "requestSubmitTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "SubRequest" + } + } + } + } + } + } +}; + +export const SubRequest: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SubRequest", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "Composite", + className: "ResourceName" + } + }, + resourceType: { + serializedName: "resourceType", + readOnly: true, + type: { + name: "String" + } + }, + unit: { + serializedName: "unit", + type: { + name: "String" + } + }, + provisioningState: { + serializedName: "provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + }, + subRequestId: { + serializedName: "subRequestId", + readOnly: true, + type: { + name: "String" + } + }, + limit: { + serializedName: "limit", + type: { + name: "Composite", + className: "LimitJsonObject" + } + } + } + } +}; + +export const QuotaRequestDetailsList: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaRequestDetailsList", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "QuotaRequestDetails" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const OperationList: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationList", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "OperationResponse" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const OperationResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationResponse", + modelProperties: { + name: { + serializedName: "name", + type: { + name: "String" + } + }, + display: { + serializedName: "display", + type: { + name: "Composite", + className: "OperationDisplay" + } + }, + origin: { + serializedName: "origin", + type: { + name: "String" + } + } + } + } +}; + +export const OperationDisplay: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationDisplay", + modelProperties: { + provider: { + serializedName: "provider", + type: { + name: "String" + } + }, + resource: { + serializedName: "resource", + type: { + name: "String" + } + }, + operation: { + serializedName: "operation", + type: { + name: "String" + } + }, + description: { + serializedName: "description", + type: { + name: "String" + } + } + } + } +}; + +export const CommonResourceProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CommonResourceProperties", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const QuotaLimitsResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaLimitsResponse", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "CurrentQuotaLimitBase" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const CreateGenericQuotaRequestParameters: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CreateGenericQuotaRequestParameters", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "CurrentQuotaLimitBase" + } + } + } + } + } + } +}; + +export const LimitObject: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LimitObject", + modelProperties: { + value: { + serializedName: "value", + required: true, + type: { + name: "Number" + } + }, + limitObjectType: { + serializedName: "limitObjectType", + type: { + name: "String" + } + }, + limitType: { + serializedName: "limitType", + type: { + name: "String" + } + } + } + } +}; + +export const QuotaRequestOneResourceSubmitResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaRequestOneResourceSubmitResponse", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + provisioningState: { + serializedName: "properties.provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "properties.message", + readOnly: true, + type: { + name: "String" + } + }, + requestSubmitTime: { + serializedName: "properties.requestSubmitTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + limit: { + serializedName: "properties.limit", + type: { + name: "Composite", + className: "LimitObject" + } + }, + currentValue: { + serializedName: "properties.currentValue", + readOnly: true, + type: { + name: "Number" + } + }, + unit: { + serializedName: "properties.unit", + type: { + name: "String" + } + }, + namePropertiesName: { + serializedName: "properties.name", + type: { + name: "Composite", + className: "ResourceName" + } + }, + resourceType: { + serializedName: "properties.resourceType", + type: { + name: "String" + } + }, + quotaPeriod: { + serializedName: "properties.quotaPeriod", + readOnly: true, + type: { + name: "String" + } + }, + isQuotaApplicable: { + serializedName: "properties.isQuotaApplicable", + readOnly: true, + type: { + name: "Boolean" + } + }, + error: { + serializedName: "properties.error", + type: { + name: "Composite", + className: "ServiceErrorDetail" + } + }, + properties: { + serializedName: "properties.properties", + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + } + } + } +}; + +export const QuotaRequestSubmitResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaRequestSubmitResponse", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + properties: { + serializedName: "properties", + type: { + name: "Composite", + className: "QuotaRequestProperties" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const QuotaRequestSubmitResponse202: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaRequestSubmitResponse202", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + provisioningState: { + serializedName: "properties.provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "properties.message", + readOnly: true, + type: { + name: "String" + } + }, + limit: { + serializedName: "properties.limit", + type: { + name: "Composite", + className: "LimitObject" + } + }, + unit: { + serializedName: "properties.unit", + type: { + name: "String" + } + }, + namePropertiesName: { + serializedName: "properties.name", + type: { + name: "Composite", + className: "ResourceName" + } + }, + resourceType: { + serializedName: "properties.resourceType", + type: { + name: "String" + } + }, + quotaPeriod: { + serializedName: "properties.quotaPeriod", + readOnly: true, + type: { + name: "String" + } + }, + properties: { + serializedName: "properties.properties", + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + } + } + } +}; + +export const LimitValue: coreClient.CompositeMapper = { + serializedName: "LimitValue", + type: { + name: "Composite", + className: "LimitValue", + uberParent: "LimitJsonObject", + polymorphicDiscriminator: LimitJsonObject.type.polymorphicDiscriminator, + modelProperties: { + ...LimitJsonObject.type.modelProperties, + ...LimitObject.type.modelProperties + } + } +}; + +export const UsagesGetHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UsagesGetHeaders", + modelProperties: { + eTag: { + serializedName: "etag", + type: { + name: "String" + } + } + } + } +}; + +export const UsagesListHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UsagesListHeaders", + modelProperties: { + eTag: { + serializedName: "etag", + type: { + name: "String" + } + } + } + } +}; + +export const UsagesListNextHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UsagesListNextHeaders", + modelProperties: { + eTag: { + serializedName: "etag", + type: { + name: "String" + } + } + } + } +}; + +export const QuotaGetHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaGetHeaders", + modelProperties: { + eTag: { + serializedName: "etag", + type: { + name: "String" + } + } + } + } +}; + +export const QuotaListHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaListHeaders", + modelProperties: { + eTag: { + serializedName: "etag", + type: { + name: "String" + } + } + } + } +}; + +export const QuotaListNextHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaListNextHeaders", + modelProperties: { + eTag: { + serializedName: "etag", + type: { + name: "String" + } + } + } + } +}; + +export let discriminators = { + LimitJsonObject: LimitJsonObject, + "LimitJsonObject.LimitValue": LimitValue +}; diff --git a/sdk/quota/arm-quota/src/models/parameters.ts b/sdk/quota/arm-quota/src/models/parameters.ts new file mode 100644 index 000000000000..16ad1e6b051d --- /dev/null +++ b/sdk/quota/arm-quota/src/models/parameters.ts @@ -0,0 +1,146 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + OperationParameter, + OperationURLParameter, + OperationQueryParameter +} from "@azure/core-client"; +import { CurrentQuotaLimitBase as CurrentQuotaLimitBaseMapper } from "../models/mappers"; + +export const accept: OperationParameter = { + parameterPath: "accept", + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", + type: { + name: "String" + } + } +}; + +export const $host: OperationURLParameter = { + parameterPath: "$host", + mapper: { + serializedName: "$host", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const resourceName: OperationURLParameter = { + parameterPath: "resourceName", + mapper: { + serializedName: "resourceName", + required: true, + type: { + name: "String" + } + } +}; + +export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2021-03-15-preview", + isConstant: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; + +export const scope: OperationURLParameter = { + parameterPath: "scope", + mapper: { + serializedName: "scope", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const createQuotaRequest: OperationParameter = { + parameterPath: "createQuotaRequest", + mapper: CurrentQuotaLimitBaseMapper +}; + +export const id: OperationURLParameter = { + parameterPath: "id", + mapper: { + serializedName: "id", + required: true, + type: { + name: "String" + } + } +}; + +export const filter: OperationQueryParameter = { + parameterPath: ["options", "filter"], + mapper: { + serializedName: "$filter", + type: { + name: "String" + } + } +}; + +export const top: OperationQueryParameter = { + parameterPath: ["options", "top"], + mapper: { + constraints: { + InclusiveMinimum: 1 + }, + serializedName: "$top", + type: { + name: "Number" + } + } +}; + +export const skiptoken: OperationQueryParameter = { + parameterPath: ["options", "skiptoken"], + mapper: { + serializedName: "$skiptoken", + type: { + name: "String" + } + } +}; diff --git a/sdk/quota/arm-quota/src/operations/index.ts b/sdk/quota/arm-quota/src/operations/index.ts new file mode 100644 index 000000000000..94c54b2fb240 --- /dev/null +++ b/sdk/quota/arm-quota/src/operations/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 "./usages"; +export * from "./quota"; +export * from "./quotaRequestStatus"; +export * from "./operation"; diff --git a/sdk/quota/arm-quota/src/operations/operation.ts b/sdk/quota/arm-quota/src/operations/operation.ts new file mode 100644 index 000000000000..b593bf9690f1 --- /dev/null +++ b/sdk/quota/arm-quota/src/operations/operation.ts @@ -0,0 +1,137 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Operation } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { AzureQuotaExtensionAPIContext } from "../azureQuotaExtensionAPIContext"; +import { + OperationResponse, + OperationListNextOptionalParams, + OperationListOptionalParams, + OperationListResponse, + OperationListNextResponse +} from "../models"; + +/// +/** Class containing Operation operations. */ +export class OperationImpl implements Operation { + private readonly client: AzureQuotaExtensionAPIContext; + + /** + * Initialize a new instance of the class Operation class. + * @param client Reference to the service client + */ + constructor(client: AzureQuotaExtensionAPIContext) { + this.client = client; + } + + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * @param options The options parameters. + */ + public list( + options?: OperationListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(options); + } + }; + } + + private async *listPagingPage( + options?: OperationListOptionalParams + ): 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?: OperationListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * @param options The options parameters. + */ + private _list( + options?: OperationListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + nextLink: string, + options?: OperationListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.Quota/operations", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationList + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationList + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/quota/arm-quota/src/operations/quota.ts b/sdk/quota/arm-quota/src/operations/quota.ts new file mode 100644 index 000000000000..562fc7e4c90c --- /dev/null +++ b/sdk/quota/arm-quota/src/operations/quota.ts @@ -0,0 +1,497 @@ +/* + * 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 { Quota } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { AzureQuotaExtensionAPIContext } from "../azureQuotaExtensionAPIContext"; +import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; +import { LroImpl } from "../lroImpl"; +import { + CurrentQuotaLimitBase, + QuotaListNextOptionalParams, + QuotaListOptionalParams, + QuotaGetOptionalParams, + QuotaGetResponse, + QuotaCreateOrUpdateOptionalParams, + QuotaCreateOrUpdateResponse, + QuotaUpdateOptionalParams, + QuotaUpdateResponse, + QuotaListResponse, + QuotaListNextResponse +} from "../models"; + +/// +/** Class containing Quota operations. */ +export class QuotaImpl implements Quota { + private readonly client: AzureQuotaExtensionAPIContext; + + /** + * Initialize a new instance of the class Quota class. + * @param client Reference to the service client + */ + constructor(client: AzureQuotaExtensionAPIContext) { + this.client = client; + } + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this + * GET operation can be leveraged to submit requests to update a quota. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + public list( + scope: string, + options?: QuotaListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(scope, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(scope, options); + } + }; + } + + private async *listPagingPage( + scope: string, + options?: QuotaListOptionalParams + ): AsyncIterableIterator { + let result = await this._list(scope, options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listNext(scope, continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listPagingAll( + scope: string, + options?: QuotaListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(scope, options)) { + yield* page; + } + } + + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to + * calculate a new quota limit that can be submitted with a PUT request. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + get( + resourceName: string, + scope: string, + options?: QuotaGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceName, scope, options }, + getOperationSpec + ); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the + * quota, follow these steps: + * 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the + * detailed status of the request. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param createQuotaRequest Quota request payload. + * @param options The options parameters. + */ + async beginCreateOrUpdate( + resourceName: string, + scope: string, + createQuotaRequest: CurrentQuotaLimitBase, + options?: QuotaCreateOrUpdateOptionalParams + ): Promise< + PollerLike< + PollOperationState, + QuotaCreateOrUpdateResponse + > + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ) => { + let currentRawResponse: + | coreClient.FullOperationResponse + | undefined = undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback + } + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON() + } + }; + }; + + const lro = new LroImpl( + sendOperation, + { resourceName, scope, createQuotaRequest, options }, + createOrUpdateOperationSpec + ); + return new LroEngine(lro, { + resumeFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + lroResourceLocationConfig: "location" + }); + } + + /** + * Create or update the quota limit for the specified resource with the requested value. To update the + * quota, follow these steps: + * 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the + * detailed status of the request. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param createQuotaRequest Quota request payload. + * @param options The options parameters. + */ + async beginCreateOrUpdateAndWait( + resourceName: string, + scope: string, + createQuotaRequest: CurrentQuotaLimitBase, + options?: QuotaCreateOrUpdateOptionalParams + ): Promise { + const poller = await this.beginCreateOrUpdate( + resourceName, + scope, + createQuotaRequest, + options + ); + return poller.pollUntilDone(); + } + + /** + * Update the quota limit for a specific resource to the specified value: + * 1. Use the Usages-GET and Quota-GET operations to determine the remaining quota for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the + * detailed status of the request. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param createQuotaRequest Quota requests payload. + * @param options The options parameters. + */ + async beginUpdate( + resourceName: string, + scope: string, + createQuotaRequest: CurrentQuotaLimitBase, + options?: QuotaUpdateOptionalParams + ): Promise< + PollerLike, QuotaUpdateResponse> + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ) => { + let currentRawResponse: + | coreClient.FullOperationResponse + | undefined = undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback + } + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON() + } + }; + }; + + const lro = new LroImpl( + sendOperation, + { resourceName, scope, createQuotaRequest, options }, + updateOperationSpec + ); + return new LroEngine(lro, { + resumeFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + lroResourceLocationConfig: "location" + }); + } + + /** + * Update the quota limit for a specific resource to the specified value: + * 1. Use the Usages-GET and Quota-GET operations to determine the remaining quota for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the + * detailed status of the request. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param createQuotaRequest Quota requests payload. + * @param options The options parameters. + */ + async beginUpdateAndWait( + resourceName: string, + scope: string, + createQuotaRequest: CurrentQuotaLimitBase, + options?: QuotaUpdateOptionalParams + ): Promise { + const poller = await this.beginUpdate( + resourceName, + scope, + createQuotaRequest, + options + ); + return poller.pollUntilDone(); + } + + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this + * GET operation can be leveraged to submit requests to update a quota. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + private _list( + scope: string, + options?: QuotaListOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, options }, + listOperationSpec + ); + } + + /** + * ListNext + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + scope: string, + nextLink: string, + options?: QuotaListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const getOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Quota/quotas/{resourceName}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.CurrentQuotaLimitBase, + headersMapper: Mappers.QuotaGetHeaders + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.resourceName, Parameters.scope], + headerParameters: [Parameters.accept], + serializer +}; +const createOrUpdateOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Quota/quotas/{resourceName}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.CurrentQuotaLimitBase + }, + 201: { + bodyMapper: Mappers.CurrentQuotaLimitBase + }, + 202: { + bodyMapper: Mappers.CurrentQuotaLimitBase + }, + 204: { + bodyMapper: Mappers.CurrentQuotaLimitBase + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + requestBody: Parameters.createQuotaRequest, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.resourceName, Parameters.scope], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const updateOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Quota/quotas/{resourceName}", + httpMethod: "PATCH", + responses: { + 200: { + bodyMapper: Mappers.CurrentQuotaLimitBase + }, + 201: { + bodyMapper: Mappers.CurrentQuotaLimitBase + }, + 202: { + bodyMapper: Mappers.CurrentQuotaLimitBase + }, + 204: { + bodyMapper: Mappers.CurrentQuotaLimitBase + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + requestBody: Parameters.createQuotaRequest, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.resourceName, Parameters.scope], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const listOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Quota/quotas", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.QuotaLimits, + headersMapper: Mappers.QuotaListHeaders + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.scope], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.QuotaLimits, + headersMapper: Mappers.QuotaListNextHeaders + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/quota/arm-quota/src/operations/quotaRequestStatus.ts b/sdk/quota/arm-quota/src/operations/quotaRequestStatus.ts new file mode 100644 index 000000000000..718695d9d56c --- /dev/null +++ b/sdk/quota/arm-quota/src/operations/quotaRequestStatus.ts @@ -0,0 +1,213 @@ +/* + * 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 { QuotaRequestStatus } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { AzureQuotaExtensionAPIContext } from "../azureQuotaExtensionAPIContext"; +import { + QuotaRequestDetails, + QuotaRequestStatusListNextOptionalParams, + QuotaRequestStatusListOptionalParams, + QuotaRequestStatusGetOptionalParams, + QuotaRequestStatusGetResponse, + QuotaRequestStatusListResponse, + QuotaRequestStatusListNextResponse +} from "../models"; + +/// +/** Class containing QuotaRequestStatus operations. */ +export class QuotaRequestStatusImpl implements QuotaRequestStatus { + private readonly client: AzureQuotaExtensionAPIContext; + + /** + * Initialize a new instance of the class QuotaRequestStatus class. + * @param client Reference to the service client + */ + constructor(client: AzureQuotaExtensionAPIContext) { + this.client = client; + } + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is + * made. Use the **oData** filter to select quota requests. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + public list( + scope: string, + options?: QuotaRequestStatusListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(scope, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(scope, options); + } + }; + } + + private async *listPagingPage( + scope: string, + options?: QuotaRequestStatusListOptionalParams + ): AsyncIterableIterator { + let result = await this._list(scope, options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listNext(scope, continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listPagingAll( + scope: string, + options?: QuotaRequestStatusListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(scope, options)) { + yield* page; + } + } + + /** + * Get the quota request details and status by quota request ID for the resources of the resource + * provider at a specific location. The quota request ID **id** is returned in the response of the PUT + * operation. + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + get( + id: string, + scope: string, + options?: QuotaRequestStatusGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { id, scope, options }, + getOperationSpec + ); + } + + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is + * made. Use the **oData** filter to select quota requests. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + private _list( + scope: string, + options?: QuotaRequestStatusListOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, options }, + listOperationSpec + ); + } + + /** + * ListNext + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + scope: string, + nextLink: string, + options?: QuotaRequestStatusListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const getOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Quota/quotaRequests/{id}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.QuotaRequestDetails + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.scope, Parameters.id], + headerParameters: [Parameters.accept], + serializer +}; +const listOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Quota/quotaRequests", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.QuotaRequestDetailsList + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [ + Parameters.apiVersion, + Parameters.filter, + Parameters.top, + Parameters.skiptoken + ], + urlParameters: [Parameters.$host, Parameters.scope], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.QuotaRequestDetailsList + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [ + Parameters.apiVersion, + Parameters.filter, + Parameters.top, + Parameters.skiptoken + ], + urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/quota/arm-quota/src/operations/usages.ts b/sdk/quota/arm-quota/src/operations/usages.ts new file mode 100644 index 000000000000..d9f307a8e571 --- /dev/null +++ b/sdk/quota/arm-quota/src/operations/usages.ts @@ -0,0 +1,205 @@ +/* + * 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 { Usages } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { AzureQuotaExtensionAPIContext } from "../azureQuotaExtensionAPIContext"; +import { + CurrentUsagesBase, + UsagesListNextOptionalParams, + UsagesListOptionalParams, + UsagesGetOptionalParams, + UsagesGetResponse, + UsagesListResponse, + UsagesListNextResponse +} from "../models"; + +/// +/** Class containing Usages operations. */ +export class UsagesImpl implements Usages { + private readonly client: AzureQuotaExtensionAPIContext; + + /** + * Initialize a new instance of the class Usages class. + * @param client Reference to the service client + */ + constructor(client: AzureQuotaExtensionAPIContext) { + this.client = client; + } + + /** + * Get a list of current usage for all resources for the scope specified. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + public list( + scope: string, + options?: UsagesListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(scope, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(scope, options); + } + }; + } + + private async *listPagingPage( + scope: string, + options?: UsagesListOptionalParams + ): AsyncIterableIterator { + let result = await this._list(scope, options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listNext(scope, continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listPagingAll( + scope: string, + options?: UsagesListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(scope, options)) { + yield* page; + } + } + + /** + * Get the current usage of a resource. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + get( + resourceName: string, + scope: string, + options?: UsagesGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceName, scope, options }, + getOperationSpec + ); + } + + /** + * Get a list of current usage for all resources for the scope specified. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + private _list( + scope: string, + options?: UsagesListOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, options }, + listOperationSpec + ); + } + + /** + * ListNext + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + scope: string, + nextLink: string, + options?: UsagesListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { scope, nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const getOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Quota/usages/{resourceName}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.CurrentUsagesBase, + headersMapper: Mappers.UsagesGetHeaders + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.resourceName, Parameters.scope], + headerParameters: [Parameters.accept], + serializer +}; +const listOperationSpec: coreClient.OperationSpec = { + path: "/{scope}/providers/Microsoft.Quota/usages", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.UsagesLimits, + headersMapper: Mappers.UsagesListHeaders + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.scope], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.UsagesLimits, + headersMapper: Mappers.UsagesListNextHeaders + }, + default: { + bodyMapper: Mappers.ExceptionResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/quota/arm-quota/src/operationsInterfaces/index.ts b/sdk/quota/arm-quota/src/operationsInterfaces/index.ts new file mode 100644 index 000000000000..94c54b2fb240 --- /dev/null +++ b/sdk/quota/arm-quota/src/operationsInterfaces/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 "./usages"; +export * from "./quota"; +export * from "./quotaRequestStatus"; +export * from "./operation"; diff --git a/sdk/quota/arm-quota/src/operationsInterfaces/operation.ts b/sdk/quota/arm-quota/src/operationsInterfaces/operation.ts new file mode 100644 index 000000000000..76f522d80216 --- /dev/null +++ b/sdk/quota/arm-quota/src/operationsInterfaces/operation.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 { OperationResponse, OperationListOptionalParams } from "../models"; + +/// +/** Interface representing a Operation. */ +export interface Operation { + /** + * List all the operations supported by the Microsoft.Quota resource provider. + * @param options The options parameters. + */ + list( + options?: OperationListOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/quota/arm-quota/src/operationsInterfaces/quota.ts b/sdk/quota/arm-quota/src/operationsInterfaces/quota.ts new file mode 100644 index 000000000000..0818e76ebfa2 --- /dev/null +++ b/sdk/quota/arm-quota/src/operationsInterfaces/quota.ts @@ -0,0 +1,167 @@ +/* + * 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 { PollerLike, PollOperationState } from "@azure/core-lro"; +import { + CurrentQuotaLimitBase, + QuotaListOptionalParams, + QuotaGetOptionalParams, + QuotaGetResponse, + QuotaCreateOrUpdateOptionalParams, + QuotaCreateOrUpdateResponse, + QuotaUpdateOptionalParams, + QuotaUpdateResponse +} from "../models"; + +/// +/** Interface representing a Quota. */ +export interface Quota { + /** + * Get a list of current quota limits of all resources for the specified scope. The response from this + * GET operation can be leveraged to submit requests to update a quota. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + list( + scope: string, + options?: QuotaListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Get the quota limit of a resource. The response can be used to determine the remaining quota to + * calculate a new quota limit that can be submitted with a PUT request. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + get( + resourceName: string, + scope: string, + options?: QuotaGetOptionalParams + ): Promise; + /** + * Create or update the quota limit for the specified resource with the requested value. To update the + * quota, follow these steps: + * 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the + * detailed status of the request. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param createQuotaRequest Quota request payload. + * @param options The options parameters. + */ + beginCreateOrUpdate( + resourceName: string, + scope: string, + createQuotaRequest: CurrentQuotaLimitBase, + options?: QuotaCreateOrUpdateOptionalParams + ): Promise< + PollerLike< + PollOperationState, + QuotaCreateOrUpdateResponse + > + >; + /** + * Create or update the quota limit for the specified resource with the requested value. To update the + * quota, follow these steps: + * 1. Use the GET operation for quotas and usages to determine how much quota remains for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the + * detailed status of the request. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param createQuotaRequest Quota request payload. + * @param options The options parameters. + */ + beginCreateOrUpdateAndWait( + resourceName: string, + scope: string, + createQuotaRequest: CurrentQuotaLimitBase, + options?: QuotaCreateOrUpdateOptionalParams + ): Promise; + /** + * Update the quota limit for a specific resource to the specified value: + * 1. Use the Usages-GET and Quota-GET operations to determine the remaining quota for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the + * detailed status of the request. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param createQuotaRequest Quota requests payload. + * @param options The options parameters. + */ + beginUpdate( + resourceName: string, + scope: string, + createQuotaRequest: CurrentQuotaLimitBase, + options?: QuotaUpdateOptionalParams + ): Promise< + PollerLike, QuotaUpdateResponse> + >; + /** + * Update the quota limit for a specific resource to the specified value: + * 1. Use the Usages-GET and Quota-GET operations to determine the remaining quota for the specific + * resource and to calculate the new quota limit. These steps are detailed in [this + * example](https://techcommunity.microsoft.com/t5/azure-governance-and-management/using-the-new-quota-rest-api/ba-p/2183670). + * 2. Use this PUT operation to update the quota limit. Please check the URI in location header for the + * detailed status of the request. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param createQuotaRequest Quota requests payload. + * @param options The options parameters. + */ + beginUpdateAndWait( + resourceName: string, + scope: string, + createQuotaRequest: CurrentQuotaLimitBase, + options?: QuotaUpdateOptionalParams + ): Promise; +} diff --git a/sdk/quota/arm-quota/src/operationsInterfaces/quotaRequestStatus.ts b/sdk/quota/arm-quota/src/operationsInterfaces/quotaRequestStatus.ts new file mode 100644 index 000000000000..88ce57374da8 --- /dev/null +++ b/sdk/quota/arm-quota/src/operationsInterfaces/quotaRequestStatus.ts @@ -0,0 +1,51 @@ +/* + * 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 { + QuotaRequestDetails, + QuotaRequestStatusListOptionalParams, + QuotaRequestStatusGetOptionalParams, + QuotaRequestStatusGetResponse +} from "../models"; + +/// +/** Interface representing a QuotaRequestStatus. */ +export interface QuotaRequestStatus { + /** + * For the specified scope, get the current quota requests for a one year period ending at the time is + * made. Use the **oData** filter to select quota requests. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + list( + scope: string, + options?: QuotaRequestStatusListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Get the quota request details and status by quota request ID for the resources of the resource + * provider at a specific location. The quota request ID **id** is returned in the response of the PUT + * operation. + * @param id Quota request ID. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + get( + id: string, + scope: string, + options?: QuotaRequestStatusGetOptionalParams + ): Promise; +} diff --git a/sdk/quota/arm-quota/src/operationsInterfaces/usages.ts b/sdk/quota/arm-quota/src/operationsInterfaces/usages.ts new file mode 100644 index 000000000000..f56be64edf46 --- /dev/null +++ b/sdk/quota/arm-quota/src/operationsInterfaces/usages.ts @@ -0,0 +1,51 @@ +/* + * 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 { + CurrentUsagesBase, + UsagesListOptionalParams, + UsagesGetOptionalParams, + UsagesGetResponse +} from "../models"; + +/// +/** Interface representing a Usages. */ +export interface Usages { + /** + * Get a list of current usage for all resources for the scope specified. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + list( + scope: string, + options?: UsagesListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Get the current usage of a resource. + * @param resourceName Resource name for a given resource provider. For example: + * - SKU name for Microsoft.Compute + * - SKU or TotalLowPriorityCores for Microsoft.MachineLearningServices + * For Microsoft.Network PublicIPAddresses. + * @param scope The target Azure resource URI. For example, + * `/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/qms-test/providers/Microsoft.Batch/batchAccounts/testAccount/`. + * This is the target Azure resource URI for the List GET operation. If a `{resourceName}` is added + * after `/quotas`, then it's the target Azure resource URI in the GET operation for the specific + * resource. + * @param options The options parameters. + */ + get( + resourceName: string, + scope: string, + options?: UsagesGetOptionalParams + ): Promise; +} diff --git a/sdk/quota/arm-quota/test/sampleTest.ts b/sdk/quota/arm-quota/test/sampleTest.ts new file mode 100644 index 000000000000..7ed89b043e1b --- /dev/null +++ b/sdk/quota/arm-quota/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/quota/arm-quota/tsconfig.json b/sdk/quota/arm-quota/tsconfig.json new file mode 100644 index 000000000000..6e3251194117 --- /dev/null +++ b/sdk/quota/arm-quota/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "es6", + "moduleResolution": "node", + "strict": true, + "target": "es6", + "sourceMap": true, + "declarationMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es6", "dom"], + "declaration": true, + "outDir": "./dist-esm", + "importHelpers": true + }, + "include": ["./src/**/*.ts", "./test/**/*.ts"], + "exclude": ["node_modules"] +} diff --git a/sdk/quota/ci.yml b/sdk/quota/ci.yml new file mode 100644 index 000000000000..caa0a8084e44 --- /dev/null +++ b/sdk/quota/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/quota/ + +pr: + branches: + include: + - main + - release/* + - hotfix/* + paths: + include: + - sdk/quota/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: quota + Artifacts: + - name: azure-arm-quota + safeName: azurearmquota + \ No newline at end of file From 4f34da914b0617108e4ee7fcc5a8513e1b202bd8 Mon Sep 17 00:00:00 2001 From: colawwj Date: Wed, 29 Sep 2021 10:22:15 +0800 Subject: [PATCH 2/2] update --- .../recordings/node/my_test/recording_sample_test.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 sdk/quota/arm-quota/recordings/node/my_test/recording_sample_test.js diff --git a/sdk/quota/arm-quota/recordings/node/my_test/recording_sample_test.js b/sdk/quota/arm-quota/recordings/node/my_test/recording_sample_test.js new file mode 100644 index 000000000000..0f6ecb857acf --- /dev/null +++ b/sdk/quota/arm-quota/recordings/node/my_test/recording_sample_test.js @@ -0,0 +1,5 @@ +let nock = require('nock'); + +module.exports.hash = "7a6be38bb8cb644d64b4094802301751"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}}