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 AccountDataSourceCheckPresence(ctx context.Context, accountId uint64, c *client.Client) (*account.InfoAccount, error) {
	tflog.Info(ctx, fmt.Sprintf("CbAccountDataSourceCheckPresence: Get info about account with ID - %v", accountId))

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

	tflog.Info(ctx, "CbAccountDataSourceCheckPresence: response from CloudBroker().Account().Get",
		map[string]any{"account_id": accountId, "response": recordAccount})

	return &recordAccount.InfoAccount, err
}
