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

import (
	"context"

	iam "github.com/yandex-cloud/go-genproto/yandex/cloud/iam"
	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 SubjectDetailsClientIterator interface {
	Iterator(context.Context, *iam_.ListSubjectsRequest, ...grpc.CallOption) *iterator.Iterator[*iam_.ListSubjectsRequest, *iam.Subject]
}

type subjectDetailsServiceListInternal struct {
	*iam_.ListSubjectsResponse
}

func (r subjectDetailsServiceListInternal) Items() []*iam.Subject {
	return r.ListSubjectsResponse.Subjects
}

func (c subjectDetailsClient) Iterator(ctx context.Context, req *iam_.ListSubjectsRequest, opts ...grpc.CallOption) *iterator.Iterator[*iam_.ListSubjectsRequest, *iam.Subject] {
	return iterator.NewIterator[*iam_.ListSubjectsRequest, *iam.Subject](ctx, req,
		func(ctx context.Context, req *iam_.ListSubjectsRequest, opts ...grpc.CallOption) (iterator.PageResponse[*iam.Subject], error) {
			resp, err := c.List(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return subjectDetailsServiceListInternal{resp}, nil
		})
}
