summaryrefslogtreecommitdiff
path: root/opendc/api/v2/topologies
diff options
context:
space:
mode:
authorjc0b <j@jc0b.computer>2020-06-26 12:30:16 +0200
committerjc0b <j@jc0b.computer>2020-06-26 12:30:16 +0200
commitf1017676a150de60b13ff2b33ca83079d87aebfc (patch)
tree15c84fd426f65d54c70d405b9a2fc82b579c2812 /opendc/api/v2/topologies
parent6f51282cd7c3945ddd0fac68407a7a7be57aa2ba (diff)
parent19bede4fc7f7320bb4eb16c3fe1a211b19ab4714 (diff)
Merged refactoring changes with upstream
Diffstat (limited to 'opendc/api/v2/topologies')
-rw-r--r--opendc/api/v2/topologies/topologyId/endpoint.py23
1 files changed, 3 insertions, 20 deletions
diff --git a/opendc/api/v2/topologies/topologyId/endpoint.py b/opendc/api/v2/topologies/topologyId/endpoint.py
index ef541daa..3470ad94 100644
--- a/opendc/api/v2/topologies/topologyId/endpoint.py
+++ b/opendc/api/v2/topologies/topologyId/endpoint.py
@@ -6,29 +6,12 @@ from opendc.util.rest import Response
def GET(request):
"""Get this Topology."""
- # Make sure required parameters are there
-
- try:
- request.check_required_parameters(path={'topologyId': 'int'})
- except exceptions.ParameterError as e:
- return Response(400, str(e))
-
- # Instantiate a Topology from the database
+ request.check_required_parameters(path={'topologyId': 'int'})
topology = Topology.from_id(request.params_path['topologyId'])
- # Make sure this Topology exists
-
- validation_error = topology.validate()
- if validation_error is not None:
- return validation_error
-
- # Make sure this user is authorized to view this Topology
-
- access_error = topology.validate_user_access(request.google_id, False)
- if access_error is not None:
- return access_error
+ topology.check_exists()
- # Return this Topology
+ topology.check_user_access(request.google_id, False)
return Response(200, 'Successfully retrieved topology.', topology.obj)