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"
	"github.com/hashicorp/terraform-plugin-framework/types"
)

func MakeSchemaResourceFlipgroup() map[string]schema.Attribute {
	return map[string]schema.Attribute{
		"account_id": schema.Int64Attribute{
			Required:    true,
			Description: "Account ID",
		},
		"name": schema.StringAttribute{
			Required:    true,
			Description: "Flipgroup name",
		},
		"net_id": schema.Int64Attribute{
			Required:    true,
			Description: "EXTNET or ViNS ID",
		},
		"net_type": schema.StringAttribute{
			Required: true,
			Validators: []validator.String{
				stringvalidator.OneOf("EXTNET", "VINS"),
			},
			Description: "Network type, EXTNET or VINS",
		},
		"client_type": schema.StringAttribute{
			Required: true,
			Validators: []validator.String{
				stringvalidator.OneOf("compute"),
			},
			Description: "Type of client, 'compute' ('vins' will be later)",
		},
		"ip": schema.StringAttribute{
			Optional:    true,
			Computed:    true,
			Description: "IP address to associate with this group. If empty, the platform will autoselect IP address",
		},
		"desc": schema.StringAttribute{
			Optional:    true,
			Description: "Text description of this Flipgroup instance",
		},
		"client_ids": schema.ListAttribute{
			Optional:    true,
			Computed:    true,
			ElementType: types.Int64Type,
			Description: "List of clients attached to this Flipgroup instance",
		},
		"flipgroup_id": schema.Int64Attribute{
			Computed: true,
		},
		"account_name": schema.StringAttribute{
			Computed: true,
		},
		"conn_id": schema.Int64Attribute{
			Computed: true,
		},
		"conn_type": schema.StringAttribute{
			Computed: true,
		},
		"created_by": schema.StringAttribute{
			Computed: true,
		},
		"created_time": schema.Int64Attribute{
			Computed: true,
		},
		"default_gw": schema.StringAttribute{
			Computed: true,
		},
		"deleted_by": schema.StringAttribute{
			Computed: true,
		},
		"deleted_time": schema.Int64Attribute{
			Computed: true,
		},
		"gid": schema.Int64Attribute{
			Computed: true,
		},
		"guid": schema.Int64Attribute{
			Computed: true,
		},
		"id": schema.StringAttribute{
			Computed: true,
			PlanModifiers: []planmodifier.String{
				stringplanmodifier.UseStateForUnknown(),
			},
		},
		"milestones": schema.Int64Attribute{
			Computed: true,
		},
		"status": schema.StringAttribute{
			Computed: true,
		},
		"network": schema.StringAttribute{
			Computed: true,
		},
		"rg_id": schema.Int64Attribute{
			Computed: true,
		},
		"rg_name": schema.StringAttribute{
			Computed: true,
		},
		"updated_by": schema.StringAttribute{
			Computed: true,
		},
		"updated_time": schema.Int64Attribute{
			Computed: true,
		},
	}
}
