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/tiles/tileId/rack/machines | |
| parent | 6fdb3e75dad15523d996e457c216647755b29101 (diff) | |
Add formatter
Diffstat (limited to 'opendc/api/v2/tiles/tileId/rack/machines')
| -rw-r--r-- | opendc/api/v2/tiles/tileId/rack/machines/endpoint.py | 46 | ||||
| -rw-r--r-- | opendc/api/v2/tiles/tileId/rack/machines/position/endpoint.py | 64 |
2 files changed, 35 insertions, 75 deletions
diff --git a/opendc/api/v2/tiles/tileId/rack/machines/endpoint.py b/opendc/api/v2/tiles/tileId/rack/machines/endpoint.py index 5272c117..1ff25f44 100644 --- a/opendc/api/v2/tiles/tileId/rack/machines/endpoint.py +++ b/opendc/api/v2/tiles/tileId/rack/machines/endpoint.py @@ -10,11 +10,7 @@ def GET(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'tileId': 'int' - } - ) + request.check_required_parameters(path={'tileId': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) @@ -40,11 +36,7 @@ def GET(request): for machine in machines: machine.read() - return Response( - 200, - 'Successfully retrieved Machines for {}.'.format(rack), - [x.to_JSON() for x in machines] - ) + return Response(200, 'Successfully retrieved Machines for {}.'.format(rack), [x.to_JSON() for x in machines]) def POST(request): @@ -53,22 +45,18 @@ def POST(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'tileId': 'int' - }, - body={ - 'machine': { - 'rackId': 'int', - 'position': 'int', - 'tags': 'list-string', - 'cpuIds': 'list-int', - 'gpuIds': 'list-int', - 'memoryIds': 'list-int', - 'storageIds': 'list-int' - } - } - ) + request.check_required_parameters(path={'tileId': 'int'}, + body={ + 'machine': { + 'rackId': 'int', + 'position': 'int', + 'tags': 'list-string', + 'cpuIds': 'list-int', + 'gpuIds': 'list-int', + 'memoryIds': 'list-int', + 'storageIds': 'list-int' + } + }) except exceptions.ParameterError as e: return Response(400, e.message) @@ -111,8 +99,4 @@ def POST(request): machine.read() - return Response( - 200, - 'Successfully added {}.'.format(machine), - machine.to_JSON() - ) + return Response(200, 'Successfully added {}.'.format(machine), machine.to_JSON()) diff --git a/opendc/api/v2/tiles/tileId/rack/machines/position/endpoint.py b/opendc/api/v2/tiles/tileId/rack/machines/position/endpoint.py index 99011fa4..d82014b3 100644 --- a/opendc/api/v2/tiles/tileId/rack/machines/position/endpoint.py +++ b/opendc/api/v2/tiles/tileId/rack/machines/position/endpoint.py @@ -10,12 +10,7 @@ def GET(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'tileId': 'int', - 'position': 'int' - } - ) + request.check_required_parameters(path={'tileId': 'int', 'position': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) @@ -38,34 +33,28 @@ def GET(request): machine.read() - return Response( - 200, - 'Successfully retrieved {}.'.format(machine), - machine.to_JSON() - ) + return Response(200, 'Successfully retrieved {}.'.format(machine), machine.to_JSON()) def PUT(request): """Update the Machine at this location in this Rack.""" try: - request.check_required_parameters( - path={ - 'tileId': 'int', - 'position': 'int' - }, - body={ - 'machine': { - 'rackId': 'int', - 'position': 'int', - 'tags': 'list-string', - 'cpuIds': 'list-int', - 'gpuIds': 'list-int', - 'memoryIds': 'list-int', - 'storageIds': 'list-int' - } - } - ) + request.check_required_parameters(path={ + 'tileId': 'int', + 'position': 'int' + }, + body={ + 'machine': { + 'rackId': 'int', + 'position': 'int', + 'tags': 'list-string', + 'cpuIds': 'list-int', + 'gpuIds': 'list-int', + 'memoryIds': 'list-int', + 'storageIds': 'list-int' + } + }) except exceptions.ParameterError as e: return Response(400, e.message) @@ -114,11 +103,7 @@ def PUT(request): machine.read() - return Response( - 200, - 'Successfully updated {}.'.format(machine), - machine.to_JSON() - ) + return Response(200, 'Successfully updated {}.'.format(machine), machine.to_JSON()) def DELETE(request): @@ -127,12 +112,7 @@ def DELETE(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'tileId': 'int', - 'position': 'int' - } - ) + request.check_required_parameters(path={'tileId': 'int', 'position': 'int'}) except exceptions.ParameterError as e: return Response(400, e.message) @@ -157,8 +137,4 @@ def DELETE(request): # Return this Machine - return Response( - 200, - 'Successfully deleted {}.'.format(machine), - machine.to_JSON() - ) + return Response(200, 'Successfully deleted {}.'.format(machine), machine.to_JSON()) |
