import { Paginator } from "@aws-sdk/types" ; import { ListDomainsCommand , ListDomainsCommandInput , ListDomainsCommandOutput } from "../commands/ListDomainsCommand" ; import { SageMaker } from "../SageMaker" ; import { SageMakerClient } from "../SageMakerClient" ; import { SageMakerPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListDomainsCommandOutput > => { return await client . send ( new ListDomainsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListDomainsCommandOutput > => { return await client . listDomains ( input , ... args ) ; } ; export async function * paginateListDomains ( 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 SageMaker ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof SageMakerClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected SageMaker | SageMakerClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }