Skip to content

Commit 2fe2e8a

Browse files
author
Joris Conijn
committed
refactor: fix import issues and provide context in docblocks
1 parent a7f8b11 commit 2fe2e8a

File tree

6 files changed

+70
-23
lines changed

6 files changed

+70
-23
lines changed

aws_lambda_powertools/utilities/typing/__init__.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,10 @@
66
> This is copied from: https://gist.github.com/alexcasalboni/a545b68ee164b165a74a20a5fee9d133
77
"""
88

9-
from .lambda_client_context import LambdaClientContext
10-
from .lambda_client_context_mobile_client import LambdaClientContextMobileClient
11-
from .lambda_cognito_identity import LambdaCognitoIdentity
9+
from .event import LambdaEvent
1210
from .lambda_context import LambdaContext
13-
from .lambda_dict import LambdaDict
1411

1512
__all__ = [
16-
"LambdaDict",
17-
"LambdaClientContext",
18-
"LambdaClientContextMobileClient",
19-
"LambdaCognitoIdentity",
13+
"LambdaEvent",
2014
"LambdaContext",
2115
]

aws_lambda_powertools/utilities/typing/lambda_dict.py renamed to aws_lambda_powertools/utilities/typing/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
from typing import Any, Dict
44

5-
LambdaDict = Dict[str, Any]
5+
LambdaEvent = Dict[str, Any]
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
# -*- coding: utf-8 -*-
2-
from aws_lambda_powertools.utilities.typing import LambdaClientContextMobileClient, LambdaDict
2+
from aws_lambda_powertools.utilities.typing import LambdaEvent
3+
from aws_lambda_powertools.utilities.typing.lambda_client_context_mobile_client import LambdaClientContextMobileClient
34

45

56
class LambdaClientContext(object):
6-
client: LambdaClientContextMobileClient
7-
custom: LambdaDict
8-
env: LambdaDict
7+
_client: LambdaClientContextMobileClient
8+
_custom: LambdaEvent
9+
_env: LambdaEvent
10+
11+
@property
12+
def client(self) -> LambdaClientContextMobileClient:
13+
"""Client context that's provided to Lambda by the client application."""
14+
return self._client
15+
16+
@property
17+
def custom(self) -> LambdaEvent:
18+
"""A dict of custom values set by the mobile client application."""
19+
return self._custom
20+
21+
@property
22+
def env(self) -> LambdaEvent:
23+
"""A dict of environment information provided by the AWS SDK."""
24+
return self._env

aws_lambda_powertools/utilities/typing/lambda_client_context_mobile_client.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,30 @@
22

33

44
class LambdaClientContextMobileClient(object):
5-
installation_id: str
6-
app_title: str
7-
app_version_name: str
8-
app_version_code: str
9-
app_package_name: str
5+
"""Mobile Client context that's provided to Lambda by the client application."""
6+
7+
_installation_id: str
8+
_app_title: str
9+
_app_version_name: str
10+
_app_version_code: str
11+
_app_package_name: str
12+
13+
@property
14+
def installation_id(self) -> str:
15+
return self._installation_id
16+
17+
@property
18+
def app_title(self) -> str:
19+
return self._app_title
20+
21+
@property
22+
def app_version_name(self) -> str:
23+
return self._app_version_name
24+
25+
@property
26+
def app_version_code(self) -> str:
27+
return self._app_version_code
28+
29+
@property
30+
def app_package_name(self) -> str:
31+
return self._app_package_name

aws_lambda_powertools/utilities/typing/lambda_cognito_identity.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,19 @@
22

33

44
class LambdaCognitoIdentity(object):
5-
cognito_identity_id: str
6-
cognito_identity_pool_id: str
5+
"""
6+
Information about the Amazon Cognito identity that authorized the request.
7+
"""
8+
9+
_cognito_identity_id: str
10+
_cognito_identity_pool_id: str
11+
12+
@property
13+
def cognito_identity_id(self) -> str:
14+
"""The authenticated Amazon Cognito identity."""
15+
return self._cognito_identity_id
16+
17+
@property
18+
def cognito_identity_pool_id(self) -> str:
19+
"""The Amazon Cognito identity pool that authorized the invocation."""
20+
return self._cognito_identity_pool_id

aws_lambda_powertools/utilities/typing/lambda_context.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
2-
from aws_lambda_powertools.utilities.typing import LambdaClientContext, LambdaCognitoIdentity
2+
from aws_lambda_powertools.utilities.typing.lambda_client_context import LambdaClientContext
3+
from aws_lambda_powertools.utilities.typing.lambda_cognito_identity import LambdaCognitoIdentity
34

45

56
class LambdaContext(object):
@@ -9,9 +10,9 @@ class LambdaContext(object):
910
-------
1011
**A Lambda function using LambdaContext**
1112
12-
>>> from aws_lambda_powertools.utilities.typing import LambdaDict, LambdaContext
13+
>>> from aws_lambda_powertools.utilities.typing import LambdaEvent, LambdaContext
1314
>>>
14-
>>> def handler(event: LambdaDict, context: LambdaContext) -> LambdaDict:
15+
>>> def handler(event: LambdaEvent, context: LambdaContext) -> LambdaEvent:
1516
>>> # Insert business logic
1617
>>> return event
1718

0 commit comments

Comments
 (0)