package utilities

import (
	"context"
	"fmt"

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

func VINSIPListDataSourceCheckPresence(ctx context.Context, vinsId uint64, c *client.Client) (*vins.ListIPs, diag.Diagnostics) {
	tflog.Info(ctx, fmt.Sprintf("VINSIPListDataSourceCheckPresence: Get info about vins audit with vins ID - %v", vinsId))

	diags := diag.Diagnostics{}

	ipList, err := c.CloudBroker().VINS().IPList(ctx, vins.IPListRequest{VINSID: vinsId})
	if err != nil {
		diags.AddError(fmt.Sprintf("Cannot get info about ip list for vins with ID %v", vinsId), err.Error())
		return nil, diags
	}

	tflog.Info(ctx, "VINSIPListDataSourceCheckPresence: successful response from CloudBroker().VINS().IPList", map[string]any{"vins_id": vinsId})

	return ipList, nil
}
