foundation_deployment_docker 0.1.2

Docker Engine API v1.53 client over DynNetClient + valtron (bollard-free)
Documentation
//! Auto-generated API module for docker swarm.
//!
//! Generated by `cargo run --bin ewe_platform gen_api`.
//! DO NOT EDIT MANUALLY.
//!
//! Feature flag: `docker_swarm `

#![cfg(feature = "docker_swarm")]
#![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>>,
}

/// `JoinTokens` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct JoinTokens {
    /// Manager property.
    #[serde(rename = "Manager")]
    pub manager: Option<String>,
    /// Worker property.
    #[serde(rename = "Worker")]
    pub worker: Option<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>,
}

/// `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>,
}

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

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

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

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

// -----------------------------------------------------------------------------
// GET /swarm
// -----------------------------------------------------------------------------

/// GET /swarm.
///
/// 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 = swarm_inspect_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn swarm_inspect_request<F>(
    client: DynNetClient,
    _args: &SwarmInspectArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<Swarm>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/swarm",
    );
    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: Swarm = 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 })
}