import { Paginator } from "@aws-sdk/types" ; import { ListReservationsCommand , ListReservationsCommandInput , ListReservationsCommandOutput , } from "../commands/ListReservationsCommand" ; import { MediaConnect } from "../MediaConnect" ; import { MediaConnectClient } from "../MediaConnectClient" ; import { MediaConnectPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListReservationsCommandOutput > => { return await client . send ( new ListReservationsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListReservationsCommandOutput > => { return await client . listReservations ( input , ... args ) ; } ; export async function * paginateListReservations ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . NextToken = token ; input [ "MaxResults" ] = config . pageSize ; if ( config . client instanceof MediaConnect ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof MediaConnectClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected MediaConnect | MediaConnectClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }