Skip to content

Commit

Permalink
PATCH: Implemented checkpoint pagination for retrieving Role users (a…
Browse files Browse the repository at this point in the history
…uth0#1048)

* Implemented checkpoint pagination on role users

* added tests

Signed-off-by: BryanLewis-AtOkta <[email protected]>
  • Loading branch information
bryanlewis-okta committed Oct 24, 2024
1 parent 822c3b2 commit 9184505
Show file tree
Hide file tree
Showing 4 changed files with 1,191 additions and 1,183 deletions.
16 changes: 12 additions & 4 deletions internal/auth0/role/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,28 @@ func getAllRoleUsers(
roleID string,
) ([]*management.User, error) {
var users []*management.User
var page int
var from string

options := []management.RequestOption{
management.Take(100),
}

for {
userList, err := api.Role.Users(ctx, roleID, management.Page(page), management.PerPage(100))
if from != "" {
options = append(options, management.From(from))
}

userList, err := api.Role.Users(ctx, roleID, options...)
if err != nil {
return nil, err
}

users = append(users, userList.Users...)

if !userList.HasNext() {
break
}

page++
from = userList.Next
}

return users, nil
Expand Down
Loading

0 comments on commit 9184505

Please sign in to comment.