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 | |
| parent | 6fdb3e75dad15523d996e457c216647755b29101 (diff) | |
Add formatter
Diffstat (limited to 'opendc/api/v2/tiles/tileId')
| -rw-r--r-- | opendc/api/v2/tiles/tileId/endpoint.py | 28 | ||||
| -rw-r--r-- | opendc/api/v2/tiles/tileId/rack/endpoint.py | 86 | ||||
| -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 |
4 files changed, 66 insertions, 158 deletions
diff --git a/opendc/api/v2/tiles/tileId/endpoint.py b/opendc/api/v2/tiles/tileId/endpoint.py index 5ccc9cd7..85cbd9f4 100644 --- a/opendc/api/v2/tiles/tileId/endpoint.py +++ b/opendc/api/v2/tiles/tileId/endpoint.py @@ -9,18 +9,14 @@ def GET(request): # Make sure request 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) # Instantiate a Tile from the database - tile = Tile.from_primary_key((request.params_path['tileId'],)) + tile = Tile.from_primary_key((request.params_path['tileId'], )) # Make sure this Tile exists @@ -36,11 +32,7 @@ def GET(request): tile.read() - return Response( - 200, - 'Successfully retrieved {}.'.format(tile), - tile.to_JSON() - ) + return Response(200, 'Successfully retrieved {}.'.format(tile), tile.to_JSON()) def DELETE(request): @@ -49,18 +41,14 @@ def DELETE(request): # Make sure request 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) # Instantiate a Tile from the database - tile = Tile.from_primary_key((request.params_path['tileId'],)) + tile = Tile.from_primary_key((request.params_path['tileId'], )) # Make sure this Tile exists @@ -78,8 +66,4 @@ def DELETE(request): # Return this Tile - return Response( - 200, - 'Successfully deleted {}.'.format(tile), - tile.to_JSON() - ) + return Response(200, 'Successfully deleted {}.'.format(tile), tile.to_JSON()) diff --git a/opendc/api/v2/tiles/tileId/rack/endpoint.py b/opendc/api/v2/tiles/tileId/rack/endpoint.py index 64245856..0e1017e8 100644 --- a/opendc/api/v2/tiles/tileId/rack/endpoint.py +++ b/opendc/api/v2/tiles/tileId/rack/endpoint.py @@ -10,18 +10,14 @@ 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) # Instantiate a Tile from the database - tile = Tile.from_primary_key((request.params_path['tileId'],)) + tile = Tile.from_primary_key((request.params_path['tileId'], )) # Make sure this Tile exists @@ -35,7 +31,7 @@ def GET(request): # Instantiate a Rack from the database - rack = Rack.from_primary_key((tile.object_id,)) + rack = Rack.from_primary_key((tile.object_id, )) # Make sure this Rack exists @@ -46,11 +42,7 @@ def GET(request): rack.read() - return Response( - 200, - 'Successfully retrieved {}.'.format(rack), - rack.to_JSON() - ) + return Response(200, 'Successfully retrieved {}.'.format(rack), rack.to_JSON()) def POST(request): @@ -59,25 +51,19 @@ def POST(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'tileId': 'int' - }, - body={ - 'rack': { - 'name': 'string', - 'capacity': 'int', - 'powerCapacityW': 'int' - } - } - ) + request.check_required_parameters(path={'tileId': 'int'}, + body={'rack': { + 'name': 'string', + 'capacity': 'int', + 'powerCapacityW': 'int' + }}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Tile from the database - tile = Tile.from_primary_key((request.params_path['tileId'],)) + tile = Tile.from_primary_key((request.params_path['tileId'], )) # Make sure this Tile exists @@ -109,11 +95,7 @@ def POST(request): rack.read() - return Response( - 200, - 'Successfully added {}.'.format(rack), - rack.to_JSON() - ) + return Response(200, 'Successfully added {}.'.format(rack), rack.to_JSON()) def PUT(request): @@ -122,25 +104,19 @@ def PUT(request): # Make sure required parameters are there try: - request.check_required_parameters( - path={ - 'tileId': 'int' - }, - body={ - 'rack': { - 'name': 'string', - 'capacity': 'int', - 'powerCapacityW': 'int' - } - } - ) + request.check_required_parameters(path={'tileId': 'int'}, + body={'rack': { + 'name': 'string', + 'capacity': 'int', + 'powerCapacityW': 'int' + }}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate a Tile from the database - tile = Tile.from_primary_key((request.params_path['tileId'],)) + tile = Tile.from_primary_key((request.params_path['tileId'], )) # Make sure this Tile exists @@ -154,7 +130,7 @@ def PUT(request): # Instantiate a Rack from the database - rack = Rack.from_primary_key((tile.object_id,)) + rack = Rack.from_primary_key((tile.object_id, )) # Make sure this Rack exists @@ -172,11 +148,7 @@ def PUT(request): rack.read() - return Response( - 200, - 'Successfully updated {}.'.format(rack), - rack.to_JSON() - ) + return Response(200, 'Successfully updated {}.'.format(rack), rack.to_JSON()) def DELETE(request): @@ -185,18 +157,14 @@ def DELETE(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) # Instantiate a Tile from the database - tile = Tile.from_primary_key((request.params_path['tileId'],)) + tile = Tile.from_primary_key((request.params_path['tileId'], )) # Make sure this Tile exists @@ -210,7 +178,7 @@ def DELETE(request): # Instantiate a Rack from the database - rack = Rack.from_primary_key((tile.object_id,)) + rack = Rack.from_primary_key((tile.object_id, )) # Make sure this Rack exists @@ -230,8 +198,4 @@ def DELETE(request): # Return this Rack - return Response( - 200, - 'Successfully deleted {}.'.format(rack), - rack.to_JSON() - ) + return Response(200, 'Successfully deleted {}.'.format(rack), rack.to_JSON()) 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()) |
