package models

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

type DataSourceAccountModel struct {
	// request fields
	AccountID types.Int64    `tfsdk:"account_id"`
	Timeouts  timeouts.Value `tfsdk:"timeouts"`

	// response fields
	Id                     types.String  `tfsdk:"id"`
	DCLocation             types.String  `tfsdk:"dc_location"`
	CKey                   types.String  `tfsdk:"ckey"`
	ACL                    types.List    `tfsdk:"acl"`
	Company                types.String  `tfsdk:"company"`
	CompanyURL             types.String  `tfsdk:"companyurl"`
	ComputeFeatures        types.List    `tfsdk:"compute_features"`
	Computes               types.Object  `tfsdk:"computes"`
	CPUAllocationParameter types.String  `tfsdk:"cpu_allocation_parameter"`
	CPUAllocationRatio     types.Float64 `tfsdk:"cpu_allocation_ratio"`
	CreatedBy              types.String  `tfsdk:"created_by"`
	CreatedTime            types.Int64   `tfsdk:"created_time"`
	DeactivationTime       types.Float64 `tfsdk:"deactivation_time"`
	DeletedBy              types.String  `tfsdk:"deleted_by"`
	DeletedTime            types.Int64   `tfsdk:"deleted_time"`
	Desc                   types.String  `tfsdk:"desc"`
	DisplayName            types.String  `tfsdk:"displayname"`
	GUID                   types.Int64   `tfsdk:"guid"`
	Machines               types.Object  `tfsdk:"machines"`
	AccountName            types.String  `tfsdk:"account_name"`
	ResourceLimits         types.Object  `tfsdk:"resource_limits"`
	SendAccessEmails       types.Bool    `tfsdk:"send_access_emails"`
	Status                 types.String  `tfsdk:"status"`
	UpdatedTime            types.Int64   `tfsdk:"updated_time"`
	Version                types.Int64   `tfsdk:"version"`
	VINS                   types.List    `tfsdk:"vins"`
	VINSes                 types.Int64   `tfsdk:"vinses"`
}

type ResourceLimitsInAccountModel struct {
	CUC      types.Float64 `tfsdk:"cu_c"`
	CUD      types.Float64 `tfsdk:"cu_d"`
	CUI      types.Float64 `tfsdk:"cu_i"`
	CUM      types.Float64 `tfsdk:"cu_m"`
	CUDM     types.Float64 `tfsdk:"cu_dm"`
	CUNP     types.Float64 `tfsdk:"cu_np"`
	GPUUnits types.Float64 `tfsdk:"gpu_units"`
}

type ACLInAccountModel struct {
	Explicit     types.Bool   `tfsdk:"explicit"`
	GUID         types.String `tfsdk:"guid"`
	Right        types.String `tfsdk:"right"`
	Status       types.String `tfsdk:"status"`
	Type         types.String `tfsdk:"type"`
	UserGroupID  types.String `tfsdk:"user_group_id"`
	CanBeDeleted types.Bool   `tfsdk:"can_be_deleted"`
}

type ComputesInAccountModel struct {
	Started types.Int64 `tfsdk:"started"`
	Stopped types.Int64 `tfsdk:"stopped"`
}

type MachinesInAccountModel struct {
	Running types.Int64 `tfsdk:"running"`
	Halted  types.Int64 `tfsdk:"halted"`
}

var ItemResourceLimitsInAccount = map[string]attr.Type{
	"cu_c":      types.Float64Type,
	"cu_d":      types.Float64Type,
	"cu_i":      types.Float64Type,
	"cu_m":      types.Float64Type,
	"cu_dm":     types.Float64Type,
	"cu_np":     types.Float64Type,
	"gpu_units": types.Float64Type,
}

var ItemACLInAccount = map[string]attr.Type{
	"explicit":       types.BoolType,
	"guid":           types.StringType,
	"right":          types.StringType,
	"status":         types.StringType,
	"type":           types.StringType,
	"user_group_id":  types.StringType,
	"can_be_deleted": types.BoolType,
}

var ItemComputesInAccount = map[string]attr.Type{
	"started": types.Int64Type,
	"stopped": types.Int64Type,
}

var ItemMachinesInAccount = map[string]attr.Type{
	"running": types.Int64Type,
	"halted":  types.Int64Type,
}
