import { Paginator } from "@aws-sdk/types" ; import { ListKeysCommand , ListKeysCommandInput , ListKeysCommandOutput } from "../commands/ListKeysCommand" ; import { KMS } from "../KMS" ; import { KMSClient } from "../KMSClient" ; import { KMSPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListKeysCommandOutput > => { return await client . send ( new ListKeysCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListKeysCommandOutput > => { return await client . listKeys ( input , ... args ) ; } ; export async function * paginateListKeys ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . Marker = token ; input [ "Limit" ] = config . pageSize ; if ( config . client instanceof KMS ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof KMSClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected KMS | KMSClient" ) ; } yield page ; token = page . NextMarker ; hasNext = ! ! token ; } return undefined ; }