diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index eab8c36cbaad..4abebe8a405e 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -12563,7 +12563,7 @@ packages: dev: false file:projects/arm-loadtestservice.tgz: - resolution: {integrity: sha512-brHj43tfs4UlJEt65ld1LzuBasRcHqGcO0GCWqrzNO4kbMOydvnEq1lAhuye+6AA92VWV6MfMyn1Pld85VxgLw==, tarball: file:projects/arm-loadtestservice.tgz} + resolution: {integrity: sha512-benRcY/O8zsYhY+DlkitcIRM9Ht5lIvGKug3+S88We77Z48TwN9MiUj68aY9J3dBI6Pqsbi2YY36/YBx2OKYBg==, tarball: file:projects/arm-loadtestservice.tgz} name: '@rush-temp/arm-loadtestservice' version: 0.0.0 dependencies: @@ -12574,6 +12574,8 @@ packages: '@rollup/plugin-json': 4.1.0_rollup@2.79.0 '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.0 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.0 + '@types/chai': 4.3.3 + chai: 4.3.6 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 @@ -12585,7 +12587,6 @@ packages: uglify-js: 3.17.0 transitivePeerDependencies: - '@types/node' - - encoding - supports-color dev: false diff --git a/sdk/loadtestservice/arm-loadtestservice/CHANGELOG.md b/sdk/loadtestservice/arm-loadtestservice/CHANGELOG.md index f0e454a703fc..511576ee1e3e 100644 --- a/sdk/loadtestservice/arm-loadtestservice/CHANGELOG.md +++ b/sdk/loadtestservice/arm-loadtestservice/CHANGELOG.md @@ -1,5 +1,37 @@ # Release History + +## 1.0.0-beta.3 (2022-09-13) + +**Features** + + - Added operation LoadTests.beginCreateOrUpdate + - Added operation LoadTests.beginCreateOrUpdateAndWait + - Added operation LoadTests.beginUpdate + - Added operation LoadTests.beginUpdateAndWait + - Added Interface EncryptionProperties + - Added Interface EncryptionPropertiesIdentity + - Added Interface LoadTestResource + - Added Interface ManagedServiceIdentity + - Added Interface TrackedResource + - Added Interface UserAssignedIdentity + - Added Type Alias ManagedServiceIdentityType + - Added Type Alias Type + - Interface LoadTestResourcePatchRequestBody has a new optional parameter description + - Interface LoadTestResourcePatchRequestBody has a new optional parameter encryption + - Interface LoadTestsCreateOrUpdateOptionalParams has a new optional parameter resumeFrom + - Interface LoadTestsCreateOrUpdateOptionalParams has a new optional parameter updateIntervalInMs + - Interface LoadTestsUpdateOptionalParams has a new optional parameter resumeFrom + - Interface LoadTestsUpdateOptionalParams has a new optional parameter updateIntervalInMs + - Added Enum KnownManagedServiceIdentityType + - Added Enum KnownType + +**Breaking Changes** + - Removed operation LoadTests.createOrUpdate + - Removed operation LoadTests.update + - Interface LoadTestResourcePatchRequestBody no longer has parameter properties + - Removed Enum KnownSystemAssignedServiceIdentityType + ## 1.0.0-beta.2 (2022-04-24) **Features** diff --git a/sdk/loadtestservice/arm-loadtestservice/_meta.json b/sdk/loadtestservice/arm-loadtestservice/_meta.json index 9d9ae4bafe05..b30527cf874d 100644 --- a/sdk/loadtestservice/arm-loadtestservice/_meta.json +++ b/sdk/loadtestservice/arm-loadtestservice/_meta.json @@ -1,8 +1,8 @@ { - "commit": "d90729bbada2b4f784f2737ab4b4e39693a7aab8", - "readme": "specification\\loadtestservice\\resource-manager\\readme.md", - "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\loadtestservice\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", + "commit": "3a62e93594187eda7f8ccfe12e1134894dc38a16", + "readme": "specification/loadtestservice/resource-manager/readme.md", + "autorest_command": "autorest --version=3.8.4 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/loadtestservice/resource-manager/readme.md --use=@autorest/typescript@6.0.0-rc.1", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", - "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.4.2", + "use": "@autorest/typescript@6.0.0-rc.1" } \ No newline at end of file diff --git a/sdk/loadtestservice/arm-loadtestservice/package.json b/sdk/loadtestservice/arm-loadtestservice/package.json index 1ccf7afbfb33..fddbec321678 100644 --- a/sdk/loadtestservice/arm-loadtestservice/package.json +++ b/sdk/loadtestservice/arm-loadtestservice/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for LoadTestClient.", - "version": "1.0.0-beta.2", + "version": "1.0.0-beta.3", "engines": { "node": ">=12.0.0" }, @@ -40,9 +40,13 @@ "uglify-js": "^3.4.9", "rimraf": "^3.0.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@azure/dev-tool": "^1.0.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtestservice/arm-loadtestservice", "repository": { @@ -93,9 +97,8 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", - "integration-test:browser": "echo skipped", - "docs": "echo skipped" + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, "//metadata": { @@ -106,13 +109,5 @@ } ] }, - "autoPublish": true, - "//sampleConfiguration": { - "productName": "", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-loadtestservice?view=azure-node-preview" - } -} + "autoPublish": true +} \ No newline at end of file diff --git a/sdk/loadtestservice/arm-loadtestservice/review/arm-loadtestservice.api.md b/sdk/loadtestservice/arm-loadtestservice/review/arm-loadtestservice.api.md index ce02d82d013a..b0fdee7e8611 100644 --- a/sdk/loadtestservice/arm-loadtestservice/review/arm-loadtestservice.api.md +++ b/sdk/loadtestservice/arm-loadtestservice/review/arm-loadtestservice.api.md @@ -16,6 +16,18 @@ export type ActionType = string; // @public export type CreatedByType = string; +// @public +export interface EncryptionProperties { + identity?: EncryptionPropertiesIdentity; + keyUrl?: string; +} + +// @public +export interface EncryptionPropertiesIdentity { + resourceId?: string; + type?: Type; +} + // @public export interface ErrorAdditionalInfo { readonly info?: Record; @@ -38,50 +50,44 @@ export interface ErrorResponse { // @public export enum KnownActionType { - // (undocumented) Internal = "Internal" } // @public export enum KnownCreatedByType { - // (undocumented) Application = "Application", - // (undocumented) Key = "Key", - // (undocumented) ManagedIdentity = "ManagedIdentity", - // (undocumented) User = "User" } +// @public +export enum KnownManagedServiceIdentityType { + None = "None", + SystemAssigned = "SystemAssigned", + SystemAssignedUserAssigned = "SystemAssigned,UserAssigned", + UserAssigned = "UserAssigned" +} + // @public export enum KnownOrigin { - // (undocumented) System = "system", - // (undocumented) User = "user", - // (undocumented) UserSystem = "user,system" } // @public export enum KnownResourceState { - // (undocumented) Canceled = "Canceled", - // (undocumented) Deleted = "Deleted", - // (undocumented) Failed = "Failed", - // (undocumented) Succeeded = "Succeeded" } // @public -export enum KnownSystemAssignedServiceIdentityType { - // (undocumented) - None = "None", - // (undocumented) - SystemAssigned = "SystemAssigned" +export enum KnownType { + SystemAssigned = "SystemAssigned", + UserAssigned = "UserAssigned" } // @public (undocumented) @@ -107,12 +113,13 @@ export interface LoadTestClientOptionalParams extends coreClient.ServiceClientOp } // @public -export type LoadTestResource = TrackedResource & { - identity?: SystemAssignedServiceIdentity; +export interface LoadTestResource extends TrackedResource { + readonly dataPlaneURI?: string; description?: string; + encryption?: EncryptionProperties; + identity?: ManagedServiceIdentity; readonly provisioningState?: ResourceState; - readonly dataPlaneURI?: string; -}; +} // @public export interface LoadTestResourcePageList { @@ -122,29 +129,29 @@ export interface LoadTestResourcePageList { // @public export interface LoadTestResourcePatchRequestBody { - identity?: SystemAssignedServiceIdentity; - properties?: LoadTestResourcePatchRequestBodyProperties; - tags?: Record; -} - -// @public -export interface LoadTestResourcePatchRequestBodyProperties { description?: string; + encryption?: EncryptionProperties; + identity?: ManagedServiceIdentity; + tags?: Record; } // @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; - createOrUpdate(resourceGroupName: string, loadTestName: string, loadTestResource: LoadTestResource, options?: LoadTestsCreateOrUpdateOptionalParams): 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; - update(resourceGroupName: string, loadTestName: string, loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody, options?: LoadTestsUpdateOptionalParams): Promise; } // @public export interface LoadTestsCreateOrUpdateOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; } // @public @@ -193,11 +200,26 @@ export type LoadTestsListBySubscriptionResponse = LoadTestResourcePageList; // @public export interface LoadTestsUpdateOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; } // @public export type LoadTestsUpdateResponse = LoadTestResource; +// @public +export interface ManagedServiceIdentity { + readonly principalId?: string; + readonly tenantId?: string; + type: ManagedServiceIdentityType; + userAssignedIdentities?: { + [propertyName: string]: UserAssignedIdentity; + }; +} + +// @public +export type ManagedServiceIdentityType = string; + // @public export interface Operation { readonly actionType?: ActionType; @@ -254,16 +276,6 @@ export interface Resource { // @public export type ResourceState = string; -// @public -export interface SystemAssignedServiceIdentity { - readonly principalId?: string; - readonly tenantId?: string; - type: SystemAssignedServiceIdentityType; -} - -// @public -export type SystemAssignedServiceIdentityType = string; - // @public export interface SystemData { createdAt?: Date; @@ -275,12 +287,21 @@ export interface SystemData { } // @public -export type TrackedResource = Resource & { +export interface TrackedResource extends Resource { + location: string; tags?: { [propertyName: string]: string; }; - location: string; -}; +} + +// @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/loadtestservice/arm-loadtestservice/src/loadTestClient.ts b/sdk/loadtestservice/arm-loadtestservice/src/loadTestClient.ts index e7343b59bc8b..13bfc2adb99b 100644 --- a/sdk/loadtestservice/arm-loadtestservice/src/loadTestClient.ts +++ b/sdk/loadtestservice/arm-loadtestservice/src/loadTestClient.ts @@ -8,6 +8,11 @@ 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, LoadTestsImpl } from "./operations"; import { Operations, LoadTests } from "./operationsInterfaces"; @@ -45,7 +50,7 @@ export class LoadTestClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-loadtestservice/1.0.0-beta.2`; + const packageDetails = `azsdk-js-arm-loadtestservice/1.0.0-beta.3`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -92,9 +97,38 @@ export class LoadTestClient extends coreClient.ServiceClient { // Assigning values to Constant parameters this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2021-12-01-preview"; + this.apiVersion = options.apiVersion || "2022-04-15-preview"; this.operations = new OperationsImpl(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; diff --git a/sdk/loadtestservice/arm-loadtestservice/src/models/index.ts b/sdk/loadtestservice/arm-loadtestservice/src/models/index.ts index bfcfc48d7fa0..e5ca25ff744f 100644 --- a/sdk/loadtestservice/arm-loadtestservice/src/models/index.ts +++ b/sdk/loadtestservice/arm-loadtestservice/src/models/index.ts @@ -129,8 +129,24 @@ export interface LoadTestResourcePageList { nextLink?: string; } -/** Managed service identity (either system assigned, or none) */ -export interface SystemAssignedServiceIdentity { +/** 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. @@ -141,8 +157,24 @@ export interface SystemAssignedServiceIdentity { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly tenantId?: string; - /** Type of managed service identity (either system assigned, or none). */ - type: SystemAssignedServiceIdentityType; + /** 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 }; +} + +/** 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; } /** Common fields that are returned in the response for all Azure Resource Manager resources */ @@ -190,29 +222,25 @@ export interface LoadTestResourcePatchRequestBody { /** Resource tags. */ tags?: Record; /** The type of identity used for the resource. */ - identity?: SystemAssignedServiceIdentity; - /** Load Test resource properties */ - properties?: LoadTestResourcePatchRequestBodyProperties; -} - -/** Load Test resource properties */ -export interface LoadTestResourcePatchRequestBodyProperties { + identity?: ManagedServiceIdentity; /** Description of the resource. */ description?: string; + /** CMK Encryption property. */ + encryption?: EncryptionProperties; } /** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ -export type TrackedResource = Resource & { +export interface TrackedResource extends Resource { /** Resource tags. */ tags?: { [propertyName: string]: string }; /** The geo-location where the resource lives */ location: string; -}; +} /** LoadTest details */ -export type LoadTestResource = TrackedResource & { +export interface LoadTestResource extends TrackedResource { /** The type of identity used for the resource. */ - identity?: SystemAssignedServiceIdentity; + identity?: ManagedServiceIdentity; /** Description of the resource. */ description?: string; /** @@ -225,12 +253,17 @@ export type LoadTestResource = TrackedResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly dataPlaneURI?: string; -}; + /** CMK Encryption property. */ + encryption?: EncryptionProperties; +} /** Known values of {@link Origin} that the service accepts. */ export enum KnownOrigin { + /** User */ User = "user", + /** System */ System = "system", + /** UserSystem */ UserSystem = "user,system" } @@ -247,6 +280,7 @@ export type Origin = string; /** Known values of {@link ActionType} that the service accepts. */ export enum KnownActionType { + /** Internal */ Internal = "Internal" } @@ -261,9 +295,13 @@ 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" } @@ -279,27 +317,57 @@ export enum KnownResourceState { */ export type ResourceState = string; -/** Known values of {@link SystemAssignedServiceIdentityType} that the service accepts. */ -export enum KnownSystemAssignedServiceIdentityType { +/** 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 */ + SystemAssigned = "SystemAssigned", + /** UserAssigned */ + UserAssigned = "UserAssigned", + /** SystemAssignedUserAssigned */ + SystemAssignedUserAssigned = "SystemAssigned,UserAssigned" } /** - * Defines values for SystemAssignedServiceIdentityType. \ - * {@link KnownSystemAssignedServiceIdentityType} can be used interchangeably with SystemAssignedServiceIdentityType, + * 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** + * **SystemAssigned** \ + * **UserAssigned** \ + * **SystemAssigned,UserAssigned** */ -export type SystemAssignedServiceIdentityType = string; +export type ManagedServiceIdentityType = 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" } @@ -352,14 +420,24 @@ export type LoadTestsGetResponse = LoadTestResource; /** Optional parameters. */ export interface LoadTestsCreateOrUpdateOptionalParams - extends coreClient.OperationOptions {} + 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 {} + 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; diff --git a/sdk/loadtestservice/arm-loadtestservice/src/models/mappers.ts b/sdk/loadtestservice/arm-loadtestservice/src/models/mappers.ts index 5634c0043bdd..1ab79e42ff8e 100644 --- a/sdk/loadtestservice/arm-loadtestservice/src/models/mappers.ts +++ b/sdk/loadtestservice/arm-loadtestservice/src/models/mappers.ts @@ -241,10 +241,53 @@ export const LoadTestResourcePageList: coreClient.CompositeMapper = { } }; -export const SystemAssignedServiceIdentity: coreClient.CompositeMapper = { +export const EncryptionProperties: coreClient.CompositeMapper = { type: { name: "Composite", - className: "SystemAssignedServiceIdentity", + 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", + type: { + name: "String" + } + } + } + } +}; + +export const ManagedServiceIdentity: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ManagedServiceIdentity", modelProperties: { principalId: { serializedName: "principalId", @@ -266,6 +309,38 @@ export const SystemAssignedServiceIdentity: coreClient.CompositeMapper = { 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" + } } } } @@ -369,33 +444,24 @@ export const LoadTestResourcePatchRequestBody: coreClient.CompositeMapper = { serializedName: "identity", type: { name: "Composite", - className: "SystemAssignedServiceIdentity" + className: "ManagedServiceIdentity" } }, - properties: { - serializedName: "properties", - type: { - name: "Composite", - className: "LoadTestResourcePatchRequestBodyProperties" - } - } - } - } -}; - -export const LoadTestResourcePatchRequestBodyProperties: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "LoadTestResourcePatchRequestBodyProperties", - modelProperties: { description: { constraints: { MaxLength: 512 }, - serializedName: "description", + serializedName: "properties.description", type: { name: "String" } + }, + encryption: { + serializedName: "properties.encryption", + type: { + name: "Composite", + className: "EncryptionProperties" + } } } } @@ -435,7 +501,7 @@ export const LoadTestResource: coreClient.CompositeMapper = { serializedName: "identity", type: { name: "Composite", - className: "SystemAssignedServiceIdentity" + className: "ManagedServiceIdentity" } }, description: { @@ -463,6 +529,13 @@ export const LoadTestResource: coreClient.CompositeMapper = { type: { name: "String" } + }, + encryption: { + serializedName: "properties.encryption", + type: { + name: "Composite", + className: "EncryptionProperties" + } } } } diff --git a/sdk/loadtestservice/arm-loadtestservice/src/models/parameters.ts b/sdk/loadtestservice/arm-loadtestservice/src/models/parameters.ts index 606e293f1fd1..52dce30769de 100644 --- a/sdk/loadtestservice/arm-loadtestservice/src/models/parameters.ts +++ b/sdk/loadtestservice/arm-loadtestservice/src/models/parameters.ts @@ -43,7 +43,7 @@ export const $host: OperationURLParameter = { export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2021-12-01-preview", + defaultValue: "2022-04-15-preview", isConstant: true, serializedName: "api-version", type: { diff --git a/sdk/loadtestservice/arm-loadtestservice/src/operations/loadTests.ts b/sdk/loadtestservice/arm-loadtestservice/src/operations/loadTests.ts index f6dc792bd59f..c59a97b45c2d 100644 --- a/sdk/loadtestservice/arm-loadtestservice/src/operations/loadTests.ts +++ b/sdk/loadtestservice/arm-loadtestservice/src/operations/loadTests.ts @@ -173,7 +173,7 @@ export class LoadTestsImpl implements LoadTests { /** * Get a LoadTest resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param loadTestName Load Test name. + * @param loadTestName Load Test resource name. * @param options The options parameters. */ get( @@ -190,36 +190,155 @@ export class LoadTestsImpl implements LoadTests { /** * Create or update LoadTest resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param loadTestName Load Test name. + * @param loadTestName Load Test resource name. * @param loadTestResource LoadTest resource data * @param options The options parameters. */ - createOrUpdate( + async beginCreateOrUpdate( resourceGroupName: string, loadTestName: string, loadTestResource: LoadTestResource, options?: LoadTestsCreateOrUpdateOptionalParams - ): Promise { - return this.client.sendOperationRequest( + ): 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 resource 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 loadTestName Load Test resource name. * @param loadTestResourcePatchRequestBody LoadTest resource update data * @param options The options parameters. */ - update( + async beginUpdate( resourceGroupName: string, loadTestName: string, loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody, options?: LoadTestsUpdateOptionalParams - ): Promise { - return this.client.sendOperationRequest( + ): 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, @@ -228,12 +347,41 @@ export class LoadTestsImpl implements LoadTests { }, 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 resource 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 loadTestName Load Test resource name. * @param options The options parameters. */ async beginDelete( @@ -287,7 +435,8 @@ export class LoadTestsImpl implements LoadTests { ); const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, - intervalInMs: options?.updateIntervalInMs + intervalInMs: options?.updateIntervalInMs, + lroResourceLocationConfig: "location" }); await poller.poll(); return poller; @@ -296,7 +445,7 @@ export class LoadTestsImpl implements LoadTests { /** * Delete a LoadTest resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param loadTestName Load Test name. + * @param loadTestName Load Test resource name. * @param options The options parameters. */ async beginDeleteAndWait( @@ -415,6 +564,15 @@ const createOrUpdateOperationSpec: coreClient.OperationSpec = { 200: { bodyMapper: Mappers.LoadTestResource }, + 201: { + bodyMapper: Mappers.LoadTestResource + }, + 202: { + bodyMapper: Mappers.LoadTestResource + }, + 204: { + bodyMapper: Mappers.LoadTestResource + }, default: { bodyMapper: Mappers.ErrorResponse } @@ -439,6 +597,15 @@ const updateOperationSpec: coreClient.OperationSpec = { 200: { bodyMapper: Mappers.LoadTestResource }, + 201: { + bodyMapper: Mappers.LoadTestResource + }, + 202: { + bodyMapper: Mappers.LoadTestResource + }, + 204: { + bodyMapper: Mappers.LoadTestResource + }, default: { bodyMapper: Mappers.ErrorResponse } diff --git a/sdk/loadtestservice/arm-loadtestservice/src/operationsInterfaces/loadTests.ts b/sdk/loadtestservice/arm-loadtestservice/src/operationsInterfaces/loadTests.ts index 3d222e890f40..7339ec1358af 100644 --- a/sdk/loadtestservice/arm-loadtestservice/src/operationsInterfaces/loadTests.ts +++ b/sdk/loadtestservice/arm-loadtestservice/src/operationsInterfaces/loadTests.ts @@ -44,7 +44,7 @@ export interface LoadTests { /** * Get a LoadTest resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param loadTestName Load Test name. + * @param loadTestName Load Test resource name. * @param options The options parameters. */ get( @@ -55,11 +55,29 @@ export interface LoadTests { /** * Create or update LoadTest resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param loadTestName Load Test name. + * @param loadTestName Load Test resource name. * @param loadTestResource LoadTest resource data * @param options The options parameters. */ - createOrUpdate( + 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 resource name. + * @param loadTestResource LoadTest resource data + * @param options The options parameters. + */ + beginCreateOrUpdateAndWait( resourceGroupName: string, loadTestName: string, loadTestResource: LoadTestResource, @@ -68,11 +86,29 @@ export interface LoadTests { /** * Update a loadtest resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param loadTestName Load Test name. + * @param loadTestName Load Test resource 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 resource name. * @param loadTestResourcePatchRequestBody LoadTest resource update data * @param options The options parameters. */ - update( + beginUpdateAndWait( resourceGroupName: string, loadTestName: string, loadTestResourcePatchRequestBody: LoadTestResourcePatchRequestBody, @@ -81,7 +117,7 @@ export interface LoadTests { /** * Delete a LoadTest resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param loadTestName Load Test name. + * @param loadTestName Load Test resource name. * @param options The options parameters. */ beginDelete( @@ -92,7 +128,7 @@ export interface LoadTests { /** * Delete a LoadTest resource. * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param loadTestName Load Test name. + * @param loadTestName Load Test resource name. * @param options The options parameters. */ beginDeleteAndWait( diff --git a/sdk/loadtestservice/arm-loadtestservice/test/sampleTest.ts b/sdk/loadtestservice/arm-loadtestservice/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/loadtestservice/arm-loadtestservice/test/sampleTest.ts +++ b/sdk/loadtestservice/arm-loadtestservice/test/sampleTest.ts @@ -7,35 +7,30 @@ */ import { - env, - record, - RecorderEnvironmentSetup, - Recorder + Recorder, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import * as assert from "assert"; +import { assert } from "chai"; +import { Context } from "mocha"; -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables }; describe("My test", () => { let recorder: Recorder; - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); }); afterEach(async function() { diff --git a/sdk/loadtestservice/arm-loadtestservice/tsconfig.json b/sdk/loadtestservice/arm-loadtestservice/tsconfig.json index 3f26a9e3ce75..3e6ae96443f3 100644 --- a/sdk/loadtestservice/arm-loadtestservice/tsconfig.json +++ b/sdk/loadtestservice/arm-loadtestservice/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-loadtestservice": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"