foundation_deployment_docker 0.1.3

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

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

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

use super::shared::ApiResponse;

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

/// `ExecStartRequest` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ExecStartRequest {
    /// `ConsoleSize` property.
    #[serde(rename = "ConsoleSize")]
    pub console_size: Option<Vec<i64>>,
    /// `Detach` property.
    #[serde(rename = "Detach")]
    pub detach: Option<bool>,
    /// `Tty` property.
    #[serde(rename = "Tty")]
    pub tty: Option<bool>,
}

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

/// Arguments for [`ContainerStart_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct ContainerStartArgs {
    /// Path parameter: `id`.
    pub id: String,
    /// Query parameter: `detachKeys`.
    pub detach_keys: Option<String>,
}

/// Arguments for [`ExecStart_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct ExecStartArgs {
    /// Path parameter: `id`.
    pub id: String,
    /// Request body.
    pub body: ExecStartRequest,
}

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

// -----------------------------------------------------------------------------
// POST /containers/{id}/start
// -----------------------------------------------------------------------------

/// POST /containers/{id}/start.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `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 = container_start_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn container_start_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &ContainerStartArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<()>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/containers/{}/start", args.id,);
    let endpoint_url = format!("{}{}", base_url, path);

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

    builder = builder.query("detachKeys", args.detach_keys.as_deref());

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

    super::shared::send_without_body(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// POST /exec/{id}/start
// -----------------------------------------------------------------------------

/// POST /exec/{id}/start.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Response body
///
/// Returned unread, as a stream of byte chunks: read it with `.next().await`.
/// The status is checked before the body is touched.
///
/// # Example
///
/// ```ignore
/// let response = exec_start_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn exec_start_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &ExecStartArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<super::shared::ByteStream>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/exec/{}/start", args.id,);
    let endpoint_url = format!("{}{}", base_url, path);

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

    builder = builder
        .body_json(&args.body)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

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

    super::shared::send_bytes(client.into(), builder.build()).await
}