package flipgroup

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

func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
	rets := map[string]*schema.Schema{
		"flipgroup_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "flipgroup_id",
		},
		"account_id": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "account_id",
		},
		"account_name": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "account_name",
		},
		"client_ids": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
			Description: "client_ids",
		},
		"client_names": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
			Description: "client_names",
		},
		"client_type": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "client_type",
		},
		"conn_id": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "conn_id",
		},
		"conn_type": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "conn_type",
		},
		"created_by": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "created_by",
		},
		"created_time": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "created_time",
		},
		"default_gw": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "default_gw",
		},
		"deleted_by": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "deleted_by",
		},
		"deleted_time": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "deleted_time",
		},
		"description": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "description",
		},
		"gid": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "gid",
		},
		"guid": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "guid",
		},
		"ip": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "ip",
		},
		"milestones": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "milestones",
		},
		"name": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "name",
		},
		"net_id": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "net_id",
		},
		"net_type": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "net_type",
		},
		"network": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "network",
		},
		"status": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "status",
		},
		"updated_by": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "updated_by",
		},
		"updated_time": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "updated_time",
		},
	}
	return rets
}

func dataSourceFlipgroupsListSchemaMake() map[string]*schema.Schema {
	res := map[string]*schema.Schema{
		"name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "name",
		},
		"vins_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "vins_id",
		},
		"vins_name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "vins_name",
		},
		"extnet_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "extnet_id",
		},
		"by_ip": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "by_ip",
		},
		"by_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "by_id",
		},
		"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",
		},
		"account_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Account id",
		},
		"conn_id": {
			Type:        schema.TypeInt,
			Optional:    true,
			Description: "Conn id",
		},
		"client_ids": {
			Type:     schema.TypeList,
			Optional: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
			Description: "client_ids",
		},
		"status": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "Status",
		},
		"items": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"ckey": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "ckey",
					},
					"meta": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeString,
						},
					},
					"account_id": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "account_id",
					},
					"client_ids": {
						Type:     schema.TypeList,
						Computed: true,
						Elem: &schema.Schema{
							Type: schema.TypeInt,
						},
						Description: "client_ids",
					},
					"client_type": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "client_type",
					},
					"conn_id": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "conn_id",
					},
					"conn_type": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "conn_type",
					},
					"default_gw": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "default_gw",
					},
					"description": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "description",
					},
					"gid": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "gid",
					},
					"guid": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "guid",
					},
					"flipgroup_id": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "flipgroup_id",
					},
					"ip": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "ip",
					},
					"milestones": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "milestones",
					},
					"name": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "name",
					},
					"net_id": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "net_id",
					},
					"net_type": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "net_type",
					},
					"net_mask": {
						Type:        schema.TypeInt,
						Computed:    true,
						Description: "net_mask",
					},
					"status": {
						Type:        schema.TypeString,
						Computed:    true,
						Description: "status",
					},
				},
			},
		},
		"entry_count": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "entry_count",
		},
	}
	return res
}

func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
	return map[string]*schema.Schema{
		"account_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "Account ID",
		},
		"name": {
			Type:        schema.TypeString,
			Required:    true,
			Description: "Flipgroup name",
		},
		"net_id": {
			Type:        schema.TypeInt,
			Required:    true,
			Description: "EXTNET or ViNS ID",
		},
		"net_type": {
			Type:         schema.TypeString,
			Required:     true,
			ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS"}, true),
			Description:  "Network type, EXTNET or VINS",
		},
		"client_type": {
			Type:         schema.TypeString,
			Optional:     true,
			Default:      "compute",
			Description:  "Type of client, 'compute' ('vins' will be later)",
			ValidateFunc: validation.StringInSlice([]string{"compute"}, true),
		},
		"ip": {
			Type:        schema.TypeString,
			Optional:    true,
			Computed:    true,
			Description: "IP address to associate with this group. If empty, the platform will autoselect IP address",
		},
		"desc": {
			Type:        schema.TypeString,
			Optional:    true,
			Computed:    true,
			Description: "Text description of this Flipgroup instance",
		},
		"client_ids": {
			Type:     schema.TypeList,
			Optional: true,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeInt,
			},
			Description: "List of clients attached to this Flipgroup instance",
		},
		"client_names": {
			Type:     schema.TypeList,
			Computed: true,
			Elem: &schema.Schema{
				Type: schema.TypeString,
			},
			Description: "client_names",
		},
		"account_name": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "account_name",
		},
		"flipgroup_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"conn_id": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"conn_type": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"created_by": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "created_by",
		},
		"created_time": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "created_time",
		},
		"default_gw": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"deleted_by": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "deleted_by",
		},
		"deleted_time": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "deleted_time",
		},
		"gid": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "gid",
		},
		"guid": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "guid",
		},
		"milestones": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "milestones",
		},
		"network": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "network",
		},
		"status": {
			Type:     schema.TypeString,
			Computed: true,
		},
		"updated_by": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "updated_by",
		},
		"updated_time": {
			Type:        schema.TypeInt,
			Computed:    true,
			Description: "updated_time",
		},
		"net_mask": {
			Type:     schema.TypeInt,
			Computed: true,
		},
		"ckey": {
			Type:     schema.TypeString,
			Computed: true,
		},
	}
}
