Event Source Data Classes
Base class for Event Source Data Classes
Usage Documentation
| 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:
|
api_key |
For API methods that require an API key, this variable is the API key associated with the method request.
TYPE:
|
api_key_id |
The API key ID associated with an API request that requires an API key.
TYPE:
|
caller |
The principal identifier of the caller making the request.
TYPE:
|
cognito_authentication_provider |
A comma-separated list of the Amazon Cognito authentication providers used by the caller
TYPE:
|
cognito_authentication_type |
The Amazon Cognito authentication type of the caller making the request.
TYPE:
|
cognito_identity_id |
The Amazon Cognito identity ID of the caller making the request.
TYPE:
|
cognito_identity_pool_id |
The Amazon Cognito identity pool ID of the caller making the request.
TYPE:
|
principal_org_id |
The AWS organization ID.
TYPE:
|
source_ip |
The source IP address of the TCP connection making the request to API Gateway.
TYPE:
|
user |
The principal identifier of the user making the request.
TYPE:
|
user_agent |
The User Agent of the API caller.
TYPE:
|
user_arn |
The Amazon Resource Name (ARN) of the effective user identified after authentication.
TYPE:
|
Source code in aws_lambda_powertools/utilities/data_classes/common.py
116 117 118 119 120 121 122 123 124 125 126 127 | |
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.
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.
source_ip
property
¶
source_ip: str
The source IP address of the TCP connection making the request to API Gateway.
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:
|
decoded_body |
Decode the body from base64 if encoded, otherwise return it as is.
TYPE:
|
http_method |
The HTTP method used. Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.
TYPE:
|
json_body |
Parses the submitted body as json
TYPE:
|
resolved_cookies_field |
This property extracts cookies from the request as a dict of name-value pairs. |
resolved_headers_field |
This property determines the appropriate header to be used |
resolved_query_string_parameters |
This property determines the appropriate query string parameter to be used |
Source code in aws_lambda_powertools/utilities/data_classes/common.py
116 117 118 119 120 121 122 123 124 125 126 127 | |
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.
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_header_value(name: str, default_value: str | None = None, case_sensitive: bool = False) -> str | None
Get header value by name
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Header name
TYPE:
|
default_value
|
Default value if no value was found by name
TYPE:
|
case_sensitive
|
Whether to use a case-sensitive look up. By default we make a case-insensitive lookup.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
(str, optional)
|
Header value |
Source code in aws_lambda_powertools/utilities/data_classes/common.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
get_multi_value_query_string_values ¶
get_multi_value_query_string_values(name: str, default_values: list[str] | None = None) -> list[str]
Get multi-value query string parameter values by name
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Multi-Value query string parameter name
TYPE:
|
default_values
|
Default values is no values are found by name |
| RETURNS | DESCRIPTION |
|---|---|
(List[str], optional)
|
List of query string values |
Source code in aws_lambda_powertools/utilities/data_classes/common.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
get_query_string_value ¶
get_query_string_value(name: str, default_value: str) -> str
get_query_string_value(name: str, default_value: str | None = None) -> str | None
get_query_string_value(name: str, default_value: str | None = None) -> str | None
Get query string value by name
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Query string parameter name
TYPE:
|
default_value
|
Default value if no value was found by name
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
(str, optional)
|
Query string parameter value |
Source code in aws_lambda_powertools/utilities/data_classes/common.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
BaseRequestContext ¶
BaseRequestContext(data: dict[str, Any], json_deserializer: Callable | None = None)
Bases: DictWrapper
| ATTRIBUTE | DESCRIPTION |
|---|---|
account_id |
The AWS account ID associated with the request.
TYPE:
|
api_id |
The identifier API Gateway assigns to your API.
TYPE:
|
domain_name |
A domain name
TYPE:
|
extended_request_id |
An automatically generated ID for the API call, which contains more useful information
TYPE:
|
http_method |
The HTTP method used. Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.
TYPE:
|
protocol |
The request protocol, for example, HTTP/1.1.
TYPE:
|
request_id |
The ID that API Gateway assigns to the API request.
TYPE:
|
request_time |
The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm)
TYPE:
|
request_time_epoch |
The Epoch-formatted request time.
TYPE:
|
stage |
The deployment stage of the API request
TYPE:
|
Source code in aws_lambda_powertools/utilities/data_classes/common.py
116 117 118 119 120 121 122 123 124 125 126 127 | |
extended_request_id
property
¶
extended_request_id: str | None
An automatically generated ID for the API call, which contains more useful information for debugging/troubleshooting.
http_method
property
¶
http_method: str
The HTTP method used. Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.
request_time
property
¶
request_time: str | None
The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm)
BaseRequestContextV2 ¶
BaseRequestContextV2(data: dict[str, Any], json_deserializer: Callable | None = None)
Bases: DictWrapper
| ATTRIBUTE | DESCRIPTION |
|---|---|
account_id |
The AWS account ID associated with the request.
TYPE:
|
api_id |
The identifier API Gateway assigns to your API.
TYPE:
|
authentication |
Optional when using mutual TLS authentication
TYPE:
|
domain_name |
A domain name
TYPE:
|
request_id |
The ID that API Gateway assigns to the API request.
TYPE:
|
route_key |
The selected route key.
TYPE:
|
stage |
The deployment stage of the API request
TYPE:
|
time |
The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm).
TYPE:
|
time_epoch |
The Epoch-formatted request time.
TYPE:
|
Source code in aws_lambda_powertools/utilities/data_classes/common.py
116 117 118 119 120 121 122 123 124 125 126 127 | |
authentication
property
¶
authentication: RequestContextClientCert | None
Optional when using mutual TLS authentication
CaseInsensitiveDict ¶
CaseInsensitiveDict(data=None, **kwargs)
Bases: dict
Case insensitive dict implementation. Assumes string keys only.
Source code in aws_lambda_powertools/utilities/data_classes/common.py
46 47 48 | |
DictWrapper ¶
DictWrapper(data: dict[str, Any], json_deserializer: Callable | None = None)
Bases: Mapping
Provides a single read only access to a wrapper dict
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
| ATTRIBUTE | DESCRIPTION |
|---|---|
raw_event |
The original raw event dict |
Source code in aws_lambda_powertools/utilities/data_classes/common.py
116 117 118 119 120 121 122 123 124 125 126 127 | |
RequestContextClientCert ¶
RequestContextClientCert(data: dict[str, Any], json_deserializer: Callable | None = None)
Bases: DictWrapper
| ATTRIBUTE | DESCRIPTION |
|---|---|
client_cert_pem |
Client certificate pem
TYPE:
|
issuer_dn |
Issuer Distinguished Name
TYPE:
|
serial_number |
Unique serial number for client cert
TYPE:
|
subject_dn |
Subject Distinguished Name
TYPE:
|
validity_not_after |
Date when the cert is no longer valid
TYPE:
|
validity_not_before |
Cert is not valid before this date
TYPE:
|
Source code in aws_lambda_powertools/utilities/data_classes/common.py
116 117 118 119 120 121 122 123 124 125 126 127 | |
RequestContextV2Http ¶
RequestContextV2Http(data: dict[str, Any], json_deserializer: Callable | None = None)
Bases: DictWrapper
| ATTRIBUTE | DESCRIPTION |
|---|---|
protocol |
The request protocol, for example, HTTP/1.1.
TYPE:
|
source_ip |
The source IP address of the TCP connection making the request to API Gateway.
TYPE:
|
user_agent |
The User Agent of the API caller.
TYPE:
|
Source code in aws_lambda_powertools/utilities/data_classes/common.py
116 117 118 119 120 121 122 123 124 125 126 127 | |