package schemas

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

func MakeSchemaDataSourceStackList() map[string]schema.Attribute {
	return map[string]schema.Attribute{
		// optional attributes
		"by_id": schema.Int64Attribute{
			Optional:    true,
			Description: "filter by id",
		},
		"name": schema.StringAttribute{
			Optional:    true,
			Description: "filter by name",
		},
		"type": schema.StringAttribute{
			Computed: true,
		},
		"status": schema.StringAttribute{
			Computed: true,
		},
		"sort_by": schema.StringAttribute{
			Optional:    true,
			Description: "sort by one of supported fields, format +|-(field)",
		},
		"page": schema.Int64Attribute{
			Optional:    true,
			Description: "page number",
		},
		"size": schema.Int64Attribute{
			Optional:    true,
			Description: "page size",
		},
		"items": schema.ListNestedAttribute{
			Computed: true,
			NestedObject: schema.NestedAttributeObject{
				Attributes: map[string]schema.Attribute{
					"stack_id": schema.Int64Attribute{
						Required: true,
					},
					"ckey": schema.StringAttribute{
						Computed: true,
					},
					"meta": schema.ListAttribute{
						Computed:    true,
						ElementType: types.StringType,
					},
					"api_url": schema.StringAttribute{
						Computed: true,
					},
					"api_key": schema.StringAttribute{
						Computed: true,
					},
					"app_id": schema.StringAttribute{
						Computed: true,
					},
					"cpu_allocation_ratio": schema.Float64Attribute{
						Computed: true,
					},
					"description": schema.StringAttribute{
						Computed: true,
					},
					"descr": schema.StringAttribute{
						Computed: true,
					},
					"drivers": schema.ListAttribute{
						Computed:    true,
						ElementType: types.StringType,
					},
					"eco": schema.StringAttribute{
						Computed: true,
					},
					"error": schema.Int64Attribute{
						Computed: true,
					},
					"gid": schema.Int64Attribute{
						Computed: true,
					},
					"guid": schema.Int64Attribute{
						Computed: true,
					},
					"images": schema.ListAttribute{
						Computed:    true,
						ElementType: types.Int64Type,
					},
					"login": schema.StringAttribute{
						Computed: true,
					},
					"mem_allocation_ratio": schema.Float64Attribute{
						Computed: true,
					},
					"name": schema.StringAttribute{
						Computed: true,
					},
					"packages": schema.SingleNestedAttribute{
						Computed: true,
						Attributes: map[string]schema.Attribute{
							"libvirt_bin": schema.SingleNestedAttribute{
								Computed: true,
								Attributes: map[string]schema.Attribute{
									"installed_size": schema.StringAttribute{
										Computed: true,
									},
									"ver": schema.StringAttribute{
										Computed: true,
									},
								},
							},
							"libvirt_daemon": schema.SingleNestedAttribute{
								Computed: true,
								Attributes: map[string]schema.Attribute{
									"installed_size": schema.StringAttribute{
										Computed: true,
									},
									"ver": schema.StringAttribute{
										Computed: true,
									},
								},
							},
							"lvm2_lockd": schema.SingleNestedAttribute{
								Computed: true,
								Attributes: map[string]schema.Attribute{
									"installed_size": schema.StringAttribute{
										Computed: true,
									},
									"ver": schema.StringAttribute{
										Computed: true,
									},
								},
							},
							"openvswitch_common": schema.SingleNestedAttribute{
								Computed: true,
								Attributes: map[string]schema.Attribute{
									"installed_size": schema.StringAttribute{
										Computed: true,
									},
									"ver": schema.StringAttribute{
										Computed: true,
									},
								},
							},
							"openvswitch_switch": schema.SingleNestedAttribute{
								Computed: true,
								Attributes: map[string]schema.Attribute{
									"installed_size": schema.StringAttribute{
										Computed: true,
									},
									"ver": schema.StringAttribute{
										Computed: true,
									},
								},
							},
							"qemu_system_x86": schema.SingleNestedAttribute{
								Computed: true,
								Attributes: map[string]schema.Attribute{
									"installed_size": schema.StringAttribute{
										Computed: true,
									},
									"ver": schema.StringAttribute{
										Computed: true,
									},
								},
							},
							"sanlock": schema.SingleNestedAttribute{
								Computed: true,
								Attributes: map[string]schema.Attribute{
									"installed_size": schema.StringAttribute{
										Computed: true,
									},
									"ver": schema.StringAttribute{
										Computed: true,
									},
								},
							},
						},
					},
					"passwd": schema.StringAttribute{
						Computed: true,
					},
					"reference_id": schema.StringAttribute{
						Computed: true,
					},
					"status": schema.StringAttribute{
						Computed: true,
					},
					"type": schema.StringAttribute{
						Computed: true,
					},
				},
			},
		},
		"entry_count": schema.Int64Attribute{
			Computed: true,
		},
	}

}
