8
8
from localstack .aws .api .apigateway import Method , Resource
9
9
from localstack .services .apigateway .models import RestApiDeployment
10
10
11
+ from .variables import ContextVariables , LoggingContextVariables
12
+
11
13
12
14
class InvocationRequest (TypedDict , total = False ):
13
15
http_method : Optional [HTTPMethod ]
@@ -33,55 +35,21 @@ class InvocationRequest(TypedDict, total=False):
33
35
"""Body content of the request"""
34
36
35
37
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
38
+ class IntegrationRequest (TypedDict , total = False ):
39
+ http_method : Optional [HTTPMethod ]
40
+ """HTTP Method of the incoming request"""
41
+ uri : Optional [str ]
42
+ """URI of the integration"""
43
+ query_string_parameters : Optional [dict [str , str ]]
44
+ """Query string parameters of the request"""
45
+ headers : Optional [dict [str , str ]]
46
+ """Headers of the request"""
47
+ multi_value_query_string_parameters : Optional [dict [str , list [str ]]]
48
+ """Multi value query string parameters of the request"""
49
+ multi_value_headers : Optional [dict [str , list [str ]]]
50
+ """Multi value headers of the request"""
51
+ body : Optional [bytes ]
52
+ """Body content of the request"""
85
53
86
54
87
55
class RestApiInvocationContext (RequestContext ):
@@ -97,6 +65,8 @@ class RestApiInvocationContext(RequestContext):
97
65
"""The REST API identifier of the invoked API"""
98
66
stage : Optional [str ]
99
67
"""The REST API stage linked to this invocation"""
68
+ deployment_id : Optional [str ]
69
+ """The REST API deployment linked to this invocation"""
100
70
region : Optional [str ]
101
71
"""The region the REST API is living in."""
102
72
account_id : Optional [str ]
@@ -105,17 +75,27 @@ class RestApiInvocationContext(RequestContext):
105
75
"""The resource the invocation matched""" # TODO: verify if needed through the invocation
106
76
resource_method : Optional [Method ]
107
77
"""The method of the resource the invocation matched"""
78
+ stage_variables : Optional [dict [str , str ]]
79
+ """The Stage variables, also used in parameters mapping and mapping templates"""
108
80
context_variables : Optional [ContextVariables ]
109
- """Variables can be used in data models, authorizers, mapping templates, and CloudWatch access logging."""
81
+ """The $context used in data models, authorizers, mapping templates, and CloudWatch access logging"""
82
+ logging_context_variables : Optional [LoggingContextVariables ]
83
+ """Additional $context variables available only for access logging, not yet implemented"""
84
+ integration_request : Optional [IntegrationRequest ]
85
+ """Contains the data needed to construct an HTTP request to an Integration"""
110
86
111
87
def __init__ (self , request : Request ):
112
88
super ().__init__ (request )
113
89
self .deployment = None
114
90
self .api_id = None
115
91
self .stage = None
92
+ self .deployment_id = None
116
93
self .account_id = None
117
94
self .region = None
118
95
self .invocation_request = None
119
96
self .resource = None
120
97
self .resource_method = None
98
+ self .stage_variables = None
121
99
self .context_variables = None
100
+ self .logging_context_variables = None
101
+ self .integration_request = None
0 commit comments