runbeam_sdk/runbeam_api/
resources.rs

1use serde::{Deserialize, Serialize};
2
3/// Paginated response wrapper
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct PaginatedResponse<T> {
6    pub data: Vec<T>,
7    pub links: PaginationLinks,
8    pub meta: PaginationMeta,
9}
10
11/// Pagination links
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct PaginationLinks {
14    pub first: Option<String>,
15    pub last: Option<String>,
16    pub prev: Option<String>,
17    pub next: Option<String>,
18}
19
20/// Pagination metadata
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct PaginationMeta {
23    pub current_page: u32,
24    pub from: Option<u32>,
25    pub last_page: u32,
26    pub path: Option<String>,
27    pub per_page: u32,
28    pub to: Option<u32>,
29    pub total: u32,
30}
31
32/// Single resource response wrapper
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct ResourceResponse<T> {
35    pub data: T,
36}
37
38/// Gateway resource
39#[derive(Debug, Clone, Serialize, Deserialize)]
40pub struct Gateway {
41    #[serde(rename = "type")]
42    pub resource_type: String,
43    pub id: String,
44    pub code: String,
45    pub name: String,
46    pub team_id: String,
47    pub enabled: Option<bool>,
48    #[serde(default)]
49    pub pipelines_path: Option<String>,
50    #[serde(default)]
51    pub transforms_path: Option<String>,
52    #[serde(default)]
53    pub jwks_cache_duration_hours: Option<u32>,
54    #[serde(default)]
55    pub management_enabled: Option<bool>,
56    #[serde(default)]
57    pub management_base_path: Option<String>,
58    #[serde(default)]
59    pub management_network_id: Option<String>,
60    #[serde(default)]
61    pub dns: Option<Vec<String>>,
62    #[serde(default)]
63    pub settings: Option<serde_json::Value>,
64    #[serde(default)]
65    pub created_at: Option<String>,
66    #[serde(default)]
67    pub updated_at: Option<String>,
68}
69
70/// User who authorized a gateway
71#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct AuthorizedByInfo {
73    pub id: String,
74    pub name: String,
75    pub email: String,
76}
77
78/// Service resource
79#[derive(Debug, Clone, Serialize, Deserialize)]
80pub struct Service {
81    #[serde(rename = "type")]
82    pub resource_type: String,
83    pub id: String,
84    pub code: String,
85    pub name: String,
86    pub team_id: String,
87    pub gateway_id: String,
88    #[serde(default)]
89    pub description: Option<String>,
90    #[serde(default)]
91    pub created_at: Option<String>,
92    #[serde(default)]
93    pub updated_at: Option<String>,
94}
95
96/// Endpoint resource
97#[derive(Debug, Clone, Serialize, Deserialize)]
98pub struct Endpoint {
99    #[serde(rename = "type")]
100    pub resource_type: String,
101    pub id: String,
102    pub code: String,
103    pub name: String,
104    pub team_id: String,
105    pub gateway_id: Option<String>,
106    #[serde(default)]
107    pub service_id: Option<String>,
108    #[serde(default)]
109    pub path: Option<String>,
110    #[serde(default)]
111    pub methods: Option<Vec<String>>,
112    #[serde(default)]
113    pub description: Option<String>,
114    #[serde(default)]
115    pub created_at: Option<String>,
116    #[serde(default)]
117    pub updated_at: Option<String>,
118}
119
120/// Backend resource
121#[derive(Debug, Clone, Serialize, Deserialize)]
122pub struct Backend {
123    #[serde(rename = "type")]
124    pub resource_type: String,
125    pub id: String,
126    pub code: String,
127    pub name: String,
128    pub team_id: String,
129    pub gateway_id: Option<String>,
130    #[serde(default)]
131    pub service_id: Option<String>,
132    #[serde(default)]
133    pub url: Option<String>,
134    #[serde(default)]
135    pub timeout_seconds: Option<u32>,
136    #[serde(default)]
137    pub created_at: Option<String>,
138    #[serde(default)]
139    pub updated_at: Option<String>,
140}
141
142/// Pipeline resource
143#[derive(Debug, Clone, Serialize, Deserialize)]
144pub struct Pipeline {
145    #[serde(rename = "type")]
146    pub resource_type: String,
147    pub id: String,
148    pub code: String,
149    pub name: String,
150    pub description: String,
151    pub team_id: String,
152    pub gateway_id: Option<String>,
153    #[serde(default)]
154    pub networks: Option<Vec<String>>,
155    #[serde(default)]
156    pub endpoints: Option<serde_json::Value>,
157    #[serde(default)]
158    pub backends: Option<serde_json::Value>,
159    #[serde(default)]
160    pub middleware: Option<serde_json::Value>,
161    #[serde(default)]
162    pub created_at: Option<String>,
163    #[serde(default)]
164    pub updated_at: Option<String>,
165}
166
167/// Middleware resource  
168#[derive(Debug, Clone, Serialize, Deserialize)]
169pub struct Middleware {
170    #[serde(rename = "type")]
171    pub resource_type: String,
172    pub id: String,
173    pub code: String,
174    pub name: String,
175    pub team_id: String,
176    pub middleware_type: String,
177    #[serde(default)]
178    pub options: Option<serde_json::Value>,
179    #[serde(default)]
180    pub created_at: Option<String>,
181    #[serde(default)]
182    pub updated_at: Option<String>,
183}
184
185/// Transform resource
186#[derive(Debug, Clone, Serialize, Deserialize)]
187pub struct Transform {
188    #[serde(rename = "type")]
189    pub resource_type: String,
190    pub id: String,
191    pub code: String,
192    pub name: String,
193    pub team_id: String,
194    pub gateway_id: String,
195    #[serde(default)]
196    pub options: Option<TransformOptions>,
197    #[serde(default)]
198    pub created_at: Option<String>,
199    #[serde(default)]
200    pub updated_at: Option<String>,
201}
202
203/// Transform options
204#[derive(Debug, Clone, Serialize, Deserialize)]
205pub struct TransformOptions {
206    pub instructions: Option<String>,
207}
208
209/// Policy resource
210#[derive(Debug, Clone, Serialize, Deserialize)]
211pub struct Policy {
212    #[serde(rename = "type")]
213    pub resource_type: String,
214    pub id: String,
215    pub code: String,
216    pub name: String,
217    pub enabled: u32,
218    pub team_id: String,
219    pub gateway_id: String,
220    #[serde(default)]
221    pub rules: Option<serde_json::Value>,
222    #[serde(default)]
223    pub created_at: Option<String>,
224    #[serde(default)]
225    pub updated_at: Option<String>,
226}
227
228/// Network resource
229#[derive(Debug, Clone, Serialize, Deserialize)]
230pub struct Network {
231    #[serde(rename = "type")]
232    pub resource_type: String,
233    pub id: String,
234    pub code: String,
235    pub name: String,
236    pub team_id: String,
237    pub gateway_id: Option<String>,
238    pub enable_wireguard: bool,
239    #[serde(default)]
240    pub interface: Option<String>,
241    #[serde(default)]
242    pub http: Option<HttpConfig>,
243    #[serde(default)]
244    pub created_at: Option<String>,
245    #[serde(default)]
246    pub updated_at: Option<String>,
247}
248
249/// HTTP configuration for network
250#[derive(Debug, Clone, Serialize, Deserialize)]
251pub struct HttpConfig {
252    pub bind_address: Option<String>,
253    pub bind_port: Option<u16>,
254}
255
256/// Authentication resource
257#[derive(Debug, Clone, Serialize, Deserialize)]
258pub struct Authentication {
259    #[serde(rename = "type")]
260    pub resource_type: String,
261    pub id: String,
262    pub code: Option<String>,
263    pub name: String,
264    pub team_id: Option<String>,
265    pub gateway_id: Option<String>,
266    #[serde(default)]
267    pub options: Option<String>,
268    #[serde(default)]
269    pub created_at: Option<String>,
270    #[serde(default)]
271    pub updated_at: Option<String>,
272}
273
274/// Full gateway configuration (for downloading complete config)
275#[derive(Debug, Clone, Serialize, Deserialize)]
276pub struct GatewayConfiguration {
277    pub gateway: Gateway,
278    #[serde(default)]
279    pub services: Vec<Service>,
280    #[serde(default)]
281    pub endpoints: Vec<Endpoint>,
282    #[serde(default)]
283    pub backends: Vec<Backend>,
284    #[serde(default)]
285    pub pipelines: Vec<Pipeline>,
286    #[serde(default)]
287    pub middlewares: Vec<Middleware>,
288    #[serde(default)]
289    pub transforms: Vec<Transform>,
290    #[serde(default)]
291    pub policies: Vec<Policy>,
292    #[serde(default)]
293    pub networks: Vec<Network>,
294}