diff options
Diffstat (limited to 'opendc/api/v2/simulations/simulationId/topologies/endpoint.py')
| -rw-r--r-- | opendc/api/v2/simulations/simulationId/topologies/endpoint.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/opendc/api/v2/simulations/simulationId/topologies/endpoint.py b/opendc/api/v2/simulations/simulationId/topologies/endpoint.py index ee60e5b4..ab7b7006 100644 --- a/opendc/api/v2/simulations/simulationId/topologies/endpoint.py +++ b/opendc/api/v2/simulations/simulationId/topologies/endpoint.py @@ -10,21 +10,12 @@ from opendc.util.database import Database def POST(request): """Add a new Topology to the specified simulation and return it""" - # Make sure required parameters are there - - try: - request.check_required_parameters(path={'simulationId': 'string'}, body={'topology': {'name': 'string'}}) - except exceptions.ParameterError as e: - return Response(400, str(e)) + request.check_required_parameters(path={'simulationId': 'string'}, body={'topology': {'name': 'string'}}) simulation = Simulation.from_id(request.params_path['simulationId']) - validation_error = simulation.validate() - if validation_error is not None: - return validation_error - access_error = simulation.validate_user_access(request.google_id, False) - if access_error is not None: - return access_error + simulation.check_exists() + simulation.check_user_access(request.google_id, True) topology = Topology({'name': request.params_body['topology']['name']}) topology.set_property('datetimeCreated', Database.datetime_to_string(datetime.now())) @@ -34,6 +25,5 @@ def POST(request): simulation.obj['topologyIds'].append(topology.obj['_id']) simulation.set_property('datetimeLastEdited', Database.datetime_to_string(datetime.now())) simulation.update() - # Instantiate the user from the request, and add this topology object to their authorizations return Response(200, 'Successfully inserted topology.', topology.obj) |
