using ZB.MOM.WW.OtOpcUa.Core.Abstractions;

namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browse;

/// <summary>
///     Maps Galaxy <c>security_classification</c> integer codes to
///     <see cref="SecurityClassification"/>. Ported from the legacy
///     <c>GalaxyProxyDriver.MapSecurity</c>; unknown codes fall back to
///     <see cref="SecurityClassification.FreeAccess"/> so a forward-compatible Galaxy
///     deployment with new classifications doesn't break discovery.
/// </summary>
internal static class SecurityMap
{
    /// <summary>Maps a Galaxy security_classification code to a SecurityClassification enum.</summary>
    /// <param name="mxSec">The Galaxy security classification code.</param>
    /// <returns>The corresponding SecurityClassification.</returns>
    public static SecurityClassification Map(int mxSec) => mxSec switch
    {
        0 => SecurityClassification.FreeAccess,
        1 => SecurityClassification.Operate,
        2 => SecurityClassification.SecuredWrite,
        3 => SecurityClassification.VerifiedWrite,
        4 => SecurityClassification.Tune,
        5 => SecurityClassification.Configure,
        6 => SecurityClassification.ViewOnly,
        _ => SecurityClassification.FreeAccess,
    };
}
