import { Paginator } from "@aws-sdk/types" ; import { ListServerCertificatesCommand , ListServerCertificatesCommandInput , ListServerCertificatesCommandOutput , } from "../commands/ListServerCertificatesCommand" ; import { IAM } from "../IAM" ; import { IAMClient } from "../IAMClient" ; import { IAMPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListServerCertificatesCommandOutput > => { return await client . send ( new ListServerCertificatesCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListServerCertificatesCommandOutput > => { return await client . listServerCertificates ( input , ... args ) ; } ; export async function * paginateListServerCertificates ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . Marker = token ; input [ "MaxItems" ] = config . pageSize ; if ( config . client instanceof IAM ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof IAMClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected IAM | IAMClient" ) ; } yield page ; token = page . Marker ; hasNext = ! ! token ; } return undefined ; }