package schemas

import (
	"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/types"
)

func MakeSchemaResourceVFPool() map[string]schema.Attribute {
	return map[string]schema.Attribute{
		"name": schema.StringAttribute{
			Required: true,
		},
		"description": schema.StringAttribute{
			Optional: true,
		},
		"account_access": schema.ListAttribute{
			Optional:    true,
			ElementType: types.Int64Type,
		},
		"rg_access": schema.ListAttribute{
			Optional:    true,
			ElementType: types.Int64Type,
		},
		"config": schema.ListNestedAttribute{
			Optional: true,
			NestedObject: schema.NestedAttributeObject{
				Attributes: map[string]schema.Attribute{
					"node_id": schema.Int64Attribute{
						Required: true,
					},
					"nic_name": schema.StringAttribute{
						Required: true,
					},
					"vf_ids": schema.ListAttribute{
						Required:    true,
						ElementType: types.Int64Type,
					},
				},
			},
		},
		"enable": schema.BoolAttribute{
			Optional: true,
		},
		"created_time": schema.Int64Attribute{
			Computed: true,
		},
		"gid": schema.Int64Attribute{
			Computed: true,
		},
		"guid": schema.Int64Attribute{
			Computed: true,
		},
		"vfpool_id": schema.Int64Attribute{
			Computed: true,
		},
		"status": schema.StringAttribute{
			Computed: true,
		},
		"updated_time": schema.Int64Attribute{
			Computed: true,
		},
		"vfs": schema.ListNestedAttribute{
			Computed: true,
			NestedObject: schema.NestedAttributeObject{
				Attributes: map[string]schema.Attribute{
					"node_id": schema.Int64Attribute{
						Computed: true,
					},
					"vf_list": schema.ListNestedAttribute{
						Computed: true,
						NestedObject: schema.NestedAttributeObject{
							Attributes: map[string]schema.Attribute{
								"nic_name": schema.StringAttribute{
									Computed: true,
								},
								"vfs_info": schema.ListNestedAttribute{
									Computed: true,
									NestedObject: schema.NestedAttributeObject{
										Attributes: map[string]schema.Attribute{
											"id": schema.Int64Attribute{
												Computed: true,
											},
											"claimed": schema.BoolAttribute{
												Computed: true,
											},
											"vm_id": schema.Int64Attribute{
												Computed: true,
											},
										},
									},
								},
							},
						},
					},
				},
			},
		},
		"id": schema.StringAttribute{
			Computed: true,
			PlanModifiers: []planmodifier.String{
				stringplanmodifier.UseStateForUnknown(),
			},
		},
	}
}
