Skip to content

Commit afc7773

Browse files
authored
feat(shared): align models with Proxmox API and fix deserialization issues (#57)
- Update XML documentation across all models to match official API descriptions - VmConfigLxc: add LXC-specific overrides (arch, memory, ostype, tags, onboot, lock, protection) with correct LXC descriptions; fix lxc field type from IEnumerable<string> to IEnumerable<string[]> to match [[key,val],...] format - NodeVmBase: use generic descriptions for status/name shared between QEMU and LXC - NodeStorageContent: change Encrypted from string to bool (PBS fingerprint support) - ResultExtension: fix CustomBooleanJsonConverter to handle non-numeric strings (e.g. fingerprints) by returning true instead of throwing an exception - NodeStatus: add boot-info and current-kernel nested models - NodeTask: add pstart field - ClusterExtension: add GetWebUrl() extension method for ClusterResource - bump version to 9.1.5
1 parent 9f0069f commit afc7773

39 files changed

+1308
-342
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>net8.0;net9.0;net10.0;netstandard2.0</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
66
<ImplicitUsings>enable</ImplicitUsings>
7-
<Version>9.1.4</Version>
7+
<Version>9.1.5</Version>
88
<!-- <NoWarn>$(NoWarn);CS1591;CS0436</NoWarn> -->
99
<Company>Corsinvest Srl</Company>
1010
<Authors>Corsinvest Srl</Authors>

src/Corsinvest.ProxmoxVE.Api.Extension/Utils/InfoHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace Corsinvest.ProxmoxVE.Api.Extension.Utils;
1717
/// <summary>
1818
/// Global Info
1919
/// </summary>
20+
[Obsolete("This class is deprecated and will be removed in future versions. It is recommended to use specific API calls to retrieve the necessary information instead of relying on a global info collection.")]
2021
public static class InfoHelper
2122
{
2223
/// <summary>

src/Corsinvest.ProxmoxVE.Api.Shared/Models/Access/AccessAcl.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ namespace Corsinvest.ProxmoxVE.Api.Shared.Models.Access;
1313
public class AccessAcl: ModelBase
1414
{
1515
/// <summary>
16-
/// Path
16+
/// Access control path
1717
/// </summary>
18-
/// <value></value>
1918
[JsonProperty("path")]
2019
public string Path { get; set; }
2120

@@ -34,9 +33,8 @@ public class AccessAcl: ModelBase
3433
public string UsersGroupid { get; set; }
3534

3635
/// <summary>
37-
/// Propagate
36+
/// Allow to propagate (inherit) permissions.
3837
/// </summary>
39-
/// <value></value>
4038
[JsonProperty("propagate")]
4139
public int Propagate { get; set; }
4240

src/Corsinvest.ProxmoxVE.Api.Shared/Models/Access/AccessDomain.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ public class AccessDomain : ModelBase
2020
public string Realm { get; set; }
2121

2222
/// <summary>
23-
/// Comment
23+
/// A comment. The GUI use this text when you select a domain (Realm) on the login window.
2424
/// </summary>
25-
/// <value></value>
2625
[JsonProperty("comment")]
2726
public string Comment { get; set; }
2827

@@ -32,4 +31,10 @@ public class AccessDomain : ModelBase
3231
/// <value></value>
3332
[JsonProperty("type")]
3433
public string Type { get; set; }
34+
35+
/// <summary>
36+
/// Two-factor authentication provider.
37+
/// </summary>
38+
[JsonProperty("tfa")]
39+
public string Tfa { get; set; }
3540
}

src/Corsinvest.ProxmoxVE.Api.Shared/Models/Access/AccessGroup.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ public class AccessGroup : ModelBase
2020
public string Id { get; set; }
2121

2222
/// <summary>
23-
/// Users
23+
/// list of users which form this group
2424
/// </summary>
25-
/// <value></value>
2625
[JsonProperty("users")]
2726
public string Users { get; set; }
2827

src/Corsinvest.ProxmoxVE.Api.Shared/Models/Access/AccessTfa.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ namespace Corsinvest.ProxmoxVE.Api.Shared.Models.Access;
1313
public class AccessTfa : ModelBase
1414
{
1515
/// <summary>
16-
/// User id
16+
/// User this entry belongs to.
1717
/// </summary>
18-
/// <value></value>
1918
[JsonProperty("userid")]
2019
public string UserId { get; set; }
2120

@@ -26,6 +25,18 @@ public class AccessTfa : ModelBase
2625
[JsonProperty("entries")]
2726
public IEnumerable<AccessTfaEntry> Entries { get; set; }
2827

28+
/// <summary>
29+
/// Contains a timestamp until when a user is locked out of 2nd factors.
30+
/// </summary>
31+
[JsonProperty("tfa-locked-until")]
32+
public long? TfaLockedUntil { get; set; }
33+
34+
/// <summary>
35+
/// True if the user is currently locked out of TOTP factors.
36+
/// </summary>
37+
[JsonProperty("totp-locked")]
38+
public bool TotpLocked { get; set; }
39+
2940
/// <summary>
3041
/// TFA Entry
3142
/// </summary>

src/Corsinvest.ProxmoxVE.Api.Shared/Models/Access/AccessUser.cs

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,20 @@ namespace Corsinvest.ProxmoxVE.Api.Shared.Models.Access;
1313
public class AccessUser : ModelBase
1414
{
1515
/// <summary>
16-
/// Enabled
16+
/// Enable the account (default). You can set this to '0' to disable the account
1717
/// </summary>
18-
/// <value></value>
1918
[JsonProperty("enable")]
20-
public int Enable { get; set; }
19+
public bool Enable { get; set; }
2120

2221
/// <summary>
23-
/// Id
22+
/// Full User ID, in the `name@realm` format.
2423
/// </summary>
25-
/// <value></value>
2624
[JsonProperty("userid")]
2725
public string Id { get; set; }
2826

2927
/// <summary>
30-
/// Expire
28+
/// Account expiration date (seconds since epoch). '0' means no expiration date.
3129
/// </summary>
32-
/// <value></value>
3330
[JsonProperty("expire")]
3431
public int Expire { get; set; }
3532

@@ -47,7 +44,37 @@ public class AccessUser : ModelBase
4744
public string Comment { get; set; }
4845

4946
/// <summary>
50-
/// Realm Type
47+
/// First name.
48+
/// </summary>
49+
[JsonProperty("firstname")]
50+
public string Firstname { get; set; }
51+
52+
/// <summary>
53+
/// Last name.
54+
/// </summary>
55+
[JsonProperty("lastname")]
56+
public string Lastname { get; set; }
57+
58+
/// <summary>
59+
/// Keys for two factor auth (yubico).
60+
/// </summary>
61+
[JsonProperty("keys")]
62+
public string Keys { get; set; }
63+
64+
/// <summary>
65+
/// Contains a timestamp until when a user is locked out of 2nd factors.
66+
/// </summary>
67+
[JsonProperty("tfa-locked-until")]
68+
public long? TfaLockedUntil { get; set; }
69+
70+
/// <summary>
71+
/// True if the user is currently locked out of TOTP factors.
72+
/// </summary>
73+
[JsonProperty("totp-locked")]
74+
public bool TotpLocked { get; set; }
75+
76+
/// <summary>
77+
/// The type of the users realm
5178
/// </summary>
5279
[JsonProperty("realm-type")]
5380
public string RealmType { get; set; }
@@ -76,7 +103,7 @@ public class Token
76103
public string Id { get; set; }
77104

78105
/// <summary>
79-
/// Expire
106+
/// Account expiration date (seconds since epoch). '0' means no expiration date.
80107
/// </summary>
81108
[JsonProperty("expire")]
82109
public int Expire { get; set; }

src/Corsinvest.ProxmoxVE.Api.Shared/Models/Cluster/ClusterExtension.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,20 @@ public static IEnumerable<string> GetDefaultColumns()
126126
nameof(ClusterResource.Uptime)
127127
];
128128

129+
/// <summary>
130+
/// Get web URL path for a cluster resource
131+
/// </summary>
132+
public static string GetWebUrl(this ClusterResource resource)
133+
=> resource.ResourceType switch
134+
{
135+
ClusterResourceType.Node => PveWebUrlHelper.GetWebUrlNode(resource.Node),
136+
ClusterResourceType.Storage => PveWebUrlHelper.GetWebUrlStorage(resource.Node, resource.Storage),
137+
ClusterResourceType.Pool => PveWebUrlHelper.GetWebUrlPool(resource.Pool),
138+
ClusterResourceType.Vm when resource.VmType == VmType.Qemu => PveWebUrlHelper.GetWebUrlQemu(resource.Node, resource.VmId),
139+
ClusterResourceType.Vm when resource.VmType == VmType.Lxc => PveWebUrlHelper.GetWebUrlLxc(resource.Node, resource.VmId),
140+
_ => string.Empty,
141+
};
142+
129143
/// <summary>
130144
/// Column for VM/CT
131145
/// </summary>

src/Corsinvest.ProxmoxVE.Api.Shared/Models/Cluster/ClusterHaResource.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,21 @@ public class ClusterHaResource : ModelBase
4747
/// </summary>
4848
[JsonProperty("comment")]
4949
public string Comment { get; set; }
50-
}
50+
/// <summary>
51+
/// Failback.
52+
/// </summary>
53+
[JsonProperty("failback")]
54+
public bool Failback { get; set; }
55+
56+
/// <summary>
57+
/// Max relocate.
58+
/// </summary>
59+
[JsonProperty("max_relocate")]
60+
public int MaxRelocate { get; set; }
61+
62+
/// <summary>
63+
/// Max restart.
64+
/// </summary>
65+
[JsonProperty("max_restart")]
66+
public int MaxRestart { get; set; }
67+
}

src/Corsinvest.ProxmoxVE.Api.Shared/Models/Cluster/ClusterHaStatusCurrent.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,80 +13,80 @@ namespace Corsinvest.ProxmoxVE.Api.Shared.Models.Cluster;
1313
public class ClusterHaStatusCurrent : ModelBase
1414
{
1515
/// <summary>
16-
/// Id
16+
/// Status entry ID (quorum, master, lrm:&lt;node&gt;, service:&lt;sid&gt;).
1717
/// </summary>
1818
[JsonProperty("id")]
1919
public string Id { get; set; }
2020

2121
/// <summary>
22-
/// Node
22+
/// Node associated to status entry.
2323
/// </summary>
2424
[JsonProperty("node")]
2525
public string Node { get; set; }
2626

2727
/// <summary>
28-
/// Quorate
28+
/// For type 'quorum'. Whether the cluster is quorate or not.
2929
/// </summary>
3030
[JsonProperty("quorate")]
31-
public int Quorate { get; set; }
31+
public bool Quorate { get; set; }
3232

3333
/// <summary>
34-
/// Status
34+
/// Status of the entry (value depends on type).
3535
/// </summary>
3636
[JsonProperty("status")]
3737
public string Status { get; set; }
3838

3939
/// <summary>
40-
/// Type
40+
/// Type of status entry.
4141
/// </summary>
4242
[JsonProperty("type")]
4343
public string Type { get; set; }
4444

4545
/// <summary>
46-
/// Timestamp
46+
/// For type 'lrm','master'. Timestamp of the status information.
4747
/// </summary>
4848
[JsonProperty("timestamp")]
4949
public long Timestamp { get; set; }
5050

5151
/// <summary>
52-
/// CrmState
52+
/// For type 'service'. Service state as seen by the CRM.
5353
/// </summary>
5454
[JsonProperty("crm_state")]
5555
public string CrmState { get; set; }
5656

5757
/// <summary>
58-
/// Group
59-
/// </summary>
60-
[JsonProperty("group")]
61-
public string Group { get; set; }
62-
63-
/// <summary>
64-
/// MaxRelocate
58+
/// For type 'service'.
6559
/// </summary>
6660
[JsonProperty("max_relocate")]
6761
public int MaxRelocate { get; set; }
6862

6963
/// <summary>
70-
/// MaxRestart
64+
/// For type 'service'.
7165
/// </summary>
7266
[JsonProperty("max_restart")]
7367
public int MaxRestart { get; set; }
7468

7569
/// <summary>
76-
/// RequestState
70+
/// For type 'service'. Requested service state.
7771
/// </summary>
7872
[JsonProperty("request_state")]
7973
public string RequestState { get; set; }
8074

8175
/// <summary>
82-
/// Sid
76+
/// For type 'service'. Service ID.
8377
/// </summary>
8478
[JsonProperty("sid")]
8579
public string Sid { get; set; }
8680

8781
/// <summary>
88-
/// State
82+
/// For type 'service'. Verbose service state.
8983
/// </summary>
9084
[JsonProperty("state")]
9185
public string State { get; set; }
86+
87+
/// <summary>
88+
/// The HA resource is automatically migrated to the node with the highest priority according to their node affinity rule, if a node with a higher priority than the current node comes online.
89+
/// </summary>
90+
[JsonProperty("failback")]
91+
public bool Failback { get; set; }
9292
}

0 commit comments

Comments
 (0)