import { Paginator } from "@aws-sdk/types" ; import { DescribeAddressesCommand , DescribeAddressesCommandInput , DescribeAddressesCommandOutput , } from "../commands/DescribeAddressesCommand" ; import { Snowball } from "../Snowball" ; import { SnowballClient } from "../SnowballClient" ; import { SnowballPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < DescribeAddressesCommandOutput > => { return await client . send ( new DescribeAddressesCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < DescribeAddressesCommandOutput > => { return await client . describeAddresses ( input , ... args ) ; } ; export async function * paginateDescribeAddresses ( 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 Snowball ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof SnowballClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected Snowball | SnowballClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }