package utilities

import (
	"context"
	"fmt"

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

func RGCheckPresence(ctx context.Context, rgId uint64, c *client.Client) (*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
}
