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

import (
	"context"

	access "github.com/yandex-cloud/go-genproto/yandex/cloud/access"
	dns "github.com/yandex-cloud/go-genproto/yandex/cloud/dns/v1"
	operation "github.com/yandex-cloud/go-genproto/yandex/cloud/operation"
	"github.com/yandex-cloud/go-sdk/v2/pkg/iterator"
	"google.golang.org/grpc"
)

type DnsFirewallClientIterator interface {
	Iterator(context.Context, *dns.ListDnsFirewallsRequest, ...grpc.CallOption) *iterator.Iterator[*dns.ListDnsFirewallsRequest, *dns.DnsFirewall]
	OperationsIterator(context.Context, *dns.ListDnsFirewallOperationsRequest, ...grpc.CallOption) *iterator.Iterator[*dns.ListDnsFirewallOperationsRequest, *operation.Operation]
	AccessBindingsIterator(context.Context, *access.ListAccessBindingsRequest, ...grpc.CallOption) *iterator.Iterator[*access.ListAccessBindingsRequest, *access.AccessBinding]
}

type dnsFirewallServiceListInternal struct {
	*dns.ListDnsFirewallsResponse
}

func (r dnsFirewallServiceListInternal) Items() []*dns.DnsFirewall {
	return r.ListDnsFirewallsResponse.DnsFirewalls
}

func (c dnsFirewallClient) Iterator(ctx context.Context, req *dns.ListDnsFirewallsRequest, opts ...grpc.CallOption) *iterator.Iterator[*dns.ListDnsFirewallsRequest, *dns.DnsFirewall] {
	return iterator.NewIterator[*dns.ListDnsFirewallsRequest, *dns.DnsFirewall](ctx, req,
		func(ctx context.Context, req *dns.ListDnsFirewallsRequest, opts ...grpc.CallOption) (iterator.PageResponse[*dns.DnsFirewall], error) {
			resp, err := c.List(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return dnsFirewallServiceListInternal{resp}, nil
		})
}

type dnsFirewallServiceListOperationsInternal struct {
	*dns.ListDnsFirewallOperationsResponse
}

func (r dnsFirewallServiceListOperationsInternal) Items() []*operation.Operation {
	return r.ListDnsFirewallOperationsResponse.Operations
}

func (c dnsFirewallClient) OperationsIterator(ctx context.Context, req *dns.ListDnsFirewallOperationsRequest, opts ...grpc.CallOption) *iterator.Iterator[*dns.ListDnsFirewallOperationsRequest, *operation.Operation] {
	return iterator.NewIterator[*dns.ListDnsFirewallOperationsRequest, *operation.Operation](ctx, req,
		func(ctx context.Context, req *dns.ListDnsFirewallOperationsRequest, opts ...grpc.CallOption) (iterator.PageResponse[*operation.Operation], error) {
			resp, err := c.ListOperations(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return dnsFirewallServiceListOperationsInternal{resp}, nil
		})
}

type dnsFirewallServiceListAccessBindingsInternal struct {
	*access.ListAccessBindingsResponse
}

func (r dnsFirewallServiceListAccessBindingsInternal) Items() []*access.AccessBinding {
	return r.ListAccessBindingsResponse.AccessBindings
}

func (c dnsFirewallClient) AccessBindingsIterator(ctx context.Context, req *access.ListAccessBindingsRequest, opts ...grpc.CallOption) *iterator.Iterator[*access.ListAccessBindingsRequest, *access.AccessBinding] {
	return iterator.NewIterator[*access.ListAccessBindingsRequest, *access.AccessBinding](ctx, req,
		func(ctx context.Context, req *access.ListAccessBindingsRequest, opts ...grpc.CallOption) (iterator.PageResponse[*access.AccessBinding], error) {
			resp, err := c.ListAccessBindings(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return dnsFirewallServiceListAccessBindingsInternal{resp}, nil
		})
}
