use anyhow::Error;
use crate::common::app_context::AppContext;
use crate::http_client::{MantaClient, OpenApiResultExt};
use crate::openapi_client::types::ApplyRuntimeConfigurationRequest;
pub struct ExecParams<'a> {
pub configuration_name: &'a str,
pub hosts_expression: &'a str,
pub disable: bool,
pub dry_run: bool,
}
pub async fn exec(
ctx: &AppContext<'_>,
token: &str,
p: ExecParams<'_>,
) -> Result<(), Error> {
let client = MantaClient::from_app_ctx(ctx, Some(token))?;
let result = client
.openapi
.apply_runtime_configuration(
client.site_name(),
&ApplyRuntimeConfigurationRequest {
cfs_configuration_name: p.configuration_name.to_string(),
hosts_expression: p.hosts_expression.to_string(),
enabled: !p.disable,
dry_run: Some(p.dry_run),
},
)
.await
.into_anyhow()
.await?;
println!("{}", serde_json::to_string_pretty(&result)?);
Ok(())
}