dazza-codes / aio-aws

Asyncio utils for AWS Services
Apache License 2.0
3 stars 1 forks source link

lambda data encoding and parsers #18

Closed dazza-codes closed 3 years ago

dazza-codes commented 3 years ago

In general, lambda returns JSON but the lambda interface now keeps the raw data and it could provide accessors to parse the data rather than duplicate it in many attributes. The lambda_func.content and lambda_func.error could be accessors that read the data and response as required.

The .content could be a property that basically does the JSON parsing on demand:

ipdb> type(lambda_func.data)
<class 'bytes'>
ipdb> type(lambda_func.data.decode())
<class 'str'>
ipdb> json.loads(lambda_func.data.decode())

Maybe the .content should be renamed to .json instead.

If a lambda function returns a response with binary data (check content-type), the API should be able to detect it and parse it into binary content (image, protobuf, etc).