1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
// MIT License
//
// Copyright (c) 2020 Ankur Srivastava
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

use std::collections::HashMap;

use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Alert {
	pub create_time: String,
	pub event: String,
	pub project_name: String,
	pub service_name: String,
	pub service_type: String,
	pub severity: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResAlerts {
	pub alerts: Vec<Alert>,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ACL {
	pub id: String,
	pub permission: String,
	pub topic: String,
	pub username: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Backup {
	pub backup_name: String,
	pub backup_time: String,
	pub data_size: i64,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Component {
	pub component: String,
	pub host: String,
	pub kafka_authentication_method: Option<String>,
	pub port: i32,
	pub route: Option<String>,
	pub ssl: Option<bool>,
	pub usage: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ConnectionPool {
	pub connection_uri: String,
	pub database: String,
	pub pool_mode: String,
	pub pool_name: String,
	pub pool_size: i32,
	pub username: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Update {
	pub deadline: String,
	pub description: String,
	pub start_after: String,
	pub start_at: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Maintenance {
	pub dow: String,
	pub time: String,
	pub updates: Vec<Update>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ProgressUpdate {
	pub completed: bool,
	pub current: i64,
	pub max: i64,
	pub min: i64,
	pub phase: String,
	pub unit: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct NodeState {
	pub name: String,
	pub progress_updates: Vec<ProgressUpdate>,
	pub state: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ServiceIntegration {
	pub active: bool,
	pub description: String,
	pub dest_endpoint: String,
	pub dest_endpoint_id: String,
	pub dest_project: String,
	pub dest_service: String,
	pub dest_service_type: String,
	pub enabled: bool,
	pub integration_status: HashMap<String, serde_json::Value>,
	pub integration_type: String,
	pub service_integration_id: String,
	pub source_endpoint: String,
	pub source_endpoint_id: String,
	pub source_project: String,
	pub source_service: String,
	pub source_service_type: String,
	pub user_config: HashMap<String, serde_json::Value>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Topic {
	pub cleanup_policy: String,
	pub min_insync_replicas: i32,
	pub partitions: i32,
	pub replication: i32,
	pub retention_bytes: i32,
	pub retention_hours: i32,
	pub state: String,
	pub topic_name: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct User {
	pub access_cert: String,
	pub access_key: String,
	pub authentication: Option<String>,
	pub password: String,
	#[serde(rename = "type")]
	pub user_type: String,
	pub username: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Service {
	pub acl: Option<Vec<ACL>>,
	pub backups: Vec<Backup>,
	pub cloud_description: String,
	pub cloud_name: String,
	pub components: Vec<Component>,
	pub connection_info: HashMap<String, serde_json::Value>,
	pub connection_pools: Option<Vec<ConnectionPool>>,
	pub create_time: String,
	pub disk_space_mb: i64,
	pub databases: Option<Vec<String>>,
	pub features: HashMap<String, serde_json::Value>,
	pub group_list: Vec<String>,
	pub maintenance: Maintenance,
	pub metadata: HashMap<String, serde_json::Value>,
	pub node_count: i32,
	pub node_cpu_count: i32,
	pub node_memory_mb: i32,
	pub node_states: Vec<NodeState>,
	pub plan: String,
	pub project_vpc_id: Option<String>,
	pub service_integrations: Vec<ServiceIntegration>,
	pub service_name: String,
	pub service_type: String,
	pub service_type_description: String,
	pub service_uri: String,
	pub service_uri_params: HashMap<String, serde_json::Value>,
	pub state: String,
	pub termination_protection: bool,
	pub topics: Option<Vec<Topic>>,
	pub update_time: String,
	pub user_config: HashMap<String, serde_json::Value>,
	pub users: Vec<User>,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResService {
	pub service: Service,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ServiceCancelQuery {
	pub success: bool,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ServiceUser {
	pub access_cert: String,
	pub access_key: String,
	pub authentication: String,
	pub password: String,
	#[serde(rename = "type")]
	pub account_type: String,
	pub username: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResServiceUser {
	pub user: ServiceUser,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResResetQueryStats {
	pub queries: Vec<serde_json::Value>,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct BackupConfig {
	pub interval: i32,
	pub max_count: i32,
	pub recovery_mode: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Region {
	pub disk_space_mb: i32,
	pub node_cpu_count: i32,
	pub node_memory_mb: i32,
	pub price_usd: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ServicePlan {
	pub backup_config: BackupConfig,
	pub node_count: i64,
	pub regions: HashMap<String, Region>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResServices {
	pub services: Vec<Service>,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ServiceDescription {
	pub description: String,
	pub service_plans: Vec<ServicePlan>,
	pub latest_available_version: Option<String>,
	pub user_config_schema: Option<serde_json::Value>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserConfigSchema {
	#[serde(rename = "additionalProperties")]
	pub additional_properties: bool,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResServiceTypes {
	pub service_types: HashMap<String, ServiceDescription>,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct DatabaseName {
	pub database_name: String,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResDatabaseNames {
	pub databases: Vec<DatabaseName>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Database {
	pub database_name: String,
	pub lc_collate: String,
	pub lc_ctype: String,
	pub owner: String,
	pub quoted_owner: String,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResServiceDatabaseList {
	pub databases: Vec<Database>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResEnableWrites {
	pub until: String,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResServiceCA {
	// PEM encoded certificate
	pub certificate: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResServiceKeyPair {
	// PEM encoded certificate
	pub certificate: String,
	pub key: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Task {
	pub create_time: String,
	pub result: String,
	pub success: bool,
	pub task_type: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResTask {
	pub task: Task,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Log {
	pub msg: String,
	pub time: String,
	pub unit: String,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResLogs {
	pub first_log_offset: String,
	pub logs: Vec<Log>,
	pub offset: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResQueries {
	pub queries: Vec<Query>,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Query {
	pub active_channel_subscriptions: i32,
	pub active_database: String,
	pub active_pattern_matching_channel_subscriptions: i32,
	pub application_name: String,
	pub backend_start: String,
	pub backend_type: String,
	pub backend_xid: String,
	pub backend_xmin: String,
	pub client_addr: String,
	pub client_hostname: String,
	pub client_port: i32,
	pub connection_age_seconds: i32,
	pub connection_idle_seconds: i32,
	pub datid: i32,
	pub datname: String,
	pub flags: Vec<String>,
	pub flags_raw: String,
	pub id: String,
	pub multi_exec_commands: i32,
	pub name: String,
	pub output_buffer: i32,
	pub output_buffer_memory: i32,
	pub output_list_length: i32,
	pub pid: i32,
	pub query: String,
	pub query_buffer: i32,
	pub query_buffer_free: i32,
	pub query_duration: f32,
	pub query_start: String,
	pub state: String,
	pub state_change: String,
	pub usename: String,
	pub usesysid: i32,
	pub wait_event: String,
	pub wait_event_type: String,
	pub waiting: bool,
	pub xact_start: String,
}