@@ -4,10 +4,11 @@ use serde::{Deserialize, Serialize};
44use serde_json:: Value ;
55use sqlx:: FromRow ;
66use std:: collections:: HashMap ;
7+ use utoipa:: ToSchema ;
78use uuid:: Uuid ;
89use validator:: Validate ;
910
10- #[ derive( Debug , Clone , FromRow , Serialize , Deserialize ) ]
11+ #[ derive( Debug , Clone , FromRow , Serialize , Deserialize , ToSchema ) ]
1112pub struct Deployment {
1213 pub id : Uuid ,
1314 pub user_id : Uuid ,
@@ -25,49 +26,66 @@ pub struct Deployment {
2526 pub deployed_at : Option < DateTime < Utc > > ,
2627}
2728
28- #[ derive( Debug , Deserialize , Validate ) ]
29+ #[ derive( Debug , Deserialize , Validate , ToSchema ) ]
2930pub struct CreateDeploymentRequest {
31+ /// Application name (1-63 characters, DNS-compatible)
3032 #[ validate( length( min = 1 , max = 63 ) ) ]
3133 pub app_name : String ,
34+ /// Container image URL
3235 #[ validate( length( min = 1 ) ) ]
3336 pub image : String ,
37+ /// Port number the container listens on (1-65535)
3438 #[ validate( range( min = 1 , max = 65535 ) ) ]
3539 pub port : i32 ,
40+ /// Environment variables
3641 pub env_vars : Option < HashMap < String , String > > ,
42+ /// Number of replicas (1-100)
3743 #[ validate( range( min = 1 , max = 100 ) ) ]
3844 pub replicas : Option < i32 > ,
45+ /// Resource requirements
3946 pub resources : Option < ResourceRequirements > ,
47+ /// Health check configuration
4048 pub health_check : Option < HealthCheck > ,
49+ /// Registry authentication (if required)
4150 pub registry_auth : Option < RegistryAuth > ,
4251}
4352
44- #[ derive( Debug , Serialize , Deserialize , Validate , Default ) ]
53+ #[ derive( Debug , Serialize , Deserialize , Validate , Default , ToSchema ) ]
4554pub struct ResourceRequirements {
55+ /// CPU request/limit (e.g., "100m", "0.5")
4656 pub cpu : Option < String > ,
57+ /// Memory request/limit (e.g., "128Mi", "1Gi")
4758 pub memory : Option < String > ,
4859}
4960
50- #[ derive( Debug , Serialize , Deserialize , Validate ) ]
61+ #[ derive( Debug , Serialize , Deserialize , Validate , ToSchema ) ]
5162pub struct HealthCheck {
63+ /// Health check endpoint path
5264 #[ validate( length( min = 1 ) ) ]
5365 pub path : String ,
66+ /// Initial delay before first health check (0-300 seconds)
5467 #[ validate( range( min = 0 , max = 300 ) ) ]
5568 pub initial_delay_seconds : Option < i32 > ,
69+ /// Interval between health checks (1-300 seconds)
5670 #[ validate( range( min = 1 , max = 300 ) ) ]
5771 pub period_seconds : Option < i32 > ,
72+ /// Timeout for each health check (1-60 seconds)
5873 #[ validate( range( min = 1 , max = 60 ) ) ]
5974 pub timeout_seconds : Option < i32 > ,
75+ /// Number of failures before marking unhealthy (1-10)
6076 #[ validate( range( min = 1 , max = 10 ) ) ]
6177 pub failure_threshold : Option < i32 > ,
6278}
6379
64- #[ derive( Debug , Deserialize ) ]
80+ #[ derive( Debug , Deserialize , ToSchema ) ]
6581pub struct RegistryAuth {
82+ /// Registry username
6683 pub username : String ,
84+ /// Registry password
6785 pub password : String ,
6886}
6987
70- #[ derive( Debug , Serialize ) ]
88+ #[ derive( Debug , Serialize , ToSchema ) ]
7189pub struct DeploymentResponse {
7290 pub id : Uuid ,
7391 pub app_name : String ,
@@ -78,7 +96,7 @@ pub struct DeploymentResponse {
7896 pub message : String ,
7997}
8098
81- #[ derive( Debug , Serialize ) ]
99+ #[ derive( Debug , Serialize , ToSchema ) ]
82100pub struct DeploymentListItem {
83101 pub id : Uuid ,
84102 pub app_name : String ,
@@ -90,75 +108,87 @@ pub struct DeploymentListItem {
90108 pub updated_at : DateTime < Utc > ,
91109}
92110
93- #[ derive( Debug , Serialize ) ]
111+ #[ derive( Debug , Serialize , ToSchema ) ]
94112pub struct DeploymentListResponse {
95113 pub deployments : Vec < DeploymentListItem > ,
96114 pub pagination : PaginationInfo ,
97115}
98116
99- #[ derive( Debug , Serialize ) ]
117+ #[ derive( Debug , Serialize , ToSchema ) ]
100118pub struct PaginationInfo {
101119 pub page : u32 ,
102120 pub limit : u32 ,
103121 pub total : u64 ,
104122 pub total_pages : u32 ,
105123}
106124
107- #[ derive( Debug , Deserialize , Validate ) ]
125+ #[ derive( Debug , Deserialize , Validate , ToSchema ) ]
108126pub struct UpdateDeploymentRequest {
127+ /// New container image
109128 pub image : Option < String > ,
129+ /// Updated environment variables
110130 pub env_vars : Option < HashMap < String , String > > ,
131+ /// New replica count (1-100)
111132 #[ validate( range( min = 1 , max = 100 ) ) ]
112133 pub replicas : Option < i32 > ,
134+ /// Updated resource requirements
113135 pub resources : Option < ResourceRequirements > ,
114136}
115137
116- #[ derive( Debug , Deserialize , Validate ) ]
138+ #[ derive( Debug , Deserialize , Validate , ToSchema ) ]
117139pub struct ScaleDeploymentRequest {
140+ /// Number of replicas (0-100)
118141 #[ validate( range( min = 0 , max = 100 ) ) ]
119142 pub replicas : i32 ,
120143}
121144
122- #[ derive( Debug , Deserialize ) ]
145+ #[ derive( Debug , Deserialize , ToSchema ) ]
123146pub struct LogsQuery {
147+ /// Number of lines to show from the end
124148 pub tail : Option < i32 > ,
149+ /// Follow log output (streaming)
125150 pub follow : Option < bool > ,
151+ /// Show logs after this timestamp
126152 pub since : Option < DateTime < Utc > > ,
153+ /// Show logs before this timestamp
127154 pub until : Option < DateTime < Utc > > ,
128155}
129156
130- #[ derive( Debug , Serialize ) ]
157+ #[ derive( Debug , Serialize , ToSchema ) ]
131158pub struct LogEntry {
132159 pub timestamp : DateTime < Utc > ,
133160 pub level : String ,
134161 pub message : String ,
135162 pub source : String ,
136163}
137164
138- #[ derive( Debug , Serialize ) ]
165+ #[ derive( Debug , Serialize , ToSchema ) ]
139166pub struct LogsResponse {
140167 pub logs : Vec < LogEntry > ,
141168}
142169
143- #[ derive( Debug , Deserialize ) ]
170+ #[ derive( Debug , Deserialize , ToSchema ) ]
144171pub struct MetricsQuery {
172+ /// Start time for metrics
145173 pub from : Option < DateTime < Utc > > ,
174+ /// End time for metrics
146175 pub to : Option < DateTime < Utc > > ,
176+ /// Metrics resolution
147177 pub resolution : Option < String > ,
148178}
149179
150- #[ derive( Debug , Serialize ) ]
180+ #[ derive( Debug , Serialize , ToSchema ) ]
151181pub struct MetricPoint {
152182 pub timestamp : DateTime < Utc > ,
153183 pub value : f64 ,
154184}
155185
156- #[ derive( Debug , Serialize ) ]
186+ #[ derive( Debug , Serialize , ToSchema ) ]
157187pub struct MetricsResponse {
158188 pub metrics : HashMap < String , Vec < MetricPoint > > ,
159189}
160190
161- #[ derive( Debug , Serialize ) ]
191+ #[ derive( Debug , Serialize , ToSchema ) ]
162192pub struct DeploymentStatus {
163193 pub status : String ,
164194 pub health : String ,
@@ -168,20 +198,21 @@ pub struct DeploymentStatus {
168198 pub restart_count : i32 ,
169199}
170200
171- #[ derive( Debug , Serialize ) ]
201+ #[ derive( Debug , Serialize , ToSchema ) ]
172202pub struct ReplicaStatus {
173203 pub desired : i32 ,
174204 pub ready : i32 ,
175205 pub available : i32 ,
176206}
177207
178- #[ derive( Debug , Deserialize , Validate ) ]
208+ #[ derive( Debug , Deserialize , Validate , ToSchema ) ]
179209pub struct AddDomainRequest {
210+ /// Custom domain name (1-253 characters)
180211 #[ validate( length( min = 1 , max = 253 ) ) ]
181212 pub domain : String ,
182213}
183214
184- #[ derive( Debug , Serialize ) ]
215+ #[ derive( Debug , Serialize , ToSchema ) ]
185216pub struct DomainResponse {
186217 pub id : Uuid ,
187218 pub domain : String ,
@@ -190,19 +221,19 @@ pub struct DomainResponse {
190221 pub dns_records : Vec < DnsRecord > ,
191222}
192223
193- #[ derive( Debug , Serialize ) ]
224+ #[ derive( Debug , Serialize , ToSchema ) ]
194225pub struct DnsRecord {
195226 pub record_type : String ,
196227 pub name : String ,
197228 pub value : String ,
198229}
199230
200- #[ derive( Debug , Serialize ) ]
231+ #[ derive( Debug , Serialize , ToSchema ) ]
201232pub struct DomainListResponse {
202233 pub domains : Vec < DomainListItem > ,
203234}
204235
205- #[ derive( Debug , Serialize ) ]
236+ #[ derive( Debug , Serialize , ToSchema ) ]
206237pub struct DomainListItem {
207238 pub id : Uuid ,
208239 pub domain : String ,
0 commit comments