import { Paginator } from "@aws-sdk/types" ; import { CloudFront } from "../CloudFront" ; import { CloudFrontClient } from "../CloudFrontClient" ; import { ListStreamingDistributionsCommand , ListStreamingDistributionsCommandInput , ListStreamingDistributionsCommandOutput , } from "../commands/ListStreamingDistributionsCommand" ; import { CloudFrontPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListStreamingDistributionsCommandOutput > => { return await client . send ( new ListStreamingDistributionsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListStreamingDistributionsCommandOutput > => { return await client . listStreamingDistributions ( input , ... args ) ; } ; export async function * paginateListStreamingDistributions ( 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 CloudFront ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof CloudFrontClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected CloudFront | CloudFrontClient" ) ; } yield page ; token = page . StreamingDistributionList ! . NextMarker ; hasNext = ! ! token ; } return undefined ; }