AWS Lambda REST ToolBox
Project description
Lambdalizator
AWS Lambda REST Toolbox inspired by Flask. Created and Open Sourced thanks to LocalBini.com by pdyba and songofroland.
Settings:
For toggling boolean variables, set them to "0" or "1" respectively.
CLIENT_SECRET For decoding authorization jwt. Defaults 'secret'.
COGNITO_AUTHENTICATION Toggle authenticating user based on Cognito IdToken. Defaults False.
COGNITO_PUBLIC_KEYS For validating IdToken signature when Cognito authentication enabled.
(simply paste from https://cognito-idp.{your aws region}.amazonaws.com/{your pool id}/.well-known/jwks.json)
COGNITO_ALLOWED_CLIENTS Allowed Cognito clients id's. String in format "id1,id2,id3". Used for verifying IdToken signature.
PRINT_TRACEBACK More verbose errors. Defaults False.
LOGGING_LEVEL For logging level. Defaults INFO.\
Hello World Example:
1. Define resource
# simple_resource.py
from lbz.router import add_route
from lbz.response import Response
from lbz.resource import Resource
class HelloWorld(Resource):
@add_route("/", method="GET")
def list(self):
return Response({"message": "HelloWorld"})
2. Define handler
# simple_resource_handler.py
from lbz.exceptions import LambdaFWException
from simple_resource import HelloWorld
def handle(event, context):
try:
exp = HelloWorld(event)
resp = exp()
return resp
except Exception as err:
return LambdaFWException().to_dict()
3. Create dev Server [Optional]
# simple_resource_dev.py
from lbz.dev.server import MyDevServer
from simple_resource.simple_resource import HelloWorld
if __name__ == '__main__':
server = MyDevServer(acls=HelloWorld, port=8001)
server.run()
4. Don't forget to unit test
# python -m unittest simple_resource_test.py
import unittest
from lbz.dev.test import Client
from simple_resource import HelloWorld
class PublicTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.client = Client(resource=HelloWorld)
def test_filter_queries_all_active_when_no_params(self):
data = self.client.get("/").to_dict()["body"]
self.assertEqual(data, '{"message":"HelloWorld"}')
5. Authenticate it
# simple_auth/simple_resource.py
from lbz.router import add_route
from lbz.response import Response
from lbz.resource import Resource
from lbz.authz import add_authz, authorize, set_authz
@set_authz
class HelloWorld(Resource):
_name = "helloworld"
@authorize
@add_authz()
@add_route("/", method="GET")
def list(self, restrictions=None):
return Response({"message": f"Hello, {self.request.user.username} !"})
## Documentation
WIP
## Changelog
[Release Changelogs](./CHANGELOG.md)
Contribution
------------
We are always happy to have new contributions.
We have marked issues good for anyone looking to get started
Please take a look at our [Contribution guidelines](CONTRIBUTING.md).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lbz-0.1.7.tar.gz.
File metadata
- Download URL: lbz-0.1.7.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3804baf265901eda826a22bdf9de1deeb90a47655ac200c62a4f8dab1fbecfd
|
|
| MD5 |
2abc517118690c5e9e3eb06ad0d76195
|
|
| BLAKE2b-256 |
62e7ca7ddbb5e91da33f6ea34c250823ce14213c7a2cb1ff7330e6e2f19fb099
|
File details
Details for the file lbz-0.1.7-py3-none-any.whl.
File metadata
- Download URL: lbz-0.1.7-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4c3ce51b8ebd2f79d0c0b7e83e390b19409db2be15b8100d583358076ffc081
|
|
| MD5 |
50438ce7f07b7966a18b92426d6486e5
|
|
| BLAKE2b-256 |
c13f1ab938eb95548f8f1191d9774b71187b677fcdc6eb7496eba4c7230c2972
|