package utilities

import (
	"context"
	"fmt"

	"github.com/hashicorp/terraform-plugin-log/tflog"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vfpool"
	"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
)

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

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

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

	return vfPool, err
}
