-
Notifications
You must be signed in to change notification settings - Fork 586
/
waitForLoadBalancersDeleted.ts
65 lines (63 loc) · 2.33 KB
/
waitForLoadBalancersDeleted.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
63
64
65
// smithy-typescript generated code
import { checkExceptions, createWaiter, WaiterConfiguration, WaiterResult, WaiterState } from "@smithy/util-waiter";
import {
DescribeLoadBalancersCommand,
DescribeLoadBalancersCommandInput,
} from "../commands/DescribeLoadBalancersCommand";
import { ElasticLoadBalancingV2Client } from "../ElasticLoadBalancingV2Client";
const checkState = async (
client: ElasticLoadBalancingV2Client,
input: DescribeLoadBalancersCommandInput
): Promise<WaiterResult> => {
let reason;
try {
const result: any = await client.send(new DescribeLoadBalancersCommand(input));
reason = result;
try {
const returnComparator = () => {
const flat_1: any[] = [].concat(...result.LoadBalancers);
const projection_3 = flat_1.map((element_2: any) => {
return element_2.State.Code;
});
return projection_3;
};
let allStringEq_5 = returnComparator().length > 0;
for (const element_4 of returnComparator()) {
allStringEq_5 = allStringEq_5 && element_4 == "active";
}
if (allStringEq_5) {
return { state: WaiterState.RETRY, reason };
}
} catch (e) {}
} catch (exception) {
reason = exception;
if (exception.name && exception.name == "LoadBalancerNotFound") {
return { state: WaiterState.SUCCESS, reason };
}
}
return { state: WaiterState.RETRY, reason };
};
/**
*
* @deprecated Use waitUntilLoadBalancersDeleted instead. waitForLoadBalancersDeleted does not throw error in non-success cases.
*/
export const waitForLoadBalancersDeleted = async (
params: WaiterConfiguration<ElasticLoadBalancingV2Client>,
input: DescribeLoadBalancersCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 15, maxDelay: 120 };
return createWaiter({ ...serviceDefaults, ...params }, input, checkState);
};
/**
*
* @param params - Waiter configuration options.
* @param input - The input to DescribeLoadBalancersCommand for polling.
*/
export const waitUntilLoadBalancersDeleted = async (
params: WaiterConfiguration<ElasticLoadBalancingV2Client>,
input: DescribeLoadBalancersCommandInput
): Promise<WaiterResult> => {
const serviceDefaults = { minDelay: 15, maxDelay: 120 };
const result = await createWaiter({ ...serviceDefaults, ...params }, input, checkState);
return checkExceptions(result);
};