pygrestqlambda 0.0.0__tar.gz → 0.0.1__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.
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/.github/workflows/validate.yml +2 -0
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/PKG-INFO +1 -1
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/pyproject.toml +1 -1
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/src/pygrestqlambda/aws/lambda_function/json_transform.py +4 -0
- pygrestqlambda-0.0.0/src/pygrestqlambda/aws/lambda_function/proxy_integration_respose.py → pygrestqlambda-0.0.1/src/pygrestqlambda/aws/lambda_function/rest_api_gateway_proxy_integration.py +5 -5
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/src/pygrestqlambda/db/record.py +11 -8
- pygrestqlambda-0.0.1/tests/__init__.py +0 -0
- pygrestqlambda-0.0.1/tests/aws/__init__.py +0 -0
- pygrestqlambda-0.0.1/tests/aws/lambda_function/__init__.py +0 -0
- pygrestqlambda-0.0.1/tests/aws/lambda_function/test_rest_api_gateway_proxy_integration.py +38 -0
- pygrestqlambda-0.0.1/tests/test_record.py +14 -0
- pygrestqlambda-0.0.0/tests/test_record.py +0 -8
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/.github/workflows/publish.yml +0 -0
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/.gitignore +0 -0
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/LICENSE +0 -0
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/README.md +0 -0
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/scripts/validate.sh +0 -0
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/src/__init__.py +0 -0
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/src/pygrestqlambda/__init__.py +0 -0
- {pygrestqlambda-0.0.0/tests → pygrestqlambda-0.0.1/src/pygrestqlambda/aws}/__init__.py +0 -0
- {pygrestqlambda-0.0.0/tests/aws → pygrestqlambda-0.0.1/src/pygrestqlambda/aws/lambda_function}/__init__.py +0 -0
- {pygrestqlambda-0.0.0/tests/aws/lambda_function → pygrestqlambda-0.0.1/src/pygrestqlambda/db}/__init__.py +0 -0
- {pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/tests/aws/lambda_function/test_json_transform.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pygrestqlambda
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.1
|
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
|
@@ -6,17 +6,17 @@ Returns payload structure expected by REST API Gateway
|
|
6
6
|
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-output-format
|
7
7
|
"""
|
8
8
|
|
9
|
-
import
|
10
|
-
import json
|
9
|
+
from base64 import b64encode
|
11
10
|
from dataclasses import dataclass
|
11
|
+
import json
|
12
|
+
import logging
|
12
13
|
from pygrestqlambda.aws.lambda_function.json_transform import json_output
|
13
|
-
from base64 import b64encode
|
14
14
|
|
15
15
|
|
16
16
|
@dataclass
|
17
|
-
class
|
17
|
+
class Response:
|
18
18
|
"""
|
19
|
-
Lambda function response
|
19
|
+
Lambda function proxy response for REST API Gateway
|
20
20
|
"""
|
21
21
|
is_base64_encoded: bool | None = False
|
22
22
|
status_code: int | None = 401
|
@@ -1,3 +1,7 @@
|
|
1
|
+
"""
|
2
|
+
Record that represents a DB table row
|
3
|
+
"""
|
4
|
+
|
1
5
|
from abc import ABCMeta
|
2
6
|
|
3
7
|
|
@@ -14,53 +18,52 @@ class Record(metaclass=ABCMeta):
|
|
14
18
|
Runs before a new record is created. Useful for mutating a new record
|
15
19
|
before being committed.
|
16
20
|
"""
|
17
|
-
|
21
|
+
|
18
22
|
|
19
23
|
def before_read(self):
|
20
24
|
"""
|
21
25
|
Before a record is retrieved from the database. Useful for injecting
|
22
26
|
filters or sorting.
|
23
27
|
"""
|
24
|
-
|
28
|
+
|
25
29
|
|
26
30
|
def before_update(self):
|
27
31
|
"""
|
28
32
|
Before a new record is created. Useful for mutating a record before it
|
29
33
|
is committed.
|
30
34
|
"""
|
31
|
-
|
35
|
+
|
32
36
|
|
33
37
|
def before_delete(self):
|
34
38
|
"""
|
35
39
|
Before an existing record is deleted. Useful for e.g. updating counters
|
36
40
|
or other aggregate fields in other tables.
|
37
41
|
"""
|
38
|
-
|
42
|
+
|
39
43
|
|
40
44
|
def after_create(self):
|
41
45
|
"""
|
42
46
|
Runs after a new record is created. Useful for updating e.g. counters
|
43
47
|
tables.
|
44
48
|
"""
|
45
|
-
|
49
|
+
|
46
50
|
|
47
51
|
def after_read(self):
|
48
52
|
"""
|
49
53
|
After a record is retrieved from the database. Useful for transforming
|
50
54
|
retrieved data.
|
51
55
|
"""
|
52
|
-
|
56
|
+
|
53
57
|
|
54
58
|
def after_update(self):
|
55
59
|
"""
|
56
60
|
Runs after a new record is updated. Useful for updating e.g. counters
|
57
61
|
tables.
|
58
62
|
"""
|
59
|
-
|
63
|
+
|
60
64
|
|
61
65
|
def after_delete(self):
|
62
66
|
"""
|
63
67
|
Runs after an existing record is deleted. Useful for updating e.g.
|
64
68
|
counters tables.
|
65
69
|
"""
|
66
|
-
pass
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"""
|
2
|
+
Test REST API Gateway lambda proxy integration response
|
3
|
+
"""
|
4
|
+
|
5
|
+
import base64
|
6
|
+
import json
|
7
|
+
from pygrestqlambda.aws.lambda_function.rest_api_gateway_proxy_integration import Response
|
8
|
+
|
9
|
+
|
10
|
+
def test_json_response():
|
11
|
+
"""
|
12
|
+
Test JSON response is prepared correctly
|
13
|
+
"""
|
14
|
+
|
15
|
+
response = Response()
|
16
|
+
response.body = {'hello': 'world'}
|
17
|
+
|
18
|
+
payload = response.get_payload()
|
19
|
+
|
20
|
+
print(payload)
|
21
|
+
|
22
|
+
assert payload['headers']['Content-Type'] == 'application/json'
|
23
|
+
assert json.loads(payload['body'])['hello'] == 'world'
|
24
|
+
|
25
|
+
|
26
|
+
def test_binary_response():
|
27
|
+
"""
|
28
|
+
Test binary response is correctly prepared
|
29
|
+
"""
|
30
|
+
|
31
|
+
response = Response(
|
32
|
+
body=b'hello world',
|
33
|
+
is_base64_encoded=True
|
34
|
+
)
|
35
|
+
|
36
|
+
payload = response.get_payload()
|
37
|
+
|
38
|
+
assert base64.b64decode(payload['body']) == b'hello world'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pygrestqlambda-0.0.0 → pygrestqlambda-0.0.1}/tests/aws/lambda_function/test_json_transform.py
RENAMED
File without changes
|