|
8 | 8 | BashObservation, |
9 | 9 | CloseBashSessionResponse, |
10 | 10 | CommandResponse, |
| 11 | + CommitStatusResponse, |
11 | 12 | CreateBashSessionResponse, |
12 | 13 | ReadFileResponse, |
13 | 14 | ResponseStatus, |
14 | 15 | RockResponse, |
| 16 | + SandboxResponse, |
15 | 17 | UploadResponse, |
16 | 18 | WriteFileResponse, |
17 | 19 | ) |
18 | 20 | from rock.admin.proto.request import ( |
19 | 21 | BatchSandboxStatusRequest, |
| 22 | + CommitRequest, |
20 | 23 | SandboxBashAction, |
21 | 24 | SandboxCloseBashSessionRequest, |
22 | 25 | SandboxCommand, |
|
28 | 31 | from rock.admin.proto.response import BatchSandboxStatusResponse, SandboxListResponse, SandboxStatusResponse |
29 | 32 | from rock.common.exception import handle_exceptions |
30 | 33 | from rock.common.port_validation import validate_port_forward_port |
31 | | -from rock.common.validation import NonBlankStr |
| 34 | +from rock.common.validation import NonBlankStr, SandboxContainerName |
32 | 35 | from rock.logger import init_logger |
33 | 36 | from rock.sandbox.service.sandbox_proxy_service import SandboxProxyService |
34 | 37 | from rock.sdk.common.exceptions import BadRequestRockError |
@@ -115,6 +118,18 @@ async def execute(command: SandboxCommand) -> RockResponse[CommandResponse]: |
115 | 118 | return RockResponse(result=await sandbox_proxy_service.execute(command)) |
116 | 119 |
|
117 | 120 |
|
| 121 | +@sandbox_proxy_router.post("/commit") |
| 122 | +@handle_exceptions(error_message="commit sandbox failed") |
| 123 | +async def commit(request: CommitRequest) -> RockResponse[CommitStatusResponse | SandboxResponse]: |
| 124 | + return RockResponse(result=await sandbox_proxy_service.commit(request)) |
| 125 | + |
| 126 | + |
| 127 | +@sandbox_proxy_router.get("/commit/{sandbox_id}") |
| 128 | +@handle_exceptions(error_message="get commit status failed") |
| 129 | +async def get_commit_status(sandbox_id: SandboxContainerName) -> RockResponse[CommitStatusResponse | SandboxResponse]: |
| 130 | + return RockResponse(result=await sandbox_proxy_service.get_commit_status(sandbox_id)) |
| 131 | + |
| 132 | + |
118 | 133 | @sandbox_proxy_router.post("/create_session") |
119 | 134 | @handle_exceptions(error_message="create session failed") |
120 | 135 | async def create_session(request: SandboxCreateBashSessionRequest) -> RockResponse[CreateBashSessionResponse]: |
|
0 commit comments