// Code generated by sdkgen-v2. DO NOT EDIT.
package dnssdk

import (
	"context"

	dns "github.com/yandex-cloud/go-genproto/yandex/cloud/dns/v1"
	"github.com/yandex-cloud/go-sdk/v2/pkg/sdkresolvers"
)

type dnsInboundEndpointResolver struct {
	client DnsInboundEndpointClient
	sdkresolvers.BaseNameResolver
}

func DnsInboundEndpointResolver(name string, client DnsInboundEndpointClient, opts ...sdkresolvers.ResolveOption) sdkresolvers.Resolver {
	return &dnsInboundEndpointResolver{
		client:           client,
		BaseNameResolver: sdkresolvers.NewBaseNameResolver(name, "DnsInboundEndpoint", opts...),
	}
}

func (r *dnsInboundEndpointResolver) Run(ctx context.Context) error {
	err := r.EnsureFolderID()
	if err != nil {
		return err
	}

	resp := r.client.Iterator(ctx, &dns.ListDnsInboundEndpointsRequest{
		FolderId: r.FolderID(),
		Filter:   sdkresolvers.CreateResolverFilter("name", r.Name),
		PageSize: sdkresolvers.DefaultResolverPageSize,
	})
	return r.FindName(resp.TakeAll())
}
