package utilities

import (
	"context"
	"fmt"

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

func ExtNetCheckPresence(ctx context.Context, netId uint64, c *client.Client) (*extnet.RecordExtNet, error) {
	tflog.Info(ctx, fmt.Sprintf("Get info about extnet with ID - %v", netId))

	recordExtNet, err := c.CloudAPI().ExtNet().Get(ctx, extnet.GetRequest{NetID: netId})
	if err != nil {
		return nil, fmt.Errorf("cannot get info about extnet with error: %w", err)
	}

	tflog.Info(ctx, "ExtNetCheckPresence: response from CloudAPI().ExtNet().Get", map[string]any{"net_id": netId, "response": recordExtNet})

	return recordExtNet, err
}
