package utilities

import (
	"context"

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

func VINSNATRuleListDataSourceCheckPresence(ctx context.Context, state *models.DataSourceVINSNATRuleListModel, c *client.Client) (*vins.ListNATRules, diag.Diagnostics) {
	tflog.Info(ctx, "VINSNATRuleListDataSourceCheckPresence: Get info about vins nat rule list")

	diags := diag.Diagnostics{}

	req := vins.NATRuleListRequest{
		VINSID: uint64(state.VinsID.ValueInt64()),
	}

	natRuleList, err := c.CloudBroker().VINS().NATRuleList(ctx, req)
	if err != nil {
		diags.AddError("Cannot get info about vins nat rule list", err.Error())
		return nil, diags
	}
	tflog.Info(ctx, "VINSNATRuleListDataSourceCheckPresence: successful response from CloudBroker().VINS().NATRuleList")

	return natRuleList, nil
}
