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

	limits, err := c.CloudAPI().Account().GetConsumedAccountUnits(ctx, account.GetConsumedAccountUnitsRequest{AccountID: accountId})
	if err != nil {
		return nil, fmt.Errorf("cannot get info about account consumed units with error: %w", err)
	}

	tflog.Info(ctx, "AccountConsumedUnitsDataSourceCheckPresence: response from CloudAPI().Account().GetConsumedAccountUnits",
		map[string]any{"account_id": accountId, "response": limits})

	return limits, err
}
