package utilities

import (
	"context"
	"fmt"

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

func AccountGetResourceConsumptionDataSourceCheckPresence(ctx context.Context, accountId uint64, c *client.Client) (*account.RecordResourceConsumption, error) {
	tflog.Info(ctx, fmt.Sprintf("AccountGetResourceConsumptionDataSourceCheckPresence: Get info about account with ID - %v", accountId))

	record, err := c.CloudBroker().Account().GetResourceConsumption(ctx, account.GetResourceConsumptionRequest{AccountID: accountId})
	if err != nil {
		return nil, fmt.Errorf("cannot get info about resource with error: %w", err)
	}

	tflog.Info(ctx, "AccountGetResourceConsumptionDataSourceCheckPresence: response from CloudBroker().Account().GetResourceConsumption",
		map[string]any{"account_id": accountId, "response": record})

	return record, err
}
