rusty_cdk_core/apigateway/
dto.rs

1use serde::Serialize;
2use serde_json::Value;
3use crate::{dto_methods, ref_struct};
4use crate::shared::Id;
5
6ref_struct!(ApiGatewayV2ApiRef);
7
8#[derive(Debug, Serialize)]
9pub struct ApiGatewayV2Api {
10    #[serde(skip)]
11    pub(crate) id: Id,
12    #[serde(skip)]
13    pub(crate) resource_id: String,
14    #[serde(rename = "Type")]
15    pub(crate) r#type: String,
16    #[serde(rename = "Properties")]
17    pub(crate) properties: ApiGatewayV2ApiProperties,
18}
19dto_methods!(ApiGatewayV2Api);
20
21#[derive(Debug, Serialize)]
22pub struct ApiGatewayV2ApiProperties {
23    #[serde(rename = "Name", skip_serializing_if = "Option::is_none")]
24    pub(super) name: Option<String>,
25    #[serde(rename = "ProtocolType")]
26    pub(super) protocol_type: String,
27    #[serde(rename = "DisableExecuteApiEndpoint", skip_serializing_if = "Option::is_none")]
28    pub(super) disable_execute_api_endpoint: Option<bool>,
29    #[serde(rename = "DisableSchemaValidation", skip_serializing_if = "Option::is_none")]
30    pub(super) disable_schema_validation: Option<bool>,
31    #[serde(rename = "CorsConfiguration", skip_serializing_if = "Option::is_none")]
32    pub(super) cors_configuration: Option<CorsConfiguration>,
33    #[serde(rename = "RouteSelectionExpression", skip_serializing_if = "Option::is_none")]
34    pub(super) route_selection_expression: Option<String>,
35
36    // #[serde(rename = "ApiKeySelectionExpression", skip_serializing_if = "Option::is_none")]
37    // pub(super) api_key_selection_expression: String // $request.header.x-api-key OR $context.authorizer.usageIdentifierKey
38}
39
40#[derive(Debug, Serialize)]
41pub struct CorsConfiguration {
42    #[serde(rename = "AllowCredentials", skip_serializing_if = "Option::is_none")]
43    pub(super) allow_credentials: Option<bool>,
44    #[serde(rename = "AllowHeaders", skip_serializing_if = "Option::is_none")]
45    pub(super) allow_headers: Option<Vec<String>>,
46    #[serde(rename = "AllowMethods", skip_serializing_if = "Option::is_none")]
47    pub(super) allow_methods: Option<Vec<String>>,
48    #[serde(rename = "AllowOrigins", skip_serializing_if = "Option::is_none")]
49    pub(super) allow_origins: Option<Vec<String>>,
50    #[serde(rename = "ExposeHeaders", skip_serializing_if = "Option::is_none")]
51    pub(super) expose_headers: Option<Vec<String>>,
52    #[serde(rename = "MaxAge", skip_serializing_if = "Option::is_none")]
53    pub(super) max_age: Option<u64>,
54}
55
56ref_struct!(ApiGatewayV2StageRef);
57
58#[derive(Debug, Serialize)]
59pub struct ApiGatewayV2Stage {
60    #[serde(skip)]
61    pub(super) id: Id,
62    #[serde(skip)]
63    pub(super) resource_id: String,
64    #[serde(rename = "Type")]
65    pub(super) r#type: String,
66    #[serde(rename = "Properties")]
67    pub(super) properties: ApiGatewayV2StageProperties,
68}
69dto_methods!(ApiGatewayV2Stage);
70
71#[derive(Debug, Serialize)]
72pub struct ApiGatewayV2StageProperties {
73    #[serde(rename = "ApiId")]
74    pub(super) api_id: Value,
75    #[serde(rename = "StageName")]
76    pub(super) stage_name: String,
77    #[serde(rename = "AutoDeploy")]
78    pub(super) auto_deploy: bool,
79    #[serde(rename = "DefaultRouteSettings", skip_serializing_if = "Option::is_none")]
80    pub(super) default_route_settings: Option<RouteSettings>,
81    #[serde(rename = "RouteSettings", skip_serializing_if = "Option::is_none")]
82    pub(super) route_settings: Option<Value>,
83}
84
85#[derive(Debug, Serialize)]
86pub struct RouteSettings {
87    #[serde(rename = "ThrottlingBurstLimit", skip_serializing_if = "Option::is_none")]
88    pub(super) throttling_burst_limit: Option<u32>,
89    #[serde(rename = "ThrottlingRateLimit", skip_serializing_if = "Option::is_none")]
90    pub(super) throttling_rate_limit: Option<f64>,
91}
92
93ref_struct!(ApiGatewayV2IntegrationRef);
94
95#[derive(Debug, Serialize)]
96pub struct ApiGatewayV2Integration {
97    #[serde(skip)]
98    pub(super) id: Id,
99    #[serde(skip)]
100    pub(super) resource_id: String,
101    #[serde(rename = "Type")]
102    pub(super) r#type: String,
103    #[serde(rename = "Properties")]
104    pub(super) properties: ApiGatewayV2IntegrationProperties,
105}
106dto_methods!(ApiGatewayV2Integration);
107
108#[derive(Debug, Serialize)]
109pub struct ApiGatewayV2IntegrationProperties {
110    #[serde(rename = "ApiId")]
111    pub(super) api_id: Value,
112    #[serde(rename = "ContentHandlingStrategy", skip_serializing_if = "Option::is_none")]
113    pub(super) content_handling_strategy: Option<String>,
114    #[serde(rename = "IntegrationType")]
115    pub(super) integration_type: String,
116    #[serde(rename = "IntegrationUri", skip_serializing_if = "Option::is_none")]
117    pub(super) integration_uri: Option<Value>,
118    #[serde(rename = "IntegrationMethod", skip_serializing_if = "Option::is_none")]
119    pub(super) integration_method: Option<String>,
120    #[serde(rename = "PassthroughBehavior", skip_serializing_if = "Option::is_none")]
121    pub(super) passthrough_behavior: Option<String>,
122    #[serde(rename = "PayloadFormatVersion", skip_serializing_if = "Option::is_none")]
123    pub(super) payload_format_version: Option<String>,
124    #[serde(rename = "RequestParameters", skip_serializing_if = "Option::is_none")]
125    pub(super) request_parameters: Option<Value>,
126    #[serde(rename = "RequestTemplates", skip_serializing_if = "Option::is_none")]
127    pub(super) request_templates: Option<Value>,
128    #[serde(rename = "ResponseParameters", skip_serializing_if = "Option::is_none")]
129    pub(super) response_parameters: Option<Value>,
130    #[serde(rename = "TimeoutInMillis", skip_serializing_if = "Option::is_none")]
131    pub(super) timeout_in_millis: Option<u32>,
132
133    // #[serde(rename = "IntegrationSubtype", skip_serializing_if = "Option::is_none")]
134    // pub(super) integration_subtype: Option<String>, // only for http api aws proxy
135}
136
137ref_struct!(ApiGatewayV2RouteRef);
138
139#[derive(Debug, Serialize)]
140pub struct ApiGatewayV2Route {
141    #[serde(skip)]
142    pub(super) id: Id,
143    #[serde(skip)]
144    pub(super) resource_id: String,
145    #[serde(rename = "Type")]
146    pub(super) r#type: String,
147    #[serde(rename = "Properties")]
148    pub(super) properties: ApiGatewayV2RouteProperties,
149}
150dto_methods!(ApiGatewayV2Route);
151
152#[derive(Debug, Serialize)]
153pub struct ApiGatewayV2RouteProperties {
154    #[serde(rename = "ApiId")]
155    pub(super) api_id: Value,
156    #[serde(rename = "RouteKey")]
157    pub(super) route_key: String, // match with value for websocket api
158    #[serde(rename = "Target", skip_serializing_if = "Option::is_none")]
159    pub(super) target: Option<Value>,
160
161    // #[serde(rename = "ApiKeyRequired", skip_serializing_if = "Option::is_none")]
162    // pub(super) api_key_required: Option<bool>, // only for websocket
163    // #[serde(rename = "OperationName", skip_serializing_if = "Option::is_none")]
164    // pub(super) operation_name: Option<String>,
165}
166