package exporter

// ReanimatorExport represents the top-level structure for Reanimator format export
type ReanimatorExport struct {
	Filename    string             `json:"filename"`
	SourceType  string             `json:"source_type,omitempty"`
	Protocol    string             `json:"protocol,omitempty"`
	TargetHost  string             `json:"target_host,omitempty"`
	CollectedAt string             `json:"collected_at"` // RFC3339 format
	Hardware    ReanimatorHardware `json:"hardware"`
}

// ReanimatorHardware contains all hardware components
type ReanimatorHardware struct {
	Board         ReanimatorBoard      `json:"board"`
	Firmware      []ReanimatorFirmware `json:"firmware,omitempty"`
	CPUs          []ReanimatorCPU      `json:"cpus,omitempty"`
	Memory        []ReanimatorMemory   `json:"memory,omitempty"`
	Storage       []ReanimatorStorage  `json:"storage,omitempty"`
	PCIeDevices   []ReanimatorPCIe     `json:"pcie_devices,omitempty"`
	PowerSupplies []ReanimatorPSU      `json:"power_supplies,omitempty"`
}

// ReanimatorBoard represents motherboard/server information
type ReanimatorBoard struct {
	Manufacturer string `json:"manufacturer,omitempty"`
	ProductName  string `json:"product_name,omitempty"`
	SerialNumber string `json:"serial_number"`
	PartNumber   string `json:"part_number,omitempty"`
	UUID         string `json:"uuid,omitempty"`
}

// ReanimatorFirmware represents firmware version information
type ReanimatorFirmware struct {
	DeviceName string `json:"device_name"`
	Version    string `json:"version"`
}

type ReanimatorStatusAtCollection struct {
	Status string `json:"status"`
	At     string `json:"at"`
}

type ReanimatorStatusHistoryEntry struct {
	Status    string `json:"status"`
	ChangedAt string `json:"changed_at"`
	Details   string `json:"details,omitempty"`
}

// ReanimatorCPU represents processor information
type ReanimatorCPU struct {
	Socket           int                            `json:"socket"`
	Model            string                         `json:"model"`
	Cores            int                            `json:"cores,omitempty"`
	Threads          int                            `json:"threads,omitempty"`
	FrequencyMHz     int                            `json:"frequency_mhz,omitempty"`
	MaxFrequencyMHz  int                            `json:"max_frequency_mhz,omitempty"`
	Manufacturer     string                         `json:"manufacturer,omitempty"`
	Status           string                         `json:"status,omitempty"`
	StatusCheckedAt  string                         `json:"status_checked_at,omitempty"`
	StatusChangedAt  string                         `json:"status_changed_at,omitempty"`
	StatusAtCollect  *ReanimatorStatusAtCollection  `json:"status_at_collection,omitempty"`
	StatusHistory    []ReanimatorStatusHistoryEntry `json:"status_history,omitempty"`
	ErrorDescription string                         `json:"error_description,omitempty"`
}

// ReanimatorMemory represents a memory module (DIMM)
type ReanimatorMemory struct {
	Slot             string                         `json:"slot"`
	Location         string                         `json:"location,omitempty"`
	Present          bool                           `json:"present"`
	SizeMB           int                            `json:"size_mb,omitempty"`
	Type             string                         `json:"type,omitempty"`
	MaxSpeedMHz      int                            `json:"max_speed_mhz,omitempty"`
	CurrentSpeedMHz  int                            `json:"current_speed_mhz,omitempty"`
	Manufacturer     string                         `json:"manufacturer,omitempty"`
	SerialNumber     string                         `json:"serial_number,omitempty"`
	PartNumber       string                         `json:"part_number,omitempty"`
	Status           string                         `json:"status,omitempty"`
	StatusCheckedAt  string                         `json:"status_checked_at,omitempty"`
	StatusChangedAt  string                         `json:"status_changed_at,omitempty"`
	StatusAtCollect  *ReanimatorStatusAtCollection  `json:"status_at_collection,omitempty"`
	StatusHistory    []ReanimatorStatusHistoryEntry `json:"status_history,omitempty"`
	ErrorDescription string                         `json:"error_description,omitempty"`
}

// ReanimatorStorage represents a storage device
type ReanimatorStorage struct {
	Slot             string                         `json:"slot"`
	Type             string                         `json:"type,omitempty"`
	Model            string                         `json:"model"`
	SizeGB           int                            `json:"size_gb,omitempty"`
	SerialNumber     string                         `json:"serial_number"`
	Manufacturer     string                         `json:"manufacturer,omitempty"`
	Firmware         string                         `json:"firmware,omitempty"`
	Interface        string                         `json:"interface,omitempty"`
	Present          bool                           `json:"present"`
	Status           string                         `json:"status,omitempty"`
	StatusCheckedAt  string                         `json:"status_checked_at,omitempty"`
	StatusChangedAt  string                         `json:"status_changed_at,omitempty"`
	StatusAtCollect  *ReanimatorStatusAtCollection  `json:"status_at_collection,omitempty"`
	StatusHistory    []ReanimatorStatusHistoryEntry `json:"status_history,omitempty"`
	ErrorDescription string                         `json:"error_description,omitempty"`
}

// ReanimatorPCIe represents a PCIe device
type ReanimatorPCIe struct {
	Slot             string                         `json:"slot"`
	VendorID         int                            `json:"vendor_id,omitempty"`
	DeviceID         int                            `json:"device_id,omitempty"`
	BDF              string                         `json:"bdf,omitempty"`
	DeviceClass      string                         `json:"device_class,omitempty"`
	Manufacturer     string                         `json:"manufacturer,omitempty"`
	Model            string                         `json:"model,omitempty"`
	LinkWidth        int                            `json:"link_width,omitempty"`
	LinkSpeed        string                         `json:"link_speed,omitempty"`
	MaxLinkWidth     int                            `json:"max_link_width,omitempty"`
	MaxLinkSpeed     string                         `json:"max_link_speed,omitempty"`
	SerialNumber     string                         `json:"serial_number,omitempty"`
	Firmware         string                         `json:"firmware,omitempty"`
	TemperatureC     int                            `json:"temperature_c,omitempty"`
	PowerW           int                            `json:"power_w,omitempty"`
	VoltageV         float64                        `json:"voltage_v,omitempty"`
	Status           string                         `json:"status,omitempty"`
	StatusCheckedAt  string                         `json:"status_checked_at,omitempty"`
	StatusChangedAt  string                         `json:"status_changed_at,omitempty"`
	StatusAtCollect  *ReanimatorStatusAtCollection  `json:"status_at_collection,omitempty"`
	StatusHistory    []ReanimatorStatusHistoryEntry `json:"status_history,omitempty"`
	ErrorDescription string                         `json:"error_description,omitempty"`
}

// ReanimatorPSU represents a power supply unit
type ReanimatorPSU struct {
	Slot             string                         `json:"slot"`
	Present          bool                           `json:"present"`
	Model            string                         `json:"model,omitempty"`
	Vendor           string                         `json:"vendor,omitempty"`
	WattageW         int                            `json:"wattage_w,omitempty"`
	SerialNumber     string                         `json:"serial_number,omitempty"`
	PartNumber       string                         `json:"part_number,omitempty"`
	Firmware         string                         `json:"firmware,omitempty"`
	Status           string                         `json:"status,omitempty"`
	InputType        string                         `json:"input_type,omitempty"`
	InputPowerW      int                            `json:"input_power_w,omitempty"`
	OutputPowerW     int                            `json:"output_power_w,omitempty"`
	InputVoltage     float64                        `json:"input_voltage,omitempty"`
	TemperatureC     int                            `json:"temperature_c,omitempty"`
	StatusCheckedAt  string                         `json:"status_checked_at,omitempty"`
	StatusChangedAt  string                         `json:"status_changed_at,omitempty"`
	StatusAtCollect  *ReanimatorStatusAtCollection  `json:"status_at_collection,omitempty"`
	StatusHistory    []ReanimatorStatusHistoryEntry `json:"status_history,omitempty"`
	ErrorDescription string                         `json:"error_description,omitempty"`
}
