package utilities

import (
	"context"
	"fmt"

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

func DataSourceDiskCheckPresence(ctx context.Context, diskId uint64, c *client.Client) (*disks.RecordDisk, error) {
	tflog.Info(ctx, fmt.Sprintf("DataSourceDiskCheckPresence: Get info about disk with ID - %v", diskId))

	recordDisk, err := c.CloudAPI().Disks().Get(ctx, disks.GetRequest{DiskID: diskId})
	if err != nil {
		return nil, fmt.Errorf("cannot get info about disk with error: %w", err)
	}

	tflog.Info(ctx, "DataSourceDiskCheckPresence: response from CloudAPI().Disks().Get", map[string]any{
		"disk_id":  diskId,
		"response": recordDisk})

	return recordDisk, err
}
