Module for creating a simple API with AWS Lambda and API Gateway
Project description
anslapi
A python3 module for creating a simple API with AWS Lambda and API Gateway.
Install
python3 -m pip install anslapi
Configuration
Create an api gateway with the methods that are needed, and set up authentication, schemas, etc. as wished. Create a Lambda function and configure our function as the target for each method. Use Lambda proxy mode.
Usage example
from anslapi import APIHandler
def get_user(userid):
return "user.name@example.com"
def add(event):
import json
result = {
"status": "FAIL"
}
j = json.loads(event["body"])
if "userid" in j:
result["response"] = cls.get_user(j["userid"])
result["status"] = "SUCCESS"
return (200, result)
else:
result["reason"] = "Invalid request"
return (400, result)
def lambda_handler(event, context):
ah = APIHandler()
ah.add_handler('/add', 'POST', Actions.add)
response = ah.handle(event)
return response
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
anslapi-1.0.1.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file anslapi-1.0.1.tar.gz
.
File metadata
- Download URL: anslapi-1.0.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f72aca1e6e636ec35dc3fe76e667d241db710954c005700100c7a6643ac17f2 |
|
MD5 | 130442a133a9199bfd7ab5b8630229ad |
|
BLAKE2b-256 | ebb8a2ef78eb8eb12ade4ea8842f18e5d9ccb44e19a3cdb006cf02d3b7c49906 |
File details
Details for the file anslapi-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: anslapi-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49df0a8c578fc0fd8bde3ad64ba4e7b568c14afd4cb35dae40fe2cf7ff945241 |
|
MD5 | 8b100f08071dab64aad24ac3a1e410ae |
|
BLAKE2b-256 | 87b905aa58f707d8ed2d1b584b3d54ca0411e8a79414019b93715641e344e4ad |