-
Notifications
You must be signed in to change notification settings - Fork 544
/
GetBasePathMappingsPaginator.ts
51 lines (50 loc) · 1.76 KB
/
GetBasePathMappingsPaginator.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
import { APIGateway } from "../APIGateway";
import { APIGatewayClient } from "../APIGatewayClient";
import {
GetBasePathMappingsCommand,
GetBasePathMappingsCommandInput,
GetBasePathMappingsCommandOutput,
} from "../commands/GetBasePathMappingsCommand";
import { APIGatewayPaginationConfiguration } from "./Interfaces";
import { Paginator } from "@aws-sdk/types";
const makePagedClientRequest = async (
client: APIGatewayClient,
input: GetBasePathMappingsCommandInput,
...args: any
): Promise<GetBasePathMappingsCommandOutput> => {
// @ts-ignore
return await client.send(new GetBasePathMappingsCommand(input, ...args));
};
const makePagedRequest = async (
client: APIGateway,
input: GetBasePathMappingsCommandInput,
...args: any
): Promise<GetBasePathMappingsCommandOutput> => {
// @ts-ignore
return await client.getBasePathMappings(input, ...args);
};
export async function* getBasePathMappingsPaginate(
config: APIGatewayPaginationConfiguration,
input: GetBasePathMappingsCommandInput,
...additionalArguments: any
): Paginator<GetBasePathMappingsCommandOutput> {
let token: string | undefined = config.startingToken || undefined;
let hasNext = true;
let page: GetBasePathMappingsCommandOutput;
while (hasNext) {
input.position = token;
input["limit"] = config.pageSize;
if (config.client instanceof APIGateway) {
page = await makePagedRequest(config.client, input, ...additionalArguments);
} else if (config.client instanceof APIGatewayClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected APIGateway | APIGatewayClient");
}
yield page;
token = page.position;
hasNext = !!token;
}
// @ts-ignore
return undefined;
}