package schemas

import (
	"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
	"github.com/hashicorp/terraform-plugin-framework/schema/validator"
)

func MakeSchemaResourceLBBackendServer() map[string]schema.Attribute {
	return map[string]schema.Attribute{
		"lb_id": schema.Int64Attribute{
			Required:    true,
			Description: "ID of the LB instance to backendCreate",
		},
		"backend_name": schema.StringAttribute{
			Required:    true,
			Description: "Must be unique among all backends of this LB - name of the new backend to create",
		},
		"name": schema.StringAttribute{
			Required:    true,
			Description: "Must be unique among all servers defined for this backend - name of the server definition to add.",
		},
		"address": schema.StringAttribute{
			Required:    true,
			Description: "IP address of the server.",
		},
		"port": schema.Int64Attribute{
			Required:    true,
			Description: "Port number on the server",
		},
		"check": schema.StringAttribute{
			Computed: true,
			Optional: true,
			Validators: []validator.String{
				stringvalidator.OneOf("disabled", "enabled"),
			},
			Description: "set to disabled if this server should be used regardless of its state.",
		},
		"guid": schema.StringAttribute{
			Computed: true,
		},
		"downinter": schema.Int64Attribute{
			Optional: true,
			Computed: true,
		},
		"fall": schema.Int64Attribute{
			Optional: true,
			Computed: true,
		},
		"inter": schema.Int64Attribute{
			Optional: true,
			Computed: true,
		},
		"maxconn": schema.Int64Attribute{
			Optional: true,
			Computed: true,
		},
		"maxqueue": schema.Int64Attribute{
			Optional: true,
			Computed: true,
		},
		"rise": schema.Int64Attribute{
			Optional: true,
			Computed: true,
		},
		"slowstart": schema.Int64Attribute{
			Optional: true,
			Computed: true,
		},
		"weight": schema.Int64Attribute{
			Optional: true,
			Computed: true,
		},
		"id": schema.StringAttribute{
			Computed: true,
			PlanModifiers: []planmodifier.String{
				stringplanmodifier.UseStateForUnknown(),
			},
		},
	}
}
