package utilities

import (
	"context"
	"fmt"

	"github.com/hashicorp/terraform-plugin-log/tflog"
	decort "repository.basistech.ru/BASIS/decort-golang-sdk"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vfpool"
)

func VFPoolCheckPresence(ctx context.Context, vfPoolID uint64, c *decort.DecortClient) (*vfpool.RecordVFPool,
	error) {
	req := vfpool.GetRequest{VFPoolID: vfPoolID}

	tflog.Info(ctx, "VFPoolCheckPresence: before call CloudAPI().VFPool().Get", map[string]any{"req": req})
	vfPool, err := c.CloudAPI().VFPool().Get(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("VFPoolCheckPresence: cannot get info about vfpool")
	}

	tflog.Info(ctx, "VFPoolCheckPresence: response from CloudAPI().VFPool().Get", map[string]any{"response": vfPool})

	return vfPool, err
}
