Skip to main content

rusty_cdk_core/apigateway/
dto.rs

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