import { Paginator } from "@aws-sdk/types" ; import { DescribeReservedElasticsearchInstanceOfferingsCommand , DescribeReservedElasticsearchInstanceOfferingsCommandInput , DescribeReservedElasticsearchInstanceOfferingsCommandOutput , } from "../commands/DescribeReservedElasticsearchInstanceOfferingsCommand" ; import { ElasticsearchService } from "../ElasticsearchService" ; import { ElasticsearchServiceClient } from "../ElasticsearchServiceClient" ; import { ElasticsearchServicePaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < DescribeReservedElasticsearchInstanceOfferingsCommandOutput > => { return await client . send ( new DescribeReservedElasticsearchInstanceOfferingsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < DescribeReservedElasticsearchInstanceOfferingsCommandOutput > => { return await client . describeReservedElasticsearchInstanceOfferings ( input , ... args ) ; } ; export async function * paginateDescribeReservedElasticsearchInstanceOfferings ( 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 ElasticsearchService ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof ElasticsearchServiceClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected ElasticsearchService | ElasticsearchServiceClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }