summaryrefslogtreecommitdiff
path: root/opendc/api/v2/rooms/roomId/endpoint.py
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-06-24 09:13:09 +0200
committerGeorgios Andreadis <info@gandreadis.com>2020-06-24 09:13:09 +0200
commitbae760a62fc6a480fbe615dff6a7de03c7fd6d1d (patch)
tree06fc47f9922add14a3ac50fcfdfeb3d4fdc00363 /opendc/api/v2/rooms/roomId/endpoint.py
parent6fdb3e75dad15523d996e457c216647755b29101 (diff)
Add formatter
Diffstat (limited to 'opendc/api/v2/rooms/roomId/endpoint.py')
-rw-r--r--opendc/api/v2/rooms/roomId/endpoint.py52
1 files changed, 13 insertions, 39 deletions
diff --git a/opendc/api/v2/rooms/roomId/endpoint.py b/opendc/api/v2/rooms/roomId/endpoint.py
index 1dfc32cc..a43a82e7 100644
--- a/opendc/api/v2/rooms/roomId/endpoint.py
+++ b/opendc/api/v2/rooms/roomId/endpoint.py
@@ -9,18 +9,14 @@ def GET(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'roomId': 'int'
- }
- )
+ request.check_required_parameters(path={'roomId': 'int'})
except exceptions.ParameterError as e:
return Response(400, e.message)
# Instantiate a Room from the database
- room = Room.from_primary_key((request.params_path['roomId'],))
+ room = Room.from_primary_key((request.params_path['roomId'], ))
# Make sure this Room exists
@@ -36,11 +32,7 @@ def GET(request):
room.read()
- return Response(
- 200,
- 'Successfully retrieved {}.'.format(room),
- room.to_JSON()
- )
+ return Response(200, 'Successfully retrieved {}.'.format(room), room.to_JSON())
def PUT(request):
@@ -49,24 +41,18 @@ def PUT(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'roomId': 'int'
- },
- body={
- 'room': {
- 'name': 'string',
- 'roomType': 'string'
- }
- }
- )
+ request.check_required_parameters(path={'roomId': 'int'},
+ body={'room': {
+ 'name': 'string',
+ 'roomType': 'string'
+ }})
except exceptions.ParameterError as e:
return Response(400, e.message)
# Instantiate a Room from the database
- room = Room.from_primary_key((request.params_path['roomId'],))
+ room = Room.from_primary_key((request.params_path['roomId'], ))
# Make sure this Room exists
@@ -90,11 +76,7 @@ def PUT(request):
# Return this Room
- return Response(
- 200,
- 'Successfully updated {}.'.format(room),
- room.to_JSON()
- )
+ return Response(200, 'Successfully updated {}.'.format(room), room.to_JSON())
def DELETE(request):
@@ -103,18 +85,14 @@ def DELETE(request):
# Make sure required parameters are there
try:
- request.check_required_parameters(
- path={
- 'roomId': 'int'
- }
- )
+ request.check_required_parameters(path={'roomId': 'int'})
except exceptions.ParameterError as e:
return Response(400, e.message)
# Instantiate a Room and make sure it exists
- room = Room.from_primary_key((request.params_path['roomId'],))
+ room = Room.from_primary_key((request.params_path['roomId'], ))
if not room.exists():
return Response(404, '{} not found.'.format(room))
@@ -130,8 +108,4 @@ def DELETE(request):
# Return this Room
- return Response(
- 200,
- 'Successfully deleted {}.'.format(room),
- room.to_JSON()
- )
+ return Response(200, 'Successfully deleted {}.'.format(room), room.to_JSON())