/
poller.ts
62 lines (54 loc) · 1.54 KB
/
poller.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import {
KeyVaultSelectiveKeyRestorePollOperation,
KeyVaultSelectiveKeyRestoreOperationState,
KeyVaultSelectiveKeyRestorePollOperationState
} from "./operation";
import { KeyVaultAdminPollerOptions, KeyVaultAdminPoller } from "../keyVaultAdminPoller";
import { KeyVaultSelectiveKeyRestoreResult } from "../../backupClientModels";
export interface KeyVaultSelectiveKeyRestorePollerOptions extends KeyVaultAdminPollerOptions {
keyName: string;
folderUri: string;
sasToken: string;
folderName: string;
}
/**
* Class that creates a poller that waits until a key of a Key Vault backup ends up being restored.
*/
export class KeyVaultSelectiveKeyRestorePoller extends KeyVaultAdminPoller<
KeyVaultSelectiveKeyRestoreOperationState,
KeyVaultSelectiveKeyRestoreResult
> {
constructor(options: KeyVaultSelectiveKeyRestorePollerOptions) {
const {
client,
vaultUrl,
keyName,
folderUri,
sasToken,
folderName,
requestOptions,
intervalInMs = 2000,
resumeFrom
} = options;
let state: KeyVaultSelectiveKeyRestorePollOperationState | undefined;
if (resumeFrom) {
state = JSON.parse(resumeFrom).state;
}
const operation = new KeyVaultSelectiveKeyRestorePollOperation(
{
...state,
keyName,
folderUri: folderUri,
sasToken,
folderName
},
vaultUrl,
client,
requestOptions
);
super(operation);
this.intervalInMs = intervalInMs;
}
}