using Newtonsoft.Json;
namespace PSProxmoxVE.Core.Models.Users;
///
/// Represents a Proxmox VE role as returned by the /access/roles endpoint.
/// Roles are named collections of privileges that can be assigned to users or groups via ACLs.
///
public class PveRole
{
///
/// The unique role identifier (e.g., "Administrator", "PVEVMAdmin", "PVEDatastoreUser").
///
[JsonProperty("roleid")]
public string RoleId { get; set; } = string.Empty;
///
/// Comma-separated list of privilege strings assigned to this role
/// (e.g., "VM.Allocate,VM.Config.Disk,Datastore.AllocateSpace").
///
[JsonProperty("privs")]
public string? Privileges { get; set; }
///
/// Indicates whether this is a built-in / special role (1) that cannot be deleted,
/// or a custom role (0).
///
[JsonProperty("special")]
public int? Special { get; set; }
///
public override string ToString()
{
var specialStr = Special is 1 ? " [built-in]" : string.Empty;
return $"Role: {RoleId}{specialStr} | Privs: {Privileges ?? "none"}";
}
}