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 ResourceLBModel struct {
	// required fields
	RGID     types.Int64  `tfsdk:"rg_id"`
	Name     types.String `tfsdk:"name"`
	ExtNetID types.Int64  `tfsdk:"extnet_id"`
	VINSID   types.Int64  `tfsdk:"vins_id"`
	Start    types.Bool   `tfsdk:"start"`

	// optional fields
	HAMode       types.Bool     `tfsdk:"ha_mode"`
	ACL          types.String   `tfsdk:"acl"`
	Description  types.String   `tfsdk:"desc"`
	Enable       types.Bool     `tfsdk:"enable"`
	Restart      types.Bool     `tfsdk:"restart"`
	ConfigReset  types.Bool     `tfsdk:"config_reset"`
	Permanently  types.Bool     `tfsdk:"permanently"`
	Restore      types.Bool     `tfsdk:"restore"`
	Safe         types.Bool     `tfsdk:"safe"`
	SysctlParams types.List     `tfsdk:"sysctl_params"`
	Timeouts     timeouts.Value `tfsdk:"timeouts"`

	// response fields
	BackendHAIP   types.String `tfsdk:"backend_haip"`
	Backends      types.List   `tfsdk:"backends"`
	CreatedBy     types.String `tfsdk:"created_by"`
	CreatedTime   types.Int64  `tfsdk:"created_time"`
	DeletedBy     types.String `tfsdk:"deleted_by"`
	DeletedTime   types.Int64  `tfsdk:"deleted_time"`
	DPAPIUser     types.String `tfsdk:"dp_api_user"`
	FrontendHAIP  types.String `tfsdk:"frontend_haip"`
	Frontends     types.List   `tfsdk:"frontends"`
	GID           types.Int64  `tfsdk:"gid"`
	GUID          types.Int64  `tfsdk:"guid"`
	ID            types.String `tfsdk:"id"`
	ImageID       types.Int64  `tfsdk:"image_id"`
	LBID          types.Int64  `tfsdk:"lb_id"`
	ManagerId     types.Int64  `tfsdk:"manager_id"`
	ManagerType   types.String `tfsdk:"manager_type"`
	Milestones    types.Int64  `tfsdk:"milestones"`
	PartK8s       types.Bool   `tfsdk:"part_k8s"`
	PrimaryNode   types.Object `tfsdk:"primary_node"`
	RGName        types.String `tfsdk:"rg_name"`
	SecondaryNode types.Object `tfsdk:"secondary_node"`
	Status        types.String `tfsdk:"status"`
	TechStatus    types.String `tfsdk:"tech_status"`
	UpdatedBy     types.String `tfsdk:"updated_by"`
	UpdatedTime   types.Int64  `tfsdk:"updated_time"`
	UserManaged   types.Bool   `tfsdk:"user_managed"`
}

type ItemBackendModel struct {
	Algorithm             types.String `tfsdk:"algorithm"`
	GUID                  types.String `tfsdk:"guid"`
	Name                  types.String `tfsdk:"name"`
	ServerDefaultSettings types.Object `tfsdk:"server_default_settings"`
	Servers               types.List   `tfsdk:"servers"`
}

type ItemFrontendModel struct {
	Backend  types.String `tfsdk:"backend"`
	Bindings types.List   `tfsdk:"bindings"`
	GUID     types.String `tfsdk:"guid"`
	Name     types.String `tfsdk:"name"`
}

var ItemNode = map[string]attr.Type{
	"backend_ip":  types.StringType,
	"compute_id":  types.Int64Type,
	"frontend_ip": types.StringType,
	"guid":        types.StringType,
	"mgmt_ip":     types.StringType,
	"network_id":  types.Int64Type,
}

var ItemBackend = map[string]attr.Type{
	"algorithm":               types.StringType,
	"guid":                    types.StringType,
	"name":                    types.StringType,
	"server_default_settings": types.ObjectType{AttrTypes: ItemServerSettings},
	"servers":                 types.ListType{ElemType: types.ObjectType{AttrTypes: ItemServers}},
}

var ItemFrontend = map[string]attr.Type{
	"backend":  types.StringType,
	"bindings": types.ListType{ElemType: types.ObjectType{AttrTypes: ItemBindings}},
	"guid":     types.StringType,
	"name":     types.StringType,
}
