mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-30 09:38:53 +00:00
Basic project stats.
This commit is contained in:
parent
90ce6093d8
commit
fb3bcf3b8f
@ -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,
|
||||
|
@ -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={
|
||||
|
Loading…
Reference in New Issue
Block a user