using System.Text.Json.Serialization;

namespace NexusShell.Services.Policy;

public sealed class NexusPolicyRule
{
    [JsonPropertyName("type")]
    public string Type { get; set; } = string.Empty;

    [JsonPropertyName("target")]
    public string Target { get; set; } = string.Empty;

    [JsonPropertyName("value")]
    public string? Value { get; set; }

    public NexusPolicyRuleType? ParsedType =>
        Enum.TryParse<NexusPolicyRuleType>(Type, ignoreCase: true, out var parsed) ? parsed : null;
}
