#![cfg(feature = "docker_auth")]
#![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;
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct AuthConfig {
pub password: Option<String>,
pub serveraddress: Option<String>,
pub username: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct AuthResponse {
#[serde(rename = "IdentityToken")]
pub identity_token: Option<String>,
#[serde(rename = "Status")]
pub status: String,
}
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct SystemAuthArgs {
pub body: AuthConfig,
}
pub async fn system_auth_request<F>(
client: impl Into<super::shared::ApiClient>,
args: &SystemAuthArgs,
base_url: &str,
builder_mod: Option<F>,
) -> Result<ApiResponse<AuthResponse>, super::shared::ApiError>
where
F: FnOnce(&mut PreparedRequestBuilder),
{
let path = format!("/auth",);
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_json(client.into(), builder.build()).await
}