mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Adding host stats to the API
This commit is contained in:
parent
083e7b2f3f
commit
99ef2db016
@ -69,6 +69,7 @@ from app.classes.web.routes.api.crafty.config.index import (
|
|||||||
from app.classes.web.routes.api.crafty.config.server_dir import (
|
from app.classes.web.routes.api.crafty.config.server_dir import (
|
||||||
ApiCraftyConfigServerDirHandler,
|
ApiCraftyConfigServerDirHandler,
|
||||||
)
|
)
|
||||||
|
from app.classes.web.routes.api.crafty.stats.stats import ApiCraftyHostStatsHandler
|
||||||
from app.classes.web.routes.api.crafty.clogs.index import ApiCraftyLogIndexHandler
|
from app.classes.web.routes.api.crafty.clogs.index import ApiCraftyLogIndexHandler
|
||||||
from app.classes.web.routes.api.crafty.imports.index import ApiImportFilesIndexHandler
|
from app.classes.web.routes.api.crafty.imports.index import ApiImportFilesIndexHandler
|
||||||
from app.classes.web.routes.api.crafty.exe_cache import ApiCraftyExeCacheIndexHandler
|
from app.classes.web.routes.api.crafty.exe_cache import ApiCraftyExeCacheIndexHandler
|
||||||
@ -107,6 +108,11 @@ def api_handlers(handler_args):
|
|||||||
ApiCraftyConfigServerDirHandler,
|
ApiCraftyConfigServerDirHandler,
|
||||||
handler_args,
|
handler_args,
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
r"/api/v2/crafty/stats/?",
|
||||||
|
ApiCraftyHostStatsHandler,
|
||||||
|
handler_args,
|
||||||
|
),
|
||||||
(
|
(
|
||||||
r"/api/v2/crafty/logs/([a-z0-9_]+)/?",
|
r"/api/v2/crafty/logs/([a-z0-9_]+)/?",
|
||||||
ApiCraftyLogIndexHandler,
|
ApiCraftyLogIndexHandler,
|
||||||
|
21
app/classes/web/routes/api/crafty/stats/stats.py
Normal file
21
app/classes/web/routes/api/crafty/stats/stats.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import logging
|
||||||
|
from app.classes.web.base_api_handler import BaseApiHandler
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ApiCraftyHostStatsHandler(BaseApiHandler):
|
||||||
|
def get(self):
|
||||||
|
auth_data = self.authenticate_user()
|
||||||
|
if not auth_data:
|
||||||
|
return
|
||||||
|
|
||||||
|
latest = self.controller.management.get_latest_hosts_stats()
|
||||||
|
|
||||||
|
self.finish_json(
|
||||||
|
200,
|
||||||
|
{
|
||||||
|
"status": "ok",
|
||||||
|
"data": latest,
|
||||||
|
},
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user