foundation_deployment_docker 0.1.3

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

#![cfg(feature = "docker_logs")]
#![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
// =============================================================================

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

/// Arguments for [`ContainerLogs_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct ContainerLogsArgs {
    /// Path parameter: `id`.
    pub id: String,
    /// Query parameter: `follow`.
    pub follow: Option<String>,
    /// Query parameter: `stdout`.
    pub stdout: Option<String>,
    /// Query parameter: `stderr`.
    pub stderr: Option<String>,
    /// Query parameter: `since`.
    pub since: Option<String>,
    /// Query parameter: `until`.
    pub until: Option<String>,
    /// Query parameter: `timestamps`.
    pub timestamps: Option<String>,
    /// Query parameter: `tail`.
    pub tail: Option<String>,
}

/// Arguments for [`ServiceLogs_request`].
///
/// Same shape as `super::shared::ServiceLogsArgsShape`.
pub type ServiceLogsArgs = super::shared::ServiceLogsArgsShape;

/// Arguments for [`TaskLogs_request`].
///
/// Same shape as `super::shared::ServiceLogsArgsShape`.
pub type TaskLogsArgs = super::shared::ServiceLogsArgsShape;

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

// -----------------------------------------------------------------------------
// GET /containers/{id}/logs
// -----------------------------------------------------------------------------

/// GET /containers/{id}/logs.
///
/// 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 = container_logs_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn container_logs_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &ContainerLogsArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<super::shared::ByteStream>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/containers/{}/logs", args.id,);
    let endpoint_url = format!("{}{}", base_url, path);

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

    builder = builder.query("follow", args.follow.as_deref());
    builder = builder.query("stdout", args.stdout.as_deref());
    builder = builder.query("stderr", args.stderr.as_deref());
    builder = builder.query("since", args.since.as_deref());
    builder = builder.query("until", args.until.as_deref());
    builder = builder.query("timestamps", args.timestamps.as_deref());
    builder = builder.query("tail", args.tail.as_deref());

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

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

// -----------------------------------------------------------------------------
// GET /services/{id}/logs
// -----------------------------------------------------------------------------

/// GET /services/{id}/logs.
///
/// 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 = service_logs_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn service_logs_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &ServiceLogsArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<super::shared::ByteStream>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/services/{}/logs", args.id,);
    let endpoint_url = format!("{}{}", base_url, path);

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

    builder = builder.query("details", args.details.as_deref());
    builder = builder.query("follow", args.follow.as_deref());
    builder = builder.query("stdout", args.stdout.as_deref());
    builder = builder.query("stderr", args.stderr.as_deref());
    builder = builder.query("since", args.since.as_deref());
    builder = builder.query("timestamps", args.timestamps.as_deref());
    builder = builder.query("tail", args.tail.as_deref());

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

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

// -----------------------------------------------------------------------------
// GET /tasks/{id}/logs
// -----------------------------------------------------------------------------

/// GET /tasks/{id}/logs.
///
/// 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 = task_logs_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn task_logs_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &TaskLogsArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<super::shared::ByteStream>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/tasks/{}/logs", args.id,);
    let endpoint_url = format!("{}{}", base_url, path);

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

    builder = builder.query("details", args.details.as_deref());
    builder = builder.query("follow", args.follow.as_deref());
    builder = builder.query("stdout", args.stdout.as_deref());
    builder = builder.query("stderr", args.stderr.as_deref());
    builder = builder.query("since", args.since.as_deref());
    builder = builder.query("timestamps", args.timestamps.as_deref());
    builder = builder.query("tail", args.tail.as_deref());

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

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