use super::*;
use async_trait::async_trait;

use crate::executors::ExecutorError;

#[async_trait]
pub trait TenantManager {
    /// Provisions a new tenant based on the provided configuration.
    /// This operation should be idempotent; if a tenant with the same `config.name`
    /// already exists and matches the config, it will succeed without changes.
    /// If it exists but differs, it will be updated, or return an error if the update
    /// action is not supported
    ///
    /// # Arguments
    /// * `config`: The desired configuration for the new tenant.
    async fn provision_tenant(&self, config: &TenantConfig) -> Result<(), ExecutorError>;

    /// Updates the resource limits for an existing tenant.
    ///
    /// # Arguments
    /// * `tenant_name`: The logical name of the tenant to update.
    /// * `new_limits`: The new set of resource limits to apply.
    async fn update_tenant_resource_limits(
        &self,
        tenant_name: &str,
        new_limits: &ResourceLimits,
    ) -> Result<(), ExecutorError>;

    /// Updates the high-level network isolation policy for an existing tenant.
    ///
    /// # Arguments
    /// * `tenant_name`: The logical name of the tenant to update.
    /// * `new_policy`: The new network policy to apply.
    async fn update_tenant_network_policy(
        &self,
        tenant_name: &str,
        new_policy: &TenantNetworkPolicy,
    ) -> Result<(), ExecutorError>;

    /// Decommissions an existing tenant, removing its isolated context and associated resources.
    /// This operation should be idempotent.
    ///
    /// # Arguments
    /// * `tenant_name`: The logical name of the tenant to deprovision.
    async fn deprovision_tenant(&self, tenant_name: &str) -> Result<(), ExecutorError>;
}
