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/cloudbroker/rg"
	"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
)

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

	tflog.Info(ctx, "RGListPFWCheckPresence: before call CloudBroker().RG().ListPFW", map[string]any{"response": listPFWReq})
	rgListPFW, err := c.CloudBroker().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 CloudBroker().RG().ListPFW", map[string]any{"response": rgListPFW})

	return rgListPFW, err
}
