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

import (
	"context"

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

type accessPolicyTemplateServiceListInternal struct {
	*iam.ListAccessPolicyTemplatesResponse
}

func (r accessPolicyTemplateServiceListInternal) Items() []*access.AccessPolicy {
	return r.ListAccessPolicyTemplatesResponse.AccessPolicyTemplates
}

func (c accessPolicyTemplateClient) Iterator(ctx context.Context, req *iam.ListAccessPolicyTemplatesRequest, opts ...grpc.CallOption) *iterator.Iterator[*iam.ListAccessPolicyTemplatesRequest, *access.AccessPolicy] {
	return iterator.NewIterator[*iam.ListAccessPolicyTemplatesRequest, *access.AccessPolicy](ctx, req,
		func(ctx context.Context, req *iam.ListAccessPolicyTemplatesRequest, opts ...grpc.CallOption) (iterator.PageResponse[*access.AccessPolicy], error) {
			resp, err := c.List(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return accessPolicyTemplateServiceListInternal{resp}, nil
		})
}
