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

import (
	"context"

	endpoint "github.com/yandex-cloud/go-genproto/yandex/cloud/endpoint"
	"github.com/yandex-cloud/go-sdk/v2/pkg/iterator"
	"google.golang.org/grpc"
)

type ApiEndpointClientIterator interface {
	Iterator(context.Context, *endpoint.ListApiEndpointsRequest, ...grpc.CallOption) *iterator.Iterator[*endpoint.ListApiEndpointsRequest, *endpoint.ApiEndpoint]
}

type apiEndpointServiceListInternal struct {
	*endpoint.ListApiEndpointsResponse
}

func (r apiEndpointServiceListInternal) Items() []*endpoint.ApiEndpoint {
	return r.ListApiEndpointsResponse.Endpoints
}

func (c apiEndpointClient) Iterator(ctx context.Context, req *endpoint.ListApiEndpointsRequest, opts ...grpc.CallOption) *iterator.Iterator[*endpoint.ListApiEndpointsRequest, *endpoint.ApiEndpoint] {
	return iterator.NewIterator[*endpoint.ListApiEndpointsRequest, *endpoint.ApiEndpoint](ctx, req,
		func(ctx context.Context, req *endpoint.ListApiEndpointsRequest, opts ...grpc.CallOption) (iterator.PageResponse[*endpoint.ApiEndpoint], error) {
			resp, err := c.List(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return apiEndpointServiceListInternal{resp}, nil
		})
}
