use std::sync::Arc;
use crate::error::{map_manager_err, ManagerError};
use crate::gen::manager::apis::configuration::Configuration;
use crate::gen::manager::apis::manager_api as api;
use crate::gen::manager::models;
use crate::retry::{with_retry, RetryPolicy};
pub struct ExpressionsResource {
pub(crate) cfg: Arc<Configuration>,
pub(crate) retry: RetryPolicy,
}
impl ExpressionsResource {
pub async fn list(&self) -> Result<Vec<models::AvailableExpression>, ManagerError> {
let resp = with_retry(&self.retry, true, || {
api::list_expressions(self.cfg.as_ref())
})
.await
.map_err(map_manager_err)?;
Ok(resp.items)
}
pub async fn evaluate(
&self,
body: models::EvaluateExpression,
is_async: bool,
) -> Result<models::EvaluateExpressionResponse, ManagerError> {
with_retry(&self.retry, false, || {
api::evaluate_expression(self.cfg.as_ref(), is_async, Some(body.clone()))
})
.await
.map_err(map_manager_err)
}
}