summaryrefslogtreecommitdiff
path: root/opendc/api/v2/topologies
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-06-26 12:27:51 +0200
committerGeorgios Andreadis <info@gandreadis.com>2020-06-26 12:27:51 +0200
commit19bede4fc7f7320bb4eb16c3fe1a211b19ab4714 (patch)
tree6a53629feb7bd8c7a9380d204287f3429ed2f378 /opendc/api/v2/topologies
parent92b94b59ad80329a2c99471edbf5bbdc9af1e525 (diff)
Revamp error responses everywhere
Diffstat (limited to 'opendc/api/v2/topologies')
-rw-r--r--opendc/api/v2/topologies/topologyId/endpoint.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/opendc/api/v2/topologies/topologyId/endpoint.py b/opendc/api/v2/topologies/topologyId/endpoint.py
index 719048c4..3470ad94 100644
--- a/opendc/api/v2/topologies/topologyId/endpoint.py
+++ b/opendc/api/v2/topologies/topologyId/endpoint.py
@@ -6,26 +6,12 @@ from opendc.util.rest import Response
def GET(request):
"""Get this Topology."""
- # Make sure required parameters are there
-
request.check_required_parameters(path={'topologyId': 'int'})
- # Instantiate a Topology from the database
-
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)