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

Bring back Pagination in v11.0.0 #884

Closed
arvindkrishnakumar-okta opened this issue Jun 14, 2023 · 3 comments
Closed

Bring back Pagination in v11.0.0 #884

arvindkrishnakumar-okta opened this issue Jun 14, 2023 · 3 comments

Comments

@arvindkrishnakumar-okta
Copy link
Contributor

Describe the feature request?

Bring back list*WithPaginationInfo in 11.0.0 SDK version.

New or Affected Resource(s)

All APIs that return a collection of models.

Provide a documentation link

No response

Additional Information?

No response

@clementdenis
Copy link
Contributor

clementdenis commented Jun 16, 2023

Hi @arvindkrishnakumar-okta,

I've implemented a quick and easy solution to bring back pagination in v11:
clementdenis@6879127?w=1

The idea is to wrap List<> responses with pagination info (self / next link headers) in a PagedList instance (I just brought back the class from v10, but made it extend ArrayList).

Paginating is done this way:

UserApi userApi = new UserApi(client);
int limit = 2;
List<User> pagedUserList = null;
do {
    pagedUserList = userApi.listUsers(null, PagedList.getAfter(pagedUserList), limit, null, null, null, null);
    //pagedUserList can also be casted to a PagedList instance
    // loop through all of them
    for (User tmpUser : pagedUserList.getItems()) {
        log.info("User: {}", tmpUser.getProfile().getEmail());
    }
} while (PagedList.hasMoreResults(pagedUserList));

Feel free to use this code, or I can create a PR if you prefer.

PS: I took the liberty of reformating ApiClient.mustache properly, it's much easier to add changes that way.

@arvindkrishnakumar-okta
Copy link
Contributor Author

@clementdenis Thanks, I'll create a PR for Pagination shortly.

@arvindkrishnakumar-okta arvindkrishnakumar-okta changed the title Bring back list*WithPaginationInfo in 11.0.0 Bring back Pagination in v11.0.0 Jun 23, 2023
@arvindkrishnakumar-okta
Copy link
Contributor Author

PR merged to master, will cut a new major release in a week.

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

No branches or pull requests

2 participants