@@ -61,63 +61,78 @@ def parse_api_gateway_arn(arn: str) -> APIGatewayRouteArn:
61
61
)
62
62
63
63
64
- class APIGatewayAuthorizerV2Event (DictWrapper ):
65
- """API Gateway Authorizer Event Format 2.0
64
+ class APIGatewayAuthorizerTokenEvent (DictWrapper ):
65
+ """API Gateway Authorizer Token Event Format 1.0
66
+
67
+ Documentation:
68
+ -------------
69
+ - https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
70
+ """
71
+
72
+ @property
73
+ def get_type (self ) -> str :
74
+ return self ["type" ]
75
+
76
+ @property
77
+ def authorization_token (self ) -> str :
78
+ return self ["authorizationToken" ]
79
+
80
+ @property
81
+ def method_arn (self ) -> str :
82
+ """ARN of the incoming method request and is populated by API Gateway in accordance with the Lambda authorizer
83
+ configuration"""
84
+ return self ["methodArn" ]
85
+
86
+ @property
87
+ def parsed_arn (self ) -> APIGatewayRouteArn :
88
+ """Convenient property to return a parsed api gateway method arn"""
89
+ return parse_api_gateway_arn (self .method_arn )
90
+
91
+
92
+ class APIGatewayAuthorizerRequestEvent (DictWrapper ):
93
+ """API Gateway Authorizer Request Event Format 1.0
66
94
67
95
Documentation:
68
96
-------------
97
+ - https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
69
98
- https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html
70
99
"""
71
100
72
101
@property
73
102
def version (self ) -> str :
74
- """Event payload version should always be 2.0"""
75
103
return self ["version" ]
76
104
77
105
@property
78
106
def get_type (self ) -> str :
79
- """Event type should always be request"""
80
107
return self ["type" ]
81
108
82
109
@property
83
- def route_arn (self ) -> str :
84
- """ARN of the route being called
85
-
86
- eg: arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request"""
87
- return self ["routeArn" ]
110
+ def method_arn (self ) -> str :
111
+ return self ["methodArn" ]
88
112
89
113
@property
90
114
def parsed_arn (self ) -> APIGatewayRouteArn :
91
- """Convenient property to return a parsed api gateway route arn"""
92
- return parse_api_gateway_arn (self .route_arn )
115
+ return parse_api_gateway_arn (self .method_arn )
93
116
94
117
@property
95
- def identity_source (self ) -> Optional [List [str ]]:
96
- """The identity source for which authorization is requested.
97
-
98
- For a REQUEST authorizer, this is optional. The value is a set of one or more mapping expressions of the
99
- specified request parameters. The identity source can be headers, query string parameters, stage variables,
100
- and context parameters.
101
- """
102
- return self .get ("identitySource" )
118
+ def identity_source (self ) -> str :
119
+ return self ["identitySource" ]
103
120
104
121
@property
105
- def route_key (self ) -> str :
106
- """The route key for the route. For HTTP APIs, the route key can be either $default,
107
- or a combination of an HTTP method and resource path, for example, GET /pets."""
108
- return self ["routeKey" ]
122
+ def authorization_token (self ) -> str :
123
+ return self ["authorizationToken" ]
109
124
110
125
@property
111
- def raw_path (self ) -> str :
112
- return self ["rawPath " ]
126
+ def resource (self ) -> str :
127
+ return self ["resource " ]
113
128
114
129
@property
115
- def raw_query_string (self ) -> str :
116
- return self ["rawQueryString " ]
130
+ def path (self ) -> str :
131
+ return self ["path " ]
117
132
118
133
@property
119
- def cookies (self ) -> List [ str ] :
120
- return self ["cookies " ]
134
+ def http_method (self ) -> str :
135
+ return self ["httpMethod " ]
121
136
122
137
@property
123
138
def headers (self ) -> Dict [str , str ]:
@@ -128,16 +143,16 @@ def query_string_parameters(self) -> Dict[str, str]:
128
143
return self ["queryStringParameters" ]
129
144
130
145
@property
131
- def request_context (self ) -> BaseRequestContextV2 :
132
- return BaseRequestContextV2 ( self . _data )
146
+ def path_parameters (self ) -> Dict [ str , str ] :
147
+ return self [ "pathParameters" ]
133
148
134
149
@property
135
- def path_parameters (self ) -> Optional [ Dict [str , str ] ]:
136
- return self . get ( "pathParameters" )
150
+ def stage_variables (self ) -> Dict [str , str ]:
151
+ return self [ "stageVariables" ]
137
152
138
153
@property
139
- def stage_variables (self ) -> Optional [ Dict [ str , str ]] :
140
- return self .get ( "stageVariables" )
154
+ def request_context (self ) -> BaseRequestContext :
155
+ return BaseRequestContext ( self ._data )
141
156
142
157
def get_header_value (
143
158
self , name : str , default_value : Optional [str ] = None , case_sensitive : Optional [bool ] = False
@@ -160,78 +175,64 @@ def get_header_value(
160
175
return get_header_value (self .headers , name , default_value , case_sensitive )
161
176
162
177
163
- class APIGatewayAuthorizerTokenEvent (DictWrapper ):
164
- """API Gateway Authorizer Token Event Format 1.0
165
-
166
- Documentation:
167
- -------------
168
- - https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
169
- """
170
-
171
- @property
172
- def get_type (self ) -> str :
173
- return self ["type" ]
174
-
175
- @property
176
- def authorization_token (self ) -> str :
177
- return self ["authorizationToken" ]
178
-
179
- @property
180
- def method_arn (self ) -> str :
181
- """ARN of the incoming method request and is populated by API Gateway in accordance with the Lambda authorizer
182
- configuration"""
183
- return self ["methodArn" ]
184
-
185
- @property
186
- def parsed_arn (self ) -> APIGatewayRouteArn :
187
- """Convenient property to return a parsed api gateway method arn"""
188
- return parse_api_gateway_arn (self .method_arn )
189
-
190
-
191
- class APIGatewayAuthorizerRequestEvent (DictWrapper ):
192
- """API Gateway Authorizer Request Event Format 1.0
178
+ class APIGatewayAuthorizerEventV2 (DictWrapper ):
179
+ """API Gateway Authorizer Event Format 2.0
193
180
194
181
Documentation:
195
182
-------------
196
- - https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
197
183
- https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html
184
+ - https://aws.amazon.com/blogs/compute/introducing-iam-and-lambda-authorizers-for-amazon-api-gateway-http-apis/
198
185
"""
199
186
200
187
@property
201
188
def version (self ) -> str :
189
+ """Event payload version should always be 2.0"""
202
190
return self ["version" ]
203
191
204
192
@property
205
193
def get_type (self ) -> str :
194
+ """Event type should always be request"""
206
195
return self ["type" ]
207
196
208
197
@property
209
- def method_arn (self ) -> str :
210
- return self ["methodArn" ]
198
+ def route_arn (self ) -> str :
199
+ """ARN of the route being called
200
+
201
+ eg: arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request"""
202
+ return self ["routeArn" ]
211
203
212
204
@property
213
205
def parsed_arn (self ) -> APIGatewayRouteArn :
214
- return parse_api_gateway_arn (self .method_arn )
206
+ """Convenient property to return a parsed api gateway route arn"""
207
+ return parse_api_gateway_arn (self .route_arn )
215
208
216
209
@property
217
- def identity_source (self ) -> str :
218
- return self ["identitySource" ]
210
+ def identity_source (self ) -> Optional [List [str ]]:
211
+ """The identity source for which authorization is requested.
212
+
213
+ For a REQUEST authorizer, this is optional. The value is a set of one or more mapping expressions of the
214
+ specified request parameters. The identity source can be headers, query string parameters, stage variables,
215
+ and context parameters.
216
+ """
217
+ return self .get ("identitySource" )
219
218
220
219
@property
221
- def authorization_token (self ) -> str :
222
- return self ["authorizationToken" ]
220
+ def route_key (self ) -> str :
221
+ """The route key for the route. For HTTP APIs, the route key can be either $default,
222
+ or a combination of an HTTP method and resource path, for example, GET /pets."""
223
+ return self ["routeKey" ]
223
224
224
225
@property
225
- def resource (self ) -> str :
226
- return self ["resource " ]
226
+ def raw_path (self ) -> str :
227
+ return self ["rawPath " ]
227
228
228
229
@property
229
- def path (self ) -> str :
230
- return self ["path " ]
230
+ def raw_query_string (self ) -> str :
231
+ return self ["rawQueryString " ]
231
232
232
233
@property
233
- def http_method (self ) -> str :
234
- return self ["httpMethod " ]
234
+ def cookies (self ) -> List [ str ] :
235
+ return self ["cookies " ]
235
236
236
237
@property
237
238
def headers (self ) -> Dict [str , str ]:
@@ -242,16 +243,16 @@ def query_string_parameters(self) -> Dict[str, str]:
242
243
return self ["queryStringParameters" ]
243
244
244
245
@property
245
- def path_parameters (self ) -> Dict [ str , str ] :
246
- return self [ "pathParameters" ]
246
+ def request_context (self ) -> BaseRequestContextV2 :
247
+ return BaseRequestContextV2 ( self . _data )
247
248
248
249
@property
249
- def stage_variables (self ) -> Dict [str , str ]:
250
- return self [ "stageVariables" ]
250
+ def path_parameters (self ) -> Optional [ Dict [str , str ] ]:
251
+ return self . get ( "pathParameters" )
251
252
252
253
@property
253
- def request_context (self ) -> BaseRequestContext :
254
- return BaseRequestContext ( self ._data )
254
+ def stage_variables (self ) -> Optional [ Dict [ str , str ]] :
255
+ return self .get ( "stageVariables" )
255
256
256
257
def get_header_value (
257
258
self , name : str , default_value : Optional [str ] = None , case_sensitive : Optional [bool ] = False
@@ -274,7 +275,7 @@ def get_header_value(
274
275
return get_header_value (self .headers , name , default_value , case_sensitive )
275
276
276
277
277
- class APIGatewayAuthorizerV2Response :
278
+ class APIGatewayAuthorizerResponseV2 :
278
279
"""Api Gateway HTTP API V2 payload authorizer simple response helper
279
280
280
281
Parameters
0 commit comments