Add bulk grant permission API endpoint
New Features: - BulkGrantPermission model: Grant same permission to multiple users - BulkGrantResult model: Detailed success/failure results - POST /api/v1/admin/permissions/bulk-grant endpoint This simplifies the admin workflow for granting the same account permission to multiple users at once (e.g., onboarding a team). The endpoint validates the account exists and is active, then grants the permission to each user, collecting successes and failures to return a detailed result. Related: UI-IMPROVEMENTS-PLAN.md Phase 1
This commit is contained in:
parent
c35944d51f
commit
ed1e6509ee
2 changed files with 74 additions and 0 deletions
18
models.py
18
models.py
|
|
@ -315,6 +315,24 @@ class CreateAccountPermission(BaseModel):
|
|||
notes: Optional[str] = None
|
||||
|
||||
|
||||
class BulkGrantPermission(BaseModel):
|
||||
"""Bulk grant same permission to multiple users"""
|
||||
user_ids: list[str] # List of user IDs to grant permission to
|
||||
account_id: str # Account to grant permission on
|
||||
permission_type: PermissionType # Type of permission to grant
|
||||
expires_at: Optional[datetime] = None # Optional expiration
|
||||
notes: Optional[str] = None # Notes for all permissions
|
||||
|
||||
|
||||
class BulkGrantResult(BaseModel):
|
||||
"""Result of bulk grant operation"""
|
||||
granted: list[AccountPermission] # Successfully granted permissions
|
||||
failed: list[dict] # Failed grants with errors
|
||||
total: int # Total attempted
|
||||
success_count: int # Number of successful grants
|
||||
failure_count: int # Number of failed grants
|
||||
|
||||
|
||||
class AccountWithPermissions(BaseModel):
|
||||
"""Account with user-specific permission metadata"""
|
||||
id: str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue