package vfpool

import (
	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceVFPoolSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"vfpool_id": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"account_access": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
		},
		"created_time": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"description": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"gid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"guid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"name": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"rg_access": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
		},
		"status": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"updated_time": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"vfs": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"node_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vf_list": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"nic_name": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"vfs_info": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"id": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"claimed": {
												Type:     schema.TypeBool,
												Computed: true,
											},
											"vm_id": {
												Type:     schema.TypeInt,
												Computed: true,
											},
										},
									},
								},
							},
						},
					},
				},
			},
		},
	}

	return res
}

func dataSourceVFPoolListSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"by_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Find by ID",
		},
		"gid": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Find by Grid ID",
		},
		"name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Find by name",
		},
		"description": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Find by description",
		},
		"status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Find by status",
		},
		"account_access": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Find by accountAccess",
		},
		"rg_access": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Find by rgAccess",
		},
		"sort_by": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "sort by one of supported fields, format +|-(field)",
		},
		"page": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Page number",
		},
		"size": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Page size",
		},
		"items": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"account_access": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"created_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"description": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"gid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"guid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vfpool_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"rg_access": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"updated_time": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vfs": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"node_id": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"vf_list": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"nic_name": {
												Type:     schema.TypeString,
												Computed: true,
											},
											"vfs_info": {
												Type:     schema.TypeList,
												Computed: true,
												Elem: &schema.Resource{
													Schema: map[string]*schema.Schema{
														"id": {
															Type:     schema.TypeInt,
															Computed: true,
														},
														"claimed": {
															Type:     schema.TypeBool,
															Computed: true,
														},
														"vm_id": {
															Type:     schema.TypeInt,
															Computed: true,
														},
													},
												},
											},
										},
									},
								},
							},
						},
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}

	return res
}

func resourceVFPoolSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"name": {
			Type:        schema.TypeString,
			Required:    true,
			Description: "Name of device",
		},
		"description": {
			Type:     schema.TypeString,
			Computed: true,
			Optional: true,
			Description: "Description",
		},
		"account_access": {
			Type:     schema.TypeSet,
			Computed: true,
			Optional: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
			Description: "List of account IDs",
		},
		"rg_access": {
			Type:     schema.TypeSet,
			Computed: true,
			Optional: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
			Description: "List of RG IDs",
		},
		"config": {
			Type:     schema.TypeSet,
			Optional: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"node_id": {
						Type:     schema.TypeInt,
						Required: true,
					},
					"nic_name": {
						Type:     schema.TypeString,
						Required: true,
					},
					"vf_ids": {
						Required: true,
						Type:     schema.TypeList,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
						MinItems: 1,
					},
				},
			},
			Description: "List of dict describing configuration data",
		},
		"enable": {
			Type:     schema.TypeBool,
			Optional: true,
		},
		"created_time": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"gid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"guid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"vfpool_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"status": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"updated_time": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"vfs": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"node_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"vf_list": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"nic_name": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"vfs_info": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Resource{
										Schema: map[string]*schema.Schema{
											"id": {
												Type:     schema.TypeInt,
												Computed: true,
											},
											"claimed": {
												Type:     schema.TypeBool,
												Computed: true,
											},
											"vm_id": {
												Type:     schema.TypeInt,
												Computed: true,
											},
										},
									},
								},
							},
						},
					},
				},
			},
		},
	}

	return res
}
