package pcidevice

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

func dataSourcePcideviceSchemaMake() map[string]*schema.Schema {
	rets := map[string]*schema.Schema{
		"device_id": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"compute_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"description": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"guid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"hw_path": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"name": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"rg_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"node_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"status": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"system_name": {
			Type:     schema.TypeString,
			Computed: true,
		},
	}
	return rets
}

func dataSourcePcideviceListSchemaMake() map[string]*schema.Schema {
	rets := map[string]*schema.Schema{
		"by_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "by_id",
		},
		"compute_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "compute_id",
		},
		"name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "name",
		},
		"rg_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "rg_id",
		},
		"status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "status",
		},
		"page": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "page number",
		},
		"size": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "page size",
		},
		"items": {
			Type:        schema.TypeList,
			Computed:    true,
			Description: "pcidevice list",
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"device_id": {
						Type:     schema.TypeInt,
						Required: true,
					},
					"compute_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"description": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"guid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"hw_path": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"rg_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"node_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"system_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
				},
			},
		},
		"entry_count": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "entry count",
		},
	}
	return rets
}

func resourcePcideviceSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"node_id": {
			Type:         schema.TypeInt,
			Required:     true,
			ValidateFunc: validation.IntAtLeast(1),
			Description:  "Node ID",
		},
		"rg_id": {
			Type:         schema.TypeInt,
			Required:     true,
			ValidateFunc: validation.IntAtLeast(1),
			Description:  "Resource GROUP",
		},
		"name": {
			Type:        schema.TypeString,
			Required:    true,
			Description: "Name of Device",
		},
		"hw_path": {
			Type:        schema.TypeString,
			Required:    true,
			Description: "PCI address of the device",
		},
		"ckey": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"compute_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"description": {
			Type:        schema.TypeString,
			Optional:    true,
			Computed:    true,
			Description: "description, just for information",
		},
		"device_id": {
			Type:     schema.TypeInt,
			Optional: true,
			Computed: true,
		},
		"enable": {
			Type:        schema.TypeBool,
			Optional:    true,
			Default:     false,
			Description: "Enable pci device",
		},
		"force_delete": {
			Type:        schema.TypeBool,
			Optional:    true,
			Default:     false,
			Description: "Force delete",
		},
		"force_disable": {
			Type:        schema.TypeBool,
			Optional:    true,
			Default:     false,
			Description: "Force disable",
		},
		"guid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"meta": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
		},
		"status": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"system_name": {
			Type:     schema.TypeString,
			Computed: true,
		},
	}
}
