aws-lambda-requests-wrapper-0.2.3
توضیحات
Request/Response wrapper for AWS Lambda with API Gateway
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | aws-lambda-requests-wrapper-0.2.3 |
| نام | aws-lambda-requests-wrapper |
| نسخه کتابخانه | 0.2.3 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | rikhilrai |
| ایمیل نویسنده | - |
| آدرس صفحه اصلی | https://github.com/DeveloperRSquared/aws-lambda-requests-wrapper |
| آدرس اینترنتی | https://pypi.org/project/aws-lambda-requests-wrapper/ |
| مجوز | MIT |
# AWS Lambda Requests Wrapper
Request/Response wrapper for AWS Lambda with API Gateway.
[](https://github.com/DeveloperRSquared/aws-lambda-requests-wrapper/actions/workflows/publish.yml)
[](#aws-lambda-requests-wrapper)
[](LICENSE)
[](https://pypi.org/project/aws-lambda-requests-wrapper)
[](https://codecov.io/gh/DeveloperRSquared/aws-lambda-requests-wrapper)
[](https://results.pre-commit.ci/latest/github/DeveloperRSquared/aws-lambda-requests-wrapper/main)
[](https://github.com/DeveloperRSquared/aws-lambda-requests-wrapper/actions/workflows/codeql-analysis.yml)
[](https://pycqa.github.io/isort/)
[](https://github.com/psf/black)
[](http://mypy-lang.org/)
## Install
Install and update using [pip](https://pypi.org/project/aws-lambda-requests-wrapper/).
```sh
$ pip install -U aws-lambda-requests-wrapper
```
## Example
Converts the lambda_handler syntax:
```py
import json
def lambda_handler(event, context):
...
response = {"key": "value"}
return {
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
},
"body": json.dumps(response)
}
```
into this:
```py
import json
from aws_lambda_requests_wrapper.lambda_handler import lambda_request_wrapper
from aws_lambda_requests_wrapper.models import Request
from aws_lambda_requests_wrapper.models import Response
@lambda_request_wrapper()
def lambda_handler(request: Request) -> Response:
...
response = {"key": "value"}
return Response(body=json.dumps(response))
```
or return a Pydantic model directly:
```py
from pydantic import BaseModel
from aws_lambda_requests_wrapper.lambda_handler import lambda_request_wrapper
from aws_lambda_requests_wrapper.models import Request
class Model(BaseModel):
model_id: int
@lambda_request_wrapper()
def get_pydantic_model(request: Request) -> Model:
return Model(model_id=1)
```
## Contributing
Contributions are welcome via pull requests.
### First time setup
```sh
$ git clone git@github.com:DeveloperRSquared/aws-lambda-requests-wrapper.git
$ cd aws-lambda-requests-wrapper
$ poetry install
$ source .venv/bin/activate
```
Tools including black, mypy etc. will run automatically if you install [pre-commit](https://pre-commit.com) using the instructions below
```sh
$ pre-commit install
$ pre-commit run --all-files
```
### Running tests
```sh
$ poetry run pytest
```
## Links
- Source Code: <https://github.com/DeveloperRSquared/aws-lambda-requests-wrapper/>
- PyPI Releases: <https://pypi.org/project/aws-lambda-requests-wrapper/>
- Issue Tracker: <https://github.com/DeveloperRSquared/aws-lambda-requests-wrapper/issues/>
نیازمندی
| مقدار | نام |
|---|---|
| >=0.0.14,<0.0.15 | datetime-helpers |
| >=1.9.0,<2.0.0 | pydantic |
| <4.3) | importlib-metadata |
| >=0.1.1,<0.2.0 | case-insensitive-dictionary |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7,<4.0 | Python |
نحوه نصب
نصب پکیج whl aws-lambda-requests-wrapper-0.2.3:
pip install aws-lambda-requests-wrapper-0.2.3.whl
نصب پکیج tar.gz aws-lambda-requests-wrapper-0.2.3:
pip install aws-lambda-requests-wrapper-0.2.3.tar.gz