Skip to content

Commit

Permalink
feat: support pagination for admin list_users
Browse files Browse the repository at this point in the history
  • Loading branch information
connorlurring committed Aug 31, 2023
1 parent 5cc198b commit e7cbd9f
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 e7cbd9f

Please sign in to comment.