runbeam_sdk/runbeam_api/
resources.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4/// Paginated response wrapper
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct PaginatedResponse<T> {
7    pub data: Vec<T>,
8    pub links: PaginationLinks,
9    pub meta: PaginationMeta,
10}
11
12/// Pagination links
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct PaginationLinks {
15    pub first: Option<String>,
16    pub last: Option<String>,
17    pub prev: Option<String>,
18    pub next: Option<String>,
19}
20
21/// Pagination metadata
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct PaginationMeta {
24    pub current_page: u32,
25    pub from: Option<u32>,
26    pub last_page: u32,
27    pub path: Option<String>,
28    pub per_page: u32,
29    pub to: Option<u32>,
30    pub total: u32,
31}
32
33/// Single resource response wrapper
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct ResourceResponse<T> {
36    pub data: T,
37}
38
39/// Gateway resource
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct Gateway {
42    pub id: String,
43    pub code: String,
44    pub name: String,
45    pub enabled: bool,
46    #[serde(default)]
47    pub metadata: Option<HashMap<String, serde_json::Value>>,
48    #[serde(default)]
49    pub authorized_by: Option<AuthorizedByInfo>,
50    pub created_at: String,
51    pub updated_at: String,
52}
53
54/// User who authorized a gateway
55#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct AuthorizedByInfo {
57    pub id: String,
58    pub name: String,
59    pub email: String,
60}
61
62/// Service resource
63#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct Service {
65    pub id: String,
66    pub gateway_id: String,
67    pub name: String,
68    pub service_type: String,
69    #[serde(default)]
70    pub description: Option<String>,
71    #[serde(default)]
72    pub metadata: Option<HashMap<String, serde_json::Value>>,
73    pub created_at: String,
74    pub updated_at: String,
75}
76
77/// Endpoint resource
78#[derive(Debug, Clone, Serialize, Deserialize)]
79pub struct Endpoint {
80    pub id: String,
81    pub service_id: String,
82    pub name: String,
83    pub path: String,
84    pub methods: Vec<String>,
85    #[serde(default)]
86    pub description: Option<String>,
87    pub created_at: String,
88    pub updated_at: String,
89}
90
91/// Backend resource
92#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct Backend {
94    pub id: String,
95    pub service_id: String,
96    pub name: String,
97    pub url: String,
98    #[serde(default)]
99    pub timeout_seconds: Option<u32>,
100    #[serde(default)]
101    pub metadata: Option<HashMap<String, serde_json::Value>>,
102    pub created_at: String,
103    pub updated_at: String,
104}
105
106/// Pipeline resource
107#[derive(Debug, Clone, Serialize, Deserialize)]
108pub struct Pipeline {
109    pub id: String,
110    pub endpoint_id: String,
111    pub backend_id: String,
112    pub name: String,
113    #[serde(default)]
114    pub order: Option<u32>,
115    #[serde(default)]
116    pub middleware_ids: Vec<String>,
117    pub created_at: String,
118    pub updated_at: String,
119}
120
121/// Middleware resource  
122#[derive(Debug, Clone, Serialize, Deserialize)]
123pub struct Middleware {
124    pub id: String,
125    pub name: String,
126    pub middleware_type: String,
127    #[serde(default)]
128    pub config: Option<HashMap<String, serde_json::Value>>,
129    pub created_at: String,
130    pub updated_at: String,
131}
132
133/// Transform resource
134#[derive(Debug, Clone, Serialize, Deserialize)]
135pub struct Transform {
136    pub id: String,
137    pub name: String,
138    pub transform_type: String,
139    #[serde(default)]
140    pub config: Option<HashMap<String, serde_json::Value>>,
141    pub created_at: String,
142    pub updated_at: String,
143}
144
145/// Policy resource
146#[derive(Debug, Clone, Serialize, Deserialize)]
147pub struct Policy {
148    pub id: String,
149    pub name: String,
150    pub policy_type: String,
151    #[serde(default)]
152    pub rules: Option<HashMap<String, serde_json::Value>>,
153    pub created_at: String,
154    pub updated_at: String,
155}
156
157/// Network resource
158#[derive(Debug, Clone, Serialize, Deserialize)]
159pub struct Network {
160    pub id: String,
161    pub gateway_id: String,
162    pub domain: String,
163    #[serde(default)]
164    pub dns_config: Option<HashMap<String, serde_json::Value>>,
165    pub created_at: String,
166    pub updated_at: String,
167}
168
169/// Authentication resource
170#[derive(Debug, Clone, Serialize, Deserialize)]
171pub struct Authentication {
172    pub id: String,
173    pub name: String,
174    pub auth_type: String,
175    #[serde(default)]
176    pub config: Option<HashMap<String, serde_json::Value>>,
177    pub created_at: String,
178    pub updated_at: String,
179}
180
181/// Full gateway configuration (for downloading complete config)
182#[derive(Debug, Clone, Serialize, Deserialize)]
183pub struct GatewayConfiguration {
184    pub gateway: Gateway,
185    #[serde(default)]
186    pub services: Vec<Service>,
187    #[serde(default)]
188    pub endpoints: Vec<Endpoint>,
189    #[serde(default)]
190    pub backends: Vec<Backend>,
191    #[serde(default)]
192    pub pipelines: Vec<Pipeline>,
193    #[serde(default)]
194    pub middlewares: Vec<Middleware>,
195    #[serde(default)]
196    pub transforms: Vec<Transform>,
197    #[serde(default)]
198    pub policies: Vec<Policy>,
199    #[serde(default)]
200    pub networks: Vec<Network>,
201}