This commit is contained in:
Oliver
2026-02-15 17:18:32 -03:00
parent 38873facc0
commit a48789ec66
9 changed files with 197 additions and 7 deletions

View File

@@ -131,6 +131,10 @@ class MoveRequest(BaseModel):
source: str
destination: str
class AddKeyRequest(BaseModel):
key: str
uuid: str
# ---------------------- Routes ----------------------
@app.get("/", include_in_schema=False)
@@ -209,7 +213,11 @@ def start_container(request: UUIDRequest):
@app.post("/container/stop", dependencies=[Depends(verify_api_key)])
def stop_container(request: UUIDRequest):
return {"message": run_command([f"{BIN_PATH}/stopContainer", request.UUID])}
try:
return {"message": run_command([f"{BIN_PATH}/stopContainer", request.UUID])}
except HTTPException:
# Command failed, but continue without error to the API
return {"message": "Container stop command executed (may have failed)"}
@app.post("/container/nuke", dependencies=[Depends(verify_api_key)])
@@ -346,6 +354,25 @@ def git_tool(request: CommandRequest):
output = run_command(command)
return {"message": output}
@app.post("/client/addGitKey", dependencies=[Depends(verify_api_key)])
def add_git_key(request: AddKeyRequest):
if not request.key or not request.uuid:
raise HTTPException(status_code=400, detail="Key and uuid are required")
file_path = f"/4server/data/{request.uuid}/git-server/keys/id_rsa.pub"
try:
# Ensure the directory exists
os.makedirs(os.path.dirname(file_path), exist_ok=True)
# Write the key to the file
with open(file_path, "w", encoding="utf-8") as f:
f.write(request.key)
except Exception as e:
raise HTTPException(status_code=500, detail=f"Failed to save key: {str(e)}")
return {"message": f"Key saved for container {request.uuid}", "file": file_path}
@app.get("/client/logs/{uuid}", dependencies=[Depends(verify_api_key)])
async def get_odoo_log_summary(uuid: str):
if not re.fullmatch(r"[0-9a-fA-F\-]+", uuid):