import { Paginator } from "@aws-sdk/types" ; import { ListRetainedMessagesCommand , ListRetainedMessagesCommandInput , ListRetainedMessagesCommandOutput , } from "../commands/ListRetainedMessagesCommand" ; import { IoTDataPlane } from "../IoTDataPlane" ; import { IoTDataPlaneClient } from "../IoTDataPlaneClient" ; import { IoTDataPlanePaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListRetainedMessagesCommandOutput > => { return await client . send ( new ListRetainedMessagesCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListRetainedMessagesCommandOutput > => { return await client . listRetainedMessages ( input , ... args ) ; } ; export async function * paginateListRetainedMessages ( 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 IoTDataPlane ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof IoTDataPlaneClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected IoTDataPlane | IoTDataPlaneClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }