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

import (
	"context"

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

type SymmetricKeyClientIterator interface {
	Iterator(context.Context, *kms.ListSymmetricKeysRequest, ...grpc.CallOption) *iterator.Iterator[*kms.ListSymmetricKeysRequest, *kms.SymmetricKey]
	VersionsIterator(context.Context, *kms.ListSymmetricKeyVersionsRequest, ...grpc.CallOption) *iterator.Iterator[*kms.ListSymmetricKeyVersionsRequest, *kms.SymmetricKeyVersion]
	OperationsIterator(context.Context, *kms.ListSymmetricKeyOperationsRequest, ...grpc.CallOption) *iterator.Iterator[*kms.ListSymmetricKeyOperationsRequest, *operation.Operation]
	AccessBindingsIterator(context.Context, *access.ListAccessBindingsRequest, ...grpc.CallOption) *iterator.Iterator[*access.ListAccessBindingsRequest, *access.AccessBinding]
}

type symmetricKeyServiceListInternal struct {
	*kms.ListSymmetricKeysResponse
}

func (r symmetricKeyServiceListInternal) Items() []*kms.SymmetricKey {
	return r.ListSymmetricKeysResponse.Keys
}

func (c symmetricKeyClient) Iterator(ctx context.Context, req *kms.ListSymmetricKeysRequest, opts ...grpc.CallOption) *iterator.Iterator[*kms.ListSymmetricKeysRequest, *kms.SymmetricKey] {
	return iterator.NewIterator[*kms.ListSymmetricKeysRequest, *kms.SymmetricKey](ctx, req,
		func(ctx context.Context, req *kms.ListSymmetricKeysRequest, opts ...grpc.CallOption) (iterator.PageResponse[*kms.SymmetricKey], error) {
			resp, err := c.List(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return symmetricKeyServiceListInternal{resp}, nil
		})
}

type symmetricKeyServiceListVersionsInternal struct {
	*kms.ListSymmetricKeyVersionsResponse
}

func (r symmetricKeyServiceListVersionsInternal) Items() []*kms.SymmetricKeyVersion {
	return r.ListSymmetricKeyVersionsResponse.KeyVersions
}

func (c symmetricKeyClient) VersionsIterator(ctx context.Context, req *kms.ListSymmetricKeyVersionsRequest, opts ...grpc.CallOption) *iterator.Iterator[*kms.ListSymmetricKeyVersionsRequest, *kms.SymmetricKeyVersion] {
	return iterator.NewIterator[*kms.ListSymmetricKeyVersionsRequest, *kms.SymmetricKeyVersion](ctx, req,
		func(ctx context.Context, req *kms.ListSymmetricKeyVersionsRequest, opts ...grpc.CallOption) (iterator.PageResponse[*kms.SymmetricKeyVersion], error) {
			resp, err := c.ListVersions(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return symmetricKeyServiceListVersionsInternal{resp}, nil
		})
}

type symmetricKeyServiceListOperationsInternal struct {
	*kms.ListSymmetricKeyOperationsResponse
}

func (r symmetricKeyServiceListOperationsInternal) Items() []*operation.Operation {
	return r.ListSymmetricKeyOperationsResponse.Operations
}

func (c symmetricKeyClient) OperationsIterator(ctx context.Context, req *kms.ListSymmetricKeyOperationsRequest, opts ...grpc.CallOption) *iterator.Iterator[*kms.ListSymmetricKeyOperationsRequest, *operation.Operation] {
	return iterator.NewIterator[*kms.ListSymmetricKeyOperationsRequest, *operation.Operation](ctx, req,
		func(ctx context.Context, req *kms.ListSymmetricKeyOperationsRequest, opts ...grpc.CallOption) (iterator.PageResponse[*operation.Operation], error) {
			resp, err := c.ListOperations(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return symmetricKeyServiceListOperationsInternal{resp}, nil
		})
}

type symmetricKeyServiceListAccessBindingsInternal struct {
	*access.ListAccessBindingsResponse
}

func (r symmetricKeyServiceListAccessBindingsInternal) Items() []*access.AccessBinding {
	return r.ListAccessBindingsResponse.AccessBindings
}

func (c symmetricKeyClient) AccessBindingsIterator(ctx context.Context, req *access.ListAccessBindingsRequest, opts ...grpc.CallOption) *iterator.Iterator[*access.ListAccessBindingsRequest, *access.AccessBinding] {
	return iterator.NewIterator[*access.ListAccessBindingsRequest, *access.AccessBinding](ctx, req,
		func(ctx context.Context, req *access.ListAccessBindingsRequest, opts ...grpc.CallOption) (iterator.PageResponse[*access.AccessBinding], error) {
			resp, err := c.ListAccessBindings(ctx, req, opts...)
			if err != nil {
				return nil, err
			}
			return symmetricKeyServiceListAccessBindingsInternal{resp}, nil
		})
}
