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
75 76 77 78 79 80 81 82 83 84 85 86 |
|
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_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
75 76 77 78 79 80 81 82 83 84 85 86 |
|
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_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
cached
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
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
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
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
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
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
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
75 76 77 78 79 80 81 82 83 84 85 86 |
|
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
75 76 77 78 79 80 81 82 83 84 85 86 |
|
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
32 33 34 |
|
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
75 76 77 78 79 80 81 82 83 84 85 86 |
|
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
75 76 77 78 79 80 81 82 83 84 85 86 |
|
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
75 76 77 78 79 80 81 82 83 84 85 86 |
|