diff --git a/aws_lambda_powertools/event_handler/api_gateway.py b/aws_lambda_powertools/event_handler/api_gateway.py index 30c13ada6b5..5017597c0f1 100644 --- a/aws_lambda_powertools/event_handler/api_gateway.py +++ b/aws_lambda_powertools/event_handler/api_gateway.py @@ -101,7 +101,7 @@ def __init__( only be used during development. allow_headers: Optional[List[str]] The list of additional allowed headers. This list is added to list of - built in allowed headers: `Authorization`, `Content-Type`, `X-Amz-Date`, + built-in allowed headers: `Authorization`, `Content-Type`, `X-Amz-Date`, `X-Api-Key`, `X-Amz-Security-Token`. expose_headers: Optional[List[str]] A list of values to return for the Access-Control-Expose-Headers diff --git a/aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py b/aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py index 4682711af92..327d37238aa 100644 --- a/aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py +++ b/aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py @@ -28,11 +28,12 @@ def __init__( self.api_id = api_id self.stage = stage self.http_method = http_method - self.resource = resource + # Remove matching "/" from `resource`. + self.resource = resource.lstrip("/") @property def arn(self) -> str: - """Build an arn from it's parts + """Build an arn from its parts eg: arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request""" return ( f"arn:{self.partition}:execute-api:{self.region}:{self.aws_account_id}:{self.api_id}/{self.stage}/" @@ -168,7 +169,7 @@ def get_header_value( default_value: str, optional Default value if no value was found by name case_sensitive: bool - Whether to use a case sensitive look up + Whether to use a case-sensitive look up Returns ------- str, optional @@ -270,7 +271,7 @@ def get_header_value( default_value: str, optional Default value if no value was found by name case_sensitive: bool - Whether to use a case sensitive look up + Whether to use a case-sensitive look up Returns ------- str, optional @@ -440,9 +441,6 @@ def _add_route(self, effect: str, http_method: str, resource: str, conditions: O if not self._resource_pattern.match(resource): raise ValueError(f"Invalid resource path: {resource}. Path should match {self.path_regex}") - if resource[:1] == "/": - resource = resource[1:] - resource_arn = APIGatewayRouteArn( self.region, self.aws_account_id, self.api_id, self.stage, http_method, resource ).arn diff --git a/aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py b/aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py index 56d37851631..89f774293e7 100644 --- a/aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py +++ b/aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py @@ -27,7 +27,7 @@ def source_ip(self) -> List[str]: @property def username(self) -> str: - """The user name of the authenticated user. IAM user principal""" + """The username of the authenticated user. IAM user principal""" return self["username"] @property @@ -72,7 +72,7 @@ def source_ip(self) -> List[str]: @property def username(self) -> str: - """The user name of the authenticated user.""" + """The username of the authenticated user.""" return self["username"] @property @@ -172,7 +172,7 @@ def arguments(self) -> Dict[str, Any]: def identity(self) -> Union[None, AppSyncIdentityIAM, AppSyncIdentityCognito]: """An object that contains information about the caller. - Depending of the type of identify found: + Depending on the type of identify found: - API_KEY authorization - returns None - AWS_IAM authorization - returns AppSyncIdentityIAM @@ -223,7 +223,7 @@ def get_header_value( default_value: str, optional Default value if no value was found by name case_sensitive: bool - Whether to use a case sensitive look up + Whether to use a case-sensitive look up Returns ------- str, optional diff --git a/aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py b/aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py index df2726ee722..a97bf26a16f 100644 --- a/aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py +++ b/aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py @@ -195,7 +195,7 @@ def final_user_status(self) -> Optional[str]: @final_user_status.setter def final_user_status(self, value: str): """During sign-in, this attribute can be set to CONFIRMED, or not set, to auto-confirm your users and - allow them to sign-in with their previous passwords. This is the simplest experience for the user. + allow them to sign in with their previous passwords. This is the simplest experience for the user. If this attribute is set to RESET_REQUIRED, the user is required to change his or her password immediately after migration at the time of sign-in, and your client app needs to handle the PasswordResetRequiredException @@ -333,7 +333,7 @@ class CustomMessageTriggerEvent(BaseTriggerEvent): verification code automatically to the user. Cannot be used for other attributes. - `CustomMessage_VerifyUserAttribute` This trigger sends a verification code to the user when they manually request it for a new email or phone number. - - `CustomMessage_Authentication` To send MFA code during authentication. + - `CustomMessage_Authentication` To send MFA codes during authentication. Documentation: -------------- @@ -590,7 +590,7 @@ def user_attributes(self) -> Dict[str, str]: @property def user_not_found(self) -> Optional[bool]: """A Boolean that is populated when PreventUserExistenceErrors is set to ENABLED for your user pool client. - A value of true means that the user id (user name, email address, etc.) did not match any existing users.""" + A value of true means that the user id (username, email address, etc.) did not match any existing users.""" return self["request"].get("userNotFound") @property @@ -601,7 +601,7 @@ def session(self) -> List[ChallengeResult]: @property def client_metadata(self) -> Optional[Dict[str, str]]: """One or more key-value pairs that you can provide as custom input to the Lambda function that you specify - for the define auth challenge trigger.""" + for the defined auth challenge trigger.""" return self["request"].get("clientMetadata") @@ -687,7 +687,7 @@ def session(self) -> List[ChallengeResult]: @property def client_metadata(self) -> Optional[Dict[str, str]]: """One or more key-value pairs that you can provide as custom input to the Lambda function that you - specify for the create auth challenge trigger.""" + specify for the creation auth challenge trigger.""" return self["request"].get("clientMetadata") @@ -699,7 +699,7 @@ def public_challenge_parameters(self) -> Dict[str, str]: @public_challenge_parameters.setter def public_challenge_parameters(self, value: Dict[str, str]): """One or more key-value pairs for the client app to use in the challenge to be presented to the user. - This parameter should contain all of the necessary information to accurately present the challenge to + This parameter should contain all the necessary information to accurately present the challenge to the user.""" self["response"]["publicChallengeParameters"] = value @@ -709,8 +709,8 @@ def private_challenge_parameters(self) -> Dict[str, str]: @private_challenge_parameters.setter def private_challenge_parameters(self, value: Dict[str, str]): - """This parameter is only used by the Verify Auth Challenge Response Lambda trigger. - This parameter should contain all of the information that is required to validate the user's + """This parameter is only used by the "Verify Auth Challenge" Response Lambda trigger. + This parameter should contain all the information that is required to validate the user's response to the challenge. In other words, the publicChallengeParameters parameter contains the question that is presented to the user and privateChallengeParameters contains the valid answers for the question.""" @@ -730,7 +730,7 @@ class CreateAuthChallengeTriggerEvent(BaseTriggerEvent): """Create Auth Challenge Lambda Trigger Amazon Cognito invokes this trigger after Define Auth Challenge if a custom challenge has been - specified as part of the Define Auth Challenge trigger. + specified as part of the "Define Auth Challenge" trigger. It creates a custom authentication flow. Notes: @@ -775,7 +775,7 @@ def challenge_answer(self) -> Any: @property def client_metadata(self) -> Optional[Dict[str, str]]: """One or more key-value pairs that you can provide as custom input to the Lambda function that - you specify for the verify auth challenge trigger.""" + you specify for the "Verify Auth Challenge" trigger.""" return self["request"].get("clientMetadata") @property diff --git a/aws_lambda_powertools/utilities/data_classes/dynamo_db_stream_event.py b/aws_lambda_powertools/utilities/data_classes/dynamo_db_stream_event.py index 01d892f9edc..7e209fab3e2 100644 --- a/aws_lambda_powertools/utilities/data_classes/dynamo_db_stream_event.py +++ b/aws_lambda_powertools/utilities/data_classes/dynamo_db_stream_event.py @@ -231,7 +231,7 @@ def aws_region(self) -> Optional[str]: @property def dynamodb(self) -> Optional[StreamRecord]: - """The main body of the stream record, containing all of the DynamoDB-specific fields.""" + """The main body of the stream record, containing all the DynamoDB-specific fields.""" stream_record = self.get("dynamodb") return None if stream_record is None else StreamRecord(stream_record) diff --git a/aws_lambda_powertools/utilities/data_classes/s3_object_event.py b/aws_lambda_powertools/utilities/data_classes/s3_object_event.py index b22434c68e3..d4f97b725bf 100644 --- a/aws_lambda_powertools/utilities/data_classes/s3_object_event.py +++ b/aws_lambda_powertools/utilities/data_classes/s3_object_event.py @@ -82,7 +82,7 @@ def get_header_value( default_value: str, optional Default value if no value was found by name case_sensitive: bool - Whether to use a case sensitive look up + Whether to use a case-sensitive look up Returns ------- str, optional @@ -128,7 +128,7 @@ def creation_date(self) -> str: @property def mfa_authenticated(self) -> str: """The value is true if the root user or IAM user whose credentials were used for the request also was - authenticated with an MFA device; otherwise, false..""" + authenticated with an MFA device; otherwise, false.""" return self["mfaAuthenticated"] diff --git a/aws_lambda_powertools/utilities/data_classes/sqs_event.py b/aws_lambda_powertools/utilities/data_classes/sqs_event.py index 57caeea4cc2..1b93a775bca 100644 --- a/aws_lambda_powertools/utilities/data_classes/sqs_event.py +++ b/aws_lambda_powertools/utilities/data_classes/sqs_event.py @@ -76,7 +76,7 @@ def data_type(self) -> str: class SQSMessageAttributes(Dict[str, SQSMessageAttribute]): def __getitem__(self, key: str) -> Optional[SQSMessageAttribute]: # type: ignore - item = super(SQSMessageAttributes, self).get(key) + item = super().get(key) return None if item is None else SQSMessageAttribute(item) # type: ignore