import { Paginator } from "@aws-sdk/types" ; import { CognitoIdentityProvider } from "../CognitoIdentityProvider" ; import { CognitoIdentityProviderClient } from "../CognitoIdentityProviderClient" ; import { AdminListGroupsForUserCommand , AdminListGroupsForUserCommandInput , AdminListGroupsForUserCommandOutput , } from "../commands/AdminListGroupsForUserCommand" ; import { CognitoIdentityProviderPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < AdminListGroupsForUserCommandOutput > => { return await client . send ( new AdminListGroupsForUserCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < AdminListGroupsForUserCommandOutput > => { return await client . adminListGroupsForUser ( input , ... args ) ; } ; export async function * paginateAdminListGroupsForUser ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . NextToken = token ; input [ "Limit" ] = config . pageSize ; if ( config . client instanceof CognitoIdentityProvider ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof CognitoIdentityProviderClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected CognitoIdentityProvider | CognitoIdentityProviderClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }