import { Paginator } from "@aws-sdk/types" ; import { ACM } from "../ACM" ; import { ACMClient } from "../ACMClient" ; import { ListCertificatesCommand , ListCertificatesCommandInput , ListCertificatesCommandOutput , } from "../commands/ListCertificatesCommand" ; import { ACMPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListCertificatesCommandOutput > => { return await client . send ( new ListCertificatesCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListCertificatesCommandOutput > => { return await client . listCertificates ( input , ... args ) ; } ; export async function * paginateListCertificates ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . NextToken = token ; input [ "MaxItems" ] = config . pageSize ; if ( config . client instanceof ACM ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof ACMClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected ACM | ACMClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }