diff --git a/aws_lambda_powertools/utilities/typing/lambda_context.py b/aws_lambda_powertools/utilities/typing/lambda_context.py index e3ea837d4d5..49fb7044792 100644 --- a/aws_lambda_powertools/utilities/typing/lambda_context.py +++ b/aws_lambda_powertools/utilities/typing/lambda_context.py @@ -34,6 +34,7 @@ class LambdaContext: _aws_request_id: str _log_group_name: str _log_stream_name: str + _tenant_id: str | None = None _identity: LambdaCognitoIdentity _client_context: LambdaClientContext @@ -75,14 +76,19 @@ def log_stream_name(self) -> str: @property def identity(self) -> LambdaCognitoIdentity: - """(mobile apps) Information about the Amazon Cognito identity that authorized the request.""" + """Information about the Amazon Cognito identity that authorized the request.""" return self._identity @property def client_context(self) -> LambdaClientContext: - """(mobile apps) Client context that's provided to Lambda by the client application.""" + """Client context that's provided to Lambda by the client application.""" return self._client_context + @property + def tenant_id(self) -> str | None: + """The tenant_id""" + return self._tenant_id + @staticmethod def get_remaining_time_in_millis() -> int: """Returns the number of milliseconds left before the execution times out.""" diff --git a/docs/utilities/typing.md b/docs/utilities/typing.md index 5678bdf2527..bf80996600c 100644 --- a/docs/utilities/typing.md +++ b/docs/utilities/typing.md @@ -42,5 +42,18 @@ Using `LambdaContext` typing makes it possible to access information and hints o --8<-- "examples/typing/src/working_with_context_function.py" ``` -![Utilities Typing All](../media/utilities_typing_2.png) -![Utilities Typing Specific](../media/utilities_typing_3.png) +### Available properties and methods + +| Name | Type | Description | +| ------------------------------ | -------- | ------------------------------------------------------------------------- | +| `function_name` | property | The name of the Lambda function | +| `function_version` | property | The version of the function | +| `invoked_function_arn` | property | The Amazon Resource Name (ARN) that's used to invoke the function | +| `memory_limit_in_mb` | property | The amount of memory that's allocated for the function | +| `aws_request_id` | property | The identifier of the invocation request | +| `log_group_name` | property | The log group for the function | +| `log_stream_name` | property | The log stream for the function instance | +| `identity` | property | Information about the Amazon Cognito identity that authorized the request | +| `client_context` | property | Client context that's provided to Lambda by the client application | +| `tenant_id` | property | The tenant_id used to invoke the function | +| `get_remaining_time_in_millis` | method | Returns the number of milliseconds left before the execution times out | diff --git a/tests/functional/typing/required_dependencies/test_utilities_typing.py b/tests/functional/typing/required_dependencies/test_utilities_typing.py index 7d2a609fbf7..71dd8ddf531 100644 --- a/tests/functional/typing/required_dependencies/test_utilities_typing.py +++ b/tests/functional/typing/required_dependencies/test_utilities_typing.py @@ -19,6 +19,7 @@ def test_typing(): context._aws_request_id = "_aws_request_id" context._log_group_name = "_log_group_name" context._log_stream_name = "_log_stream_name" + context._tenant_id = "_tenant_id" identity = LambdaCognitoIdentity() identity._cognito_identity_id = "_cognito_identity_id" identity._cognito_identity_pool_id = "_cognito_identity_pool_id" @@ -42,6 +43,7 @@ def test_typing(): assert context.aws_request_id == context._aws_request_id assert context.log_group_name == context._log_group_name assert context.log_stream_name == context._log_stream_name + assert context.tenant_id == context._tenant_id assert context.identity == context._identity assert context.identity.cognito_identity_id == identity._cognito_identity_id assert context.identity.cognito_identity_pool_id == identity._cognito_identity_pool_id