mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-27 07:27:28 +00:00
feat(auth): implement ticket and API token authentication with session model
Add PveSession, PveAuthenticator, PveVersion, and PveAuthMode. Support ticket-based auth (username/password with 2hr expiry) and API token auth (USER@REALM!TOKENID=UUID format). Version detection on connect via GET /api2/json/version. Custom exception types for API errors, expired sessions, missing connections, version mismatches, and task failures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace PSProxmoxVE.Core.Exceptions
|
||||
{
|
||||
/// <summary>Exception thrown when the Proxmox VE API returns an error response</summary>
|
||||
public class PveApiException : Exception
|
||||
{
|
||||
public HttpStatusCode StatusCode { get; }
|
||||
public string Resource { get; }
|
||||
public string HttpMethod { get; }
|
||||
|
||||
public PveApiException(HttpStatusCode statusCode, string message, string resource, string httpMethod)
|
||||
: base($"PVE API error ({(int)statusCode} {statusCode}) on {httpMethod} {resource}: {message}")
|
||||
{
|
||||
StatusCode = statusCode;
|
||||
Resource = resource;
|
||||
HttpMethod = httpMethod;
|
||||
}
|
||||
|
||||
public PveApiException(HttpStatusCode statusCode, string message, string resource, string httpMethod, Exception innerException)
|
||||
: base($"PVE API error ({(int)statusCode} {statusCode}) on {httpMethod} {resource}: {message}", innerException)
|
||||
{
|
||||
StatusCode = statusCode;
|
||||
Resource = resource;
|
||||
HttpMethod = httpMethod;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user