Skip to content

Commit e0039e3

Browse files
committed
Add the search to users list function
1 parent 2d286dd commit e0039e3

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def create_user(self, name: str, email: str, roles: Optional[Dict[str, bool]] =
152152
response.raise_for_status()
153153
return response.json()
154154

155-
def list_users(self, limit: int = 10, offset: int = 0) -> Dict[str, Any]:
155+
def list_users(self, limit: int = 10, offset: int = 0, search: Optional[str] = None) -> Dict[str, Any]:
156156
"""List all users in PagerTree."""
157-
params = {k: v for k, v in {"limit": limit, "offset": offset}.items() if v is not None}
157+
params = {k: v for k, v in {"limit": limit, "offset": offset, "q": search}.items() if v is not None}
158158
response = self.session.get(f"{self.base_url}/account_users", params=params)
159159
response.raise_for_status()
160160
data = response.json()

commands/users.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ def create_user_cmd(ctx, name, email, role, team_ids):
2525
@users.command(name="list")
2626
@click.option("--limit", default=10, type=click.IntRange(1, 100), help="Number of users per page")
2727
@click.option("--offset", default=0, type=click.IntRange(0), help="Starting point for pagination")
28+
@click.option("--search", help="Search for users by name, email, phone, or roles")
2829
@click.pass_context
29-
def list_users_cmd(ctx, limit, offset):
30+
def list_users_cmd(ctx, limit, offset, search):
3031
"""List users in PagerTree with pagination."""
3132
try:
3233
client = ctx.obj # Get PagerTreeClient from context
33-
result = client.list_users(limit=limit, offset=offset)
34+
result = client.list_users(limit=limit, offset=offset, search=search)
3435
users_list = result["data"]
3536
total = result["total"]
3637
# Prepare table data

0 commit comments

Comments
 (0)