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"
)

func RGCheckPresence(ctx context.Context, rgId uint64, c *decort.DecortClient) (*rg.RecordRG, error) {
	tflog.Info(ctx, fmt.Sprintf("Get info about resource group with ID - %v", rgId))

	recordRG, err := c.CloudBroker().RG().Get(ctx, rg.GetRequest{RGID: rgId})
	if err != nil {
		return nil, fmt.Errorf("cannot get info about resource group with error: %w", err)
	}

	tflog.Info(ctx, "UtilityRGCheckPresence: response from CloudBroker().RG().Get", map[string]any{"rg_id": rgId, "response": recordRG})

	return recordRG, err
}
