mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-07-26 07:58:14 +00:00
docs: add XML doc comments to Core public API and remove CS1591 suppression
- Add missing XML doc comments to all public types and members in PSProxmoxVE.Core (Authentication, Exceptions, Models, Client) - Remove CS1591 suppression from PSProxmoxVE.Core.csproj - Build succeeds with 0 warnings Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
namespace PSProxmoxVE.Core.Authentication
|
||||
{
|
||||
/// <summary>Authentication mode for Proxmox VE API</summary>
|
||||
/// <summary>Authentication mode for Proxmox VE API.</summary>
|
||||
public enum PveAuthMode
|
||||
{
|
||||
/// <summary>Authenticate using a username/password ticket and CSRF token.</summary>
|
||||
Ticket,
|
||||
|
||||
/// <summary>Authenticate using a persistent API token (USER@REALM!TOKENID=UUID).</summary>
|
||||
ApiToken
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,34 @@ using PSProxmoxVE.Core.Models;
|
||||
|
||||
namespace PSProxmoxVE.Core.Authentication
|
||||
{
|
||||
/// <summary>Represents an authenticated session to a Proxmox VE server</summary>
|
||||
/// <summary>Represents an authenticated session to a Proxmox VE server.</summary>
|
||||
public class PveSession
|
||||
{
|
||||
/// <summary>The hostname or IP address of the Proxmox VE server.</summary>
|
||||
public string Hostname { get; }
|
||||
|
||||
/// <summary>The TCP port of the Proxmox VE API (default 8006).</summary>
|
||||
public int Port { get; }
|
||||
|
||||
/// <summary>Whether to skip TLS certificate validation when connecting.</summary>
|
||||
public bool SkipCertificateCheck { get; }
|
||||
|
||||
/// <summary>The authentication mode used for this session.</summary>
|
||||
public PveAuthMode AuthMode { get; }
|
||||
|
||||
/// <summary>The API token string, when using API token authentication.</summary>
|
||||
public string? ApiToken { get; }
|
||||
|
||||
/// <summary>The session ticket cookie value, when using ticket authentication.</summary>
|
||||
public string? Ticket { get; }
|
||||
|
||||
/// <summary>The CSRF prevention token, when using ticket authentication.</summary>
|
||||
public string? CsrfToken { get; }
|
||||
|
||||
/// <summary>The UTC expiry time for the session ticket.</summary>
|
||||
public DateTime TicketExpiry { get; }
|
||||
|
||||
/// <summary>The Proxmox VE version detected on the server at connection time.</summary>
|
||||
public PveVersion? ServerVersion { get; internal set; }
|
||||
|
||||
/// <summary>Returns true if the ticket has expired (only relevant for Ticket auth mode)</summary>
|
||||
|
||||
@@ -2,12 +2,18 @@ using System;
|
||||
|
||||
namespace PSProxmoxVE.Core.Authentication
|
||||
{
|
||||
/// <summary>Represents a Proxmox VE server version (major.minor only)</summary>
|
||||
/// <summary>Represents a Proxmox VE server version (major.minor only).</summary>
|
||||
public class PveVersion
|
||||
{
|
||||
/// <summary>The major version number (e.g., 8 in PVE 8.1).</summary>
|
||||
public int Major { get; }
|
||||
|
||||
/// <summary>The minor version number (e.g., 1 in PVE 8.1).</summary>
|
||||
public int Minor { get; }
|
||||
|
||||
/// <summary>Creates a new PVE version with the specified major and minor components.</summary>
|
||||
/// <param name="major">The major version number.</param>
|
||||
/// <param name="minor">The minor version number.</param>
|
||||
public PveVersion(int major, int minor)
|
||||
{
|
||||
Major = major;
|
||||
@@ -34,11 +40,15 @@ namespace PSProxmoxVE.Core.Authentication
|
||||
return new PveVersion(major, minor);
|
||||
}
|
||||
|
||||
/// <summary>Returns true if this version is greater than or equal to the specified version.</summary>
|
||||
/// <param name="major">The minimum major version.</param>
|
||||
/// <param name="minor">The minimum minor version.</param>
|
||||
public bool IsAtLeast(int major, int minor)
|
||||
{
|
||||
return Major > major || (Major == major && Minor >= minor);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString() => $"{Major}.{Minor}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,10 @@ namespace PSProxmoxVE.Core.Client
|
||||
private readonly HttpClient _httpClient;
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Creates an HTTP client authenticated with the specified PVE session.
|
||||
/// </summary>
|
||||
/// <param name="session">The authenticated PVE session providing credentials and base URL.</param>
|
||||
public PveHttpClient(PveSession session)
|
||||
{
|
||||
_session = session ?? throw new ArgumentNullException(nameof(session));
|
||||
@@ -394,6 +398,7 @@ namespace PSProxmoxVE.Core.Client
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
if (!_disposed)
|
||||
|
||||
@@ -3,13 +3,23 @@ using System.Net;
|
||||
|
||||
namespace PSProxmoxVE.Core.Exceptions
|
||||
{
|
||||
/// <summary>Exception thrown when the Proxmox VE API returns an error response</summary>
|
||||
/// <summary>Exception thrown when the Proxmox VE API returns an error response.</summary>
|
||||
public class PveApiException : Exception
|
||||
{
|
||||
/// <summary>The HTTP status code returned by the PVE API.</summary>
|
||||
public HttpStatusCode StatusCode { get; }
|
||||
|
||||
/// <summary>The API resource path that was requested.</summary>
|
||||
public string Resource { get; }
|
||||
|
||||
/// <summary>The HTTP method used for the request (GET, POST, PUT, DELETE).</summary>
|
||||
public string HttpMethod { get; }
|
||||
|
||||
/// <summary>Initializes a new instance for a failed PVE API request.</summary>
|
||||
/// <param name="statusCode">The HTTP status code returned.</param>
|
||||
/// <param name="message">The error message from the API.</param>
|
||||
/// <param name="resource">The API resource path that was requested.</param>
|
||||
/// <param name="httpMethod">The HTTP method used.</param>
|
||||
public PveApiException(HttpStatusCode statusCode, string message, string resource, string httpMethod)
|
||||
: base($"PVE API error ({(int)statusCode} {statusCode}) on {httpMethod} {resource}: {message}")
|
||||
{
|
||||
@@ -18,6 +28,12 @@ namespace PSProxmoxVE.Core.Exceptions
|
||||
HttpMethod = httpMethod;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance for a failed PVE API request, with an inner exception.</summary>
|
||||
/// <param name="statusCode">The HTTP status code returned.</param>
|
||||
/// <param name="message">The error message from the API.</param>
|
||||
/// <param name="resource">The API resource path that was requested.</param>
|
||||
/// <param name="httpMethod">The HTTP method used.</param>
|
||||
/// <param name="innerException">The exception that caused this failure.</param>
|
||||
public PveApiException(HttpStatusCode statusCode, string message, string resource, string httpMethod, Exception innerException)
|
||||
: base($"PVE API error ({(int)statusCode} {statusCode}) on {httpMethod} {resource}: {message}", innerException)
|
||||
{
|
||||
|
||||
@@ -2,14 +2,19 @@ using System;
|
||||
|
||||
namespace PSProxmoxVE.Core.Exceptions
|
||||
{
|
||||
/// <summary>Exception thrown when authentication to a Proxmox VE server fails</summary>
|
||||
/// <summary>Exception thrown when authentication to a Proxmox VE server fails.</summary>
|
||||
public class PveAuthenticationException : Exception
|
||||
{
|
||||
/// <summary>Initializes a new instance with the specified error message.</summary>
|
||||
/// <param name="message">The error message describing the authentication failure.</param>
|
||||
public PveAuthenticationException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance with the specified error message and inner exception.</summary>
|
||||
/// <param name="message">The error message describing the authentication failure.</param>
|
||||
/// <param name="innerException">The exception that caused this failure.</param>
|
||||
public PveAuthenticationException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
|
||||
@@ -2,14 +2,17 @@ using System;
|
||||
|
||||
namespace PSProxmoxVE.Core.Exceptions
|
||||
{
|
||||
/// <summary>Exception thrown when an operation is attempted without an active Proxmox VE session</summary>
|
||||
/// <summary>Exception thrown when an operation is attempted without an active Proxmox VE session.</summary>
|
||||
public class PveNotConnectedException : Exception
|
||||
{
|
||||
/// <summary>Initializes a new instance indicating no active session exists.</summary>
|
||||
public PveNotConnectedException()
|
||||
: base("No active Proxmox VE session. Run Connect-PveServer first.")
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance indicating no active session exists, with an inner exception.</summary>
|
||||
/// <param name="innerException">The exception that caused this failure.</param>
|
||||
public PveNotConnectedException(Exception innerException)
|
||||
: base("No active Proxmox VE session. Run Connect-PveServer first.", innerException)
|
||||
{
|
||||
|
||||
@@ -2,14 +2,17 @@ using System;
|
||||
|
||||
namespace PSProxmoxVE.Core.Exceptions
|
||||
{
|
||||
/// <summary>Exception thrown when the Proxmox VE session ticket has expired</summary>
|
||||
/// <summary>Exception thrown when the Proxmox VE session ticket has expired.</summary>
|
||||
public class PveSessionExpiredException : Exception
|
||||
{
|
||||
/// <summary>Initializes a new instance indicating the session has expired.</summary>
|
||||
public PveSessionExpiredException()
|
||||
: base("Your Proxmox VE session has expired. Please run Connect-PveServer to establish a new session.")
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance indicating the session has expired, with an inner exception.</summary>
|
||||
/// <param name="innerException">The exception that caused this failure.</param>
|
||||
public PveSessionExpiredException(Exception innerException)
|
||||
: base("Your Proxmox VE session has expired. Please run Connect-PveServer to establish a new session.", innerException)
|
||||
{
|
||||
|
||||
@@ -2,12 +2,18 @@ using System;
|
||||
|
||||
namespace PSProxmoxVE.Core.Exceptions
|
||||
{
|
||||
/// <summary>Exception thrown when a Proxmox VE task completes with a failed exit status</summary>
|
||||
/// <summary>Exception thrown when a Proxmox VE task completes with a failed exit status.</summary>
|
||||
public class PveTaskFailedException : Exception
|
||||
{
|
||||
/// <summary>The UPID of the failed task.</summary>
|
||||
public string Upid { get; }
|
||||
|
||||
/// <summary>The exit status string reported by the task (e.g., an error message).</summary>
|
||||
public string ExitStatus { get; }
|
||||
|
||||
/// <summary>Initializes a new instance for a task that failed with the specified exit status.</summary>
|
||||
/// <param name="upid">The UPID of the failed task.</param>
|
||||
/// <param name="exitStatus">The exit status string reported by the task.</param>
|
||||
public PveTaskFailedException(string upid, string exitStatus)
|
||||
: base($"Task {upid} failed with exit status: {exitStatus}")
|
||||
{
|
||||
@@ -15,6 +21,10 @@ namespace PSProxmoxVE.Core.Exceptions
|
||||
ExitStatus = exitStatus;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance for a task that failed, with an inner exception.</summary>
|
||||
/// <param name="upid">The UPID of the failed task.</param>
|
||||
/// <param name="exitStatus">The exit status string reported by the task.</param>
|
||||
/// <param name="innerException">The exception that caused this failure.</param>
|
||||
public PveTaskFailedException(string upid, string exitStatus, Exception innerException)
|
||||
: base($"Task {upid} failed with exit status: {exitStatus}", innerException)
|
||||
{
|
||||
|
||||
@@ -2,12 +2,18 @@ using System;
|
||||
|
||||
namespace PSProxmoxVE.Core.Exceptions
|
||||
{
|
||||
/// <summary>Exception thrown when a Proxmox VE task does not complete within the allowed timeout period</summary>
|
||||
/// <summary>Exception thrown when a Proxmox VE task does not complete within the allowed timeout period.</summary>
|
||||
public class PveTaskTimeoutException : Exception
|
||||
{
|
||||
/// <summary>The UPID of the task that timed out.</summary>
|
||||
public string Upid { get; }
|
||||
|
||||
/// <summary>The timeout duration that was exceeded.</summary>
|
||||
public TimeSpan Timeout { get; }
|
||||
|
||||
/// <summary>Initializes a new instance for a task that exceeded the specified timeout.</summary>
|
||||
/// <param name="upid">The UPID of the timed-out task.</param>
|
||||
/// <param name="timeout">The timeout duration that was exceeded.</param>
|
||||
public PveTaskTimeoutException(string upid, TimeSpan timeout)
|
||||
: base($"Task {upid} did not complete within {timeout.TotalSeconds} seconds.")
|
||||
{
|
||||
@@ -15,6 +21,10 @@ namespace PSProxmoxVE.Core.Exceptions
|
||||
Timeout = timeout;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance for a task that exceeded the specified timeout, with an inner exception.</summary>
|
||||
/// <param name="upid">The UPID of the timed-out task.</param>
|
||||
/// <param name="timeout">The timeout duration that was exceeded.</param>
|
||||
/// <param name="innerException">The exception that caused this failure.</param>
|
||||
public PveTaskTimeoutException(string upid, TimeSpan timeout, Exception innerException)
|
||||
: base($"Task {upid} did not complete within {timeout.TotalSeconds} seconds.", innerException)
|
||||
{
|
||||
|
||||
@@ -3,13 +3,22 @@ using PSProxmoxVE.Core.Authentication;
|
||||
|
||||
namespace PSProxmoxVE.Core.Exceptions
|
||||
{
|
||||
/// <summary>Exception thrown when the connected Proxmox VE server does not meet the minimum version requirement for an operation</summary>
|
||||
/// <summary>Exception thrown when the connected Proxmox VE server does not meet the minimum version requirement for an operation.</summary>
|
||||
public class PveVersionException : Exception
|
||||
{
|
||||
/// <summary>The minimum required major version number.</summary>
|
||||
public int RequiredMajor { get; }
|
||||
|
||||
/// <summary>The minimum required minor version number.</summary>
|
||||
public int RequiredMinor { get; }
|
||||
|
||||
/// <summary>The actual server version that did not meet the requirement.</summary>
|
||||
public PveVersion ActualVersion { get; }
|
||||
|
||||
/// <summary>Initializes a new instance for a version requirement that was not met.</summary>
|
||||
/// <param name="requiredMajor">The minimum required major version.</param>
|
||||
/// <param name="requiredMinor">The minimum required minor version.</param>
|
||||
/// <param name="actualVersion">The actual server version detected.</param>
|
||||
public PveVersionException(int requiredMajor, int requiredMinor, PveVersion actualVersion)
|
||||
: base($"This operation requires Proxmox VE {requiredMajor}.{requiredMinor} or later. Connected server is version {actualVersion}.")
|
||||
{
|
||||
@@ -18,6 +27,11 @@ namespace PSProxmoxVE.Core.Exceptions
|
||||
ActualVersion = actualVersion;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance for a version requirement that was not met, with an inner exception.</summary>
|
||||
/// <param name="requiredMajor">The minimum required major version.</param>
|
||||
/// <param name="requiredMinor">The minimum required minor version.</param>
|
||||
/// <param name="actualVersion">The actual server version detected.</param>
|
||||
/// <param name="innerException">The exception that caused this failure.</param>
|
||||
public PveVersionException(int requiredMajor, int requiredMinor, PveVersion actualVersion, Exception innerException)
|
||||
: base($"This operation requires Proxmox VE {requiredMajor}.{requiredMinor} or later. Connected server is version {actualVersion}.", innerException)
|
||||
{
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace PSProxmoxVE.Core.Models.Vms
|
||||
[JsonProperty("cicustom")]
|
||||
public string? CiCustom { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString() =>
|
||||
$"CloudInit: User={CiUser ?? "N/A"} | IP0={IpConfig0 ?? "N/A"} | NS={Nameserver ?? "N/A"}";
|
||||
}
|
||||
|
||||
@@ -23,5 +23,6 @@ public class PveGuestIpAddress
|
||||
[JsonProperty("prefix")]
|
||||
public int Prefix { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString() => $"{Address}/{Prefix} ({Type})";
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class PveGuestNetworkInterface
|
||||
[JsonProperty("ip-addresses")]
|
||||
public PveGuestIpAddress[] IpAddresses { get; set; } = System.Array.Empty<PveGuestIpAddress>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
var ips = IpAddresses.Length > 0
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace PSProxmoxVE.Core.Models.Vms
|
||||
[JsonProperty("t")]
|
||||
public string Text { get; set; } = string.Empty;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString() => $"{LineNumber,4}: {Text}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<RootNamespace>PSProxmoxVE.Core</RootNamespace>
|
||||
<AssemblyName>PSProxmoxVE.Core</AssemblyName>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
<NoWarn>$(NoWarn)</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user