def delete_wheel()

in api/wheel.py [0:0]


def delete_wheel(event):
    """
    Deletes the wheel and all of its participants

    :param event: Lambda event containing the API Gateway request path parameter wheel_id
    {
      "pathParameters":
      {
        "wheel_id": string ID of the wheel (DDB Hash Key)
      }
    }
    :return: response dictionary
    """
    wheel_id = event['pathParameters']['wheel_id']
    # DynamoDB always succeeds for delete_item,
    Wheel.delete_item(Key={'id': wheel_id})

    # Clear out all participants of the wheel.  Query will be empty if it was already deleted
    with WheelParticipant.batch_writer() as batch:
        query_params = {
            'KeyConditionExpression': Key('wheel_id').eq(wheel_id),
            'ProjectionExpression': 'id'
        }
        # We don't use the default generator here because we don't want the deletes to change the query results
        for p in list(WheelParticipant.iter_query(**query_params)):
            batch.delete_item(Key={'id': p['id'], 'wheel_id': wheel_id})