Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Paginator Functionality #40

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

anitarodia
Copy link

Added the paginateEach and paginateEachSearchApi method to the Paginator class.

This method returns an async iterable, allowing users to iterate over pages of results using the for await...of syntax.This provides an efficient way to process large datasets page by page, reducing memory usage by handling each page individually.

Introduced paginateEach and paginateEachSearchApi: These generator functions allow you to iterate over each page individually, improving memory efficiency.
Added for AsyncGenerator support in Paginator
@anitarodia
Copy link
Author

anitarodia commented Aug 27, 2024

Example:

import { Configuration, AccountsApi, Paginator } from 'sailpoint-api-client';

const processAccountsPageByPage = async () => {
  let apiConfig = new Configuration();
  let api = new AccountsApi(apiConfig);

  // Using paginateEach to process each page individually
  for await (const page of Paginator.paginateEach(
    api,
    api.listAccounts,
    { limit: 1000 }, // Request a total of 1000 accounts
    250              // Page size of 250 accounts
  )) {
    console.log(page.forEach(account => console.log(account)));
    // Process each page of results here
  }
};

processAccountsPageByPage();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant