import { Paginator } from "@aws-sdk/types" ; import { DescribeCapacityReservationsCommand , DescribeCapacityReservationsCommandInput , DescribeCapacityReservationsCommandOutput , } from "../commands/DescribeCapacityReservationsCommand" ; import { EC2 } from "../EC2" ; import { EC2Client } from "../EC2Client" ; import { EC2PaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < DescribeCapacityReservationsCommandOutput > => { return await client . send ( new DescribeCapacityReservationsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < DescribeCapacityReservationsCommandOutput > => { return await client . describeCapacityReservations ( input , ... args ) ; } ; export async function * paginateDescribeCapacityReservations ( 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 EC2 ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof EC2Client ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected EC2 | EC2Client" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }