import { Paginator } from "@aws-sdk/types" ; import { DescribeEcsClustersCommand , DescribeEcsClustersCommandInput , DescribeEcsClustersCommandOutput , } from "../commands/DescribeEcsClustersCommand" ; import { OpsWorks } from "../OpsWorks" ; import { OpsWorksClient } from "../OpsWorksClient" ; import { OpsWorksPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < DescribeEcsClustersCommandOutput > => { return await client . send ( new DescribeEcsClustersCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < DescribeEcsClustersCommandOutput > => { return await client . describeEcsClusters ( input , ... args ) ; } ; export async function * paginateDescribeEcsClusters ( 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 OpsWorks ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof OpsWorksClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected OpsWorks | OpsWorksClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }