using Newtonsoft.Json;

namespace ITNexusAgent.Models;

public class CheckinPayload
{
    [JsonProperty("hostname")]        public string Hostname { get; set; } = "";
    [JsonProperty("agent_version")]   public string AgentVersion { get; set; } = "";
    [JsonProperty("os")]              public string Os { get; set; } = "";
    [JsonProperty("os_version")]      public string OsVersion { get; set; } = "";
    [JsonProperty("domain")]          public string Domain { get; set; } = "";
    [JsonProperty("ip_address")]      public string IpAddress { get; set; } = "";
    [JsonProperty("mac_address")]     public string MacAddress { get; set; } = "";
    [JsonProperty("last_user")]       public string LastUser { get; set; } = "";
    [JsonProperty("cpu_model")]       public string CpuModel { get; set; } = "";
    [JsonProperty("cpu_cores")]       public int CpuCores { get; set; }
    [JsonProperty("cpu_usage")]       public double? CpuUsage { get; set; }
    [JsonProperty("ram_total")]       public double? RamTotal { get; set; }
    [JsonProperty("ram_used")]        public double? RamUsed { get; set; }
    [JsonProperty("disk_total")]      public double? DiskTotal { get; set; }
    [JsonProperty("disk_free")]       public double? DiskFree { get; set; }
    [JsonProperty("uptime_hours")]    public double? UptimeHours { get; set; }
    [JsonProperty("pending_updates")] public int PendingUpdates { get; set; }
    [JsonProperty("tpm_present")]     public bool TpmPresent { get; set; }
    [JsonProperty("tpm_version")]     public string TpmVersion { get; set; } = "";
    [JsonProperty("tpm_v2")]          public bool TpmV2 { get; set; }
    [JsonProperty("secure_boot")]     public bool SecureBoot { get; set; }
    [JsonProperty("win11_ready")]     public bool Win11Ready { get; set; }
    [JsonProperty("bitlocker_status")] public string BitlockerStatus { get; set; } = "";
    [JsonProperty("defender_enabled")] public bool DefenderEnabled { get; set; }
    [JsonProperty("defender_signatures_age")] public int? DefenderSignaturesAge { get; set; }
    [JsonProperty("hardware_serial")] public string HardwareSerial { get; set; } = "";
    [JsonProperty("installed_software")] public List<string> InstalledSoftware { get; set; } = [];
}

public class CheckinResponse
{
    [JsonProperty("agent_version")]    public string? AgentVersion { get; set; }
    [JsonProperty("commands")]         public List<PatchCommand> Commands { get; set; } = [];
    [JsonProperty("announcements")]    public List<Announcement> Announcements { get; set; } = [];
    [JsonProperty("running_commands")] public List<RunningCommand> RunningCommands { get; set; } = [];
}

public class PatchCommand
{
    [JsonProperty("id")]      public int Id { get; set; }
    [JsonProperty("command")] public string Command { get; set; } = "";
    [JsonProperty("params")]  public string? Params { get; set; }
}

public class RunningCommand
{
    [JsonProperty("id")]      public int Id { get; set; }
    [JsonProperty("command")] public string Command { get; set; } = "";
}

public class Announcement
{
    [JsonProperty("id")]      public int Id { get; set; }
    [JsonProperty("title")]   public string Title { get; set; } = "";
    [JsonProperty("message")] public string Message { get; set; } = "";
    [JsonProperty("type")]    public string Type { get; set; } = "info";
}

public class CommandResult
{
    [JsonProperty("command_id")] public int CommandId { get; set; }
    [JsonProperty("status")]     public string Status { get; set; } = "done";
    [JsonProperty("result")]     public string Result { get; set; } = "";
}

public class StatusCache
{
    [JsonProperty("hostname")]          public string Hostname { get; set; } = "";
    [JsonProperty("last_checkin")]      public DateTime LastCheckin { get; set; }
    [JsonProperty("agent_version")]     public string AgentVersion { get; set; } = "";
    [JsonProperty("server_url")]        public string ServerUrl { get; set; } = "";
    [JsonProperty("online")]            public bool Online { get; set; }
    [JsonProperty("cpu_usage")]         public double? CpuUsage { get; set; }
    [JsonProperty("ram_total")]         public double? RamTotal { get; set; }
    [JsonProperty("ram_used")]          public double? RamUsed { get; set; }
    [JsonProperty("disk_total")]        public double? DiskTotal { get; set; }
    [JsonProperty("disk_free")]         public double? DiskFree { get; set; }
    [JsonProperty("pending_updates")]   public int PendingUpdates { get; set; }
    [JsonProperty("bitlocker_status")]  public string BitlockerStatus { get; set; } = "";
    [JsonProperty("defender_enabled")]  public bool DefenderEnabled { get; set; }
    [JsonProperty("defender_sig_age")]  public int? DefenderSignaturesAge { get; set; }
    [JsonProperty("hardware_serial")]   public string HardwareSerial { get; set; } = "";
    [JsonProperty("os")]                public string Os { get; set; } = "";
    [JsonProperty("last_user")]         public string LastUser { get; set; } = "";
    [JsonProperty("installed_software")] public List<string> InstalledSoftware { get; set; } = [];
}
