Skip to content

Commit

Permalink
Merge pull request #304 from connorlurring/admin-list-users-pagination
Browse files Browse the repository at this point in the history
feat: support pagination for auth admin list_users
  • Loading branch information
J0 committed Sep 8, 2023
2 parents 8684125 + e7cbd9f commit 1b88c51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gotrue/_async/gotrue_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def create_user(self, attributes: AdminUserAttributes) -> UserResponse:
xform=parse_user_response,
)

async def list_users(self) -> List[User]:
async def list_users(self, page: int = None, per_page: int = None) -> List[User]:
"""
Get a list of users.
Expand All @@ -110,6 +110,7 @@ async def list_users(self) -> List[User]:
return await self._request(
"GET",
"admin/users",
query={"page": page, "per_page": per_page},
xform=lambda data: [model_validate(User, user) for user in data["users"]]
if "users" in data
else [],
Expand Down
3 changes: 2 additions & 1 deletion gotrue/_sync/gotrue_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def create_user(self, attributes: AdminUserAttributes) -> UserResponse:
xform=parse_user_response,
)

def list_users(self) -> List[User]:
def list_users(self, page: int = None, per_page: int = None) -> List[User]:
"""
Get a list of users.
Expand All @@ -110,6 +110,7 @@ def list_users(self) -> List[User]:
return self._request(
"GET",
"admin/users",
query={"page": page, "per_page": per_page},
xform=lambda data: [model_validate(User, user) for user in data["users"]]
if "users" in data
else [],
Expand Down

0 comments on commit 1b88c51

Please sign in to comment.