import { Paginator } from "@aws-sdk/types" ; import { Amp } from "../Amp" ; import { AmpClient } from "../AmpClient" ; import { ListRuleGroupsNamespacesCommand , ListRuleGroupsNamespacesCommandInput , ListRuleGroupsNamespacesCommandOutput , } from "../commands/ListRuleGroupsNamespacesCommand" ; import { AmpPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListRuleGroupsNamespacesCommandOutput > => { return await client . send ( new ListRuleGroupsNamespacesCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListRuleGroupsNamespacesCommandOutput > => { return await client . listRuleGroupsNamespaces ( input , ... args ) ; } ; export async function * paginateListRuleGroupsNamespaces ( 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 Amp ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof AmpClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected Amp | AmpClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }