1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use super::Session;
use crate::session::session::SessionError;
use crate::session::RUNTIME;
use antimatter_api::apis::internal_api;
use antimatter_api::models::{DataTaggingHookResponse, DomainDataTaggingHookTestRequest};
impl Session {
/// Invoke a hook for testing purposes.
///
/// Arguments:
///
/// * `hook_name` - A &str containing the name of the hook to invoke.
/// * `req` - The hook test request, which contains the `ClassifierRule`
/// to test together with the input on which to test it.
///
/// Returns:
/// A `Result` containing a `DataTaggingHookResponse` which is the result
/// of invoking the argument hook using the `ClassiferRule` and the
/// input from the argument `req`.
pub fn test_hook(
&mut self,
hook_name: &str,
req: DomainDataTaggingHookTestRequest,
) -> Result<DataTaggingHookResponse, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(internal_api::domain_data_tagging_hook_test(
&conf,
self.get_domain_id().as_str(),
hook_name,
req,
))
.map_err(|e| SessionError::APIError(e.to_string()))?;
Ok(res)
}
}