1use crate::{
2 custom_serde::{
3 deserialize_headers, deserialize_lambda_map, deserialize_nullish_boolean, http_method, serialize_headers,
4 serialize_multi_value_headers,
5 },
6 encodings::Body,
7 iam::IamPolicyStatement,
8};
9use http::{HeaderMap, Method};
10use query_map::QueryMap;
11use serde::{de::DeserializeOwned, ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
12use serde_json::Value;
13use std::collections::HashMap;
14
15#[non_exhaustive]
17#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
18#[serde(rename_all = "camelCase")]
19pub struct ApiGatewayProxyRequest {
20 #[serde(default)]
22 pub resource: Option<String>,
23 #[serde(default)]
25 pub path: Option<String>,
26 #[serde(with = "http_method")]
27 pub http_method: Method,
28 #[serde(deserialize_with = "deserialize_headers", default)]
29 #[serde(serialize_with = "serialize_headers")]
30 pub headers: HeaderMap,
31 #[serde(deserialize_with = "deserialize_headers", default)]
32 #[serde(serialize_with = "serialize_multi_value_headers")]
33 pub multi_value_headers: HeaderMap,
34 #[serde(default, deserialize_with = "query_map::serde::standard::deserialize_empty")]
35 #[serde(serialize_with = "query_map::serde::aws_api_gateway_v1::serialize_query_string_parameters")]
36 pub query_string_parameters: QueryMap,
37 #[serde(default, deserialize_with = "query_map::serde::standard::deserialize_empty")]
38 pub multi_value_query_string_parameters: QueryMap,
39 #[serde(deserialize_with = "deserialize_lambda_map")]
40 #[serde(default)]
41 pub path_parameters: HashMap<String, String>,
42 #[serde(deserialize_with = "deserialize_lambda_map")]
43 #[serde(default)]
44 pub stage_variables: HashMap<String, String>,
45 #[serde(bound = "")]
46 pub request_context: ApiGatewayProxyRequestContext,
47 #[serde(default)]
48 pub body: Option<String>,
49 #[serde(default, deserialize_with = "deserialize_nullish_boolean")]
50 pub is_base64_encoded: bool,
51 #[cfg(feature = "catch-all-fields")]
55 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
56 #[serde(flatten)]
57 pub other: serde_json::Map<String, Value>,
58}
59
60#[non_exhaustive]
62#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
63#[serde(rename_all = "camelCase")]
64pub struct ApiGatewayProxyResponse {
65 pub status_code: i64,
66 #[serde(deserialize_with = "deserialize_headers", default)]
67 #[serde(serialize_with = "serialize_headers")]
68 pub headers: HeaderMap,
69 #[serde(deserialize_with = "deserialize_headers", default)]
70 #[serde(serialize_with = "serialize_multi_value_headers")]
71 pub multi_value_headers: HeaderMap,
72 #[serde(skip_serializing_if = "Option::is_none")]
73 pub body: Option<Body>,
74 #[serde(default, deserialize_with = "deserialize_nullish_boolean")]
75 pub is_base64_encoded: bool,
76 #[cfg(feature = "catch-all-fields")]
80 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
81 #[serde(flatten)]
82 pub other: serde_json::Map<String, Value>,
83}
84
85#[non_exhaustive]
88#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
89#[serde(rename_all = "camelCase")]
90pub struct ApiGatewayProxyRequestContext {
91 #[serde(default)]
92 pub account_id: Option<String>,
93 #[serde(default)]
94 pub resource_id: Option<String>,
95 #[serde(skip_serializing_if = "Option::is_none")]
96 pub operation_name: Option<String>,
97 #[serde(default)]
98 pub stage: Option<String>,
99 #[serde(default)]
100 pub domain_name: Option<String>,
101 #[serde(default)]
102 pub domain_prefix: Option<String>,
103 #[serde(default)]
104 pub request_id: Option<String>,
105 #[serde(default)]
106 pub protocol: Option<String>,
107 #[serde(default)]
108 pub identity: ApiGatewayRequestIdentity,
109 #[serde(default)]
110 pub resource_path: Option<String>,
111 #[serde(default)]
112 pub path: Option<String>,
113 #[serde(
114 default,
115 deserialize_with = "deserialize_authorizer_fields",
116 serialize_with = "serialize_authorizer_fields",
117 skip_serializing_if = "ApiGatewayRequestAuthorizer::is_empty"
118 )]
119 pub authorizer: ApiGatewayRequestAuthorizer,
120 #[serde(with = "http_method")]
121 pub http_method: Method,
122 #[serde(default)]
123 pub request_time: Option<String>,
124 #[serde(default)]
125 pub request_time_epoch: i64,
126 #[serde(default)]
128 #[serde(rename = "apiId")]
129 pub apiid: Option<String>,
130 #[cfg(feature = "catch-all-fields")]
134 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
135 #[serde(flatten)]
136 pub other: serde_json::Map<String, Value>,
137}
138
139#[non_exhaustive]
141#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
142#[serde(rename_all = "camelCase")]
143pub struct ApiGatewayV2httpRequest {
144 #[serde(default, rename = "type")]
145 pub kind: Option<String>,
146 #[serde(default)]
147 pub method_arn: Option<String>,
148 #[serde(with = "http_method", default = "default_http_method")]
149 pub http_method: Method,
150 #[serde(default)]
151 pub identity_source: Option<String>,
152 #[serde(default)]
153 pub authorization_token: Option<String>,
154 #[serde(default)]
155 pub resource: Option<String>,
156 #[serde(default)]
157 pub version: Option<String>,
158 #[serde(default)]
159 pub route_key: Option<String>,
160 #[serde(default, alias = "path")]
161 pub raw_path: Option<String>,
162 #[serde(default)]
163 pub raw_query_string: Option<String>,
164 #[serde(skip_serializing_if = "Option::is_none")]
165 pub cookies: Option<Vec<String>>,
166 #[serde(deserialize_with = "deserialize_headers", default)]
167 #[serde(serialize_with = "serialize_headers")]
168 pub headers: HeaderMap,
169 #[serde(
170 default,
171 deserialize_with = "query_map::serde::aws_api_gateway_v2::deserialize_empty"
172 )]
173 #[serde(skip_serializing_if = "QueryMap::is_empty")]
174 #[serde(serialize_with = "query_map::serde::aws_api_gateway_v2::serialize_query_string_parameters")]
175 pub query_string_parameters: QueryMap,
176 #[serde(deserialize_with = "deserialize_lambda_map")]
177 #[serde(default)]
178 #[serde(skip_serializing_if = "HashMap::is_empty")]
179 pub path_parameters: HashMap<String, String>,
180 pub request_context: ApiGatewayV2httpRequestContext,
181 #[serde(deserialize_with = "deserialize_lambda_map")]
182 #[serde(default)]
183 pub stage_variables: HashMap<String, String>,
184 #[serde(skip_serializing_if = "Option::is_none")]
185 pub body: Option<String>,
186 #[serde(default)]
187 pub is_base64_encoded: bool,
188 #[cfg(feature = "catch-all-fields")]
192 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
193 #[serde(flatten)]
194 pub other: serde_json::Map<String, Value>,
195}
196
197#[non_exhaustive]
199#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
200#[serde(rename_all = "camelCase")]
201pub struct ApiGatewayV2httpRequestContext {
202 #[serde(default)]
203 pub route_key: Option<String>,
204 #[serde(default)]
205 pub account_id: Option<String>,
206 #[serde(default)]
207 pub stage: Option<String>,
208 #[serde(default)]
209 pub request_id: Option<String>,
210 #[serde(default)]
211 #[serde(skip_serializing_if = "Option::is_none")]
212 pub authorizer: Option<ApiGatewayRequestAuthorizer>,
213 #[serde(default)]
215 #[serde(rename = "apiId")]
216 pub apiid: Option<String>,
217 #[serde(default)]
218 pub domain_name: Option<String>,
219 #[serde(default)]
220 pub domain_prefix: Option<String>,
221 #[serde(default)]
222 pub time: Option<String>,
223 #[serde(default)]
224 pub time_epoch: i64,
225 pub http: ApiGatewayV2httpRequestContextHttpDescription,
226 #[serde(skip_serializing_if = "Option::is_none")]
227 pub authentication: Option<ApiGatewayV2httpRequestContextAuthentication>,
228 #[cfg(feature = "catch-all-fields")]
232 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
233 #[serde(flatten)]
234 pub other: serde_json::Map<String, Value>,
235}
236
237#[non_exhaustive]
239#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
240pub struct ApiGatewayRequestAuthorizer {
241 #[serde(skip_serializing_if = "Option::is_none")]
242 pub jwt: Option<ApiGatewayRequestAuthorizerJwtDescription>,
243 #[serde(
244 bound = "",
245 rename = "lambda",
246 default,
247 skip_serializing_if = "HashMap::is_empty",
248 deserialize_with = "deserialize_lambda_map"
249 )]
250 pub fields: HashMap<String, Value>,
251 #[serde(skip_serializing_if = "Option::is_none")]
252 pub iam: Option<ApiGatewayRequestAuthorizerIamDescription>,
253 #[cfg(feature = "catch-all-fields")]
257 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
258 #[serde(flatten)]
259 pub other: serde_json::Map<String, Value>,
260}
261
262#[non_exhaustive]
264#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
265#[serde(rename_all = "camelCase")]
266pub struct ApiGatewayRequestAuthorizerJwtDescription {
267 #[serde(deserialize_with = "deserialize_lambda_map")]
268 #[serde(default)]
269 pub claims: HashMap<String, String>,
270 #[serde(skip_serializing_if = "Option::is_none")]
271 pub scopes: Option<Vec<String>>,
272 #[cfg(feature = "catch-all-fields")]
276 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
277 #[serde(flatten)]
278 pub other: serde_json::Map<String, Value>,
279}
280
281#[non_exhaustive]
283#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
284#[serde(rename_all = "camelCase")]
285pub struct ApiGatewayRequestAuthorizerIamDescription {
286 #[serde(default)]
287 pub access_key: Option<String>,
288 #[serde(default)]
289 pub account_id: Option<String>,
290 #[serde(default)]
291 pub caller_id: Option<String>,
292 #[serde(skip_serializing_if = "Option::is_none")]
293 pub cognito_identity: Option<ApiGatewayRequestAuthorizerCognitoIdentity>,
294 #[serde(default)]
295 pub principal_org_id: Option<String>,
296 #[serde(default)]
297 pub user_arn: Option<String>,
298 #[serde(default)]
299 pub user_id: Option<String>,
300 #[cfg(feature = "catch-all-fields")]
304 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
305 #[serde(flatten)]
306 pub other: serde_json::Map<String, Value>,
307}
308
309#[non_exhaustive]
311#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
312#[serde(rename_all = "camelCase")]
313pub struct ApiGatewayRequestAuthorizerCognitoIdentity {
314 pub amr: Vec<String>,
315 #[serde(default)]
316 pub identity_id: Option<String>,
317 #[serde(default)]
318 pub identity_pool_id: Option<String>,
319 #[cfg(feature = "catch-all-fields")]
323 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
324 #[serde(flatten)]
325 pub other: serde_json::Map<String, Value>,
326}
327
328#[non_exhaustive]
330#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
331#[serde(rename_all = "camelCase")]
332pub struct ApiGatewayV2httpRequestContextHttpDescription {
333 #[serde(with = "http_method")]
334 pub method: Method,
335 #[serde(default)]
336 pub path: Option<String>,
337 #[serde(default)]
338 pub protocol: Option<String>,
339 #[serde(default)]
340 pub source_ip: Option<String>,
341 #[serde(default)]
342 pub user_agent: Option<String>,
343 #[cfg(feature = "catch-all-fields")]
347 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
348 #[serde(flatten)]
349 pub other: serde_json::Map<String, Value>,
350}
351
352#[non_exhaustive]
354#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
355#[serde(rename_all = "camelCase")]
356pub struct ApiGatewayV2httpResponse {
357 pub status_code: i64,
358 #[serde(deserialize_with = "deserialize_headers", default)]
359 #[serde(serialize_with = "serialize_headers")]
360 pub headers: HeaderMap,
361 #[serde(deserialize_with = "deserialize_headers", default)]
362 #[serde(serialize_with = "serialize_multi_value_headers")]
363 pub multi_value_headers: HeaderMap,
364 #[serde(skip_serializing_if = "Option::is_none")]
365 pub body: Option<Body>,
366 #[serde(default, deserialize_with = "deserialize_nullish_boolean")]
367 pub is_base64_encoded: bool,
368 pub cookies: Vec<String>,
369 #[cfg(feature = "catch-all-fields")]
373 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
374 #[serde(flatten)]
375 pub other: serde_json::Map<String, Value>,
376}
377
378#[non_exhaustive]
380#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
381#[serde(rename_all = "camelCase")]
382pub struct ApiGatewayRequestIdentity {
383 #[serde(default)]
384 pub cognito_identity_pool_id: Option<String>,
385 #[serde(default)]
386 pub account_id: Option<String>,
387 #[serde(default)]
388 pub cognito_identity_id: Option<String>,
389 #[serde(default)]
390 pub caller: Option<String>,
391 #[serde(default)]
392 pub api_key: Option<String>,
393 #[serde(default)]
394 pub api_key_id: Option<String>,
395 #[serde(default)]
396 pub access_key: Option<String>,
397 #[serde(default)]
398 pub source_ip: Option<String>,
399 #[serde(default)]
400 pub cognito_authentication_type: Option<String>,
401 #[serde(default)]
402 pub cognito_authentication_provider: Option<String>,
403 #[serde(default)]
405 pub user_arn: Option<String>,
406 #[serde(default)]
407 pub user_agent: Option<String>,
408 #[serde(default)]
409 pub user: Option<String>,
410 #[cfg(feature = "catch-all-fields")]
414 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
415 #[serde(flatten)]
416 pub other: serde_json::Map<String, Value>,
417}
418
419#[non_exhaustive]
421#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
422#[serde(rename_all = "camelCase")]
423pub struct ApiGatewayWebsocketProxyRequest {
424 #[serde(default)]
426 pub resource: Option<String>,
427 #[serde(default)]
429 pub path: Option<String>,
430 #[serde(deserialize_with = "http_method::deserialize_optional")]
431 #[serde(serialize_with = "http_method::serialize_optional")]
432 #[serde(skip_serializing_if = "Option::is_none")]
433 #[serde(default)]
434 pub http_method: Option<Method>,
435 #[serde(deserialize_with = "deserialize_headers", default)]
436 #[serde(serialize_with = "serialize_headers")]
437 pub headers: HeaderMap,
438 #[serde(deserialize_with = "deserialize_headers", default)]
439 #[serde(serialize_with = "serialize_multi_value_headers")]
440 pub multi_value_headers: HeaderMap,
441 #[serde(default, deserialize_with = "query_map::serde::standard::deserialize_empty")]
442 pub query_string_parameters: QueryMap,
443 #[serde(default, deserialize_with = "query_map::serde::standard::deserialize_empty")]
444 pub multi_value_query_string_parameters: QueryMap,
445 #[serde(deserialize_with = "deserialize_lambda_map")]
446 #[serde(default)]
447 pub path_parameters: HashMap<String, String>,
448 #[serde(deserialize_with = "deserialize_lambda_map")]
449 #[serde(default)]
450 pub stage_variables: HashMap<String, String>,
451 #[serde(bound = "")]
452 pub request_context: ApiGatewayWebsocketProxyRequestContext,
453 #[serde(default)]
454 pub body: Option<String>,
455 #[serde(default, deserialize_with = "deserialize_nullish_boolean")]
456 pub is_base64_encoded: bool,
457 #[cfg(feature = "catch-all-fields")]
461 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
462 #[serde(flatten)]
463 pub other: serde_json::Map<String, Value>,
464}
465
466#[non_exhaustive]
470#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
471#[serde(rename_all = "camelCase")]
472pub struct ApiGatewayWebsocketProxyRequestContext {
473 #[serde(default)]
474 pub account_id: Option<String>,
475 #[serde(default)]
476 pub resource_id: Option<String>,
477 #[serde(default)]
478 pub stage: Option<String>,
479 #[serde(default)]
480 pub request_id: Option<String>,
481 #[serde(default)]
482 pub identity: ApiGatewayRequestIdentity,
483 #[serde(default)]
484 pub resource_path: Option<String>,
485 #[serde(
486 default,
487 deserialize_with = "deserialize_authorizer_fields",
488 serialize_with = "serialize_authorizer_fields",
489 skip_serializing_if = "ApiGatewayRequestAuthorizer::is_empty"
490 )]
491 pub authorizer: ApiGatewayRequestAuthorizer,
492 #[serde(deserialize_with = "http_method::deserialize_optional")]
493 #[serde(serialize_with = "http_method::serialize_optional")]
494 #[serde(skip_serializing_if = "Option::is_none")]
495 #[serde(default)]
496 pub http_method: Option<Method>,
497 #[serde(default)]
499 #[serde(rename = "apiId")]
500 pub apiid: Option<String>,
501 pub connected_at: i64,
502 #[serde(default)]
503 pub connection_id: Option<String>,
504 #[serde(default)]
505 pub domain_name: Option<String>,
506 #[serde(default)]
507 pub error: Option<String>,
508 #[serde(default)]
509 pub event_type: Option<String>,
510 #[serde(default)]
511 pub extended_request_id: Option<String>,
512 #[serde(default)]
513 pub integration_latency: Option<String>,
514 #[serde(default)]
515 pub message_direction: Option<String>,
516 #[serde(bound = "")]
517 pub message_id: Option<String>,
518 #[serde(default)]
519 pub request_time: Option<String>,
520 pub request_time_epoch: i64,
521 #[serde(default)]
522 pub route_key: Option<String>,
523 #[serde(default)]
524 pub status: Option<String>,
525 #[serde(default)]
526 pub disconnect_status_code: Option<i64>,
527 #[serde(default)]
528 pub disconnect_reason: Option<String>,
529 #[cfg(feature = "catch-all-fields")]
533 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
534 #[serde(flatten)]
535 pub other: serde_json::Map<String, Value>,
536}
537
538#[non_exhaustive]
540#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
541#[serde(rename_all = "camelCase")]
542pub struct ApiGatewayCustomAuthorizerRequestTypeRequestIdentity {
543 #[serde(default)]
544 pub api_key_id: Option<String>,
545 #[serde(default)]
546 pub api_key: Option<String>,
547 #[serde(default)]
548 pub source_ip: Option<String>,
549 #[serde(default)]
550 pub client_cert: Option<ApiGatewayCustomAuthorizerRequestTypeRequestIdentityClientCert>,
551 #[cfg(feature = "catch-all-fields")]
555 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
556 #[serde(flatten)]
557 pub other: serde_json::Map<String, Value>,
558}
559
560#[non_exhaustive]
562#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
563#[serde(rename_all = "camelCase")]
564pub struct ApiGatewayCustomAuthorizerRequestTypeRequestIdentityClientCert {
565 #[serde(default)]
566 pub client_cert_pem: Option<String>,
567 #[serde(default)]
568 #[serde(rename = "issuerDN")]
569 pub issuer_dn: Option<String>,
570 #[serde(default)]
571 pub serial_number: Option<String>,
572 #[serde(default)]
573 #[serde(rename = "subjectDN")]
574 pub subject_dn: Option<String>,
575 pub validity: ApiGatewayCustomAuthorizerRequestTypeRequestIdentityClientCertValidity,
576 #[cfg(feature = "catch-all-fields")]
580 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
581 #[serde(flatten)]
582 pub other: serde_json::Map<String, Value>,
583}
584
585#[non_exhaustive]
587#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
588#[serde(rename_all = "camelCase")]
589pub struct ApiGatewayCustomAuthorizerRequestTypeRequestIdentityClientCertValidity {
590 #[serde(default)]
591 pub not_after: Option<String>,
592 #[serde(default)]
593 pub not_before: Option<String>,
594 #[cfg(feature = "catch-all-fields")]
598 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
599 #[serde(flatten)]
600 pub other: serde_json::Map<String, Value>,
601}
602
603#[non_exhaustive]
605#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
606#[serde(rename_all = "camelCase")]
607pub struct ApiGatewayV2httpRequestContextAuthentication {
608 #[serde(default)]
609 pub client_cert: Option<ApiGatewayV2httpRequestContextAuthenticationClientCert>,
610 #[cfg(feature = "catch-all-fields")]
614 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
615 #[serde(flatten)]
616 pub other: serde_json::Map<String, Value>,
617}
618
619#[non_exhaustive]
621#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
622#[serde(rename_all = "camelCase")]
623pub struct ApiGatewayV2httpRequestContextAuthenticationClientCert {
624 #[serde(default)]
625 pub client_cert_pem: Option<String>,
626 #[serde(default)]
627 #[serde(rename = "issuerDN")]
628 pub issuer_dn: Option<String>,
629 #[serde(default)]
630 pub serial_number: Option<String>,
631 #[serde(default)]
632 #[serde(rename = "subjectDN")]
633 pub subject_dn: Option<String>,
634 pub validity: ApiGatewayV2httpRequestContextAuthenticationClientCertValidity,
635 #[cfg(feature = "catch-all-fields")]
639 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
640 #[serde(flatten)]
641 pub other: serde_json::Map<String, Value>,
642}
643
644#[non_exhaustive]
646#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
647#[serde(rename_all = "camelCase")]
648pub struct ApiGatewayV2httpRequestContextAuthenticationClientCertValidity {
649 #[serde(default)]
650 pub not_after: Option<String>,
651 #[serde(default)]
652 pub not_before: Option<String>,
653 #[cfg(feature = "catch-all-fields")]
657 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
658 #[serde(flatten)]
659 pub other: serde_json::Map<String, Value>,
660}
661
662#[non_exhaustive]
663#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
664#[serde(rename_all = "camelCase")]
665pub struct ApiGatewayV2CustomAuthorizerV1RequestTypeRequestContext {
666 #[serde(default)]
667 pub path: Option<String>,
668 #[serde(default)]
669 pub account_id: Option<String>,
670 #[serde(default)]
671 pub resource_id: Option<String>,
672 #[serde(default)]
673 pub stage: Option<String>,
674 #[serde(default)]
675 pub request_id: Option<String>,
676 pub identity: ApiGatewayCustomAuthorizerRequestTypeRequestIdentity,
677 #[serde(default)]
678 pub resource_path: Option<String>,
679 #[serde(with = "http_method")]
680 pub http_method: Method,
681 #[serde(default)]
682 #[serde(rename = "apiId")]
683 pub apiid: Option<String>,
684 #[cfg(feature = "catch-all-fields")]
688 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
689 #[serde(flatten)]
690 pub other: serde_json::Map<String, Value>,
691}
692
693#[non_exhaustive]
694#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
695#[serde(rename_all = "camelCase")]
696pub struct ApiGatewayV2CustomAuthorizerV1Request {
697 #[serde(default)]
698 pub version: Option<String>,
699 #[serde(default)]
700 pub type_: Option<String>,
701 #[serde(default)]
703 pub method_arn: Option<String>,
704 #[serde(default)]
705 pub identity_source: Option<String>,
706 #[serde(default)]
707 pub authorization_token: Option<String>,
708 #[serde(default)]
709 pub resource: Option<String>,
710 #[serde(default)]
711 pub path: Option<String>,
712 #[serde(with = "http_method")]
713 pub http_method: Method,
714 #[serde(deserialize_with = "http_serde::header_map::deserialize", default)]
715 #[serde(serialize_with = "serialize_headers")]
716 pub headers: HeaderMap,
717 #[serde(deserialize_with = "deserialize_lambda_map")]
718 #[serde(default)]
719 pub query_string_parameters: HashMap<String, String>,
720 #[serde(deserialize_with = "deserialize_lambda_map")]
721 #[serde(default)]
722 pub path_parameters: HashMap<String, String>,
723 #[serde(deserialize_with = "deserialize_lambda_map")]
724 #[serde(default)]
725 pub stage_variables: HashMap<String, String>,
726 pub request_context: ApiGatewayV2CustomAuthorizerV1RequestTypeRequestContext,
727 #[cfg(feature = "catch-all-fields")]
731 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
732 #[serde(flatten)]
733 pub other: serde_json::Map<String, Value>,
734}
735
736#[non_exhaustive]
737#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
738#[serde(rename_all = "camelCase")]
739pub struct ApiGatewayV2CustomAuthorizerV2Request {
740 #[serde(default)]
741 pub version: Option<String>,
742 #[serde(default)]
743 pub type_: Option<String>,
744 #[serde(default)]
746 pub route_arn: Option<String>,
747 #[serde(skip_serializing_if = "Option::is_none")]
748 pub identity_source: Option<Vec<String>>,
749 #[serde(default)]
750 pub route_key: Option<String>,
751 #[serde(default)]
752 pub raw_path: Option<String>,
753 #[serde(default)]
754 pub raw_query_string: Option<String>,
755 #[serde(default)]
756 pub cookies: Vec<String>,
757 #[serde(deserialize_with = "http_serde::header_map::deserialize", default)]
758 #[serde(serialize_with = "serialize_headers")]
759 pub headers: HeaderMap,
760 #[serde(deserialize_with = "deserialize_lambda_map")]
761 #[serde(default)]
762 pub query_string_parameters: HashMap<String, String>,
763 pub request_context: ApiGatewayV2httpRequestContext,
764 #[serde(deserialize_with = "deserialize_lambda_map")]
765 #[serde(default)]
766 pub path_parameters: HashMap<String, String>,
767 #[serde(deserialize_with = "deserialize_lambda_map")]
768 #[serde(default)]
769 pub stage_variables: HashMap<String, String>,
770 #[cfg(feature = "catch-all-fields")]
774 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
775 #[serde(flatten)]
776 pub other: serde_json::Map<String, Value>,
777}
778
779#[non_exhaustive]
782#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
783#[serde(rename_all = "camelCase")]
784pub struct ApiGatewayCustomAuthorizerContext {
785 pub principal_id: Option<String>,
786 pub string_key: Option<String>,
787 pub num_key: Option<i64>,
788 #[serde(default, deserialize_with = "deserialize_nullish_boolean")]
789 pub bool_key: bool,
790 #[cfg(feature = "catch-all-fields")]
794 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
795 #[serde(flatten)]
796 pub other: serde_json::Map<String, Value>,
797}
798
799#[non_exhaustive]
801#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
802#[serde(rename_all = "camelCase")]
803pub struct ApiGatewayCustomAuthorizerRequestTypeRequestContext {
804 #[serde(default)]
805 pub path: Option<String>,
806 #[serde(default)]
807 pub account_id: Option<String>,
808 #[serde(default)]
809 pub resource_id: Option<String>,
810 #[serde(default)]
811 pub stage: Option<String>,
812 #[serde(default)]
813 pub request_id: Option<String>,
814 #[serde(default)]
815 pub identity: Option<ApiGatewayCustomAuthorizerRequestTypeRequestIdentity>,
816 #[serde(default)]
817 pub resource_path: Option<String>,
818 #[serde(deserialize_with = "http_method::deserialize_optional")]
819 #[serde(serialize_with = "http_method::serialize_optional")]
820 #[serde(skip_serializing_if = "Option::is_none")]
821 #[serde(default)]
822 pub http_method: Option<Method>,
823 #[serde(default)]
824 #[serde(rename = "apiId")]
825 pub apiid: Option<String>,
826 #[cfg(feature = "catch-all-fields")]
830 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
831 #[serde(flatten)]
832 pub other: serde_json::Map<String, Value>,
833}
834
835#[non_exhaustive]
837#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
838#[serde(rename_all = "camelCase")]
839pub struct ApiGatewayCustomAuthorizerRequest {
840 #[serde(default)]
841 pub type_: Option<String>,
842 #[serde(default)]
843 pub authorization_token: Option<String>,
844 #[serde(default)]
846 pub method_arn: Option<String>,
847 #[cfg(feature = "catch-all-fields")]
851 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
852 #[serde(flatten)]
853 pub other: serde_json::Map<String, Value>,
854}
855
856#[non_exhaustive]
858#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
859#[serde(rename_all = "camelCase")]
860pub struct ApiGatewayCustomAuthorizerRequestTypeRequest {
861 #[serde(default)]
862 pub type_: Option<String>,
863 #[serde(default)]
865 pub method_arn: Option<String>,
866 #[serde(default)]
867 pub resource: Option<String>,
868 #[serde(default)]
869 pub path: Option<String>,
870 #[serde(deserialize_with = "http_method::deserialize_optional")]
871 #[serde(serialize_with = "http_method::serialize_optional")]
872 #[serde(skip_serializing_if = "Option::is_none")]
873 #[serde(default)]
874 pub http_method: Option<Method>,
875 #[serde(deserialize_with = "deserialize_headers", default)]
876 #[serde(serialize_with = "serialize_headers")]
877 pub headers: HeaderMap,
878 #[serde(deserialize_with = "deserialize_headers", default)]
879 #[serde(serialize_with = "serialize_multi_value_headers")]
880 pub multi_value_headers: HeaderMap,
881 #[serde(default, deserialize_with = "query_map::serde::standard::deserialize_empty")]
882 pub query_string_parameters: QueryMap,
883 #[serde(default, deserialize_with = "query_map::serde::standard::deserialize_empty")]
884 pub multi_value_query_string_parameters: QueryMap,
885 #[serde(deserialize_with = "deserialize_lambda_map")]
886 #[serde(default)]
887 pub path_parameters: HashMap<String, String>,
888 #[serde(deserialize_with = "deserialize_lambda_map")]
889 #[serde(default)]
890 pub stage_variables: HashMap<String, String>,
891 pub request_context: ApiGatewayCustomAuthorizerRequestTypeRequestContext,
892 #[cfg(feature = "catch-all-fields")]
896 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
897 #[serde(flatten)]
898 pub other: serde_json::Map<String, Value>,
899}
900
901#[non_exhaustive]
903#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
904#[serde(rename_all = "camelCase")]
905pub struct ApiGatewayCustomAuthorizerResponse<T1 = Value>
906where
907 T1: DeserializeOwned,
908 T1: Serialize,
909{
910 #[serde(default)]
911 pub principal_id: Option<String>,
912 pub policy_document: ApiGatewayCustomAuthorizerPolicy,
913 #[serde(bound = "", default)]
914 pub context: T1,
915 pub usage_identifier_key: Option<String>,
916 #[cfg(feature = "catch-all-fields")]
920 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
921 #[serde(flatten)]
922 pub other: serde_json::Map<String, Value>,
923}
924
925#[non_exhaustive]
927#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
928#[serde(rename_all = "camelCase")]
929pub struct ApiGatewayV2CustomAuthorizerSimpleResponse<T1 = Value>
930where
931 T1: DeserializeOwned,
932 T1: Serialize,
933{
934 pub is_authorized: bool,
935 #[serde(bound = "", default)]
936 pub context: T1,
937 #[cfg(feature = "catch-all-fields")]
941 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
942 #[serde(flatten)]
943 pub other: serde_json::Map<String, Value>,
944}
945
946#[non_exhaustive]
947#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
948#[serde(rename_all = "camelCase")]
949pub struct ApiGatewayV2CustomAuthorizerIamPolicyResponse<T1 = Value>
950where
951 T1: DeserializeOwned,
952 T1: Serialize,
953{
954 #[serde(default)]
955 pub principal_id: Option<String>,
956 pub policy_document: ApiGatewayCustomAuthorizerPolicy,
957 #[serde(bound = "", default)]
958 pub context: T1,
959 #[cfg(feature = "catch-all-fields")]
963 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
964 #[serde(flatten)]
965 pub other: serde_json::Map<String, Value>,
966}
967
968#[non_exhaustive]
970#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
971#[serde(rename_all = "PascalCase")]
972pub struct ApiGatewayCustomAuthorizerPolicy {
973 #[serde(default)]
974 pub version: Option<String>,
975 pub statement: Vec<IamPolicyStatement>,
976 #[cfg(feature = "catch-all-fields")]
980 #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
981 #[serde(flatten)]
982 pub other: serde_json::Map<String, Value>,
983}
984
985fn default_http_method() -> Method {
986 Method::GET
987}
988
989#[deprecated = "use `ApiGatewayRequestAuthorizer` instead"]
990pub type ApiGatewayV2httpRequestContextAuthorizerDescription = ApiGatewayRequestAuthorizer;
991#[deprecated = "use `ApiGatewayRequestAuthorizerJwtDescription` instead"]
992pub type ApiGatewayV2httpRequestContextAuthorizerJwtDescription = ApiGatewayRequestAuthorizerJwtDescription;
993#[deprecated = "use `ApiGatewayRequestAuthorizerIamDescription` instead"]
994pub type ApiGatewayV2httpRequestContextAuthorizerIamDescription = ApiGatewayRequestAuthorizerIamDescription;
995#[deprecated = "use `ApiGatewayRequestAuthorizerCognitoIdentity` instead"]
996pub type ApiGatewayV2httpRequestContextAuthorizerCognitoIdentity = ApiGatewayRequestAuthorizerCognitoIdentity;
997
998impl ApiGatewayRequestAuthorizer {
999 fn is_empty(&self) -> bool {
1000 self.fields.is_empty()
1001 }
1002}
1003
1004fn deserialize_authorizer_fields<'de, D>(deserializer: D) -> Result<ApiGatewayRequestAuthorizer, D::Error>
1005where
1006 D: Deserializer<'de>,
1007{
1008 let fields: Option<HashMap<String, Value>> = Option::deserialize(deserializer)?;
1009 let mut authorizer = ApiGatewayRequestAuthorizer::default();
1010 if let Some(fields) = fields {
1011 authorizer.fields = fields;
1012 }
1013
1014 Ok(authorizer)
1015}
1016
1017pub fn serialize_authorizer_fields<S: Serializer>(
1018 authorizer: &ApiGatewayRequestAuthorizer,
1019 ser: S,
1020) -> Result<S::Ok, S::Error> {
1021 let mut map = ser.serialize_map(Some(authorizer.fields.len()))?;
1022 for (k, v) in &authorizer.fields {
1023 map.serialize_entry(k, v)?;
1024 }
1025 map.end()
1026}
1027
1028#[cfg(test)]
1029mod test {
1030 use super::*;
1031
1032 #[test]
1033 #[cfg(feature = "apigw")]
1034 fn example_apigw_custom_auth_request_type_request() {
1035 let data = include_bytes!("../../fixtures/example-apigw-custom-auth-request-type-request.json");
1036 let parsed: ApiGatewayCustomAuthorizerRequestTypeRequest = serde_json::from_slice(data).unwrap();
1037 let output: String = serde_json::to_string(&parsed).unwrap();
1038 let reparsed: ApiGatewayCustomAuthorizerRequestTypeRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1039 assert_eq!(parsed, reparsed);
1040 }
1041
1042 #[test]
1043 #[cfg(feature = "apigw")]
1044 fn example_apigw_custom_auth_request_type_request_websocket() {
1045 let data = include_bytes!("../../fixtures/example-apigw-v2-custom-authorizer-websocket-request.json");
1046 let parsed: ApiGatewayCustomAuthorizerRequestTypeRequest = serde_json::from_slice(data).unwrap();
1047 let output: String = serde_json::to_string(&parsed).unwrap();
1048 let reparsed: ApiGatewayCustomAuthorizerRequestTypeRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1049 assert_eq!(parsed, reparsed);
1050 }
1051
1052 #[test]
1053 #[cfg(feature = "apigw")]
1054 fn example_apigw_custom_auth_request() {
1055 let data = include_bytes!("../../fixtures/example-apigw-custom-auth-request.json");
1056 let parsed: ApiGatewayCustomAuthorizerRequest = serde_json::from_slice(data).unwrap();
1057 let output: String = serde_json::to_string(&parsed).unwrap();
1058 let reparsed: ApiGatewayCustomAuthorizerRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1059 assert_eq!(parsed, reparsed);
1060 }
1061
1062 #[test]
1063 #[cfg(feature = "apigw")]
1064 fn example_apigw_custom_auth_response() {
1065 let data = include_bytes!("../../fixtures/example-apigw-custom-auth-response.json");
1066 let parsed: ApiGatewayCustomAuthorizerResponse = serde_json::from_slice(data).unwrap();
1067 let output: String = serde_json::to_string(&parsed).unwrap();
1068 let reparsed: ApiGatewayCustomAuthorizerResponse = serde_json::from_slice(output.as_bytes()).unwrap();
1069 assert_eq!(parsed, reparsed);
1070 }
1071
1072 #[test]
1073 #[cfg(feature = "apigw")]
1074 fn example_apigw_custom_auth_response_with_single_value_action() {
1075 let data = include_bytes!("../../fixtures/example-apigw-custom-auth-response-with-single-value-action.json");
1076 let parsed: ApiGatewayCustomAuthorizerResponse = serde_json::from_slice(data).unwrap();
1077 let output: String = serde_json::to_string(&parsed).unwrap();
1078 let reparsed: ApiGatewayCustomAuthorizerResponse = serde_json::from_slice(output.as_bytes()).unwrap();
1079 assert_eq!(parsed, reparsed);
1080 }
1081
1082 #[test]
1083 #[cfg(feature = "apigw")]
1084 fn example_apigw_custom_auth_response_with_single_value_resource() {
1085 let data = include_bytes!("../../fixtures/example-apigw-custom-auth-response-with-single-value-resource.json");
1086 let parsed: ApiGatewayCustomAuthorizerResponse = serde_json::from_slice(data).unwrap();
1087 let output: String = serde_json::to_string(&parsed).unwrap();
1088 let reparsed: ApiGatewayCustomAuthorizerResponse = serde_json::from_slice(output.as_bytes()).unwrap();
1089 assert_eq!(parsed, reparsed);
1090 }
1091
1092 #[test]
1093 #[cfg(feature = "apigw")]
1094 fn example_apigw_request() {
1095 let data = include_bytes!("../../fixtures/example-apigw-request.json");
1096 let parsed: ApiGatewayProxyRequest = serde_json::from_slice(data).unwrap();
1097 let output: String = serde_json::to_string(&parsed).unwrap();
1098 let reparsed: ApiGatewayProxyRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1099 assert_eq!(parsed, reparsed);
1100 }
1101
1102 #[test]
1103 #[cfg(feature = "apigw")]
1104 fn example_apigw_response() {
1105 let data = include_bytes!("../../fixtures/example-apigw-response.json");
1106 let parsed: ApiGatewayProxyResponse = serde_json::from_slice(data).unwrap();
1107 let output: String = serde_json::to_string(&parsed).unwrap();
1108 let reparsed: ApiGatewayProxyResponse = serde_json::from_slice(output.as_bytes()).unwrap();
1109 assert_eq!(parsed, reparsed);
1110 }
1111
1112 #[test]
1113 #[cfg(feature = "apigw")]
1114 fn example_apigw_request_multi_value_parameters() {
1115 let data = include_bytes!("../../fixtures/example-apigw-request-multi-value-parameters.json");
1116 let parsed: ApiGatewayProxyRequest = serde_json::from_slice(data).unwrap();
1117 let output: String = serde_json::to_string(&parsed).unwrap();
1118 let reparsed: ApiGatewayProxyRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1119 assert_eq!(parsed, reparsed);
1120
1121 assert!(output.contains(r#""multiValueQueryStringParameters":{"name":["me","me2"]}"#));
1122 assert!(output.contains(r#""queryStringParameters":{"name":"me"}"#));
1123 assert!(output.contains(r#""headername":["headerValue","headerValue2"]"#));
1124 assert!(output.contains(r#""headername":"headerValue2""#));
1125 }
1126
1127 #[test]
1128 #[cfg(all(feature = "apigw", feature = "catch-all-fields"))]
1129 fn example_apigw_request_catch_all() {
1130 use serde_json::json;
1131
1132 let data = include_bytes!("../../fixtures/example-apigw-request-catch-all.json");
1133 let parsed: ApiGatewayProxyRequest = serde_json::from_slice(data).unwrap();
1134 let output: String = serde_json::to_string(&parsed).unwrap();
1135 let reparsed: ApiGatewayProxyRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1136 assert_eq!(parsed, reparsed);
1137
1138 assert_eq!(parsed.other.get("otherField"), Some(&json!("foobar")));
1139 assert_eq!(
1140 parsed.request_context.identity.other.get("otherField"),
1141 Some(&json!(2345))
1142 );
1143 }
1144
1145 #[test]
1146 #[cfg(feature = "apigw")]
1147 fn example_apigw_restapi_openapi_request() {
1148 let data = include_bytes!("../../fixtures/example-apigw-restapi-openapi-request.json");
1149 let parsed: ApiGatewayProxyRequest = serde_json::from_slice(data).unwrap();
1150 let output: String = serde_json::to_string(&parsed).unwrap();
1151 let reparsed: ApiGatewayProxyRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1152 assert_eq!(parsed, reparsed);
1153 }
1154
1155 #[test]
1156 #[cfg(feature = "apigw")]
1157 fn example_apigw_v2_request_iam() {
1158 let data = include_bytes!("../../fixtures/example-apigw-v2-request-iam.json");
1159 let parsed: ApiGatewayV2httpRequest = serde_json::from_slice(data).unwrap();
1160 let output: String = serde_json::to_string(&parsed).unwrap();
1161 let reparsed: ApiGatewayV2httpRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1162 assert_eq!(parsed, reparsed);
1163 }
1164
1165 #[test]
1166 #[cfg(feature = "apigw")]
1167 fn example_apigw_v2_request_jwt_authorizer() {
1168 let data = include_bytes!("../../fixtures/example-apigw-v2-request-jwt-authorizer.json");
1169 let parsed: ApiGatewayV2httpRequest = serde_json::from_slice(data).unwrap();
1170 let output: String = serde_json::to_string(&parsed).unwrap();
1171 let reparsed: ApiGatewayV2httpRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1172 assert_eq!(parsed, reparsed);
1173 }
1174
1175 #[test]
1176 #[cfg(feature = "apigw")]
1177 fn example_apigw_v2_request_lambda_authorizer() {
1178 let data = include_bytes!("../../fixtures/example-apigw-v2-request-lambda-authorizer.json");
1179 let parsed: ApiGatewayV2httpRequest = serde_json::from_slice(data).unwrap();
1180 let output: String = serde_json::to_string(&parsed).unwrap();
1181 let reparsed: ApiGatewayV2httpRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1182 assert_eq!(parsed, reparsed);
1183 }
1184
1185 #[test]
1186 #[cfg(feature = "apigw")]
1187 fn example_apigw_v2_request_multi_value_parameters() {
1188 let data = include_bytes!("../../fixtures/example-apigw-v2-request-multi-value-parameters.json");
1189 let parsed: ApiGatewayV2httpRequest = serde_json::from_slice(data).unwrap();
1190 let output: String = serde_json::to_string(&parsed).unwrap();
1191 let reparsed: ApiGatewayV2httpRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1192 assert_eq!(parsed, reparsed);
1193
1194 assert!(output.contains(r#""header2":"value1,value2""#));
1195 assert!(output.contains(r#""queryStringParameters":{"Parameter1":"value1,value2"}"#));
1196 }
1197
1198 #[test]
1199 #[cfg(feature = "apigw")]
1200 fn example_apigw_v2_request_no_authorizer() {
1201 let data = include_bytes!("../../fixtures/example-apigw-v2-request-no-authorizer.json");
1202 let parsed: ApiGatewayV2httpRequest = serde_json::from_slice(data).unwrap();
1203 let output: String = serde_json::to_string(&parsed).unwrap();
1204 let reparsed: ApiGatewayV2httpRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1205 assert_eq!(parsed, reparsed);
1206 }
1207
1208 #[test]
1209 #[cfg(feature = "apigw")]
1210 fn example_apigw_websocket_request() {
1211 let data = include_bytes!("../../fixtures/example-apigw-websocket-request.json");
1212 let parsed: ApiGatewayWebsocketProxyRequest = serde_json::from_slice(data).unwrap();
1213 let output: String = serde_json::to_string(&parsed).unwrap();
1214 let reparsed: ApiGatewayWebsocketProxyRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1215 assert_eq!(parsed, reparsed);
1216 }
1217
1218 #[test]
1219 #[cfg(feature = "apigw")]
1220 fn example_apigw_console_test_request() {
1221 let data = include_bytes!("../../fixtures/example-apigw-console-test-request.json");
1222 let parsed: ApiGatewayProxyRequest = serde_json::from_slice(data).unwrap();
1223 let output: String = serde_json::to_string(&parsed).unwrap();
1224 let reparsed: ApiGatewayProxyRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1225 assert_eq!(parsed, reparsed);
1226 }
1227
1228 #[test]
1229 #[cfg(feature = "apigw")]
1230 fn example_apigw_websocket_request_without_method() {
1231 let data = include_bytes!("../../fixtures/example-apigw-websocket-request-without-method.json");
1232 let parsed: ApiGatewayWebsocketProxyRequest = serde_json::from_slice(data).unwrap();
1233 let output: String = serde_json::to_string(&parsed).unwrap();
1234 let reparsed: ApiGatewayWebsocketProxyRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1235 assert_eq!(parsed, reparsed);
1236 }
1237
1238 #[test]
1239 #[cfg(feature = "apigw")]
1240 fn example_apigw_websocket_request_disconnect_route() {
1241 let data = include_bytes!("../../fixtures/example-apigw-websocket-request-disconnect-route.json");
1242 let parsed: ApiGatewayWebsocketProxyRequest = serde_json::from_slice(data).unwrap();
1243 let output: String = serde_json::to_string(&parsed).unwrap();
1244 let reparsed: ApiGatewayWebsocketProxyRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1245 assert_eq!(parsed, reparsed);
1246 }
1247
1248 #[test]
1249 #[cfg(feature = "apigw")]
1250 fn example_apigw_v2_custom_authorizer_v1_request() {
1251 let data = include_bytes!("../../fixtures/example-apigw-v2-custom-authorizer-v1-request.json");
1252 let parsed: ApiGatewayV2httpRequest = serde_json::from_slice(data).unwrap();
1253 let output: String = serde_json::to_string(&parsed).unwrap();
1254 let reparsed: ApiGatewayV2httpRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1255 assert_eq!(parsed, reparsed);
1256 assert_eq!("REQUEST", parsed.kind.unwrap());
1257 assert_eq!(Method::GET, parsed.http_method);
1258 }
1259
1260 #[test]
1261 #[cfg(feature = "apigw")]
1262 fn example_apigw_v2_custom_authorizer_v2_request() {
1263 let data = include_bytes!("../../fixtures/example-apigw-v2-custom-authorizer-v2-request.json");
1264 let parsed: ApiGatewayV2CustomAuthorizerV2Request = serde_json::from_slice(data).unwrap();
1265 let output: String = serde_json::to_string(&parsed).unwrap();
1266 let reparsed: ApiGatewayV2CustomAuthorizerV2Request = serde_json::from_slice(output.as_bytes()).unwrap();
1267 assert_eq!(parsed, reparsed);
1268 }
1269
1270 #[test]
1271 #[cfg(feature = "apigw")]
1272 fn example_apigw_v2_custom_authorizer_v2_request_without_cookies() {
1273 let data = include_bytes!("../../fixtures/example-apigw-v2-custom-authorizer-v2-request-without-cookies.json");
1274 let parsed: ApiGatewayV2CustomAuthorizerV2Request = serde_json::from_slice(data).unwrap();
1275 let output: String = serde_json::to_string(&parsed).unwrap();
1276 let reparsed: ApiGatewayV2CustomAuthorizerV2Request = serde_json::from_slice(output.as_bytes()).unwrap();
1277 assert_eq!(parsed, reparsed);
1278 }
1279
1280 #[test]
1281 #[cfg(feature = "apigw")]
1282 fn example_apigw_v2_custom_authorizer_v2_request_without_identity_source() {
1283 let data =
1284 include_bytes!("../../fixtures/example-apigw-v2-custom-authorizer-v2-request-without-identity-source.json");
1285 let parsed: ApiGatewayV2CustomAuthorizerV2Request = serde_json::from_slice(data).unwrap();
1286 let output: String = serde_json::to_string(&parsed).unwrap();
1287 let reparsed: ApiGatewayV2CustomAuthorizerV2Request = serde_json::from_slice(output.as_bytes()).unwrap();
1288 assert_eq!(parsed, reparsed);
1289 }
1290
1291 #[test]
1292 #[cfg(feature = "apigw")]
1293 fn example_apigw_console_request() {
1294 let data = include_bytes!("../../fixtures/example-apigw-console-request.json");
1295 let parsed: ApiGatewayProxyRequest = serde_json::from_slice(data).unwrap();
1296 let output: String = serde_json::to_string(&parsed).unwrap();
1297 let reparsed: ApiGatewayProxyRequest = serde_json::from_slice(output.as_bytes()).unwrap();
1298 assert_eq!(parsed, reparsed);
1299 }
1300
1301 #[test]
1302 #[cfg(feature = "apigw")]
1303 fn example_apigw_request_authorizer_fields() {
1304 let data = include_bytes!("../../fixtures/example-apigw-request.json");
1305 let parsed: ApiGatewayProxyRequest = serde_json::from_slice(data).unwrap();
1306
1307 let fields = parsed.request_context.authorizer.fields;
1308 assert_eq!(Some("admin"), fields.get("principalId").unwrap().as_str());
1309 assert_eq!(Some(1), fields.get("clientId").unwrap().as_u64());
1310 assert_eq!(Some("Exata"), fields.get("clientName").unwrap().as_str());
1311 }
1312
1313 #[test]
1314 #[cfg(feature = "apigw")]
1315 fn example_apigw_custom_auth_response_with_statement_condition() {
1316 use crate::iam::IamPolicyEffect;
1317
1318 let data = include_bytes!("../../fixtures/example-apigw-custom-auth-response-with-condition.json");
1319 let parsed: ApiGatewayCustomAuthorizerResponse = serde_json::from_slice(data).unwrap();
1320 let output: String = serde_json::to_string(&parsed).unwrap();
1321 let reparsed: ApiGatewayCustomAuthorizerResponse = serde_json::from_slice(output.as_bytes()).unwrap();
1322 assert_eq!(parsed, reparsed);
1323
1324 let statement = parsed.policy_document.statement.first().unwrap();
1325 assert_eq!(IamPolicyEffect::Deny, statement.effect);
1326
1327 let condition = statement.condition.as_ref().unwrap();
1328 assert_eq!(vec!["xxx"], condition["StringEquals"]["aws:SourceIp"]);
1329 }
1330}