@@ -33,6 +33,57 @@ class InvocationRequest(TypedDict, total=False):
33
33
"""Body content of the request"""
34
34
35
35
36
+ class AuthorizerContext (TypedDict , total = False ):
37
+ # https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
38
+ claims : Optional [dict [str , str ]]
39
+ """Claims returned from the Amazon Cognito user pool after the method caller is successfully authenticated"""
40
+ principal_id : Optional [str ]
41
+ """The principal user identification associated with the token sent by the client and returned from an API Gateway Lambda authorizer"""
42
+ context : Optional [dict [str , str ]]
43
+ """The stringified value of the specified key-value pair of the context map returned from an API Gateway Lambda authorizer function"""
44
+
45
+
46
+ class IdentityContext (TypedDict , total = False ):
47
+ # https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
48
+ accountId : Optional [str ]
49
+ """The AWS account ID associated with the request."""
50
+ apiKey : Optional [str ]
51
+ """For API methods that require an API key, this variable is the API key associated with the method request."""
52
+ apiKeyId : Optional [str ]
53
+ """The API key ID associated with an API request that requires an API key."""
54
+ caller : Optional [str ]
55
+ """The principal identifier of the caller that signed the request. Supported for resources that use IAM authorization."""
56
+ cognitoAuthenticationProvider : Optional [str ]
57
+ """A comma-separated list of the Amazon Cognito authentication providers used by the caller making the request"""
58
+ cognitoAuthenticationType : Optional [str ]
59
+ """The Amazon Cognito authentication type of the caller making the request"""
60
+ cognitoIdentityId : Optional [str ]
61
+ """The Amazon Cognito identity ID of the caller making the request"""
62
+ cognitoIdentityPoolId : Optional [str ]
63
+ """The Amazon Cognito identity pool ID of the caller making the request"""
64
+ principalOrgId : Optional [str ]
65
+ """The AWS organization ID."""
66
+ sourceIp : Optional [str ]
67
+ """The source IP address of the immediate TCP connection making the request to the API Gateway endpoint"""
68
+ clientCert : Optional [dict [str , str ]]
69
+ """Certificate that a client presents. Present only in access logs if mutual TLS authentication fails."""
70
+ vpcId : Optional [str ]
71
+ """The VPC ID of the VPC making the request to the API Gateway endpoint."""
72
+ vpceId : Optional [str ]
73
+ """The VPC endpoint ID of the VPC endpoint making the request to the API Gateway endpoint."""
74
+ user : Optional [str ]
75
+ """The principal identifier of the user that will be authorized against resource access for resources that use IAM authorization."""
76
+ userAgent : Optional [str ]
77
+ """The User-Agent header of the API caller."""
78
+ userArn : Optional [str ]
79
+ """The Amazon Resource Name (ARN) of the effective user identified after authentication."""
80
+
81
+
82
+ class ContextVariables (TypedDict , total = False ):
83
+ authorizer : AuthorizerContext
84
+ identity : IdentityContext
85
+
86
+
36
87
class RestApiInvocationContext (RequestContext ):
37
88
"""
38
89
This context is going to be used to pass relevant information across an API Gateway invocation.
@@ -54,6 +105,8 @@ class RestApiInvocationContext(RequestContext):
54
105
"""The resource the invocation matched""" # TODO: verify if needed through the invocation
55
106
resource_method : Optional [Method ]
56
107
"""The method of the resource the invocation matched"""
108
+ context_variables : Optional [ContextVariables ]
109
+ """Variables can be used in data models, authorizers, mapping templates, and CloudWatch access logging."""
57
110
58
111
def __init__ (self , request : Request ):
59
112
super ().__init__ (request )
@@ -65,3 +118,4 @@ def __init__(self, request: Request):
65
118
self .invocation_request = None
66
119
self .resource = None
67
120
self .resource_method = None
121
+ self .context_variables = None
0 commit comments