in aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py [0:0]
def _add_route(self, effect: str, http_method: str, resource: str, conditions: Optional[List[Dict]] = None):
"""Adds a route to the internal lists of allowed or denied routes. Each object in
the internal list contains a resource ARN and a condition statement. The condition
statement can be null."""
if http_method != "*" and http_method not in HttpVerb.__members__:
allowed_values = [verb.value for verb in HttpVerb]
raise ValueError(f"Invalid HTTP verb: '{http_method}'. Use either '{allowed_values}'")
if not self._resource_pattern.match(resource):
raise ValueError(f"Invalid resource path: {resource}. Path should match {self.path_regex}")
resource_arn = APIGatewayRouteArn(
self.region, self.aws_account_id, self.api_id, self.stage, http_method, resource
).arn
route = {"resourceArn": resource_arn, "conditions": conditions}
if effect.lower() == "allow":
self._allow_routes.append(route)
else: # deny
self._deny_routes.append(route)