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

import (
	"context"

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

type ServiceControlClientIterator interface {
	Iterator(context.Context, *iam.ListServicesRequest, ...grpc.CallOption) *iterator.Iterator[*iam.ListServicesRequest, *iam.Service]
}

type serviceControlServiceListInternal struct {
	*iam.ListServicesResponse
}

func (r serviceControlServiceListInternal) Items() []*iam.Service {
	return r.ListServicesResponse.Services
}

func (c serviceControlClient) Iterator(ctx context.Context, req *iam.ListServicesRequest, opts ...grpc.CallOption) *iterator.Iterator[*iam.ListServicesRequest, *iam.Service] {
	return iterator.NewIterator[*iam.ListServicesRequest, *iam.Service](ctx, req,
		func(ctx context.Context, req *iam.ListServicesRequest, opts ...grpc.CallOption) (iterator.PageResponse[*iam.Service], error) {
			resp, err := c.List(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return serviceControlServiceListInternal{resp}, nil
		})
}
