use async_trait::async_trait;
use modkit_security::SecurityContext;
use crate::error::TenantResolverError;
use crate::models::{
GetAncestorsOptions, GetAncestorsResponse, GetDescendantsOptions, GetDescendantsResponse,
GetTenantsOptions, IsAncestorOptions, TenantId, TenantInfo,
};
#[async_trait]
pub trait TenantResolverClient: Send + Sync {
async fn get_tenant(
&self,
ctx: &SecurityContext,
id: TenantId,
) -> Result<TenantInfo, TenantResolverError>;
async fn get_root_tenant(
&self,
ctx: &SecurityContext,
) -> Result<TenantInfo, TenantResolverError>;
async fn get_tenants(
&self,
ctx: &SecurityContext,
ids: &[TenantId],
options: &GetTenantsOptions,
) -> Result<Vec<TenantInfo>, TenantResolverError>;
async fn get_ancestors(
&self,
ctx: &SecurityContext,
id: TenantId,
options: &GetAncestorsOptions,
) -> Result<GetAncestorsResponse, TenantResolverError>;
async fn get_descendants(
&self,
ctx: &SecurityContext,
id: TenantId,
options: &GetDescendantsOptions,
) -> Result<GetDescendantsResponse, TenantResolverError>;
async fn is_ancestor(
&self,
ctx: &SecurityContext,
ancestor_id: TenantId,
descendant_id: TenantId,
options: &IsAncestorOptions,
) -> Result<bool, TenantResolverError>;
}