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.
-
all
–Retrieve all users in the system.
Functions¶
details
¶
details(user_id: int | None = None, direct_reports: bool = False, positions: bool = False, 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)
-
direct_reports
(bool
, default:False
) –Whether to include direct reports (default: False)
-
positions
(bool
, default:False
) –Whether to include positions (default: False)
-
all
(bool
, default:False
) –Whether to include both direct reports and positions (default: False)
Returns:
-
UserDetails
–A UserDetails model containing user details
direct_reports
¶
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
¶
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 for users based on a search term.
Parameters:
-
term
(str
) –The search term
Returns:
-
list[UserSearchResult]
–A list of UserSearchResult models containing search results
all
¶
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.
Initialize the async user operations.
Parameters:
-
client
(AsyncClient
) –The async HTTP client to use for API requests.
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.
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.all()
# Get user with direct reports and positions
user_full = client.user.details(
user_id=123,
include_direct_reports=True,
include_positions=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.all()
# Get user with direct reports and positions
user_full = await client.user.details(
user_id=123,
include_direct_reports=True,
include_positions=True
)
asyncio.run(main())
Available Methods¶
Method | Description | Parameters |
---|---|---|
details() |
Get detailed information about a user | user_id , include_direct_reports , include_positions , all |
search() |
Search for users by name or email | term |
all() |
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 |