package utilities

import (
	"context"

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

func ComputeGetLogCheckPresence(ctx context.Context, state *models.GetLogModel, c *client.Client) (string, error) {
	tflog.Info(ctx, "Get compute log")

	req := compute.GetLogRequest{
		ComputeID: uint64(state.ComputeID.ValueInt64()),
		Path:      state.Path.ValueString(),
	}

	tflog.Info(ctx, "Check req", map[string]any{"req": req})

	log, err := c.CloudAPI().Compute().GetLog(ctx, req)
	if err != nil {
		return "", err
	}

	tflog.Info(ctx, "Getting compute log, successfully")
	return log, nil
}
