Files
PSProxmoxVE/src/PSProxmoxVE.Core/Models/Cluster/PvePool.cs
T
Clint Branham 3ce19a721c feat: emit native types instead of Newtonsoft JObject/JArray in public APIs
Replace all Newtonsoft.Json.Linq types (JObject, JArray, JToken) exposed
in public service methods, model properties, and cmdlet OutputTypes with
native .NET types (Dictionary<string, object?>, List<Dictionary<string,
object?>>, PSObject).

New utilities:
- JsonHelper: ToNative, ToDictionary, ToListOfDictionaries for recursive
  JToken→native conversion
- NativeListConverter / NativeDictionaryConverter: JsonConverters for
  model properties that deserialize JArray/JObject to native types

Services updated (8 methods):
- NodeService: GetNodeConfig, GetNodeDns → Dictionary<string, object?>
- BackupService: GetNotBackedUp → List<Dictionary<string, object?>>
- ClusterConfigService: GetClusterConfig, GetTotem, GetQdevice → Dictionary
- HaService: GetManagerStatus → Dictionary<string, object?>
- VmService: GetGuestExecStatus → Dictionary<string, object?>

Models updated (2 properties):
- PvePool.Members: JArray → List<Dictionary<string, object?>>
- PveHaRule.Properties: JObject → Dictionary<string, object?>

Cmdlets updated (5):
- GetPveClusterConfigCmdlet: OutputType JToken → Dictionary<string, object>
- GetPveNodeConfigCmdlet: iteration updated for Dictionary
- GetPveNodeDnsCmdlet: iteration updated for Dictionary
- GetPveBackupInfoCmdlet: iteration updated for List<Dictionary>
- InvokePveVmGuestExecCmdlet: polling updated for Dictionary

Added D013 to DECISIONS.md: cmdlets must emit only native or module-defined types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 11:12:57 -05:00

39 lines
1.1 KiB
C#

using System.Collections.Generic;
using Newtonsoft.Json;
using PSProxmoxVE.Core.Utilities;
namespace PSProxmoxVE.Core.Models.Cluster;
/// <summary>
/// Represents a Proxmox VE resource pool as returned by the /pools endpoint.
/// </summary>
public class PvePool
{
/// <summary>
/// The pool identifier.
/// </summary>
[JsonProperty("poolid")]
public string? PoolId { get; set; }
/// <summary>
/// An optional comment or description for the pool.
/// </summary>
[JsonProperty("comment")]
public string? Comment { get; set; }
/// <summary>
/// The pool members (VMs, containers, storage). Returned as a list of dictionaries
/// when querying a specific pool.
/// </summary>
[JsonProperty("members")]
[JsonConverter(typeof(NativeListConverter))]
public List<Dictionary<string, object?>>? Members { get; set; }
/// <inheritdoc />
public override string ToString()
{
var memberCount = Members?.Count ?? 0;
return $"Pool: {PoolId ?? "N/A"} | Comment: {Comment ?? "-"} | Members: {memberCount}";
}
}