Event Source Data Classes - Powertools for AWS Lambda (Python)
Skip to content Event Source Data Classes Base class for Event Source Data Classes Usage Documentation Data classes CLASS DESCRIPTION APIGatewayEventIdentity BaseProxyEvent BaseRequestContext BaseRequestContextV2 CaseInsensitiveDict Case insensitive dict implementation. Assumes string keys only. DictWrapper Provides a single read only access to a wrapper dict RequestContextClientCert RequestContextV2Http APIGatewayEventIdentity ¶ APIGatewayEventIdentity ( data : dict [ str , Any ], json_deserializer : Callable | None = None ) Bases: DictWrapper ATTRIBUTE DESCRIPTION account_id The AWS account ID associated with the request.
TYPE: str | None api_key For API methods that require an API key, this variable is the API key associated with the method request. TYPE: str | None api_key_id The API key ID associated with an API request that requires an API key. TYPE: str | None caller The principal identifier of the caller making the request. TYPE: str | None cognito_authentication_provider A comma-separated list of the Amazon Cognito authentication providers used by the caller TYPE: str | None cognito_authentication_type The Amazon Cognito authentication type of the caller making the request.
TYPE: str | None cognito_identity_id The Amazon Cognito identity ID of the caller making the request. TYPE: str | None cognito_identity_pool_id The Amazon Cognito identity pool ID of the caller making the request. TYPE: str | None principal_org_id The AWS organization ID. TYPE: str | None source_ip The source IP address of the TCP connection making the request to API Gateway. TYPE: str user The principal identifier of the user making the request.
TYPE: str | None user_agent The User Agent of the API caller. TYPE: str | None user_arn The Amazon Resource Name (ARN) of the effective user identified after authentication. TYPE: str | None Source code in aws_lambda_powertools/utilities/data_classes/common.py 116 117 118 119 120 121 122 123 124 125 126 127 def __init__ ( self , data : dict [ str , Any ], json_deserializer : Callable | None = None ): """ Parameters ---------- data : dict[str, Any] Lambda Event Source Event payload json_deserializer : Callable, optional function to deserialize `str`, `bytes`, `bytearray` containing a JSON document to a Python `obj`, by default json.loads """ self . _data = data self . _json_deserializer = json_deserializer or json . loads account_id property ¶ account_id : str | None The AWS account ID associated with the request. api_key property ¶ api_key : str | None For API methods that require an API key, this variable is the API key associated with the method request.
For methods that don't require an API key, this variable is null. api_key_id property ¶ api_key_id : str | None The API key ID associated with an API request that requires an API key. caller property ¶ caller : str | None The principal identifier of the caller making the request. cognito_authentication_provider property ¶ cognito_authentication_provider : str | None A comma-separated list of the Amazon Cognito authentication providers used by the caller making the request.
Available only if the request was signed with Amazon Cognito credentials. cognito_authentication_type property ¶ cognito_authentication_type : str | None The Amazon Cognito authentication type of the caller making the request. Available only if the request was signed with Amazon Cognito credentials. cognito_identity_id property ¶ cognito_identity_id : str | None The Amazon Cognito identity ID of the caller making the request.
Available only if the request was signed with Amazon Cognito credentials. cognito_identity_pool_id property ¶ cognito_identity_pool_id : str | None The Amazon Cognito identity pool ID of the caller making the request. Available only if the request was signed with Amazon Cognito credentials. principal_org_id property ¶ principal_org_id : str | None The AWS organization ID. source_ip property ¶ source_ip : str The source IP address of the TCP connection making the request to API Gateway. user property ¶ user : str | None The principal identifier of the user making the request. user_agent property ¶ user_agent : str | None The User Agent of the API caller. user_arn property ¶ user_arn : str | None The Amazon Resource Name (ARN) of the effective user identified after authentication.
BaseProxyEvent ¶ BaseProxyEvent ( data : dict [ str , Any ], json_deserializer : Callable | None = None ) Bases: DictWrapper METHOD DESCRIPTION get_header_value Get header value by name get_multi_value_query_string_values Get multi-value query string parameter values by name get_query_string_value Get query string value by name ATTRIBUTE DESCRIPTION body Submitted body of the request as a string TYPE: str | None decoded_body Decode the body from base64 if encoded, otherwise return it as is.
TYPE: str | None http_method The HTTP method used. Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT. TYPE: str json_body Parses the submitted body as json TYPE: Any resolved_cookies_field This property extracts cookies from the request as a dict of name-value pairs. TYPE: dict [ str , str ] resolved_headers_field This property determines the appropriate header to be used TYPE: dict [ str , str ] resolved_query_string_parameters This property determines the appropriate query string parameter to be used TYPE: dict [ str , list [ str ]] Source code in aws_lambda_powertools/utilities/data_classes/common.py 116 117 118 119 120 121 122 123 124 125 126 127 def __init__ ( self , data : dict [ str , Any ], json_deserializer : Callable | None = None ): """ Parameters ---------- data : dict[str, Any] Lambda Event Source Event payload json_deserializer : Callable, optional function to deserialize `str`, `bytes`, `bytearray` containing a JSON document to a Python `obj`, by default json.loads """ self . _data = data self . _json_deserializer = json_deserializer or json . loads body property ¶ body : str | None Submitted body of the request as a string decoded_body cached property ¶ decoded_body : str | None Decode the body from base64 if encoded, otherwise return it as is. http_method property ¶ http_method : str The HTTP method used.
Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT. json_body cached property ¶ json_body : Any Parses the submitted body as json resolved_cookies_field property ¶ resolved_cookies_field : dict [ str , str ] This property extracts cookies from the request as a dict of name-value pairs. By default, cookies are parsed from the Cookie header. Uses self.headers (CaseInsensitiveDict) first for reliable case-insensitive lookup, then falls back to resolved_headers_field for proxies that only populate multi-value headers (e.g., ALB without single-value headers).
Subclasses may override this for event formats that provide cookies in a dedicated field (e.g., API Gateway HTTP API v2). resolved_headers_field property ¶ resolved_headers_field : dict [ str , str ] This property determines the appropriate header to be used as a trusted source for validating OpenAPI. This is necessary because different resolvers use different formats to encode headers parameters. Headers are case-insensitive according to RFC 7540 (HTTP/2), so we lower the header name This ensures that customers can access headers with any casing, as per the RFC guidelines.
Reference: https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2 resolved_query_string_parameters property ¶ resolved_query_string_parameters : dict [ str , list [ str ]] This property determines the appropriate query string parameter to be used as a trusted source for validating OpenAPI. This is necessary because different resolvers use different formats to encode multi query string parameters. get_header_value ¶ get_header_value ( name : str , default_value : str , case_sensitive : bool = False ) -> str get_header_value ( name : str , default_value : str | None = None , case_sensitive : bool = False ) -> str | None get_head
The rest of this page is on the live site.