antimatter 2.0.13

antimatter.io Rust library for data control
Documentation
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)
    }
}