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

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

/// <summary>
///     Authenticates a <see cref="ClusterNode"/> to the central config DB.
///     Credentials bind to NodeId, not ClusterId.
/// </summary>
public sealed class ClusterNodeCredential
{
    /// <summary>Gets or sets the credential identifier.</summary>
    public Guid CredentialId { get; set; }

    /// <summary>Gets or sets the node identifier this credential binds to.</summary>
    public required string NodeId { get; set; }

    /// <summary>Gets or sets the credential kind (login, certificate, etc.).</summary>
    public required CredentialKind Kind { get; set; }

    /// <summary>Gets or sets the credential value (login name / cert thumbprint / SID / gMSA name).</summary>
    public required string Value { get; set; }

    /// <summary>Gets or sets a value indicating whether the credential is enabled.</summary>
    public bool Enabled { get; set; } = true;

    /// <summary>Gets or sets the date/time when the credential was last rotated.</summary>
    public DateTime? RotatedAt { get; set; }

    /// <summary>Gets or sets the date/time when the credential was created.</summary>
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    /// <summary>Gets or sets the user who created the credential.</summary>
    public required string CreatedBy { get; set; }

    /// <summary>Gets or sets the related cluster node.</summary>
    public ClusterNode? Node { get; set; }
}
