package rg

import (
	"context"

	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
	log "github.com/sirupsen/logrus"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
	"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)

func utilityRgAuditsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (rg.ListAudits, error) {
	c := m.(*controller.ControllerCfg)
	req := rg.AuditsRequest{
		RGID: uint64(d.Get("rg_id").(int)),
	}

	log.Debugf("utilityRgAuditsCheckPresence: load rg audits")
	rgAudits, err := c.CloudBroker().RG().Audits(ctx, req)
	if err != nil {
		return nil, err
	}

	return rgAudits, nil
}
