summaryrefslogtreecommitdiff
path: root/web-server/opendc/api/v2/topologies/topologyId/endpoint.py
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-07-14 21:10:56 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:48:04 +0200
commit02997b2522b9c66072b16f1425c02e81e0085e3c (patch)
treeeb8cb533e3ef37a11598e86736b063293f8b0e2b /web-server/opendc/api/v2/topologies/topologyId/endpoint.py
parent1a4776636bf6b585d4a19a6721d9d57b02c88ca4 (diff)
Rename web-server to API
This change renames the web-server component to API in order to be more descriptive of its role. The OpenDC API bridges between the frontend on one side and the database and simulator on the other side.
Diffstat (limited to 'web-server/opendc/api/v2/topologies/topologyId/endpoint.py')
-rw-r--r--web-server/opendc/api/v2/topologies/topologyId/endpoint.py56
1 files changed, 0 insertions, 56 deletions
diff --git a/web-server/opendc/api/v2/topologies/topologyId/endpoint.py b/web-server/opendc/api/v2/topologies/topologyId/endpoint.py
deleted file mode 100644
index 512b050a..00000000
--- a/web-server/opendc/api/v2/topologies/topologyId/endpoint.py
+++ /dev/null
@@ -1,56 +0,0 @@
-from datetime import datetime
-
-from opendc.util.database import Database
-from opendc.models.project import Project
-from opendc.models.topology import Topology
-from opendc.util.rest import Response
-
-
-def GET(request):
- """Get this Topology."""
-
- request.check_required_parameters(path={'topologyId': 'string'})
-
- topology = Topology.from_id(request.params_path['topologyId'])
-
- topology.check_exists()
- topology.check_user_access(request.google_id, False)
-
- return Response(200, 'Successfully retrieved topology.', topology.obj)
-
-
-def PUT(request):
- """Update this topology"""
- request.check_required_parameters(path={'topologyId': 'string'}, body={'topology': {'name': 'string', 'rooms': {}}})
- topology = Topology.from_id(request.params_path['topologyId'])
-
- topology.check_exists()
- topology.check_user_access(request.google_id, True)
-
- topology.set_property('name', request.params_body['topology']['name'])
- topology.set_property('rooms', request.params_body['topology']['rooms'])
- topology.set_property('datetimeLastEdited', Database.datetime_to_string(datetime.now()))
-
- topology.update()
-
- return Response(200, 'Successfully updated topology.', topology.obj)
-
-
-def DELETE(request):
- """Delete this topology"""
- request.check_required_parameters(path={'topologyId': 'string'})
-
- topology = Topology.from_id(request.params_path['topologyId'])
-
- topology.check_exists()
- topology.check_user_access(request.google_id, True)
-
- project = Project.from_id(topology.obj['projectId'])
- project.check_exists()
- if request.params_path['topologyId'] in project.obj['topologyIds']:
- project.obj['topologyIds'].remove(request.params_path['topologyId'])
- project.update()
-
- old_object = topology.delete()
-
- return Response(200, 'Successfully deleted topology.', old_object)