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 ResourceRecordGroupModel struct {
	//required fields
	ServiceID types.Int64  `tfsdk:"service_id"`
	CompCount types.Int64  `tfsdk:"comp_count"`
	Name      types.String `tfsdk:"compgroup_name"`
	CPU       types.Int64  `tfsdk:"cpu"`
	RAM       types.Int64  `tfsdk:"ram"`
	Disk      types.Int64  `tfsdk:"disk"`
	ImageID   types.Int64  `tfsdk:"image_id"`
	Driver    types.String `tfsdk:"driver"`

	//optional fields
	SEPID          types.Int64    `tfsdk:"sep_id"`
	SepPool        types.String   `tfsdk:"sep_pool"`
	CloudInit      types.String   `tfsdk:"cloud_init"`
	Role           types.String   `tfsdk:"role"`
	Chipset        types.String   `tfsdk:"chipset"`
	TimeoutStart   types.Int64    `tfsdk:"timeout_start"`
	VINSes         types.List     `tfsdk:"vinses"`
	ExtNets        types.List     `tfsdk:"extnets"`
	Mode           types.String   `tfsdk:"mode"`
	Start          types.Bool     `tfsdk:"start"`
	ForceStop      types.Bool     `tfsdk:"force_stop"`
	ForceUpdate    types.Bool     `tfsdk:"force_update"`
	Parents        types.List     `tfsdk:"parents"`
	RemoveComputes types.List     `tfsdk:"remove_computes"`
	CompgroupID    types.Int64    `tfsdk:"compgroup_id"`
	Timeouts       timeouts.Value `tfsdk:"timeouts"`

	//compute fields
	AccountID   types.Int64  `tfsdk:"account_id"`
	AccountName types.String `tfsdk:"account_name"`
	Computes    types.List   `tfsdk:"computes"`
	Consistency types.Bool   `tfsdk:"consistency"`
	CreatedBy   types.String `tfsdk:"created_by"`
	CreatedTime types.Int64  `tfsdk:"created_time"`
	DeletedBy   types.String `tfsdk:"deleted_by"`
	DeletedTime types.Int64  `tfsdk:"deleted_time"`
	GID         types.Int64  `tfsdk:"gid"`
	GUID        types.Int64  `tfsdk:"guid"`
	Milestones  types.Int64  `tfsdk:"milestones"`
	RGID        types.Int64  `tfsdk:"rg_id"`
	RGName      types.String `tfsdk:"rg_name"`
	SeqNo       types.Int64  `tfsdk:"seq_no"`
	Status      types.String `tfsdk:"status"`
	TechStatus  types.String `tfsdk:"tech_status"`
	UpdatedBy   types.String `tfsdk:"updated_by"`
	UpdatedTime types.Int64  `tfsdk:"updated_time"`
	ID          types.String `tfsdk:"id"`
	SID         types.String `tfsdk:"sid"`
}

type ResourceItemGroupComputeModel struct {
	ID          types.Int64  `tfsdk:"id"`
	IPAddresses types.List   `tfsdk:"ip_addresses"`
	Name        types.String `tfsdk:"name"`
	Chipset     types.String `tfsdk:"chipset"`
	OSUsers     types.List   `tfsdk:"os_users"`
}

var ResourceItemGroupCompute = map[string]attr.Type{
	"id":           types.Int64Type,
	"ip_addresses": types.ListType{ElemType: types.StringType},
	"name":         types.StringType,
	"chipset":      types.StringType,
	"os_users":     types.ListType{ElemType: types.ObjectType{AttrTypes: ResourceItemOSUser}},
}

type ResourceItemOSUserModel struct {
	Login    types.String `tfsdk:"login"`
	Password types.String `tfsdk:"password"`
}

var ResourceItemOSUser = map[string]attr.Type{
	"login":    types.StringType,
	"password": types.StringType,
}
