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
use std::collections::HashMap;

use serde::{Deserialize, Serialize};
use typeshare::typeshare;

use crate::entities::{
  I64, NoData, U64, docker::task::TaskSpecRestartPolicyConditionEnum,
  swarm::SwarmState,
};

use super::{
  EndpointPortConfig, NetworkAttachmentConfig, ObjectVersion,
  task::TaskSpec,
};

/// Swarm service list item.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct SwarmServiceListItem {
  #[serde(rename = "ID")]
  pub id: Option<String>,

  /// Name of the service.
  #[serde(rename = "Name")]
  pub name: Option<String>,

  /// The image associated with service
  #[serde(rename = "Image")]
  pub image: Option<String>,

  /// Runtime is the type of runtime specified for the task executor.
  #[serde(rename = "Runtime")]
  pub runtime: Option<String>,

  /// Condition for restart.
  #[serde(rename = "Restart")]
  pub restart: Option<TaskSpecRestartPolicyConditionEnum>,

  /// The service mode.
  #[serde(rename = "Mode")]
  pub mode: Option<SwarmServiceMode>,

  /// Number of replicas (in a replicated mode)
  #[serde(rename = "Replicas")]
  pub replicas: Option<I64>,

  /// Max concurrent tasks (in a replicated job mode)
  #[serde(rename = "MaxConcurrent")]
  pub max_concurrent: Option<I64>,

  /// Attached config names
  #[serde(rename = "Configs")]
  pub configs: Vec<String>,

  /// Attached secret names
  #[serde(rename = "Secrets")]
  pub secrets: Vec<String>,

  /// The number of tasks for the service currently in the Running state.
  #[serde(rename = "RunningTasks")]
  pub running_tasks: Option<U64>,

  /// The number of tasks for the service desired to be running.
  /// - For replicated services, this is the replica count from the service spec.
  /// - For global services, this is computed by taking count of all tasks for the
  ///   service with a Desired State other than Shutdown.
  #[serde(rename = "DesiredTasks")]
  pub desired_tasks: Option<U64>,

  /// The number of tasks for a job that are in the Completed state.
  /// This field must be cross-referenced with the service type,
  /// as the value of 0 may mean the service is not in a job mode,
  /// or it may mean the job-mode service has no tasks yet Completed.
  #[serde(rename = "CompletedTasks")]
  pub completed_tasks: Option<U64>,

  /// Swarm service state.
  /// - Healthy if all associated tasks match their desired state (or report no desired state)
  /// - Unhealthy otherwise
  ///
  /// Not included in docker cli return, computed by Komodo
  #[serde(rename = "State")]
  pub state: SwarmState,

  #[serde(rename = "CreatedAt")]
  pub created_at: Option<String>,

  #[serde(rename = "UpdatedAt")]
  pub updated_at: Option<String>,
}

/// The service mode.
#[typeshare]
#[derive(
  Debug,
  Clone,
  Copy,
  PartialEq,
  Eq,
  PartialOrd,
  Ord,
  Serialize,
  Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum SwarmServiceMode {
  /// Replicated service
  /// - Run desired number of replicas
  Replicated,
  /// Global service
  /// - Run once per node
  Global,
  /// Replicated job
  /// - Scheduled tasks which run to completion
  /// - Run desired number of job replicas
  ReplicatedJob,
  /// Global job
  /// - Scheduled tasks which run to completion
  /// - Run one job per node
  GlobalJob,
}

/// Swarm service details.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct SwarmService {
  #[serde(rename = "ID")]
  pub id: Option<String>,

  /// The service mode.
  #[serde(rename = "Mode")]
  pub mode: Option<SwarmServiceMode>,

  /// Number of replicas (in a replicated mode)
  #[serde(rename = "Replicas")]
  pub replicas: Option<I64>,

  /// Max concurrent tasks (in a replicated job mode)
  #[serde(rename = "MaxConcurrent")]
  pub max_concurrent: Option<I64>,

  /// Swarm service state.
  /// - Healthy if all associated tasks match their desired state (or report no desired state)
  /// - Unhealthy otherwise
  ///
  /// Not included in docker cli return, computed by Komodo
  #[serde(rename = "State")]
  pub state: SwarmState,

  #[serde(rename = "Version")]
  pub version: Option<ObjectVersion>,

  #[serde(rename = "CreatedAt")]
  pub created_at: Option<String>,

  #[serde(rename = "UpdatedAt")]
  pub updated_at: Option<String>,

  #[serde(rename = "Spec")]
  pub spec: Option<ServiceSpec>,

  #[serde(rename = "Endpoint")]
  pub endpoint: Option<ServiceEndpoint>,

  #[serde(rename = "UpdateStatus")]
  pub update_status: Option<ServiceUpdateStatus>,

  #[serde(rename = "ServiceStatus")]
  pub service_status: Option<ServiceServiceStatus>,

  #[serde(rename = "JobStatus")]
  pub job_status: Option<ServiceJobStatus>,
}

/// User modifiable configuration for a service.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceSpec {
  /// Name of the service.
  #[serde(rename = "Name")]
  pub name: Option<String>,

  /// User-defined key/value metadata.
  #[serde(rename = "Labels")]
  pub labels: Option<HashMap<String, String>>,

  #[serde(rename = "TaskTemplate")]
  pub task_template: Option<TaskSpec>,

  #[serde(rename = "Mode")]
  pub mode: Option<ServiceSpecMode>,

  #[serde(rename = "UpdateConfig")]
  pub update_config: Option<ServiceSpecUpdateConfig>,

  #[serde(rename = "RollbackConfig")]
  pub rollback_config: Option<ServiceSpecRollbackConfig>,

  /// Specifies which networks the service should attach to.  Deprecated: This field is deprecated since v1.44. The Networks field in TaskSpec should be used instead.
  #[serde(rename = "Networks")]
  pub networks: Option<Vec<NetworkAttachmentConfig>>,

  #[serde(rename = "EndpointSpec")]
  pub endpoint_spec: Option<EndpointSpec>,
}

/// Scheduling mode for the service.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceSpecMode {
  #[serde(rename = "Replicated")]
  pub replicated: Option<ServiceSpecModeReplicated>,

  #[serde(rename = "Global")]
  pub global: Option<NoData>,

  #[serde(rename = "ReplicatedJob")]
  pub replicated_job: Option<ServiceSpecModeReplicatedJob>,

  /// The mode used for services which run a task to the completed state on each valid node.
  #[serde(rename = "GlobalJob")]
  pub global_job: Option<NoData>,
}

#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceSpecModeReplicated {
  #[serde(rename = "Replicas")]
  pub replicas: Option<I64>,
}

/// The mode used for services with a finite number of tasks that run to a completed state.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceSpecModeReplicatedJob {
  /// The maximum number of replicas to run simultaneously.
  #[serde(rename = "MaxConcurrent")]
  pub max_concurrent: Option<I64>,

  /// The total number of replicas desired to reach the Completed state. If unset, will default to the value of `MaxConcurrent`
  #[serde(rename = "TotalCompletions")]
  pub total_completions: Option<I64>,
}

/// Specification for the update strategy of the service.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceSpecUpdateConfig {
  /// Maximum number of tasks to be updated in one iteration (0 means unlimited parallelism).
  #[serde(rename = "Parallelism")]
  pub parallelism: Option<I64>,

  /// Amount of time between updates, in nanoseconds.
  #[serde(rename = "Delay")]
  pub delay: Option<I64>,

  /// Action to take if an updated task fails to run, or stops running during the update.
  #[serde(rename = "FailureAction")]
  pub failure_action:
    Option<ServiceSpecUpdateConfigFailureActionEnum>,

  /// Amount of time to monitor each updated task for failures, in nanoseconds.
  #[serde(rename = "Monitor")]
  pub monitor: Option<I64>,

  /// The fraction of tasks that may fail during an update before the failure action is invoked, specified as a floating point number between 0 and 1.
  #[serde(rename = "MaxFailureRatio")]
  pub max_failure_ratio: Option<f64>,

  /// The order of operations when rolling out an updated task. Either the old task is shut down before the new task is started, or the new task is started before the old task is shut down.
  #[serde(rename = "Order")]
  pub order: Option<ServiceSpecUpdateConfigOrderEnum>,
}

#[typeshare]
#[derive(
  Debug,
  Clone,
  Copy,
  PartialEq,
  Eq,
  PartialOrd,
  Ord,
  Default,
  Serialize,
  Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum ServiceSpecUpdateConfigFailureActionEnum {
  #[default]
  #[serde(rename = "")]
  EMPTY,
  #[serde(rename = "continue")]
  CONTINUE,
  #[serde(rename = "pause")]
  PAUSE,
  #[serde(rename = "rollback")]
  ROLLBACK,
}

#[allow(non_camel_case_types)]
#[typeshare]
#[derive(
  Debug,
  Clone,
  Copy,
  PartialEq,
  Eq,
  PartialOrd,
  Ord,
  Default,
  Serialize,
  Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum ServiceSpecUpdateConfigOrderEnum {
  #[default]
  #[serde(rename = "")]
  EMPTY,
  #[serde(rename = "stop-first")]
  STOP_FIRST,
  #[serde(rename = "start-first")]
  START_FIRST,
}

/// Specification for the rollback strategy of the service.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceSpecRollbackConfig {
  /// Maximum number of tasks to be rolled back in one iteration (0 means unlimited parallelism).
  #[serde(rename = "Parallelism")]
  pub parallelism: Option<I64>,

  /// Amount of time between rollback iterations, in nanoseconds.
  #[serde(rename = "Delay")]
  pub delay: Option<I64>,

  /// Action to take if an rolled back task fails to run, or stops running during the rollback.
  #[serde(rename = "FailureAction")]
  pub failure_action:
    Option<ServiceSpecRollbackConfigFailureActionEnum>,

  /// Amount of time to monitor each rolled back task for failures, in nanoseconds.
  #[serde(rename = "Monitor")]
  pub monitor: Option<I64>,

  /// The fraction of tasks that may fail during a rollback before the failure action is invoked, specified as a floating point number between 0 and 1.
  #[serde(rename = "MaxFailureRatio")]
  pub max_failure_ratio: Option<f64>,

  /// The order of operations when rolling back a task. Either the old task is shut down before the new task is started, or the new task is started before the old task is shut down.
  #[serde(rename = "Order")]
  pub order: Option<ServiceSpecRollbackConfigOrderEnum>,
}

#[typeshare]
#[derive(
  Debug,
  Clone,
  Copy,
  PartialEq,
  Eq,
  PartialOrd,
  Ord,
  Default,
  Serialize,
  Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum ServiceSpecRollbackConfigFailureActionEnum {
  #[default]
  #[serde(rename = "")]
  EMPTY,
  #[serde(rename = "continue")]
  CONTINUE,
  #[serde(rename = "pause")]
  PAUSE,
}

#[allow(non_camel_case_types)]
#[typeshare]
#[derive(
  Debug,
  Clone,
  Copy,
  PartialEq,
  Eq,
  PartialOrd,
  Ord,
  Default,
  Serialize,
  Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum ServiceSpecRollbackConfigOrderEnum {
  #[default]
  #[serde(rename = "")]
  EMPTY,
  #[serde(rename = "stop-first")]
  STOP_FIRST,
  #[serde(rename = "start-first")]
  START_FIRST,
}

/// Properties that can be configured to access and load balance a service.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct EndpointSpec {
  /// The mode of resolution to use for internal load balancing between tasks.
  #[serde(rename = "Mode")]
  pub mode: Option<EndpointSpecModeEnum>,

  /// List of exposed ports that this service is accessible on from the outside. Ports can only be provided if `vip` resolution mode is used.
  #[serde(rename = "Ports")]
  pub ports: Option<Vec<EndpointPortConfig>>,
}

#[typeshare]
#[derive(
  Debug,
  Clone,
  Copy,
  PartialEq,
  Eq,
  PartialOrd,
  Ord,
  Default,
  Serialize,
  Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum EndpointSpecModeEnum {
  #[default]
  #[serde(rename = "")]
  EMPTY,
  #[serde(rename = "vip")]
  VIP,
  #[serde(rename = "dnsrr")]
  DNSRR,
}

#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceEndpoint {
  #[serde(rename = "Spec")]
  pub spec: Option<EndpointSpec>,

  #[serde(rename = "Ports")]
  pub ports: Option<Vec<EndpointPortConfig>>,

  #[serde(rename = "VirtualIPs")]
  pub virtual_ips: Option<Vec<ServiceEndpointVirtualIps>>,
}

#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceEndpointVirtualIps {
  #[serde(rename = "NetworkID")]
  pub network_id: Option<String>,

  #[serde(rename = "Addr")]
  pub addr: Option<String>,
}

/// The status of a service update.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceUpdateStatus {
  #[serde(rename = "State")]
  pub state: Option<ServiceUpdateStatusStateEnum>,

  #[serde(rename = "StartedAt")]
  pub started_at: Option<String>,

  #[serde(rename = "CompletedAt")]
  pub completed_at: Option<String>,

  #[serde(rename = "Message")]
  pub message: Option<String>,
}

#[allow(non_camel_case_types)]
#[typeshare]
#[derive(
  Debug,
  Clone,
  Copy,
  PartialEq,
  Eq,
  PartialOrd,
  Ord,
  Default,
  Serialize,
  Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub enum ServiceUpdateStatusStateEnum {
  #[default]
  #[serde(rename = "")]
  EMPTY,
  #[serde(rename = "updating")]
  UPDATING,
  #[serde(rename = "paused")]
  PAUSED,
  #[serde(rename = "completed")]
  COMPLETED,
  #[serde(rename = "rollback_started")]
  ROLLBACK_STARTED,
  #[serde(rename = "rollback_paused")]
  ROLLBACK_PAUSED,
  #[serde(rename = "rollback_completed")]
  ROLLBACK_COMPLETED,
}

/// The status of the service's tasks. Provided only when requested as part of a ServiceList operation.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceServiceStatus {
  /// The number of tasks for the service currently in the Running state.
  #[serde(rename = "RunningTasks")]
  pub running_tasks: Option<U64>,

  /// The number of tasks for the service desired to be running.
  /// For replicated services, this is the replica count from the service spec.
  /// For global services, this is computed by taking count of all tasks for the service with a Desired State other than Shutdown.
  #[serde(rename = "DesiredTasks")]
  pub desired_tasks: Option<U64>,

  /// The number of tasks for a job that are in the Completed state.
  /// This field must be cross-referenced with the service type, as the value of 0 may mean the service is not in a job mode,
  /// or it may mean the job-mode service has no tasks yet Completed.
  #[serde(rename = "CompletedTasks")]
  pub completed_tasks: Option<U64>,
}

/// The status of the service when it is in one of ReplicatedJob or GlobalJob modes. Absent on Replicated and Global mode services. The JobIteration is an ObjectVersion, but unlike the Service's version, does not need to be sent with an update request.
#[typeshare]
#[derive(
  Debug, Clone, Default, PartialEq, Serialize, Deserialize,
)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct ServiceJobStatus {
  /// JobIteration is a value increased each time a Job is executed, successfully or otherwise. \"Executed\", in this case, means the job as a whole has been started, not that an individual Task has been launched. A job is \"Executed\" when its ServiceSpec is updated. JobIteration can be used to disambiguate Tasks belonging to different executions of a job.  Though JobIteration will increase with each subsequent execution, it may not necessarily increase by 1, and so JobIteration should not be used to
  #[serde(rename = "JobIteration")]
  pub job_iteration: Option<ObjectVersion>,

  /// The last time, as observed by the server, that this job was started.
  #[serde(rename = "LastExecution")]
  pub last_execution: Option<String>,
}