package stpolicy

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

func dataSourceStoragePolicySchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"storage_policy_id": {
			Type:     schema.TypeInt,
			Required: true,
		},
		"description": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"guid": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"limit_iops": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"name": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"status": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"access_seps_pools": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"pool_names": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeString,
						},
					},
					"sep_id": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"sep_name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"sep_tech_status": {
						Type:     schema.TypeString,
						Computed: true,
					},
				},
			},
		},
		"usage": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"accounts": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
					"resgroups": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
					},
				},
			},
		},
	}

	return res
}

func dataSourceStoragePolicyListSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"account_id": {
			Type:     schema.TypeInt,
			Optional: true,
		},
		"page": {
			Type:     schema.TypeInt,
			Optional: true,
		},
		"size": {
			Type:     schema.TypeInt,
			Optional: true,
		},
		"by_id": {
			Type:     schema.TypeInt,
			Optional: true,
		},
		"name": {
			Type:     schema.TypeString,
			Optional: true,
		},
		"status": {
			Type:     schema.TypeString,
			Optional: true,
		},
		"desc": {
			Type:     schema.TypeString,
			Optional: true,
		},
		"limit_iops": {
			Type:     schema.TypeInt,
			Optional: true,
		},
		"sort_by": {
			Type:     schema.TypeString,
			Optional: true,
		},
		"resgroup_id": {
			Type:     schema.TypeInt,
			Optional: true,
		},
		"sep_id": {
			Type:     schema.TypeInt,
			Optional: true,
		},
		"sep_tech_status": {
			Type:         schema.TypeString,
			Optional:     true,
			ValidateFunc: validation.StringInSlice([]string{"ENABLED", "DISABLED"}, true),
		},
		"pool_name": {
			Type:     schema.TypeString,
			Optional: true,
		},

		"items": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"storage_policy_id": {
						Type:     schema.TypeInt,
						Required: true,
					},
					"description": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"guid": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"limit_iops": {
						Type:     schema.TypeInt,
						Computed: true,
					},
					"name": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"status": {
						Type:     schema.TypeString,
						Computed: true,
					},
					"access_seps_pools": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"pool_names": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Schema{
										Type: schema.TypeString,
									},
								},
								"sep_id": {
									Type:     schema.TypeInt,
									Computed: true,
								},
								"sep_name": {
									Type:     schema.TypeString,
									Computed: true,
								},
								"sep_tech_status": {
									Type:     schema.TypeString,
									Computed: true,
								},
							},
						},
					},
					"usage": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
								"accounts": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Schema{
										Type: schema.TypeInt,
									},
								},
								"resgroups": {
									Type:     schema.TypeList,
									Computed: true,
									Elem: &schema.Schema{
										Type: schema.TypeInt,
									},
								},
							},
						},
					},
				},
			},
		},
		"entry_count": {
			Type:     schema.TypeInt,
			Computed: true,
		},
	}
	return res
}
