import { Paginator } from "@aws-sdk/types" ; import { ListEnvironmentTemplatesCommand , ListEnvironmentTemplatesCommandInput , ListEnvironmentTemplatesCommandOutput , } from "../commands/ListEnvironmentTemplatesCommand" ; import { Proton } from "../Proton" ; import { ProtonClient } from "../ProtonClient" ; import { ProtonPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListEnvironmentTemplatesCommandOutput > => { return await client . send ( new ListEnvironmentTemplatesCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListEnvironmentTemplatesCommandOutput > => { return await client . listEnvironmentTemplates ( input , ... args ) ; } ; export async function * paginateListEnvironmentTemplates ( 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 Proton ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof ProtonClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected Proton | ProtonClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }