main
py 35 lines 1.25 KB
Raw
1 from helpers.api import ApiHandler, Request, Response
2
3 from helpers import runtime
4 from helpers import self_update
5
6
7 class SelfUpdateSchedule(ApiHandler):
8 async def process(self, input: dict, request: Request) -> dict | Response:
9 if not runtime.is_dockerized():
10 return {
11 "success": False,
12 "error": "Self-update is only available in dockerized installations.",
13 }
14
15 try:
16 pending = self_update.schedule_update(
17 branch=str(input.get("branch", "")),
18 tag=str(input.get("tag", "")),
19 backup_usr=bool(input.get("backup_usr", True)),
20 backup_path=str(input.get("backup_path", "")),
21 backup_name=str(input.get("backup_name", "")),
22 backup_conflict_policy=str(input.get("backup_conflict_policy", "rename")),
23 )
24 return {
25 "success": True,
26 "pending": pending,
27 "message": (
28 "Self-update was scheduled. Restart Agent Zero to apply the requested branch/tag."
29 ),
30 }
31 except Exception as e:
32 return {
33 "success": False,
34 "error": str(e),
35 }