use serde::Serialize;
use serde_json::Value;
use manta_shared::types::dto::BosSessionTemplate;
use manta_shared::types::params::template::GetTemplateParams;
use super::{MantaClient, QueryBuilder};
#[derive(Serialize)]
pub struct ApplyTemplateSessionRequest<'a> {
pub operation: &'a str,
pub limit: &'a str,
pub session_name: Option<&'a str>,
pub include_disabled: bool,
pub dry_run: bool,
}
impl MantaClient {
pub async fn get_templates(
&self,
token: &str,
params: &GetTemplateParams,
) -> anyhow::Result<Vec<BosSessionTemplate>> {
let q = QueryBuilder::new()
.opt("name", ¶ms.name)
.opt("hsm_group", ¶ms.hsm_group)
.opt_display("limit", ¶ms.limit)
.build();
self.get_json(token, "/templates", &q).await
}
pub async fn apply_template_session(
&self,
token: &str,
name: &str,
req: &ApplyTemplateSessionRequest<'_>,
) -> anyhow::Result<Value> {
self
.post_json(token, &format!("/templates/{name}/sessions"), req)
.await
}
}