pygrestqlambda 0.0.1__tar.gz → 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/PKG-INFO +4 -1
  2. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/README.md +3 -0
  3. pygrestqlambda-0.0.2/docs/examples/direct/README.md +16 -0
  4. pygrestqlambda-0.0.2/docs/examples/direct/json_response.py +9 -0
  5. pygrestqlambda-0.0.2/docs/examples/direct/string_response.py +8 -0
  6. pygrestqlambda-0.0.2/docs/examples/lambda/Dockerfile +7 -0
  7. pygrestqlambda-0.0.2/docs/examples/lambda/README.md +35 -0
  8. pygrestqlambda-0.0.2/docs/examples/lambda/app.py +23 -0
  9. pygrestqlambda-0.0.2/docs/examples/local_lambda_gateway_compose/README.md +23 -0
  10. pygrestqlambda-0.0.2/docs/examples/local_lambda_gateway_compose/docker-compose.yaml +12 -0
  11. pygrestqlambda-0.0.2/docs/examples/local_lambda_gateway_compose/lambda/Dockerfile +9 -0
  12. pygrestqlambda-0.0.2/docs/examples/local_lambda_gateway_compose/lambda/app.py +22 -0
  13. pygrestqlambda-0.0.2/docs/examples/local_lambda_gateway_compose/lambda/requirements.txt +1 -0
  14. pygrestqlambda-0.0.2/docs/examples/local_lambda_gateway_compose/openapi.yaml +19 -0
  15. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/pyproject.toml +1 -1
  16. pygrestqlambda-0.0.2/tests/aws/lambda_function/__init__.py +0 -0
  17. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/.github/workflows/publish.yml +0 -0
  18. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/.github/workflows/validate.yml +0 -0
  19. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/.gitignore +0 -0
  20. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/LICENSE +0 -0
  21. /pygrestqlambda-0.0.1/src/__init__.py → /pygrestqlambda-0.0.2/docs/examples/direct/requirements.txt +0 -0
  22. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/scripts/validate.sh +0 -0
  23. {pygrestqlambda-0.0.1/src/pygrestqlambda → pygrestqlambda-0.0.2/src}/__init__.py +0 -0
  24. {pygrestqlambda-0.0.1/src/pygrestqlambda/aws → pygrestqlambda-0.0.2/src/pygrestqlambda}/__init__.py +0 -0
  25. {pygrestqlambda-0.0.1/src/pygrestqlambda/aws/lambda_function → pygrestqlambda-0.0.2/src/pygrestqlambda/aws}/__init__.py +0 -0
  26. {pygrestqlambda-0.0.1/src/pygrestqlambda/db → pygrestqlambda-0.0.2/src/pygrestqlambda/aws/lambda_function}/__init__.py +0 -0
  27. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/src/pygrestqlambda/aws/lambda_function/json_transform.py +0 -0
  28. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/src/pygrestqlambda/aws/lambda_function/rest_api_gateway_proxy_integration.py +0 -0
  29. {pygrestqlambda-0.0.1/tests → pygrestqlambda-0.0.2/src/pygrestqlambda/db}/__init__.py +0 -0
  30. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/src/pygrestqlambda/db/record.py +0 -0
  31. {pygrestqlambda-0.0.1/tests/aws → pygrestqlambda-0.0.2/tests}/__init__.py +0 -0
  32. {pygrestqlambda-0.0.1/tests/aws/lambda_function → pygrestqlambda-0.0.2/tests/aws}/__init__.py +0 -0
  33. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/tests/aws/lambda_function/test_json_transform.py +0 -0
  34. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/tests/aws/lambda_function/test_rest_api_gateway_proxy_integration.py +0 -0
  35. {pygrestqlambda-0.0.1 → pygrestqlambda-0.0.2}/tests/test_record.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygrestqlambda
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: PostgreSQL REST API framework for AWS Lambda functions
5
5
  Project-URL: Homepage, https://github.com/mesogate/pygrestqlambda
6
6
  Project-URL: Issues, https://github.com/mesogate/pygrestqlambda/issues
@@ -32,3 +32,6 @@ A REST API web framework for persisting records in a PostgreSQL database.
32
32
  - Automatic setting of `created_at` and `last_updated_at` timestamps
33
33
  - Automatic setting of `creator_uid` and `last_updater_uid`
34
34
  - RDS with IAM credentials
35
+
36
+ ## Examples
37
+ See [Examples docs directory](./docs/examples/)
@@ -9,3 +9,6 @@ A REST API web framework for persisting records in a PostgreSQL database.
9
9
  - Automatic setting of `created_at` and `last_updated_at` timestamps
10
10
  - Automatic setting of `creator_uid` and `last_updater_uid`
11
11
  - RDS with IAM credentials
12
+
13
+ ## Examples
14
+ See [Examples docs directory](./docs/examples/)
@@ -0,0 +1,16 @@
1
+ # Direct python script invocation example
2
+
3
+ Navigate to the current directory from the root of this project:
4
+ ```shell
5
+ cd docs/examples/direct
6
+ ```
7
+
8
+ First install dependency with:
9
+ ```shell
10
+ pip install pygrestqlambda
11
+ ```
12
+
13
+ Then execute the scripts in this directory with, for example:
14
+ ```shell
15
+ python json_response.py
16
+ ```
@@ -0,0 +1,9 @@
1
+ from pygrestqlambda.aws.lambda_function.rest_api_gateway_proxy_integration import Response
2
+
3
+ response = Response(
4
+ body = {
5
+ 'hello': 'world'
6
+ }
7
+ )
8
+
9
+ print(response.get_payload())
@@ -0,0 +1,8 @@
1
+ from pygrestqlambda.aws.lambda_function.rest_api_gateway_proxy_integration import Response
2
+
3
+ response = Response(
4
+ headers={'Content-Type': 'text/html'},
5
+ body = 'hello'
6
+ )
7
+
8
+ print(response.get_payload())
@@ -0,0 +1,7 @@
1
+ FROM public.ecr.aws/lambda/python:3.12
2
+
3
+ RUN pip install pygrestqlambda
4
+
5
+ COPY app.py ${LAMBDA_TASK_ROOT}
6
+
7
+ CMD [ "app.handler" ]
@@ -0,0 +1,35 @@
1
+ # Lambda function docker container example
2
+
3
+ Navigate to the current directory from the root of this project:
4
+ ```shell
5
+ cd docs/examples/lambda
6
+ ```
7
+
8
+ From the current directory, build image with:
9
+ ```shell
10
+ docker build -t pygrestqlambda/lambda .
11
+ ```
12
+
13
+ The run the container with:
14
+ ```shell
15
+ docker run -p 9095:8080 pygrestqlambda/lambda
16
+ ```
17
+
18
+ In a separate terminal, run the following commands:
19
+ ```shell
20
+ curl \
21
+ -X POST \
22
+ -d '{"hello": "from terminal"}' \
23
+ http://127.0.0.1:9095/2015-03-31/functions/function/invocations
24
+ ```
25
+
26
+ The following is returned:
27
+ ```json
28
+ {
29
+ "isBase64Encoded": false,
30
+ "statusCode": 200,
31
+ "headers": {"Content-Type": "application/json"},
32
+ "multiValueHeaders": null,
33
+ "body": "{\"hello\": \"from lambda handler\", \"original_input\": {\"hello\": \"from terminal\"}}"
34
+ }
35
+ ```
@@ -0,0 +1,23 @@
1
+ """
2
+ Lambda handler
3
+ """
4
+
5
+ import logging
6
+ from pygrestqlambda.aws.lambda_function.rest_api_gateway_proxy_integration import Response
7
+
8
+ def handler(event: dict, context: dict):
9
+ """
10
+ Lambda handler to return supplied JSON in a format expected by AWS REST API Gateway
11
+ """
12
+
13
+ logging.debug(context)
14
+ response = Response(
15
+ body={
16
+ 'hello': 'from lambda handler',
17
+ 'original_input': event
18
+ },
19
+ status_code=200,
20
+ )
21
+ payload = response.get_payload()
22
+
23
+ return payload
@@ -0,0 +1,23 @@
1
+ # REST API Gateway Lambda function docker compose example
2
+
3
+ Navigate to the current directory from the root of this project:
4
+ ```shell
5
+ cd docs/examples/local_lambda_gateway_compose
6
+ ```
7
+
8
+ Start the stack with:
9
+ ```shell
10
+ docker compose up --build
11
+ ```
12
+
13
+ In another terminal, make a request to the example endpoint:
14
+ ```shell
15
+ curl http://127.0.0.1:9096/example
16
+ ```
17
+
18
+ The following response should be returned:
19
+ ```json
20
+ {
21
+ "hello": "through local OpenAPI REST gateway"
22
+ }
23
+ ```
@@ -0,0 +1,12 @@
1
+ services:
2
+ rest-api-gateway:
3
+ image: voquis/local-openapi-aws-rest-api-gateway-lambda
4
+ volumes:
5
+ - ./openapi.yaml:/openapi/openapi.yaml:ro
6
+ ports:
7
+ - 9096:8080
8
+ depends_on:
9
+ - rest-api-lambda
10
+ rest-api-lambda:
11
+ build:
12
+ context: ./lambda
@@ -0,0 +1,9 @@
1
+ FROM public.ecr.aws/lambda/python:3.12
2
+
3
+ COPY requirements.txt ${LAMBDA_TASK_ROOT}
4
+
5
+ RUN pip install -r requirements.txt
6
+
7
+ COPY . ${LAMBDA_TASK_ROOT}
8
+
9
+ CMD [ "app.handler" ]
@@ -0,0 +1,22 @@
1
+ """
2
+ Lambda handler
3
+ """
4
+
5
+ import logging
6
+ from pygrestqlambda.aws.lambda_function.rest_api_gateway_proxy_integration import Response
7
+
8
+ def handler(event: dict, context: dict):
9
+ """
10
+ Lambda handler to return supplied JSON in a format expected by AWS REST API Gateway
11
+ """
12
+
13
+ logging.debug(context)
14
+ response = Response(
15
+ body={
16
+ 'hello': 'through local OpenAPI REST gateway'
17
+ },
18
+ status_code=200,
19
+ )
20
+ payload = response.get_payload()
21
+
22
+ return payload
@@ -0,0 +1,19 @@
1
+ openapi: 3.0.1
2
+ info:
3
+ title: Example API
4
+ version: 0.0.2
5
+ servers:
6
+ - url: http://127.0.0.1:9096
7
+ paths:
8
+ /example:
9
+ get:
10
+ responses:
11
+ '200':
12
+ description: An example response.
13
+ content:
14
+ application/json:
15
+ schema:
16
+ type: object
17
+ properties:
18
+ hello:
19
+ type: string
@@ -4,7 +4,7 @@ requires = ["hatchling"]
4
4
 
5
5
  [project]
6
6
  name = "pygrestqlambda"
7
- version = "0.0.1"
7
+ version = "0.0.2"
8
8
  description = "PostgreSQL REST API framework for AWS Lambda functions"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
File without changes