- Install from PyPi
- Import
Event
andContext
fromfunction_addons.request
- Change your DO Functions function signature to
(event: Event, context: Context)
DigitalOcean functions adds any extra request body to Event. Simply extend the Event class with your custom attributes for typing support.
from function_addons.request import Event, Context
class MyEvent(Event):
data: object
def main(event: MyEvent, context: Context):
data = event["data"]
Make sure to either use .get()
or except KeyError
as this doesn't validate if the key is actually present.