import { Paginator } from "@aws-sdk/types" ; import { AuditManager } from "../AuditManager" ; import { AuditManagerClient } from "../AuditManagerClient" ; import { GetEvidenceByEvidenceFolderCommand , GetEvidenceByEvidenceFolderCommandInput , GetEvidenceByEvidenceFolderCommandOutput , } from "../commands/GetEvidenceByEvidenceFolderCommand" ; import { AuditManagerPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < GetEvidenceByEvidenceFolderCommandOutput > => { return await client . send ( new GetEvidenceByEvidenceFolderCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < GetEvidenceByEvidenceFolderCommandOutput > => { return await client . getEvidenceByEvidenceFolder ( input , ... args ) ; } ; export async function * paginateGetEvidenceByEvidenceFolder ( 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 AuditManager ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof AuditManagerClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected AuditManager | AuditManagerClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }