package utilities

import (
	"context"
	"fmt"

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

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

	recordAccount, err := c.CloudAPI().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, "AccountDataSourceCheckPresence: response from CloudAPI().Account().Get",
		map[string]any{"account_id": accountId, "response": recordAccount})

	return recordAccount, err
}
