from fastapi import APIRouter, Depends from sqlalchemy.orm import Session from app.common.security.auth import verify_project_admin, verify_users from utils.sx_time import sxtimeit from utils.sx_web import web_try import app.crud as crud from app import schemas, get_db router = APIRouter( prefix="/jpt/programme", tags=["programme-可视化编程管理"], ) @router.post("") @web_try() @sxtimeit def create_programme(item: schemas.ProgrammeCreate, token_data: schemas.TokenData = Depends(verify_project_admin), db: Session = Depends(get_db)): return crud.create_programme(db, item) @router.put("/start_jupyter") @web_try() @sxtimeit def start_jupyter(item: schemas.ProgrammeId, token_data: schemas.TokenData = Depends(verify_project_admin), db: Session = Depends(get_db)): return crud.start_jupyter(db, item) @router.put("/stop_jupyter") @web_try() @sxtimeit def stop_jupyter(item: schemas.ProgrammeId, token_data: schemas.TokenData = Depends(verify_project_admin), db: Session = Depends(get_db)): return crud.stop_jupyter(db, item) @router.put("/update_password") @web_try() @sxtimeit def update_jupyter_password(item: schemas.ProgrammeUpdate, token_data: schemas.TokenData = Depends(verify_project_admin), db: Session = Depends(get_db)): return crud.update_jupyter_password(db, item) @router.get("") @web_try() @sxtimeit def get_programme(token_data: schemas.TokenData = Depends(verify_users), db: Session = Depends(get_db)): return crud.get_programme(db)