using System.Security.Claims;

namespace ZB.MOM.WW.MxGateway.Server.Dashboard;

public interface IDashboardApiKeyManagementService
{
    /// <summary>Determines whether the user can manage API keys.</summary>
    /// <param name="user">The user principal.</param>
    /// <returns>True if the user can manage keys; otherwise false.</returns>
    bool CanManage(ClaimsPrincipal user);

    /// <summary>Creates a new API key.</summary>
    /// <param name="user">The user principal.</param>
    /// <param name="request">The key creation request details.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The creation result.</returns>
    Task<DashboardApiKeyManagementResult> CreateAsync(
        ClaimsPrincipal user,
        DashboardApiKeyManagementRequest request,
        CancellationToken cancellationToken);

    /// <summary>Revokes an existing API key.</summary>
    /// <param name="user">The user principal.</param>
    /// <param name="keyId">The key identifier to revoke.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The revocation result.</returns>
    Task<DashboardApiKeyManagementResult> RevokeAsync(
        ClaimsPrincipal user,
        string keyId,
        CancellationToken cancellationToken);

    /// <summary>Rotates an existing API key.</summary>
    /// <param name="user">The user principal.</param>
    /// <param name="keyId">The key identifier to rotate.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The rotation result.</returns>
    Task<DashboardApiKeyManagementResult> RotateAsync(
        ClaimsPrincipal user,
        string keyId,
        CancellationToken cancellationToken);

    /// <summary>Deletes an API key.</summary>
    /// <param name="user">The user principal.</param>
    /// <param name="keyId">The key identifier to delete.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>The deletion result.</returns>
    Task<DashboardApiKeyManagementResult> DeleteAsync(
        ClaimsPrincipal user,
        string keyId,
        CancellationToken cancellationToken);
}
