dellweb3's picture
Deploy verified conversational workbench and isolated Java application previews
caf8059 verified
Raw History Blame Contribute Delete
2.04 kB
from fastapi import APIRouter, Depends, Header
from pydantic import Field
from src.modules.skill.domain.models import Contract, Identifier
class StartRun(Contract):
release_ref: str = Field(min_length=1, max_length=110)
project_id: Identifier
source_digest: str = Field(pattern=r'^[a-f0-9]{64}$')
requirement: str = Field(min_length=1, max_length=6000)
query: str = Field(min_length=1, max_length=300)
class ApproveRun(Contract):
expected_digest: str = Field(pattern=r'^[a-f0-9]{64}$')
def build_router(runtime, principal):
router = APIRouter(prefix='/api/v1/coding/runs', tags=['ZKCoding Runtime'])
@router.get('/readiness')
def readiness(actor=Depends(principal)):
return runtime.readiness(actor)
@router.post('', status_code=201)
def create(data: StartRun, actor=Depends(principal), key: str = Header(alias='Idempotency-Key', min_length=8, max_length=128)):
return runtime.create(actor, data.model_dump(), key)
@router.get('/{run_id}')
def get(run_id: str, actor=Depends(principal)):
return runtime.get(actor, run_id)
@router.post('/{run_id}/advance')
def advance(run_id: str, actor=Depends(principal)):
return runtime.advance(actor, run_id)
@router.post('/{run_id}/approvals')
def approve(run_id: str, data: ApproveRun, actor=Depends(principal)):
return runtime.approve(actor, run_id, data.expected_digest)
@router.post('/{run_id}/cancel')
def cancel(run_id: str, actor=Depends(principal)):
return runtime.cancel(actor, run_id)
@router.post('/{run_id}/repair')
def repair(run_id: str, actor=Depends(principal)):
return runtime.repair(actor, run_id)
@router.post('/{run_id}/recover')
def recover(run_id: str, actor=Depends(principal)):
return runtime.recover(actor, run_id)
@router.post('/{run_id}/validation-evidence')
def validation_evidence(run_id: str, actor=Depends(principal)):
return runtime.validation_evidence(actor, run_id)
return router