using System; using Newtonsoft.Json; namespace PSProxmox.Models { /// /// Represents a virtual machine in Proxmox VE. /// public class ProxmoxVM { /// /// Gets or sets the VM ID. /// [JsonProperty("vmid")] public int VMID { get; set; } /// /// Gets or sets the VM name. /// [JsonProperty("name")] public string Name { get; set; } /// /// Gets or sets the VM status. /// [JsonProperty("status")] public string Status { get; set; } /// /// Gets or sets the VM CPU count. /// [JsonProperty("cpus")] public int CPUs { get; set; } /// /// Gets or sets the VM memory in bytes. /// [JsonProperty("maxmem")] public long MaxMemory { get; set; } /// /// Gets or sets the VM disk size in bytes. /// [JsonProperty("maxdisk")] public long MaxDisk { get; set; } /// /// Gets or sets the VM uptime in seconds. /// [JsonProperty("uptime")] public long Uptime { get; set; } /// /// Gets or sets the VM node. /// [JsonProperty("node")] public string Node { get; set; } /// /// Gets or sets the VM type (qemu, lxc, etc.). /// [JsonProperty("type")] public string Type { get; set; } /// /// Gets or sets the VM template flag. /// [JsonProperty("template")] public int Template { get; set; } /// /// Gets or sets the VM network interfaces. /// [JsonProperty("netif")] public string NetIf { get; set; } /// /// Gets or sets the VM tags. /// [JsonProperty("tags")] public string Tags { get; set; } /// /// Gets a value indicating whether the VM is a template. /// [JsonIgnore] public bool IsTemplate => Template == 1; /// /// Gets a value indicating whether the VM is running. /// [JsonIgnore] public bool IsRunning => Status == "running"; /// /// Gets the VM memory in megabytes. /// [JsonIgnore] public int MemoryMB => (int)(MaxMemory / 1024 / 1024); /// /// Gets the VM disk size in gigabytes. /// [JsonIgnore] public int DiskGB => (int)(MaxDisk / 1024 / 1024 / 1024); /// /// Gets the VM uptime as a TimeSpan. /// [JsonIgnore] public TimeSpan UptimeSpan => TimeSpan.FromSeconds(Uptime); } }