diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-06-24 09:13:09 +0200 |
|---|---|---|
| committer | Georgios Andreadis <info@gandreadis.com> | 2020-06-24 09:13:09 +0200 |
| commit | bae760a62fc6a480fbe615dff6a7de03c7fd6d1d (patch) | |
| tree | 06fc47f9922add14a3ac50fcfdfeb3d4fdc00363 /opendc/api/v2/simulations/simulationId | |
| parent | 6fdb3e75dad15523d996e457c216647755b29101 (diff) | |
Add formatter
Diffstat (limited to 'opendc/api/v2/simulations/simulationId')
6 files changed, 75 insertions, 178 deletions
diff --git a/opendc/api/v2/simulations/simulationId/authorizations/endpoint.py b/opendc/api/v2/simulations/simulationId/authorizations/endpoint.py index 1d6b494e..80d45d04 100644 --- a/opendc/api/v2/simulations/simulationId/authorizations/endpoint.py +++ b/opendc/api/v2/simulations/simulationId/authorizations/endpoint.py @@ -10,18 +10,14 @@ def GET(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'simulationId': 'int' - } - ) + request.check_required_parameters(path={'simulationId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Simulation and make sure it exists - simulation = Simulation.from_primary_key((request.params_path['simulationId'],)) + simulation = Simulation.from_primary_key((request.params_path['simulationId'], )) if not simulation.exists(): return Response(404, '{} not found.'.format(simulation)) @@ -37,8 +33,5 @@ def GET(request): # Return the Authorizations - return Response( - 200, - 'Successfully retrieved Authorizations for {}.'.format(simulation), - [x.to_JSON() for x in authorizations] - ) + return Response(200, 'Successfully retrieved Authorizations for {}.'.format(simulation), + [x.to_JSON() for x in authorizations]) diff --git a/opendc/api/v2/simulations/simulationId/authorizations/userId/endpoint.py b/opendc/api/v2/simulations/simulationId/authorizations/userId/endpoint.py index 46458ffc..d417936f 100644 --- a/opendc/api/v2/simulations/simulationId/authorizations/userId/endpoint.py +++ b/opendc/api/v2/simulations/simulationId/authorizations/userId/endpoint.py @@ -11,22 +11,14 @@ def DELETE(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'simulationId': 'int', - 'userId': 'int' - } - ) + request.check_required_parameters(path={'simulationId': 'int', 'userId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate an Authorization - authorization = Authorization.from_primary_key(( - request.params_path['userId'], - request.params_path['simulationId'] - )) + authorization = Authorization.from_primary_key((request.params_path['userId'], request.params_path['simulationId'])) # Make sure this Authorization exists in the database @@ -42,11 +34,7 @@ def DELETE(request): authorization.delete() - return Response( - 200, - 'Successfully deleted {}.'.format(authorization), - authorization.to_JSON() - ) + return Response(200, 'Successfully deleted {}.'.format(authorization), authorization.to_JSON()) def GET(request): @@ -55,22 +43,14 @@ def GET(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'simulationId': 'int', - 'userId': 'int' - } - ) + request.check_required_parameters(path={'simulationId': 'int', 'userId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate an Authorization - authorization = Authorization.from_primary_key(( - request.params_path['userId'], - request.params_path['simulationId'] - )) + authorization = Authorization.from_primary_key((request.params_path['userId'], request.params_path['simulationId'])) # Make sure this Authorization exists in the database @@ -83,11 +63,7 @@ def GET(request): # Return this Authorization - return Response( - 200, - 'Successfully retrieved {}'.format(authorization), - authorization.to_JSON() - ) + return Response(200, 'Successfully retrieved {}'.format(authorization), authorization.to_JSON()) def POST(request): @@ -96,17 +72,13 @@ def POST(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'userId': 'int', - 'simulationId': 'int' - }, - body={ - 'authorization': { - 'authorizationLevel': 'string' - } - } - ) + request.check_required_parameters(path={ + 'userId': 'int', + 'simulationId': 'int' + }, + body={'authorization': { + 'authorizationLevel': 'string' + }}) except exceptions.ParameterError as e: return Response(400, e.message) @@ -114,18 +86,21 @@ def POST(request): # Instantiate an Authorization authorization = Authorization.from_JSON({ - 'userId': request.params_path['userId'], - 'simulationId': request.params_path['simulationId'], - 'authorizationLevel': request.params_body['authorization']['authorizationLevel'] + 'userId': + request.params_path['userId'], + 'simulationId': + request.params_path['simulationId'], + 'authorizationLevel': + request.params_body['authorization']['authorizationLevel'] }) # Make sure the Simulation and User exist - user = User.from_primary_key((authorization.user_id,)) + user = User.from_primary_key((authorization.user_id, )) if not user.exists(): return Response(404, '{} not found.'.format(user)) - simulation = Simulation.from_primary_key((authorization.simulation_id,)) + simulation = Simulation.from_primary_key((authorization.simulation_id, )) if not simulation.exists(): return Response(404, '{} not found.'.format(simulation)) @@ -149,11 +124,7 @@ def POST(request): # Return this Authorization - return Response( - 200, - 'Successfully added {}'.format(authorization), - authorization.to_JSON() - ) + return Response(200, 'Successfully added {}'.format(authorization), authorization.to_JSON()) def PUT(request): @@ -162,17 +133,13 @@ def PUT(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'simulationId': 'int', - 'userId': 'int' - }, - body={ - 'authorization': { - 'authorizationLevel': 'string' - } - } - ) + request.check_required_parameters(path={ + 'simulationId': 'int', + 'userId': 'int' + }, + body={'authorization': { + 'authorizationLevel': 'string' + }}) except exceptions.ParameterError as e: return Response(400, e.message) @@ -180,9 +147,12 @@ def PUT(request): # Instantiate and Authorization authorization = Authorization.from_JSON({ - 'userId': request.params_path['userId'], - 'simulationId': request.params_path['simulationId'], - 'authorizationLevel': request.params_body['authorization']['authorizationLevel'] + 'userId': + request.params_path['userId'], + 'simulationId': + request.params_path['simulationId'], + 'authorizationLevel': + request.params_body['authorization']['authorizationLevel'] }) # Make sure this Authorization exists @@ -205,8 +175,4 @@ def PUT(request): # Return this Authorization - return Response( - 200, - 'Successfully updated {}.'.format(authorization), - authorization.to_JSON() - ) + return Response(200, 'Successfully updated {}.'.format(authorization), authorization.to_JSON()) diff --git a/opendc/api/v2/simulations/simulationId/datacenters/endpoint.py b/opendc/api/v2/simulations/simulationId/datacenters/endpoint.py index e28402e4..88c5fe21 100644 --- a/opendc/api/v2/simulations/simulationId/datacenters/endpoint.py +++ b/opendc/api/v2/simulations/simulationId/datacenters/endpoint.py @@ -10,17 +10,11 @@ def POST(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'simulationId': 'int' - }, - body={ - 'datacenter': { - 'starred': 'int', - 'simulationId': 'int' - } - } - ) + request.check_required_parameters(path={'simulationId': 'int'}, + body={'datacenter': { + 'starred': 'int', + 'simulationId': 'int' + }}) except exceptions.ParameterError as e: return Response(400, e.message) @@ -32,7 +26,7 @@ def POST(request): # Instantiate a Simulation from the database - simulation = Simulation.from_primary_key((request.params_path['simulationId'],)) + simulation = Simulation.from_primary_key((request.params_path['simulationId'], )) # Make sure this Simulation exists @@ -54,8 +48,4 @@ def POST(request): datacenter.read() - return Response( - 200, - 'Successfully added {}.'.format(datacenter), - datacenter.to_JSON() - ) + return Response(200, 'Successfully added {}.'.format(datacenter), datacenter.to_JSON()) diff --git a/opendc/api/v2/simulations/simulationId/endpoint.py b/opendc/api/v2/simulations/simulationId/endpoint.py index 5e595740..a6fc0a02 100644 --- a/opendc/api/v2/simulations/simulationId/endpoint.py +++ b/opendc/api/v2/simulations/simulationId/endpoint.py @@ -11,18 +11,14 @@ def DELETE(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'simulationId': 'int' - } - ) + request.check_required_parameters(path={'simulationId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Simulation and make sure it exists - simulation = Simulation.from_primary_key((request.params_path['simulationId'],)) + simulation = Simulation.from_primary_key((request.params_path['simulationId'], )) if not simulation.exists(): return Response(404, '{} not found.'.format(simulation)) @@ -38,11 +34,7 @@ def DELETE(request): # Return this Simulation - return Response( - 200, - 'Successfully deleted {}.'.format(simulation), - simulation.to_JSON() - ) + return Response(200, 'Successfully deleted {}.'.format(simulation), simulation.to_JSON()) def GET(request): @@ -51,18 +43,14 @@ def GET(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'simulationId': 'int' - } - ) + request.check_required_parameters(path={'simulationId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Simulation and make sure it exists - simulation = Simulation.from_primary_key((request.params_path['simulationId'],)) + simulation = Simulation.from_primary_key((request.params_path['simulationId'], )) if not simulation.exists(): return Response(404, '{} not found.'.format(simulation)) @@ -76,11 +64,7 @@ def GET(request): simulation.read() - return Response( - 200, - 'Successfully retrieved {}'.format(simulation), - simulation.to_JSON() - ) + return Response(200, 'Successfully retrieved {}'.format(simulation), simulation.to_JSON()) def PUT(request): @@ -89,23 +73,14 @@ def PUT(request): # Make sure required parameters are there try: - request.check_required_parameters( - body={ - 'simulation': { - 'name': 'name' - } - }, - path={ - 'simulationId': 'int' - } - ) + request.check_required_parameters(body={'simulation': {'name': 'name'}}, path={'simulationId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Simulation and make sure it exists - simulation = Simulation.from_primary_key((request.params_path['simulationId'],)) + simulation = Simulation.from_primary_key((request.params_path['simulationId'], )) if not simulation.exists(): return Response(404, '{} not found.'.format(simulation)) @@ -126,8 +101,4 @@ def PUT(request): # Return this Simulation - return Response( - 200, - 'Successfully updated {}.'.format(simulation), - simulation.to_JSON() - ) + return Response(200, 'Successfully updated {}.'.format(simulation), simulation.to_JSON()) diff --git a/opendc/api/v2/simulations/simulationId/experiments/endpoint.py b/opendc/api/v2/simulations/simulationId/experiments/endpoint.py index 86fadb24..68465bdc 100644 --- a/opendc/api/v2/simulations/simulationId/experiments/endpoint.py +++ b/opendc/api/v2/simulations/simulationId/experiments/endpoint.py @@ -10,18 +10,14 @@ def GET(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'simulationId': 'int' - } - ) + request.check_required_parameters(path={'simulationId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Simulation from the database - simulation = Simulation.from_primary_key((request.params_path['simulationId'],)) + simulation = Simulation.from_primary_key((request.params_path['simulationId'], )) # Make sure this Simulation exists @@ -37,11 +33,8 @@ def GET(request): experiments = Experiment.query('simulation_id', request.params_path['simulationId']) - return Response( - 200, - 'Successfully retrieved Experiments for {}.'.format(simulation), - [x.to_JSON() for x in experiments] - ) + return Response(200, 'Successfully retrieved Experiments for {}.'.format(simulation), + [x.to_JSON() for x in experiments]) def POST(request): @@ -50,20 +43,16 @@ def POST(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'simulationId': 'int' - }, - body={ - 'experiment': { - 'simulationId': 'int', - 'pathId': 'int', - 'traceId': 'int', - 'schedulerName': 'string', - 'name': 'string' - } - } - ) + request.check_required_parameters(path={'simulationId': 'int'}, + body={ + 'experiment': { + 'simulationId': 'int', + 'pathId': 'int', + 'traceId': 'int', + 'schedulerName': 'string', + 'name': 'string' + } + }) except exceptions.ParameterError as e: return Response(400, e.message) @@ -75,7 +64,7 @@ def POST(request): # Instantiate a Simulation from the database - simulation = Simulation.from_primary_key((request.params_path['simulationId'],)) + simulation = Simulation.from_primary_key((request.params_path['simulationId'], )) # Make sure this Simulation exists @@ -105,8 +94,4 @@ def POST(request): experiment.read() - return Response( - 200, - 'Successfully added {}.'.format(experiment), - experiment.to_JSON() - ) + return Response(200, 'Successfully added {}.'.format(experiment), experiment.to_JSON()) diff --git a/opendc/api/v2/simulations/simulationId/paths/endpoint.py b/opendc/api/v2/simulations/simulationId/paths/endpoint.py index e4aab427..85a373b2 100644 --- a/opendc/api/v2/simulations/simulationId/paths/endpoint.py +++ b/opendc/api/v2/simulations/simulationId/paths/endpoint.py @@ -10,17 +10,13 @@ def GET(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'simulationId': 'int' - } - ) + request.check_required_parameters(path={'simulationId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Simulation from the database - simulation = Simulation.from_primary_key((request.params_path['simulationId'],)) + simulation = Simulation.from_primary_key((request.params_path['simulationId'], )) # Make sure this Simulation exists @@ -36,8 +32,4 @@ def GET(request): paths = Path.query('simulation_id', request.params_path['simulationId']) - return Response( - 200, - 'Successfully retrieved Paths for {}.'.format(simulation), - [x.to_JSON() for x in paths] - ) + return Response(200, 'Successfully retrieved Paths for {}.'.format(simulation), [x.to_JSON() for x in paths]) |
