in aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py [0:0]
def _get_statement_for_effect(self, effect: str, routes: List[Dict]) -> List[Dict]:
"""This function loops over an array of objects containing a `resourceArn` and
`conditions` statement and generates the array of statements for the policy."""
if not routes:
return []
statements: List[Dict] = []
statement = self._get_empty_statement(effect)
for route in routes:
resource_arn = route["resourceArn"]
conditions = route.get("conditions")
if conditions is not None and len(conditions) > 0:
conditional_statement = self._get_empty_statement(effect)
conditional_statement["Resource"].append(resource_arn)
conditional_statement["Condition"] = conditions
statements.append(conditional_statement)
else:
statement["Resource"].append(resource_arn)
if len(statement["Resource"]) > 0:
statements.append(statement)
return statements