From 56b36fbd95a477b7dcd52c7db4900a1639b65390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodr=C3=ADguez?= Date: Fri, 21 May 2021 15:23:48 -0400 Subject: [PATCH] [Key Vault Admin] Selective Restore to Selective Key Restore (#15354) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR changes all the references to `/selectiverestore/ig` to `selectiveKeyRestore` (I did it manually, don't worry). I also copied the selective restore return type into a new type: `KeyVaultSelectiveKeyRestoreResult`. Feedback appreciated 👍 Fixes #15357 --- sdk/keyvault/keyvault-admin/CHANGELOG.md | 4 +++ ...ing_can_abort_beginselectivekeyrestore.js} | 0 ...ctivekeyrestore_completes_successfully.js} | 0 .../review/keyvault-admin.api.md | 12 ++++++--- ...estore.ts => backupSelectiveKeyRestore.ts} | 4 +-- .../samples/v4/javascript/README.md | 8 +++--- ...estore.js => backupSelectiveKeyRestore.js} | 4 +-- .../samples/v4/typescript/README.md | 8 +++--- ...estore.ts => backupSelectiveKeyRestore.ts} | 4 +-- .../keyvault-admin/src/backupClient.ts | 24 ++++++++++------- .../keyvault-admin/src/backupClientModels.ts | 19 ++++++++++++-- .../operation.ts | 20 +++++++------- .../poller.ts | 26 ++++++++++--------- .../test/public/backupClient.abort.spec.ts | 4 +-- .../test/public/backupClient.spec.ts | 16 ++++++------ 15 files changed, 92 insertions(+), 61 deletions(-) rename sdk/keyvault/keyvault-admin/recordings/node/aborting_keyvaultbackupclients_requests/{recording_can_abort_beginselectiverestore.js => recording_can_abort_beginselectivekeyrestore.js} (100%) rename sdk/keyvault/keyvault-admin/recordings/node/keyvaultbackupclient_beginrestore/{recording_selectiverestore_completes_successfully.js => recording_selectivekeyrestore_completes_successfully.js} (100%) rename sdk/keyvault/keyvault-admin/samples-dev/{backupSelectiveRestore.ts => backupSelectiveKeyRestore.ts} (94%) rename sdk/keyvault/keyvault-admin/samples/v4/javascript/{backupSelectiveRestore.js => backupSelectiveKeyRestore.js} (94%) rename sdk/keyvault/keyvault-admin/samples/v4/typescript/src/{backupSelectiveRestore.ts => backupSelectiveKeyRestore.ts} (94%) rename sdk/keyvault/keyvault-admin/src/lro/{selectiveRestore => selectiveKeyRestore}/operation.ts (85%) rename sdk/keyvault/keyvault-admin/src/lro/{selectiveRestore => selectiveKeyRestore}/poller.ts (56%) diff --git a/sdk/keyvault/keyvault-admin/CHANGELOG.md b/sdk/keyvault/keyvault-admin/CHANGELOG.md index f102cae86b49..dd666fcb03d2 100644 --- a/sdk/keyvault/keyvault-admin/CHANGELOG.md +++ b/sdk/keyvault/keyvault-admin/CHANGELOG.md @@ -14,6 +14,10 @@ - Removed `folderName` from `beginSelectiveRestore`. Now the folder name will be inferred from the `folderUri`. - Reordered the parameters of `beginSelectiveRestore` to `keyName`, `folderUrl`, `sasToken`, `[options]`. - Renamed `KeyVaultBackupResult`'s `backupFolderUri` to `folderUri`. +- Renamed `beginSelectiveRestore` to `beginSelectiveKeyRestore`. +- Renamed `KeyVaultBeginSelectiveRestoreOptions` to `KeyVaultBeginSelectiveKeyRestoreOptions`. +- Renamed `KeyVaultSelectiveRestoreOperationState` to `KeyVaultSelectiveKeyRestoreOperationState`. +- Renamed `KeyVaultSelectiveRestoreResult` to `KeyVaultSelectiveKeyRestoreResult`. ## 4.0.0-beta.3 (2021-04-06) diff --git a/sdk/keyvault/keyvault-admin/recordings/node/aborting_keyvaultbackupclients_requests/recording_can_abort_beginselectiverestore.js b/sdk/keyvault/keyvault-admin/recordings/node/aborting_keyvaultbackupclients_requests/recording_can_abort_beginselectivekeyrestore.js similarity index 100% rename from sdk/keyvault/keyvault-admin/recordings/node/aborting_keyvaultbackupclients_requests/recording_can_abort_beginselectiverestore.js rename to sdk/keyvault/keyvault-admin/recordings/node/aborting_keyvaultbackupclients_requests/recording_can_abort_beginselectivekeyrestore.js diff --git a/sdk/keyvault/keyvault-admin/recordings/node/keyvaultbackupclient_beginrestore/recording_selectiverestore_completes_successfully.js b/sdk/keyvault/keyvault-admin/recordings/node/keyvaultbackupclient_beginrestore/recording_selectivekeyrestore_completes_successfully.js similarity index 100% rename from sdk/keyvault/keyvault-admin/recordings/node/keyvaultbackupclient_beginrestore/recording_selectiverestore_completes_successfully.js rename to sdk/keyvault/keyvault-admin/recordings/node/keyvaultbackupclient_beginrestore/recording_selectivekeyrestore_completes_successfully.js diff --git a/sdk/keyvault/keyvault-admin/review/keyvault-admin.api.md b/sdk/keyvault/keyvault-admin/review/keyvault-admin.api.md index 9a28dd45ccbb..fba9a7261cb9 100644 --- a/sdk/keyvault/keyvault-admin/review/keyvault-admin.api.md +++ b/sdk/keyvault/keyvault-admin/review/keyvault-admin.api.md @@ -63,7 +63,7 @@ export class KeyVaultBackupClient { constructor(vaultUrl: string, credential: TokenCredential, options?: KeyVaultBackupClientOptions); beginBackup(blobStorageUri: string, sasToken: string, options?: KeyVaultBeginBackupOptions): Promise>; beginRestore(folderUri: string, sasToken: string, options?: KeyVaultBeginRestoreOptions): Promise>; - beginSelectiveRestore(keyName: string, folderUri: string, sasToken: string, options?: KeyVaultBeginBackupOptions): Promise>; + beginSelectiveKeyRestore(keyName: string, folderUri: string, sasToken: string, options?: KeyVaultBeginSelectiveKeyRestoreOptions): Promise>; readonly vaultUrl: string; } @@ -97,7 +97,7 @@ export interface KeyVaultBeginRestoreOptions extends KeyVaultBackupPollerOptions } // @public -export interface KeyVaultBeginSelectiveRestoreOptions extends KeyVaultBackupPollerOptions { +export interface KeyVaultBeginSelectiveKeyRestoreOptions extends KeyVaultBackupPollerOptions { } // @public @@ -152,7 +152,13 @@ export interface KeyVaultRoleDefinition { export type KeyVaultRoleScope = "/" | "/keys" | string; // @public -export interface KeyVaultSelectiveRestoreOperationState extends KeyVaultAdminPollOperationState { +export interface KeyVaultSelectiveKeyRestoreOperationState extends KeyVaultAdminPollOperationState { +} + +// @public +export interface KeyVaultSelectiveKeyRestoreResult { + endTime?: Date; + startTime: Date; } // @public diff --git a/sdk/keyvault/keyvault-admin/samples-dev/backupSelectiveRestore.ts b/sdk/keyvault/keyvault-admin/samples-dev/backupSelectiveKeyRestore.ts similarity index 94% rename from sdk/keyvault/keyvault-admin/samples-dev/backupSelectiveRestore.ts rename to sdk/keyvault/keyvault-admin/samples-dev/backupSelectiveKeyRestore.ts index b4004b042e61..367f82f7975f 100644 --- a/sdk/keyvault/keyvault-admin/samples-dev/backupSelectiveRestore.ts +++ b/sdk/keyvault/keyvault-admin/samples-dev/backupSelectiveKeyRestore.ts @@ -40,12 +40,12 @@ export async function main(): Promise { const backupPoller = await client.beginBackup(blobStorageUri, sasToken); await backupPoller.pollUntilDone(); - const selectiveRestorePoller = await client.beginSelectiveRestore( + const selectiveKeyRestorePoller = await client.beginSelectiveKeyRestore( key.name, blobStorageUri, sasToken ); - await selectiveRestorePoller.pollUntilDone(); + await selectiveKeyRestorePoller.pollUntilDone(); // Deleting and purging the key, just in case we want to create the same key again. const deleteKeyPoller = await keyClient.beginDeleteKey(keyName); diff --git a/sdk/keyvault/keyvault-admin/samples/v4/javascript/README.md b/sdk/keyvault/keyvault-admin/samples/v4/javascript/README.md index 4562b02649b1..e82c896d4e59 100644 --- a/sdk/keyvault/keyvault-admin/samples/v4/javascript/README.md +++ b/sdk/keyvault/keyvault-admin/samples/v4/javascript/README.md @@ -14,9 +14,9 @@ These sample programs show how to use the JavaScript client libraries for Azure | **File Name** | **Description** | | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -| [accessControlHelloWorld.js][accesscontrolhelloworld] | Uses an AccessControlClient to list, create, and assign roles to users. | -| [backupRestoreHelloWorld.js][backuprestorehelloworld] | Uses a BackupClient to backup and fully restore an Azure Key Vault using Azure Storage Blob. | -| [backupSelectiveRestore.js][backupselectiverestore] | Uses a BackupClient to backup and restore a specific key in Azure Key Vault using Azure Storage Blob. | +| [accessControlHelloWorld.js][accesscontrolhelloworld] | Uses an KeyVaultAccessControlClient to list, create, and assign roles to users. | +| [backupRestoreHelloWorld.js][backuprestorehelloworld] | Uses a KeyVaultBackupClient to backup and fully restore an Azure Key Vault using Azure Storage Blob. | +| [backupSelectiveKeyRestore.js][backupselectiveKeyrestore] | Uses a KeyVaultBackupClient to backup and restore a specific key in Azure Key Vault using Azure Storage Blob. | ## Prerequisites @@ -66,7 +66,7 @@ Take a look at our [API Documentation][apiref] for more information about the AP [accesscontrolhelloworld]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/keyvault/keyvault-admin/samples/v4/javascript/accessControlHelloWorld.js [backuprestorehelloworld]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/keyvault/keyvault-admin/samples/v4/javascript/backupRestoreHelloWorld.js -[backupselectiverestore]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/keyvault/keyvault-admin/samples/v4/javascript/backupSelectiveRestore.js +[backupselectiveKeyrestore]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/keyvault/keyvault-admin/samples/v4/javascript/backupSelectiveKeyRestore.js [apiref]: https://docs.microsoft.com/javascript/api/@azure/keyvault-admin [freesub]: https://azure.microsoft.com/free/ [createinstance_azurekeyvault]: https://docs.microsoft.com/azure/key-vault/quick-create-portal diff --git a/sdk/keyvault/keyvault-admin/samples/v4/javascript/backupSelectiveRestore.js b/sdk/keyvault/keyvault-admin/samples/v4/javascript/backupSelectiveKeyRestore.js similarity index 94% rename from sdk/keyvault/keyvault-admin/samples/v4/javascript/backupSelectiveRestore.js rename to sdk/keyvault/keyvault-admin/samples/v4/javascript/backupSelectiveKeyRestore.js index 8807f9dde639..4e94e8218f3a 100644 --- a/sdk/keyvault/keyvault-admin/samples/v4/javascript/backupSelectiveRestore.js +++ b/sdk/keyvault/keyvault-admin/samples/v4/javascript/backupSelectiveKeyRestore.js @@ -40,12 +40,12 @@ async function main() { const backupPoller = await client.beginBackup(blobStorageUri, sasToken); await backupPoller.pollUntilDone(); - const selectiveRestorePoller = await client.beginSelectiveRestore( + const selectiveKeyRestorePoller = await client.beginSelectiveKeyRestore( key.name, blobStorageUri, sasToken ); - await selectiveRestorePoller.pollUntilDone(); + await selectiveKeyRestorePoller.pollUntilDone(); // Deleting and purging the key, just in case we want to create the same key again. const deleteKeyPoller = await keyClient.beginDeleteKey(keyName); diff --git a/sdk/keyvault/keyvault-admin/samples/v4/typescript/README.md b/sdk/keyvault/keyvault-admin/samples/v4/typescript/README.md index f9c9f0d9974d..1b0f91b66071 100644 --- a/sdk/keyvault/keyvault-admin/samples/v4/typescript/README.md +++ b/sdk/keyvault/keyvault-admin/samples/v4/typescript/README.md @@ -14,9 +14,9 @@ These sample programs show how to use the TypeScript client libraries for Azure | **File Name** | **Description** | | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -| [accessControlHelloWorld.ts][accesscontrolhelloworld] | Uses an AccessControlClient to list, create, and assign roles to users. | -| [backupRestoreHelloWorld.ts][backuprestorehelloworld] | Uses a BackupClient to backup and fully restore an Azure Key Vault using Azure Storage Blob. | -| [backupSelectiveRestore.ts][backupselectiverestore] | Uses a BackupClient to backup and restore a specific key in Azure Key Vault using Azure Storage Blob. | +| [accessControlHelloWorld.ts][accesscontrolhelloworld] | Uses an KeyVaultAccessControlClient to list, create, and assign roles to users. | +| [backupRestoreHelloWorld.ts][backuprestorehelloworld] | Uses a KeyVaultBackupClient to backup and fully restore an Azure Key Vault using Azure Storage Blob. | +| [backupSelectiveKeyRestore.ts][backupselectiveKeyrestore] | Uses a KeyVaultBackupClient to backup and restore a specific key in Azure Key Vault using Azure Storage Blob. | ## Prerequisites @@ -78,7 +78,7 @@ Take a look at our [API Documentation][apiref] for more information about the AP [accesscontrolhelloworld]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/keyvault/keyvault-admin/samples/v4/typescript/src/accessControlHelloWorld.ts [backuprestorehelloworld]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/keyvault/keyvault-admin/samples/v4/typescript/src/backupRestoreHelloWorld.ts -[backupselectiverestore]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/keyvault/keyvault-admin/samples/v4/typescript/src/backupSelectiveRestore.ts +[backupselectiveKeyrestore]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/keyvault/keyvault-admin/samples/v4/typescript/src/backupSelectiveKeyRestore.ts [apiref]: https://docs.microsoft.com/javascript/api/@azure/keyvault-admin [freesub]: https://azure.microsoft.com/free/ [createinstance_azurekeyvault]: https://docs.microsoft.com/azure/key-vault/quick-create-portal diff --git a/sdk/keyvault/keyvault-admin/samples/v4/typescript/src/backupSelectiveRestore.ts b/sdk/keyvault/keyvault-admin/samples/v4/typescript/src/backupSelectiveKeyRestore.ts similarity index 94% rename from sdk/keyvault/keyvault-admin/samples/v4/typescript/src/backupSelectiveRestore.ts rename to sdk/keyvault/keyvault-admin/samples/v4/typescript/src/backupSelectiveKeyRestore.ts index b4004b042e61..367f82f7975f 100644 --- a/sdk/keyvault/keyvault-admin/samples/v4/typescript/src/backupSelectiveRestore.ts +++ b/sdk/keyvault/keyvault-admin/samples/v4/typescript/src/backupSelectiveKeyRestore.ts @@ -40,12 +40,12 @@ export async function main(): Promise { const backupPoller = await client.beginBackup(blobStorageUri, sasToken); await backupPoller.pollUntilDone(); - const selectiveRestorePoller = await client.beginSelectiveRestore( + const selectiveKeyRestorePoller = await client.beginSelectiveKeyRestore( key.name, blobStorageUri, sasToken ); - await selectiveRestorePoller.pollUntilDone(); + await selectiveKeyRestorePoller.pollUntilDone(); // Deleting and purging the key, just in case we want to create the same key again. const deleteKeyPoller = await keyClient.beginDeleteKey(keyName); diff --git a/sdk/keyvault/keyvault-admin/src/backupClient.ts b/sdk/keyvault/keyvault-admin/src/backupClient.ts index 60bbd6504e11..0660b642dbcb 100644 --- a/sdk/keyvault/keyvault-admin/src/backupClient.ts +++ b/sdk/keyvault/keyvault-admin/src/backupClient.ts @@ -17,24 +17,26 @@ import { KeyVaultBackupResult, KeyVaultBeginBackupOptions, KeyVaultBeginRestoreOptions, - KeyVaultRestoreResult + KeyVaultBeginSelectiveKeyRestoreOptions, + KeyVaultRestoreResult, + KeyVaultSelectiveKeyRestoreResult } from "./backupClientModels"; import { LATEST_API_VERSION, SDK_VERSION } from "./constants"; import { logger } from "./log"; import { KeyVaultBackupPoller } from "./lro/backup/poller"; import { KeyVaultRestorePoller } from "./lro/restore/poller"; -import { KeyVaultSelectiveRestorePoller } from "./lro/selectiveRestore/poller"; +import { KeyVaultSelectiveKeyRestorePoller } from "./lro/selectiveKeyRestore/poller"; import { KeyVaultBackupOperationState } from "./lro/backup/operation"; import { KeyVaultRestoreOperationState } from "./lro/restore/operation"; import { KeyVaultAdminPollOperationState } from "./lro/keyVaultAdminPoller"; -import { KeyVaultSelectiveRestoreOperationState } from "./lro/selectiveRestore/operation"; +import { KeyVaultSelectiveKeyRestoreOperationState } from "./lro/selectiveKeyRestore/operation"; import { KeyVaultClientOptionalParams } from "./generated/models"; import { mappings } from "./mappings"; export { KeyVaultBackupOperationState, KeyVaultRestoreOperationState, - KeyVaultSelectiveRestoreOperationState, + KeyVaultSelectiveKeyRestoreOperationState, KeyVaultAdminPollOperationState }; @@ -233,7 +235,7 @@ export class KeyVaultBackupClient { * const blobStorageUri = ""; * const sasToken = ""; * const keyName = ""; - * const poller = await client.beginSelectiveRestore(keyName, blobStorageUri, sasToken); + * const poller = await client.beginSelectiveKeyRestore(keyName, blobStorageUri, sasToken); * * // Serializing the poller * // @@ -241,7 +243,7 @@ export class KeyVaultBackupClient { * // * // A new poller can be created with: * // - * // await client.beginSelectiveRestore(keyName, blobStorageUri, sasToken, { resumeFrom: serialized }); + * // await client.beginSelectiveKeyRestore(keyName, blobStorageUri, sasToken, { resumeFrom: serialized }); * // * * // Waiting until it's done @@ -253,13 +255,15 @@ export class KeyVaultBackupClient { * @param sasToken - The SAS token. * @param options - The optional parameters. */ - public async beginSelectiveRestore( + public async beginSelectiveKeyRestore( keyName: string, folderUri: string, sasToken: string, - options: KeyVaultBeginBackupOptions = {} - ): Promise> { - const poller = new KeyVaultSelectiveRestorePoller({ + options: KeyVaultBeginSelectiveKeyRestoreOptions = {} + ): Promise< + PollerLike + > { + const poller = new KeyVaultSelectiveKeyRestorePoller({ ...mappings.folderUriParts(folderUri), keyName, sasToken, diff --git a/sdk/keyvault/keyvault-admin/src/backupClientModels.ts b/sdk/keyvault/keyvault-admin/src/backupClientModels.ts index ec41a583c743..8ab3eac1cfe0 100644 --- a/sdk/keyvault/keyvault-admin/src/backupClientModels.ts +++ b/sdk/keyvault/keyvault-admin/src/backupClientModels.ts @@ -43,9 +43,9 @@ export interface KeyVaultBeginRestoreOptions extends KeyVaultBackupPollerOptions /** * An interface representing the optional parameters that can be - * passed to {@link beginSelectiveRestore} + * passed to {@link beginSelectiveKeyRestore} */ -export interface KeyVaultBeginSelectiveRestoreOptions extends KeyVaultBackupPollerOptions {} +export interface KeyVaultBeginSelectiveKeyRestoreOptions extends KeyVaultBackupPollerOptions {} /** * An interface representing the result of a backup operation. @@ -81,3 +81,18 @@ export interface KeyVaultRestoreResult { */ endTime?: Date; } + +/** + * An interface representing the result of a selective key restore operation. + */ +export interface KeyVaultSelectiveKeyRestoreResult { + /** + * The start time of the selective key restore operation. + */ + startTime: Date; + + /** + * The end time of the selective key restore operation. + */ + endTime?: Date; +} diff --git a/sdk/keyvault/keyvault-admin/src/lro/selectiveRestore/operation.ts b/sdk/keyvault/keyvault-admin/src/lro/selectiveKeyRestore/operation.ts similarity index 85% rename from sdk/keyvault/keyvault-admin/src/lro/selectiveRestore/operation.ts rename to sdk/keyvault/keyvault-admin/src/lro/selectiveKeyRestore/operation.ts index 0d5f845316f3..254c597d1e70 100644 --- a/sdk/keyvault/keyvault-admin/src/lro/selectiveRestore/operation.ts +++ b/sdk/keyvault/keyvault-admin/src/lro/selectiveKeyRestore/operation.ts @@ -14,20 +14,20 @@ import { KeyVaultAdminPollOperation, KeyVaultAdminPollOperationState } from "../keyVaultAdminPoller"; -import { KeyVaultRestoreResult } from "../../backupClientModels"; +import { KeyVaultSelectiveKeyRestoreResult } from "../../backupClientModels"; import { withTrace } from "./poller"; /** * An interface representing the publicly available properties of the state of a restore Key Vault's poll operation. */ -export interface KeyVaultSelectiveRestoreOperationState - extends KeyVaultAdminPollOperationState {} +export interface KeyVaultSelectiveKeyRestoreOperationState + extends KeyVaultAdminPollOperationState {} /** * An internal interface representing the state of a restore Key Vault's poll operation. */ -export interface KeyVaultSelectiveRestorePollOperationState - extends KeyVaultAdminPollOperationState { +export interface KeyVaultSelectiveKeyRestorePollOperationState + extends KeyVaultAdminPollOperationState { /** * The name of a Key Vault Key. */ @@ -49,12 +49,12 @@ export interface KeyVaultSelectiveRestorePollOperationState /** * The selective restore Key Vault's poll operation. */ -export class KeyVaultSelectiveRestorePollOperation extends KeyVaultAdminPollOperation< - KeyVaultSelectiveRestorePollOperationState, +export class KeyVaultSelectiveKeyRestorePollOperation extends KeyVaultAdminPollOperation< + KeyVaultSelectiveKeyRestorePollOperationState, string > { constructor( - public state: KeyVaultSelectiveRestorePollOperationState, + public state: KeyVaultSelectiveKeyRestorePollOperationState, private vaultUrl: string, private client: KeyVaultClient, private requestOptions: RequestOptionsBase = {} @@ -92,9 +92,9 @@ export class KeyVaultSelectiveRestorePollOperation extends KeyVaultAdminPollOper async update( options: { abortSignal?: AbortSignalLike; - fireProgress?: (state: KeyVaultSelectiveRestorePollOperationState) => void; + fireProgress?: (state: KeyVaultSelectiveKeyRestorePollOperationState) => void; } = {} - ): Promise { + ): Promise { const state = this.state; const { keyName, folderUri, sasToken, folderName } = state; diff --git a/sdk/keyvault/keyvault-admin/src/lro/selectiveRestore/poller.ts b/sdk/keyvault/keyvault-admin/src/lro/selectiveKeyRestore/poller.ts similarity index 56% rename from sdk/keyvault/keyvault-admin/src/lro/selectiveRestore/poller.ts rename to sdk/keyvault/keyvault-admin/src/lro/selectiveKeyRestore/poller.ts index 984241a74eb0..eb7a53b3932f 100644 --- a/sdk/keyvault/keyvault-admin/src/lro/selectiveRestore/poller.ts +++ b/sdk/keyvault/keyvault-admin/src/lro/selectiveKeyRestore/poller.ts @@ -2,15 +2,15 @@ // Licensed under the MIT license. import { - KeyVaultSelectiveRestorePollOperation, - KeyVaultSelectiveRestoreOperationState, - KeyVaultSelectiveRestorePollOperationState + KeyVaultSelectiveKeyRestorePollOperation, + KeyVaultSelectiveKeyRestoreOperationState, + KeyVaultSelectiveKeyRestorePollOperationState } from "./operation"; import { KeyVaultAdminPollerOptions, KeyVaultAdminPoller } from "../keyVaultAdminPoller"; -import { KeyVaultRestoreResult } from "../../backupClientModels"; +import { KeyVaultSelectiveKeyRestoreResult } from "../../backupClientModels"; import { createTraceFunction } from "../../../../keyvault-common/src"; -export interface KeyVaultSelectiveRestorePollerOptions extends KeyVaultAdminPollerOptions { +export interface KeyVaultSelectiveKeyRestorePollerOptions extends KeyVaultAdminPollerOptions { keyName: string; folderUri: string; sasToken: string; @@ -20,16 +20,18 @@ export interface KeyVaultSelectiveRestorePollerOptions extends KeyVaultAdminPoll /** * @internal */ -export const withTrace = createTraceFunction("Azure.KeyVault.Admin.KeyVaultSelectiveRestorePoller"); +export const withTrace = createTraceFunction( + "Azure.KeyVault.Admin.KeyVaultSelectiveKeyRestorePoller" +); /** * Class that creates a poller that waits until a key of a Key Vault backup ends up being restored. */ -export class KeyVaultSelectiveRestorePoller extends KeyVaultAdminPoller< - KeyVaultSelectiveRestoreOperationState, - KeyVaultRestoreResult +export class KeyVaultSelectiveKeyRestorePoller extends KeyVaultAdminPoller< + KeyVaultSelectiveKeyRestoreOperationState, + KeyVaultSelectiveKeyRestoreResult > { - constructor(options: KeyVaultSelectiveRestorePollerOptions) { + constructor(options: KeyVaultSelectiveKeyRestorePollerOptions) { const { client, vaultUrl, @@ -42,13 +44,13 @@ export class KeyVaultSelectiveRestorePoller extends KeyVaultAdminPoller< resumeFrom } = options; - let state: KeyVaultSelectiveRestorePollOperationState | undefined; + let state: KeyVaultSelectiveKeyRestorePollOperationState | undefined; if (resumeFrom) { state = JSON.parse(resumeFrom).state; } - const operation = new KeyVaultSelectiveRestorePollOperation( + const operation = new KeyVaultSelectiveKeyRestorePollOperation( { ...state, keyName, diff --git a/sdk/keyvault/keyvault-admin/test/public/backupClient.abort.spec.ts b/sdk/keyvault/keyvault-admin/test/public/backupClient.abort.spec.ts index 9e1220da0972..4a26375a3d60 100644 --- a/sdk/keyvault/keyvault-admin/test/public/backupClient.abort.spec.ts +++ b/sdk/keyvault/keyvault-admin/test/public/backupClient.abort.spec.ts @@ -57,14 +57,14 @@ describe("Aborting KeyVaultBackupClient's requests", () => { }); }); - it("can abort beginSelectiveRestore", async function() { + it("can abort beginSelectiveKeyRestore", async function() { const backupURI = `${blobStorageUri}/${generateFakeUUID()}`; const controller = new AbortController(); controller.abort(); await assertThrowsAbortError(async () => { - await client.beginSelectiveRestore("key-name", backupURI, blobSasToken, { + await client.beginSelectiveKeyRestore("key-name", backupURI, blobSasToken, { ...testPollerProperties, abortSignal: controller.signal }); diff --git a/sdk/keyvault/keyvault-admin/test/public/backupClient.spec.ts b/sdk/keyvault/keyvault-admin/test/public/backupClient.spec.ts index d54aafa0c035..542f9eee454f 100644 --- a/sdk/keyvault/keyvault-admin/test/public/backupClient.spec.ts +++ b/sdk/keyvault/keyvault-admin/test/public/backupClient.spec.ts @@ -116,7 +116,7 @@ describe("KeyVaultBackupClient", () => { } }); - it("selectiveRestore completes successfully", async function() { + it("selectiveKeyRestore completes successfully", async function() { // This test can only be run in playback mode because running a backup // or restore puts the instance in a bad state (tracked in IcM). if (!isPlaybackMode()) { @@ -136,32 +136,32 @@ describe("KeyVaultBackupClient", () => { await (await keyClient.beginDeleteKey(keyName, testPollerProperties)).pollUntilDone(); await keyClient.purgeDeletedKey(keyName); - const selectiveRestorePoller = await client.beginSelectiveRestore( + const selectiveKeyRestorePoller = await client.beginSelectiveKeyRestore( keyName, backupURI.folderUri!, blobSasToken, testPollerProperties ); - await selectiveRestorePoller.poll(); + await selectiveKeyRestorePoller.poll(); // A poller can be serialized and then resumed - const resumedPoller = await client.beginSelectiveRestore( + const resumedPoller = await client.beginSelectiveKeyRestore( keyName, blobStorageUri, blobSasToken, { ...testPollerProperties, - resumeFrom: selectiveRestorePoller.toString() + resumeFrom: selectiveKeyRestorePoller.toString() } ); assert.isTrue(resumedPoller.getOperationState().isStarted); // without polling assert.equal( resumedPoller.getOperationState().jobId, - selectiveRestorePoller.getOperationState().jobId + selectiveKeyRestorePoller.getOperationState().jobId ); - await selectiveRestorePoller.pollUntilDone(); - const operationState = selectiveRestorePoller.getOperationState(); + await selectiveKeyRestorePoller.pollUntilDone(); + const operationState = selectiveKeyRestorePoller.getOperationState(); assert.equal(operationState.isCompleted, true); await keyClient.getKey(keyName);