foundation_deployment_docker 0.1.0

Docker Engine API v1.53 client over DynNetClient + valtron (bollard-free)
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
//! Auto-generated API module for docker info.
//!
//! Generated by `cargo run --bin ewe_platform gen_api`.
//! DO NOT EDIT MANUALLY.
//!
//! Feature flag: `docker_info `

#![cfg(feature = "docker_info")]
#![allow(clippy::too_many_arguments, clippy::type_complexity)]
#![allow(clippy::missing_errors_doc, clippy::doc_markdown, clippy::useless_format)]
#![allow(unused_imports)]

use foundation_netio::{DynNetClient, PreparedRequestBuilder};
use foundation_netio::shared::client::http_client::HttpClient;
use serde::{Deserialize, Serialize};
use foundation_macros::JsonHash;

// Import shared types used by this module
use super::shared::ObjectVersion;

use super::shared::ApiResponse;

// =============================================================================
// TYPE DECLARATIONS
// =============================================================================

/// `SwarmSpec` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct SwarmSpec {
    /// CAConfig property.
    #[serde(rename = "CAConfig")]
    pub ca_config: Option<std::collections::HashMap<String, serde_json::Value>>,
    /// Dispatcher property.
    #[serde(rename = "Dispatcher")]
    pub dispatcher: Option<std::collections::HashMap<String, serde_json::Value>>,
    /// EncryptionConfig property.
    #[serde(rename = "EncryptionConfig")]
    pub encryption_config: Option<std::collections::HashMap<String, serde_json::Value>>,
    /// Labels property.
    #[serde(rename = "Labels")]
    pub labels: Option<serde_json::Value>,
    /// Name property.
    #[serde(rename = "Name")]
    pub name: Option<String>,
    /// Orchestration property.
    #[serde(rename = "Orchestration")]
    pub orchestration: Option<std::collections::HashMap<String, serde_json::Value>>,
    /// Raft property.
    #[serde(rename = "Raft")]
    pub raft: Option<std::collections::HashMap<String, serde_json::Value>>,
    /// TaskDefaults property.
    #[serde(rename = "TaskDefaults")]
    pub task_defaults: Option<std::collections::HashMap<String, serde_json::Value>>,
}

/// `SwarmInfo` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct SwarmInfo {
    /// Cluster property.
    #[serde(rename = "Cluster")]
    pub cluster: Option<ClusterInfo>,
    /// ControlAvailable property.
    #[serde(rename = "ControlAvailable")]
    pub control_available: Option<bool>,
    /// Error property.
    #[serde(rename = "Error")]
    pub error: Option<String>,
    /// LocalNodeState property.
    #[serde(rename = "LocalNodeState")]
    pub local_node_state: Option<LocalNodeState>,
    /// Managers property.
    #[serde(rename = "Managers")]
    pub managers: Option<i64>,
    /// NodeAddr property.
    #[serde(rename = "NodeAddr")]
    pub node_addr: Option<String>,
    /// NodeID property.
    #[serde(rename = "NodeID")]
    pub node_id: Option<String>,
    /// Nodes property.
    #[serde(rename = "Nodes")]
    pub nodes: Option<i64>,
    /// RemoteManagers property.
    #[serde(rename = "RemoteManagers")]
    pub remote_managers: Option<Vec<PeerNode>>,
}

/// `SystemInfo` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct SystemInfo {
    /// Architecture property.
    #[serde(rename = "Architecture")]
    pub architecture: Option<String>,
    /// CDISpecDirs property.
    #[serde(rename = "CDISpecDirs")]
    pub cdi_spec_dirs: Option<Vec<String>>,
    /// CPUSet property.
    #[serde(rename = "CPUSet")]
    pub cpu_set: Option<bool>,
    /// CPUShares property.
    #[serde(rename = "CPUShares")]
    pub cpu_shares: Option<bool>,
    /// CgroupDriver property.
    #[serde(rename = "CgroupDriver")]
    pub cgroup_driver: Option<String>,
    /// CgroupVersion property.
    #[serde(rename = "CgroupVersion")]
    pub cgroup_version: Option<String>,
    /// Containerd property.
    #[serde(rename = "Containerd")]
    pub containerd: Option<ContainerdInfo>,
    /// ContainerdCommit property.
    #[serde(rename = "ContainerdCommit")]
    pub containerd_commit: Option<Commit>,
    /// Containers property.
    #[serde(rename = "Containers")]
    pub containers: Option<i64>,
    /// ContainersPaused property.
    #[serde(rename = "ContainersPaused")]
    pub containers_paused: Option<i64>,
    /// ContainersRunning property.
    #[serde(rename = "ContainersRunning")]
    pub containers_running: Option<i64>,
    /// ContainersStopped property.
    #[serde(rename = "ContainersStopped")]
    pub containers_stopped: Option<i64>,
    /// CpuCfsPeriod property.
    #[serde(rename = "CpuCfsPeriod")]
    pub cpu_cfs_period: Option<bool>,
    /// CpuCfsQuota property.
    #[serde(rename = "CpuCfsQuota")]
    pub cpu_cfs_quota: Option<bool>,
    /// Debug property.
    #[serde(rename = "Debug")]
    pub debug: Option<bool>,
    /// DefaultAddressPools property.
    #[serde(rename = "DefaultAddressPools")]
    pub default_address_pools: Option<Vec<std::collections::HashMap<String, serde_json::Value>>>,
    /// DefaultRuntime property.
    #[serde(rename = "DefaultRuntime")]
    pub default_runtime: Option<String>,
    /// DiscoveredDevices property.
    #[serde(rename = "DiscoveredDevices")]
    pub discovered_devices: Option<Vec<DeviceInfo>>,
    /// DockerRootDir property.
    #[serde(rename = "DockerRootDir")]
    pub docker_root_dir: Option<String>,
    /// Driver property.
    #[serde(rename = "Driver")]
    pub driver: Option<String>,
    /// DriverStatus property.
    #[serde(rename = "DriverStatus")]
    pub driver_status: Option<Vec<Vec<String>>>,
    /// ExperimentalBuild property.
    #[serde(rename = "ExperimentalBuild")]
    pub experimental_build: Option<bool>,
    /// FirewallBackend property.
    #[serde(rename = "FirewallBackend")]
    pub firewall_backend: Option<FirewallInfo>,
    /// GenericResources property.
    #[serde(rename = "GenericResources")]
    pub generic_resources: Option<Vec<std::collections::HashMap<String, serde_json::Value>>>,
    /// HttpProxy property.
    #[serde(rename = "HttpProxy")]
    pub http_proxy: Option<String>,
    /// HttpsProxy property.
    #[serde(rename = "HttpsProxy")]
    pub https_proxy: Option<String>,
    /// ID property.
    #[serde(rename = "ID")]
    pub id: Option<String>,
    /// IPv4Forwarding property.
    #[serde(rename = "IPv4Forwarding")]
    pub i_pv4_forwarding: Option<bool>,
    /// Images property.
    #[serde(rename = "Images")]
    pub images: Option<i64>,
    /// IndexServerAddress property.
    #[serde(rename = "IndexServerAddress")]
    pub index_server_address: Option<String>,
    /// InitBinary property.
    #[serde(rename = "InitBinary")]
    pub init_binary: Option<String>,
    /// InitCommit property.
    #[serde(rename = "InitCommit")]
    pub init_commit: Option<Commit>,
    /// Isolation property.
    #[serde(rename = "Isolation")]
    pub isolation: Option<String>,
    /// KernelVersion property.
    #[serde(rename = "KernelVersion")]
    pub kernel_version: Option<String>,
    /// Labels property.
    #[serde(rename = "Labels")]
    pub labels: Option<Vec<String>>,
    /// LiveRestoreEnabled property.
    #[serde(rename = "LiveRestoreEnabled")]
    pub live_restore_enabled: Option<bool>,
    /// LoggingDriver property.
    #[serde(rename = "LoggingDriver")]
    pub logging_driver: Option<String>,
    /// MemTotal property.
    #[serde(rename = "MemTotal")]
    pub mem_total: Option<i64>,
    /// MemoryLimit property.
    #[serde(rename = "MemoryLimit")]
    pub memory_limit: Option<bool>,
    /// NCPU property.
    #[serde(rename = "NCPU")]
    pub ncpu: Option<i64>,
    /// NEventsListener property.
    #[serde(rename = "NEventsListener")]
    pub n_events_listener: Option<i64>,
    /// NFd property.
    #[serde(rename = "NFd")]
    pub n_fd: Option<i64>,
    /// NGoroutines property.
    #[serde(rename = "NGoroutines")]
    pub n_goroutines: Option<i64>,
    /// NRI property.
    #[serde(rename = "NRI")]
    pub nri: Option<NRIInfo>,
    /// Name property.
    #[serde(rename = "Name")]
    pub name: Option<String>,
    /// NoProxy property.
    #[serde(rename = "NoProxy")]
    pub no_proxy: Option<String>,
    /// OSType property.
    #[serde(rename = "OSType")]
    pub os_type: Option<String>,
    /// OSVersion property.
    #[serde(rename = "OSVersion")]
    pub os_version: Option<String>,
    /// OomKillDisable property.
    #[serde(rename = "OomKillDisable")]
    pub oom_kill_disable: Option<bool>,
    /// OperatingSystem property.
    #[serde(rename = "OperatingSystem")]
    pub operating_system: Option<String>,
    /// PidsLimit property.
    #[serde(rename = "PidsLimit")]
    pub pids_limit: Option<bool>,
    /// Plugins property.
    #[serde(rename = "Plugins")]
    pub plugins: Option<PluginsInfo>,
    /// ProductLicense property.
    #[serde(rename = "ProductLicense")]
    pub product_license: Option<String>,
    /// RegistryConfig property.
    #[serde(rename = "RegistryConfig")]
    pub registry_config: Option<RegistryServiceConfig>,
    /// RuncCommit property.
    #[serde(rename = "RuncCommit")]
    pub runc_commit: Option<Commit>,
    /// Runtimes property.
    #[serde(rename = "Runtimes")]
    pub runtimes: Option<serde_json::Value>,
    /// SecurityOptions property.
    #[serde(rename = "SecurityOptions")]
    pub security_options: Option<Vec<String>>,
    /// ServerVersion property.
    #[serde(rename = "ServerVersion")]
    pub server_version: Option<String>,
    /// SwapLimit property.
    #[serde(rename = "SwapLimit")]
    pub swap_limit: Option<bool>,
    /// Swarm property.
    #[serde(rename = "Swarm")]
    pub swarm: Option<SwarmInfo>,
    /// SystemTime property.
    #[serde(rename = "SystemTime")]
    pub system_time: Option<String>,
    /// Warnings property.
    #[serde(rename = "Warnings")]
    pub warnings: Option<Vec<String>>,
}

/// `ClusterInfo` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ClusterInfo {
    /// CreatedAt property.
    #[serde(rename = "CreatedAt")]
    pub created_at: Option<String>,
    /// DataPathPort property.
    #[serde(rename = "DataPathPort")]
    pub data_path_port: Option<i64>,
    /// DefaultAddrPool property.
    #[serde(rename = "DefaultAddrPool")]
    pub default_addr_pool: Option<Vec<String>>,
    /// ID property.
    #[serde(rename = "ID")]
    pub id: Option<String>,
    /// RootRotationInProgress property.
    #[serde(rename = "RootRotationInProgress")]
    pub root_rotation_in_progress: Option<bool>,
    /// Spec property.
    #[serde(rename = "Spec")]
    pub spec: Option<SwarmSpec>,
    /// SubnetSize property.
    #[serde(rename = "SubnetSize")]
    pub subnet_size: Option<i64>,
    /// TLSInfo property.
    #[serde(rename = "TLSInfo")]
    pub tls_info: Option<TLSInfo>,
    /// UpdatedAt property.
    #[serde(rename = "UpdatedAt")]
    pub updated_at: Option<String>,
    /// Version property.
    #[serde(rename = "Version")]
    pub version: Option<ObjectVersion>,
}

/// `LocalNodeState` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct LocalNodeState {
    #[serde(flatten)]
    pub data: std::collections::HashMap<String, serde_json::Value>,
}

/// `PeerNode` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct PeerNode {
    /// Addr property.
    #[serde(rename = "Addr")]
    pub addr: Option<String>,
    /// NodeID property.
    #[serde(rename = "NodeID")]
    pub node_id: Option<String>,
}

/// `FirewallInfo` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct FirewallInfo {
    /// Driver property.
    #[serde(rename = "Driver")]
    pub driver: Option<String>,
    /// Info property.
    #[serde(rename = "Info")]
    pub info: Option<Vec<Vec<String>>>,
}

/// `TLSInfo` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct TLSInfo {
    /// CertIssuerPublicKey property.
    #[serde(rename = "CertIssuerPublicKey")]
    pub cert_issuer_public_key: Option<String>,
    /// CertIssuerSubject property.
    #[serde(rename = "CertIssuerSubject")]
    pub cert_issuer_subject: Option<String>,
    /// TrustRoot property.
    #[serde(rename = "TrustRoot")]
    pub trust_root: Option<String>,
}

/// `ContainerdInfo` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ContainerdInfo {
    /// Address property.
    #[serde(rename = "Address")]
    pub address: Option<String>,
    /// Namespaces property.
    #[serde(rename = "Namespaces")]
    pub namespaces: Option<std::collections::HashMap<String, serde_json::Value>>,
}

/// `GenericResources` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct GenericResources {
    #[serde(flatten)]
    pub data: std::collections::HashMap<String, serde_json::Value>,
}

/// `DeviceInfo` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct DeviceInfo {
    /// ID property.
    #[serde(rename = "ID")]
    pub id: Option<String>,
    /// Source property.
    #[serde(rename = "Source")]
    pub source: Option<String>,
}

/// `PluginsInfo` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct PluginsInfo {
    /// Authorization property.
    #[serde(rename = "Authorization")]
    pub authorization: Option<Vec<String>>,
    /// Log property.
    #[serde(rename = "Log")]
    pub log: Option<Vec<String>>,
    /// Network property.
    #[serde(rename = "Network")]
    pub network: Option<Vec<String>>,
    /// Volume property.
    #[serde(rename = "Volume")]
    pub volume: Option<Vec<String>>,
}

/// `Commit` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct Commit {
    /// ID property.
    #[serde(rename = "ID")]
    pub id: Option<String>,
}

/// `RegistryServiceConfig` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct RegistryServiceConfig {
    /// IndexConfigs property.
    #[serde(rename = "IndexConfigs")]
    pub index_configs: Option<serde_json::Value>,
    /// InsecureRegistryCIDRs property.
    #[serde(rename = "InsecureRegistryCIDRs")]
    pub insecure_registry_cid_rs: Option<Vec<String>>,
    /// Mirrors property.
    #[serde(rename = "Mirrors")]
    pub mirrors: Option<Vec<String>>,
}

/// `NRIInfo` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct NRIInfo {
    /// Info property.
    #[serde(rename = "Info")]
    pub info: Option<Vec<Vec<String>>>,
}

// =============================================================================
// ARGS TYPES (per-endpoint)
// =============================================================================

/// Arguments for [`SystemInfo_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct SystemInfoArgs {
}

// =============================================================================
// CLIENT FUNCTIONS (per-endpoint)
// =============================================================================

// -----------------------------------------------------------------------------
// GET /info
// -----------------------------------------------------------------------------

/// GET /info.
///
/// Takes a `DynNetClient` and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = system_info_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn system_info_request<F>(
    client: DynNetClient,
    _args: &SystemInfoArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<SystemInfo>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/info",
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::get(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    let response = client.send_async(builder.build()).await
        .map_err(|e| super::shared::ApiError::RequestSendFailed(e.to_string()))?;

    let status: usize = response.get_status().into();
    let headers = response.get_headers_ref().clone();
    if status < 200 || status >= 300 {
        return Err(super::shared::ApiError::HttpStatus { code: status as u16, headers, body: None });
    }
    let body_bytes = foundation_netio::shared::client::body_reader::collect_bytes_from_send_safe(response.take_body());
    let parsed: SystemInfo = serde_json::from_slice(&body_bytes).map_err(|e: serde_json::Error| super::shared::ApiError::ParseFailed(e.to_string()))?;
    Ok(ApiResponse { status: status as u16, headers, body: parsed })
}