package user

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

func resourceUserV1() *schema.Resource {
	return &schema.Resource{
		Schema: map[string]*schema.Schema{
			"username": {
				Type:        schema.TypeString,
				Required:    true,
				Description: "ID of user",
			},
			"emailaddress": {
				Type:     schema.TypeList,
				Required: true,
				Elem: &schema.Schema{
					Type: schema.TypeString,
				},
				Description: "Email address of the user",
			},
			"password": {
				Type:        schema.TypeString,
				Default:     "strongpassword",
				Optional:    true,
				Description: "password of user",
			},
			"provider_name": {
				Type:         schema.TypeString,
				Optional:     true,
				Description:  "provider",
				ValidateFunc: validation.StringInSlice([]string{"bvs", "decs3o"}, false),
			},
			"groups": {
				Type:     schema.TypeList,
				Computed: true,
				Elem: &schema.Schema{
					Type: schema.TypeString,
				},
				Description: "list of groups this user belongs to",
			},
			"ckey": {
				Type:        schema.TypeString,
				Computed:    true,
				Description: "ckey",
			},
			"meta": {
				Type:     schema.TypeList,
				Computed: true,
				Elem: &schema.Schema{
					Type: schema.TypeString,
				},
				Description: "meta",
			},
			"active": {
				Type:        schema.TypeBool,
				Computed:    true,
				Description: "active",
			},
			"apiaccess": {
				Type:     schema.TypeSet,
				Optional: true,
				Computed: true,
				Elem: &schema.Schema{
					Type: schema.TypeInt,
				},
				Description: "list of apiaccess groups this user belongs to",
			},
			"blocked": {
				Type:        schema.TypeBool,
				Optional:    true,
				Computed:    true,
				Description: "is the user blocked",
			},
			"authkey": {
				Type:        schema.TypeString,
				Computed:    true,
				Description: "authkey",
			},
			"auth_keys": {
				Type:     schema.TypeList,
				Computed: true,
				Elem: &schema.Schema{
					Type: schema.TypeString,
				},
				Description: "authkeys",
			},
			"data": {
				Type:        schema.TypeString,
				Computed:    true,
				Description: "data",
			},
			"description": {
				Type:        schema.TypeString,
				Computed:    true,
				Description: "description",
			},
			"domain": {
				Type:        schema.TypeString,
				Computed:    true,
				Description: "domain",
			},
			"gid": {
				Type:        schema.TypeInt,
				Computed:    true,
				Description: "gid",
			},
			"guid": {
				Type:        schema.TypeString,
				Computed:    true,
				Description: "guid",
			},
			"last_check": {
				Type:        schema.TypeInt,
				Computed:    true,
				Description: "last_check",
			},
			"mobile": {
				Type:     schema.TypeList,
				Computed: true,
				Elem: &schema.Schema{
					Type: schema.TypeString,
				},
				Description: "mobile",
			},
			"protected": {
				Type:        schema.TypeBool,
				Computed:    true,
				Description: "protected",
			},
			"roles": {
				Type:     schema.TypeList,
				Computed: true,
				Elem: &schema.Schema{
					Type: schema.TypeString,
				},
				Description: "roles",
			},
			"service_account": {
				Type:        schema.TypeBool,
				Computed:    true,
				Description: "service_account",
			},
			"xmpp": {
				Type:     schema.TypeList,
				Computed: true,
				Elem: &schema.Schema{
					Type: schema.TypeString,
				},
				Description: "xmpp",
			},
		},
	}
}
