Skip to content

Commit f9d80d8

Browse files
authored
CI-408 - Add list user endpoint (#127)
* add list user endpoint * add user detail
1 parent 9f0e499 commit f9d80d8

File tree

3 files changed

+267
-323
lines changed

3 files changed

+267
-323
lines changed

cirro/services/user.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
1-
from cirro_api_client.v1.api.users import invite_user
2-
from cirro_api_client.v1.models import InviteUserRequest
1+
from typing import List
32

4-
from cirro.services.base import BaseService
3+
from cirro_api_client.v1.api.users import invite_user, list_users, get_user
4+
from cirro_api_client.v1.models import InviteUserRequest, User, UserDetail
5+
6+
from cirro.services.base import BaseService, get_all_records
57

68

79
class UserService(BaseService):
10+
def list(self, max_items: int = 10000) -> List[User]:
11+
"""
12+
List users in the system
13+
"""
14+
return get_all_records(
15+
records_getter=lambda page_args: list_users.sync(
16+
client=self._api_client,
17+
next_token=page_args.next_token,
18+
limit=page_args.limit
19+
),
20+
max_items=max_items
21+
)
22+
23+
def get(self, username: str) -> UserDetail:
24+
"""
25+
Get user details by username, including what projects they are assigned to
26+
"""
27+
return get_user.sync(username=username, client=self._api_client)
28+
829
def invite_user(self, name: str, organization: str, email: str):
930
"""
1031
Invite a user to the system.

0 commit comments

Comments
 (0)