Skip to content

Commit 97efe5d

Browse files
committed
updated readme
1 parent 46dfaeb commit 97efe5d

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,67 @@
44
[![PyPI version](https://badge.fury.io/py/pypwext.svg)](https://badge.fury.io/py/pypwext)
55
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pypwext&metric=alert_status)](https://sonarcloud.io/dashboard?id=pypwext)
66

7+
This is a extension, decorators and other utilities that complements thew [AWS Lambda Powertools](https://awslabs.github.io/aws-lambda-powertools-python) library. It is centered around the following four **pillars**
78

8-
PyPi(https://pypi.org/project/pypwext/)
99

10+
1. Logging
11+
```python
12+
logger = PyPwExtLogger()
13+
14+
@logger.method(classification=InfoClassification.PII)
15+
def subscribe(customer: Customer) -> Subscription:
16+
...
17+
```
18+
2. Error handling
19+
```python
20+
errors = PyPwExtErrorHandler()
21+
22+
@errors.collect
23+
def do_operation():
24+
raise PyPwExtHTTPError('Something went wrong', details={'foo': 'bar'})
25+
```
26+
3. HTTP and Lambda Communication
27+
```python
28+
http = PyPwExtHTTPSession() # Defaults with "sane" retries, exp back-off etc.
29+
30+
@http.method(
31+
method='POST',
32+
url='https://{STAGE}.execute-api.{AWS_REGION}.amazonaws.com/{api_version}/my-api'
33+
params= {'email':'{email}'},
34+
body='customer'
35+
)
36+
def send_offer(
37+
api_version:str,
38+
email: str,
39+
customer: Customer,
40+
response_code:HTTPStatus=HTTPStatus.OK,
41+
response_body:str = ''
42+
) -> str:
43+
...
44+
```
45+
4. µService Support
46+
```python
47+
service = PyPwExtService()
48+
49+
@service.response
50+
@event_parser(model=Order)
51+
def handler(event: Order, context: LambdaContext):
52+
53+
if not event.pypwext_id:
54+
raise StdPyPwExtError(
55+
code=HTTPStatus.BAD_REQUEST,
56+
message="Missing pypwext_id",
57+
)
58+
59+
return PyPwExtResponse(
60+
status_code=HTTPStatus.OK,
61+
updated=[item for item in event.items],
62+
operation="create-order",
63+
)
64+
```
65+
66+
67+
## Overview
1068
This module contains the core functionality of the PyPwExt µService applications.
1169

1270
:bulb: Each piece of functionality is implemented as an individual function and is **not**

0 commit comments

Comments
 (0)