import { Paginator } from "@aws-sdk/types" ; import { ListMembersCommand , ListMembersCommandInput , ListMembersCommandOutput } from "../commands/ListMembersCommand" ; import { SecurityHub } from "../SecurityHub" ; import { SecurityHubClient } from "../SecurityHubClient" ; import { SecurityHubPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListMembersCommandOutput > => { return await client . send ( new ListMembersCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListMembersCommandOutput > => { return await client . listMembers ( input , ... args ) ; } ; export async function * paginateListMembers ( 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 SecurityHub ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof SecurityHubClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected SecurityHub | SecurityHubClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }