foundation_deployment_docker 0.1.3

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

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

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

use super::shared::ApiResponse;

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

/// `PushImageInfo` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct PushImageInfo {
    /// `errorDetail` property.
    #[serde(rename = "errorDetail")]
    pub error_detail: Option<ErrorDetail>,
    /// `progressDetail` property.
    #[serde(rename = "progressDetail")]
    pub progress_detail: Option<ProgressDetail>,
    /// `status` property.
    pub status: Option<String>,
}

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

/// Arguments for [`ImagePush_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct ImagePushArgs {
    /// Path parameter: `name`.
    pub name: String,
    /// Query parameter: `tag`.
    pub tag: Option<String>,
    /// Query parameter: `platform`.
    pub platform: Option<String>,
}

/// Arguments for [`PluginPush_request`].
///
/// Same shape as `super::shared::NameArgs`.
pub type PluginPushArgs = super::shared::NameArgs;

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

// -----------------------------------------------------------------------------
// POST /images/{name}/push
// -----------------------------------------------------------------------------

/// POST /images/{name}/push.
///
/// 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 `PushImageInfo`, one per line: read it with `.next().await`.
/// The status is checked before the body is touched.
///
/// # Example
///
/// ```ignore
/// let response = image_push_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn image_push_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &ImagePushArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<super::shared::JsonLinesStream<PushImageInfo>>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/images/{}/push", args.name,);
    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("tag", args.tag.as_deref());
    builder = builder.query("platform", args.platform.as_deref());

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

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

// -----------------------------------------------------------------------------
// POST /plugins/{name}/push
// -----------------------------------------------------------------------------

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

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

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

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