use crate::{Client, Error, execute_wrapper};
use typesense_codegen::{apis::collections_api, models};
pub struct Alias<'a> {
pub(super) client: &'a Client,
pub(super) alias_name: &'a str,
}
impl<'a> Alias<'a> {
#[inline]
pub(super) fn new(client: &'a Client, alias_name: &'a str) -> Self {
Self { client, alias_name }
}
pub async fn retrieve(
&self,
) -> Result<models::CollectionAlias, Error<collections_api::GetAliasError>> {
let params = collections_api::GetAliasParams {
alias_name: self.alias_name.into(),
};
execute_wrapper!(self, collections_api::get_alias, params)
}
pub async fn delete(
&self,
) -> Result<models::CollectionAlias, Error<collections_api::DeleteAliasError>> {
let params = collections_api::DeleteAliasParams {
alias_name: self.alias_name.into(),
};
execute_wrapper!(self, collections_api::delete_alias, params)
}
}