in api/wheel.py [0:0]
def update_wheel(event):
"""
Update the name of the wheel and/or refresh its participant count
:param event: Lambda event containing the API Gateway request path parameter wheel_id
{
"pathParameters":
{
"wheel_id": string ID of the wheel (DDB Hash Key)
},
"body":
{
"id": string ID of the wheel (DDB Hash Key),
"name": string name of the wheel,
}
}
:return: response dictionary containing the updated wheel object if successful
{
"body":
{
"id": string ID of the wheel (DDB Hash Key),
"name": string name of the wheel,
"participant_count": number of participants in the wheel,
"created_at": creation timestamp,
"updated_at": updated timestamp,
}
}
"""
wheel_id = event['pathParameters']['wheel_id']
key = {'id': wheel_id}
# Make sure wheel exists
wheel = Wheel.get_existing_item(Key=key)
name = event['body'].get('name', None)
if not check_string(name):
raise base.BadRequestError("Updating a wheel requires a new name of at least 1 character in length")
update = {'name': name, 'updated_at': get_utc_timestamp()}
Wheel.update_item(Key=key, **to_update_kwargs(update))
# Represent the change locally for successful responses
wheel.update(update)
return wheel