@@ -340,10 +340,15 @@ class HttpVerb(enum.Enum):
340
340
341
341
342
342
class APIGatewayAuthorizerResponse :
343
- """Api Gateway HTTP API V1 payload or Rest api authorizer response helper
343
+ """The IAM Policy Response required for API Gateway REST APIs and HTTP APIs.
344
344
345
345
Based on: - https://github.com/awslabs/aws-apigateway-lambda-authorizer-blueprints/blob/\
346
346
master/blueprints/python/api-gateway-authorizer-python.py
347
+
348
+ Documentation:
349
+ -------------
350
+ - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html
351
+ - https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html
347
352
"""
348
353
349
354
version = "2012-10-17"
@@ -360,6 +365,7 @@ def __init__(
360
365
api_id : str ,
361
366
stage : str ,
362
367
context : Optional [Dict ] = None ,
368
+ usage_identifier_key : Optional [str ] = None ,
363
369
):
364
370
"""
365
371
Parameters
@@ -388,13 +394,18 @@ def __init__(
388
394
context : Dict, optional
389
395
Optional, context.
390
396
Note: only names of type string and values of type int, string or boolean are supported
397
+ usage_identifier_key: str, optional
398
+ If the API uses a usage plan (the apiKeySource is set to `AUTHORIZER`), the Lambda authorizer function
399
+ must return one of the usage plan's API keys as the usageIdentifierKey property value.
400
+ > **Note:** This only applies for REST APIs.
391
401
"""
402
+ self .principal_id = principal_id
392
403
self .region = region
393
404
self .aws_account_id = aws_account_id
394
405
self .api_id = api_id
395
406
self .stage = stage
396
- self .principal_id = principal_id
397
407
self .context = context
408
+ self .usage_identifier_key = usage_identifier_key
398
409
self ._allow_routes : List [Dict ] = []
399
410
self ._deny_routes : List [Dict ] = []
400
411
@@ -506,6 +517,9 @@ def asdict(self) -> Dict[str, Any]:
506
517
response ["policyDocument" ]["Statement" ].extend (self ._get_statement_for_effect ("Allow" , self ._allow_routes ))
507
518
response ["policyDocument" ]["Statement" ].extend (self ._get_statement_for_effect ("Deny" , self ._deny_routes ))
508
519
520
+ if self .usage_identifier_key :
521
+ response ["usageIdentifierKey" ] = self .usage_identifier_key
522
+
509
523
if self .context :
510
524
response ["context" ] = self .context
511
525
0 commit comments