using SharepointToolbox.Core.Models;
namespace SharepointToolbox.Services;
///
/// Manages Azure AD app registration and removal for a target tenant.
///
public interface IAppRegistrationService
{
///
/// Returns true if the currently-authenticated user has the Global Administrator
/// directory role in the target tenant (checked via transitiveMemberOf for
/// nested-group coverage). Throws on Graph/network failure so the UI can
/// distinguish a confirmed non-admin from a call that could not complete.
///
Task IsGlobalAdminAsync(string clientId, string tenantUrl, CancellationToken ct);
///
/// Creates an Azure AD Application + ServicePrincipal + OAuth2PermissionGrants
/// atomically in the tenant identified by .
/// On any intermediate failure the Application is deleted before returning
/// a Failure result (best-effort rollback).
///
Task RegisterAsync(string clientId, string tenantUrl, string tenantDisplayName, CancellationToken ct);
///
/// Deletes the registered application by its appId in the given tenant.
/// Logs a warning on failure but does not throw.
///
Task RemoveAsync(string clientId, string tenantUrl, string appId, CancellationToken ct);
///
/// Clears the live SessionManager context, evicts all in-memory MSAL accounts,
/// and unregisters the persistent token cache for the given clientId.
///
Task ClearMsalSessionAsync(string clientId, string tenantUrl);
}