import { Paginator } from "@aws-sdk/types" ; import { APIGateway } from "../APIGateway" ; import { APIGatewayClient } from "../APIGatewayClient" ; import { GetVpcLinksCommand , GetVpcLinksCommandInput , GetVpcLinksCommandOutput } from "../commands/GetVpcLinksCommand" ; import { APIGatewayPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < GetVpcLinksCommandOutput > => { return await client . send ( new GetVpcLinksCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < GetVpcLinksCommandOutput > => { return await client . getVpcLinks ( input , ... args ) ; } ; export async function * paginateGetVpcLinks ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; 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 ; } return undefined ; }