komodo_client 2.1.0

Client for the Komodo build and deployment system
Documentation
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
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
use mogh_resolver::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;

use crate::entities::{
  SearchCombinator, U64,
  docker::{
    config::{SwarmConfigDetails, SwarmConfigListItem},
    network::NetworkListItem,
    node::{SwarmNode, SwarmNodeListItem},
    secret::{SwarmSecret, SwarmSecretListItem},
    service::{SwarmService, SwarmServiceListItem},
    stack::{SwarmStack, SwarmStackListItem},
    swarm::SwarmInspectInfo,
    task::{SwarmTask, SwarmTaskListItem},
  },
  swarm::{Swarm, SwarmActionState, SwarmListItem, SwarmQuery},
  update::Log,
};

use super::KomodoReadRequest;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetSwarm",
  description = "Get a specific swarm.",
  request_body(content = GetSwarm),
  responses(
    (status = 200, description = "The swarm", body = crate::entities::swarm::SwarmSchema),
  ),
)]
pub fn get_swarm() {}

/// Get a specific swarm. Response: [Swarm].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSwarmResponse)]
#[error(mogh_error::Error)]
pub struct GetSwarm {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
}

#[typeshare]
pub type GetSwarmResponse = Swarm;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListSwarms",
  description = "List Swarms matching optional query.",
  request_body(content = ListSwarms),
  responses(
    (status = 200, description = "The list of swarms", body = ListSwarmsResponse),
  ),
)]
pub fn list_swarms() {}

/// List Swarms matching optional query. Response: [ListSwarmsResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmsResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarms {
  /// Optional structured query to filter Swarms.
  #[serde(default)]
  pub query: SwarmQuery,
}

#[typeshare]
pub type ListSwarmsResponse = Vec<SwarmListItem>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListFullSwarms",
  description = "List Swarms matching optional query.",
  request_body(content = ListFullSwarms),
  responses(
    (status = 200, description = "The list of swarms", body = ListFullSwarmsResponse),
  ),
)]
pub fn list_full_swarms() {}

/// List Swarms matching optional query. Response: [ListFullSwarmsResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListFullSwarmsResponse)]
#[error(mogh_error::Error)]
pub struct ListFullSwarms {
  /// optional structured query to filter swarms.
  #[serde(default)]
  pub query: SwarmQuery,
}

#[typeshare]
pub type ListFullSwarmsResponse = Vec<Swarm>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetSwarmActionState",
  description = "Get current action state for the swarm.",
  request_body(content = GetSwarmActionState),
  responses(
    (status = 200, description = "The swarm action state", body = GetSwarmActionStateResponse),
  ),
)]
pub fn get_swarm_action_state() {}

/// Get current action state for the swarm. Response: [SwarmActionState].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSwarmActionStateResponse)]
#[error(mogh_error::Error)]
pub struct GetSwarmActionState {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
}

#[typeshare]
pub type GetSwarmActionStateResponse = SwarmActionState;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetSwarmsSummary",
  description = "Gets a summary of data relating to all swarms.",
  request_body(content = GetSwarmsSummary),
  responses(
    (status = 200, description = "The swarms summary", body = GetSwarmsSummaryResponse),
  ),
)]
pub fn get_swarms_summary() {}

/// Gets a summary of data relating to all swarms.
/// Response: [GetSwarmsSummaryResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSwarmsSummaryResponse)]
#[error(mogh_error::Error)]
pub struct GetSwarmsSummary {}

/// Response for [GetSwarmsSummary]
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct GetSwarmsSummaryResponse {
  /// The total number of Swarms
  pub total: u32,
  /// The number of Swarms with Healthy state.
  pub healthy: u32,
  /// The number of Swarms with Unhealthy state
  pub unhealthy: u32,
  /// The number of Swarms with Down state
  pub down: u32,
  /// The number of Swarms with Unknown state
  pub unknown: u32,
}

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/InspectSwarm",
  description = "Inspect information about the swarm.",
  request_body(content = InspectSwarm),
  responses(
    (status = 200, description = "The swarm inspect info", body = InspectSwarmResponse),
  ),
)]
pub fn inspect_swarm() {}

/// Inspect information about the swarm.
/// Response: [SwarmInspectInfo].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarm {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
}

#[typeshare]
pub type InspectSwarmResponse = SwarmInspectInfo;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListSwarmNodes",
  description = "List nodes part of the target Swarm.",
  request_body(content = ListSwarmNodes),
  responses(
    (status = 200, description = "The list of swarm nodes", body = ListSwarmNodesResponse),
  ),
)]
pub fn list_swarm_nodes() {}

/// List nodes part of the target Swarm.
/// Response: [ListSwarmNodesResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmNodesResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmNodes {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
}

#[typeshare]
pub type ListSwarmNodesResponse = Vec<SwarmNodeListItem>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/InspectSwarmNode",
  description = "Inspect a Swarm node.",
  request_body(content = InspectSwarmNode),
  responses(
    (status = 200, description = "The swarm node", body = InspectSwarmNodeResponse),
  ),
)]
pub fn inspect_swarm_node() {}

/// Inspect a Swarm node.
/// Response: [SwarmNode].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmNodeResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmNode {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
  /// Node id
  pub node: String,
}

#[typeshare]
pub type InspectSwarmNodeResponse = SwarmNode;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListSwarmServices",
  description = "List services on the target Swarm.",
  request_body(content = ListSwarmServices),
  responses(
    (status = 200, description = "The list of swarm services", body = ListSwarmServicesResponse),
  ),
)]
pub fn list_swarm_services() {}

/// List services on the target Swarm.
/// Response: [ListSwarmServicesResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmServicesResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmServices {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
}

#[typeshare]
pub type ListSwarmServicesResponse = Vec<SwarmServiceListItem>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/InspectSwarmService",
  description = "Inspect a Swarm service.",
  request_body(content = InspectSwarmService),
  responses(
    (status = 200, description = "The swarm service", body = InspectSwarmServiceResponse),
  ),
)]
pub fn inspect_swarm_service() {}

/// Inspect a Swarm service.
/// Response: [SwarmService].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmServiceResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmService {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
  /// Service id
  pub service: String,
}

#[typeshare]
pub type InspectSwarmServiceResponse = SwarmService;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetSwarmServiceLog",
  description = "Get a swarm service's logs.",
  request_body(content = GetSwarmServiceLog),
  responses(
    (status = 200, description = "The swarm service log", body = GetSwarmServiceLogResponse),
  ),
)]
pub fn get_swarm_service_log() {}

/// Get a swarm service's logs. Response: [GetSwarmServiceLogResponse].
///
/// Note. This call will hit the underlying server directly for most up to date log.
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSwarmServiceLogResponse)]
#[error(mogh_error::Error)]
pub struct GetSwarmServiceLog {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
  /// Select the swarm service to get logs for.
  pub service: String,
  /// The number of lines of the log tail to include.
  /// Default: 100.
  /// Max: 5000.
  #[serde(default = "default_tail")]
  pub tail: U64,
  /// Enable `--timestamps`
  #[serde(default)]
  pub timestamps: bool,
  /// Enable `--no-task-ids`
  #[serde(default)]
  pub no_task_ids: bool,
  /// Enable `--no-resolve`
  #[serde(default)]
  pub no_resolve: bool,
  /// Enable `--details`
  #[serde(default)]
  pub details: bool,
}

fn default_tail() -> u64 {
  50
}

#[typeshare]
pub type GetSwarmServiceLogResponse = Log;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/SearchSwarmServiceLog",
  description = "Search the swarm service log's tail using `grep`.",
  request_body(content = SearchSwarmServiceLog),
  responses(
    (status = 200, description = "The search results", body = SearchSwarmServiceLogResponse),
  ),
)]
pub fn search_swarm_service_log() {}

/// Search the swarm service log's tail using `grep`. All lines go to stdout.
/// Response: [SearchSwarmServiceLogResponse].
///
/// Note. This call will hit the underlying server directly for most up to date log.
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(SearchSwarmServiceLogResponse)]
#[error(mogh_error::Error)]
pub struct SearchSwarmServiceLog {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
  /// Select the swarm service to get logs for.
  pub service: String,
  /// The terms to search for.
  pub terms: Vec<String>,
  /// When searching for multiple terms, can use `AND` or `OR` combinator.
  ///
  /// - `AND`: Only include lines with **all** terms present in that line.
  /// - `OR`: Include lines that have one or more matches in the terms.
  #[serde(default)]
  pub combinator: SearchCombinator,
  /// Invert the results, ie return all lines that DON'T match the terms / combinator.
  #[serde(default)]
  pub invert: bool,
  /// Enable `--timestamps`
  #[serde(default)]
  pub timestamps: bool,
  /// Enable `--no-task-ids`
  #[serde(default)]
  pub no_task_ids: bool,
  /// Enable `--no-resolve`
  #[serde(default)]
  pub no_resolve: bool,
  /// Enable `--details`
  #[serde(default)]
  pub details: bool,
}

#[typeshare]
pub type SearchSwarmServiceLogResponse = Log;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListSwarmTasks",
  description = "List tasks on the target Swarm.",
  request_body(content = ListSwarmTasks),
  responses(
    (status = 200, description = "The list of swarm tasks", body = ListSwarmTasksResponse),
  ),
)]
pub fn list_swarm_tasks() {}

/// List tasks on the target Swarm.
/// Response: [ListSwarmTasksResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmTasksResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmTasks {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
}

#[typeshare]
pub type ListSwarmTasksResponse = Vec<SwarmTaskListItem>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/InspectSwarmTask",
  description = "Inspect a Swarm task.",
  request_body(content = InspectSwarmTask),
  responses(
    (status = 200, description = "The swarm task", body = InspectSwarmTaskResponse),
  ),
)]
pub fn inspect_swarm_task() {}

/// Inspect a Swarm task.
/// Response: [SwarmTask].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmTaskResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmTask {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
  /// Task id
  pub task: String,
}

#[typeshare]
pub type InspectSwarmTaskResponse = SwarmTask;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListSwarmSecrets",
  description = "List secrets on the target Swarm.",
  request_body(content = ListSwarmSecrets),
  responses(
    (status = 200, description = "The list of swarm secrets", body = ListSwarmSecretsResponse),
  ),
)]
pub fn list_swarm_secrets() {}

/// List secrets on the target Swarm.
/// Response: [ListSwarmSecretsResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmSecretsResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmSecrets {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
}

#[typeshare]
pub type ListSwarmSecretsResponse = Vec<SwarmSecretListItem>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/InspectSwarmSecret",
  description = "Inspect a Swarm secret.",
  request_body(content = InspectSwarmSecret),
  responses(
    (status = 200, description = "The swarm secret", body = InspectSwarmSecretResponse),
  ),
)]
pub fn inspect_swarm_secret() {}

/// Inspect a Swarm secret.
/// Response: [SwarmSecret].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmSecretResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmSecret {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
  /// Secret id
  pub secret: String,
}

#[typeshare]
pub type InspectSwarmSecretResponse = SwarmSecret;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListSwarmConfigs",
  description = "List configs on the target Swarm.",
  request_body(content = ListSwarmConfigs),
  responses(
    (status = 200, description = "The list of swarm configs", body = ListSwarmConfigsResponse),
  ),
)]
pub fn list_swarm_configs() {}

/// List configs on the target Swarm.
/// Response: [ListSwarmConfigsResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmConfigsResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmConfigs {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
}

#[typeshare]
pub type ListSwarmConfigsResponse = Vec<SwarmConfigListItem>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/InspectSwarmConfig",
  description = "Inspect a config on the target Swarm.",
  request_body(content = InspectSwarmConfig),
  responses(
    (status = 200, description = "The swarm config", body = InspectSwarmConfigResponse),
  ),
)]
pub fn inspect_swarm_config() {}

/// Inspect a config on the target Swarm.
/// Response: [InspectSwarmConfigResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmConfigResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmConfig {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
  /// Swarm config ID or Name
  pub config: String,
}

#[typeshare]
pub type InspectSwarmConfigResponse = SwarmConfigDetails;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListSwarmStacks",
  description = "List stacks on the target Swarm.",
  request_body(content = ListSwarmStacks),
  responses(
    (status = 200, description = "The list of swarm stacks", body = ListSwarmStacksResponse),
  ),
)]
pub fn list_swarm_stacks() {}

/// List stacks on the target Swarm.
/// Response: [ListSwarmStacksResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmStacksResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmStacks {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
}

#[typeshare]
pub type ListSwarmStacksResponse = Vec<SwarmStackListItem>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/InspectSwarmStack",
  description = "Inspect a stack on the target Swarm.",
  request_body(content = InspectSwarmStack),
  responses(
    (status = 200, description = "The swarm stack", body = InspectSwarmStackResponse),
  ),
)]
pub fn inspect_swarm_stack() {}

/// Inspect a stack on the target Swarm.
/// Response: [SwarmStackLists].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(InspectSwarmStackResponse)]
#[error(mogh_error::Error)]
pub struct InspectSwarmStack {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
  /// Swarm stack name
  pub stack: String,
}

#[typeshare]
pub type InspectSwarmStackResponse = SwarmStack;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListSwarmNetworks",
  description = "List the networks on the swarm.",
  request_body(content = ListSwarmNetworks),
  responses(
    (status = 200, description = "The list of swarm networks", body = ListSwarmNetworksResponse),
  ),
)]
pub fn list_swarm_networks() {}

/// List the networks on the swarm. Response: [ListSwarmNetworksResponse].
///
/// This only includes the overlay networks.
/// They will be the same across all nodes in the swarm.
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSwarmNetworksResponse)]
#[error(mogh_error::Error)]
pub struct ListSwarmNetworks {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub swarm: String,
}

#[typeshare]
pub type ListSwarmNetworksResponse = Vec<NetworkListItem>;