/
ListFindingsPaginator.ts
47 lines (45 loc) · 1.54 KB
/
ListFindingsPaginator.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
// smithy-typescript generated code
import { Paginator } from "@aws-sdk/types";
import { AccessAnalyzerClient } from "../AccessAnalyzerClient";
import {
ListFindingsCommand,
ListFindingsCommandInput,
ListFindingsCommandOutput,
} from "../commands/ListFindingsCommand";
import { AccessAnalyzerPaginationConfiguration } from "./Interfaces";
/**
* @private
*/
const makePagedClientRequest = async (
client: AccessAnalyzerClient,
input: ListFindingsCommandInput,
...args: any
): Promise<ListFindingsCommandOutput> => {
// @ts-ignore
return await client.send(new ListFindingsCommand(input), ...args);
};
export async function* paginateListFindings(
config: AccessAnalyzerPaginationConfiguration,
input: ListFindingsCommandInput,
...additionalArguments: any
): Paginator<ListFindingsCommandOutput> {
// ToDo: replace with actual type instead of typeof input.nextToken
let token: typeof input.nextToken | undefined = config.startingToken || undefined;
let hasNext = true;
let page: ListFindingsCommandOutput;
while (hasNext) {
input.nextToken = token;
input["maxResults"] = config.pageSize;
if (config.client instanceof AccessAnalyzerClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected AccessAnalyzer | AccessAnalyzerClient");
}
yield page;
const prevToken = token;
token = page.nextToken;
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
// @ts-ignore
return undefined;
}