#![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};
use super::shared::ErrorDetail;
use super::shared::ProgressDetail;
use super::shared::ApiResponse;
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct PushImageInfo {
#[serde(rename = "errorDetail")]
pub error_detail: Option<ErrorDetail>,
#[serde(rename = "progressDetail")]
pub progress_detail: Option<ProgressDetail>,
pub status: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct ImagePushArgs {
pub name: String,
pub tag: Option<String>,
pub platform: Option<String>,
}
pub type PluginPushArgs = super::shared::NameArgs;
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
}
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
}