diff options
| author | jc0b <j@jc0b.computer> | 2020-07-07 16:55:22 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:47:51 +0200 |
| commit | 223e916997eb641a1662110b6de630a4cdfdf479 (patch) | |
| tree | 90ca4364461f676db45f25e03d8f22fc32f9fdd8 /web-server/opendc/api/v2/simulations/simulationId/endpoint.py | |
| parent | 9ff1e3c6bae253372a468dbdc9b8369ab8dd2c6f (diff) | |
| parent | b810c4413079bf5aeb5374f1cd20e151a83530d0 (diff) | |
Merge branch 'feature/mongodb-migration' of github.com:atlarge-research/opendc-dev into feature/mongodb-migration
Diffstat (limited to 'web-server/opendc/api/v2/simulations/simulationId/endpoint.py')
| -rw-r--r-- | web-server/opendc/api/v2/simulations/simulationId/endpoint.py | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/web-server/opendc/api/v2/simulations/simulationId/endpoint.py b/web-server/opendc/api/v2/simulations/simulationId/endpoint.py deleted file mode 100644 index 0cee3e9c..00000000 --- a/web-server/opendc/api/v2/simulations/simulationId/endpoint.py +++ /dev/null @@ -1,66 +0,0 @@ -from datetime import datetime - -from opendc.models.experiment import Experiment -from opendc.models.simulation import Simulation -from opendc.models.topology import Topology -from opendc.models.user import User -from opendc.util.database import Database -from opendc.util.rest import Response - - -def GET(request): - """Get this Simulation.""" - - request.check_required_parameters(path={'simulationId': 'string'}) - - simulation = Simulation.from_id(request.params_path['simulationId']) - - simulation.check_exists() - simulation.check_user_access(request.google_id, False) - - return Response(200, 'Successfully retrieved simulation', simulation.obj) - - -def PUT(request): - """Update a simulation's name.""" - - request.check_required_parameters(body={'simulation': {'name': 'name'}}, path={'simulationId': 'string'}) - - simulation = Simulation.from_id(request.params_path['simulationId']) - - simulation.check_exists() - simulation.check_user_access(request.google_id, True) - - simulation.set_property('name', request.params_body['simulation']['name']) - simulation.set_property('datetime_last_edited', Database.datetime_to_string(datetime.now())) - simulation.update() - - return Response(200, 'Successfully updated simulation.', simulation.obj) - - -def DELETE(request): - """Delete this Simulation.""" - - request.check_required_parameters(path={'simulationId': 'string'}) - - simulation = Simulation.from_id(request.params_path['simulationId']) - - simulation.check_exists() - simulation.check_user_access(request.google_id, True) - - for topology_id in simulation.obj['topologyIds']: - topology = Topology.from_id(topology_id) - topology.delete() - - for experiment_id in simulation.obj['experimentIds']: - experiment = Experiment.from_id(experiment_id) - experiment.delete() - - user = User.from_google_id(request.google_id) - user.obj['authorizations'] = list( - filter(lambda x: str(x['simulationId']) != request.params_path['simulationId'], user.obj['authorizations'])) - user.update() - - old_object = simulation.delete() - - return Response(200, 'Successfully deleted simulation.', old_object) |
