import { Paginator } from "@aws-sdk/types" ; import { ListVaultsCommand , ListVaultsCommandInput , ListVaultsCommandOutput } from "../commands/ListVaultsCommand" ; import { Glacier } from "../Glacier" ; import { GlacierClient } from "../GlacierClient" ; import { GlacierPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListVaultsCommandOutput > => { return await client . send ( new ListVaultsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListVaultsCommandOutput > => { return await client . listVaults ( input , ... args ) ; } ; export async function * paginateListVaults ( 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 Glacier ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof GlacierClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected Glacier | GlacierClient" ) ; } yield page ; token = page . Marker ; hasNext = ! ! token ; } return undefined ; }