// 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 RoleClientIterator interface {
	Iterator(context.Context, *iam.ListRolesRequest, ...grpc.CallOption) *iterator.Iterator[*iam.ListRolesRequest, *iam.Role]
}

type roleServiceListInternal struct {
	*iam.ListRolesResponse
}

func (r roleServiceListInternal) Items() []*iam.Role { return r.ListRolesResponse.Roles }

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