// 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 DnsZoneClientIterator interface {
	Iterator(context.Context, *dns.ListDnsZonesRequest, ...grpc.CallOption) *iterator.Iterator[*dns.ListDnsZonesRequest, *dns.DnsZone]
	RecordSetsIterator(context.Context, *dns.ListDnsZoneRecordSetsRequest, ...grpc.CallOption) *iterator.Iterator[*dns.ListDnsZoneRecordSetsRequest, *dns.RecordSet]
	OperationsIterator(context.Context, *dns.ListDnsZoneOperationsRequest, ...grpc.CallOption) *iterator.Iterator[*dns.ListDnsZoneOperationsRequest, *operation.Operation]
	AccessBindingsIterator(context.Context, *access.ListAccessBindingsRequest, ...grpc.CallOption) *iterator.Iterator[*access.ListAccessBindingsRequest, *access.AccessBinding]
}

type dnsZoneServiceListInternal struct {
	*dns.ListDnsZonesResponse
}

func (r dnsZoneServiceListInternal) Items() []*dns.DnsZone { return r.ListDnsZonesResponse.DnsZones }

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

type dnsZoneServiceListRecordSetsInternal struct {
	*dns.ListDnsZoneRecordSetsResponse
}

func (r dnsZoneServiceListRecordSetsInternal) Items() []*dns.RecordSet {
	return r.ListDnsZoneRecordSetsResponse.RecordSets
}

func (c dnsZoneClient) RecordSetsIterator(ctx context.Context, req *dns.ListDnsZoneRecordSetsRequest, opts ...grpc.CallOption) *iterator.Iterator[*dns.ListDnsZoneRecordSetsRequest, *dns.RecordSet] {
	return iterator.NewIterator[*dns.ListDnsZoneRecordSetsRequest, *dns.RecordSet](ctx, req,
		func(ctx context.Context, req *dns.ListDnsZoneRecordSetsRequest, opts ...grpc.CallOption) (iterator.PageResponse[*dns.RecordSet], error) {
			resp, err := c.ListRecordSets(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return dnsZoneServiceListRecordSetsInternal{resp}, nil
		})
}

type dnsZoneServiceListOperationsInternal struct {
	*dns.ListDnsZoneOperationsResponse
}

func (r dnsZoneServiceListOperationsInternal) Items() []*operation.Operation {
	return r.ListDnsZoneOperationsResponse.Operations
}

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

type dnsZoneServiceListAccessBindingsInternal struct {
	*access.ListAccessBindingsResponse
}

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

func (c dnsZoneClient) 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 dnsZoneServiceListAccessBindingsInternal{resp}, nil
		})
}
