You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@heitorlessa note, we would have to ensure the any of the data classes are json serializable (ie: Idempotent handler expects a dict or something that can be serialized to json)
@heitorlessa note, we would have to ensure the any of the data classes are json serializable (ie: Idempotent handler expects a dict or something that can be serialized to json)
Below is what i mean as an equivalent implementation for event source data classes (all of the in fact), and you would also
benefit from the utility methods like get_header_value
@lambda_handler_decoratordefevent_source(
handler: Callable[[Any, LambdaContext], Any],
event: Dict[str, Any], context: LambdaContext,
data_class: Type[DictWrapper],
):
# Where `model` is the passed in event source data class like APIGatewayProxyEventV2.returnhandler(data_class(event), context)
> raise TypeError(f'Object of type {o.__class__.__name__} '
f'is not JSON serializable')
E TypeError: Object of type APIGatewayProxyEventV2Model is not JSON serializable
See how this was resolved for the event_source implementation :
Activity
heitorlessa commentedon May 18, 2021
Hey @xpayn - Absolutely, I'd love to help with any guidance if you can make a PR.
michaelbrewer commentedon May 20, 2021
@heitorlessa note, we would have to ensure the any of the data classes are json serializable (ie: Idempotent handler expects a dict or something that can be serialized to json)
heitorlessa commentedon May 21, 2021
Sure, it'd need an additional check if it's a Pyndantic Model, then you can call
.json()to do the serialization of all of their custom types and such: https://pydantic-docs.helpmanual.io/usage/exporting_models/#modeljsonran-isenberg commentedon May 23, 2021
@xpayn @heitorlessa if you havent started it yet, i can do it this week.i created the v1 one and this was on my todo list
feat: Add APIGateway*EventModelV2 to parser #434
ran-isenberg commentedon May 24, 2021
see #441
xpayn commentedon May 24, 2021
I was planning to make the PR today, I just wanted to review my code before, but i'll read your's instead
michaelbrewer commentedon May 25, 2021
Seems like we are mixing things here. I think @xpayn is referring to the Event Source Data Classes.
michaelbrewer commentedon May 25, 2021
Note, @xpayn there is also https://awslabs.github.io/aws-lambda-powertools-python/latest/core/event_handler/api_gateway/
michaelbrewer commentedon May 25, 2021
@xpayn @risenberg-cyberark
Below is what i mean as an equivalent implementation for event source data classes (all of the in fact), and you would also
benefit from the utility methods like
get_header_valueUsage wise, it would look like this
To test:
michaelbrewer commentedon May 26, 2021
@heitorlessa @xpayn @risenberg-cyberark created then equivalent for the event source data classes see PR #442 .
feat(parser): add support for API Gateway HTTP API #434 (#441)
michaelbrewer commentedon May 28, 2021
note that the
event_parserhas to be currently placed after the idempotent handler (and not before) otherwise you will get the following error:Will raise a TypeError
See how this was resolved for the event_source implementation :
heitorlessa commentedon Jun 8, 2021
hey @xpayn - this is now available as part of 1.17.0 🎉 - I've added an example using both Model and Envelope for HTTP API: https://github.com/awslabs/aws-lambda-powertools-python/releases/tag/v1.17.0
Big thanks to @risenberg-cyberark on the implementation