package kvmvm

import (
	"context"

	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
	"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)

func utilityComputeSnapshotUsageCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (compute.ListUsageSnapshots, error) {
	c := m.(*controller.ControllerCfg)
	req := compute.SnapshotUsageRequest{
		ComputeID: uint64(d.Get("compute_id").(int)),
	}

	if label, ok := d.GetOk("label"); ok {
		req.Label = label.(string)
	}

	computeSnapshotUsage, err := c.CloudAPI().Compute().SnapshotUsage(ctx, req)
	if err != nil {
		return nil, err
	}

	return computeSnapshotUsage, err

}
