package models

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

type ResourceItemVFPoolModel struct {
	//required and optional fields
	Name          types.String   `tfsdk:"name"`
	Description   types.String   `tfsdk:"description"`
	AccountAccess types.List     `tfsdk:"account_access"`
	RGAccess      types.List     `tfsdk:"rg_access"`
	Config        types.List     `tfsdk:"config"`
	Enable        types.Bool     `tfsdk:"enable"`
	Timeouts      timeouts.Value `tfsdk:"timeouts"`

	// computed fields
	ID          types.String `tfsdk:"id"`
	VFPoolID    types.Int64  `tfsdk:"vfpool_id"`
	CreatedTime types.Int64  `tfsdk:"created_time"`
	GID         types.Int64  `tfsdk:"gid"`
	GUID        types.Int64  `tfsdk:"guid"`
	Status      types.String `tfsdk:"status"`
	UpdatedTime types.Int64  `tfsdk:"updated_time"`
	VFS         types.List   `tfsdk:"vfs"`
}

type ResourceItemVFPoolConfigModel struct {
	NodeID  types.Int64  `tfsdk:"node_id"`
	NicName types.String `tfsdk:"nic_name"`
	VFIDs   types.List   `tfsdk:"vf_ids"`
}

var ResourceItemVFPoolConfig = map[string]attr.Type{
	"node_id":  types.Int64Type,
	"nic_name": types.StringType,
	"vf_ids":   types.ListType{ElemType: types.Int64Type},
}

type ResourceIVFSModel struct {
	NodeID types.Int64 `tfsdk:"node_id"`
	VFList types.List  `tfsdk:"vf_list"`
}

var ResourceIVFS = map[string]attr.Type{
	"node_id": types.Int64Type,
	"vf_list": types.ListType{ElemType: types.ObjectType{AttrTypes: ResourceIVFItem}},
}

type ResourceIVFItemModel struct {
	NicName types.String `tfsdk:"nic_name"`
	VFSInfo types.List   `tfsdk:"vfs_info"`
}

var ResourceIVFItem = map[string]attr.Type{
	"nic_name": types.StringType,
	"vfs_info": types.ListType{ElemType: types.ObjectType{AttrTypes: ResourceIVFSInfoItem}},
}

type ResourceIVFSInfoItemModel struct {
	ID      types.Int64 `tfsdk:"id"`
	Claimed types.Bool  `tfsdk:"claimed"`
	VMID    types.Int64 `tfsdk:"vm_id"`
}

var ResourceIVFSInfoItem = map[string]attr.Type{
	"id":      types.Int64Type,
	"claimed": types.BoolType,
	"vm_id":   types.Int64Type,
}
