package utilities

import (
	"context"

	"github.com/hashicorp/terraform-plugin-framework/diag"
	"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
	"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/ic"
	"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/k8s/models"
)

func CheckParamsExistenceCP(ctx context.Context, plan *models.ResourceK8SCPModel, c *client.Client) diag.Diagnostics {
	diags := diag.Diagnostics{}

	if err := ic.ExistRG(ctx, uint64(plan.RGID.ValueInt64()), c); err != nil {
		diags.AddError("Error check input values", err.Error())
	}

	if err := ic.ExistK8CI(ctx, uint64(plan.K8SCIID.ValueInt64()), c); err != nil {
		diags.AddError("Error check input values", err.Error())
	}

	if err := ic.ExistExtNetInK8s(ctx, uint64(plan.ExtNetID.ValueInt64()), c); err != nil {
		diags.AddError("Error check input values", err.Error())
	}

	if err := ic.ExistVinsInK8s(ctx, uint64(plan.VinsId.ValueInt64()), c); err != nil {
		diags.AddError("Error check input values", err.Error())
	}

	return diags
}

func CheckParamsExistenceWG(ctx context.Context, plan *models.ResourceK8SWGModel, c *client.Client) diag.Diagnostics {
	diags := diag.Diagnostics{}

	if err := ic.ExistK8s(ctx, uint64(plan.K8SID.ValueInt64()), c); err != nil {
		diags.AddError("Error check input values", err.Error())
	}

	return diags
}
