-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
poller.ts
61 lines (51 loc) · 1.63 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { delay, RequestOptionsBase } from "@azure/core-http";
import { Poller } from "@azure/core-lro";
import {
RecoverDeletedSecretPollOperationState,
makeRecoverDeletedSecretPollOperation
} from "./operation";
import { SecretProperties, SecretClientInterface } from "../../secretsModels";
export interface RecoverDeletedSecretPollerOptions {
client: SecretClientInterface;
name: string;
requestOptions?: RequestOptionsBase;
intervalInMs?: number;
resumeFrom?: string;
}
/**
* Class that deletes a poller that waits until a secret finishes being deleted
*/
export class RecoverDeletedSecretPoller extends Poller<
RecoverDeletedSecretPollOperationState,
SecretProperties
> {
/**
* Defines how much time the poller is going to wait before making a new request to the service.
* @memberof RecoverDeletedSecretPoller
*/
public intervalInMs: number;
constructor(options: RecoverDeletedSecretPollerOptions) {
const { client, name, requestOptions, intervalInMs = 2000, resumeFrom } = options;
let state: RecoverDeletedSecretPollOperationState | undefined;
if (resumeFrom) {
state = JSON.parse(resumeFrom).state;
}
const operation = makeRecoverDeletedSecretPollOperation({
...state,
name,
requestOptions,
client
});
super(operation);
this.intervalInMs = intervalInMs;
}
/**
* The method used by the poller to wait before attempting to update its operation.
* @memberof RecoverDeletedSecretPoller
*/
async delay(): Promise<void> {
return delay(this.intervalInMs);
}
}