using ZB.MOM.WW.OtOpcUa.Configuration.Enums;

namespace ZB.MOM.WW.OtOpcUa.Configuration.Entities;

/// <summary>
///     Top-level deployment unit. 1 or 2 <see cref="ClusterNode"/> members.
///     Per <c>config-db-schema.md</c> ServerCluster table.
/// </summary>
public sealed class ServerCluster
{
    /// <summary>Stable logical ID, e.g. "LINE3-OPCUA".</summary>
    public required string ClusterId { get; set; }

    public required string Name { get; set; }

    /// <summary>UNS level 1. Canonical org value: "zb" per decision #140.</summary>
    public required string Enterprise { get; set; }

    /// <summary>UNS level 2, e.g. "warsaw-west".</summary>
    public required string Site { get; set; }

    public byte NodeCount { get; set; }

    public required RedundancyMode RedundancyMode { get; set; }

    public bool Enabled { get; set; } = true;

    public string? Notes { get; set; }

    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    public required string CreatedBy { get; set; }

    public DateTime? ModifiedAt { get; set; }

    public string? ModifiedBy { get; set; }

    // Navigation
    public ICollection<ClusterNode> Nodes { get; set; } = [];
    public ICollection<Namespace> Namespaces { get; set; } = [];
    public ICollection<ConfigGeneration> Generations { get; set; } = [];
}
