-
Notifications
You must be signed in to change notification settings - Fork 136
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
Comments
I've implemented a quick and easy solution to bring back pagination in v11: 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. |
@clementdenis Thanks, I'll create a PR for Pagination shortly. |
PR merged to master, will cut a new major release in a week. |
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
The text was updated successfully, but these errors were encountered: