mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-09-06 20:19:01 +00:00
0026ef2b57
NodeService.GetNodeConfig/GetNodeDns, ClusterConfigService.GetClusterConfig, BackupService.GetNotBackedUp and VmService.GetGuestExecStatus returned raw Dictionary/List<Dictionary> instead of a Pve* model, per issue #157. Each now has a typed model under Models/{Nodes,Cluster,Backup,Vms}/ with [JsonProperty] for documented fields and a [JsonExtensionData]-backed AdditionalProperties catch-all, following the PveVmConfig pattern. The five consuming cmdlets and their [OutputType] attributes are updated to match. GetClusterConfig also fixes a latent bug: GET /cluster/config returns a JSON array (a directory index), but the old code did `data is JObject obj ? ... : empty dict`, which silently always returned an empty dictionary since data was a JArray. PveClusterConfigEntry decodes the array correctly and exposes a typed Name property (the array items' schema documents no named fields, but the endpoint's "links" metadata gives the child-URL template as "{name}"). The guest-exec poll loop in InvokePveVmGuestExecCmdlet keeps its exact Stopwatch + Thread.Sleep(1000) structure (ADR 0001 accepted exception); only the type it reads from changed. A TolerantBooleanConverter was added so PveGuestExecStatus.Exited keeps accepting PVE's boolean/integer/string forms, matching what ApiValueHelper.IsExited already tolerated for the old dictionary path. Reviewed with codex-rescue, correctness-reviewer and api-compat-reviewer before commit; both real findings above (the name/subdir key and the Exited string-form regression) came from that pass and are mutation-tested. Co-authored-by: goodolclint-claude[bot] <323206664+goodolclint-claude[bot]@users.noreply.github.com>
57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using PSProxmoxVE.Core.Utilities;
|
|
|
|
namespace PSProxmoxVE.Core.Models.Backup;
|
|
|
|
/// <summary>
|
|
/// Represents one guest not covered by any backup job, as returned by
|
|
/// the /cluster/backup-info/not-backed-up endpoint.
|
|
/// </summary>
|
|
public class PveBackupInfo
|
|
{
|
|
/// <summary>
|
|
/// Name of the guest.
|
|
/// </summary>
|
|
[JsonProperty("name")]
|
|
public string? Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// Type of the guest ("qemu" or "lxc").
|
|
/// </summary>
|
|
[JsonProperty("type")]
|
|
public string? Type { get; set; }
|
|
|
|
/// <summary>
|
|
/// VMID of the guest.
|
|
/// </summary>
|
|
[JsonProperty("vmid")]
|
|
public int? VmId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Raw landing spot for any key not mapped to a typed property above.
|
|
/// </summary>
|
|
[JsonExtensionData]
|
|
private IDictionary<string, JToken>? ExtensionData { get; set; }
|
|
|
|
private Dictionary<string, object?>? _additionalProperties;
|
|
|
|
/// <summary>
|
|
/// Any keys not surfaced as a typed property above. Keys map to native
|
|
/// .NET values so the dictionary works naturally in PowerShell pipelines.
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
public Dictionary<string, object?> AdditionalProperties =>
|
|
_additionalProperties ??= ExtensionData == null
|
|
? new Dictionary<string, object?>()
|
|
: ExtensionData.ToDictionary(kvp => kvp.Key, kvp => JsonHelper.ToNative(kvp.Value));
|
|
|
|
/// <inheritdoc />
|
|
public override string ToString()
|
|
{
|
|
return $"{Type ?? "guest"} {VmId?.ToString() ?? "?"} ({Name ?? "N/A"}) not backed up";
|
|
}
|
|
}
|