import { Paginator } from "@aws-sdk/types" ; import { CloudTrail } from "../CloudTrail" ; import { CloudTrailClient } from "../CloudTrailClient" ; import { LookupEventsCommand , LookupEventsCommandInput , LookupEventsCommandOutput , } from "../commands/LookupEventsCommand" ; import { CloudTrailPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < LookupEventsCommandOutput > => { return await client . send ( new LookupEventsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < LookupEventsCommandOutput > => { return await client . lookupEvents ( input , ... args ) ; } ; export async function * paginateLookupEvents ( 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 CloudTrail ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof CloudTrailClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected CloudTrail | CloudTrailClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }