It looks to me like you are trying to call your class instead of an instance of the class. RequestHandler() will call the __init__ method to initialize an instance of the class. Since you haven't defined the method it doesn't take any arguments. To access __call__ you need to call an instance of your class.
handler = RequestHandler()
result = handler(request, context, *args, **kwargs)
Answer from Jacinator on Stack Overflowamazon web services - Class based AWS lambda in Python - Stack Overflow
Examples of Lambda use cases?
Lambda beginner project with python
You can use API Gateway to expose your Lambda function to the internet. Make sure you restrict access via an API key or something.
Everything else is just python.
More on reddit.comSo what does a well-made AWS Lambda in Python actually look like?
Videos
It looks to me like you are trying to call your class instead of an instance of the class. RequestHandler() will call the __init__ method to initialize an instance of the class. Since you haven't defined the method it doesn't take any arguments. To access __call__ you need to call an instance of your class.
handler = RequestHandler()
result = handler(request, context, *args, **kwargs)
You can only define a handler in python using def handler(event, context):. However, I found a package that allows you to call the handler as a class
Usage, as noted in their documentation, is as follows:
pip install aws-lambda-handler
import aws_lambda
class EchoHandler(aws_lambda.Handler):
"""Echo handler."""
def perform(self, request, **k):
"""Echo perform method."""
response = aws_lambda.Response()
response.body = self.request.event
return response
echo_handler = EchoHandler()
# `echo_handler` is now a callable function you can map your AWS Lambda function to