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/cloudapi/vins"
	"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
)

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

	diags := diag.Diagnostics{}

	extnetList, err := c.CloudAPI().VINS().ExtNetList(ctx, vins.ExtNetListRequest{VINSID: vinsId})
	if err != nil {
		diags.AddError(fmt.Sprintf("Cannot get info about extnet list for vins with ID %v", vinsId), err.Error())
		return nil, diags
	}

	tflog.Info(ctx, "VINSExtNetListDataSourceCheckPresence: successfull response from CloudAPI().VINS().ExtNetList", map[string]any{"vins_id": vinsId})

	return extnetList, nil
}
