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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
use serde_json;
use std::collections::HashMap;

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Line {
    pub status: String,
    pub component: String,
    pub value: String,
    #[serde(rename = "type")]
    pub _type: String,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Status {
    pub now: String,
    pub lines: Option<Vec<Line>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Group {
    pub id: i64,
    pub name: String,
    pub admins: Option<Vec<User>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Permissions {
    #[serde(rename = "Groups")]
    pub groups: Option<Vec<String>>,
    #[serde(rename = "ProjectsPerm")]
    pub projects_perm: Option<HashMap<String, u8>>,
    #[serde(rename = "WorkflowsPerm")]
    pub workflows_perm: Option<HashMap<String, u8>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct User {
    pub id: i64,
    pub username: String,
    pub fullname: String,
    pub email: String,
    pub admin: bool,
    pub groups: Option<Vec<Group>>,
    pub origin: String,
    pub permissions: Permissions,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Project {
    pub key: String,
    pub name: String,
    pub description: String,
    pub icon: String,
    pub permission: u8,
    pub created: String,
    pub last_modified: String,
    pub metadata: serde_json::Value,
    pub keys: Option<Vec<Key>>,
    pub vcs_servers: Option<Vec<VcsServer>>,
    pub integrations: Option<Vec<Integration>>,
    pub features: serde_json::Value,
    pub favorite: bool,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Integration {
    pub id: i64,
    pub project_id: i64,
    pub name: String,
    pub integration_model_id: i64,
    pub model: IntegrationModel,
    pub config: Option<HashMap<String, ConfigValue>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct IntegrationModel {
    pub id: i64,
    pub name: String,
    pub author: String,
    pub identifier: String,
    pub icon: String,
    pub default_config: Option<HashMap<String, ConfigValue>>,
    pub deployment_default_config: Option<HashMap<String, ConfigValue>>,
    pub disabled: bool,
    pub hook: bool,
    pub file_storage: bool,
    pub block_storage: bool,
    pub deployment: bool,
    pub compute: bool,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct ConfigValue {
    pub value: String,
    #[serde(rename = "type")]
    pub _type: String,
    pub description: String,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct VcsServer {
    pub name: String,
    pub username: String,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Application {
    pub id: i64,
    pub name: String,
    pub description: String,
    pub icon: String,
    pub project_key: String,
    pub permission: i64,
    pub last_modified: String,
    pub vcs_server: String,
    pub repository_fullname: String,
    pub vcs_strategy: VcsStrategy,
    pub metadata: serde_json::Value,
    pub keys: Option<Vec<Key>>,
    pub deployment_strategies: serde_json::Value,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct VcsStrategy {
    pub connection_type: String,
    pub ssh_key: String,
    pub user: String,
    pub password: String,
    pub pgp_key: String,
    pub branch: String,
    pub default_branch: String,
    pub ssh_key_content: String,
}

// workflow

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Audit {
    pub id: i64,
    pub triggered_by: String,
    pub created: String,
    pub data_before: String,
    pub data_after: String,
    pub event_type: String,
    pub data_type: String,
    pub project_key: String,
    pub workflow_id: i64,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Conditions {
    pub plain: Option<Vec<PlainCondition>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Context {
    pub id: i64,
    pub node_id: i64,
    pub pipeline_id: i64,
    pub application_id: i64,
    pub environment_id: i64,
    pub project_integration_id: i64,
    pub default_payload: serde_json::Value,
    // default_pipeline_parameters: string,
    pub conditions: Conditions,
    pub mutex: bool,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Environment {
    pub id: i64,
    pub name: String,
    pub variables: Option<Vec<Variable>>,
    pub project_key: String,
    pub permission: i64,
    pub last_modified: i64,
    pub keys: Option<Vec<Key>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Key {
    pub name: String,
    pub public: String,
    pub private: String,
    #[serde(rename = "keyID")]
    pub key_id: String,
    #[serde(rename = "type")]
    pub _type: String,
    pub application_id: i64,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Node {
    pub id: i64,
    pub workflow_id: i64,
    pub name: String,
    #[serde(rename = "ref")]
    pub _ref: String,
    #[serde(rename = "type")]
    pub _type: String,
    pub triggers: Option<Vec<Trigger>>,
    pub context: Option<Context>,
    pub outgoing_hook: Option<Hook>,
    pub parents: Option<Vec<Parent>>,
    pub hooks: Option<Vec<Hook>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Parent {
    pub id: i64,
    pub node_id: i64,
    pub parent_name: String,
    pub parent_id: i64,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Pipeline {
    pub id: i64,
    pub name: String,
    pub description: String,
    #[serde(rename = "type")]
    pub _type: String,
    #[serde(rename = "projectKey")]
    pub project_key: String,
    //   stages: string,
    pub permission: i64,
    pub last_modified: i64,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct PlainCondition {
    pub variable: String,
    pub operator: String,
    pub value: String,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Workflow {
    pub id: i64,
    pub name: String,
    pub last_modified: String,
    pub project_id: i64,
    pub project_key: String,
    pub root_id: i64,
    pub permission: i64,
    pub metadata: serde_json::Value,
    pub usage: Usage,
    pub history_length: i64,
    pub audits: Option<Vec<Audit>>,
    pub pipelines: Option<HashMap<i64, Pipeline>>,
    pub applications: Option<HashMap<i64, Application>>,
    pub environments: Option<HashMap<i64, Environment>>,
    // project_platforms: (),
    //   labels: string,
    pub to_delete: bool,
    pub favorite: bool,
    pub workflow_data: WorkflowData,
    //   as_code_events: Vec<()>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Hook {
    pub id: i64,
    pub uuid: String,
    #[serde(rename = "ref")]
    pub _ref: String,
    pub node_id: i64,
    pub hook_model_id: i64,
    pub config: serde_json::Value,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct HookModel {
    pub id: i64,
    pub name: String,
    #[serde(rename = "type")]
    pub _type: String,
    pub author: String,
    pub description: String,
    pub identifier: String,
    pub icon: String,
    pub command: String,
    pub default_config: serde_json::Value,
    pub disabled: bool,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Trigger {
    pub id: i64,
    pub parent_node_id: i64,
    pub child_node_id: i64,
    pub parent_node_name: String,
    pub child_node: Node,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Usage {
    pub environments: Option<Vec<Environment>>,
    pub pipelines: Option<Vec<Pipeline>>,
    pub applications: Option<Vec<Application>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Variable {
    pub id: i64,
    pub name: String,
    pub value: String,
    #[serde(rename = "type")]
    pub _type: String,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct WorkflowData {
    pub node: Node,
    pub joins: Option<Vec<Node>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct QueueCount {
    #[serde(rename = "version")]
    pub count: i64,
    pub since: String,
    pub until: String,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Bookmark {
    pub icon: String,
    pub description: String,
    pub key: String,
    pub name: String,
    pub application_name: String,
    pub workflow_name: String,
    #[serde(rename = "type")]
    pub _type: String,
    pub favorite: bool,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Action {
    pub id: i64,
    pub name: String,
    pub step_name: String,
    #[serde(rename = "type")]
    pub _type: String,
    pub description: String,
    // requirements: string,
    pub parameters: Option<Vec<Parameter>>,
    pub action: Option<Vec<Box<Action>>>,
    pub enabled: bool,
    pub deprecated: bool,
    pub optional: bool,
    pub always_executed: bool,
    pub last_modified: i64,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Bookedby {
    pub id: i64,
    pub name: String,
    #[serde(rename = "type")]
    pub _type: String,
    pub http_url: String,
    pub last_heartbeat: String,
    pub hash: String,
    pub token: String,
    pub group_id: Option<i64>,
    pub is_shared_infra: bool,
    pub version: String,
    pub up_to_date: bool,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct WorkflowRun {
    pub id: i64,
    pub num: i64,
    pub project_id: i64,
    pub workflow_id: i64,
    pub status: String,
    pub workflow: Workflow,
    pub start: String,
    pub last_modified: String,
    pub nodes: HashMap<String, Vec<NodeRun>>,
    // infos: Vec<Infos>,
    pub tags: Vec<Tag>,
    pub last_subnumber: i64,
    pub last_execution: String,
    pub to_delete: bool,
    pub header: Option<HashMap<String, String>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Tag {
    pub tag: String,
    pub value: String,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct NodeRun {
    pub workflow_run_id: i64,
    pub workflow_id: i64,
    pub application_id: i64,
    pub id: i64,
    pub workflow_node_id: i64,
    pub workflow_node_name: String,
    pub num: i64,
    pub subnumber: i64,
    pub status: String,
    pub stages: Vec<Stages>,
    pub start: String,
    pub last_modified: String,
    pub done: String,
    pub manual: ManualRequest,
    pub payload: serde_json::Value,
    pub build_parameters: Option<Vec<Parameter>>,
    pub coverage: Coverage,
    // pub vulnerabilities_report: VulnerabilitiesReport,
    pub vcs_repository: String,
    pub vcs_tag: String,
    pub vcs_branch: String,
    pub vcs_hash: String,
    pub vcs_server: String,
    pub can_be_run: bool,
    pub header: Option<HashMap<String, String>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct ManualRequest {
    pub payload: serde_json::Value,
    pub pipeline_parameter: Option<Vec<Parameter>>,
    pub user: User,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Stages {
    pub id: i64,
    pub name: String,
    pub build_order: i64,
    pub enabled: bool,
    pub run_jobs: Vec<RunJob>,
    //   prerequisites: string,
    pub last_modified: i64,
    pub jobs: Vec<Job>,
    pub status: String,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct RunJob {
    pub project_id: i64,
    pub id: i64,
    pub workflow_node_run_id: i64,
    pub job: Job,
    pub parameters: Option<Vec<Parameter>>,
    pub status: String,
    pub retry: i64,
    pub queued: String,
    pub queued_seconds: i64,
    pub start: String,
    pub done: String,
    pub bookedby: Bookedby,
    //   spawninfos: Vec<Spawninfos>,
    pub exec_groups: Vec<Group>,
    pub header: Option<HashMap<String, String>>,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Coverage {
    pub workflow_id: i64,
    pub workflow_node_run_id: i64,
    pub workflow_run_id: i64,
    pub application_id: i64,
    pub run_number: i64,
    pub repository: String,
    pub branch: String,
    pub report: Report,
    // pub trend: Trend,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Job {
    // pub step_status: string,
    pub reason: String,
    pub worker_name: String,
    pub worker_id: String,
    pub pipeline_action_id: i64,
    pub pipeline_stage_id: i64,
    pub enabled: bool,
    pub last_modified: i64,
    pub action: Action,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Parameter {
    pub id: i64,
    pub name: String,
    #[serde(rename = "type")]
    pub _type: String,
    pub value: String,
    pub description: String,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Report {
    //   files: string,
    pub total_lines: i64,
    pub covered_lines: i64,
    pub total_functions: i64,
    pub covered_functions: i64,
    pub total_branches: i64,
    pub covered_branches: i64,
}

#[derive(Serialize, Deserialize, Default, Debug)]
#[serde(default)]
pub struct Broadcast {
    pub id: i64,
    pub title: String,
    pub content: String,
    pub level: String,
    pub project_key: String,
    pub created: String,
    pub updated: String,
    pub project_id: Option<i64>,
    pub archived: bool,
    pub read: bool,
}