diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 443332ef0963..95f39370c160 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -2945,7 +2945,7 @@ packages: version: 0.0.0 '@rush-temp/arm-loadtesting@file:projects/arm-loadtesting.tgz': - resolution: {integrity: sha512-APYitAkRNU0Wu/we2Xiy3MTlgzX1saAEWnmxvdDPzYZnO9JAO1BQ7os0eefxI2TkDS+iNwMcDgJRRQPWZyhd+A==, tarball: file:projects/arm-loadtesting.tgz} + resolution: {integrity: sha512-dVE6J5DxrxSGaCntlbKXqnV38fliA7W2/wcSvPXpMCEO5sjlur+M1xcKyz4MpE7J/8AmOvhtGQac3cFhR+ya0A==, tarball: file:projects/arm-loadtesting.tgz} version: 0.0.0 '@rush-temp/arm-locks-profile-2020-09-01-hybrid@file:projects/arm-locks-profile-2020-09-01-hybrid.tgz': @@ -13821,11 +13821,11 @@ snapshots: '@rush-temp/arm-loadtesting@file:projects/arm-loadtesting.tgz(@types/debug@4.1.12)(tsx@4.19.3)(vite@6.2.6(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.1))(yaml@2.7.1)': dependencies: - '@azure/core-lro': 2.7.2 '@types/node': 18.19.86 '@vitest/browser': 3.1.1(playwright@1.51.1)(vite@6.2.6(@types/node@22.7.9)(tsx@4.19.3)(yaml@2.7.1))(vitest@3.1.1) '@vitest/coverage-istanbul': 3.1.1(vitest@3.1.1) dotenv: 16.5.0 + eslint: 9.24.0 playwright: 1.51.1 tslib: 2.8.1 typescript: 5.8.3 diff --git a/sdk/loadtesting/arm-loadtesting/CHANGELOG.md b/sdk/loadtesting/arm-loadtesting/CHANGELOG.md index 797311db57c7..4a9577e2b4e3 100644 --- a/sdk/loadtesting/arm-loadtesting/CHANGELOG.md +++ b/sdk/loadtesting/arm-loadtesting/CHANGELOG.md @@ -1,15 +1,77 @@ # Release History - -## 1.0.1 (Unreleased) - + +## 2.0.0-beta.1 (2025-04-17) +Compared with version 1.0.0 + ### Features Added -### Breaking Changes + - Added Interface CheckAvailabilityQuotaOptionalParams + - Added Interface CheckQuotaAvailabilityResponseProperties + - Added Interface CreateOrUpdateLoadtestOptionalParams + - Added Interface DeleteLoadtestOptionalParams + - Added Interface GetLoadtestOptionalParams + - Added Interface GetQuotaOptionalParams + - Added Interface ListByResourceGroupOptionalParams + - Added Interface ListBySubscriptionOptionalParams + - Added Interface ListQuotaOptionalParams + - Added Interface LoadTestMgmtClientOptionalParams + - Added Interface LoadTestProperties + - Added Interface LoadTestResourceUpdate + - Added Interface LoadTestResourceUpdateProperties + - Added Interface OutboundNetworkDependenciesEndpointsOptionalParams + - Added Interface PagedAsyncIterableIterator + - Added Interface PageSettings + - Added Interface ProxyResource + - Added Interface QuotaBucketRequestProperties + - Added Interface QuotaResourceProperties + - Added Interface RestorePollerOptions + - Added Interface UpdateLoadtestOptionalParams + - Added Class LoadTestMgmtClient + - Added Type Alias ContinuablePage + - Interface CheckQuotaAvailabilityResponse has a new optional parameter name + - Interface CheckQuotaAvailabilityResponse has a new optional parameter properties + - Interface CheckQuotaAvailabilityResponse has a new optional parameter systemData + - Interface LoadTestResource has a new optional parameter properties + - Interface QuotaBucketRequest has a new optional parameter properties + - Interface QuotaResource has a new optional parameter properties + - Type of parameter resourceId of interface EncryptionPropertiesIdentity is changed from string to string | null + - Added Enum KnownAPIVersions + - Added function restorePoller -### Bugs Fixed - -### Other Changes +### Breaking Changes + - Removed operation group LoadTests + - Removed operation group Operations + - Removed operation group Quotas + - Deleted Class LoadTestClient + - Interface CheckQuotaAvailabilityResponse no longer has parameter availabilityStatus + - Interface CheckQuotaAvailabilityResponse no longer has parameter isAvailable + - Interface LoadTestResource no longer has parameter dataPlaneURI + - Interface LoadTestResource no longer has parameter description + - Interface LoadTestResource no longer has parameter encryption + - Interface LoadTestResource no longer has parameter provisioningState + - Interface QuotaBucketRequest no longer has parameter currentQuota + - Interface QuotaBucketRequest no longer has parameter currentUsage + - Interface QuotaBucketRequest no longer has parameter dimensions + - Interface QuotaBucketRequest no longer has parameter newQuota + - Interface QuotaResource no longer has parameter limit + - Interface QuotaResource no longer has parameter provisioningState + - Interface QuotaResource no longer has parameter usage + - Interface CheckQuotaAvailabilityResponse has a new required parameter id + - Interface CheckQuotaAvailabilityResponse has a new required parameter type + - Parameter domainName of interface EndpointDependency is now required + - Type of parameter info of interface ErrorAdditionalInfo is changed from Record to Record + - Type of parameter userAssignedIdentities of interface ManagedServiceIdentity is changed from { + [propertyName: string]: UserAssignedIdentity | null; + } to Record + - Type of parameter tags of interface TrackedResource is changed from { + [propertyName: string]: string; + } to Record + - Removed Enum KnownActionType + - Removed Enum KnownOrigin + - Removed function getContinuationToken + + ## 1.0.0 (2023-01-28) -The package of @azure/arm-loadtesting is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/js/mgmt/quickstart ). +The package of @azure/arm-loadtesting is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/js/mgmt/quickstart). diff --git a/sdk/loadtesting/arm-loadtesting/LICENSE b/sdk/loadtesting/arm-loadtesting/LICENSE index b2f52a2bad4e..63447fd8bbbf 100644 --- a/sdk/loadtesting/arm-loadtesting/LICENSE +++ b/sdk/loadtesting/arm-loadtesting/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/sdk/loadtesting/arm-loadtesting/README.md b/sdk/loadtesting/arm-loadtesting/README.md index ff00301e03a1..1711871d8127 100644 --- a/sdk/loadtesting/arm-loadtesting/README.md +++ b/sdk/loadtesting/arm-loadtesting/README.md @@ -4,10 +4,12 @@ This package contains an isomorphic SDK (runs both in Node.js and in browsers) f 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/loadtesting/arm-loadtesting) | -[Package (NPM)](https://www.npmjs.com/package/@azure/arm-loadtesting) | -[API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-loadtesting) | -[Samples](https://github.com/Azure-Samples/azure-samples-js-management) +Key links: + +- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/arm-loadtesting) +- [Package (NPM)](https://www.npmjs.com/package/@azure/arm-loadtesting) +- [API reference documentation](https://learn.microsoft.com/javascript/api/@azure/arm-loadtesting?view=azure-node-preview) +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/arm-loadtesting/samples) ## Getting started @@ -30,7 +32,7 @@ Install the Azure LoadTest client library for JavaScript with `npm`: npm install @azure/arm-loadtesting ``` -### Create and authenticate a `LoadTestClient` +### Create and authenticate a `LoadTestServiceClient` 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]. @@ -44,168 +46,41 @@ 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://learn.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). Using Node.js and Node-like environments, you can use the `DefaultAzureCredential` class to authenticate the client. ```ts snippet:ReadmeSampleCreateClient_Node -import { LoadTestClient } from "@azure/arm-loadtesting"; +import { LoadTestServiceClient } from "@azure/arm-loadtesting"; import { DefaultAzureCredential } from "@azure/identity"; const subscriptionId = "00000000-0000-0000-0000-000000000000"; -const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); +const client = new LoadTestServiceClient(new DefaultAzureCredential(), subscriptionId); ``` For browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate. ```ts snippet:ReadmeSampleCreateClient_Browser import { InteractiveBrowserCredential } from "@azure/identity"; -import { LoadTestClient } from "@azure/arm-loadtesting"; +import { LoadTestServiceClient } from "@azure/arm-loadtesting"; -const subscriptionId = "00000000-0000-0000-0000-000000000000"; const credential = new InteractiveBrowserCredential({ tenantId: "", - clientId: "", -}); -const client = new LoadTestClient(credential, subscriptionId); -``` - -### Create an Azure Load Testing resource - -Create a new Azure Load Testing resource. - -```ts snippet:ReadmeSampleCreateLoadTestResource -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; - -const subscriptionId = "00000000-0000-0000-0000-000000000000"; -const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); - -const loadTestResourceCreatePayload = { - location: "westus2", -}; - -const resource = await client.loadTests.beginCreateOrUpdateAndWait( - "sample-rg", - "sample-loadtesting-resource", - loadTestResourceCreatePayload, -); -``` - -Create a new Azure Load Testing resource with managed identity and customer managed key encryption. - -```ts snippet:ReadmeSampleCreateLoadTestResourceWithManagedIdentityAndCMKEncryption -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; - -const subscriptionId = "00000000-0000-0000-0000-000000000000"; -const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); - -const loadTestResourceCreatePayload = { - location: "westus2", - tags: { team: "testing" }, - identity: { - type: "SystemAssigned, UserAssigned", - userAssignedIdentities: { - "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity1": - {}, - }, - }, - encryption: { - identity: { - type: "UserAssigned", - resourceId: - "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity1", - }, - keyUrl: "https://sample-kv.vault.azure.net/keys/cmkkey/2d1ccd5c50234ea2a0858fe148b69cde", - }, -}; - -const resource = await client.loadTests.beginCreateOrUpdateAndWait( - "sample-rg", - "sample-loadtesting-resource", - loadTestResourceCreatePayload, -); -``` - -### Get an Azure Load Testing resource - -```ts snippet:ReadmeSampleGetLoadTestResource -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; - -const subscriptionId = "00000000-0000-0000-0000-000000000000"; -const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); - -const resourceName = "sample-loadtesting-resource"; -const resourceGroupName = "sample-rg"; - -const resource = await client.loadTests.get(resourceGroupName, resourceName); -``` - -### Update an Azure Load Testing resource - -```ts snippet:ReadmeSampleUpdateLoadTestResource -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; - -const subscriptionId = "00000000-0000-0000-0000-000000000000"; -const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); - -const loadTestResourcePatchPayload = { - tags: { team: "testing-dev" }, - identity: { - type: "SystemAssigned, UserAssigned", - userAssignedIdentities: { - // removing a user-assigned managed identity by assigning the value in the payload as null - "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity1": - null, - "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity2": - {}, - }, - }, - encryption: { - // use system-assigned managed identity for CMK encryption - identity: { - type: "SystemAssigned", - resourceId: null, - }, - keyUrl: "https://sample-kv.vault.azure.net/keys/cmkkey/2d1ccd5c50234ea2a0858fe148b69cde", - }, -}; -const resource = await client.loadTests.beginUpdateAndWait( - "sample-rg", - "sample-loadtesting-resource", - loadTestResourcePatchPayload, -); + clientId: "" + }); +const client = new LoadTestServiceClient(credential, subscriptionId); ``` -### Delete an Azure Load Testing resource - -```ts snippet:ReadmeSampleDeleteLoadTestResource -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; - -const subscriptionId = "00000000-0000-0000-0000-000000000000"; -const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); - -const resourceName = "sample-loadtesting-resource"; -const resourceGroupName = "sample-rg"; - -const result = await client.loadTests.beginDeleteAndWait(resourceGroupName, resourceName); -``` ### 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 +### LoadTestServiceClient -`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. +`LoadTestServiceClient` 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 @@ -223,7 +98,7 @@ For more detailed instructions on how to enable logs, you can look at the [@azur ## 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. +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/arm-loadtesting/samples) directory for detailed examples on how to use this library. ## Contributing @@ -233,8 +108,6 @@ If you'd like to contribute to this library, please read the [contributing guide - [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js) -[azure_cli]: https://learn.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 diff --git a/sdk/loadtesting/arm-loadtesting/_meta.json b/sdk/loadtesting/arm-loadtesting/_meta.json deleted file mode 100644 index 4f72b89977cb..000000000000 --- a/sdk/loadtesting/arm-loadtesting/_meta.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "commit": "91af1c93c771c12d8b147f122c3519eae087d0ff", - "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=F:\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\loadtestservice\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.7 --generate-sample=true", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.5.4", - "use": "@autorest/typescript@6.0.0-rc.7" -} diff --git a/sdk/loadtesting/arm-loadtesting/assets.json b/sdk/loadtesting/arm-loadtesting/assets.json deleted file mode 100644 index 4ff3c1fa6d71..000000000000 --- a/sdk/loadtesting/arm-loadtesting/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "js", - "TagPrefix": "js/loadtesting/arm-loadtesting", - "Tag": "js/loadtesting/arm-loadtesting_28556fd22d" -} diff --git a/sdk/loadtesting/arm-loadtesting/eslint.config.mjs b/sdk/loadtesting/arm-loadtesting/eslint.config.mjs new file mode 100644 index 000000000000..6d2f8a5914c3 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/eslint.config.mjs @@ -0,0 +1,14 @@ +import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; + +export default azsdkEslint.config([ + { + rules: { + "@azure/azure-sdk/ts-modules-only-named": "warn", + "@azure/azure-sdk/ts-package-json-types": "warn", + "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", + "@azure/azure-sdk/ts-package-json-files-required": "off", + "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", + "tsdoc/syntax": "warn", + }, + }, +]); diff --git a/sdk/loadtesting/arm-loadtesting/package.json b/sdk/loadtesting/arm-loadtesting/package.json index d72c77041b0c..0ca7ca210e88 100644 --- a/sdk/loadtesting/arm-loadtesting/package.json +++ b/sdk/loadtesting/arm-loadtesting/package.json @@ -1,121 +1,122 @@ { "name": "@azure/arm-loadtesting", - "sdk-type": "mgmt", - "author": "Microsoft Corporation", - "description": "A generated SDK for LoadTestClient.", - "version": "1.0.1", + "version": "2.0.0-beta.1", + "description": "A generated SDK for LoadTestServiceClient.", "engines": { "node": ">=18.0.0" }, - "dependencies": { - "@azure/abort-controller": "^2.1.2", - "@azure/core-auth": "^1.9.0", - "@azure/core-client": "^1.9.2", - "@azure/core-lro": "^2.2.0", - "@azure/core-paging": "^1.6.2", - "@azure/core-rest-pipeline": "^1.19.0", - "tslib": "^2.8.1" + "sideEffects": false, + "autoPublish": false, + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./api": "./src/api/index.ts", + "./models": "./src/models/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false, + "project": "./tsconfig.src.json" }, + "type": "module", "keywords": [ "node", "azure", + "cloud", "typescript", "browser", - "isomorphic", - "cloud" + "isomorphic" ], + "author": "Microsoft Corporation", "license": "MIT", - "main": "./dist/commonjs/index.js", - "module": "./dist/esm/index.js", - "types": "./dist/commonjs/index.d.ts", + "files": [ + "dist/", + "README.md", + "LICENSE", + "review/", + "CHANGELOG.md" + ], + "sdk-type": "mgmt", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/arm-loadtesting/README.md", + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "//metadata": { + "constantPaths": [ + { + "path": "src/api/loadTestMgmtContext.ts", + "prefix": "userAgentInfo" + } + ] + }, + "dependencies": { + "@azure-rest/core-client": "^2.3.1", + "@azure/abort-controller": "^2.1.2", + "@azure/core-auth": "^1.9.0", + "@azure/core-lro": "^3.1.0", + "@azure/core-rest-pipeline": "^1.19.1", + "@azure/core-util": "^1.11.0", + "@azure/logger": "^1.1.4", + "tslib": "^2.8.1" + }, "devDependencies": { "@azure-tools/test-credential": "^2.0.0", "@azure-tools/test-recorder": "^4.1.0", "@azure-tools/test-utils-vitest": "^1.0.0", "@azure/dev-tool": "^1.0.0", - "@azure/identity": "^4.6.0", - "@azure/logger": "^1.1.4", + "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@azure/identity": "^4.9.0", "@types/node": "^18.0.0", "@vitest/browser": "^3.0.9", "@vitest/coverage-istanbul": "^3.0.9", "dotenv": "^16.0.0", - "playwright": "^1.50.1", + "eslint": "^9.9.0", + "playwright": "^1.51.1", "typescript": "~5.8.2", "vitest": "^3.0.9" }, - "repository": "github:Azure/azure-sdk-for-js", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "files": [ - "dist/", - "README.md", - "LICENSE", - "review/", - "CHANGELOG.md" - ], "scripts": { "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", - "build:browser": "echo skipped", - "build:node": "echo skipped", - "build:samples": "echo skipped.", - "build:test": "echo skipped", - "check-format": "echo skipped", + "build:samples": "tsc -p tsconfig.samples.json && dev-tool samples publish -f", + "build:test": "npm run clean && dev-tool run build-package && dev-tool run build-test", + "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", "clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", - "execute:samples": "echo skipped", - "extract-api": "dev-tool run extract-api", - "format": "echo skipped", + "execute:samples": "dev-tool samples run samples-dev", + "extract-api": "dev-tool run vendored rimraf review && dev-tool run extract-api", + "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"", + "generate:client": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", "integration-test:browser": "echo skipped", "integration-test:node": "dev-tool run test:vitest --esm", - "lint": "echo skipped", - "minify": "echo skipped", + "lint": "eslint package.json api-extractor.json src test", + "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", + "minify": "dev-tool run vendored uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", "pack": "npm pack 2>&1", - "prepack": "npm run build", - "test": "npm run integration-test", - "test:browser": "echo skipped", - "test:node": "echo skipped", + "test": "npm run clean && dev-tool run build-package && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", + "test:node": "npm run clean && dev-tool run build-package && npm run unit-test:node && npm run integration-test:node", "unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test:browser": "echo skipped", "unit-test:node": "dev-tool run test:vitest", "update-snippets": "dev-tool run update-snippets" }, - "sideEffects": false, - "//metadata": { - "constantPaths": [ - { - "path": "src/loadTestClient.ts", - "prefix": "packageDetails" - } - ] - }, - "autoPublish": true, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/arm-loadtesting", "//sampleConfiguration": { - "productName": "", + "productName": "@azure/arm-loadtesting", "productSlugs": [ "azure" ], "disableDocsMs": true, "apiRefLink": "https://learn.microsoft.com/javascript/api/@azure/arm-loadtesting?view=azure-node-preview" }, - "type": "module", - "tshy": { - "project": "./tsconfig.src.json", - "exports": { - "./package.json": "./package.json", - ".": "./src/index.ts" - }, - "dialects": [ - "esm", - "commonjs" - ], - "esmDialects": [ - "browser", - "react-native" - ], - "selfLink": false - }, "browser": "./dist/browser/index.js", "react-native": "./dist/react-native/index.js", "exports": { @@ -137,6 +138,45 @@ "types": "./dist/commonjs/index.d.ts", "default": "./dist/commonjs/index.js" } + }, + "./api": { + "browser": { + "types": "./dist/browser/api/index.d.ts", + "default": "./dist/browser/api/index.js" + }, + "react-native": { + "types": "./dist/react-native/api/index.d.ts", + "default": "./dist/react-native/api/index.js" + }, + "import": { + "types": "./dist/esm/api/index.d.ts", + "default": "./dist/esm/api/index.js" + }, + "require": { + "types": "./dist/commonjs/api/index.d.ts", + "default": "./dist/commonjs/api/index.js" + } + }, + "./models": { + "browser": { + "types": "./dist/browser/models/index.d.ts", + "default": "./dist/browser/models/index.js" + }, + "react-native": { + "types": "./dist/react-native/models/index.d.ts", + "default": "./dist/react-native/models/index.js" + }, + "import": { + "types": "./dist/esm/models/index.d.ts", + "default": "./dist/esm/models/index.js" + }, + "require": { + "types": "./dist/commonjs/models/index.d.ts", + "default": "./dist/commonjs/models/index.js" + } } - } + }, + "main": "./dist/commonjs/index.js", + "types": "./dist/commonjs/index.d.ts", + "module": "./dist/esm/index.js" } diff --git a/sdk/loadtesting/arm-loadtesting/review/arm-loadtesting-api.api.md b/sdk/loadtesting/arm-loadtesting/review/arm-loadtesting-api.api.md new file mode 100644 index 000000000000..4e442105cf4a --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/review/arm-loadtesting-api.api.md @@ -0,0 +1,103 @@ +## API Report File for "@azure/arm-loadtesting" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { Client } from '@azure-rest/core-client'; +import { ClientOptions } from '@azure-rest/core-client'; +import { OperationOptions } from '@azure-rest/core-client'; +import { OperationState } from '@azure/core-lro'; +import { PollerLike } from '@azure/core-lro'; +import { TokenCredential } from '@azure/core-auth'; + +// @public +export function checkAvailabilityQuota(context: LoadTestMgmtContext, location: string, quotaBucketName: string, quotaBucketRequest: QuotaBucketRequest, options?: CheckAvailabilityQuotaOptionalParams): Promise; + +// @public +export interface CheckAvailabilityQuotaOptionalParams extends OperationOptions { +} + +// @public (undocumented) +export function createLoadTestMgmt(credential: TokenCredential, subscriptionId: string, options?: LoadTestMgmtClientOptionalParams): LoadTestMgmtContext; + +// @public +export function createOrUpdateLoadtest(context: LoadTestMgmtContext, resourceGroupName: string, loadTestName: string, loadTestResource: LoadTestResource, options?: CreateOrUpdateLoadtestOptionalParams): PollerLike, LoadTestResource>; + +// @public +export interface CreateOrUpdateLoadtestOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export function deleteLoadtest(context: LoadTestMgmtContext, resourceGroupName: string, loadTestName: string, options?: DeleteLoadtestOptionalParams): PollerLike, void>; + +// @public +export interface DeleteLoadtestOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export function getLoadtest(context: LoadTestMgmtContext, resourceGroupName: string, loadTestName: string, options?: GetLoadtestOptionalParams): Promise; + +// @public +export interface GetLoadtestOptionalParams extends OperationOptions { +} + +// @public +export function getQuota(context: LoadTestMgmtContext, location: string, quotaBucketName: string, options?: GetQuotaOptionalParams): Promise; + +// @public +export interface GetQuotaOptionalParams extends OperationOptions { +} + +// @public +export function listByResourceGroup(context: LoadTestMgmtContext, resourceGroupName: string, options?: ListByResourceGroupOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface ListByResourceGroupOptionalParams extends OperationOptions { +} + +// @public +export function listBySubscription(context: LoadTestMgmtContext, options?: ListBySubscriptionOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface ListBySubscriptionOptionalParams extends OperationOptions { +} + +// @public +export function listQuota(context: LoadTestMgmtContext, location: string, options?: ListQuotaOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface ListQuotaOptionalParams extends OperationOptions { +} + +// @public +export interface LoadTestMgmtClientOptionalParams extends ClientOptions { + apiVersion?: string; +} + +// @public (undocumented) +export interface LoadTestMgmtContext extends Client { + apiVersion: string; + subscriptionId: string; +} + +// @public +export function outboundNetworkDependenciesEndpoints(context: LoadTestMgmtContext, resourceGroupName: string, loadTestName: string, options?: OutboundNetworkDependenciesEndpointsOptionalParams): PagedAsyncIterableIterator; + +// @public +export interface OutboundNetworkDependenciesEndpointsOptionalParams extends OperationOptions { +} + +// @public +export function updateLoadtest(context: LoadTestMgmtContext, resourceGroupName: string, loadTestName: string, loadTestResourcePatchRequestBody: LoadTestResourceUpdate, options?: UpdateLoadtestOptionalParams): PollerLike, void>; + +// @public +export interface UpdateLoadtestOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/loadtesting/arm-loadtesting/review/arm-loadtesting-models.api.md b/sdk/loadtesting/arm-loadtesting/review/arm-loadtesting-models.api.md new file mode 100644 index 000000000000..c9798e767283 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/review/arm-loadtesting-models.api.md @@ -0,0 +1,223 @@ +## API Report File for "@azure/arm-loadtesting" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +// @public +export interface CheckQuotaAvailabilityResponse { + readonly id: string; + readonly name?: string; + properties?: CheckQuotaAvailabilityResponseProperties; + readonly systemData?: SystemData; + readonly type: string; +} + +// @public +export interface CheckQuotaAvailabilityResponseProperties { + availabilityStatus?: string; + isAvailable?: boolean; +} + +// @public +export type CreatedByType = string; + +// @public +export interface EncryptionProperties { + identity?: EncryptionPropertiesIdentity; + keyUrl?: string; +} + +// @public +export interface EncryptionPropertiesIdentity { + resourceId?: string | null; + type?: Type; +} + +// @public +export interface EndpointDependency { + readonly description?: string; + readonly domainName: string; + readonly endpointDetails?: EndpointDetail[]; +} + +// @public +export interface EndpointDetail { + readonly port?: number; +} + +// @public +export interface ErrorAdditionalInfo { + readonly info?: Record; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export enum KnownAPIVersions { + V20221201 = "2022-12-01", + V20231201Preview = "2023-12-01-preview", + V20241201Preview = "2024-12-01-preview" +} + +// @public +export enum KnownCreatedByType { + Application = "Application", + Key = "Key", + ManagedIdentity = "ManagedIdentity", + User = "User" +} + +// @public +export enum KnownManagedServiceIdentityType { + None = "None", + SystemAssigned = "SystemAssigned", + SystemAssignedUserAssigned = "SystemAssigned,UserAssigned", + UserAssigned = "UserAssigned" +} + +// @public +export enum KnownResourceState { + Canceled = "Canceled", + Deleted = "Deleted", + Failed = "Failed", + Succeeded = "Succeeded" +} + +// @public +export enum KnownType { + SystemAssigned = "SystemAssigned", + UserAssigned = "UserAssigned" +} + +// @public +export interface LoadTestProperties { + readonly dataPlaneURI?: string; + description?: string; + encryption?: EncryptionProperties; + readonly provisioningState?: ResourceState; +} + +// @public +export interface LoadTestResource extends TrackedResource { + identity?: ManagedServiceIdentity; + properties?: LoadTestProperties; +} + +// @public +export interface LoadTestResourceUpdate { + identity?: ManagedServiceIdentity; + properties?: LoadTestResourceUpdateProperties; + tags?: Record; +} + +// @public +export interface LoadTestResourceUpdateProperties { + description?: string; + encryption?: EncryptionProperties; +} + +// @public +export interface ManagedServiceIdentity { + readonly principalId?: string; + readonly tenantId?: string; + type: ManagedServiceIdentityType; + userAssignedIdentities?: Record; +} + +// @public +export type ManagedServiceIdentityType = string; + +// @public +export interface OutboundEnvironmentEndpoint { + readonly category?: string; + readonly endpoints?: EndpointDependency[]; +} + +// @public +export interface ProxyResource extends Resource { +} + +// @public +export interface QuotaBucketRequest { + properties?: QuotaBucketRequestProperties; +} + +// @public +export interface QuotaBucketRequestProperties { + currentQuota?: number; + currentUsage?: number; + dimensions?: QuotaBucketRequestPropertiesDimensions; + newQuota?: number; +} + +// @public +export interface QuotaBucketRequestPropertiesDimensions { + location?: string; + subscriptionId?: string; +} + +// @public +export interface QuotaResource extends ProxyResource { + properties?: QuotaResourceProperties; +} + +// @public +export interface QuotaResourceProperties { + limit?: number; + readonly provisioningState?: ResourceState; + usage?: number; +} + +// @public +export interface Resource { + readonly id?: string; + readonly name?: string; + readonly systemData?: SystemData; + readonly type?: string; +} + +// @public +export type ResourceState = string; + +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + +// @public +export interface TrackedResource extends Resource { + location: string; + tags?: Record; +} + +// @public +export type Type = string; + +// @public +export interface UserAssignedIdentity { + readonly clientId?: string; + readonly principalId?: string; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/loadtesting/arm-loadtesting/review/arm-loadtesting.api.md b/sdk/loadtesting/arm-loadtesting/review/arm-loadtesting.api.md index 9b868094cf0e..e189bd0533dd 100644 --- a/sdk/loadtesting/arm-loadtesting/review/arm-loadtesting.api.md +++ b/sdk/loadtesting/arm-loadtesting/review/arm-loadtesting.api.md @@ -4,24 +4,52 @@ ```ts -import * as coreAuth from '@azure/core-auth'; -import * as coreClient from '@azure/core-client'; -import { PagedAsyncIterableIterator } from '@azure/core-paging'; +import { AbortSignalLike } from '@azure/abort-controller'; +import { ClientOptions } from '@azure-rest/core-client'; +import { OperationOptions } from '@azure-rest/core-client'; +import { OperationState } from '@azure/core-lro'; +import { PathUncheckedResponse } from '@azure-rest/core-client'; +import { Pipeline } from '@azure/core-rest-pipeline'; import { PollerLike } from '@azure/core-lro'; -import { PollOperationState } from '@azure/core-lro'; +import { TokenCredential } from '@azure/core-auth'; // @public -export type ActionType = string; +export interface CheckAvailabilityQuotaOptionalParams extends OperationOptions { +} + +// @public +export interface CheckQuotaAvailabilityResponse { + readonly id: string; + readonly name?: string; + properties?: CheckQuotaAvailabilityResponseProperties; + readonly systemData?: SystemData; + readonly type: string; +} // @public -export interface CheckQuotaAvailabilityResponse extends Resource { +export interface CheckQuotaAvailabilityResponseProperties { availabilityStatus?: string; isAvailable?: boolean; } +// @public +export type ContinuablePage = TPage & { + continuationToken?: string; +}; + // @public export type CreatedByType = string; +// @public +export interface CreateOrUpdateLoadtestOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + +// @public +export interface DeleteLoadtestOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + // @public export interface EncryptionProperties { identity?: EncryptionPropertiesIdentity; @@ -30,14 +58,14 @@ export interface EncryptionProperties { // @public export interface EncryptionPropertiesIdentity { - resourceId?: string; + resourceId?: string | null; type?: Type; } // @public export interface EndpointDependency { readonly description?: string; - readonly domainName?: string; + readonly domainName: string; readonly endpointDetails?: EndpointDetail[]; } @@ -48,7 +76,7 @@ export interface EndpointDetail { // @public export interface ErrorAdditionalInfo { - readonly info?: Record; + readonly info?: Record; readonly type?: string; } @@ -67,11 +95,18 @@ export interface ErrorResponse { } // @public -export function getContinuationToken(page: unknown): string | undefined; +export interface GetLoadtestOptionalParams extends OperationOptions { +} + +// @public +export interface GetQuotaOptionalParams extends OperationOptions { +} // @public -export enum KnownActionType { - Internal = "Internal" +export enum KnownAPIVersions { + V20221201 = "2022-12-01", + V20231201Preview = "2023-12-01-preview", + V20241201Preview = "2024-12-01-preview" } // @public @@ -90,13 +125,6 @@ export enum KnownManagedServiceIdentityType { UserAssigned = "UserAssigned" } -// @public -export enum KnownOrigin { - System = "system", - User = "user", - UserSystem = "user,system" -} - // @public export enum KnownResourceState { Canceled = "Canceled", @@ -111,229 +139,110 @@ export enum KnownType { UserAssigned = "UserAssigned" } -// @public (undocumented) -export class LoadTestClient extends coreClient.ServiceClient { - // (undocumented) - $host: string; - constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: LoadTestClientOptionalParams); - // (undocumented) - apiVersion: string; - // (undocumented) - loadTests: LoadTests; - // (undocumented) - operations: Operations; - // (undocumented) - quotas: Quotas; - // (undocumented) - subscriptionId: string; -} - -// @public -export interface LoadTestClientOptionalParams extends coreClient.ServiceClientOptions { - $host?: string; - apiVersion?: string; - endpoint?: string; -} - -// @public -export interface LoadTestResource extends TrackedResource { - readonly dataPlaneURI?: string; - description?: string; - encryption?: EncryptionProperties; - identity?: ManagedServiceIdentity; - readonly provisioningState?: ResourceState; -} - -// @public -export interface LoadTestResourcePageList { - nextLink?: string; - value?: LoadTestResource[]; -} - // @public -export interface LoadTestResourcePatchRequestBody { - description?: string; - encryption?: EncryptionProperties; - identity?: ManagedServiceIdentity; - tags?: { - [propertyName: string]: string; - }; -} - -// @public -export interface LoadTests { - beginCreateOrUpdate(resourceGroupName: string, loadTestName: string, loadTestResource: LoadTestResource, options?: LoadTestsCreateOrUpdateOptionalParams): Promise, LoadTestsCreateOrUpdateResponse>>; - beginCreateOrUpdateAndWait(resourceGroupName: string, loadTestName: string, loadTestResource: LoadTestResource, options?: LoadTestsCreateOrUpdateOptionalParams): Promise; - beginDelete(resourceGroupName: string, loadTestName: string, options?: LoadTestsDeleteOptionalParams): Promise, void>>; - beginDeleteAndWait(resourceGroupName: string, loadTestName: string, options?: LoadTestsDeleteOptionalParams): Promise; - beginUpdate(resourceGroupName: string, loadTestName: string, loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody, options?: LoadTestsUpdateOptionalParams): Promise, LoadTestsUpdateResponse>>; - beginUpdateAndWait(resourceGroupName: string, loadTestName: string, loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody, options?: LoadTestsUpdateOptionalParams): Promise; - get(resourceGroupName: string, loadTestName: string, options?: LoadTestsGetOptionalParams): Promise; - listByResourceGroup(resourceGroupName: string, options?: LoadTestsListByResourceGroupOptionalParams): PagedAsyncIterableIterator; - listBySubscription(options?: LoadTestsListBySubscriptionOptionalParams): PagedAsyncIterableIterator; - listOutboundNetworkDependenciesEndpoints(resourceGroupName: string, loadTestName: string, options?: LoadTestsListOutboundNetworkDependenciesEndpointsOptionalParams): PagedAsyncIterableIterator; -} - -// @public -export interface LoadTestsCreateOrUpdateHeaders { - azureAsyncOperation?: string; -} - -// @public -export interface LoadTestsCreateOrUpdateOptionalParams extends coreClient.OperationOptions { - resumeFrom?: string; - updateIntervalInMs?: number; -} - -// @public -export type LoadTestsCreateOrUpdateResponse = LoadTestResource; - -// @public -export interface LoadTestsDeleteHeaders { - location?: string; +export interface ListByResourceGroupOptionalParams extends OperationOptions { } // @public -export interface LoadTestsDeleteOptionalParams extends coreClient.OperationOptions { - resumeFrom?: string; - updateIntervalInMs?: number; +export interface ListBySubscriptionOptionalParams extends OperationOptions { } // @public -export interface LoadTestsGetOptionalParams extends coreClient.OperationOptions { +export interface ListQuotaOptionalParams extends OperationOptions { } -// @public -export type LoadTestsGetResponse = LoadTestResource; - -// @public -export interface LoadTestsListByResourceGroupNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type LoadTestsListByResourceGroupNextResponse = LoadTestResourcePageList; - -// @public -export interface LoadTestsListByResourceGroupOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type LoadTestsListByResourceGroupResponse = LoadTestResourcePageList; - -// @public -export interface LoadTestsListBySubscriptionNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type LoadTestsListBySubscriptionNextResponse = LoadTestResourcePageList; - -// @public -export interface LoadTestsListBySubscriptionOptionalParams extends coreClient.OperationOptions { +// @public (undocumented) +export class LoadTestMgmtClient { + constructor(credential: TokenCredential, subscriptionId: string, options?: LoadTestMgmtClientOptionalParams); + checkAvailabilityQuota(location: string, quotaBucketName: string, quotaBucketRequest: QuotaBucketRequest, options?: CheckAvailabilityQuotaOptionalParams): Promise; + createOrUpdateLoadtest(resourceGroupName: string, loadTestName: string, loadTestResource: LoadTestResource, options?: CreateOrUpdateLoadtestOptionalParams): PollerLike, LoadTestResource>; + deleteLoadtest(resourceGroupName: string, loadTestName: string, options?: DeleteLoadtestOptionalParams): PollerLike, void>; + getLoadtest(resourceGroupName: string, loadTestName: string, options?: GetLoadtestOptionalParams): Promise; + getQuota(location: string, quotaBucketName: string, options?: GetQuotaOptionalParams): Promise; + listByResourceGroup(resourceGroupName: string, options?: ListByResourceGroupOptionalParams): PagedAsyncIterableIterator; + listBySubscription(options?: ListBySubscriptionOptionalParams): PagedAsyncIterableIterator; + listQuota(location: string, options?: ListQuotaOptionalParams): PagedAsyncIterableIterator; + outboundNetworkDependenciesEndpoints(resourceGroupName: string, loadTestName: string, options?: OutboundNetworkDependenciesEndpointsOptionalParams): PagedAsyncIterableIterator; + readonly pipeline: Pipeline; + updateLoadtest(resourceGroupName: string, loadTestName: string, loadTestResourcePatchRequestBody: LoadTestResourceUpdate, options?: UpdateLoadtestOptionalParams): PollerLike, void>; +} + +// @public +export interface LoadTestMgmtClientOptionalParams extends ClientOptions { + apiVersion?: string; } // @public -export type LoadTestsListBySubscriptionResponse = LoadTestResourcePageList; - -// @public -export interface LoadTestsListOutboundNetworkDependenciesEndpointsNextOptionalParams extends coreClient.OperationOptions { +export interface LoadTestProperties { + readonly dataPlaneURI?: string; + description?: string; + encryption?: EncryptionProperties; + readonly provisioningState?: ResourceState; } // @public -export type LoadTestsListOutboundNetworkDependenciesEndpointsNextResponse = OutboundEnvironmentEndpointCollection; - -// @public -export interface LoadTestsListOutboundNetworkDependenciesEndpointsOptionalParams extends coreClient.OperationOptions { +export interface LoadTestResource extends TrackedResource { + identity?: ManagedServiceIdentity; + properties?: LoadTestProperties; } // @public -export type LoadTestsListOutboundNetworkDependenciesEndpointsResponse = OutboundEnvironmentEndpointCollection; - -// @public -export interface LoadTestsUpdateHeaders { - azureAsyncOperation?: string; +export interface LoadTestResourceUpdate { + identity?: ManagedServiceIdentity; + properties?: LoadTestResourceUpdateProperties; + tags?: Record; } // @public -export interface LoadTestsUpdateOptionalParams extends coreClient.OperationOptions { - resumeFrom?: string; - updateIntervalInMs?: number; +export interface LoadTestResourceUpdateProperties { + description?: string; + encryption?: EncryptionProperties; } -// @public -export type LoadTestsUpdateResponse = LoadTestResource; - // @public export interface ManagedServiceIdentity { readonly principalId?: string; readonly tenantId?: string; type: ManagedServiceIdentityType; - userAssignedIdentities?: { - [propertyName: string]: UserAssignedIdentity | null; - }; + userAssignedIdentities?: Record; } // @public export type ManagedServiceIdentityType = string; // @public -export interface Operation { - readonly actionType?: ActionType; - display?: OperationDisplay; - readonly isDataAction?: boolean; - readonly name?: string; - readonly origin?: Origin; -} - -// @public -export interface OperationDisplay { - readonly description?: string; - readonly operation?: string; - readonly provider?: string; - readonly resource?: string; +export interface OutboundEnvironmentEndpoint { + readonly category?: string; + readonly endpoints?: EndpointDependency[]; } // @public -export interface OperationListResult { - readonly nextLink?: string; - readonly value?: Operation[]; +export interface OutboundNetworkDependenciesEndpointsOptionalParams extends OperationOptions { } // @public -export interface Operations { - list(options?: OperationsListOptionalParams): PagedAsyncIterableIterator; +export interface PagedAsyncIterableIterator { + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; + next(): Promise>; } // @public -export interface OperationsListNextOptionalParams extends coreClient.OperationOptions { +export interface PageSettings { + continuationToken?: string; } // @public -export type OperationsListNextResponse = OperationListResult; - -// @public -export interface OperationsListOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type OperationsListResponse = OperationListResult; - -// @public -export type Origin = string; - -// @public -export interface OutboundEnvironmentEndpoint { - readonly category?: string; - readonly endpoints?: EndpointDependency[]; +export interface ProxyResource extends Resource { } // @public -export interface OutboundEnvironmentEndpointCollection { - nextLink?: string; - readonly value?: OutboundEnvironmentEndpoint[]; +export interface QuotaBucketRequest { + properties?: QuotaBucketRequestProperties; } // @public -export interface QuotaBucketRequest extends Resource { +export interface QuotaBucketRequestProperties { currentQuota?: number; currentUsage?: number; dimensions?: QuotaBucketRequestPropertiesDimensions; @@ -347,53 +256,17 @@ export interface QuotaBucketRequestPropertiesDimensions { } // @public -export interface QuotaResource extends Resource { - limit?: number; - readonly provisioningState?: ResourceState; - usage?: number; -} - -// @public -export interface QuotaResourceList { - readonly nextLink?: string; - readonly value?: QuotaResource[]; -} - -// @public -export interface Quotas { - checkAvailability(location: string, quotaBucketName: string, quotaBucketRequest: QuotaBucketRequest, options?: QuotasCheckAvailabilityOptionalParams): Promise; - get(location: string, quotaBucketName: string, options?: QuotasGetOptionalParams): Promise; - list(location: string, options?: QuotasListOptionalParams): PagedAsyncIterableIterator; -} - -// @public -export interface QuotasCheckAvailabilityOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type QuotasCheckAvailabilityResponse = CheckQuotaAvailabilityResponse; - -// @public -export interface QuotasGetOptionalParams extends coreClient.OperationOptions { +export interface QuotaResource extends ProxyResource { + properties?: QuotaResourceProperties; } // @public -export type QuotasGetResponse = QuotaResource; - -// @public -export interface QuotasListNextOptionalParams extends coreClient.OperationOptions { -} - -// @public -export type QuotasListNextResponse = QuotaResourceList; - -// @public -export interface QuotasListOptionalParams extends coreClient.OperationOptions { +export interface QuotaResourceProperties { + limit?: number; + readonly provisioningState?: ResourceState; + usage?: number; } -// @public -export type QuotasListResponse = QuotaResourceList; - // @public export interface Resource { readonly id?: string; @@ -405,6 +278,16 @@ export interface Resource { // @public export type ResourceState = string; +// @public +export function restorePoller(client: LoadTestMgmtClient, serializedState: string, sourceOperation: (...args: any[]) => PollerLike, TResult>, options?: RestorePollerOptions): PollerLike, TResult>; + +// @public (undocumented) +export interface RestorePollerOptions extends OperationOptions { + abortSignal?: AbortSignalLike; + processResponseBody?: (result: TResponse) => Promise; + updateIntervalInMs?: number; +} + // @public export interface SystemData { createdAt?: Date; @@ -418,14 +301,17 @@ export interface SystemData { // @public export interface TrackedResource extends Resource { location: string; - tags?: { - [propertyName: string]: string; - }; + tags?: Record; } // @public export type Type = string; +// @public +export interface UpdateLoadtestOptionalParams extends OperationOptions { + updateIntervalInMs?: number; +} + // @public export interface UserAssignedIdentity { readonly clientId?: string; diff --git a/sdk/loadtesting/arm-loadtesting/sample.env b/sdk/loadtesting/arm-loadtesting/sample.env index 672847a3fea0..508439fc7d62 100644 --- a/sdk/loadtesting/arm-loadtesting/sample.env +++ b/sdk/loadtesting/arm-loadtesting/sample.env @@ -1,4 +1 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= \ No newline at end of file +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/checkAvailabilityQuotaSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/checkAvailabilityQuotaSample.ts new file mode 100644 index 000000000000..cd509b913423 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples-dev/checkAvailabilityQuotaSample.ts @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to check Quota Availability on quota bucket per region per subscription. + * + * @summary check Quota Availability on quota bucket per region per subscription. + * x-ms-original-file: 2024-12-01-preview/Quotas_CheckAvailability.json + */ +async function checkQuotaAvailabilityOnQuotaBucketPerRegionPerSubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.checkAvailabilityQuota("westus", "testQuotaBucket", { + properties: { + currentUsage: 20, + currentQuota: 40, + newQuota: 50, + dimensions: { + subscriptionId: "testsubscriptionId", + location: "westus", + }, + }, + }); + console.log(result); +} + +async function main(): Promise { + await checkQuotaAvailabilityOnQuotaBucketPerRegionPerSubscription(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/createOrUpdateLoadtestSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/createOrUpdateLoadtestSample.ts new file mode 100644 index 000000000000..ce08f9f58309 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples-dev/createOrUpdateLoadtestSample.ts @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a LoadTestResource + * + * @summary create a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_CreateOrUpdate.json + */ +async function createALoadTestResource(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.createOrUpdateLoadtest("dummyrg", "myLoadTest", { + location: "westus", + tags: { Team: "Dev Exp" }, + identity: { + type: "SystemAssigned,UserAssigned", + userAssignedIdentities: { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": + {}, + }, + }, + properties: { + description: "This is new load test resource", + encryption: { + identity: { + type: "UserAssigned", + resourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", + }, + keyUrl: "https://dummy.vault.azure.net/keys/dummykey1", + }, + }, + }); + console.log(result); +} + +async function main(): Promise { + await createALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/deleteLoadtestSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/deleteLoadtestSample.ts new file mode 100644 index 000000000000..affacff55256 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples-dev/deleteLoadtestSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a LoadTestResource + * + * @summary delete a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_Delete.json + */ +async function deleteALoadTestResource(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + await client.deleteLoadtest("dummyrg", "myLoadTest"); +} + +async function main(): Promise { + await deleteALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/getLoadtestSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/getLoadtestSample.ts new file mode 100644 index 000000000000..9bca6756e9bf --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples-dev/getLoadtestSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a LoadTestResource + * + * @summary get a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_Get.json + */ +async function getALoadTestResource(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.getLoadtest("dummyrg", "myLoadTest"); + console.log(result); +} + +async function main(): Promise { + await getALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/getQuotaSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/getQuotaSample.ts new file mode 100644 index 000000000000..0434277c0a4a --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples-dev/getQuotaSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get the available quota for a quota bucket per region per subscription. + * + * @summary get the available quota for a quota bucket per region per subscription. + * x-ms-original-file: 2024-12-01-preview/Quotas_Get.json + */ +async function getTheAvailableQuotaForAQuotaBucketPerRegionPerSubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.getQuota("westus", "testQuotaBucket"); + console.log(result); +} + +async function main(): Promise { + await getTheAvailableQuotaForAQuotaBucketPerRegionPerSubscription(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/listByResourceGroupSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/listByResourceGroupSample.ts new file mode 100644 index 000000000000..9640d566cd81 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples-dev/listByResourceGroupSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list LoadTestResource resources by resource group + * + * @summary list LoadTestResource resources by resource group + * x-ms-original-file: 2024-12-01-preview/LoadTests_ListByResourceGroup.json + */ +async function listLoadTestResourceResourcesByResourceGroup(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.listByResourceGroup("dummyrg")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listLoadTestResourceResourcesByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/listBySubscriptionSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/listBySubscriptionSample.ts new file mode 100644 index 000000000000..14558e909efd --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples-dev/listBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list LoadTestResource resources by subscription ID + * + * @summary list LoadTestResource resources by subscription ID + * x-ms-original-file: 2024-12-01-preview/LoadTests_ListBySubscription.json + */ +async function listLoadTestResourceResourcesBySubscriptionID(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listLoadTestResourceResourcesBySubscriptionID(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/listQuotaSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/listQuotaSample.ts new file mode 100644 index 000000000000..70f5afe9fa8f --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples-dev/listQuotaSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list quotas for a given subscription Id. + * + * @summary list quotas for a given subscription Id. + * x-ms-original-file: 2024-12-01-preview/Quotas_List.json + */ +async function listQuotasForAGivenSubscriptionId(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.listQuota("westus")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listQuotasForAGivenSubscriptionId(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsCreateOrUpdateSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsCreateOrUpdateSample.ts deleted file mode 100644 index 7d4e980bfc71..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsCreateOrUpdateSample.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 type { LoadTestResource } from "@azure/arm-loadtesting"; -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Create or update LoadTest resource. - * - * @summary Create or update LoadTest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_CreateOrUpdate.json - */ -async function loadTestsCreateOrUpdate(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const loadTestResource: LoadTestResource = { - description: "This is new load test resource", - encryption: { - identity: { - type: "UserAssigned", - resourceId: - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", - }, - keyUrl: "https://dummy.vault.azure.net/keys/dummykey1", - }, - identity: { - type: "SystemAssigned,UserAssigned", - userAssignedIdentities: { - "/subscriptions/00000000000000000000000000000000/resourceGroups/dummyrg/providers/MicrosoftManagedIdentity/userAssignedIdentities/id1": - {}, - }, - }, - location: "westus", - tags: { team: "Dev Exp" }, - }; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.beginCreateOrUpdateAndWait( - resourceGroupName, - loadTestName, - loadTestResource, - ); - console.log(result); -} - -async function main(): Promise { - await loadTestsCreateOrUpdate(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsDeleteSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsDeleteSample.ts deleted file mode 100644 index 7ea2ab8b3c9c..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsDeleteSample.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Delete a LoadTest resource. - * - * @summary Delete a LoadTest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Delete.json - */ -async function loadTestsDelete(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.beginDeleteAndWait(resourceGroupName, loadTestName); - console.log(result); -} - -async function main(): Promise { - await loadTestsDelete(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsGetSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsGetSample.ts deleted file mode 100644 index b03db9492fdc..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsGetSample.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Get a LoadTest resource. - * - * @summary Get a LoadTest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json - */ -async function loadTestsGet(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.get(resourceGroupName, loadTestName); - console.log(result); -} - -async function main(): Promise { - await loadTestsGet(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsListByResourceGroupSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsListByResourceGroupSample.ts deleted file mode 100644 index 51ca0c5f1054..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsListByResourceGroupSample.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Lists loadtest resources in a resource group. - * - * @summary Lists loadtest resources in a resource group. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListByResourceGroup.json - */ -async function loadTestsListByResourceGroup(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (const item of client.loadTests.listByResourceGroup(resourceGroupName)) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - await loadTestsListByResourceGroup(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsListBySubscriptionSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsListBySubscriptionSample.ts deleted file mode 100644 index 0846945c9beb..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsListBySubscriptionSample.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Lists loadtests resources in a subscription. - * - * @summary Lists loadtests resources in a subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListBySubscription.json - */ -async function loadTestsListBySubscription(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (const item of client.loadTests.listBySubscription()) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - await loadTestsListBySubscription(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsListOutboundNetworkDependenciesEndpointsSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsListOutboundNetworkDependenciesEndpointsSample.ts deleted file mode 100644 index 4d622a2a21d4..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsListOutboundNetworkDependenciesEndpointsSample.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Lists the endpoints that agents may call as part of load testing. - * - * @summary Lists the endpoints that agents may call as part of load testing. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListOutboundNetworkDependenciesEndpoints.json - */ -async function listOutboundNetworkDependencies(): Promise { - const subscriptionId = process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "subid"; - const resourceGroupName = - process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "default-azureloadtest-japaneast"; - const loadTestName = "sampleloadtest"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (const item of client.loadTests.listOutboundNetworkDependenciesEndpoints( - resourceGroupName, - loadTestName, - )) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - await listOutboundNetworkDependencies(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsUpdateSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsUpdateSample.ts deleted file mode 100644 index ee50725f3d92..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/loadTestsUpdateSample.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 type { LoadTestResourcePatchRequestBody } from "@azure/arm-loadtesting"; -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Update a loadtest resource. - * - * @summary Update a loadtest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Update.json - */ -async function loadTestsUpdate(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody = { - description: "This is new load test resource", - encryption: { - identity: { type: "SystemAssigned", resourceId: undefined }, - keyUrl: "https://dummy.vault.azure.net/keys/dummykey1", - }, - identity: { - type: "SystemAssigned,UserAssigned", - userAssignedIdentities: { - "/subscriptions/00000000000000000000000000000000/resourceGroups/dummyrg/providers/MicrosoftManagedIdentity/userAssignedIdentities/id1": - {}, - }, - }, - tags: { division: "LT", team: "Dev Exp" }, - }; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.beginUpdateAndWait( - resourceGroupName, - loadTestName, - loadTestResourcePatchRequestBody, - ); - console.log(result); -} - -async function main(): Promise { - await loadTestsUpdate(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/operationsListSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/operationsListSample.ts deleted file mode 100644 index 6daa0db096fa..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/operationsListSample.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Lists all the available API operations for Load Test Resource. - * - * @summary Lists all the available API operations for Load Test Resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Operations_List.json - */ -async function operationsList(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (const item of client.operations.list()) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - await operationsList(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/outboundNetworkDependenciesEndpointsSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/outboundNetworkDependenciesEndpointsSample.ts new file mode 100644 index 000000000000..853fc08f3e42 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples-dev/outboundNetworkDependenciesEndpointsSample.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to lists the endpoints that agents may call as part of load testing. + * + * @summary lists the endpoints that agents may call as part of load testing. + * x-ms-original-file: 2024-12-01-preview/LoadTests_ListOutboundNetworkDependenciesEndpoints.json + */ +async function listsTheEndpointsThatAgentsMayCallAsPartOfLoadTesting(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.outboundNetworkDependenciesEndpoints( + "default-azureloadtest-japaneast", + "sampleloadtest", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listsTheEndpointsThatAgentsMayCallAsPartOfLoadTesting(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/quotasCheckAvailabilitySample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/quotasCheckAvailabilitySample.ts deleted file mode 100644 index 47becd562ca9..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/quotasCheckAvailabilitySample.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 type { QuotaBucketRequest } from "@azure/arm-loadtesting"; -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Check Quota Availability on quota bucket per region per subscription. - * - * @summary Check Quota Availability on quota bucket per region per subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_CheckAvailability.json - */ -async function quotasCheckAvailability(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const location = "westus"; - const quotaBucketName = "testQuotaBucket"; - const quotaBucketRequest: QuotaBucketRequest = { - currentQuota: 40, - currentUsage: 20, - dimensions: { location: "westus", subscriptionId: "testsubscriptionId" }, - newQuota: 50, - }; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.quotas.checkAvailability( - location, - quotaBucketName, - quotaBucketRequest, - ); - console.log(result); -} - -async function main(): Promise { - await quotasCheckAvailability(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/quotasGetSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/quotasGetSample.ts deleted file mode 100644 index 04138940ec1e..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/quotasGetSample.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Get the available quota for a quota bucket per region per subscription. - * - * @summary Get the available quota for a quota bucket per region per subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_Get.json - */ -async function quotasGet(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const location = "westus"; - const quotaBucketName = "testQuotaBucket"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.quotas.get(location, quotaBucketName); - console.log(result); -} - -async function main(): Promise { - await quotasGet(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/quotasListSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/quotasListSample.ts deleted file mode 100644 index 7f939d15c684..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples-dev/quotasListSample.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Lists all the available quota per region per subscription. - * - * @summary Lists all the available quota per region per subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_List.json - */ -async function quotasList(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const location = "westus"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (const item of client.quotas.list(location)) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - await quotasList(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples-dev/updateLoadtestSample.ts b/sdk/loadtesting/arm-loadtesting/samples-dev/updateLoadtestSample.ts new file mode 100644 index 000000000000..100dd26da835 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples-dev/updateLoadtestSample.ts @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to update a LoadTestResource + * + * @summary update a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_Update.json + */ +async function updateALoadTestResource(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + await client.updateLoadtest("dummyrg", "myLoadTest", { + tags: { Team: "Dev Exp", Division: "LT" }, + identity: { + type: "SystemAssigned,UserAssigned", + userAssignedIdentities: { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": + {}, + }, + }, + properties: { + description: "This is new load test resource", + encryption: { + identity: { type: "SystemAssigned", resourceId: null }, + keyUrl: "https://dummy.vault.azure.net/keys/dummykey1", + }, + }, + }); +} + +async function main(): Promise { + await updateALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/README.md b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/README.md index 2c937ccd4b4f..343c763fa1f4 100644 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/README.md +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/README.md @@ -1,20 +1,19 @@ -# client library samples for JavaScript - -These sample programs show how to use the JavaScript client libraries for in some common scenarios. - -| **File Name** | **Description** | -| --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [loadTestsCreateOrUpdateSample.js][loadtestscreateorupdatesample] | Create or update LoadTest resource. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_CreateOrUpdate.json | -| [loadTestsDeleteSample.js][loadtestsdeletesample] | Delete a LoadTest resource. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Delete.json | -| [loadTestsGetSample.js][loadtestsgetsample] | Get a LoadTest resource. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json | -| [loadTestsListByResourceGroupSample.js][loadtestslistbyresourcegroupsample] | Lists loadtest resources in a resource group. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListByResourceGroup.json | -| [loadTestsListBySubscriptionSample.js][loadtestslistbysubscriptionsample] | Lists loadtests resources in a subscription. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListBySubscription.json | -| [loadTestsListOutboundNetworkDependenciesEndpointsSample.js][loadtestslistoutboundnetworkdependenciesendpointssample] | Lists the endpoints that agents may call as part of load testing. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListOutboundNetworkDependenciesEndpoints.json | -| [loadTestsUpdateSample.js][loadtestsupdatesample] | Update a loadtest resource. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Update.json | -| [operationsListSample.js][operationslistsample] | Lists all the available API operations for Load Test Resource. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Operations_List.json | -| [quotasCheckAvailabilitySample.js][quotascheckavailabilitysample] | Check Quota Availability on quota bucket per region per subscription. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_CheckAvailability.json | -| [quotasGetSample.js][quotasgetsample] | Get the available quota for a quota bucket per region per subscription. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_Get.json | -| [quotasListSample.js][quotaslistsample] | Lists all the available quota per region per subscription. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_List.json | +# @azure/arm-loadtesting client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for @azure/arm-loadtesting in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [checkAvailabilityQuotaSample.js][checkavailabilityquotasample] | check Quota Availability on quota bucket per region per subscription. x-ms-original-file: 2024-12-01-preview/Quotas_CheckAvailability.json | +| [createOrUpdateLoadtestSample.js][createorupdateloadtestsample] | create a LoadTestResource x-ms-original-file: 2024-12-01-preview/LoadTests_CreateOrUpdate.json | +| [deleteLoadtestSample.js][deleteloadtestsample] | delete a LoadTestResource x-ms-original-file: 2024-12-01-preview/LoadTests_Delete.json | +| [getLoadtestSample.js][getloadtestsample] | get a LoadTestResource x-ms-original-file: 2024-12-01-preview/LoadTests_Get.json | +| [getQuotaSample.js][getquotasample] | get the available quota for a quota bucket per region per subscription. x-ms-original-file: 2024-12-01-preview/Quotas_Get.json | +| [listByResourceGroupSample.js][listbyresourcegroupsample] | list LoadTestResource resources by resource group x-ms-original-file: 2024-12-01-preview/LoadTests_ListByResourceGroup.json | +| [listBySubscriptionSample.js][listbysubscriptionsample] | list LoadTestResource resources by subscription ID x-ms-original-file: 2024-12-01-preview/LoadTests_ListBySubscription.json | +| [listQuotaSample.js][listquotasample] | list quotas for a given subscription Id. x-ms-original-file: 2024-12-01-preview/Quotas_List.json | +| [outboundNetworkDependenciesEndpointsSample.js][outboundnetworkdependenciesendpointssample] | lists the endpoints that agents may call as part of load testing. x-ms-original-file: 2024-12-01-preview/LoadTests_ListOutboundNetworkDependenciesEndpoints.json | +| [updateLoadtestSample.js][updateloadtestsample] | update a LoadTestResource x-ms-original-file: 2024-12-01-preview/LoadTests_Update.json | ## Prerequisites @@ -41,30 +40,29 @@ npm install 3. Run whichever samples you like (note that some samples may require additional setup, see the table above): ```bash -node loadTestsCreateOrUpdateSample.js +node checkAvailabilityQuotaSample.js ``` Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): ```bash -npx dev-tool run vendored cross-env LOADTESTSERVICE_SUBSCRIPTION_ID="" LOADTESTSERVICE_RESOURCE_GROUP="" node loadTestsCreateOrUpdateSample.js +npx dev-tool run vendored cross-env node checkAvailabilityQuotaSample.js ``` ## Next Steps Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. -[loadtestscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsCreateOrUpdateSample.js -[loadtestsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsDeleteSample.js -[loadtestsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsGetSample.js -[loadtestslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListByResourceGroupSample.js -[loadtestslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListBySubscriptionSample.js -[loadtestslistoutboundnetworkdependenciesendpointssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListOutboundNetworkDependenciesEndpointsSample.js -[loadtestsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsUpdateSample.js -[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/operationsListSample.js -[quotascheckavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasCheckAvailabilitySample.js -[quotasgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasGetSample.js -[quotaslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasListSample.js +[checkavailabilityquotasample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/checkAvailabilityQuotaSample.js +[createorupdateloadtestsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/createOrUpdateLoadtestSample.js +[deleteloadtestsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/deleteLoadtestSample.js +[getloadtestsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/getLoadtestSample.js +[getquotasample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/getQuotaSample.js +[listbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listByResourceGroupSample.js +[listbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listBySubscriptionSample.js +[listquotasample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listQuotaSample.js +[outboundnetworkdependenciesendpointssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/outboundNetworkDependenciesEndpointsSample.js +[updateloadtestsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/updateLoadtestSample.js [apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-loadtesting?view=azure-node-preview [freesub]: https://azure.microsoft.com/free/ [package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/arm-loadtesting/README.md diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/checkAvailabilityQuotaSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/checkAvailabilityQuotaSample.js new file mode 100644 index 000000000000..c727b921572f --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/checkAvailabilityQuotaSample.js @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { LoadTestMgmtClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to check Quota Availability on quota bucket per region per subscription. + * + * @summary check Quota Availability on quota bucket per region per subscription. + * x-ms-original-file: 2024-12-01-preview/Quotas_CheckAvailability.json + */ +async function checkQuotaAvailabilityOnQuotaBucketPerRegionPerSubscription() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.checkAvailabilityQuota("westus", "testQuotaBucket", { + properties: { + currentUsage: 20, + currentQuota: 40, + newQuota: 50, + dimensions: { + subscriptionId: "testsubscriptionId", + location: "westus", + }, + }, + }); + console.log(result); +} + +async function main() { + await checkQuotaAvailabilityOnQuotaBucketPerRegionPerSubscription(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/createOrUpdateLoadtestSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/createOrUpdateLoadtestSample.js new file mode 100644 index 000000000000..032150fd6e5d --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/createOrUpdateLoadtestSample.js @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { LoadTestMgmtClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to create a LoadTestResource + * + * @summary create a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_CreateOrUpdate.json + */ +async function createALoadTestResource() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.createOrUpdateLoadtest("dummyrg", "myLoadTest", { + location: "westus", + tags: { Team: "Dev Exp" }, + identity: { + type: "SystemAssigned,UserAssigned", + userAssignedIdentities: { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": + {}, + }, + }, + properties: { + description: "This is new load test resource", + encryption: { + identity: { + type: "UserAssigned", + resourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", + }, + keyUrl: "https://dummy.vault.azure.net/keys/dummykey1", + }, + }, + }); + console.log(result); +} + +async function main() { + await createALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/deleteLoadtestSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/deleteLoadtestSample.js new file mode 100644 index 000000000000..27cedb714cb1 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/deleteLoadtestSample.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { LoadTestMgmtClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to delete a LoadTestResource + * + * @summary delete a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_Delete.json + */ +async function deleteALoadTestResource() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + await client.deleteLoadtest("dummyrg", "myLoadTest"); +} + +async function main() { + await deleteALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/getLoadtestSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/getLoadtestSample.js new file mode 100644 index 000000000000..89735c0df7d0 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/getLoadtestSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { LoadTestMgmtClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get a LoadTestResource + * + * @summary get a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_Get.json + */ +async function getALoadTestResource() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.getLoadtest("dummyrg", "myLoadTest"); + console.log(result); +} + +async function main() { + await getALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/getQuotaSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/getQuotaSample.js new file mode 100644 index 000000000000..618c943de4ca --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/getQuotaSample.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { LoadTestMgmtClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to get the available quota for a quota bucket per region per subscription. + * + * @summary get the available quota for a quota bucket per region per subscription. + * x-ms-original-file: 2024-12-01-preview/Quotas_Get.json + */ +async function getTheAvailableQuotaForAQuotaBucketPerRegionPerSubscription() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.getQuota("westus", "testQuotaBucket"); + console.log(result); +} + +async function main() { + await getTheAvailableQuotaForAQuotaBucketPerRegionPerSubscription(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listByResourceGroupSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listByResourceGroupSample.js new file mode 100644 index 000000000000..5373ec7429ef --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listByResourceGroupSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { LoadTestMgmtClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list LoadTestResource resources by resource group + * + * @summary list LoadTestResource resources by resource group + * x-ms-original-file: 2024-12-01-preview/LoadTests_ListByResourceGroup.json + */ +async function listLoadTestResourceResourcesByResourceGroup() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.listByResourceGroup("dummyrg")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await listLoadTestResourceResourcesByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listBySubscriptionSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listBySubscriptionSample.js new file mode 100644 index 000000000000..15270b4d0329 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listBySubscriptionSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { LoadTestMgmtClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list LoadTestResource resources by subscription ID + * + * @summary list LoadTestResource resources by subscription ID + * x-ms-original-file: 2024-12-01-preview/LoadTests_ListBySubscription.json + */ +async function listLoadTestResourceResourcesBySubscriptionID() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await listLoadTestResourceResourcesBySubscriptionID(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listQuotaSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listQuotaSample.js new file mode 100644 index 000000000000..840969607e65 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/listQuotaSample.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { LoadTestMgmtClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to list quotas for a given subscription Id. + * + * @summary list quotas for a given subscription Id. + * x-ms-original-file: 2024-12-01-preview/Quotas_List.json + */ +async function listQuotasForAGivenSubscriptionId() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.listQuota("westus")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await listQuotasForAGivenSubscriptionId(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsCreateOrUpdateSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsCreateOrUpdateSample.js deleted file mode 100644 index 12fc304a4391..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsCreateOrUpdateSample.js +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Create or update LoadTest resource. - * - * @summary Create or update LoadTest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_CreateOrUpdate.json - */ -async function loadTestsCreateOrUpdate() { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const loadTestResource = { - description: "This is new load test resource", - encryption: { - identity: { - type: "UserAssigned", - resourceId: - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", - }, - keyUrl: "https://dummy.vault.azure.net/keys/dummykey1", - }, - identity: { - type: "SystemAssigned,UserAssigned", - userAssignedIdentities: { - "/subscriptions/00000000000000000000000000000000/resourceGroups/dummyrg/providers/MicrosoftManagedIdentity/userAssignedIdentities/id1": - {}, - }, - }, - location: "westus", - tags: { team: "Dev Exp" }, - }; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.beginCreateOrUpdateAndWait( - resourceGroupName, - loadTestName, - loadTestResource - ); - console.log(result); -} - -async function main() { - loadTestsCreateOrUpdate(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsDeleteSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsDeleteSample.js deleted file mode 100644 index f66f64b21577..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsDeleteSample.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Delete a LoadTest resource. - * - * @summary Delete a LoadTest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Delete.json - */ -async function loadTestsDelete() { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.beginDeleteAndWait(resourceGroupName, loadTestName); - console.log(result); -} - -async function main() { - loadTestsDelete(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsGetSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsGetSample.js deleted file mode 100644 index 8b2fa3bd09e5..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsGetSample.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Get a LoadTest resource. - * - * @summary Get a LoadTest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json - */ -async function loadTestsGet() { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.get(resourceGroupName, loadTestName); - console.log(result); -} - -async function main() { - loadTestsGet(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListByResourceGroupSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListByResourceGroupSample.js deleted file mode 100644 index 9bc0c653f059..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListByResourceGroupSample.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Lists loadtest resources in a resource group. - * - * @summary Lists loadtest resources in a resource group. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListByResourceGroup.json - */ -async function loadTestsListByResourceGroup() { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.loadTests.listByResourceGroup(resourceGroupName)) { - resArray.push(item); - } - console.log(resArray); -} - -async function main() { - loadTestsListByResourceGroup(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListBySubscriptionSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListBySubscriptionSample.js deleted file mode 100644 index 30e2785b9d87..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListBySubscriptionSample.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Lists loadtests resources in a subscription. - * - * @summary Lists loadtests resources in a subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListBySubscription.json - */ -async function loadTestsListBySubscription() { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.loadTests.listBySubscription()) { - resArray.push(item); - } - console.log(resArray); -} - -async function main() { - loadTestsListBySubscription(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListOutboundNetworkDependenciesEndpointsSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListOutboundNetworkDependenciesEndpointsSample.js deleted file mode 100644 index 7aa257fce2e4..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsListOutboundNetworkDependenciesEndpointsSample.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Lists the endpoints that agents may call as part of load testing. - * - * @summary Lists the endpoints that agents may call as part of load testing. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListOutboundNetworkDependenciesEndpoints.json - */ -async function listOutboundNetworkDependencies() { - const subscriptionId = process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "subid"; - const resourceGroupName = - process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "default-azureloadtest-japaneast"; - const loadTestName = "sampleloadtest"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.loadTests.listOutboundNetworkDependenciesEndpoints( - resourceGroupName, - loadTestName - )) { - resArray.push(item); - } - console.log(resArray); -} - -async function main() { - listOutboundNetworkDependencies(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsUpdateSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsUpdateSample.js deleted file mode 100644 index 27243e9cde67..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/loadTestsUpdateSample.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Update a loadtest resource. - * - * @summary Update a loadtest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Update.json - */ -async function loadTestsUpdate() { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const loadTestResourcePatchRequestBody = { - description: "This is new load test resource", - encryption: { - identity: { type: "SystemAssigned", resourceId: undefined }, - keyUrl: "https://dummy.vault.azure.net/keys/dummykey1", - }, - identity: { - type: "SystemAssigned,UserAssigned", - userAssignedIdentities: { - "/subscriptions/00000000000000000000000000000000/resourceGroups/dummyrg/providers/MicrosoftManagedIdentity/userAssignedIdentities/id1": - {}, - }, - }, - tags: { division: "LT", team: "Dev Exp" }, - }; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.beginUpdateAndWait( - resourceGroupName, - loadTestName, - loadTestResourcePatchRequestBody - ); - console.log(result); -} - -async function main() { - loadTestsUpdate(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/operationsListSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/operationsListSample.js deleted file mode 100644 index 3b35da5a6f9c..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/operationsListSample.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Lists all the available API operations for Load Test Resource. - * - * @summary Lists all the available API operations for Load Test Resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Operations_List.json - */ -async function operationsList() { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.operations.list()) { - resArray.push(item); - } - console.log(resArray); -} - -async function main() { - operationsList(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/outboundNetworkDependenciesEndpointsSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/outboundNetworkDependenciesEndpointsSample.js new file mode 100644 index 000000000000..93c04f0c1f5b --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/outboundNetworkDependenciesEndpointsSample.js @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { LoadTestMgmtClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to lists the endpoints that agents may call as part of load testing. + * + * @summary lists the endpoints that agents may call as part of load testing. + * x-ms-original-file: 2024-12-01-preview/LoadTests_ListOutboundNetworkDependenciesEndpoints.json + */ +async function listsTheEndpointsThatAgentsMayCallAsPartOfLoadTesting() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.outboundNetworkDependenciesEndpoints( + "default-azureloadtest-japaneast", + "sampleloadtest", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main() { + await listsTheEndpointsThatAgentsMayCallAsPartOfLoadTesting(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/package.json b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/package.json index 43a18254177d..fccf2968f874 100644 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/package.json +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/package.json @@ -2,7 +2,7 @@ "name": "@azure-samples/arm-loadtesting-js", "private": true, "version": "1.0.0", - "description": " client library samples for JavaScript", + "description": "@azure/arm-loadtesting client library samples for JavaScript", "engines": { "node": ">=18.0.0" }, @@ -14,6 +14,7 @@ "keywords": [ "node", "azure", + "cloud", "typescript", "browser", "isomorphic" @@ -27,6 +28,6 @@ "dependencies": { "@azure/arm-loadtesting": "latest", "dotenv": "latest", - "@azure/identity": "^4.2.1" + "@azure/identity": "^4.9.0" } } diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasCheckAvailabilitySample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasCheckAvailabilitySample.js deleted file mode 100644 index 7a56432f31e5..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasCheckAvailabilitySample.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Check Quota Availability on quota bucket per region per subscription. - * - * @summary Check Quota Availability on quota bucket per region per subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_CheckAvailability.json - */ -async function quotasCheckAvailability() { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const location = "westus"; - const quotaBucketName = "testQuotaBucket"; - const quotaBucketRequest = { - currentQuota: 40, - currentUsage: 20, - dimensions: { location: "westus", subscriptionId: "testsubscriptionId" }, - newQuota: 50, - }; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.quotas.checkAvailability( - location, - quotaBucketName, - quotaBucketRequest - ); - console.log(result); -} - -async function main() { - quotasCheckAvailability(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasGetSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasGetSample.js deleted file mode 100644 index e71c5076e312..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasGetSample.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Get the available quota for a quota bucket per region per subscription. - * - * @summary Get the available quota for a quota bucket per region per subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_Get.json - */ -async function quotasGet() { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const location = "westus"; - const quotaBucketName = "testQuotaBucket"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.quotas.get(location, quotaBucketName); - console.log(result); -} - -async function main() { - quotasGet(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasListSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasListSample.js deleted file mode 100644 index 3da178aa5625..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/quotasListSample.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -const { LoadTestClient } = require("@azure/arm-loadtesting"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv").config(); - -/** - * This sample demonstrates how to Lists all the available quota per region per subscription. - * - * @summary Lists all the available quota per region per subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_List.json - */ -async function quotasList() { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; - const location = "westus"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.quotas.list(location)) { - resArray.push(item); - } - console.log(resArray); -} - -async function main() { - quotasList(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/sample.env b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/sample.env index 672847a3fea0..508439fc7d62 100644 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/sample.env +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/sample.env @@ -1,4 +1 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= \ No newline at end of file +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/updateLoadtestSample.js b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/updateLoadtestSample.js new file mode 100644 index 000000000000..61d5c7663489 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/javascript/updateLoadtestSample.js @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const { LoadTestMgmtClient } = require("@azure/arm-loadtesting"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to update a LoadTestResource + * + * @summary update a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_Update.json + */ +async function updateALoadTestResource() { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + await client.updateLoadtest("dummyrg", "myLoadTest", { + tags: { Team: "Dev Exp", Division: "LT" }, + identity: { + type: "SystemAssigned,UserAssigned", + userAssignedIdentities: { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": + {}, + }, + }, + properties: { + description: "This is new load test resource", + encryption: { + identity: { type: "SystemAssigned", resourceId: null }, + keyUrl: "https://dummy.vault.azure.net/keys/dummykey1", + }, + }, + }); +} + +async function main() { + await updateALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/README.md b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/README.md index 236afd74fb3a..d594923e3ceb 100644 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/README.md +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/README.md @@ -1,20 +1,19 @@ -# client library samples for TypeScript - -These sample programs show how to use the TypeScript client libraries for in some common scenarios. - -| **File Name** | **Description** | -| --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [loadTestsCreateOrUpdateSample.ts][loadtestscreateorupdatesample] | Create or update LoadTest resource. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_CreateOrUpdate.json | -| [loadTestsDeleteSample.ts][loadtestsdeletesample] | Delete a LoadTest resource. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Delete.json | -| [loadTestsGetSample.ts][loadtestsgetsample] | Get a LoadTest resource. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json | -| [loadTestsListByResourceGroupSample.ts][loadtestslistbyresourcegroupsample] | Lists loadtest resources in a resource group. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListByResourceGroup.json | -| [loadTestsListBySubscriptionSample.ts][loadtestslistbysubscriptionsample] | Lists loadtests resources in a subscription. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListBySubscription.json | -| [loadTestsListOutboundNetworkDependenciesEndpointsSample.ts][loadtestslistoutboundnetworkdependenciesendpointssample] | Lists the endpoints that agents may call as part of load testing. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListOutboundNetworkDependenciesEndpoints.json | -| [loadTestsUpdateSample.ts][loadtestsupdatesample] | Update a loadtest resource. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Update.json | -| [operationsListSample.ts][operationslistsample] | Lists all the available API operations for Load Test Resource. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Operations_List.json | -| [quotasCheckAvailabilitySample.ts][quotascheckavailabilitysample] | Check Quota Availability on quota bucket per region per subscription. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_CheckAvailability.json | -| [quotasGetSample.ts][quotasgetsample] | Get the available quota for a quota bucket per region per subscription. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_Get.json | -| [quotasListSample.ts][quotaslistsample] | Lists all the available quota per region per subscription. x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_List.json | +# @azure/arm-loadtesting client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for @azure/arm-loadtesting in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [checkAvailabilityQuotaSample.ts][checkavailabilityquotasample] | check Quota Availability on quota bucket per region per subscription. x-ms-original-file: 2024-12-01-preview/Quotas_CheckAvailability.json | +| [createOrUpdateLoadtestSample.ts][createorupdateloadtestsample] | create a LoadTestResource x-ms-original-file: 2024-12-01-preview/LoadTests_CreateOrUpdate.json | +| [deleteLoadtestSample.ts][deleteloadtestsample] | delete a LoadTestResource x-ms-original-file: 2024-12-01-preview/LoadTests_Delete.json | +| [getLoadtestSample.ts][getloadtestsample] | get a LoadTestResource x-ms-original-file: 2024-12-01-preview/LoadTests_Get.json | +| [getQuotaSample.ts][getquotasample] | get the available quota for a quota bucket per region per subscription. x-ms-original-file: 2024-12-01-preview/Quotas_Get.json | +| [listByResourceGroupSample.ts][listbyresourcegroupsample] | list LoadTestResource resources by resource group x-ms-original-file: 2024-12-01-preview/LoadTests_ListByResourceGroup.json | +| [listBySubscriptionSample.ts][listbysubscriptionsample] | list LoadTestResource resources by subscription ID x-ms-original-file: 2024-12-01-preview/LoadTests_ListBySubscription.json | +| [listQuotaSample.ts][listquotasample] | list quotas for a given subscription Id. x-ms-original-file: 2024-12-01-preview/Quotas_List.json | +| [outboundNetworkDependenciesEndpointsSample.ts][outboundnetworkdependenciesendpointssample] | lists the endpoints that agents may call as part of load testing. x-ms-original-file: 2024-12-01-preview/LoadTests_ListOutboundNetworkDependenciesEndpoints.json | +| [updateLoadtestSample.ts][updateloadtestsample] | update a LoadTestResource x-ms-original-file: 2024-12-01-preview/LoadTests_Update.json | ## Prerequisites @@ -53,30 +52,29 @@ npm run build 4. Run whichever samples you like (note that some samples may require additional setup, see the table above): ```bash -node dist/loadTestsCreateOrUpdateSample.js +node dist/checkAvailabilityQuotaSample.js ``` Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): ```bash -npx dev-tool run vendored cross-env LOADTESTSERVICE_SUBSCRIPTION_ID="" LOADTESTSERVICE_RESOURCE_GROUP="" node dist/loadTestsCreateOrUpdateSample.js +npx dev-tool run vendored cross-env node dist/checkAvailabilityQuotaSample.js ``` ## Next Steps Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. -[loadtestscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsCreateOrUpdateSample.ts -[loadtestsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsDeleteSample.ts -[loadtestsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsGetSample.ts -[loadtestslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListByResourceGroupSample.ts -[loadtestslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListBySubscriptionSample.ts -[loadtestslistoutboundnetworkdependenciesendpointssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListOutboundNetworkDependenciesEndpointsSample.ts -[loadtestsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsUpdateSample.ts -[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/operationsListSample.ts -[quotascheckavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasCheckAvailabilitySample.ts -[quotasgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasGetSample.ts -[quotaslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasListSample.ts +[checkavailabilityquotasample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/checkAvailabilityQuotaSample.ts +[createorupdateloadtestsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/createOrUpdateLoadtestSample.ts +[deleteloadtestsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/deleteLoadtestSample.ts +[getloadtestsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/getLoadtestSample.ts +[getquotasample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/getQuotaSample.ts +[listbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listByResourceGroupSample.ts +[listbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listBySubscriptionSample.ts +[listquotasample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listQuotaSample.ts +[outboundnetworkdependenciesendpointssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/outboundNetworkDependenciesEndpointsSample.ts +[updateloadtestsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/updateLoadtestSample.ts [apiref]: https://learn.microsoft.com/javascript/api/@azure/arm-loadtesting?view=azure-node-preview [freesub]: https://azure.microsoft.com/free/ [package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/arm-loadtesting/README.md diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/package.json b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/package.json index 8f41c44a397c..d603a1757921 100644 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/package.json +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/package.json @@ -2,7 +2,7 @@ "name": "@azure-samples/arm-loadtesting-ts", "private": true, "version": "1.0.0", - "description": " client library samples for TypeScript", + "description": "@azure/arm-loadtesting client library samples for TypeScript", "engines": { "node": ">=18.0.0" }, @@ -18,6 +18,7 @@ "keywords": [ "node", "azure", + "cloud", "typescript", "browser", "isomorphic" @@ -31,7 +32,7 @@ "dependencies": { "@azure/arm-loadtesting": "latest", "dotenv": "latest", - "@azure/identity": "^4.2.1" + "@azure/identity": "^4.9.0" }, "devDependencies": { "@types/node": "^18.0.0", diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/sample.env b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/sample.env index 672847a3fea0..508439fc7d62 100644 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/sample.env +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/sample.env @@ -1,4 +1 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= \ No newline at end of file +# Feel free to add your own environment variables. \ No newline at end of file diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/checkAvailabilityQuotaSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/checkAvailabilityQuotaSample.ts new file mode 100644 index 000000000000..cd509b913423 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/checkAvailabilityQuotaSample.ts @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to check Quota Availability on quota bucket per region per subscription. + * + * @summary check Quota Availability on quota bucket per region per subscription. + * x-ms-original-file: 2024-12-01-preview/Quotas_CheckAvailability.json + */ +async function checkQuotaAvailabilityOnQuotaBucketPerRegionPerSubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.checkAvailabilityQuota("westus", "testQuotaBucket", { + properties: { + currentUsage: 20, + currentQuota: 40, + newQuota: 50, + dimensions: { + subscriptionId: "testsubscriptionId", + location: "westus", + }, + }, + }); + console.log(result); +} + +async function main(): Promise { + await checkQuotaAvailabilityOnQuotaBucketPerRegionPerSubscription(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/createOrUpdateLoadtestSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/createOrUpdateLoadtestSample.ts new file mode 100644 index 000000000000..ce08f9f58309 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/createOrUpdateLoadtestSample.ts @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to create a LoadTestResource + * + * @summary create a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_CreateOrUpdate.json + */ +async function createALoadTestResource(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.createOrUpdateLoadtest("dummyrg", "myLoadTest", { + location: "westus", + tags: { Team: "Dev Exp" }, + identity: { + type: "SystemAssigned,UserAssigned", + userAssignedIdentities: { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": + {}, + }, + }, + properties: { + description: "This is new load test resource", + encryption: { + identity: { + type: "UserAssigned", + resourceId: + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", + }, + keyUrl: "https://dummy.vault.azure.net/keys/dummykey1", + }, + }, + }); + console.log(result); +} + +async function main(): Promise { + await createALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/deleteLoadtestSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/deleteLoadtestSample.ts new file mode 100644 index 000000000000..affacff55256 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/deleteLoadtestSample.ts @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to delete a LoadTestResource + * + * @summary delete a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_Delete.json + */ +async function deleteALoadTestResource(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + await client.deleteLoadtest("dummyrg", "myLoadTest"); +} + +async function main(): Promise { + await deleteALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/getLoadtestSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/getLoadtestSample.ts new file mode 100644 index 000000000000..9bca6756e9bf --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/getLoadtestSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get a LoadTestResource + * + * @summary get a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_Get.json + */ +async function getALoadTestResource(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.getLoadtest("dummyrg", "myLoadTest"); + console.log(result); +} + +async function main(): Promise { + await getALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/getQuotaSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/getQuotaSample.ts new file mode 100644 index 000000000000..0434277c0a4a --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/getQuotaSample.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to get the available quota for a quota bucket per region per subscription. + * + * @summary get the available quota for a quota bucket per region per subscription. + * x-ms-original-file: 2024-12-01-preview/Quotas_Get.json + */ +async function getTheAvailableQuotaForAQuotaBucketPerRegionPerSubscription(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const result = await client.getQuota("westus", "testQuotaBucket"); + console.log(result); +} + +async function main(): Promise { + await getTheAvailableQuotaForAQuotaBucketPerRegionPerSubscription(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listByResourceGroupSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listByResourceGroupSample.ts new file mode 100644 index 000000000000..9640d566cd81 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listByResourceGroupSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list LoadTestResource resources by resource group + * + * @summary list LoadTestResource resources by resource group + * x-ms-original-file: 2024-12-01-preview/LoadTests_ListByResourceGroup.json + */ +async function listLoadTestResourceResourcesByResourceGroup(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.listByResourceGroup("dummyrg")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listLoadTestResourceResourcesByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listBySubscriptionSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listBySubscriptionSample.ts new file mode 100644 index 000000000000..14558e909efd --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listBySubscriptionSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list LoadTestResource resources by subscription ID + * + * @summary list LoadTestResource resources by subscription ID + * x-ms-original-file: 2024-12-01-preview/LoadTests_ListBySubscription.json + */ +async function listLoadTestResourceResourcesBySubscriptionID(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.listBySubscription()) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listLoadTestResourceResourcesBySubscriptionID(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listQuotaSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listQuotaSample.ts new file mode 100644 index 000000000000..70f5afe9fa8f --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/listQuotaSample.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to list quotas for a given subscription Id. + * + * @summary list quotas for a given subscription Id. + * x-ms-original-file: 2024-12-01-preview/Quotas_List.json + */ +async function listQuotasForAGivenSubscriptionId(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.listQuota("westus")) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listQuotasForAGivenSubscriptionId(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsCreateOrUpdateSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsCreateOrUpdateSample.ts deleted file mode 100644 index 92e5932efc2e..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsCreateOrUpdateSample.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { LoadTestResource, LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Create or update LoadTest resource. - * - * @summary Create or update LoadTest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_CreateOrUpdate.json - */ -async function loadTestsCreateOrUpdate(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || - "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = - process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const loadTestResource: LoadTestResource = { - description: "This is new load test resource", - encryption: { - identity: { - type: "UserAssigned", - resourceId: - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1" - }, - keyUrl: "https://dummy.vault.azure.net/keys/dummykey1" - }, - identity: { - type: "SystemAssigned,UserAssigned", - userAssignedIdentities: { - "/subscriptions/00000000000000000000000000000000/resourceGroups/dummyrg/providers/MicrosoftManagedIdentity/userAssignedIdentities/id1": {} - } - }, - location: "westus", - tags: { team: "Dev Exp" } - }; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.beginCreateOrUpdateAndWait( - resourceGroupName, - loadTestName, - loadTestResource - ); - console.log(result); -} - -async function main(): Promise { - loadTestsCreateOrUpdate(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsDeleteSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsDeleteSample.ts deleted file mode 100644 index 4dec3f0e1ce7..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsDeleteSample.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Delete a LoadTest resource. - * - * @summary Delete a LoadTest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Delete.json - */ -async function loadTestsDelete(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || - "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = - process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.beginDeleteAndWait( - resourceGroupName, - loadTestName - ); - console.log(result); -} - -async function main(): Promise { - loadTestsDelete(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsGetSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsGetSample.ts deleted file mode 100644 index 7f5b83777346..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsGetSample.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Get a LoadTest resource. - * - * @summary Get a LoadTest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json - */ -async function loadTestsGet(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || - "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = - process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.get(resourceGroupName, loadTestName); - console.log(result); -} - -async function main(): Promise { - loadTestsGet(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListByResourceGroupSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListByResourceGroupSample.ts deleted file mode 100644 index 46176f6f4a1f..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListByResourceGroupSample.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Lists loadtest resources in a resource group. - * - * @summary Lists loadtest resources in a resource group. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListByResourceGroup.json - */ -async function loadTestsListByResourceGroup(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || - "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = - process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.loadTests.listByResourceGroup( - resourceGroupName - )) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - loadTestsListByResourceGroup(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListBySubscriptionSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListBySubscriptionSample.ts deleted file mode 100644 index aad85d4e34bb..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListBySubscriptionSample.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Lists loadtests resources in a subscription. - * - * @summary Lists loadtests resources in a subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListBySubscription.json - */ -async function loadTestsListBySubscription(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || - "00000000-0000-0000-0000-000000000000"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.loadTests.listBySubscription()) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - loadTestsListBySubscription(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListOutboundNetworkDependenciesEndpointsSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListOutboundNetworkDependenciesEndpointsSample.ts deleted file mode 100644 index a156cf057321..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsListOutboundNetworkDependenciesEndpointsSample.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Lists the endpoints that agents may call as part of load testing. - * - * @summary Lists the endpoints that agents may call as part of load testing. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListOutboundNetworkDependenciesEndpoints.json - */ -async function listOutboundNetworkDependencies(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || "subid"; - const resourceGroupName = - process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || - "default-azureloadtest-japaneast"; - const loadTestName = "sampleloadtest"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.loadTests.listOutboundNetworkDependenciesEndpoints( - resourceGroupName, - loadTestName - )) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - listOutboundNetworkDependencies(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsUpdateSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsUpdateSample.ts deleted file mode 100644 index 6c75953bb2b3..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/loadTestsUpdateSample.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { - LoadTestResourcePatchRequestBody, - LoadTestClient -} from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Update a loadtest resource. - * - * @summary Update a loadtest resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Update.json - */ -async function loadTestsUpdate(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || - "00000000-0000-0000-0000-000000000000"; - const resourceGroupName = - process.env["LOADTESTSERVICE_RESOURCE_GROUP"] || "dummyrg"; - const loadTestName = "myLoadTest"; - const loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody = { - description: "This is new load test resource", - encryption: { - identity: { type: "SystemAssigned", resourceId: undefined }, - keyUrl: "https://dummy.vault.azure.net/keys/dummykey1" - }, - identity: { - type: "SystemAssigned,UserAssigned", - userAssignedIdentities: { - "/subscriptions/00000000000000000000000000000000/resourceGroups/dummyrg/providers/MicrosoftManagedIdentity/userAssignedIdentities/id1": {} - } - }, - tags: { division: "LT", team: "Dev Exp" } - }; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.loadTests.beginUpdateAndWait( - resourceGroupName, - loadTestName, - loadTestResourcePatchRequestBody - ); - console.log(result); -} - -async function main(): Promise { - loadTestsUpdate(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/operationsListSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/operationsListSample.ts deleted file mode 100644 index afd8934d50e9..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/operationsListSample.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Lists all the available API operations for Load Test Resource. - * - * @summary Lists all the available API operations for Load Test Resource. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Operations_List.json - */ -async function operationsList(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || - "00000000-0000-0000-0000-000000000000"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.operations.list()) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - operationsList(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/outboundNetworkDependenciesEndpointsSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/outboundNetworkDependenciesEndpointsSample.ts new file mode 100644 index 000000000000..853fc08f3e42 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/outboundNetworkDependenciesEndpointsSample.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to lists the endpoints that agents may call as part of load testing. + * + * @summary lists the endpoints that agents may call as part of load testing. + * x-ms-original-file: 2024-12-01-preview/LoadTests_ListOutboundNetworkDependenciesEndpoints.json + */ +async function listsTheEndpointsThatAgentsMayCallAsPartOfLoadTesting(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + const resArray = new Array(); + for await (const item of client.outboundNetworkDependenciesEndpoints( + "default-azureloadtest-japaneast", + "sampleloadtest", + )) { + resArray.push(item); + } + + console.log(resArray); +} + +async function main(): Promise { + await listsTheEndpointsThatAgentsMayCallAsPartOfLoadTesting(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasCheckAvailabilitySample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasCheckAvailabilitySample.ts deleted file mode 100644 index 46d4833a504c..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasCheckAvailabilitySample.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { QuotaBucketRequest, LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Check Quota Availability on quota bucket per region per subscription. - * - * @summary Check Quota Availability on quota bucket per region per subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_CheckAvailability.json - */ -async function quotasCheckAvailability(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || - "00000000-0000-0000-0000-000000000000"; - const location = "westus"; - const quotaBucketName = "testQuotaBucket"; - const quotaBucketRequest: QuotaBucketRequest = { - currentQuota: 40, - currentUsage: 20, - dimensions: { location: "westus", subscriptionId: "testsubscriptionId" }, - newQuota: 50 - }; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.quotas.checkAvailability( - location, - quotaBucketName, - quotaBucketRequest - ); - console.log(result); -} - -async function main(): Promise { - quotasCheckAvailability(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasGetSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasGetSample.ts deleted file mode 100644 index f4d80995c9d1..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasGetSample.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Get the available quota for a quota bucket per region per subscription. - * - * @summary Get the available quota for a quota bucket per region per subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_Get.json - */ -async function quotasGet(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || - "00000000-0000-0000-0000-000000000000"; - const location = "westus"; - const quotaBucketName = "testQuotaBucket"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const result = await client.quotas.get(location, quotaBucketName); - console.log(result); -} - -async function main(): Promise { - quotasGet(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasListSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasListSample.ts deleted file mode 100644 index 6ac0603bb215..000000000000 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/quotasListSample.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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. - */ - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { LoadTestClient } from "@azure/arm-loadtesting"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -/** - * This sample demonstrates how to Lists all the available quota per region per subscription. - * - * @summary Lists all the available quota per region per subscription. - * x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_List.json - */ -async function quotasList(): Promise { - const subscriptionId = - process.env["LOADTESTSERVICE_SUBSCRIPTION_ID"] || - "00000000-0000-0000-0000-000000000000"; - const location = "westus"; - const credential = new DefaultAzureCredential(); - const client = new LoadTestClient(credential, subscriptionId); - const resArray = new Array(); - for await (let item of client.quotas.list(location)) { - resArray.push(item); - } - console.log(resArray); -} - -async function main(): Promise { - quotasList(); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/updateLoadtestSample.ts b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/updateLoadtestSample.ts new file mode 100644 index 000000000000..100dd26da835 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/src/updateLoadtestSample.ts @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "@azure/arm-loadtesting"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to update a LoadTestResource + * + * @summary update a LoadTestResource + * x-ms-original-file: 2024-12-01-preview/LoadTests_Update.json + */ +async function updateALoadTestResource(): Promise { + const credential = new DefaultAzureCredential(); + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new LoadTestMgmtClient(credential, subscriptionId); + await client.updateLoadtest("dummyrg", "myLoadTest", { + tags: { Team: "Dev Exp", Division: "LT" }, + identity: { + type: "SystemAssigned,UserAssigned", + userAssignedIdentities: { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": + {}, + }, + }, + properties: { + description: "This is new load test resource", + encryption: { + identity: { type: "SystemAssigned", resourceId: null }, + keyUrl: "https://dummy.vault.azure.net/keys/dummykey1", + }, + }, + }); +} + +async function main(): Promise { + await updateALoadTestResource(); +} + +main().catch(console.error); diff --git a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/tsconfig.json b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/tsconfig.json index 984eed535aa8..400db87cf648 100644 --- a/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/tsconfig.json +++ b/sdk/loadtesting/arm-loadtesting/samples/v1/typescript/tsconfig.json @@ -1,17 +1,20 @@ { "compilerOptions": { - "target": "ES2020", + "target": "ES2023", "module": "commonjs", - "moduleResolution": "node", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, + "lib": [], + "importHelpers": true, "strict": true, - "alwaysStrict": true, - "outDir": "dist", - "rootDir": "src" + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node10", + "esModuleInterop": true, + "outDir": "./dist", + "resolveJsonModule": true }, "include": [ - "src/**/*.ts" + "./src" ] } diff --git a/sdk/loadtesting/arm-loadtesting/src/api/index.ts b/sdk/loadtesting/arm-loadtesting/src/api/index.ts new file mode 100644 index 000000000000..8eb071c5e997 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/api/index.ts @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + createLoadTestMgmt, + LoadTestMgmtContext, + LoadTestMgmtClientOptionalParams, +} from "./loadTestMgmtContext.js"; +export { + checkAvailabilityQuota, + listQuota, + getQuota, + outboundNetworkDependenciesEndpoints, + deleteLoadtest, + updateLoadtest, + createOrUpdateLoadtest, + getLoadtest, + listByResourceGroup, + listBySubscription, +} from "./operations.js"; +export { + CheckAvailabilityQuotaOptionalParams, + ListQuotaOptionalParams, + GetQuotaOptionalParams, + OutboundNetworkDependenciesEndpointsOptionalParams, + DeleteLoadtestOptionalParams, + UpdateLoadtestOptionalParams, + CreateOrUpdateLoadtestOptionalParams, + GetLoadtestOptionalParams, + ListByResourceGroupOptionalParams, + ListBySubscriptionOptionalParams, +} from "./options.js"; diff --git a/sdk/loadtesting/arm-loadtesting/src/api/loadTestMgmtContext.ts b/sdk/loadtesting/arm-loadtesting/src/api/loadTestMgmtContext.ts new file mode 100644 index 000000000000..7009fa22d47f --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/api/loadTestMgmtContext.ts @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { logger } from "../logger.js"; +import { KnownAPIVersions } from "../models/models.js"; +import { Client, ClientOptions, getClient } from "@azure-rest/core-client"; +import { TokenCredential } from "@azure/core-auth"; + +export interface LoadTestMgmtContext extends Client { + /** The API version to use for this operation. */ + /** Known values of {@link KnownAPIVersions} that the service accepts. */ + apiVersion: string; + /** The ID of the target subscription. The value must be an UUID. */ + subscriptionId: string; +} + +/** Optional parameters for the client. */ +export interface LoadTestMgmtClientOptionalParams extends ClientOptions { + /** The API version to use for this operation. */ + /** Known values of {@link KnownAPIVersions} that the service accepts. */ + apiVersion?: string; +} + +export function createLoadTestMgmt( + credential: TokenCredential, + subscriptionId: string, + options: LoadTestMgmtClientOptionalParams = {}, +): LoadTestMgmtContext { + const endpointUrl = options.endpoint ?? options.baseUrl ?? "https://management.azure.com"; + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentInfo = `azsdk-js-arm-loadtesting/2.0.0-beta.1`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}` + : `azsdk-js-api ${userAgentInfo}`; + const { apiVersion: _, ...updatedOptions } = { + ...options, + userAgentOptions: { userAgentPrefix }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + credentials: { + scopes: options.credentials?.scopes ?? [`${endpointUrl}/.default`], + }, + }; + const clientContext = getClient(endpointUrl, credential, updatedOptions); + clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + const apiVersion = options.apiVersion ?? "2024-12-01-preview"; + clientContext.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version")) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); + return { + ...clientContext, + apiVersion, + subscriptionId, + } as LoadTestMgmtContext; +} diff --git a/sdk/loadtesting/arm-loadtesting/src/api/operations.ts b/sdk/loadtesting/arm-loadtesting/src/api/operations.ts new file mode 100644 index 000000000000..82f7cf3a9d94 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/api/operations.ts @@ -0,0 +1,612 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtContext as Client } from "./index.js"; +import { + _LoadTestResourceListResult, + _loadTestResourceListResultDeserializer, + LoadTestResource, + loadTestResourceSerializer, + loadTestResourceDeserializer, + errorResponseDeserializer, + LoadTestResourceUpdate, + loadTestResourceUpdateSerializer, + _PagedOutboundEnvironmentEndpoint, + _pagedOutboundEnvironmentEndpointDeserializer, + OutboundEnvironmentEndpoint, + QuotaResource, + quotaResourceDeserializer, + _QuotaResourceListResult, + _quotaResourceListResultDeserializer, + QuotaBucketRequest, + quotaBucketRequestSerializer, + CheckQuotaAvailabilityResponse, + checkQuotaAvailabilityResponseDeserializer, +} from "../models/models.js"; +import { + CheckAvailabilityQuotaOptionalParams, + ListQuotaOptionalParams, + GetQuotaOptionalParams, + OutboundNetworkDependenciesEndpointsOptionalParams, + DeleteLoadtestOptionalParams, + UpdateLoadtestOptionalParams, + CreateOrUpdateLoadtestOptionalParams, + GetLoadtestOptionalParams, + ListByResourceGroupOptionalParams, + ListBySubscriptionOptionalParams, +} from "./options.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../static-helpers/pagingHelpers.js"; +import { getLongRunningPoller } from "../static-helpers/pollingHelpers.js"; +import { expandUrlTemplate } from "../static-helpers/urlTemplate.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +export function _checkAvailabilityQuotaSend( + context: Client, + location: string, + quotaBucketName: string, + quotaBucketRequest: QuotaBucketRequest, + options: CheckAvailabilityQuotaOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas/{quotaBucketName}/checkAvailabilityQuota{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + location: location, + quotaBucketName: quotaBucketName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: quotaBucketRequestSerializer(quotaBucketRequest), + }); +} + +export async function _checkAvailabilityQuotaDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return checkQuotaAvailabilityResponseDeserializer(result.body); +} + +/** Check Quota Availability on quota bucket per region per subscription. */ +export async function checkAvailabilityQuota( + context: Client, + location: string, + quotaBucketName: string, + quotaBucketRequest: QuotaBucketRequest, + options: CheckAvailabilityQuotaOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _checkAvailabilityQuotaSend( + context, + location, + quotaBucketName, + quotaBucketRequest, + options, + ); + return _checkAvailabilityQuotaDeserialize(result); +} + +export function _listQuotaSend( + context: Client, + location: string, + options: ListQuotaOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + location: location, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listQuotaDeserialize( + result: PathUncheckedResponse, +): Promise<_QuotaResourceListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _quotaResourceListResultDeserializer(result.body); +} + +/** List quotas for a given subscription Id. */ +export function listQuota( + context: Client, + location: string, + options: ListQuotaOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listQuotaSend(context, location, options), + _listQuotaDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _getQuotaSend( + context: Client, + location: string, + quotaBucketName: string, + options: GetQuotaOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas/{quotaBucketName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + location: location, + quotaBucketName: quotaBucketName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getQuotaDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return quotaResourceDeserializer(result.body); +} + +/** Get the available quota for a quota bucket per region per subscription. */ +export async function getQuota( + context: Client, + location: string, + quotaBucketName: string, + options: GetQuotaOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getQuotaSend(context, location, quotaBucketName, options); + return _getQuotaDeserialize(result); +} + +export function _outboundNetworkDependenciesEndpointsSend( + context: Client, + resourceGroupName: string, + loadTestName: string, + options: OutboundNetworkDependenciesEndpointsOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}/outboundNetworkDependenciesEndpoints{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + loadTestName: loadTestName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _outboundNetworkDependenciesEndpointsDeserialize( + result: PathUncheckedResponse, +): Promise<_PagedOutboundEnvironmentEndpoint> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _pagedOutboundEnvironmentEndpointDeserializer(result.body); +} + +/** Lists the endpoints that agents may call as part of load testing. */ +export function outboundNetworkDependenciesEndpoints( + context: Client, + resourceGroupName: string, + loadTestName: string, + options: OutboundNetworkDependenciesEndpointsOptionalParams = { + requestOptions: {}, + }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => + _outboundNetworkDependenciesEndpointsSend(context, resourceGroupName, loadTestName, options), + _outboundNetworkDependenciesEndpointsDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _deleteLoadtestSend( + context: Client, + resourceGroupName: string, + loadTestName: string, + options: DeleteLoadtestOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + loadTestName: loadTestName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _deleteLoadtestDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["202", "204", "200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Delete a LoadTestResource */ +export function deleteLoadtest( + context: Client, + resourceGroupName: string, + loadTestName: string, + options: DeleteLoadtestOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller(context, _deleteLoadtestDeserialize, ["202", "204", "200"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _deleteLoadtestSend(context, resourceGroupName, loadTestName, options), + resourceLocationConfig: "location", + }) as PollerLike, void>; +} + +export function _updateLoadtestSend( + context: Client, + resourceGroupName: string, + loadTestName: string, + loadTestResourcePatchRequestBody: LoadTestResourceUpdate, + options: UpdateLoadtestOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + loadTestName: loadTestName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: loadTestResourceUpdateSerializer(loadTestResourcePatchRequestBody), + }); +} + +export async function _updateLoadtestDeserialize(result: PathUncheckedResponse): Promise { + const expectedStatuses = ["200", "202"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return; +} + +/** Update a LoadTestResource */ +export function updateLoadtest( + context: Client, + resourceGroupName: string, + loadTestName: string, + loadTestResourcePatchRequestBody: LoadTestResourceUpdate, + options: UpdateLoadtestOptionalParams = { requestOptions: {} }, +): PollerLike, void> { + return getLongRunningPoller(context, _updateLoadtestDeserialize, ["200", "202"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _updateLoadtestSend( + context, + resourceGroupName, + loadTestName, + loadTestResourcePatchRequestBody, + options, + ), + resourceLocationConfig: "location", + }) as PollerLike, void>; +} + +export function _createOrUpdateLoadtestSend( + context: Client, + resourceGroupName: string, + loadTestName: string, + loadTestResource: LoadTestResource, + options: CreateOrUpdateLoadtestOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + loadTestName: loadTestName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).put({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: loadTestResourceSerializer(loadTestResource), + }); +} + +export async function _createOrUpdateLoadtestDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200", "201"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return loadTestResourceDeserializer(result.body); +} + +/** Create a LoadTestResource */ +export function createOrUpdateLoadtest( + context: Client, + resourceGroupName: string, + loadTestName: string, + loadTestResource: LoadTestResource, + options: CreateOrUpdateLoadtestOptionalParams = { requestOptions: {} }, +): PollerLike, LoadTestResource> { + return getLongRunningPoller(context, _createOrUpdateLoadtestDeserialize, ["200", "201"], { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + getInitialResponse: () => + _createOrUpdateLoadtestSend( + context, + resourceGroupName, + loadTestName, + loadTestResource, + options, + ), + resourceLocationConfig: "azure-async-operation", + }) as PollerLike, LoadTestResource>; +} + +export function _getLoadtestSend( + context: Client, + resourceGroupName: string, + loadTestName: string, + options: GetLoadtestOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + loadTestName: loadTestName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getLoadtestDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return loadTestResourceDeserializer(result.body); +} + +/** Get a LoadTestResource */ +export async function getLoadtest( + context: Client, + resourceGroupName: string, + loadTestName: string, + options: GetLoadtestOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getLoadtestSend(context, resourceGroupName, loadTestName, options); + return _getLoadtestDeserialize(result); +} + +export function _listByResourceGroupSend( + context: Client, + resourceGroupName: string, + options: ListByResourceGroupOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + resourceGroupName: resourceGroupName, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listByResourceGroupDeserialize( + result: PathUncheckedResponse, +): Promise<_LoadTestResourceListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _loadTestResourceListResultDeserializer(result.body); +} + +/** List LoadTestResource resources by resource group */ +export function listByResourceGroup( + context: Client, + resourceGroupName: string, + options: ListByResourceGroupOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listByResourceGroupSend(context, resourceGroupName, options), + _listByResourceGroupDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _listBySubscriptionSend( + context: Client, + options: ListBySubscriptionOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/loadTests{?api%2Dversion}", + { + subscriptionId: context.subscriptionId, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context.path(path).get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listBySubscriptionDeserialize( + result: PathUncheckedResponse, +): Promise<_LoadTestResourceListResult> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + const error = createRestError(result); + error.details = errorResponseDeserializer(result.body); + throw error; + } + + return _loadTestResourceListResultDeserializer(result.body); +} + +/** List LoadTestResource resources by subscription ID */ +export function listBySubscription( + context: Client, + options: ListBySubscriptionOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listBySubscriptionSend(context, options), + _listBySubscriptionDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} diff --git a/sdk/loadtesting/arm-loadtesting/src/api/options.ts b/sdk/loadtesting/arm-loadtesting/src/api/options.ts new file mode 100644 index 000000000000..11d1d169b895 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/api/options.ts @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface CheckAvailabilityQuotaOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface ListQuotaOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface GetQuotaOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface OutboundNetworkDependenciesEndpointsOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface DeleteLoadtestOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface UpdateLoadtestOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface CreateOrUpdateLoadtestOptionalParams extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; +} + +/** Optional parameters. */ +export interface GetLoadtestOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface ListByResourceGroupOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface ListBySubscriptionOptionalParams extends OperationOptions {} diff --git a/sdk/loadtesting/arm-loadtesting/src/index.ts b/sdk/loadtesting/arm-loadtesting/src/index.ts index 32715dad6614..bd22f0e0d253 100644 --- a/sdk/loadtesting/arm-loadtesting/src/index.ts +++ b/sdk/loadtesting/arm-loadtesting/src/index.ts @@ -1,13 +1,61 @@ -/* - * 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. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. -/// -export { getContinuationToken } from "./pagingHelper.js"; -export * from "./models/index.js"; -export { LoadTestClient } from "./loadTestClient.js"; -export * from "./operationsInterfaces/index.js"; +import { + PageSettings, + ContinuablePage, + PagedAsyncIterableIterator, +} from "./static-helpers/pagingHelpers.js"; + +export { LoadTestMgmtClient } from "./loadTestMgmtClient.js"; +export { restorePoller, RestorePollerOptions } from "./restorePollerHelpers.js"; +export { + LoadTestResource, + LoadTestProperties, + KnownResourceState, + ResourceState, + EncryptionProperties, + EncryptionPropertiesIdentity, + KnownType, + Type, + ManagedServiceIdentity, + KnownManagedServiceIdentityType, + ManagedServiceIdentityType, + UserAssignedIdentity, + TrackedResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + LoadTestResourceUpdate, + LoadTestResourceUpdateProperties, + OutboundEnvironmentEndpoint, + EndpointDependency, + EndpointDetail, + QuotaResource, + QuotaResourceProperties, + ProxyResource, + QuotaBucketRequest, + QuotaBucketRequestProperties, + QuotaBucketRequestPropertiesDimensions, + CheckQuotaAvailabilityResponse, + CheckQuotaAvailabilityResponseProperties, + KnownAPIVersions, +} from "./models/index.js"; +export { + LoadTestMgmtClientOptionalParams, + CheckAvailabilityQuotaOptionalParams, + ListQuotaOptionalParams, + GetQuotaOptionalParams, + OutboundNetworkDependenciesEndpointsOptionalParams, + DeleteLoadtestOptionalParams, + UpdateLoadtestOptionalParams, + CreateOrUpdateLoadtestOptionalParams, + GetLoadtestOptionalParams, + ListByResourceGroupOptionalParams, + ListBySubscriptionOptionalParams, +} from "./api/index.js"; +export { PageSettings, ContinuablePage, PagedAsyncIterableIterator }; diff --git a/sdk/loadtesting/arm-loadtesting/src/loadTestClient.ts b/sdk/loadtesting/arm-loadtesting/src/loadTestClient.ts deleted file mode 100644 index 5da540769bb9..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/loadTestClient.ts +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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/index.js"; -import { Operations, Quotas, LoadTests } from "./operationsInterfaces/index.js"; -import { LoadTestClientOptionalParams } from "./models/index.js"; - -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.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/loadtesting/arm-loadtesting/src/loadTestMgmtClient.ts b/sdk/loadtesting/arm-loadtesting/src/loadTestMgmtClient.ts new file mode 100644 index 000000000000..6a8687bf0b9d --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/loadTestMgmtClient.ts @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + createLoadTestMgmt, + LoadTestMgmtContext, + LoadTestMgmtClientOptionalParams, +} from "./api/index.js"; +import { + LoadTestResource, + LoadTestResourceUpdate, + OutboundEnvironmentEndpoint, + QuotaResource, + QuotaBucketRequest, + CheckQuotaAvailabilityResponse, +} from "./models/models.js"; +import { + CheckAvailabilityQuotaOptionalParams, + ListQuotaOptionalParams, + GetQuotaOptionalParams, + OutboundNetworkDependenciesEndpointsOptionalParams, + DeleteLoadtestOptionalParams, + UpdateLoadtestOptionalParams, + CreateOrUpdateLoadtestOptionalParams, + GetLoadtestOptionalParams, + ListByResourceGroupOptionalParams, + ListBySubscriptionOptionalParams, +} from "./api/options.js"; +import { + checkAvailabilityQuota, + listQuota, + getQuota, + outboundNetworkDependenciesEndpoints, + deleteLoadtest, + updateLoadtest, + createOrUpdateLoadtest, + getLoadtest, + listByResourceGroup, + listBySubscription, +} from "./api/operations.js"; +import { PagedAsyncIterableIterator } from "./static-helpers/pagingHelpers.js"; +import { Pipeline } from "@azure/core-rest-pipeline"; +import { TokenCredential } from "@azure/core-auth"; +import { PollerLike, OperationState } from "@azure/core-lro"; + +export { LoadTestMgmtClientOptionalParams } from "./api/loadTestMgmtContext.js"; + +export class LoadTestMgmtClient { + private _client: LoadTestMgmtContext; + /** The pipeline used by this client to make requests */ + public readonly pipeline: Pipeline; + + constructor( + credential: TokenCredential, + subscriptionId: string, + options: LoadTestMgmtClientOptionalParams = {}, + ) { + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-client` + : `azsdk-js-client`; + this._client = createLoadTestMgmt(credential, subscriptionId, { + ...options, + userAgentOptions: { userAgentPrefix }, + }); + this.pipeline = this._client.pipeline; + } + + /** Check Quota Availability on quota bucket per region per subscription. */ + checkAvailabilityQuota( + location: string, + quotaBucketName: string, + quotaBucketRequest: QuotaBucketRequest, + options: CheckAvailabilityQuotaOptionalParams = { requestOptions: {} }, + ): Promise { + return checkAvailabilityQuota( + this._client, + location, + quotaBucketName, + quotaBucketRequest, + options, + ); + } + + /** List quotas for a given subscription Id. */ + listQuota( + location: string, + options: ListQuotaOptionalParams = { requestOptions: {} }, + ): PagedAsyncIterableIterator { + return listQuota(this._client, location, options); + } + + /** Get the available quota for a quota bucket per region per subscription. */ + getQuota( + location: string, + quotaBucketName: string, + options: GetQuotaOptionalParams = { requestOptions: {} }, + ): Promise { + return getQuota(this._client, location, quotaBucketName, options); + } + + /** Lists the endpoints that agents may call as part of load testing. */ + outboundNetworkDependenciesEndpoints( + resourceGroupName: string, + loadTestName: string, + options: OutboundNetworkDependenciesEndpointsOptionalParams = { + requestOptions: {}, + }, + ): PagedAsyncIterableIterator { + return outboundNetworkDependenciesEndpoints( + this._client, + resourceGroupName, + loadTestName, + options, + ); + } + + /** Delete a LoadTestResource */ + deleteLoadtest( + resourceGroupName: string, + loadTestName: string, + options: DeleteLoadtestOptionalParams = { requestOptions: {} }, + ): PollerLike, void> { + return deleteLoadtest(this._client, resourceGroupName, loadTestName, options); + } + + /** Update a LoadTestResource */ + updateLoadtest( + resourceGroupName: string, + loadTestName: string, + loadTestResourcePatchRequestBody: LoadTestResourceUpdate, + options: UpdateLoadtestOptionalParams = { requestOptions: {} }, + ): PollerLike, void> { + return updateLoadtest( + this._client, + resourceGroupName, + loadTestName, + loadTestResourcePatchRequestBody, + options, + ); + } + + /** Create a LoadTestResource */ + createOrUpdateLoadtest( + resourceGroupName: string, + loadTestName: string, + loadTestResource: LoadTestResource, + options: CreateOrUpdateLoadtestOptionalParams = { requestOptions: {} }, + ): PollerLike, LoadTestResource> { + return createOrUpdateLoadtest( + this._client, + resourceGroupName, + loadTestName, + loadTestResource, + options, + ); + } + + /** Get a LoadTestResource */ + getLoadtest( + resourceGroupName: string, + loadTestName: string, + options: GetLoadtestOptionalParams = { requestOptions: {} }, + ): Promise { + return getLoadtest(this._client, resourceGroupName, loadTestName, options); + } + + /** List LoadTestResource resources by resource group */ + listByResourceGroup( + resourceGroupName: string, + options: ListByResourceGroupOptionalParams = { requestOptions: {} }, + ): PagedAsyncIterableIterator { + return listByResourceGroup(this._client, resourceGroupName, options); + } + + /** List LoadTestResource resources by subscription ID */ + listBySubscription( + options: ListBySubscriptionOptionalParams = { requestOptions: {} }, + ): PagedAsyncIterableIterator { + return listBySubscription(this._client, options); + } +} diff --git a/sdk/loadtesting/arm-loadtesting/src/logger.ts b/sdk/loadtesting/arm-loadtesting/src/logger.ts new file mode 100644 index 000000000000..7063602758e7 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; +export const logger = createClientLogger("arm-loadtesting"); diff --git a/sdk/loadtesting/arm-loadtesting/src/lroImpl.ts b/sdk/loadtesting/arm-loadtesting/src/lroImpl.ts deleted file mode 100644 index 518d5f053b4e..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/lroImpl.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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/loadtesting/arm-loadtesting/src/models/index.ts b/sdk/loadtesting/arm-loadtesting/src/models/index.ts index 6ede8df81609..ae6eb9893612 100644 --- a/sdk/loadtesting/arm-loadtesting/src/models/index.ts +++ b/sdk/loadtesting/arm-loadtesting/src/models/index.ts @@ -1,645 +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. - */ - -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; -} +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + LoadTestResource, + LoadTestProperties, + KnownResourceState, + ResourceState, + EncryptionProperties, + EncryptionPropertiesIdentity, + KnownType, + Type, + ManagedServiceIdentity, + KnownManagedServiceIdentityType, + ManagedServiceIdentityType, + UserAssignedIdentity, + TrackedResource, + Resource, + SystemData, + KnownCreatedByType, + CreatedByType, + ErrorResponse, + ErrorDetail, + ErrorAdditionalInfo, + LoadTestResourceUpdate, + LoadTestResourceUpdateProperties, + OutboundEnvironmentEndpoint, + EndpointDependency, + EndpointDetail, + QuotaResource, + QuotaResourceProperties, + ProxyResource, + QuotaBucketRequest, + QuotaBucketRequestProperties, + QuotaBucketRequestPropertiesDimensions, + CheckQuotaAvailabilityResponse, + CheckQuotaAvailabilityResponseProperties, + KnownAPIVersions, +} from "./models.js"; diff --git a/sdk/loadtesting/arm-loadtesting/src/models/mappers.ts b/sdk/loadtesting/arm-loadtesting/src/models/mappers.ts deleted file mode 100644 index 6db038ae0d41..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/models/mappers.ts +++ /dev/null @@ -1,855 +0,0 @@ -/* - * 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/loadtesting/arm-loadtesting/src/models/models.ts b/sdk/loadtesting/arm-loadtesting/src/models/models.ts new file mode 100644 index 000000000000..a46aa6dc8e1e --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/models/models.ts @@ -0,0 +1,744 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** The response of a LoadTestResource list operation. */ +export interface _LoadTestResourceListResult { + /** The LoadTestResource items on this page */ + value: LoadTestResource[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _loadTestResourceListResultDeserializer(item: any): _LoadTestResourceListResult { + return { + value: loadTestResourceArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function loadTestResourceArraySerializer(result: Array): any[] { + return result.map((item) => { + return loadTestResourceSerializer(item); + }); +} + +export function loadTestResourceArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return loadTestResourceDeserializer(item); + }); +} + +/** LoadTest details. */ +export interface LoadTestResource extends TrackedResource { + /** The resource-specific properties for this resource. */ + properties?: LoadTestProperties; + /** The managed service identities assigned to this resource. */ + identity?: ManagedServiceIdentity; +} + +export function loadTestResourceSerializer(item: LoadTestResource): any { + return { + tags: item["tags"], + location: item["location"], + properties: !item["properties"] + ? item["properties"] + : loadTestPropertiesSerializer(item["properties"]), + identity: !item["identity"] + ? item["identity"] + : managedServiceIdentitySerializer(item["identity"]), + }; +} + +export function loadTestResourceDeserializer(item: any): LoadTestResource { + return { + tags: item["tags"], + location: item["location"], + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : loadTestPropertiesDeserializer(item["properties"]), + identity: !item["identity"] + ? item["identity"] + : managedServiceIdentityDeserializer(item["identity"]), + }; +} + +/** LoadTest resource properties. */ +export interface LoadTestProperties { + /** Description of the resource. */ + description?: string; + /** Resource provisioning state. */ + readonly provisioningState?: ResourceState; + /** Resource data plane URI. */ + readonly dataPlaneURI?: string; + /** CMK Encryption property. */ + encryption?: EncryptionProperties; +} + +export function loadTestPropertiesSerializer(item: LoadTestProperties): any { + return { + description: item["description"], + encryption: !item["encryption"] + ? item["encryption"] + : encryptionPropertiesSerializer(item["encryption"]), + }; +} + +export function loadTestPropertiesDeserializer(item: any): LoadTestProperties { + return { + description: item["description"], + provisioningState: item["provisioningState"], + dataPlaneURI: item["dataPlaneURI"], + encryption: !item["encryption"] + ? item["encryption"] + : encryptionPropertiesDeserializer(item["encryption"]), + }; +} + +/** Resources provisioning states. */ +export enum KnownResourceState { + /** Resource has been created. */ + Succeeded = "Succeeded", + /** Resource creation failed. */ + Failed = "Failed", + /** Resource creation was canceled. */ + Canceled = "Canceled", + /** Deleted state. */ + Deleted = "Deleted", +} + +/** + * Resources provisioning states. \ + * {@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**: Resource has been created. \ + * **Failed**: Resource creation failed. \ + * **Canceled**: Resource creation was canceled. \ + * **Deleted**: Deleted state. + */ +export type ResourceState = 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; +} + +export function encryptionPropertiesSerializer(item: EncryptionProperties): any { + return { + identity: !item["identity"] + ? item["identity"] + : encryptionPropertiesIdentitySerializer(item["identity"]), + keyUrl: item["keyUrl"], + }; +} + +export function encryptionPropertiesDeserializer(item: any): EncryptionProperties { + return { + identity: !item["identity"] + ? item["identity"] + : encryptionPropertiesIdentityDeserializer(item["identity"]), + keyUrl: item["keyUrl"], + }; +} + +/** 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/a0a0a0a0-bbbb-cccd-dddd-e1e1e1e1e1e1/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. */ + resourceId?: string | null; +} + +export function encryptionPropertiesIdentitySerializer(item: EncryptionPropertiesIdentity): any { + return { type: item["type"], resourceId: item["resourceId"] }; +} + +export function encryptionPropertiesIdentityDeserializer(item: any): EncryptionPropertiesIdentity { + return { + type: item["type"], + resourceId: item["resourceId"], + }; +} + +/** Managed identity type to use for accessing encryption key Url. */ +export enum KnownType { + /** System assigned identity. */ + SystemAssigned = "SystemAssigned", + /** User assigned identity. */ + UserAssigned = "UserAssigned", +} + +/** + * Managed identity type to use for accessing encryption key Url. \ + * {@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**: System assigned identity. \ + * **UserAssigned**: User assigned identity. + */ +export type Type = 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. */ + readonly principalId?: string; + /** The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. */ + readonly tenantId?: string; + /** The type of managed identity assigned to this resource. */ + type: ManagedServiceIdentityType; + /** The identities assigned to this resource by the user. */ + userAssignedIdentities?: Record; +} + +export function managedServiceIdentitySerializer(item: ManagedServiceIdentity): any { + return { + type: item["type"], + userAssignedIdentities: item["userAssignedIdentities"], + }; +} + +export function managedServiceIdentityDeserializer(item: any): ManagedServiceIdentity { + return { + principalId: item["principalId"], + tenantId: item["tenantId"], + type: item["type"], + userAssignedIdentities: item["userAssignedIdentities"], + }; +} + +/** Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). */ +export enum KnownManagedServiceIdentityType { + /** No managed identity. */ + None = "None", + /** System assigned managed identity. */ + SystemAssigned = "SystemAssigned", + /** User assigned managed identity. */ + UserAssigned = "UserAssigned", + /** System and user assigned managed identity. */ + SystemAssignedUserAssigned = "SystemAssigned,UserAssigned", +} + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). \ + * {@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**: No managed identity. \ + * **SystemAssigned**: System assigned managed identity. \ + * **UserAssigned**: User assigned managed identity. \ + * **SystemAssigned,UserAssigned**: System and user assigned managed identity. + */ +export type ManagedServiceIdentityType = string; + +/** User assigned identity properties */ +export interface UserAssignedIdentity { + /** The client ID of the assigned identity. */ + readonly clientId?: string; + /** The principal ID of the assigned identity. */ + readonly principalId?: string; +} + +export function userAssignedIdentitySerializer(item: UserAssignedIdentity): any { + return item; +} + +export function userAssignedIdentityDeserializer(item: any): UserAssignedIdentity { + return { + clientId: item["clientId"], + principalId: item["principalId"], + }; +} + +/** 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?: Record; + /** The geo-location where the resource lives */ + location: string; +} + +export function trackedResourceSerializer(item: TrackedResource): any { + return { tags: item["tags"], location: item["location"] }; +} + +export function trackedResourceDeserializer(item: any): TrackedResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + tags: item["tags"], + location: item["location"], + }; +} + +/** 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} */ + readonly id?: string; + /** The name of the resource */ + readonly name?: string; + /** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */ + readonly type?: string; + /** Azure Resource Manager metadata containing createdBy and modifiedBy information. */ + readonly systemData?: SystemData; +} + +export function resourceSerializer(item: Resource): any { + return item; +} + +export function resourceDeserializer(item: any): Resource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["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; +} + +export function systemDataDeserializer(item: any): SystemData { + return { + createdBy: item["createdBy"], + createdByType: item["createdByType"], + createdAt: !item["createdAt"] ? item["createdAt"] : new Date(item["createdAt"]), + lastModifiedBy: item["lastModifiedBy"], + lastModifiedByType: item["lastModifiedByType"], + lastModifiedAt: !item["lastModifiedAt"] + ? item["lastModifiedAt"] + : new Date(item["lastModifiedAt"]), + }; +} + +/** The kind of entity that created the resource. */ +export enum KnownCreatedByType { + /** The entity was created by a user. */ + User = "User", + /** The entity was created by an application. */ + Application = "Application", + /** The entity was created by a managed identity. */ + ManagedIdentity = "ManagedIdentity", + /** The entity was created by a key. */ + Key = "Key", +} + +/** + * The kind of entity that created the resource. \ + * {@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**: The entity was created by a user. \ + * **Application**: The entity was created by an application. \ + * **ManagedIdentity**: The entity was created by a managed identity. \ + * **Key**: The entity was created by a key. + */ +export type CreatedByType = string; + +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +export function errorResponseDeserializer(item: any): ErrorResponse { + return { + error: !item["error"] ? item["error"] : errorDetailDeserializer(item["error"]), + }; +} + +/** The error detail. */ +export interface ErrorDetail { + /** The error code. */ + readonly code?: string; + /** The error message. */ + readonly message?: string; + /** The error target. */ + readonly target?: string; + /** The error details. */ + readonly details?: ErrorDetail[]; + /** The error additional info. */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +export function errorDetailDeserializer(item: any): ErrorDetail { + return { + code: item["code"], + message: item["message"], + target: item["target"], + details: !item["details"] ? item["details"] : errorDetailArrayDeserializer(item["details"]), + additionalInfo: !item["additionalInfo"] + ? item["additionalInfo"] + : errorAdditionalInfoArrayDeserializer(item["additionalInfo"]), + }; +} + +export function errorDetailArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorDetailDeserializer(item); + }); +} + +export function errorAdditionalInfoArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return errorAdditionalInfoDeserializer(item); + }); +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** The additional info type. */ + readonly type?: string; + /** The additional info. */ + readonly info?: Record; +} + +export function errorAdditionalInfoDeserializer(item: any): ErrorAdditionalInfo { + return { + type: item["type"], + info: !item["info"] ? item["info"] : _errorAdditionalInfoInfoDeserializer(item["info"]), + }; +} + +/** model interface _ErrorAdditionalInfoInfo */ +export interface _ErrorAdditionalInfoInfo {} + +export function _errorAdditionalInfoInfoDeserializer(item: any): _ErrorAdditionalInfoInfo { + return item; +} + +/** The type used for update operations of the LoadTestResource. */ +export interface LoadTestResourceUpdate { + /** The managed service identities assigned to this resource. */ + identity?: ManagedServiceIdentity; + /** Resource tags. */ + tags?: Record; + /** The resource-specific properties for this resource. */ + properties?: LoadTestResourceUpdateProperties; +} + +export function loadTestResourceUpdateSerializer(item: LoadTestResourceUpdate): any { + return { + identity: !item["identity"] + ? item["identity"] + : managedServiceIdentitySerializer(item["identity"]), + tags: item["tags"], + properties: !item["properties"] + ? item["properties"] + : loadTestResourceUpdatePropertiesSerializer(item["properties"]), + }; +} + +/** The updatable properties of the LoadTestResource. */ +export interface LoadTestResourceUpdateProperties { + /** Description of the resource. */ + description?: string; + /** CMK Encryption property. */ + encryption?: EncryptionProperties; +} + +export function loadTestResourceUpdatePropertiesSerializer( + item: LoadTestResourceUpdateProperties, +): any { + return { + description: item["description"], + encryption: !item["encryption"] + ? item["encryption"] + : encryptionPropertiesSerializer(item["encryption"]), + }; +} + +/** Values returned by the List operation. */ +export interface _PagedOutboundEnvironmentEndpoint { + /** The OutboundEnvironmentEndpoint items on this page */ + value: OutboundEnvironmentEndpoint[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _pagedOutboundEnvironmentEndpointDeserializer( + item: any, +): _PagedOutboundEnvironmentEndpoint { + return { + value: outboundEnvironmentEndpointArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function outboundEnvironmentEndpointArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return outboundEnvironmentEndpointDeserializer(item); + }); +} + +/** 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. */ + readonly category?: string; + /** The endpoints for this service to which the Batch service makes outbound calls. */ + readonly endpoints?: EndpointDependency[]; +} + +export function outboundEnvironmentEndpointDeserializer(item: any): OutboundEnvironmentEndpoint { + return { + category: item["category"], + endpoints: !item["endpoints"] + ? item["endpoints"] + : endpointDependencyArrayDeserializer(item["endpoints"]), + }; +} + +export function endpointDependencyArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return endpointDependencyDeserializer(item); + }); +} + +/** 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. */ + readonly domainName: string; + /** Human-readable supplemental information about the dependency and when it is applicable. */ + readonly description?: string; + /** The list of connection details for this endpoint. */ + readonly endpointDetails?: EndpointDetail[]; +} + +export function endpointDependencyDeserializer(item: any): EndpointDependency { + return { + domainName: item["domainName"], + description: item["description"], + endpointDetails: !item["endpointDetails"] + ? item["endpointDetails"] + : endpointDetailArrayDeserializer(item["endpointDetails"]), + }; +} + +export function endpointDetailArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return endpointDetailDeserializer(item); + }); +} + +/** Details about the connection between the Batch service and the endpoint. */ +export interface EndpointDetail { + /** The port an endpoint is connected to. */ + readonly port?: number; +} + +export function endpointDetailDeserializer(item: any): EndpointDetail { + return { + port: item["port"], + }; +} + +/** Quota bucket details object. */ +export interface QuotaResource extends ProxyResource { + /** The resource-specific properties for this resource. */ + properties?: QuotaResourceProperties; +} + +export function quotaResourceDeserializer(item: any): QuotaResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + properties: !item["properties"] + ? item["properties"] + : quotaResourcePropertiesDeserializer(item["properties"]), + }; +} + +/** Quota bucket resource properties. */ +export interface QuotaResourceProperties { + /** Current quota limit of the quota bucket. */ + limit?: number; + /** Current quota usage of the quota bucket. */ + usage?: number; + /** Resource provisioning state. */ + readonly provisioningState?: ResourceState; +} + +export function quotaResourcePropertiesDeserializer(item: any): QuotaResourceProperties { + return { + limit: item["limit"], + usage: item["usage"], + provisioningState: item["provisioningState"], + }; +} + +/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */ +export interface ProxyResource extends Resource {} + +export function proxyResourceDeserializer(item: any): ProxyResource { + return { + id: item["id"], + name: item["name"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + }; +} + +/** The response of a QuotaResource list operation. */ +export interface _QuotaResourceListResult { + /** The QuotaResource items on this page */ + value: QuotaResource[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _quotaResourceListResultDeserializer(item: any): _QuotaResourceListResult { + return { + value: quotaResourceArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function quotaResourceArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return quotaResourceDeserializer(item); + }); +} + +/** Request object of new quota for a quota bucket. */ +export interface QuotaBucketRequest { + /** Request object of new quota for a quota bucket. */ + properties?: QuotaBucketRequestProperties; +} + +export function quotaBucketRequestSerializer(item: QuotaBucketRequest): any { + return { + properties: !item["properties"] + ? item["properties"] + : quotaBucketRequestPropertiesSerializer(item["properties"]), + }; +} + +/** New quota request request properties. */ +export interface QuotaBucketRequestProperties { + /** 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; +} + +export function quotaBucketRequestPropertiesSerializer(item: QuotaBucketRequestProperties): any { + return { + currentUsage: item["currentUsage"], + currentQuota: item["currentQuota"], + newQuota: item["newQuota"], + dimensions: !item["dimensions"] + ? item["dimensions"] + : quotaBucketRequestPropertiesDimensionsSerializer(item["dimensions"]), + }; +} + +/** 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; +} + +export function quotaBucketRequestPropertiesDimensionsSerializer( + item: QuotaBucketRequestPropertiesDimensions, +): any { + return { subscriptionId: item["subscriptionId"], location: item["location"] }; +} + +/** Check quota availability response object. */ +export interface CheckQuotaAvailabilityResponse { + /** Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} */ + readonly id: string; + /** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */ + readonly type: string; + /** Azure Resource Manager metadata containing createdBy and modifiedBy information. */ + readonly systemData?: SystemData; + /** The name of the resource. */ + readonly name?: string; + /** Check quota availability response properties. */ + properties?: CheckQuotaAvailabilityResponseProperties; +} + +export function checkQuotaAvailabilityResponseDeserializer( + item: any, +): CheckQuotaAvailabilityResponse { + return { + id: item["id"], + type: item["type"], + systemData: !item["systemData"] + ? item["systemData"] + : systemDataDeserializer(item["systemData"]), + name: item["name"], + properties: !item["properties"] + ? item["properties"] + : checkQuotaAvailabilityResponsePropertiesDeserializer(item["properties"]), + }; +} + +/** Check quota availability response properties. */ +export interface CheckQuotaAvailabilityResponseProperties { + /** 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; +} + +export function checkQuotaAvailabilityResponsePropertiesDeserializer( + item: any, +): CheckQuotaAvailabilityResponseProperties { + return { + isAvailable: item["isAvailable"], + availabilityStatus: item["availabilityStatus"], + }; +} + +/** The Loadtest service resource manager version. */ +export enum KnownAPIVersions { + /** The 2022-12-01 version of the Azure Load Testing Resource manager API. */ + V20221201 = "2022-12-01", + /** The 2023-12-01-preview version of the Azure Load Testing Resource manager API. */ + V20231201Preview = "2023-12-01-preview", + /** The 2024-12-01-preview version of the Azure Load Testing Resource manager API. */ + V20241201Preview = "2024-12-01-preview", +} diff --git a/sdk/loadtesting/arm-loadtesting/src/models/parameters.ts b/sdk/loadtesting/arm-loadtesting/src/models/parameters.ts deleted file mode 100644 index 52b2155dc0e2..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/models/parameters.ts +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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.js"; - -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/loadtesting/arm-loadtesting/src/operations/index.ts b/sdk/loadtesting/arm-loadtesting/src/operations/index.ts deleted file mode 100644 index 564583074167..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/operations/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * 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.js"; -export * from "./quotas.js"; -export * from "./loadTests.js"; diff --git a/sdk/loadtesting/arm-loadtesting/src/operations/loadTests.ts b/sdk/loadtesting/arm-loadtesting/src/operations/loadTests.ts deleted file mode 100644 index 1b9af42774df..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/operations/loadTests.ts +++ /dev/null @@ -1,884 +0,0 @@ -/* - * 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.js"; -import { LoadTests } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import { LoadTestClient } from "../loadTestClient.js"; -import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; -import { LroImpl } from "../lroImpl.js"; -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/index.js"; - -/// -/** 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/loadtesting/arm-loadtesting/src/operations/operations.ts b/sdk/loadtesting/arm-loadtesting/src/operations/operations.ts deleted file mode 100644 index 5ef167139fff..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/operations/operations.ts +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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.js"; -import { Operations } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import { LoadTestClient } from "../loadTestClient.js"; -import { - Operation, - OperationsListNextOptionalParams, - OperationsListOptionalParams, - OperationsListResponse, - OperationsListNextResponse -} from "../models/index.js"; - -/// -/** 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/loadtesting/arm-loadtesting/src/operations/quotas.ts b/sdk/loadtesting/arm-loadtesting/src/operations/quotas.ts deleted file mode 100644 index 16bc721c48aa..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/operations/quotas.ts +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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.js"; -import { Quotas } from "../operationsInterfaces/index.js"; -import * as coreClient from "@azure/core-client"; -import * as Mappers from "../models/mappers.js"; -import * as Parameters from "../models/parameters.js"; -import { LoadTestClient } from "../loadTestClient.js"; -import { - QuotaResource, - QuotasListNextOptionalParams, - QuotasListOptionalParams, - QuotasListResponse, - QuotasGetOptionalParams, - QuotasGetResponse, - QuotaBucketRequest, - QuotasCheckAvailabilityOptionalParams, - QuotasCheckAvailabilityResponse, - QuotasListNextResponse -} from "../models/index.js"; - -/// -/** 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/loadtesting/arm-loadtesting/src/operationsInterfaces/index.ts b/sdk/loadtesting/arm-loadtesting/src/operationsInterfaces/index.ts deleted file mode 100644 index 564583074167..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/operationsInterfaces/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * 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.js"; -export * from "./quotas.js"; -export * from "./loadTests.js"; diff --git a/sdk/loadtesting/arm-loadtesting/src/operationsInterfaces/loadTests.ts b/sdk/loadtesting/arm-loadtesting/src/operationsInterfaces/loadTests.ts deleted file mode 100644 index 3d7346b97e2a..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/operationsInterfaces/loadTests.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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/index.js"; - -/// -/** 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/loadtesting/arm-loadtesting/src/operationsInterfaces/operations.ts b/sdk/loadtesting/arm-loadtesting/src/operationsInterfaces/operations.ts deleted file mode 100644 index ea7e2cd0090c..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/operationsInterfaces/operations.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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/index.js"; - -/// -/** 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/loadtesting/arm-loadtesting/src/operationsInterfaces/quotas.ts b/sdk/loadtesting/arm-loadtesting/src/operationsInterfaces/quotas.ts deleted file mode 100644 index de900f8ab4ec..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/operationsInterfaces/quotas.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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/index.js"; - -/// -/** 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/loadtesting/arm-loadtesting/src/pagingHelper.ts b/sdk/loadtesting/arm-loadtesting/src/pagingHelper.ts deleted file mode 100644 index 269a2b9814b5..000000000000 --- a/sdk/loadtesting/arm-loadtesting/src/pagingHelper.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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/loadtesting/arm-loadtesting/src/restorePollerHelpers.ts b/sdk/loadtesting/arm-loadtesting/src/restorePollerHelpers.ts new file mode 100644 index 000000000000..9f8c25ec75ae --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/restorePollerHelpers.ts @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { LoadTestMgmtClient } from "./loadTestMgmtClient.js"; +import { + _deleteLoadtestDeserialize, + _updateLoadtestDeserialize, + _createOrUpdateLoadtestDeserialize, +} from "./api/operations.js"; +import { getLongRunningPoller } from "./static-helpers/pollingHelpers.js"; +import { OperationOptions, PathUncheckedResponse } from "@azure-rest/core-client"; +import { AbortSignalLike } from "@azure/abort-controller"; +import { + PollerLike, + OperationState, + deserializeState, + ResourceLocationConfig, +} from "@azure/core-lro"; + +export interface RestorePollerOptions< + TResult, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +> extends OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** + * The signal which can be used to abort requests. + */ + abortSignal?: AbortSignalLike; + /** Deserialization function for raw response body */ + processResponseBody?: (result: TResponse) => Promise; +} + +/** + * Creates a poller from the serialized state of another poller. This can be + * useful when you want to create pollers on a different host or a poller + * needs to be constructed after the original one is not in scope. + */ +export function restorePoller( + client: LoadTestMgmtClient, + serializedState: string, + sourceOperation: (...args: any[]) => PollerLike, TResult>, + options?: RestorePollerOptions, +): PollerLike, TResult> { + const pollerConfig = deserializeState(serializedState).config; + const { initialRequestUrl, requestMethod, metadata } = pollerConfig; + if (!initialRequestUrl || !requestMethod) { + throw new Error( + `Invalid serialized state: ${serializedState} for sourceOperation ${sourceOperation?.name}`, + ); + } + const resourceLocationConfig = metadata?.["resourceLocationConfig"] as + | ResourceLocationConfig + | undefined; + const { deserializer, expectedStatuses = [] } = + getDeserializationHelper(initialRequestUrl, requestMethod) ?? {}; + const deserializeHelper = options?.processResponseBody ?? deserializer; + if (!deserializeHelper) { + throw new Error( + `Please ensure the operation is in this client! We can't find its deserializeHelper for ${sourceOperation?.name}.`, + ); + } + return getLongRunningPoller( + (client as any)["_client"] ?? client, + deserializeHelper as (result: TResponse) => Promise, + expectedStatuses, + { + updateIntervalInMs: options?.updateIntervalInMs, + abortSignal: options?.abortSignal, + resourceLocationConfig, + restoreFrom: serializedState, + initialRequestUrl, + }, + ); +} + +interface DeserializationHelper { + deserializer: Function; + expectedStatuses: string[]; +} + +const deserializeMap: Record = { + "DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}": + { + deserializer: _deleteLoadtestDeserialize, + expectedStatuses: ["202", "204", "200"], + }, + "PATCH /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}": + { + deserializer: _updateLoadtestDeserialize, + expectedStatuses: ["200", "202"], + }, + "PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}": + { + deserializer: _createOrUpdateLoadtestDeserialize, + expectedStatuses: ["200", "201"], + }, +}; + +function getDeserializationHelper( + urlStr: string, + method: string, +): DeserializationHelper | undefined { + const path = new URL(urlStr).pathname; + const pathParts = path.split("/"); + + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: DeserializationHelper | undefined; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(deserializeMap)) { + // Extracting the path from the map key which is in format + // GET /path/foo + if (!key.startsWith(method)) { + continue; + } + const candidatePath = getPathFromMapKey(key); + // Get each part of the url path + const candidateParts = candidatePath.split("/"); + + // track if we have found a match to return the values found. + let found = true; + for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) { + if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test( + pathParts[j] || "", + ); + + if (!isMatched) { + found = false; + break; + } + continue; + } + + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; + } + } + + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } + + return matchedValue; +} + +function getPathFromMapKey(mapKey: string): string { + const pathStart = mapKey.indexOf("/"); + return mapKey.slice(pathStart); +} diff --git a/sdk/loadtesting/arm-loadtesting/src/static-helpers/pagingHelpers.ts b/sdk/loadtesting/arm-loadtesting/src/static-helpers/pagingHelpers.ts new file mode 100644 index 000000000000..ce33af5f4178 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/static-helpers/pagingHelpers.ts @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; +import { RestError } from "@azure/core-rest-pipeline"; + +/** + * Options for the byPage method + */ +export interface PageSettings { + /** + * A reference to a specific page to start iterating from. + */ + continuationToken?: string; +} + +/** + * An interface that describes a page of results. + */ +export type ContinuablePage = TPage & { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +}; + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: (settings?: TPageSettings) => AsyncIterableIterator>; +} + +/** + * An interface that describes how to communicate with the service. + */ +export interface PagedResult< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * Link to the first page of results. + */ + firstPageLink?: string; + /** + * A method that returns a page of results. + */ + getPage: (pageLink?: string) => Promise<{ page: TPage; nextPageLink?: string } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: (settings?: TPageSettings) => AsyncIterableIterator>; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => TElement[]; +} + +/** + * Options for the paging helper + */ +export interface BuildPagedAsyncIteratorOptions { + itemName?: string; + nextLinkName?: string; +} + +/** + * Helper to paginate results in a generic way and return a PagedAsyncIterableIterator + */ +export function buildPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +>( + client: Client, + getInitialResponse: () => PromiseLike, + processResponseBody: (result: TResponse) => PromiseLike, + expectedStatuses: string[], + options: BuildPagedAsyncIteratorOptions = {}, +): PagedAsyncIterableIterator { + const itemName = options.itemName ?? "value"; + const nextLinkName = options.nextLinkName ?? "nextLink"; + const pagedResult: PagedResult = { + getPage: async (pageLink?: string) => { + const result = + pageLink === undefined + ? await getInitialResponse() + : await client.pathUnchecked(pageLink).get(); + checkPagingRequest(result, expectedStatuses); + const results = await processResponseBody(result as TResponse); + const nextLink = getNextLink(results, nextLinkName); + const values = getElements(results, itemName) as TPage; + return { + page: values, + nextPageLink: nextLink, + }; + }, + byPage: (settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }, + }; + return getPagedAsyncIterator(pagedResult); +} + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ + +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator(pagedResult); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + ((settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + for await (const page of pages) { + yield* page as unknown as TElement[]; + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: string; + } = {}, +): AsyncIterableIterator> { + const { pageLink } = options; + let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink); + if (!response) { + return; + } + let result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + } +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined" && nextLink !== null) { + throw new RestError( + `Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`, + ); + } + + if (nextLink === null) { + return undefined; + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + if (!Array.isArray(value)) { + throw new RestError( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`, + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse, expectedStatuses: string[]): void { + if (!expectedStatuses.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response, + ); + } +} diff --git a/sdk/loadtesting/arm-loadtesting/src/static-helpers/pollingHelpers.ts b/sdk/loadtesting/arm-loadtesting/src/static-helpers/pollingHelpers.ts new file mode 100644 index 000000000000..f01c41bab69d --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/static-helpers/pollingHelpers.ts @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + PollerLike, + OperationState, + ResourceLocationConfig, + RunningOperation, + createHttpPoller, + OperationResponse, +} from "@azure/core-lro"; + +import { Client, PathUncheckedResponse, createRestError } from "@azure-rest/core-client"; +import { AbortSignalLike } from "@azure/abort-controller"; + +export interface GetLongRunningPollerOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** + * The signal which can be used to abort requests. + */ + abortSignal?: AbortSignalLike; + /** + * The potential location of the result of the LRO if specified by the LRO extension in the swagger. + */ + resourceLocationConfig?: ResourceLocationConfig; + /** + * The original url of the LRO + * Should not be null when restoreFrom is set + */ + initialRequestUrl?: string; + /** + * A serialized poller which can be used to resume an existing paused Long-Running-Operation. + */ + restoreFrom?: string; + /** + * The function to get the initial response + */ + getInitialResponse?: () => PromiseLike; +} +export function getLongRunningPoller( + client: Client, + processResponseBody: (result: TResponse) => Promise, + expectedStatuses: string[], + options: GetLongRunningPollerOptions, +): PollerLike, TResult> { + const { restoreFrom, getInitialResponse } = options; + if (!restoreFrom && !getInitialResponse) { + throw new Error("Either restoreFrom or getInitialResponse must be specified"); + } + let initialResponse: TResponse | undefined = undefined; + const pollAbortController = new AbortController(); + const poller: RunningOperation = { + sendInitialRequest: async () => { + if (!getInitialResponse) { + throw new Error("getInitialResponse is required when initializing a new poller"); + } + initialResponse = await getInitialResponse(); + return getLroResponse(initialResponse, expectedStatuses); + }, + sendPollRequest: async ( + path: string, + pollOptions?: { + abortSignal?: AbortSignalLike; + }, + ) => { + // The poll request would both listen to the user provided abort signal and the poller's own abort signal + function abortListener(): void { + pollAbortController.abort(); + } + const abortSignal = pollAbortController.signal; + if (options.abortSignal?.aborted) { + pollAbortController.abort(); + } else if (pollOptions?.abortSignal?.aborted) { + pollAbortController.abort(); + } else if (!abortSignal.aborted) { + options.abortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + pollOptions?.abortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + } + let response; + try { + response = await client.pathUnchecked(path).get({ abortSignal }); + } finally { + options.abortSignal?.removeEventListener("abort", abortListener); + pollOptions?.abortSignal?.removeEventListener("abort", abortListener); + } + + return getLroResponse(response as TResponse, expectedStatuses); + }, + }; + return createHttpPoller(poller, { + intervalInMs: options?.updateIntervalInMs, + resourceLocationConfig: options?.resourceLocationConfig, + restoreFrom: options?.restoreFrom, + processResult: (result: unknown) => { + return processResponseBody(result as TResponse); + }, + }); +} +/** + * Converts a Rest Client response to a response that the LRO implementation understands + * @param response - a rest client http response + * @param deserializeFn - deserialize function to convert Rest response to modular output + * @returns - An LRO response that the LRO implementation understands + */ +function getLroResponse( + response: TResponse, + expectedStatuses: string[], +): OperationResponse { + if (!expectedStatuses.includes(response.status)) { + throw createRestError(response); + } + + return { + flatResponse: response, + rawResponse: { + ...response, + statusCode: Number.parseInt(response.status), + body: response.body, + }, + }; +} diff --git a/sdk/loadtesting/arm-loadtesting/src/static-helpers/urlTemplate.ts b/sdk/loadtesting/arm-loadtesting/src/static-helpers/urlTemplate.ts new file mode 100644 index 000000000000..cd03319fda35 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/src/static-helpers/urlTemplate.ts @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//--------------------- +// interfaces +//--------------------- +interface ValueOptions { + isFirst: boolean; // is first value in the expression + op?: string; // operator + varValue?: any; // variable value + varName?: string; // variable name + modifier?: string; // modifier e.g * + reserved?: boolean; // if true we'll keep reserved words with not encoding +} + +export interface UrlTemplateOptions { + // if set to true, reserved characters will not be encoded + allowReserved?: boolean; +} + +// --------------------- +// helpers +// --------------------- +function encodeComponent(val: string, reserved?: boolean, op?: string) { + return (reserved ?? op === "+") || op === "#" + ? encodeReservedComponent(val) + : encodeRFC3986URIComponent(val); +} + +function encodeReservedComponent(str: string) { + return str + .split(/(%[0-9A-Fa-f]{2})/g) + .map((part) => (!/%[0-9A-Fa-f]/.test(part) ? encodeURI(part) : part)) + .join(""); +} + +function encodeRFC3986URIComponent(str: string) { + return encodeURIComponent(str).replace( + /[!'()*]/g, + (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`, + ); +} + +function isDefined(val: any) { + return val !== undefined && val !== null; +} + +function getNamedAndIfEmpty(op?: string): [boolean, string] { + return [!!op && [";", "?", "&"].includes(op), !!op && ["?", "&"].includes(op) ? "=" : ""]; +} + +function getFirstOrSep(op?: string, isFirst = false) { + if (isFirst) { + return !op || op === "+" ? "" : op; + } else if (!op || op === "+" || op === "#") { + return ","; + } else if (op === "?") { + return "&"; + } else { + return op; + } +} + +function getExpandedValue(option: ValueOptions) { + let isFirst = option.isFirst; + const { op, varName, varValue: value, reserved } = option; + const vals: string[] = []; + const [named, ifEmpty] = getNamedAndIfEmpty(op); + + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + // prepare the following parts: separator, varName, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (named && varName) { + vals.push(`${encodeURIComponent(varName)}`); + val === "" ? vals.push(ifEmpty) : vals.push("="); + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + const val = value[key]; + if (!isDefined(val)) { + continue; + } + // prepare the following parts: separator, key, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (key) { + vals.push(`${encodeURIComponent(key)}`); + named && val === "" ? vals.push(ifEmpty) : vals.push("="); + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } + return vals.join(""); +} + +function getNonExpandedValue(option: ValueOptions) { + const { op, varName, varValue: value, isFirst, reserved } = option; + const vals: string[] = []; + const first = getFirstOrSep(op, isFirst); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + if (named && varName) { + vals.push(encodeComponent(varName, reserved, op)); + if (value === "") { + if (!ifEmpty) { + vals.push(ifEmpty); + } + return !vals.join("") ? undefined : `${first}${vals.join("")}`; + } + vals.push("="); + } + + const items = []; + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + items.push(encodeComponent(val, reserved, op)); + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + if (!isDefined(value[key])) { + continue; + } + items.push(encodeRFC3986URIComponent(key)); + items.push(encodeComponent(value[key], reserved, op)); + } + } + vals.push(items.join(",")); + return !vals.join(",") ? undefined : `${first}${vals.join("")}`; +} + +function getVarValue(option: ValueOptions): string | undefined { + const { op, varName, modifier, isFirst, reserved, varValue: value } = option; + + if (!isDefined(value)) { + return undefined; + } else if (["string", "number", "boolean"].includes(typeof value)) { + let val = value.toString(); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + const vals: string[] = [getFirstOrSep(op, isFirst)]; + if (named && varName) { + // No need to encode varName considering it is already encoded + vals.push(varName); + val === "" ? vals.push(ifEmpty) : vals.push("="); + } + if (modifier && modifier !== "*") { + val = val.substring(0, parseInt(modifier, 10)); + } + vals.push(encodeComponent(val, reserved, op)); + return vals.join(""); + } else if (modifier === "*") { + return getExpandedValue(option); + } else { + return getNonExpandedValue(option); + } +} + +// --------------------------------------------------------------------------------------------------- +// This is an implementation of RFC 6570 URI Template: https://datatracker.ietf.org/doc/html/rfc6570. +// --------------------------------------------------------------------------------------------------- +export function expandUrlTemplate( + template: string, + context: Record, + option?: UrlTemplateOptions, +): string { + return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, (_, expr, text) => { + if (!expr) { + return encodeReservedComponent(text); + } + let op; + if (["+", "#", ".", "/", ";", "?", "&"].includes(expr[0])) { + (op = expr[0]), (expr = expr.slice(1)); + } + const varList = expr.split(/,/g); + const result = []; + for (const varSpec of varList) { + const varMatch = /([^:\*]*)(?::(\d+)|(\*))?/.exec(varSpec); + if (!varMatch || !varMatch[1]) { + continue; + } + const varValue = getVarValue({ + isFirst: result.length === 0, + op, + varValue: context[varMatch[1]], + varName: varMatch[1], + modifier: varMatch[2] || varMatch[3], + reserved: option?.allowReserved, + }); + if (varValue) { + result.push(varValue); + } + } + return result.join(""); + }); +} diff --git a/sdk/loadtesting/arm-loadtesting/test/loadtesting_quota_operations.spec.ts b/sdk/loadtesting/arm-loadtesting/test/loadtesting_quota_operations.spec.ts deleted file mode 100644 index 2c8120e0e85d..000000000000 --- a/sdk/loadtesting/arm-loadtesting/test/loadtesting_quota_operations.spec.ts +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 type { RecorderStartOptions } from "@azure-tools/test-recorder"; -import { env, Recorder } from "@azure-tools/test-recorder"; -import { LoadTestClient } from "../src/loadTestClient.js"; -import { createTestCredential } from "@azure-tools/test-credential"; -import type { - QuotaBucketRequest, - QuotaBucketRequestPropertiesDimensions, -} from "../src/models/index.js"; -import { describe, it, assert, beforeEach, afterEach, beforeAll } from "vitest"; - -const replaceableVariables: Record = { - SUBSCRIPTION_ID: "00000000-0000-0000-0000-000000000000", -}; - -const recorderOptions: RecorderStartOptions = { - envSetupForPlayback: replaceableVariables, - removeCentralSanitizers: [ - "AZSDK3493", // .name in the body is not a secret and is listed below in the beforeEach section - "AZSDK3430", // .id in the body is not a secret and is listed below in the beforeEach section - ], -}; - -describe("Load Testing Quota Operations", () => { - let recorder: Recorder; - let subscriptionId: string; - let client: LoadTestClient; - let location: string; - let quotaBucketRequestPayload: QuotaBucketRequest; - let quotaBucketRequestDimensions: QuotaBucketRequestPropertiesDimensions; - let quotaBucketName: string; - - beforeAll(() => { - // Quota bucket request payload - quotaBucketRequestDimensions = { - location: location, - subscriptionId: subscriptionId, - }; - - // Set the global variables to be used in the tests - location = env.LOCATION || "westus2"; - quotaBucketName = "maxEngineInstancesPerTestRun"; - }); - - beforeEach(async (ctx) => { - recorder = new Recorder(ctx); - await recorder.start(recorderOptions); - subscriptionId = env.SUBSCRIPTION_ID || "00000000-0000-0000-0000-000000000000"; - const credential = createTestCredential(); - client = new LoadTestClient(credential, subscriptionId, recorder.configureClientOptions({})); - }); - - afterEach(async () => { - await recorder.stop(); - }); - - it("list quota buckets", async () => { - // Get the quota bucket - const result = client.quotas.list(location); - - // Verify the response - for await (const quotaBucket of result) { - assert.isNotNull(quotaBucket.name); - assert.isNotNull(quotaBucket.id); - assert.isNotNull(quotaBucket.type); - assert.isNotNull(quotaBucket.limit); - assert.isNotNull(quotaBucket.usage); - } - }); - - it("get quota bucket", async () => { - // Get the quota bucket - const result = await client.quotas.get(location, quotaBucketName); - - // Verify the response - assert.equal(result.name, quotaBucketName); - assert.isNotNull(result.id); - assert.isNotNull(result.type); - assert.isNotNull(result.limit); - assert.isNotNull(result.usage); - }); - - it("check quota bucket availability", async () => { - // Get the quota bucket - const result = await client.quotas.get(location, quotaBucketName); - - // Verify the response - assert.equal(result.name, quotaBucketName); - assert.isNotNull(result.id); - assert.isNotNull(result.type); - assert.isNotNull(result.limit); - assert.isNotNull(result.usage); - - // Quota bucket check availability request payload - quotaBucketRequestPayload = { - currentQuota: result.limit, - currentUsage: result.usage, - newQuota: result.limit, - dimensions: quotaBucketRequestDimensions, - }; - - // Check the quota bucket availability - const availability = await client.quotas.checkAvailability( - location, - quotaBucketName, - quotaBucketRequestPayload, - ); - - // Verify the response - assert.equal(availability.name, quotaBucketName); - assert.isNotNull(availability.id); - assert.isNotNull(availability.type); - assert.isBoolean(availability.isAvailable); - }); -}); diff --git a/sdk/loadtesting/arm-loadtesting/test/loadtesting_resource_operations.spec.ts b/sdk/loadtesting/arm-loadtesting/test/loadtesting_resource_operations.spec.ts deleted file mode 100644 index 8a2a48cf4430..000000000000 --- a/sdk/loadtesting/arm-loadtesting/test/loadtesting_resource_operations.spec.ts +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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 type { RecorderStartOptions } from "@azure-tools/test-recorder"; -import { env, Recorder, isPlaybackMode } from "@azure-tools/test-recorder"; -import { LoadTestClient } from "../src/loadTestClient.js"; -import { createTestCredential } from "@azure-tools/test-credential"; -import type { LoadTestResource, LoadTestResourcePatchRequestBody } from "../src/models/index.js"; -import { describe, it, assert, beforeEach, afterEach, beforeAll } from "vitest"; - -const replaceableVariables: Record = { - SUBSCRIPTION_ID: "00000000-0000-0000-0000-000000000000", -}; - -const recorderOptions: RecorderStartOptions = { - envSetupForPlayback: replaceableVariables, - removeCentralSanitizers: [ - "AZSDK3493", // .name in the body is not a secret and is listed below in the beforeEach section - "AZSDK3430", // .id in the body is not a secret and is listed below in the beforeEach section - ], -}; - -export const testPollingOptions = { - updateIntervalInMs: isPlaybackMode() ? 0 : undefined, -}; - -describe("Load Testing Resource Operations", () => { - let recorder: Recorder; - let subscriptionId: string; - let client: LoadTestClient; - let location: string; - let resourceGroupName: string; - let loadTestResourceName: string; - let loadTestResourceCreatePayload: LoadTestResource; - let loadTestResourcePatchPayload: LoadTestResourcePatchRequestBody; - - beforeAll(() => { - // Load test resource create payload - loadTestResourceCreatePayload = { - description: "New Load test resource from SDK.", - location: "westus2", - tags: { team: "Azure Load Testing SDK" }, - }; - - // Load test resource patch payload - loadTestResourcePatchPayload = { - identity: { - type: "SystemAssigned", - }, - }; - - // Set the global variables to be used in the tests - location = env.LOCATION || "westus2"; - resourceGroupName = env.RESOURCE_GROUP || "myjstest"; - loadTestResourceName = "loadtestsResource"; - }); - - beforeEach(async (ctx) => { - recorder = new Recorder(ctx); - await recorder.start(recorderOptions); - subscriptionId = env.SUBSCRIPTION_ID || "00000000-0000-0000-0000-000000000000"; - const credential = createTestCredential(); - client = new LoadTestClient(credential, subscriptionId, recorder.configureClientOptions({})); - }); - - afterEach(async () => { - await recorder.stop(); - }); - - it("create resource", async () => { - // Create a load test resource - const resource = await client.loadTests.beginCreateOrUpdateAndWait( - resourceGroupName, - loadTestResourceName, - loadTestResourceCreatePayload, - testPollingOptions, - ); - - // Verify the response - assert.equal(resource.provisioningState, "Succeeded"); - assert.equal(resource.name, loadTestResourceName); - assert.equal(resource.location, location); - assert.equal(resource.tags?.team, loadTestResourceCreatePayload.tags?.team); - assert.equal(resource.description, loadTestResourceCreatePayload.description); - assert.equal(resource.identity?.type, "None"); - }); - - it("get resource", async () => { - // Get the load test resource - const resource = await client.loadTests.get(resourceGroupName, loadTestResourceName); - - // Verify the response - assert.equal(resource.provisioningState, "Succeeded"); - assert.equal(resource.name, loadTestResourceName); - assert.equal(resource.location, location); - assert.equal(resource.tags?.team, loadTestResourceCreatePayload.tags?.team); - assert.equal(resource.description, loadTestResourceCreatePayload.description); - assert.equal(resource.identity?.type, "None"); - }); - - it("patch resource", async () => { - // Patch the load test resource - const result = await client.loadTests.beginUpdateAndWait( - resourceGroupName, - loadTestResourceName, - loadTestResourcePatchPayload, - testPollingOptions, - ); - - // // Get the load test resource - // const patchedResource = await client.loadTests.get( - // resourceGroupName, - // loadTestResourceName - // ); - - // Verify the response - assert.equal(result.provisioningState, "Succeeded"); - assert.equal(result.name, loadTestResourceName); - assert.equal(result.location, location); - assert.equal(result.tags?.team, loadTestResourceCreatePayload.tags?.team); - assert.equal(result.description, loadTestResourceCreatePayload.description); - assert.equal(result.identity?.type, loadTestResourcePatchPayload.identity?.type); - }); - - it("delete resource", async () => { - // Delete the load test resource - }); -}); diff --git a/sdk/loadtesting/arm-loadtesting/test/public/sampleTest.spec.ts b/sdk/loadtesting/arm-loadtesting/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..e4591bbad342 --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/test/public/sampleTest.spec.ts @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { assert, beforeEach, afterEach, it, describe } from "vitest"; + +describe("My test", () => { + // let recorder: Recorder; + + beforeEach(async () => { + // recorder = await createRecorder(this); + }); + + afterEach(async () => { + // await recorder.stop(); + }); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/loadtesting/arm-loadtesting/test/public/utils/recordedClient.ts b/sdk/loadtesting/arm-loadtesting/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..14dcd9fa397c --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/test/public/utils/recordedClient.ts @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Recorder, RecorderStartOptions, VitestTestContext } from "@azure-tools/test-recorder"; + +const replaceableVariables: Record = { + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables, +}; + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export async function createRecorder(context: VitestTestContext): Promise { + const recorder = new Recorder(context); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/loadtesting/arm-loadtesting/test/snippets.spec.ts b/sdk/loadtesting/arm-loadtesting/test/snippets.spec.ts index b27176496637..cc5afb538cb9 100644 --- a/sdk/loadtesting/arm-loadtesting/test/snippets.spec.ts +++ b/sdk/loadtesting/arm-loadtesting/test/snippets.spec.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { LoadTestClient } from "../src/index.js"; +import { LoadTestMgmtClient } from "../src/index.js"; import { DefaultAzureCredential, InteractiveBrowserCredential } from "@azure/identity"; import { setLogLevel } from "@azure/logger"; import { describe, it } from "vitest"; @@ -9,7 +9,7 @@ import { describe, it } from "vitest"; describe("snippets", () => { it("ReadmeSampleCreateClient_Node", async () => { const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); + const client = new LoadTestMgmtClient(new DefaultAzureCredential(), subscriptionId); }); it("ReadmeSampleCreateClient_Browser", async () => { @@ -18,106 +18,7 @@ describe("snippets", () => { tenantId: "", clientId: "", }); - const client = new LoadTestClient(credential, subscriptionId); - }); - - it("ReadmeSampleCreateLoadTestResource", async () => { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); - // @ts-preserve-whitespace - const loadTestResourceCreatePayload = { - location: "westus2", - }; - // @ts-preserve-whitespace - const resource = await client.loadTests.beginCreateOrUpdateAndWait( - "sample-rg", - "sample-loadtesting-resource", - loadTestResourceCreatePayload, - ); - }); - - it("ReadmeSampleCreateLoadTestResourceWithManagedIdentityAndCMKEncryption", async () => { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); - // @ts-preserve-whitespace - const loadTestResourceCreatePayload = { - location: "westus2", - tags: { team: "testing" }, - identity: { - type: "SystemAssigned, UserAssigned", - userAssignedIdentities: { - "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity1": - {}, - }, - }, - encryption: { - identity: { - type: "UserAssigned", - resourceId: - "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity1", - }, - keyUrl: "https://sample-kv.vault.azure.net/keys/cmkkey/2d1ccd5c50234ea2a0858fe148b69cde", - }, - }; - // @ts-preserve-whitespace - const resource = await client.loadTests.beginCreateOrUpdateAndWait( - "sample-rg", - "sample-loadtesting-resource", - loadTestResourceCreatePayload, - ); - }); - - it("ReadmeSampleGetLoadTestResource", async () => { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); - // @ts-preserve-whitespace - const resourceName = "sample-loadtesting-resource"; - const resourceGroupName = "sample-rg"; - // @ts-preserve-whitespace - const resource = await client.loadTests.get(resourceGroupName, resourceName); - }); - - it("ReadmeSampleUpdateLoadTestResource", async () => { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); - // @ts-preserve-whitespace - const loadTestResourcePatchPayload = { - tags: { team: "testing-dev" }, - identity: { - type: "SystemAssigned, UserAssigned", - userAssignedIdentities: { - // removing a user-assigned managed identity by assigning the value in the payload as null - "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity1": - null, - "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/identity2": - {}, - }, - }, - encryption: { - // use system-assigned managed identity for CMK encryption - identity: { - type: "SystemAssigned", - resourceId: null, - }, - keyUrl: "https://sample-kv.vault.azure.net/keys/cmkkey/2d1ccd5c50234ea2a0858fe148b69cde", - }, - }; - - const resource = await client.loadTests.beginUpdateAndWait( - "sample-rg", - "sample-loadtesting-resource", - loadTestResourcePatchPayload, - ); - }); - - it("ReadmeSampleDeleteLoadTestResource", async () => { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; - const client = new LoadTestClient(new DefaultAzureCredential(), subscriptionId); - // @ts-preserve-whitespace - const resourceName = "sample-loadtesting-resource"; - const resourceGroupName = "sample-rg"; - // @ts-preserve-whitespace - const result = await client.loadTests.beginDeleteAndWait(resourceGroupName, resourceName); + const client = new LoadTestMgmtClient(credential, subscriptionId); }); it("SetLogLevel", async () => { diff --git a/sdk/loadtesting/arm-loadtesting/tsp-location.yaml b/sdk/loadtesting/arm-loadtesting/tsp-location.yaml new file mode 100644 index 000000000000..8f7fe7dc640e --- /dev/null +++ b/sdk/loadtesting/arm-loadtesting/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/loadtestservice/LoadTestService.Management +commit: 6dba751bdfbb9f83808e070bbd5cd7bc64f738ed +repo: ../azure-rest-api-specs +additionalDirectories: diff --git a/sdk/loadtesting/arm-loadtesting/vitest.browser.config.ts b/sdk/loadtesting/arm-loadtesting/vitest.browser.config.ts index 10e70dbfa8ee..182729ab5ce9 100644 --- a/sdk/loadtesting/arm-loadtesting/vitest.browser.config.ts +++ b/sdk/loadtesting/arm-loadtesting/vitest.browser.config.ts @@ -1,3 +1,4 @@ + // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -8,7 +9,7 @@ export default mergeConfig( viteConfig, defineConfig({ test: { - include: ["dist-test/browser/test/**/*.spec.js"], + include: ["dist-test/browser/test/**/*.spec.js",], testTimeout: 1200000, hookTimeout: 1200000, }, diff --git a/sdk/loadtesting/arm-loadtesting/vitest.config.ts b/sdk/loadtesting/arm-loadtesting/vitest.config.ts index 86a71911ccc2..40e031385dd8 100644 --- a/sdk/loadtesting/arm-loadtesting/vitest.config.ts +++ b/sdk/loadtesting/arm-loadtesting/vitest.config.ts @@ -1,3 +1,4 @@ + // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. diff --git a/sdk/loadtesting/arm-loadtesting/vitest.esm.config.ts b/sdk/loadtesting/arm-loadtesting/vitest.esm.config.ts index 5e9735e9b144..a70127279fc9 100644 --- a/sdk/loadtesting/arm-loadtesting/vitest.esm.config.ts +++ b/sdk/loadtesting/arm-loadtesting/vitest.esm.config.ts @@ -1,3 +1,4 @@ + // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -5,4 +6,7 @@ import { mergeConfig } from "vitest/config"; import vitestConfig from "./vitest.config.ts"; import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; -export default mergeConfig(vitestConfig, vitestEsmConfig); +export default mergeConfig( + vitestConfig, + vitestEsmConfig +); diff --git a/sdk/loadtesting/ci.mgmt.yml b/sdk/loadtesting/ci.mgmt.yml index a598bb7c34b0..df7886bab087 100644 --- a/sdk/loadtesting/ci.mgmt.yml +++ b/sdk/loadtesting/ci.mgmt.yml @@ -6,6 +6,8 @@ trigger: - main - release/* - hotfix/* + exclude: + - feature/v4 paths: include: - sdk/loadtesting/ci.mgmt.yml