package models

import (
	"github.com/hashicorp/terraform-plugin-framework-timeouts/datasource/timeouts"
	"github.com/hashicorp/terraform-plugin-framework/types"
)

type DataSourceNode struct {
	//required field
	NodeID   types.Int64    `tfsdk:"node_id"`
	Timeouts timeouts.Value `tfsdk:"timeouts"`

	//response field
	Consumption        *ConsumptionModel  `tfsdk:"consumption"`
	CpuInfo            *CpuInfoModel      `tfsdk:"cpu_info"`
	CPUAllocationRatio types.Int64        `tfsdk:"cpu_allocation_ratio"`
	DPDK               *DPDKModel         `tfsdk:"dpdk"`
	GID                types.Int64        `tfsdk:"gid"`
	ID                 types.String       `tfsdk:"id"`
	IPAddr             types.List         `tfsdk:"ipaddr"`
	IsolatedCPUs       types.List         `tfsdk:"isolated_cpus"`
	Name               types.String       `tfsdk:"name"`
	NeedReboot         types.Bool         `tfsdk:"need_reboot"`
	NetworkMode        types.String       `tfsdk:"network_mode"`
	NicInfo            []NicInfoModel     `tfsdk:"nic_info"`
	NumaTopology       *NumaTopologyModel `tfsdk:"numa_topology"`
	ReservedCPUs       types.List         `tfsdk:"reserved_cpus"`
	Roles              types.List         `tfsdk:"roles"`
	SriovEnabled       types.Bool         `tfsdk:"sriov_enabled"`
	StackId            types.Int64        `tfsdk:"stack_id"`
	Status             types.String       `tfsdk:"status"`
	ToActive           *Role              `tfsdk:"to_active"`
	ToInstalling       *Role              `tfsdk:"to_installing"`
	ToMaintenance      *Role              `tfsdk:"to_maintenance"`
	ToRestricted       *Role              `tfsdk:"to_restricted"`
	Version            types.String       `tfsdk:"version"`
}

type ConsumptionModel struct {
	Consumed *ConsumedModel `tfsdk:"consumed"`
	Free     *ResourcesInfo `tfsdk:"free"`
	Reserved *ResourcesInfo `tfsdk:"reserved"`
	Total    *ResourcesInfo `tfsdk:"total"`
	Hostname types.String   `tfsdk:"hostname"`
}

type ConsumedModel struct {
	RAM      types.Int64 `tfsdk:"ram"`
	Computes types.Int64 `tfsdk:"computes"`
	Routers  types.Int64 `tfsdk:"routers"`
	VCPU     types.Int64 `tfsdk:"vcpu"`
}

type ResourcesInfo struct {
	RAM types.Int64 `tfsdk:"ram"`
}

type CpuInfoModel struct {
	ClockSpeed types.Int64 `tfsdk:"clock_speed"`
	CoreCount  types.Int64 `tfsdk:"core_count"`
	PhysCount  types.Int64 `tfsdk:"phys_count"`
}

type NicInfoModel struct {
	Driver   types.String `tfsdk:"driver"`
	MaxVFS   types.Int64  `tfsdk:"max_vfs"`
	NumaNode types.Int64  `tfsdk:"numa_node"`
	NumVFS   types.Int64  `tfsdk:"num_vfs"`
	OSName   types.String `tfsdk:"os_name"`
	PCISlot  types.String `tfsdk:"pci_slot"`
	VFList   []VFList     `tfsdk:"vf_list"`
}

type VFList struct {
	FnID    types.Int64  `tfsdk:"fn_id"`
	PCISlot types.String `tfsdk:"pci_slot"`
}

type NumaTopologyModel struct {
	NodeNum types.Int64         `tfsdk:"node_num"`
	Nodes   []NumaTopologyNodes `tfsdk:"nodes"`
}

type NumaTopologyNodes struct {
	CPUList types.List               `tfsdk:"cpu_list"`
	Memory  *NumaTopologyNodesMemory `tfsdk:"memory"`
}

type NumaTopologyNodesMemory struct {
	OneG  types.Int64 `tfsdk:"one_g"`
	TwoM  types.Int64 `tfsdk:"two_m"`
	Total types.Int64 `tfsdk:"total"`
}

type DPDKModel struct {
	Bridges  *Bridges   `tfsdk:"bridges"`
	HPMemory types.Map  `tfsdk:"hp_memory"`
	PMDCPU   types.List `tfsdk:"pmd_cpu"`
}

type Bridges struct {
	Backplane1 *Backplane1 `tfsdk:"backplane1"`
}

type Backplane1 struct {
	Interfaces types.List  `tfsdk:"interfaces"`
	NumaNode   types.Int64 `tfsdk:"numa_node"`
}

type Role struct {
	Actor  types.String `tfsdk:"actor"`
	Reason types.String `tfsdk:"reason"`
	Time   types.Int64  `tfsdk:"time"`
}
