in samcli/local/events/api_event.py [0:0]
def to_dict(self) -> Dict[str, Any]:
"""
Constructs an dictionary representation of the ApiGatewayLambdaEvent Object to be used in serializing to JSON
Returns
-------
Dict[str, Any]
Dict representing the object
"""
request_context_dict = {}
if self.request_context:
request_context_dict = self.request_context.to_dict()
json_dict = {
"httpMethod": self.http_method,
"body": self.body if self.body else None,
"resource": self.resource,
"requestContext": request_context_dict,
"queryStringParameters": dict(self.query_string_params) if self.query_string_params else None,
"multiValueQueryStringParameters": (
dict(self.multi_value_query_string_params) if self.multi_value_query_string_params else None
),
"headers": dict(self.headers) if self.headers else None,
"multiValueHeaders": dict(self.multi_value_headers) if self.multi_value_headers else None,
"pathParameters": dict(self.path_parameters) if self.path_parameters else None,
"stageVariables": dict(self.stage_variables) if self.stage_variables else None,
"path": self.path,
"isBase64Encoded": self.is_base_64_encoded,
}
# v1 payloads and rest api payloads are identical save for the version field
if self.api_type == Route.HTTP:
json_dict["version"] = "1.0"
return json_dict