User Operations¶
Operations for managing users and user-related data.
API Reference¶
UserOperations
¶
Bases: BaseOperations, UserOperationsMixin
Class to handle all operations related to users.
Methods:
-
details–Retrieve details of a specific user.
-
direct_reports–Retrieve direct reports of a specific user.
-
positions–Retrieve positions of a specific user.
-
search–Search for users based on a search term.
-
list–Retrieve all users in the system.
Functions¶
details
¶
details(user_id: int | None = None, include_direct_reports: bool = False, include_positions: bool = False, include_all: bool = False) -> UserDetails
Retrieve details of a specific user.
Parameters:
-
user_id(int | None, default:None) –The ID of the user (default: the current user ID)
-
include_direct_reports(bool, default:False) –Whether to include direct reports (default: False)
-
include_positions(bool, default:False) –Whether to include positions (default: False)
-
include_all(bool, default:False) –Whether to include both direct reports and positions (default: False)
Returns:
-
UserDetails–A UserDetails model containing user details
direct_reports
¶
direct_reports(user_id: int | None = None) -> list[DirectReport]
Retrieve direct reports of a specific user.
Parameters:
-
user_id(int | None, default:None) –The ID of the user (default: the current user ID)
Returns:
-
list[DirectReport]–A list of DirectReport models containing direct report details
positions
¶
positions(user_id: int | None = None) -> list[Position]
Retrieve positions of a specific user.
Parameters:
-
user_id(int | None, default:None) –The ID of the user (default: the current user ID)
Returns:
-
list[Position]–A list of Position models containing position details
search
¶
search(term: str) -> list[UserSearchResult]
Search for users based on a search term.
Parameters:
-
term(str) –The search term
Returns:
-
list[UserSearchResult]–A list of UserSearchResult models containing search results
list
¶
list(include_placeholders: bool = False) -> list[UserListItem]
Retrieve all users in the system.
Parameters:
-
include_placeholders(bool, default:False) –Whether to include placeholder users (default: False)
Returns:
-
list[UserListItem]–A list of UserListItem models containing user details
Async Version¶
The async version AsyncUserOperations provides the same methods as above, but with async/await support:
AsyncUserOperations
¶
Async class to handle all operations related to users.
Async Usage
All methods in AsyncUserOperations have the same parameters and return types as their sync counterparts. Simply add await before each method call and use within an async context.
Default User ID Behavior
When user_id is not provided to details(), direct_reports(), or positions(), these methods automatically default to the authenticated user. This makes it easy to get information about the current user without looking up their ID first.
Usage Examples¶
from bloomy import Client
with Client(api_key="your-api-key") as client:
# Get current user details
user = client.user.details()
print(f"Name: {user.name}")
# Search for users
results = client.user.search("john")
for user in results:
print(f"Found: {user.name}")
# Get all users
all_users = client.user.list()
# Get user with all details using include_all
user_full = client.user.details(user_id=123, include_all=True)
# Or selectively include only what you need
user_with_reports = client.user.details(user_id=123, include_direct_reports=True)
import asyncio
from bloomy import AsyncClient
async def main():
async with AsyncClient(api_key="your-api-key") as client:
# Get current user details
user = await client.user.details()
print(f"Name: {user.name}")
# Search for users
results = await client.user.search("john")
for user in results:
print(f"Found: {user.name}")
# Get all users
all_users = await client.user.list()
# Get user with all details using include_all
user_full = await client.user.details(user_id=123, include_all=True)
# Or selectively include only what you need
user_with_reports = await client.user.details(user_id=123, include_direct_reports=True)
asyncio.run(main())
Available Methods¶
| Method | Description | Parameters |
|---|---|---|
details() |
Get detailed information about a user | user_id, include_direct_reports, include_positions, include_all |
search() |
Search for users by name or email | term |
list() |
Get all users in the system | include_placeholders |
direct_reports() |
Get direct reports for a user | user_id |
positions() |
Get positions held by a user | user_id |