fix: Set-PveHaRule requires mandatory Type parameter

PVE 9 API requires 'type' on PUT /cluster/ha/rules/{rule} even for
updates. Added mandatory Type parameter with ValidateSet for
node-affinity and resource-affinity.

Updated integration test and Pester unit tests to pass -Type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Clint Branham
2026-03-25 17:52:23 -05:00
parent d43387806e
commit 514ce3fc1b
3 changed files with 17 additions and 3 deletions
@@ -19,6 +19,11 @@ namespace PSProxmoxVE.Cmdlets.HA
HelpMessage = "HA rule ID.")]
public string Rule { get; set; } = string.Empty;
/// <summary>Rule type (required by PVE API on update).</summary>
[Parameter(Mandatory = true, Position = 1, HelpMessage = "HA rule type: node-affinity or resource-affinity.")]
[ValidateSet("node-affinity", "resource-affinity")]
public string Type { get; set; } = string.Empty;
/// <summary>Rule state.</summary>
[Parameter(Mandatory = false, HelpMessage = "Rule state: enabled or disabled.")]
[ValidateSet("enabled", "disabled")]
@@ -42,7 +47,7 @@ namespace PSProxmoxVE.Cmdlets.HA
var service = new HaService();
var data = new Dictionary<string, string>();
var data = new Dictionary<string, string> { ["type"] = Type };
if (State != null) data["state"] = State;
if (Comment != null) data["comment"] = Comment;
if (Properties != null)