using MemoryPack;

namespace Insight.Agent.Messages
{
    [MemoryPackUnion(170, typeof(VirtualMaschine))]
    [MemoryPackUnion(171, typeof(VirtualMaschineList))]
    public partial interface IAgentMessage { }

    [MemoryPackable]
    public partial class VirtualMaschine : IAgentMessage
    {
        [MemoryPackOrder(0)]
        public Guid? Id { get; set; }

        [MemoryPackOrder(1)]
        public uint? ProcessId { get; set; }

        [MemoryPackOrder(2)]
        public string? Caption { get; set; }

        [MemoryPackOrder(3)]
        public string? Name { get; set; }

        [MemoryPackOrder(4)]
        public string? Notes { get; set; }

        [MemoryPackOrder(5)]
        public EnabledEnum? Enabled { get; set; }

        [MemoryPackOrder(6)]
        public EnabledDefaultEnum? EnabledDefault { get; set; }

        [MemoryPackOrder(7)]
        public HealthStatusEnum? HealthState { get; set; }

        [MemoryPackOrder(8)]
        public string? Status { get; set; }

        [MemoryPackOrder(9)]
        public ulong? OnTime { get; set; }

        [MemoryPackOrder(10)]
        public uint? ReplicationMode { get; set; }

        [MemoryPackOrder(11)]
        public ReplicationStateEnum? ReplicationState { get; set; }

        [MemoryPackOrder(12)]
        public ReplicationHealthEnum? ReplicationHealth { get; set; }

        [MemoryPackOrder(13)]
        public string? ConfigurationVersion { get; set; }

        [MemoryPackOrder(14)]
        public IntegrationServicesVersionStateEnum? IntegrationServicesVersionState { get; set; }

        [MemoryPackOrder(15)]
        public uint? NumberOfProcessors { get; set; }

        [MemoryPackOrder(16)]
        public uint? ProcessorLoad { get; set; }

        [MemoryPackOrder(17)]
        public int? MemoryAvailable { get; set; }

        [MemoryPackOrder(18)]
        public ulong? MemoryUsage { get; set; }

        [MemoryPackOrder(19)]
        public DateTime? InstallDate { get; set; }

        [MemoryPackOrder(20)]
        public DateTime? TimeOfLastConfigurationChange { get; set; }

        [MemoryPackOrder(21)]
        public DateTime? TimeOfLastStateChange { get; set; }

        [MemoryPackOrder(22)]
        public DateTime? LastReplicationTime { get; set; }

        [MemoryPackOrder(23)]
        public string? GuestOperatingSystem { get; set; }

        [MemoryPackOrder(24)]
        public List<VirtualMaschineConfiguration>? Configurations { get; set; }

        public enum EnabledEnum
        {
            Unbekannt = 0,
            Andere = 1,
            Aktiviert = 2,
            Deaktiviert = 3,
            Herunterfahren = 4,
            Nicht_Verfügbar = 5,
            Aktiviert_Offline = 6,
            In_Test = 7,
            Latent = 8,
            Eingeschränkt = 9,
            Wird_gestartet = 10
        }

        public enum EnabledDefaultEnum
        {
            Aktiviert = 2,
            Deaktiviert = 3,
            Aktiviert_Offline = 6
        }

        public enum HealthStatusEnum
        {
            OK = 5,
            Hauptfehler = 20,
            Kritischer_Fehler = 25
        }

        public enum ReplicationStateEnum
        {
            Deaktiviert = 0,
            Bereit = 1,
            Warten_auf_Erstreplikation = 2,
            Replikat = 3,
            Synchronisierte_Replication_abgeschlossen = 4,
            Wiederhergestellt = 5,
            Commit = 6,
            Angehalten = 7,
            Kritisch = 8,
            Warten_auf_die_Neusynchronisierung = 9,
            Resynchronisierung = 10,
            Resynchronisierung_angehalten = 11,
            Failover_in_Bearbeitung = 12,
            Failback_in_Fortschritt = 13,
            Failback_abgeschlossen = 14,
            Datenträgerupdate_in_Bearbeitung = 15,
            Datenträgeraktualisierung_kritisch = 16,
            Unbekannt = 17,
            Repurpose_Replikation_in_Bearbeitung = 18,
            Vorbereitet_für_die_Synchronisierungsreplikation = 19,
            Vorbereitet_für_die_Umgekehrte_Replikation_der_Gruppe = 20,
            Failover_in_Fortschritt = 21
        }

        public enum ReplicationHealthEnum
        {
            OK = 1,
            Warnung = 2,
            Kritisch = 3
        }

        public enum IntegrationServicesVersionStateEnum
        {
            Unknown = 0,
            UpToDate = 1,
            Mismatch = 2
        }
    }

    [MemoryPackable(GenerateType.Collection)]
    public partial class VirtualMaschineList : List<VirtualMaschine>, IAgentMessage { }

    [MemoryPackable]
    public partial class VirtualMaschineConfiguration : IAgentMessage
    {
        [MemoryPackOrder(0)]
        public string? Id { get; set; }

        [MemoryPackOrder(1)]
        public string? ParentId { get; set; }

        [MemoryPackOrder(2)]
        public string? Type { get; set; }

        [MemoryPackOrder(3)]
        public string? Name { get; set; }

        [MemoryPackOrder(4)]
        public DateTime? CreationTime { get; set; }

        [MemoryPackOrder(5)]
        public string? Generation { get; set; }

        [MemoryPackOrder(6)]
        public string? Architecture { get; set; }

        [MemoryPackOrder(7)]
        public AutomaticStartupActionEnum? AutomaticStartupAction { get; set; }
        //public DateTime? AutomaticStartupActionDelay { get; set; }

        [MemoryPackOrder(8)]
        public AutomaticShutdownActionEnum? AutomaticShutdownAction { get; set; }

        [MemoryPackOrder(9)]
        public AutomaticRecoveryActionEnum? AutomaticRecoveryAction { get; set; }

        [MemoryPackOrder(10)]
        public bool? AutomaticSnapshotsEnabled { get; set; }

        [MemoryPackOrder(11)]
        public string? BaseBoardSerialNumber { get; set; }

        [MemoryPackOrder(12)]
        public string? BIOSGUID { get; set; }

        [MemoryPackOrder(13)]
        public string? BIOSSerialNumber { get; set; }

        [MemoryPackOrder(14)]
        public ushort[]? BootOrder { get; set; }

        [MemoryPackOrder(15)]
        public string? ConfigurationDataRoot { get; set; }

        [MemoryPackOrder(16)]
        public string? ConfigurationFile { get; set; }

        [MemoryPackOrder(17)]
        public string? GuestStateDataRoot { get; set; }

        [MemoryPackOrder(18)]
        public string? GuestStateFile { get; set; }

        [MemoryPackOrder(19)]
        public string? SnapshotDataRoot { get; set; }

        [MemoryPackOrder(20)]
        public string? SuspendDataRoot { get; set; }

        [MemoryPackOrder(21)]
        public string? SwapFileDataRoot { get; set; }

        [MemoryPackOrder(22)]
        public bool? SecureBootEnabled { get; set; }

        [MemoryPackOrder(23)]
        public bool? IsAutomaticSnapshot { get; set; }

        [MemoryPackOrder(24)]
        public string[]? Notes { get; set; }

        [MemoryPackOrder(25)]
        public List<VirtualMaschineConfiguration>? Childs { get; set; }

        //public string[]? HostResource { get; set; }

        public enum AutomaticStartupActionEnum
        {
            Nothing = 2,
            RestartIfLastStateActive = 3,
            Alway = 4
        }

        public enum AutomaticShutdownActionEnum
        {
            Ausschalten = 2,
            Speichern = 3,
            Herunterfahren = 4
        }

        public enum AutomaticRecoveryActionEnum
        {
            Keine = 2,
            Neustart = 3,
            Rollback = 4
        }
    }
}