Skip to content

Commit

Permalink
Merge pull request #57 from jtetrault/cognito_custom_message
Browse files Browse the repository at this point in the history
Add event type for cognito CustomMessage
  • Loading branch information
MousaZeidBaker committed May 19, 2022
2 parents c4b8f4b + d769dfc commit c3bbf55
Show file tree
Hide file tree
Showing 6 changed files with 459 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -63,6 +63,7 @@ def handler(event: events.SQSEvent, context: context_.Context) -> None:
- CloudWatchLogsEvent
- CodeCommitMessageEvent
- CodePipelineEvent
- CognitoCustomMessageEvent
- ConfigEvent
- DynamoDBStreamEvent
- EventBridgeEvent
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aws-lambda-typing"
version = "2.11.1"
version = "2.12.0"
description = "A package that provides type hints for AWS Lambda event, context and response objects"
authors = ["Mousa Zeid Baker"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,5 +1,5 @@
[flake8]
max-line-length = 80
per-file-ignores =
__init__.py:F401
__init__.py:F401,E501
test*.py:F841
24 changes: 24 additions & 0 deletions src/aws_lambda_typing/events/__init__.py
Expand Up @@ -26,6 +26,30 @@
from .cloud_watch_logs import CloudWatchLogsEvent as CloudWatchLogsEvent
from .code_commit import CodeCommitMessageEvent as CodeCommitMessageEvent
from .code_pipeline import CodePipelineEvent as CodePipelineEvent
from .cognito_custom_message import (
CognitoCustomMessageAdminCreateUserEvent as CognitoCustomMessageAdminCreateUserEvent,
)
from .cognito_custom_message import (
CognitoCustomMessageAuthenticationEvent as CognitoCustomMessageAuthenticationEvent,
)
from .cognito_custom_message import (
CognitoCustomMessageEvent as CognitoCustomMessageEvent,
)
from .cognito_custom_message import (
CognitoCustomMessageForgotPasswordEvent as CognitoCustomMessageForgotPasswordEvent,
)
from .cognito_custom_message import (
CognitoCustomMessageResendCodeEvent as CognitoCustomMessageResendCodeEvent,
)
from .cognito_custom_message import (
CognitoCustomMessageSignUpEvent as CognitoCustomMessageSignUpEvent,
)
from .cognito_custom_message import (
CognitoCustomMessageUpdateUserAttributeEvent as CognitoCustomMessageUpdateUserAttributeEvent,
)
from .cognito_custom_message import (
CognitoCustomMessageVerifyUserAttributeEvent as CognitoCustomMessageVerifyUserAttributeEvent,
)
from .config import ConfigEvent as ConfigEvent
from .dynamodb_stream import DynamoDBStreamEvent as DynamoDBStreamEvent
from .event_bridge import EventBridgeEvent as EventBridgeEvent
Expand Down
241 changes: 241 additions & 0 deletions src/aws_lambda_typing/events/cognito_custom_message.py
@@ -0,0 +1,241 @@
#!/usr/bin/env python

import sys

if sys.version_info >= (3, 8):
from typing import Any, Dict, Literal, Optional, TypedDict, Union
else:
from typing import Any, Dict, Optional, Union

from typing_extensions import Literal, TypedDict


class CallerContext(TypedDict):
"""
CallerContext
Attributes:
----------:
awsSdkVersion: str
clientId: str
"""

awsSdkVersion: str
clientId: str


class Request(TypedDict, total=False):
"""
Request
Attributes:
----------:
userAttributes: Dict[str, Any]
codeParameter: str
usernameParameter: str
clientMetadata: Optional[Dict[str, Any]]
"""

userAttributes: Dict[str, Any]
codeParameter: str
usernameParameter: str
clientMetadata: Optional[Dict[str, Any]]


class Response(TypedDict):
"""
Response
Attributes:
----------:
smsMessage: str
emailMessage: str
emailSubject: str
"""

smsMessage: str
emailMessage: str
emailSubject: str


class CognitoCustomMessageCommon(TypedDict):
"""
CognitoCustomMessageCommon
https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html#cognito-user-pools-lambda-trigger-syntax-shared
Attributes:
----------
version: str
region: str
userPoolId: str
userName: str
callerContext: :py:class:`CallerContext`
request: :py:class:`Request`
response: :py:class:`Response`
"""

version: str
region: str
userPoolId: str
userName: str
callerContext: CallerContext
request: Request
response: Response


class CognitoCustomMessageSignUpEvent(
CognitoCustomMessageCommon,
):
"""
CognitoCustomMessageSignUpEvent
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
Attributes:
----------
triggerSource: Literal['CustomMessage_SignUp']
"""

triggerSource: Literal["CustomMessage_SignUp"]


class CognitoCustomMessageAdminCreateUserEvent(
CognitoCustomMessageCommon,
):
"""
CognitoCustomMessageAdminCreateUserEvent
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
Attributes:
----------
triggerSource: Literal['CustomMessage_AdminCreateUser']
"""

triggerSource: Literal["CustomMessage_AdminCreateUser"]


class CognitoCustomMessageResendCodeEvent(
CognitoCustomMessageCommon,
):
"""
CognitoCustomMessageResendCodeEvent
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
Attributes:
----------
triggerSource: Literal['CustomMessage_ResendCode']
"""

triggerSource: Literal["CustomMessage_ResendCode"]


class CognitoCustomMessageForgotPasswordEvent(
CognitoCustomMessageCommon,
):
"""
CognitoCustomMessageForgotPasswordEvent
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
Attributes:
----------
triggerSource: Literal['CustomMessage_ForgotPassword']
"""

triggerSource: Literal["CustomMessage_ForgotPassword"]


class CognitoCustomMessageUpdateUserAttributeEvent(
CognitoCustomMessageCommon,
):
"""
CognitoCustomMessageUpdateUserAttributeEvent
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
Attributes:
----------
triggerSource: Literal['CustomMessage_UpdateUserAttribute']
"""

triggerSource: Literal["CustomMessage_UpdateUserAttribute"]


class CognitoCustomMessageVerifyUserAttributeEvent(
CognitoCustomMessageCommon,
):
"""
CognitoCustomMessageVerifyUserAttributeEvent
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
Attributes:
----------
triggerSource: Literal['CustomMessage_VerifyUserAttribute']
"""

triggerSource: Literal["CustomMessage_VerifyUserAttribute"]


class CognitoCustomMessageAuthenticationEvent(
CognitoCustomMessageCommon,
):
"""
CognitoCustomMessageAuthenticationEvent
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
Attributes:
----------
triggerSource: Literal['CustomMessage_Authentication']
"""

triggerSource: Literal["CustomMessage_Authentication"]


CognitoCustomMessageEvent = Union[
CognitoCustomMessageSignUpEvent,
CognitoCustomMessageAdminCreateUserEvent,
CognitoCustomMessageResendCodeEvent,
CognitoCustomMessageForgotPasswordEvent,
CognitoCustomMessageUpdateUserAttributeEvent,
CognitoCustomMessageVerifyUserAttributeEvent,
CognitoCustomMessageAuthenticationEvent,
]
"""
CognitoCustomMessageEvent
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
Attributes:
----------
version: str
triggerSource: Literal[
"CustomMessage_SignUp",
"CustomMessage_AdminCreateUser",
"CustomMessage_ResendCode",
"CustomMessage_ForgotPassword",
"CustomMessage_UpdateUserAttribute",
"CustomMessage_VerifyUserAttribute",
"CustomMessage_Authentication"
]
region: str
userPoolId: str
userName: str
callerContext: :py:class:`CallerContext`
request: :py:class:`Request`
response: :py:class:`Response`
"""

0 comments on commit c3bbf55

Please sign in to comment.