in aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py [0:0]
def asdict(self) -> Dict[str, Any]:
"""Generates the policy document based on the internal lists of allowed and denied
conditions. This will generate a policy with two main statements for the effect:
one statement for Allow and one statement for Deny.
Methods that includes conditions will have their own statement in the policy."""
if len(self._allow_routes) == 0 and len(self._deny_routes) == 0:
raise ValueError("No statements defined for the policy")
response: Dict[str, Any] = {
"principalId": self.principal_id,
"policyDocument": {"Version": "2012-10-17", "Statement": []},
}
response["policyDocument"]["Statement"].extend(self._get_statement_for_effect("Allow", self._allow_routes))
response["policyDocument"]["Statement"].extend(self._get_statement_for_effect("Deny", self._deny_routes))
if self.usage_identifier_key:
response["usageIdentifierKey"] = self.usage_identifier_key
if self.context:
response["context"] = self.context
return response