package models

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

type DataSourceRGListLBModel struct {
	// request required fields
	RGID types.Int64 `tfsdk:"rg_id"`

	// request optional fields
	ByID       types.Int64    `tfsdk:"by_id"`
	Name       types.String   `tfsdk:"name"`
	TechStatus types.String   `tfsdk:"tech_status"`
	Status     types.String   `tfsdk:"status"`
	FrontIP    types.String   `tfsdk:"front_ip"`
	BackIP     types.String   `tfsdk:"back_ip"`
	SortBy     types.String   `tfsdk:"sort_by"`
	Page       types.Int64    `tfsdk:"page"`
	Size       types.Int64    `tfsdk:"size"`
	Timeouts   timeouts.Value `tfsdk:"timeouts"`

	// response fields
	Id         types.String         `tfsdk:"id"`
	Items      []ItemsRGListLBModel `tfsdk:"items"`
	EntryCount types.Int64          `tfsdk:"entry_count"`
}

type ItemsRGListLBModel struct {
	HAMode        types.Bool          `tfsdk:"ha_mode"`
	BackendHAIP   types.String        `tfsdk:"backend_haip"`
	Backends      []ItemBackendModel  `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"`
	Description   types.String        `tfsdk:"desc"`
	DPAPIUser     types.String        `tfsdk:"dp_api_user"`
	ExtNetID      types.Int64         `tfsdk:"extnet_id"`
	FrontendHAIP  types.String        `tfsdk:"frontend_haip"`
	Frontends     []ItemFrontendModel `tfsdk:"frontends"`
	GID           types.Int64         `tfsdk:"gid"`
	GUID          types.Int64         `tfsdk:"guid"`
	ID            types.Int64         `tfsdk:"id"`
	ImageID       types.Int64         `tfsdk:"image_id"`
	Milestones    types.Int64         `tfsdk:"milestones"`
	Name          types.String        `tfsdk:"name"`
	PrimaryNode   RecordNodeModel     `tfsdk:"primary_node"`
	RGName        types.String        `tfsdk:"rg_name"`
	SecondaryNode RecordNodeModel     `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"`
	VINSID        types.Int64         `tfsdk:"vins_id"`
}

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

type ItemBindingModel struct {
	Address types.String `tfsdk:"address"`
	GUID    types.String `tfsdk:"guid"`
	Name    types.String `tfsdk:"name"`
	Port    types.Int64  `tfsdk:"port"`
}

type RecordNodeModel struct {
	BackendIP  types.String `tfsdk:"backend_ip"`
	ComputeID  types.Int64  `tfsdk:"compute_id"`
	FrontendIP types.String `tfsdk:"frontend_ip"`
	GUID       types.String `tfsdk:"guid"`
	MGMTIP     types.String `tfsdk:"mgmt_ip"`
	NetworkID  types.Int64  `tfsdk:"network_id"`
}

type ItemBackendModel struct {
	Algorithm             types.String              `tfsdk:"algorithm"`
	GUID                  types.String              `tfsdk:"guid"`
	Name                  types.String              `tfsdk:"name"`
	ServerDefaultSettings RecordServerSettingsModel `tfsdk:"server_default_settings"`
	Servers               []ItemServerModel         `tfsdk:"servers"`
}

type RecordServerSettingsModel struct {
	Inter     types.Int64  `tfsdk:"inter"`
	GUID      types.String `tfsdk:"guid"`
	DownInter types.Int64  `tfsdk:"down_inter"`
	Rise      types.Int64  `tfsdk:"rise"`
	Fall      types.Int64  `tfsdk:"fall"`
	SlowStart types.Int64  `tfsdk:"slow_start"`
	MaxConn   types.Int64  `tfsdk:"max_conn"`
	MaxQueue  types.Int64  `tfsdk:"max_queue"`
	Weight    types.Int64  `tfsdk:"weight"`
}

type ItemServerModel struct {
	Address        types.String              `tfsdk:"address"`
	Check          types.String              `tfsdk:"check"`
	GUID           types.String              `tfsdk:"guid"`
	Name           types.String              `tfsdk:"name"`
	Port           types.Int64               `tfsdk:"port"`
	ServerSettings RecordServerSettingsModel `tfsdk:"server_settings"`
}
