|
16 | 16 | CreateDownloadSessionInput, |
17 | 17 | CreateUploadSessionInput, |
18 | 18 | CreateVFolderInput, |
| 19 | + CreateVFolderInScopeInput, |
19 | 20 | DeleteFilesInput, |
20 | 21 | DeployVFolderInput, |
21 | 22 | ListFilesInput, |
|
127 | 128 | from ai.backend.manager.services.vfolder.actions.upload_session_v2 import ( |
128 | 129 | CreateUploadSessionV2Action, |
129 | 130 | ) |
| 131 | +from ai.backend.manager.services.vfolder.actions.vfolder_in_project import ( |
| 132 | + CreateVFolderInProjectAction, |
| 133 | +) |
130 | 134 | from ai.backend.manager.services.vfolder.actions.vfolder_v2 import ( |
131 | 135 | DeleteVFolderV2Action, |
132 | 136 | PurgeVFolderV2Action, |
@@ -363,6 +367,32 @@ async def create(self, input: CreateVFolderInput) -> CreateVFolderPayload: |
363 | 367 | result = await self._processors.vfolder.create_vfolder_v2.wait_for_complete(action) |
364 | 368 | return CreateVFolderPayload(vfolder=self._vfolder_data_to_node(result.vfolder)) |
365 | 369 |
|
| 370 | + async def create_in_project( |
| 371 | + self, |
| 372 | + project_id: UUID, |
| 373 | + input: CreateVFolderInScopeInput, |
| 374 | + ) -> CreateVFolderPayload: |
| 375 | + """Create a vfolder owned by the given project. |
| 376 | +
|
| 377 | + Uses ``CreateVFolderInProjectAction`` which is PROJECT-scoped so the |
| 378 | + caller must hold CREATE permission on the project. |
| 379 | + """ |
| 380 | + me = current_user() |
| 381 | + if me is None: |
| 382 | + raise UnreachableError("User context is not available") |
| 383 | + action = CreateVFolderInProjectAction( |
| 384 | + project_id=project_id, |
| 385 | + user_id=me.user_id, |
| 386 | + domain_name=me.domain_name, |
| 387 | + name=input.name, |
| 388 | + host=input.host, |
| 389 | + usage_mode=VFolderUsageMode(input.usage_mode.value), |
| 390 | + permission=VFolderPermission(input.permission.value), |
| 391 | + cloneable=input.cloneable, |
| 392 | + ) |
| 393 | + result = await self._processors.vfolder.create_vfolder_in_project.wait_for_complete(action) |
| 394 | + return CreateVFolderPayload(vfolder=self._vfolder_data_to_node(result.vfolder)) |
| 395 | + |
366 | 396 | async def create_upload_session( |
367 | 397 | self, vfolder_id: UUID, input: CreateUploadSessionInput |
368 | 398 | ) -> CreateUploadSessionPayload: |
|
0 commit comments