1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Basic project stats.

This commit is contained in:
grossmj 2018-03-15 15:21:29 +07:00
parent 90ce6093d8
commit fb3bcf3b8f
2 changed files with 24 additions and 0 deletions

View File

@ -1013,6 +1013,15 @@ class Project:
raise e
return new_node
def stats(self):
return {
"nodes": len(self._nodes),
"links": len(self._links),
"drawings": len(self._drawings),
"snapshots": len(self._snapshots)
}
def __json__(self):
return {
"name": self._name,

View File

@ -92,6 +92,21 @@ class ProjectHandler:
project = controller.get_project(request.match_info["project_id"])
response.json(project)
@Route.get(
r"/projects/{project_id}/stats",
description="Get a project statistics",
parameters={
"project_id": "Project UUID",
},
status_codes={
200: "Project statistics returned",
404: "The project doesn't exist"
})
def get(request, response):
controller = Controller.instance()
project = controller.get_project(request.match_info["project_id"])
response.json(project.stats())
@Route.put(
r"/projects/{project_id}",
status_codes={