Extend VFolderHandler.create_vfolder() to support owner specification
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Objective
Extend VFolderHandler.create_vfolder() API to accept optional `owner_uuid` parameter, allowing Superadmins to create vfolders on behalf of other users.
## Scope
This task focuses on extending the **new VFolderHandler API** (`src/ai/backend/manager/api/vfolders/handlers.py`) only. Legacy vfolder APIs should not be modified.
## Implementation Tasks
1. **Update Request DTO**
- Add optional `owner_uuid` field to `VFolderCreateReq`
- Location: `src/ai/backend/common/dto/manager/request.py`
1. **Update Data Transfer Object**
- Add `owner_uuid` field to `VFolderItemToCreate`
- Update `from_request()` method to handle owner_uuid
- Location: `src/ai/backend/manager/data/vfolder/dto.py`
1. **Update VFolder Action**
- Modify `CreateVFolderAction` to distinguish creator from owner
- Resolve TODO comment: "Distinguish between creator and owner"
- Add `owner_uuid` field (separate from `user_uuid` for creator)
- Location: `src/ai/backend/manager/services/vfolder/actions/base.py`
1. **Update VFolder Service**
- Handle `owner_uuid` parameter in vfolder creation logic
- Add Superadmin authorization check when owner differs from creator
- Use owner_uuid for vfolder ownership instead of creator's uuid
- Location: `src/ai/backend/manager/services/vfolder/services/vfolder.py`
1. **Service Protocol Update**
- Update `VFolderServiceProtocol` if needed
- Location: `src/ai/backend/manager/api/vfolders/handlers.py`
## Authorization Requirements
- Only Superadmin can specify `owner_uuid` different from their own uuid
- Non-superadmin users attempting to specify different owner should get authorization error
- When `owner_uuid` is not specified, use creator's uuid (backward compatible)
## Acceptance Criteria
- VFolderHandler.create_vfolder() accepts optional `owner_uuid` in request body
- Superadmin can successfully create vfolder with specified owner
- Created vfolder is owned by specified user, not the creator
- Non-superadmin gets authorization error when trying to specify different owner
- Backward compatible: requests without `owner_uuid` work as before
- Creator and owner are tracked separately for audit
## Technical Notes
- VFolderHandler is currently not used in production (tests are commented out)
- This provides flexibility to modify the API without breaking existing functionality
- Focus on clean implementation following service/repository pattern
JIRA Issue: BA-3574
Contributor guide
Assessment
This issue has not been assessed yet.