This commit is contained in:
ilyastar9999
2025-12-04 14:41:44 +03:00
parent 42aecacced
commit 40bddd1449
2 changed files with 97 additions and 2 deletions

View File

@@ -138,6 +138,33 @@ def api_service_action(service_id):
finally:
loop.close()
@app.route('/api/services/<int:service_id>/update', methods=['PATCH'])
@login_required
def api_service_update(service_id):
"""Update service (e.g., alias)"""
updates = request.json
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
async def patch_call():
headers = {"Authorization": f"Bearer {SECRET_TOKEN}"}
async with aiohttp.ClientSession() as session:
async with session.patch(
f"{CONTROLLER_API}/services/{service_id}",
headers=headers,
json=updates
) as resp:
if resp.status == 200:
return await resp.json()
return {"error": f"Status {resp.status}"}
data = loop.run_until_complete(patch_call())
return jsonify(data)
finally:
loop.close()
@app.route('/api/services/<int:service_id>/logs')
@login_required
def api_service_logs(service_id):