use manta_backend_dispatcher::{
  error::Error, interfaces::bos::ClusterTemplateTrait,
  types::bos::session_template::BosSessionTemplate,
};

use StaticBackendDispatcher::*;

use crate::manta_backend_dispatcher::StaticBackendDispatcher;

impl ClusterTemplateTrait for StaticBackendDispatcher {
  async fn get_template(
    &self,
    shasta_token: &str,
    shasta_base_url: &str,
    shasta_root_cert: &[u8],
    bos_session_template_id_opt: Option<&str>,
  ) -> Result<Vec<BosSessionTemplate>, Error> {
    dispatch!(
      self,
      get_template,
      shasta_token,
      shasta_base_url,
      shasta_root_cert,
      bos_session_template_id_opt
    )
  }

  async fn get_and_filter_templates(
    &self,
    shasta_token: &str,
    shasta_base_url: &str,
    shasta_root_cert: &[u8],
    hsm_group_name_vec: &[String],
    hsm_member_vec: &[String],
    bos_sessiontemplate_name_opt: Option<&str>,
    limit_number_opt: Option<&u8>,
  ) -> Result<Vec<BosSessionTemplate>, Error> {
    dispatch!(
      self,
      get_and_filter_templates,
      shasta_token,
      shasta_base_url,
      shasta_root_cert,
      hsm_group_name_vec,
      hsm_member_vec,
      bos_sessiontemplate_name_opt,
      limit_number_opt
    )
  }

  async fn get_all_templates(
    &self,
    shasta_token: &str,
    shasta_base_url: &str,
    shasta_root_cert: &[u8],
  ) -> Result<Vec<BosSessionTemplate>, Error> {
    dispatch!(
      self,
      get_all_templates,
      shasta_token,
      shasta_base_url,
      shasta_root_cert
    )
  }

  async fn put_template(
    &self,
    shasta_token: &str,
    shasta_base_url: &str,
    shasta_root_cert: &[u8],
    bos_template: &BosSessionTemplate,
    bos_template_name: &str,
  ) -> Result<BosSessionTemplate, Error> {
    dispatch!(
      self,
      put_template,
      shasta_token,
      shasta_base_url,
      shasta_root_cert,
      bos_template,
      bos_template_name
    )
  }

  async fn delete_template(
    &self,
    shasta_token: &str,
    shasta_base_url: &str,
    shasta_root_cert: &[u8],
    bos_template_id: &str,
  ) -> Result<(), Error> {
    dispatch!(
      self,
      delete_template,
      shasta_token,
      shasta_base_url,
      shasta_root_cert,
      bos_template_id
    )
  }
}
