package utilities

import (
	"context"
	"fmt"

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

func RGListPFWCheckPresence(ctx context.Context, plan *models.DataSourceRGListPFWModel, c *client.Client) (*rg.ListPortForwards, error) {
	listPFWReq := rg.ListPFWRequest{
		RGID: uint64(plan.RGID.ValueInt64()),
	}

	tflog.Info(ctx, "RGListPFWCheckPresence: before call CloudAPI().RG().ListPFW", map[string]any{"response": listPFWReq})
	rgListPFW, err := c.CloudAPI().RG().ListPFW(ctx, listPFWReq)
	if err != nil {
		return nil, fmt.Errorf("cannot get info about resource group list pfw with error: %w", err)
	}

	tflog.Info(ctx, "RGListPFWCheckPresence: response from CloudAPI().RG().ListPFW", map[string]any{"response": rgListPFW})

	return rgListPFW, err
}
