// SPDX-License-Identifier: AGPL-3.0-only

// Code generated by informer-gen. DO NOT EDIT.

package v0alpha1

import (
	context "context"
	time "time"

	apisaggregationv0alpha1 "github.com/grafana/grafana/pkg/aggregator/apis/aggregation/v0alpha1"
	versioned "github.com/grafana/grafana/pkg/aggregator/generated/clientset/versioned"
	internalinterfaces "github.com/grafana/grafana/pkg/aggregator/generated/informers/externalversions/internalinterfaces"
	aggregationv0alpha1 "github.com/grafana/grafana/pkg/aggregator/generated/listers/aggregation/v0alpha1"
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	runtime "k8s.io/apimachinery/pkg/runtime"
	watch "k8s.io/apimachinery/pkg/watch"
	cache "k8s.io/client-go/tools/cache"
)

// DataPlaneServiceInformer provides access to a shared informer and lister for
// DataPlaneServices.
type DataPlaneServiceInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() aggregationv0alpha1.DataPlaneServiceLister
}

type dataPlaneServiceInformer struct {
	factory          internalinterfaces.SharedInformerFactory
	tweakListOptions internalinterfaces.TweakListOptionsFunc
}

// NewDataPlaneServiceInformer constructs a new informer for DataPlaneService type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewDataPlaneServiceInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
	return NewFilteredDataPlaneServiceInformer(client, resyncPeriod, indexers, nil)
}

// NewFilteredDataPlaneServiceInformer constructs a new informer for DataPlaneService type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredDataPlaneServiceInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
	return cache.NewSharedIndexInformer(
		cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{
			ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.AggregationV0alpha1().DataPlaneServices().List(context.Background(), options)
			},
			WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.AggregationV0alpha1().DataPlaneServices().Watch(context.Background(), options)
			},
			ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.AggregationV0alpha1().DataPlaneServices().List(ctx, options)
			},
			WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&options)
				}
				return client.AggregationV0alpha1().DataPlaneServices().Watch(ctx, options)
			},
		}, client),
		&apisaggregationv0alpha1.DataPlaneService{},
		resyncPeriod,
		indexers,
	)
}

func (f *dataPlaneServiceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
	return NewFilteredDataPlaneServiceInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}

func (f *dataPlaneServiceInformer) Informer() cache.SharedIndexInformer {
	return f.factory.InformerFor(&apisaggregationv0alpha1.DataPlaneService{}, f.defaultInformer)
}

func (f *dataPlaneServiceInformer) Lister() aggregationv0alpha1.DataPlaneServiceLister {
	return aggregationv0alpha1.NewDataPlaneServiceLister(f.Informer().GetIndexer())
}
