package schemas

import (
	"github.com/hashicorp/terraform-plugin-framework/resource/schema"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
	"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
)

func MakeSchemaResourceBService() map[string]schema.Attribute {
	return map[string]schema.Attribute{
		"service_name": schema.StringAttribute{
			Required: true,
		},
		"rg_id": schema.Int64Attribute{
			Required: true,
		},
		"ssh_key": schema.StringAttribute{
			Optional: true,
			Computed: true,
		},
		"ssh_user": schema.StringAttribute{
			Optional: true,
			Computed: true,
		},
		"permanently": schema.BoolAttribute{
			Optional: true,
			Computed: true,
			Default:  booldefault.StaticBool(true),
		},
		"enable": schema.BoolAttribute{
			Optional: true,
			Computed: true,
			Default:  booldefault.StaticBool(true),
		},
		"restore": schema.BoolAttribute{
			Optional: true,
			Computed: true,
			Default:  booldefault.StaticBool(false),
		},
		"start": schema.BoolAttribute{
			Optional: true,
			Computed: true,
			Default:  booldefault.StaticBool(false),
		},
		"service_id": schema.Int64Attribute{
			Optional: true,
			Computed: true,
		},
		"snapshots": schema.SetNestedAttribute{
			Optional: true,
			Computed: true,
			NestedObject: schema.NestedAttributeObject{
				Attributes: map[string]schema.Attribute{
					"guid": schema.StringAttribute{
						Computed: true,
					},
					"label": schema.StringAttribute{
						Required: true,
					},
					"rollback": schema.BoolAttribute{
						Optional: true,
					},
					"timestamp": schema.Int64Attribute{
						Computed: true,
					},
					"valid": schema.BoolAttribute{
						Computed: true,
					},
				},
			},
		},
		"account_id": schema.Int64Attribute{
			Computed: true,
		},
		"account_name": schema.StringAttribute{
			Computed: true,
		},
		"base_domain": schema.StringAttribute{
			Computed: true,
		},
		"computes": schema.ListNestedAttribute{
			Computed: true,
			NestedObject: schema.NestedAttributeObject{
				Attributes: map[string]schema.Attribute{
					"account_id": schema.Int64Attribute{
						Computed: true,
					},
					"architecture": schema.StringAttribute{
						Computed: true,
					},
					"compgroup_id": schema.Int64Attribute{
						Computed: true,
					},
					"compgroup_name": schema.StringAttribute{
						Computed: true,
					},
					"compgroup_role": schema.StringAttribute{
						Computed: true,
					},
					"id": schema.Int64Attribute{
						Computed: true,
					},
					"rg_id": schema.Int64Attribute{
						Computed: true,
					},
					"stack_id": schema.Int64Attribute{
						Computed: true,
					},
					"name": schema.StringAttribute{
						Computed: true,
					},
					"status": schema.StringAttribute{
						Computed: true,
					},
					"tech_status": schema.StringAttribute{
						Computed: true,
					},
				},
			},
		},
		"cpu_total": schema.Int64Attribute{
			Computed: true,
		},
		"created_by": schema.StringAttribute{
			Computed: true,
		},
		"created_time": schema.Int64Attribute{
			Computed: true,
		},
		"deleted_by": schema.StringAttribute{
			Computed: true,
		},
		"deleted_time": schema.Int64Attribute{
			Computed: true,
		},
		"disk_total": schema.Int64Attribute{
			Computed: true,
		},
		"gid": schema.Int64Attribute{
			Computed: true,
		},
		"groups": schema.ListNestedAttribute{
			Computed: true,
			NestedObject: schema.NestedAttributeObject{
				Attributes: map[string]schema.Attribute{
					"computes": schema.Int64Attribute{
						Computed: true,
					},
					"consistency": schema.BoolAttribute{
						Computed: true,
					},
					"id": schema.Int64Attribute{
						Computed: true,
					},
					"name": schema.StringAttribute{
						Computed: true,
					},
					"status": schema.StringAttribute{
						Computed: true,
					},
					"tech_status": schema.StringAttribute{
						Computed: true,
					},
				},
			},
		},
		"guid": schema.Int64Attribute{
			Computed: true,
		},
		"milestones": schema.Int64Attribute{
			Computed: true,
		},
		"parent_srv_id": schema.Int64Attribute{
			Computed: true,
		},
		"parent_srv_type": schema.StringAttribute{
			Computed: true,
		},
		"ram_total": schema.Int64Attribute{
			Computed: true,
		},
		"rg_name": schema.StringAttribute{
			Computed: true,
		},
		"status": schema.StringAttribute{
			Computed: true,
		},
		"tech_status": schema.StringAttribute{
			Computed: true,
		},
		"updated_by": schema.StringAttribute{
			Computed: true,
		},
		"updated_time": schema.Int64Attribute{
			Computed: true,
		},
		"user_managed": schema.BoolAttribute{
			Computed: true,
		},
		"id": schema.StringAttribute{
			Computed: true,
			PlanModifiers: []planmodifier.String{
				stringplanmodifier.UseStateForUnknown(),
			},
		},
	}
}
