package models

import (
	"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
	"github.com/hashicorp/terraform-plugin-framework/attr"
	"github.com/hashicorp/terraform-plugin-framework/types"
)

type RecordBasicServiceResourceModel struct {
	//required fields
	Name types.String `tfsdk:"service_name"`
	RGID types.Int64  `tfsdk:"rg_id"`

	//optional fields
	SSHKey      types.String   `tfsdk:"ssh_key"`
	SSHUser     types.String   `tfsdk:"ssh_user"`
	Permanently types.Bool     `tfsdk:"permanently"`
	Enable      types.Bool     `tfsdk:"enable"`
	Restore     types.Bool     `tfsdk:"restore"`
	Start       types.Bool     `tfsdk:"start"`
	ServiceId   types.Int64    `tfsdk:"service_id"`
	Snapshots   types.Set      `tfsdk:"snapshots"`
	Timeouts    timeouts.Value `tfsdk:"timeouts"`

	//computed fields
	AccountID     types.Int64  `tfsdk:"account_id"`
	AccountName   types.String `tfsdk:"account_name"`
	BaseDomain    types.String `tfsdk:"base_domain"`
	Computes      types.List   `tfsdk:"computes"`
	CPUTotal      types.Int64  `tfsdk:"cpu_total"`
	CreatedBy     types.String `tfsdk:"created_by"`
	CreatedTime   types.Int64  `tfsdk:"created_time"`
	DeletedBy     types.String `tfsdk:"deleted_by"`
	DeletedTime   types.Int64  `tfsdk:"deleted_time"`
	DiskTotal     types.Int64  `tfsdk:"disk_total"`
	GID           types.Int64  `tfsdk:"gid"`
	Groups        types.List   `tfsdk:"groups"`
	GUID          types.Int64  `tfsdk:"guid"`
	Milestones    types.Int64  `tfsdk:"milestones"`
	ParentSrvID   types.Int64  `tfsdk:"parent_srv_id"`
	ParentSrvType types.String `tfsdk:"parent_srv_type"`
	RAMTotal      types.Int64  `tfsdk:"ram_total"`
	RGName        types.String `tfsdk:"rg_name"`
	Status        types.String `tfsdk:"status"`
	TechStatus    types.String `tfsdk:"tech_status"`
	UpdatedBy     types.String `tfsdk:"updated_by"`
	UpdatedTime   types.Int64  `tfsdk:"updated_time"`
	UserManaged   types.Bool   `tfsdk:"user_managed"`
	ID            types.String `tfsdk:"id"`
}

type ItemComputeResourceModel struct {
	AccountID     types.Int64  `tfsdk:"account_id"`
	Architecture  types.String `tfsdk:"architecture"`
	CompGroupID   types.Int64  `tfsdk:"compgroup_id"`
	CompGroupName types.String `tfsdk:"compgroup_name"`
	CompGroupRole types.String `tfsdk:"compgroup_role"`
	ID            types.Int64  `tfsdk:"id"`
	Name          types.String `tfsdk:"name"`
	RGID          types.Int64  `tfsdk:"rg_id"`
	StackID       types.Int64  `tfsdk:"stack_id"`
	Status        types.String `tfsdk:"status"`
	TechStatus    types.String `tfsdk:"tech_status"`
}

var ItemComputeResource = map[string]attr.Type{
	"account_id":     types.Int64Type,
	"architecture":   types.StringType,
	"compgroup_id":   types.Int64Type,
	"compgroup_name": types.StringType,
	"compgroup_role": types.StringType,
	"id":             types.Int64Type,
	"name":           types.StringType,
	"rg_id":          types.Int64Type,
	"stack_id":       types.Int64Type,
	"status":         types.StringType,
	"tech_status":    types.StringType,
}

type ItemGroupResourceModel struct {
	Computes    types.Int64  `tfsdk:"computes"`
	Consistency types.Bool   `tfsdk:"consistency"`
	ID          types.Int64  `tfsdk:"id"`
	Name        types.String `tfsdk:"name"`
	Status      types.String `tfsdk:"status"`
	TechStatus  types.String `tfsdk:"tech_status"`
}

var ItemGroupResource = map[string]attr.Type{
	"computes":    types.Int64Type,
	"consistency": types.BoolType,
	"id":          types.Int64Type,
	"name":        types.StringType,
	"status":      types.StringType,
	"tech_status": types.StringType,
}

type ItemSnapshotResourceModel struct {
	GUID      types.String `tfsdk:"guid"`
	Label     types.String `tfsdk:"label"`
	Rollback  types.Bool   `tfsdk:"rollback"`
	Timestamp types.Int64  `tfsdk:"timestamp"`
	Valid     types.Bool   `tfsdk:"valid"`
}

var ItemSnapshotResource = map[string]attr.Type{
	"guid":      types.StringType,
	"label":     types.StringType,
	"rollback":  types.BoolType,
	"timestamp": types.Int64Type,
	"valid":     types.BoolType,
}
