using Microsoft.Extensions.Options;
using ZB.MOM.WW.ScadaBridge.HealthMonitoring;

namespace ZB.MOM.WW.ScadaBridge.Host;

/// <summary>
/// Provides the site identity from NodeOptions configuration.
/// </summary>
public class SiteIdentityProvider : ISiteIdentityProvider
{
    /// <inheritdoc />
    public string SiteId { get; }

    /// <summary>
    /// Initializes the provider by reading the site id from node options.
    /// </summary>
    /// <param name="nodeOptions">Node configuration containing the site id.</param>
    public SiteIdentityProvider(IOptions<NodeOptions> nodeOptions)
    {
        SiteId = nodeOptions.Value.SiteId
            ?? throw new InvalidOperationException("SiteId is required for site nodes.");
    }
}
