lambdantic
Pydantic model and lambda event handler for AWS Lambda
This project is an experimental phase.
What is Lambdantic ?
The name means AWS Lambda + pydantic
lambdantic dispatch handler function from aws lambda events and to assign attributes from event object.
Installation
To install lambdantic:
$ pip install lambdantic
Example
API Gateway
The example is simple api which is invoked by API Gateway.
lambdantic parse Lambda Proxy Integration request.
The example should be deployed by Serverless, AWS CDK or other framework which supports Lambda Proxy Integration.
# handler.py
from typing import List, Optional
from pydantic import BaseModel, Schema
from lambdantic.apigateway import Handler
handler = Handler()
class Pet(BaseModel):
pet_id: Optional[int] = Schema(..., alias='id')
name: str
age: int
# database
pets = [
Pet(id=1, name='dog', age=3),
Pet(id=2, name='cat', age=2)
]
@handler.get('/pets')
def get_pets() -> List[Pet]:
return pets
@handler.get('/pets/<pet_id>')
def get_pet(pet_id: int) -> Pet:
for pet in pets:
if pet.pet_id == pet_id:
return pet
@handler.post('/pets', body_model=Pet, status_code=201)
def crate_pet(pet: Pet) -> Pet:
pet.pet_id = max(p.pet_id for p in pets)
pets.append(pet)
return pet
If you use Serverless then, the handler is defined like this example.
functions:
pet:
handler: handler.handler
events:
- http:
method: any
path: /{proxy+}
I show common parameters for Other framework
Handler: handler.handler
API Gateway API integration type : Lambda Proxy Integration
Path: /{proxy+}
method: ANY
Implemented
- API Gateway (WIP)
Not Implemented
- S3
- SNS ... and more
Development
Install the package in editable mode:
$ git clone git@github.com:koxudaxi/lambdantic.git
$ pip install -e lambdantic
PyPi
https://pypi.org/project/lambdantic
Source Code
https://github.com/koxudaxi/lambdantic
Documentation
https://koxudaxi.github.io/lambdantic
License
lambdantic is released under the MIT License. http://www.opensource.org/licenses/mit-license
Metadata
Release files for lambdantic 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lambdantic-0.0.4.tar.gz | 13.9 kB | Without provenance | Details for lambdantic-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lambdantic-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for lambdantic-0.0.4-py3-none-any.whl |
Total release size: 28.9 kB
Release files / lambdantic-0.0.4.tar.gz
| Download URL | lambdantic-0.0.4.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
946eb84c5a59ee9b205b113fdb86ab5c40c3243fe05f9797c7cc522a1f3ca8e9
|
|
BLAKE2b-256 checksum How to use checksums |
3d30fcf2ddb279161dfaf5ac5d826b9d3715b7e7d00515524d32746c0497a7b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.1
|
Release files / lambdantic-0.0.4-py3-none-any.whl
| Download URL | lambdantic-0.0.4-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4af72330966ac95083b6a896f2f6a69fd3c3c44fc0b7863f681d4cc5ec497990
|
|
BLAKE2b-256 checksum How to use checksums |
a22e65cc27c1842a56cd74704c7e4e1043696d867557418a95b62d45c8648f76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.1
|
Security for lambdantic 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.