package utilities

import (
	"context"
	"fmt"

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

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

	recordDisk, err := c.CloudBroker().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, "DiskSnapshotListCheckPresence: response from CloudBroker().Disks().Get", map[string]any{
		"disk_id":  diskId,
		"response": recordDisk})

	return &recordDisk.Snapshots, err
}
