diff --git a/sdk/loadtestservice/arm-loadtesting/LICENSE b/sdk/loadtestservice/arm-loadtesting/LICENSE new file mode 100644 index 000000000000..3a1d9b6f24f7 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2023 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/loadtestservice/arm-loadtesting/README.md b/sdk/loadtestservice/arm-loadtesting/README.md new file mode 100644 index 000000000000..a4183e098c7b --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/README.md @@ -0,0 +1,109 @@ +# Azure LoadTest client library for JavaScript + +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure LoadTest client. + +LoadTest client provides access to LoadTest Resource and it's status operations. + +[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtestservice/arm-loadtesting) | +[Package (NPM)](https://www.npmjs.com/package/@azure/arm-loadtesting) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-loadtesting?view=azure-node-preview) | +[Samples](https://github.com/Azure-Samples/azure-samples-js-management) + +## Getting started + +### Currently supported environments + +- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) +- Latest versions of Safari, Chrome, Edge and Firefox. + +See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. + +### Prerequisites + +- An [Azure subscription][azure_sub]. + +### Install the `@azure/arm-loadtesting` package + +Install the Azure LoadTest client library for JavaScript with `npm`: + +```bash +npm install @azure/arm-loadtesting +``` + +### Create and authenticate a `LoadTestClient` + +To create a client object to access the Azure LoadTest API, you will need the `endpoint` of your Azure LoadTest resource and a `credential`. The Azure LoadTest client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure LoadTest 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 LoadTest** 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 { LoadTestClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); +// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. + +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new LoadTestClient(credential, subscriptionId); +``` + + +### JavaScript Bundle +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). + +## Key concepts + +### LoadTestClient + +`LoadTestClient` is the primary interface for developers using the Azure LoadTest client library. Explore the methods on this client object to understand the different features of the Azure LoadTest 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%2Floadtestservice%2Farm-loadtesting%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/loadtestservice/arm-loadtesting/_meta.json b/sdk/loadtestservice/arm-loadtesting/_meta.json new file mode 100644 index 000000000000..830fda0912d3 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/_meta.json @@ -0,0 +1,8 @@ +{ + "commit": "e16870317d588dda243e69712cc6e25757fd16e0", + "readme": "specification/loadtestservice/resource-manager/readme.md", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/loadtestservice/resource-manager/readme.md --use=@autorest/typescript@6.0.0-rc.5", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "release_tool": "@azure-tools/js-sdk-release-tools@2.6.2", + "use": "@autorest/typescript@6.0.0-rc.5" +} \ No newline at end of file diff --git a/sdk/loadtestservice/arm-loadtesting/api-extractor.json b/sdk/loadtestservice/arm-loadtesting/api-extractor.json new file mode 100644 index 000000000000..7be38f43f243 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$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-loadtesting.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} \ No newline at end of file diff --git a/sdk/loadtestservice/arm-loadtesting/package.json b/sdk/loadtestservice/arm-loadtesting/package.json new file mode 100644 index 000000000000..c08dc75b1cda --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/package.json @@ -0,0 +1,114 @@ +{ + "name": "@azure/arm-loadtesting", + "sdk-type": "mgmt", + "author": "Microsoft Corporation", + "description": "A generated SDK for LoadTestClient.", + "version": "1.0.0-beta.1", + "engines": { + "node": ">=14.0.0" + }, + "dependencies": { + "@azure/core-lro": "^2.2.0", + "@azure/abort-controller": "^1.0.0", + "@azure/core-paging": "^1.2.0", + "@azure/core-client": "^1.6.1", + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.8.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-loadtesting.d.ts", + "devDependencies": { + "@microsoft/api-extractor": "^7.31.1", + "@rollup/plugin-commonjs": "^21.0.1", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-multi-entry": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.1.3", + "mkdirp": "^1.0.4", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", + "typescript": "~4.8.0", + "uglify-js": "^3.4.9", + "rimraf": "^3.0.0", + "@azure/identity": "^2.0.1", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", + "mocha": "^7.1.1", + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtestservice/arm-loadtesting", + "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": "npm run clean && tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "prepack": "npm run build", + "pack": "npm pack 2>&1", + "extract-api": "api-extractor run --local", + "lint": "echo skipped", + "audit": "echo skipped", + "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "build:node": "echo skipped", + "build:browser": "echo skipped", + "build:test": "echo skipped", + "build:samples": "echo skipped.", + "check-format": "echo skipped", + "execute:samples": "echo skipped", + "format": "echo skipped", + "test": "npm run integration-test", + "test:node": "echo skipped", + "test:browser": "echo skipped", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", + "unit-test:browser": "echo skipped", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" + }, + "sideEffects": false, + "//metadata": { + "constantPaths": [ + { + "path": "src/loadTestClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true +} \ No newline at end of file diff --git a/sdk/loadtestservice/arm-loadtesting/rollup.config.js b/sdk/loadtestservice/arm-loadtesting/rollup.config.js new file mode 100644 index 000000000000..3f89d7309da5 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/rollup.config.js @@ -0,0 +1,122 @@ +/* + * 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"; + +// #region Warning Handler + +/** + * A function that can determine whether a rollup warning should be ignored. If + * the function returns `true`, then the warning will not be displayed. + */ + +function ignoreNiseSinonEval(warning) { + return ( + warning.code === "EVAL" && + warning.id && + (warning.id.includes("node_modules/nise") || + warning.id.includes("node_modules/sinon")) === true + ); +} + +function ignoreChaiCircularDependency(warning) { + return ( + warning.code === "CIRCULAR_DEPENDENCY" && + warning.importer && warning.importer.includes("node_modules/chai") === true + ); +} + +const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval]; + +/** + * 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(), + 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()] + }; + + const config = [baseConfig]; + + if (!options.disableBrowserBundle) { + config.push(makeBrowserTestConfig()); + } + + return config; +} + +export default makeConfig(require("./package.json")); diff --git a/sdk/loadtestservice/arm-loadtesting/sample.env b/sdk/loadtestservice/arm-loadtesting/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/loadtestservice/arm-loadtesting/src/index.ts b/sdk/loadtestservice/arm-loadtesting/src/index.ts new file mode 100644 index 000000000000..3c1afd1c064c --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/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 { getContinuationToken } from "./pagingHelper"; +export * from "./models"; +export { LoadTestClient } from "./loadTestClient"; +export * from "./operationsInterfaces"; diff --git a/sdk/loadtestservice/arm-loadtesting/src/loadTestClient.ts b/sdk/loadtestservice/arm-loadtesting/src/loadTestClient.ts new file mode 100644 index 000000000000..6a54636542cd --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/loadTestClient.ts @@ -0,0 +1,144 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; +import * as coreAuth from "@azure/core-auth"; +import { OperationsImpl, QuotasImpl, LoadTestsImpl } from "./operations"; +import { Operations, Quotas, LoadTests } from "./operationsInterfaces"; +import { LoadTestClientOptionalParams } from "./models"; + +export class LoadTestClient extends coreClient.ServiceClient { + $host: string; + apiVersion: string; + subscriptionId: string; + + /** + * Initializes a new instance of the LoadTestClient class. + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param subscriptionId The ID of the target subscription. + * @param options The parameter options + */ + constructor( + credentials: coreAuth.TokenCredential, + subscriptionId: string, + options?: LoadTestClientOptionalParams + ) { + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + if (subscriptionId === undefined) { + throw new Error("'subscriptionId' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: LoadTestClientOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; + + const packageDetails = `azsdk-js-arm-loadtesting/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; + + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix + }, + endpoint: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" + }; + super(optionsWithDefaults); + + let bearerTokenAuthenticationPolicyFound: boolean = false; + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + // Parameter assignments + this.subscriptionId = subscriptionId; + + // Assigning values to Constant parameters + this.$host = options.$host || "https://management.azure.com"; + this.apiVersion = options.apiVersion || "2022-12-01"; + this.operations = new OperationsImpl(this); + this.quotas = new QuotasImpl(this); + this.loadTests = new LoadTestsImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); + } + + operations: Operations; + quotas: Quotas; + loadTests: LoadTests; +} diff --git a/sdk/loadtestservice/arm-loadtesting/src/lroImpl.ts b/sdk/loadtestservice/arm-loadtesting/src/lroImpl.ts new file mode 100644 index 000000000000..518d5f053b4e --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/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/loadtestservice/arm-loadtesting/src/models/index.ts b/sdk/loadtestservice/arm-loadtesting/src/models/index.ts new file mode 100644 index 000000000000..6ede8df81609 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/models/index.ts @@ -0,0 +1,645 @@ +/* + * 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"; + +/** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */ +export interface OperationListResult { + /** + * List of operations supported by the resource provider + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: Operation[]; + /** + * URL to get the next set of operation list results (if there are any). + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nextLink?: string; +} + +/** Details of a REST API operation, returned from the Resource Provider Operations API */ +export interface Operation { + /** + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly isDataAction?: boolean; + /** Localized display information for this particular operation. */ + display?: OperationDisplay; + /** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly origin?: Origin; + /** + * Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly actionType?: ActionType; +} + +/** Localized display information for this particular operation. */ +export interface OperationDisplay { + /** + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provider?: string; + /** + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly resource?: string; + /** + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly operation?: string; + /** + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly description?: string; +} + +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +/** The error detail. */ +export interface ErrorDetail { + /** + * The error code. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly code?: string; + /** + * The error message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** + * The error target. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly target?: string; + /** + * The error details. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly details?: ErrorDetail[]; + /** + * The error additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** + * The additional info type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * The additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly info?: Record; +} + +/** List of quota bucket objects. It contains a URL link to get the next set of results. */ +export interface QuotaResourceList { + /** + * List of quota bucket objects provided by the loadtestservice. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: QuotaResource[]; + /** + * URL to get the next set of quota bucket objects results (if there are any). + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nextLink?: string; +} + +/** Common fields that are returned in the response for all Azure Resource Manager resources */ +export interface Resource { + /** + * Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The name of the resource + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly systemData?: SystemData; +} + +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemData { + /** The identity that created the resource. */ + createdBy?: string; + /** The type of identity that created the resource. */ + createdByType?: CreatedByType; + /** The timestamp of resource creation (UTC). */ + createdAt?: Date; + /** The identity that last modified the resource. */ + lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + lastModifiedByType?: CreatedByType; + /** The timestamp of resource last modification (UTC) */ + lastModifiedAt?: Date; +} + +/** Dimensions for new quota request. */ +export interface QuotaBucketRequestPropertiesDimensions { + /** Subscription Id dimension for new quota request of the quota bucket. */ + subscriptionId?: string; + /** Location dimension for new quota request of the quota bucket. */ + location?: string; +} + +/** List of resources page result. */ +export interface LoadTestResourcePageList { + /** List of resources in current page. */ + value?: LoadTestResource[]; + /** Link to next page of resources. */ + nextLink?: string; +} + +/** Key and identity details for Customer Managed Key encryption of load test resource */ +export interface EncryptionProperties { + /** All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key Vault. */ + identity?: EncryptionPropertiesIdentity; + /** key encryption key Url, versioned. Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78 or https://contosovault.vault.azure.net/keys/contosokek. */ + keyUrl?: string; +} + +/** All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key Vault. */ +export interface EncryptionPropertiesIdentity { + /** Managed identity type to use for accessing encryption key Url */ + type?: Type; + /** user assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId */ + resourceId?: string; +} + +/** Managed service identity (system assigned and/or user assigned identities) */ +export interface ManagedServiceIdentity { + /** + * The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly principalId?: string; + /** + * The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly tenantId?: string; + /** Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). */ + type: ManagedServiceIdentityType; + /** The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests. */ + userAssignedIdentities?: { + [propertyName: string]: UserAssignedIdentity | null; + }; +} + +/** User assigned identity properties */ +export interface UserAssignedIdentity { + /** + * The principal ID of the assigned identity. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly principalId?: string; + /** + * The client ID of the assigned identity. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly clientId?: string; +} + +/** LoadTest resource patch request body. */ +export interface LoadTestResourcePatchRequestBody { + /** Resource tags. */ + tags?: { [propertyName: string]: string }; + /** The type of identity used for the resource. */ + identity?: ManagedServiceIdentity; + /** Description of the resource. */ + description?: string; + /** CMK Encryption property. */ + encryption?: EncryptionProperties; +} + +/** Values returned by the List operation. */ +export interface OutboundEnvironmentEndpointCollection { + /** + * The collection of outbound network dependency endpoints returned by the listing operation. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: OutboundEnvironmentEndpoint[]; + /** The continuation token. */ + nextLink?: string; +} + +/** A collection of related endpoints from the same service for which the Batch service requires outbound access. */ +export interface OutboundEnvironmentEndpoint { + /** + * The type of service that Azure Load Testing connects to. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly category?: string; + /** + * The endpoints for this service to which the Batch service makes outbound calls. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly endpoints?: EndpointDependency[]; +} + +/** A domain name and connection details used to access a dependency. */ +export interface EndpointDependency { + /** + * The domain name of the dependency. Domain names may be fully qualified or may contain a * wildcard. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly domainName?: string; + /** + * Human-readable supplemental information about the dependency and when it is applicable. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly description?: string; + /** + * The list of connection details for this endpoint. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly endpointDetails?: EndpointDetail[]; +} + +/** Details about the connection between the Batch service and the endpoint. */ +export interface EndpointDetail { + /** + * The port an endpoint is connected to. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly port?: number; +} + +/** Quota bucket details object. */ +export interface QuotaResource extends Resource { + /** Current quota limit of the quota bucket. */ + limit?: number; + /** Current quota usage of the quota bucket. */ + usage?: number; + /** + * Resource provisioning state. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: ResourceState; +} + +/** Request object of new quota for a quota bucket. */ +export interface QuotaBucketRequest extends Resource { + /** Current quota usage of the quota bucket. */ + currentUsage?: number; + /** Current quota limit of the quota bucket. */ + currentQuota?: number; + /** New quota limit of the quota bucket. */ + newQuota?: number; + /** Dimensions for new quota request. */ + dimensions?: QuotaBucketRequestPropertiesDimensions; +} + +/** Check quota availability response object. */ +export interface CheckQuotaAvailabilityResponse extends Resource { + /** True/False indicating whether the quota request be granted based on availability. */ + isAvailable?: boolean; + /** Message indicating additional details to add to quota support request. */ + availabilityStatus?: string; +} + +/** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ +export interface TrackedResource extends Resource { + /** Resource tags. */ + tags?: { [propertyName: string]: string }; + /** The geo-location where the resource lives */ + location: string; +} + +/** LoadTest details */ +export interface LoadTestResource extends TrackedResource { + /** The type of identity used for the resource. */ + identity?: ManagedServiceIdentity; + /** Description of the resource. */ + description?: string; + /** + * Resource provisioning state. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: ResourceState; + /** + * Resource data plane URI. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly dataPlaneURI?: string; + /** CMK Encryption property. */ + encryption?: EncryptionProperties; +} + +/** Defines headers for LoadTests_createOrUpdate operation. */ +export interface LoadTestsCreateOrUpdateHeaders { + /** URL to query for status of the operation. */ + azureAsyncOperation?: string; +} + +/** Defines headers for LoadTests_update operation. */ +export interface LoadTestsUpdateHeaders { + /** URL to query for status of the operation. */ + azureAsyncOperation?: string; +} + +/** Defines headers for LoadTests_delete operation. */ +export interface LoadTestsDeleteHeaders { + /** URL to query for status of the operation. */ + location?: string; +} + +/** Known values of {@link Origin} that the service accepts. */ +export enum KnownOrigin { + /** User */ + User = "user", + /** System */ + System = "system", + /** UserSystem */ + UserSystem = "user,system" +} + +/** + * Defines values for Origin. \ + * {@link KnownOrigin} can be used interchangeably with Origin, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **user** \ + * **system** \ + * **user,system** + */ +export type Origin = string; + +/** Known values of {@link ActionType} that the service accepts. */ +export enum KnownActionType { + /** Internal */ + Internal = "Internal" +} + +/** + * Defines values for ActionType. \ + * {@link KnownActionType} can be used interchangeably with ActionType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Internal** + */ +export type ActionType = string; + +/** Known values of {@link ResourceState} that the service accepts. */ +export enum KnownResourceState { + /** Succeeded */ + Succeeded = "Succeeded", + /** Failed */ + Failed = "Failed", + /** Canceled */ + Canceled = "Canceled", + /** Deleted */ + Deleted = "Deleted" +} + +/** + * Defines values for ResourceState. \ + * {@link KnownResourceState} can be used interchangeably with ResourceState, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **Succeeded** \ + * **Failed** \ + * **Canceled** \ + * **Deleted** + */ +export type ResourceState = string; + +/** Known values of {@link CreatedByType} that the service accepts. */ +export enum KnownCreatedByType { + /** User */ + User = "User", + /** Application */ + Application = "Application", + /** ManagedIdentity */ + ManagedIdentity = "ManagedIdentity", + /** Key */ + Key = "Key" +} + +/** + * Defines values for CreatedByType. \ + * {@link KnownCreatedByType} can be used interchangeably with CreatedByType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **User** \ + * **Application** \ + * **ManagedIdentity** \ + * **Key** + */ +export type CreatedByType = string; + +/** Known values of {@link Type} that the service accepts. */ +export enum KnownType { + /** SystemAssigned */ + SystemAssigned = "SystemAssigned", + /** UserAssigned */ + UserAssigned = "UserAssigned" +} + +/** + * Defines values for Type. \ + * {@link KnownType} can be used interchangeably with Type, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **SystemAssigned** \ + * **UserAssigned** + */ +export type Type = string; + +/** Known values of {@link ManagedServiceIdentityType} that the service accepts. */ +export enum KnownManagedServiceIdentityType { + /** None */ + None = "None", + /** SystemAssigned */ + SystemAssigned = "SystemAssigned", + /** UserAssigned */ + UserAssigned = "UserAssigned", + /** SystemAssignedUserAssigned */ + SystemAssignedUserAssigned = "SystemAssigned,UserAssigned" +} + +/** + * Defines values for ManagedServiceIdentityType. \ + * {@link KnownManagedServiceIdentityType} can be used interchangeably with ManagedServiceIdentityType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **None** \ + * **SystemAssigned** \ + * **UserAssigned** \ + * **SystemAssigned,UserAssigned** + */ +export type ManagedServiceIdentityType = string; + +/** Optional parameters. */ +export interface OperationsListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type OperationsListResponse = OperationListResult; + +/** Optional parameters. */ +export interface OperationsListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type OperationsListNextResponse = OperationListResult; + +/** Optional parameters. */ +export interface QuotasListOptionalParams extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type QuotasListResponse = QuotaResourceList; + +/** Optional parameters. */ +export interface QuotasGetOptionalParams extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type QuotasGetResponse = QuotaResource; + +/** Optional parameters. */ +export interface QuotasCheckAvailabilityOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the checkAvailability operation. */ +export type QuotasCheckAvailabilityResponse = CheckQuotaAvailabilityResponse; + +/** Optional parameters. */ +export interface QuotasListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type QuotasListNextResponse = QuotaResourceList; + +/** Optional parameters. */ +export interface LoadTestsListBySubscriptionOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listBySubscription operation. */ +export type LoadTestsListBySubscriptionResponse = LoadTestResourcePageList; + +/** Optional parameters. */ +export interface LoadTestsListByResourceGroupOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByResourceGroup operation. */ +export type LoadTestsListByResourceGroupResponse = LoadTestResourcePageList; + +/** Optional parameters. */ +export interface LoadTestsGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type LoadTestsGetResponse = LoadTestResource; + +/** Optional parameters. */ +export interface LoadTestsCreateOrUpdateOptionalParams + 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 LoadTestsCreateOrUpdateResponse = LoadTestResource; + +/** Optional parameters. */ +export interface LoadTestsUpdateOptionalParams + 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 LoadTestsUpdateResponse = LoadTestResource; + +/** Optional parameters. */ +export interface LoadTestsDeleteOptionalParams + 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; +} + +/** Optional parameters. */ +export interface LoadTestsListOutboundNetworkDependenciesEndpointsOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listOutboundNetworkDependenciesEndpoints operation. */ +export type LoadTestsListOutboundNetworkDependenciesEndpointsResponse = OutboundEnvironmentEndpointCollection; + +/** Optional parameters. */ +export interface LoadTestsListBySubscriptionNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listBySubscriptionNext operation. */ +export type LoadTestsListBySubscriptionNextResponse = LoadTestResourcePageList; + +/** Optional parameters. */ +export interface LoadTestsListByResourceGroupNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByResourceGroupNext operation. */ +export type LoadTestsListByResourceGroupNextResponse = LoadTestResourcePageList; + +/** Optional parameters. */ +export interface LoadTestsListOutboundNetworkDependenciesEndpointsNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listOutboundNetworkDependenciesEndpointsNext operation. */ +export type LoadTestsListOutboundNetworkDependenciesEndpointsNextResponse = OutboundEnvironmentEndpointCollection; + +/** Optional parameters. */ +export interface LoadTestClientOptionalParams + extends coreClient.ServiceClientOptions { + /** server parameter */ + $host?: string; + /** Api Version */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/loadtestservice/arm-loadtesting/src/models/mappers.ts b/sdk/loadtestservice/arm-loadtesting/src/models/mappers.ts new file mode 100644 index 000000000000..6db038ae0d41 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/models/mappers.ts @@ -0,0 +1,855 @@ +/* + * 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 OperationListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationListResult", + modelProperties: { + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Operation" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const Operation: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Operation", + modelProperties: { + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + isDataAction: { + serializedName: "isDataAction", + readOnly: true, + type: { + name: "Boolean" + } + }, + display: { + serializedName: "display", + type: { + name: "Composite", + className: "OperationDisplay" + } + }, + origin: { + serializedName: "origin", + readOnly: true, + type: { + name: "String" + } + }, + actionType: { + serializedName: "actionType", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const OperationDisplay: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OperationDisplay", + modelProperties: { + provider: { + serializedName: "provider", + readOnly: true, + type: { + name: "String" + } + }, + resource: { + serializedName: "resource", + readOnly: true, + type: { + name: "String" + } + }, + operation: { + serializedName: "operation", + readOnly: true, + type: { + name: "String" + } + }, + description: { + serializedName: "description", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const ErrorResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorDetail" + } + } + } + } +}; + +export const ErrorDetail: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorDetail", + modelProperties: { + code: { + serializedName: "code", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + }, + target: { + serializedName: "target", + readOnly: true, + type: { + name: "String" + } + }, + details: { + serializedName: "details", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorDetail" + } + } + } + }, + additionalInfo: { + serializedName: "additionalInfo", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorAdditionalInfo" + } + } + } + } + } + } +}; + +export const ErrorAdditionalInfo: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorAdditionalInfo", + modelProperties: { + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + info: { + serializedName: "info", + readOnly: true, + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + } + } + } +}; + +export const QuotaResourceList: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaResourceList", + modelProperties: { + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "QuotaResource" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const Resource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Resource", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" + } + } + } + } +}; + +export const SystemData: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SystemData", + modelProperties: { + createdBy: { + serializedName: "createdBy", + type: { + name: "String" + } + }, + createdByType: { + serializedName: "createdByType", + type: { + name: "String" + } + }, + createdAt: { + serializedName: "createdAt", + type: { + name: "DateTime" + } + }, + lastModifiedBy: { + serializedName: "lastModifiedBy", + type: { + name: "String" + } + }, + lastModifiedByType: { + serializedName: "lastModifiedByType", + type: { + name: "String" + } + }, + lastModifiedAt: { + serializedName: "lastModifiedAt", + type: { + name: "DateTime" + } + } + } + } +}; + +export const QuotaBucketRequestPropertiesDimensions: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaBucketRequestPropertiesDimensions", + modelProperties: { + subscriptionId: { + constraints: { + MinLength: 1 + }, + serializedName: "subscriptionId", + type: { + name: "String" + } + }, + location: { + constraints: { + MinLength: 1 + }, + serializedName: "location", + type: { + name: "String" + } + } + } + } +}; + +export const LoadTestResourcePageList: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LoadTestResourcePageList", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "LoadTestResource" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const EncryptionProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "EncryptionProperties", + modelProperties: { + identity: { + serializedName: "identity", + type: { + name: "Composite", + className: "EncryptionPropertiesIdentity" + } + }, + keyUrl: { + serializedName: "keyUrl", + type: { + name: "String" + } + } + } + } +}; + +export const EncryptionPropertiesIdentity: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "EncryptionPropertiesIdentity", + modelProperties: { + type: { + serializedName: "type", + type: { + name: "String" + } + }, + resourceId: { + serializedName: "resourceId", + nullable: true, + type: { + name: "String" + } + } + } + } +}; + +export const ManagedServiceIdentity: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedServiceIdentity", + modelProperties: { + principalId: { + serializedName: "principalId", + readOnly: true, + type: { + name: "Uuid" + } + }, + tenantId: { + serializedName: "tenantId", + readOnly: true, + type: { + name: "Uuid" + } + }, + type: { + serializedName: "type", + required: true, + type: { + name: "String" + } + }, + userAssignedIdentities: { + serializedName: "userAssignedIdentities", + type: { + name: "Dictionary", + value: { + type: { name: "Composite", className: "UserAssignedIdentity" } + } + } + } + } + } +}; + +export const UserAssignedIdentity: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UserAssignedIdentity", + modelProperties: { + principalId: { + serializedName: "principalId", + readOnly: true, + type: { + name: "Uuid" + } + }, + clientId: { + serializedName: "clientId", + readOnly: true, + type: { + name: "Uuid" + } + } + } + } +}; + +export const LoadTestResourcePatchRequestBody: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LoadTestResourcePatchRequestBody", + modelProperties: { + tags: { + serializedName: "tags", + nullable: true, + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + }, + identity: { + serializedName: "identity", + type: { + name: "Composite", + className: "ManagedServiceIdentity" + } + }, + description: { + constraints: { + MaxLength: 512 + }, + serializedName: "properties.description", + type: { + name: "String" + } + }, + encryption: { + serializedName: "properties.encryption", + type: { + name: "Composite", + className: "EncryptionProperties" + } + } + } + } +}; + +export const OutboundEnvironmentEndpointCollection: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OutboundEnvironmentEndpointCollection", + modelProperties: { + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "OutboundEnvironmentEndpoint" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const OutboundEnvironmentEndpoint: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "OutboundEnvironmentEndpoint", + modelProperties: { + category: { + serializedName: "category", + readOnly: true, + type: { + name: "String" + } + }, + endpoints: { + serializedName: "endpoints", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "EndpointDependency" + } + } + } + } + } + } +}; + +export const EndpointDependency: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "EndpointDependency", + modelProperties: { + domainName: { + serializedName: "domainName", + readOnly: true, + type: { + name: "String" + } + }, + description: { + serializedName: "description", + readOnly: true, + type: { + name: "String" + } + }, + endpointDetails: { + serializedName: "endpointDetails", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "EndpointDetail" + } + } + } + } + } + } +}; + +export const EndpointDetail: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "EndpointDetail", + modelProperties: { + port: { + serializedName: "port", + readOnly: true, + type: { + name: "Number" + } + } + } + } +}; + +export const QuotaResource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaResource", + modelProperties: { + ...Resource.type.modelProperties, + limit: { + constraints: { + InclusiveMinimum: 0 + }, + serializedName: "properties.limit", + type: { + name: "Number" + } + }, + usage: { + constraints: { + InclusiveMinimum: 0 + }, + serializedName: "properties.usage", + type: { + name: "Number" + } + }, + provisioningState: { + serializedName: "properties.provisioningState", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const QuotaBucketRequest: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "QuotaBucketRequest", + modelProperties: { + ...Resource.type.modelProperties, + currentUsage: { + constraints: { + InclusiveMinimum: 0 + }, + serializedName: "properties.currentUsage", + type: { + name: "Number" + } + }, + currentQuota: { + constraints: { + InclusiveMinimum: 0 + }, + serializedName: "properties.currentQuota", + type: { + name: "Number" + } + }, + newQuota: { + constraints: { + InclusiveMinimum: 0 + }, + serializedName: "properties.newQuota", + type: { + name: "Number" + } + }, + dimensions: { + serializedName: "properties.dimensions", + type: { + name: "Composite", + className: "QuotaBucketRequestPropertiesDimensions" + } + } + } + } +}; + +export const CheckQuotaAvailabilityResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CheckQuotaAvailabilityResponse", + modelProperties: { + ...Resource.type.modelProperties, + isAvailable: { + serializedName: "properties.isAvailable", + type: { + name: "Boolean" + } + }, + availabilityStatus: { + serializedName: "properties.availabilityStatus", + type: { + name: "String" + } + } + } + } +}; + +export const TrackedResource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TrackedResource", + modelProperties: { + ...Resource.type.modelProperties, + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + }, + location: { + serializedName: "location", + required: true, + type: { + name: "String" + } + } + } + } +}; + +export const LoadTestResource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LoadTestResource", + modelProperties: { + ...TrackedResource.type.modelProperties, + identity: { + serializedName: "identity", + type: { + name: "Composite", + className: "ManagedServiceIdentity" + } + }, + description: { + constraints: { + MaxLength: 512 + }, + serializedName: "properties.description", + type: { + name: "String" + } + }, + provisioningState: { + serializedName: "properties.provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + dataPlaneURI: { + constraints: { + MaxLength: 2083 + }, + serializedName: "properties.dataPlaneURI", + readOnly: true, + type: { + name: "String" + } + }, + encryption: { + serializedName: "properties.encryption", + type: { + name: "Composite", + className: "EncryptionProperties" + } + } + } + } +}; + +export const LoadTestsCreateOrUpdateHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LoadTestsCreateOrUpdateHeaders", + modelProperties: { + azureAsyncOperation: { + serializedName: "azure-asyncoperation", + type: { + name: "String" + } + } + } + } +}; + +export const LoadTestsUpdateHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LoadTestsUpdateHeaders", + modelProperties: { + azureAsyncOperation: { + serializedName: "azure-asyncoperation", + type: { + name: "String" + } + } + } + } +}; + +export const LoadTestsDeleteHeaders: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "LoadTestsDeleteHeaders", + modelProperties: { + location: { + serializedName: "location", + type: { + name: "String" + } + } + } + } +}; diff --git a/sdk/loadtestservice/arm-loadtesting/src/models/parameters.ts b/sdk/loadtestservice/arm-loadtesting/src/models/parameters.ts new file mode 100644 index 000000000000..2e74e8860d2f --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/models/parameters.ts @@ -0,0 +1,158 @@ +/* + * 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 { + QuotaBucketRequest as QuotaBucketRequestMapper, + LoadTestResource as LoadTestResourceMapper, + LoadTestResourcePatchRequestBody as LoadTestResourcePatchRequestBodyMapper +} 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 apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2022-12-01", + isConstant: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const subscriptionId: OperationURLParameter = { + parameterPath: "subscriptionId", + mapper: { + constraints: { + MinLength: 1 + }, + serializedName: "subscriptionId", + required: true, + type: { + name: "String" + } + } +}; + +export const location: OperationURLParameter = { + parameterPath: "location", + mapper: { + constraints: { + MinLength: 1 + }, + serializedName: "location", + required: true, + type: { + name: "String" + } + } +}; + +export const quotaBucketName: OperationURLParameter = { + parameterPath: "quotaBucketName", + mapper: { + serializedName: "quotaBucketName", + required: true, + type: { + name: "String" + } + } +}; + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String" + } + } +}; + +export const quotaBucketRequest: OperationParameter = { + parameterPath: "quotaBucketRequest", + mapper: QuotaBucketRequestMapper +}; + +export const resourceGroupName: OperationURLParameter = { + parameterPath: "resourceGroupName", + mapper: { + constraints: { + MaxLength: 90, + MinLength: 1 + }, + serializedName: "resourceGroupName", + required: true, + type: { + name: "String" + } + } +}; + +export const loadTestName: OperationURLParameter = { + parameterPath: "loadTestName", + mapper: { + serializedName: "loadTestName", + required: true, + type: { + name: "String" + } + } +}; + +export const loadTestResource: OperationParameter = { + parameterPath: "loadTestResource", + mapper: LoadTestResourceMapper +}; + +export const loadTestResourcePatchRequestBody: OperationParameter = { + parameterPath: "loadTestResourcePatchRequestBody", + mapper: LoadTestResourcePatchRequestBodyMapper +}; diff --git a/sdk/loadtestservice/arm-loadtesting/src/operations/index.ts b/sdk/loadtestservice/arm-loadtesting/src/operations/index.ts new file mode 100644 index 000000000000..a132021589c9 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/operations/index.ts @@ -0,0 +1,11 @@ +/* + * 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 "./operations"; +export * from "./quotas"; +export * from "./loadTests"; diff --git a/sdk/loadtestservice/arm-loadtesting/src/operations/loadTests.ts b/sdk/loadtestservice/arm-loadtesting/src/operations/loadTests.ts new file mode 100644 index 000000000000..10326d0ad36b --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/operations/loadTests.ts @@ -0,0 +1,884 @@ +/* + * 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, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { LoadTests } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { LoadTestClient } from "../loadTestClient"; +import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; +import { LroImpl } from "../lroImpl"; +import { + LoadTestResource, + LoadTestsListBySubscriptionNextOptionalParams, + LoadTestsListBySubscriptionOptionalParams, + LoadTestsListBySubscriptionResponse, + LoadTestsListByResourceGroupNextOptionalParams, + LoadTestsListByResourceGroupOptionalParams, + LoadTestsListByResourceGroupResponse, + OutboundEnvironmentEndpoint, + LoadTestsListOutboundNetworkDependenciesEndpointsNextOptionalParams, + LoadTestsListOutboundNetworkDependenciesEndpointsOptionalParams, + LoadTestsListOutboundNetworkDependenciesEndpointsResponse, + LoadTestsGetOptionalParams, + LoadTestsGetResponse, + LoadTestsCreateOrUpdateOptionalParams, + LoadTestsCreateOrUpdateResponse, + LoadTestResourcePatchRequestBody, + LoadTestsUpdateOptionalParams, + LoadTestsUpdateResponse, + LoadTestsDeleteOptionalParams, + LoadTestsListBySubscriptionNextResponse, + LoadTestsListByResourceGroupNextResponse, + LoadTestsListOutboundNetworkDependenciesEndpointsNextResponse +} from "../models"; + +/// +/** Class containing LoadTests operations. */ +export class LoadTestsImpl implements LoadTests { + private readonly client: LoadTestClient; + + /** + * Initialize a new instance of the class LoadTests class. + * @param client Reference to the service client + */ + constructor(client: LoadTestClient) { + this.client = client; + } + + /** + * Lists loadtests resources in a subscription. + * @param options The options parameters. + */ + public listBySubscription( + options?: LoadTestsListBySubscriptionOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listBySubscriptionPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listBySubscriptionPagingPage(options, settings); + } + }; + } + + private async *listBySubscriptionPagingPage( + options?: LoadTestsListBySubscriptionOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: LoadTestsListBySubscriptionResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listBySubscription(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listBySubscriptionNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listBySubscriptionPagingAll( + options?: LoadTestsListBySubscriptionOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listBySubscriptionPagingPage(options)) { + yield* page; + } + } + + /** + * Lists loadtest resources in a resource group. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + public listByResourceGroup( + resourceGroupName: string, + options?: LoadTestsListByResourceGroupOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listByResourceGroupPagingAll(resourceGroupName, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); + } + }; + } + + private async *listByResourceGroupPagingPage( + resourceGroupName: string, + options?: LoadTestsListByResourceGroupOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: LoadTestsListByResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listByResourceGroupNext( + resourceGroupName, + continuationToken, + options + ); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listByResourceGroupPagingAll( + resourceGroupName: string, + options?: LoadTestsListByResourceGroupOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listByResourceGroupPagingPage( + resourceGroupName, + options + )) { + yield* page; + } + } + + /** + * Lists the endpoints that agents may call as part of load testing. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param options The options parameters. + */ + public listOutboundNetworkDependenciesEndpoints( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsListOutboundNetworkDependenciesEndpointsOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listOutboundNetworkDependenciesEndpointsPagingAll( + resourceGroupName, + loadTestName, + options + ); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listOutboundNetworkDependenciesEndpointsPagingPage( + resourceGroupName, + loadTestName, + options, + settings + ); + } + }; + } + + private async *listOutboundNetworkDependenciesEndpointsPagingPage( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsListOutboundNetworkDependenciesEndpointsOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: LoadTestsListOutboundNetworkDependenciesEndpointsResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listOutboundNetworkDependenciesEndpoints( + resourceGroupName, + loadTestName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listOutboundNetworkDependenciesEndpointsNext( + resourceGroupName, + loadTestName, + continuationToken, + options + ); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listOutboundNetworkDependenciesEndpointsPagingAll( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsListOutboundNetworkDependenciesEndpointsOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listOutboundNetworkDependenciesEndpointsPagingPage( + resourceGroupName, + loadTestName, + options + )) { + yield* page; + } + } + + /** + * Lists loadtests resources in a subscription. + * @param options The options parameters. + */ + private _listBySubscription( + options?: LoadTestsListBySubscriptionOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { options }, + listBySubscriptionOperationSpec + ); + } + + /** + * Lists loadtest resources in a resource group. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + private _listByResourceGroup( + resourceGroupName: string, + options?: LoadTestsListByResourceGroupOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, options }, + listByResourceGroupOperationSpec + ); + } + + /** + * Get a LoadTest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, loadTestName, options }, + getOperationSpec + ); + } + + /** + * Create or update LoadTest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data + * @param options The options parameters. + */ + async beginCreateOrUpdate( + resourceGroupName: string, + loadTestName: string, + loadTestResource: LoadTestResource, + options?: LoadTestsCreateOrUpdateOptionalParams + ): Promise< + PollerLike< + PollOperationState, + LoadTestsCreateOrUpdateResponse + > + > { + 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, + { resourceGroupName, loadTestName, loadTestResource, options }, + createOrUpdateOperationSpec + ); + const poller = new LroEngine(lro, { + resumeFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + lroResourceLocationConfig: "azure-async-operation" + }); + await poller.poll(); + return poller; + } + + /** + * Create or update LoadTest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data + * @param options The options parameters. + */ + async beginCreateOrUpdateAndWait( + resourceGroupName: string, + loadTestName: string, + loadTestResource: LoadTestResource, + options?: LoadTestsCreateOrUpdateOptionalParams + ): Promise { + const poller = await this.beginCreateOrUpdate( + resourceGroupName, + loadTestName, + loadTestResource, + options + ); + return poller.pollUntilDone(); + } + + /** + * Update a loadtest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data + * @param options The options parameters. + */ + async beginUpdate( + resourceGroupName: string, + loadTestName: string, + loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody, + options?: LoadTestsUpdateOptionalParams + ): Promise< + PollerLike< + PollOperationState, + LoadTestsUpdateResponse + > + > { + 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, + { + resourceGroupName, + loadTestName, + loadTestResourcePatchRequestBody, + options + }, + updateOperationSpec + ); + const poller = new LroEngine(lro, { + resumeFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + lroResourceLocationConfig: "azure-async-operation" + }); + await poller.poll(); + return poller; + } + + /** + * Update a loadtest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data + * @param options The options parameters. + */ + async beginUpdateAndWait( + resourceGroupName: string, + loadTestName: string, + loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody, + options?: LoadTestsUpdateOptionalParams + ): Promise { + const poller = await this.beginUpdate( + resourceGroupName, + loadTestName, + loadTestResourcePatchRequestBody, + options + ); + return poller.pollUntilDone(); + } + + /** + * Delete a LoadTest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param options The options parameters. + */ + async beginDelete( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsDeleteOptionalParams + ): Promise, void>> { + 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, + { resourceGroupName, loadTestName, options }, + deleteOperationSpec + ); + const poller = new LroEngine(lro, { + resumeFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + lroResourceLocationConfig: "location" + }); + await poller.poll(); + return poller; + } + + /** + * Delete a LoadTest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param options The options parameters. + */ + async beginDeleteAndWait( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsDeleteOptionalParams + ): Promise { + const poller = await this.beginDelete( + resourceGroupName, + loadTestName, + options + ); + return poller.pollUntilDone(); + } + + /** + * Lists the endpoints that agents may call as part of load testing. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param options The options parameters. + */ + private _listOutboundNetworkDependenciesEndpoints( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsListOutboundNetworkDependenciesEndpointsOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, loadTestName, options }, + listOutboundNetworkDependenciesEndpointsOperationSpec + ); + } + + /** + * ListBySubscriptionNext + * @param nextLink The nextLink from the previous successful call to the ListBySubscription method. + * @param options The options parameters. + */ + private _listBySubscriptionNext( + nextLink: string, + options?: LoadTestsListBySubscriptionNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listBySubscriptionNextOperationSpec + ); + } + + /** + * ListByResourceGroupNext + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method. + * @param options The options parameters. + */ + private _listByResourceGroupNext( + resourceGroupName: string, + nextLink: string, + options?: LoadTestsListByResourceGroupNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, nextLink, options }, + listByResourceGroupNextOperationSpec + ); + } + + /** + * ListOutboundNetworkDependenciesEndpointsNext + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param nextLink The nextLink from the previous successful call to the + * ListOutboundNetworkDependenciesEndpoints method. + * @param options The options parameters. + */ + private _listOutboundNetworkDependenciesEndpointsNext( + resourceGroupName: string, + loadTestName: string, + nextLink: string, + options?: LoadTestsListOutboundNetworkDependenciesEndpointsNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, loadTestName, nextLink, options }, + listOutboundNetworkDependenciesEndpointsNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listBySubscriptionOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/loadTests", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.LoadTestResourcePageList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer +}; +const listByResourceGroupOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.LoadTestResourcePageList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName + ], + headerParameters: [Parameters.accept], + serializer +}; +const getOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.LoadTestResource + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.loadTestName + ], + headerParameters: [Parameters.accept], + serializer +}; +const createOrUpdateOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.LoadTestResource + }, + 201: { + bodyMapper: Mappers.LoadTestResource + }, + 202: { + bodyMapper: Mappers.LoadTestResource + }, + 204: { + bodyMapper: Mappers.LoadTestResource + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.loadTestResource, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.loadTestName + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const updateOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}", + httpMethod: "PATCH", + responses: { + 200: { + bodyMapper: Mappers.LoadTestResource + }, + 201: { + bodyMapper: Mappers.LoadTestResource + }, + 202: { + bodyMapper: Mappers.LoadTestResource + }, + 204: { + bodyMapper: Mappers.LoadTestResource + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.loadTestResourcePatchRequestBody, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.loadTestName + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const deleteOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}", + httpMethod: "DELETE", + responses: { + 200: {}, + 201: {}, + 202: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.loadTestName + ], + headerParameters: [Parameters.accept], + serializer +}; +const listOutboundNetworkDependenciesEndpointsOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}/outboundNetworkDependenciesEndpoints", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OutboundEnvironmentEndpointCollection + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.loadTestName + ], + headerParameters: [Parameters.accept], + serializer +}; +const listBySubscriptionNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.LoadTestResourcePageList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId + ], + headerParameters: [Parameters.accept], + serializer +}; +const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.LoadTestResourcePageList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId, + Parameters.resourceGroupName + ], + headerParameters: [Parameters.accept], + serializer +}; +const listOutboundNetworkDependenciesEndpointsNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OutboundEnvironmentEndpointCollection + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.loadTestName + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/loadtestservice/arm-loadtesting/src/operations/operations.ts b/sdk/loadtestservice/arm-loadtesting/src/operations/operations.ts new file mode 100644 index 000000000000..c3ce77c59291 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/operations/operations.ts @@ -0,0 +1,149 @@ +/* + * 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, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { Operations } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { LoadTestClient } from "../loadTestClient"; +import { + Operation, + OperationsListNextOptionalParams, + OperationsListOptionalParams, + OperationsListResponse, + OperationsListNextResponse +} from "../models"; + +/// +/** Class containing Operations operations. */ +export class OperationsImpl implements Operations { + private readonly client: LoadTestClient; + + /** + * Initialize a new instance of the class Operations class. + * @param client Reference to the service client + */ + constructor(client: LoadTestClient) { + this.client = client; + } + + /** + * Lists all the available API operations for Load Test Resource. + * @param options The options parameters. + */ + public list( + options?: OperationsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); + } + }; + } + + private async *listPagingPage( + options?: OperationsListOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: OperationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listPagingAll( + options?: OperationsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + + /** + * Lists all the available API operations for Load Test Resource. + * @param options The options parameters. + */ + private _list( + options?: OperationsListOptionalParams + ): 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?: OperationsListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/providers/Microsoft.LoadTestService/operations", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/loadtestservice/arm-loadtesting/src/operations/quotas.ts b/sdk/loadtestservice/arm-loadtesting/src/operations/quotas.ts new file mode 100644 index 000000000000..fdf57d63ef2e --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/operations/quotas.ts @@ -0,0 +1,257 @@ +/* + * 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, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { Quotas } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { LoadTestClient } from "../loadTestClient"; +import { + QuotaResource, + QuotasListNextOptionalParams, + QuotasListOptionalParams, + QuotasListResponse, + QuotasGetOptionalParams, + QuotasGetResponse, + QuotaBucketRequest, + QuotasCheckAvailabilityOptionalParams, + QuotasCheckAvailabilityResponse, + QuotasListNextResponse +} from "../models"; + +/// +/** Class containing Quotas operations. */ +export class QuotasImpl implements Quotas { + private readonly client: LoadTestClient; + + /** + * Initialize a new instance of the class Quotas class. + * @param client Reference to the service client + */ + constructor(client: LoadTestClient) { + this.client = client; + } + + /** + * Lists all the available quota per region per subscription. + * @param location The name of Azure region. + * @param options The options parameters. + */ + public list( + location: string, + options?: QuotasListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(location, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(location, options, settings); + } + }; + } + + private async *listPagingPage( + location: string, + options?: QuotasListOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: QuotasListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(location, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listNext(location, continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listPagingAll( + location: string, + options?: QuotasListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(location, options)) { + yield* page; + } + } + + /** + * Lists all the available quota per region per subscription. + * @param location The name of Azure region. + * @param options The options parameters. + */ + private _list( + location: string, + options?: QuotasListOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { location, options }, + listOperationSpec + ); + } + + /** + * Get the available quota for a quota bucket per region per subscription. + * @param location The name of Azure region. + * @param quotaBucketName Quota Bucket name. + * @param options The options parameters. + */ + get( + location: string, + quotaBucketName: string, + options?: QuotasGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { location, quotaBucketName, options }, + getOperationSpec + ); + } + + /** + * Check Quota Availability on quota bucket per region per subscription. + * @param location The name of Azure region. + * @param quotaBucketName Quota Bucket name. + * @param quotaBucketRequest Quota Bucket Request data + * @param options The options parameters. + */ + checkAvailability( + location: string, + quotaBucketName: string, + quotaBucketRequest: QuotaBucketRequest, + options?: QuotasCheckAvailabilityOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { location, quotaBucketName, quotaBucketRequest, options }, + checkAvailabilityOperationSpec + ); + } + + /** + * ListNext + * @param location The name of Azure region. + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + location: string, + nextLink: string, + options?: QuotasListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { location, nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.QuotaResourceList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.location + ], + headerParameters: [Parameters.accept], + serializer +}; +const getOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas/{quotaBucketName}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.QuotaResource + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.location, + Parameters.quotaBucketName + ], + headerParameters: [Parameters.accept], + serializer +}; +const checkAvailabilityOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas/{quotaBucketName}/checkAvailability", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.CheckQuotaAvailabilityResponse + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.quotaBucketRequest, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.location, + Parameters.quotaBucketName + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.QuotaResourceList + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [ + Parameters.$host, + Parameters.nextLink, + Parameters.subscriptionId, + Parameters.location + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/index.ts b/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/index.ts new file mode 100644 index 000000000000..a132021589c9 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/index.ts @@ -0,0 +1,11 @@ +/* + * 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 "./operations"; +export * from "./quotas"; +export * from "./loadTests"; diff --git a/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/loadTests.ts b/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/loadTests.ts new file mode 100644 index 000000000000..cf8b423855e2 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/loadTests.ts @@ -0,0 +1,152 @@ +/* + * 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 { + LoadTestResource, + LoadTestsListBySubscriptionOptionalParams, + LoadTestsListByResourceGroupOptionalParams, + OutboundEnvironmentEndpoint, + LoadTestsListOutboundNetworkDependenciesEndpointsOptionalParams, + LoadTestsGetOptionalParams, + LoadTestsGetResponse, + LoadTestsCreateOrUpdateOptionalParams, + LoadTestsCreateOrUpdateResponse, + LoadTestResourcePatchRequestBody, + LoadTestsUpdateOptionalParams, + LoadTestsUpdateResponse, + LoadTestsDeleteOptionalParams +} from "../models"; + +/// +/** Interface representing a LoadTests. */ +export interface LoadTests { + /** + * Lists loadtests resources in a subscription. + * @param options The options parameters. + */ + listBySubscription( + options?: LoadTestsListBySubscriptionOptionalParams + ): PagedAsyncIterableIterator; + /** + * Lists loadtest resources in a resource group. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param options The options parameters. + */ + listByResourceGroup( + resourceGroupName: string, + options?: LoadTestsListByResourceGroupOptionalParams + ): PagedAsyncIterableIterator; + /** + * Lists the endpoints that agents may call as part of load testing. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param options The options parameters. + */ + listOutboundNetworkDependenciesEndpoints( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsListOutboundNetworkDependenciesEndpointsOptionalParams + ): PagedAsyncIterableIterator; + /** + * Get a LoadTest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsGetOptionalParams + ): Promise; + /** + * Create or update LoadTest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data + * @param options The options parameters. + */ + beginCreateOrUpdate( + resourceGroupName: string, + loadTestName: string, + loadTestResource: LoadTestResource, + options?: LoadTestsCreateOrUpdateOptionalParams + ): Promise< + PollerLike< + PollOperationState, + LoadTestsCreateOrUpdateResponse + > + >; + /** + * Create or update LoadTest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResource LoadTest resource data + * @param options The options parameters. + */ + beginCreateOrUpdateAndWait( + resourceGroupName: string, + loadTestName: string, + loadTestResource: LoadTestResource, + options?: LoadTestsCreateOrUpdateOptionalParams + ): Promise; + /** + * Update a loadtest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data + * @param options The options parameters. + */ + beginUpdate( + resourceGroupName: string, + loadTestName: string, + loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody, + options?: LoadTestsUpdateOptionalParams + ): Promise< + PollerLike< + PollOperationState, + LoadTestsUpdateResponse + > + >; + /** + * Update a loadtest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param loadTestResourcePatchRequestBody LoadTest resource update data + * @param options The options parameters. + */ + beginUpdateAndWait( + resourceGroupName: string, + loadTestName: string, + loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody, + options?: LoadTestsUpdateOptionalParams + ): Promise; + /** + * Delete a LoadTest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param options The options parameters. + */ + beginDelete( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsDeleteOptionalParams + ): Promise, void>>; + /** + * Delete a LoadTest resource. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param loadTestName Load Test name. + * @param options The options parameters. + */ + beginDeleteAndWait( + resourceGroupName: string, + loadTestName: string, + options?: LoadTestsDeleteOptionalParams + ): Promise; +} diff --git a/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/operations.ts b/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/operations.ts new file mode 100644 index 000000000000..c9afaa2566ad --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/operations.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Operation, OperationsListOptionalParams } from "../models"; + +/// +/** Interface representing a Operations. */ +export interface Operations { + /** + * Lists all the available API operations for Load Test Resource. + * @param options The options parameters. + */ + list( + options?: OperationsListOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/quotas.ts b/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/quotas.ts new file mode 100644 index 000000000000..8d0b8c3f4fdf --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/operationsInterfaces/quotas.ts @@ -0,0 +1,56 @@ +/* + * 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 { + QuotaResource, + QuotasListOptionalParams, + QuotasGetOptionalParams, + QuotasGetResponse, + QuotaBucketRequest, + QuotasCheckAvailabilityOptionalParams, + QuotasCheckAvailabilityResponse +} from "../models"; + +/// +/** Interface representing a Quotas. */ +export interface Quotas { + /** + * Lists all the available quota per region per subscription. + * @param location The name of Azure region. + * @param options The options parameters. + */ + list( + location: string, + options?: QuotasListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Get the available quota for a quota bucket per region per subscription. + * @param location The name of Azure region. + * @param quotaBucketName Quota Bucket name. + * @param options The options parameters. + */ + get( + location: string, + quotaBucketName: string, + options?: QuotasGetOptionalParams + ): Promise; + /** + * Check Quota Availability on quota bucket per region per subscription. + * @param location The name of Azure region. + * @param quotaBucketName Quota Bucket name. + * @param quotaBucketRequest Quota Bucket Request data + * @param options The options parameters. + */ + checkAvailability( + location: string, + quotaBucketName: string, + quotaBucketRequest: QuotaBucketRequest, + options?: QuotasCheckAvailabilityOptionalParams + ): Promise; +} diff --git a/sdk/loadtestservice/arm-loadtesting/src/pagingHelper.ts b/sdk/loadtestservice/arm-loadtesting/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * 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 interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/loadtestservice/arm-loadtesting/test/sampleTest.ts b/sdk/loadtestservice/arm-loadtesting/test/sampleTest.ts new file mode 100644 index 000000000000..25aeb3ebcc36 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/test/sampleTest.ts @@ -0,0 +1,43 @@ +/* + * 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 { + Recorder, + RecorderStartOptions, + env +} from "@azure-tools/test-recorder"; +import { assert } from "chai"; +import { Context } from "mocha"; + +const replaceableVariables: Record = { + 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" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables +}; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("sample test", async function() { + console.log("Hi, I'm a test!"); + }); +}); diff --git a/sdk/loadtestservice/arm-loadtesting/tsconfig.json b/sdk/loadtestservice/arm-loadtesting/tsconfig.json new file mode 100644 index 000000000000..3e6ae96443f3 --- /dev/null +++ b/sdk/loadtestservice/arm-loadtesting/tsconfig.json @@ -0,0 +1,27 @@ +{ + "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" + ] +} \ No newline at end of file diff --git a/sdk/loadtestservice/ci.mgmt.yml b/sdk/loadtestservice/ci.mgmt.yml new file mode 100644 index 000000000000..b761eb5d5ad5 --- /dev/null +++ b/sdk/loadtestservice/ci.mgmt.yml @@ -0,0 +1,38 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/loadtestservice/arm-loadtesting + - sdk/loadtestservice/ci.mgmt.yml + +pr: + branches: + include: + - main + - feature/* + - release/* + - hotfix/* + exclude: + - feature/v4 + paths: + include: + - sdk/loadtestservice/arm-loadtesting + - sdk/loadtestservice/ci.mgmt.yml + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: loadtestservice + Artifacts: + - name: azure-arm-loadtesting + safeName: azurearmloadtesting + \ No newline at end of file