namespace ScadaLink.Commons.Messages.Management;

public record ListInstancesCommand(int? SiteId = null, int? TemplateId = null, string? SearchTerm = null);
public record GetInstanceCommand(int InstanceId);
public record CreateInstanceCommand(string UniqueName, int TemplateId, int SiteId, int? AreaId = null);
public record MgmtDeployInstanceCommand(int InstanceId);
public record MgmtEnableInstanceCommand(int InstanceId);
public record MgmtDisableInstanceCommand(int InstanceId);
public record MgmtDeleteInstanceCommand(int InstanceId);
public record SetConnectionBindingsCommand(int InstanceId, IReadOnlyList<(string AttributeName, int DataConnectionId)> Bindings);
public record SetInstanceOverridesCommand(int InstanceId, IReadOnlyDictionary<string, string?> Overrides);
public record SetInstanceAreaCommand(int InstanceId, int? AreaId);

/// <summary>
/// Sets (or upserts) a per-instance alarm override. For HiLo trigger types the
/// <c>TriggerConfigurationOverride</c> JSON is merged setpoint-by-setpoint with
/// the inherited config; for binary trigger types it replaces the whole config.
/// Either field is optional — pass null to leave it unchanged.
/// </summary>
public record SetInstanceAlarmOverrideCommand(
    int InstanceId,
    string AlarmCanonicalName,
    string? TriggerConfigurationOverride,
    int? PriorityLevelOverride);

public record DeleteInstanceAlarmOverrideCommand(
    int InstanceId,
    string AlarmCanonicalName);

public record ListInstanceAlarmOverridesCommand(int InstanceId);
