ads
This commit is contained in:
27
web/app.py
27
web/app.py
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user