/*
Copyright The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

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

package v1alpha1

import (
	context "context"
	time "time"

	apilifecyclev1alpha1 "k8s.io/api/lifecycle/v1alpha1"
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	runtime "k8s.io/apimachinery/pkg/runtime"
	schema "k8s.io/apimachinery/pkg/runtime/schema"
	watch "k8s.io/apimachinery/pkg/watch"
	internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
	kubernetes "k8s.io/client-go/kubernetes"
	lifecyclev1alpha1 "k8s.io/client-go/listers/lifecycle/v1alpha1"
	cache "k8s.io/client-go/tools/cache"
)

// EvictionInformer provides access to a shared informer and lister for
// Evictions. Prefer using the type-safe variant (see [TypedEvictionInformer]).
type EvictionInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() lifecyclev1alpha1.EvictionLister
}

// TypedEvictionInformer provides access to a shared informer and lister for
// Evictions, including the type-safe TypedInformer variant.
// It is a superset of EvictionInformer.
type TypedEvictionInformer interface {
	Informer() cache.SharedIndexInformer
	TypedInformer() EvictionIndexInformer
	Lister() lifecyclev1alpha1.EvictionLister
}

// EvictionIndexInformer is a wrapper around the underlying [cache.SharedIndexInformer]
// with type-safe variants of several methods.
type EvictionIndexInformer cache.TypedSharedIndexInformer[*apilifecyclev1alpha1.Eviction]

// EvictionHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerFuncs] for Eviction.
type EvictionHandlerFuncs = cache.TypedResourceEventHandlerFuncs[*apilifecyclev1alpha1.Eviction]

// EvictionDetailedHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerDetailedFuncs] for Eviction.
type EvictionDetailedHandlerFuncs = cache.TypedResourceEventHandlerDetailedFuncs[*apilifecyclev1alpha1.Eviction]

// EvictionFilteringHandler is a specialization of [cache.TypedFilteringResourceEventHandler] for Eviction.
type EvictionFilteringHandler = cache.TypedFilteringResourceEventHandler[*apilifecyclev1alpha1.Eviction]

// EvictionIndexers is a specialization of [cache.TypedIndexers] for Eviction.
type EvictionIndexers = cache.TypedIndexers[*apilifecyclev1alpha1.Eviction]

// DeletedEviction is a specialization of [cache.DeletedObject] for Eviction.
type DeletedEviction = cache.DeletedObject[*apilifecyclev1alpha1.Eviction]

type evictionInformer struct {
	factory          internalinterfaces.SharedInformerFactory
	tweakListOptions internalinterfaces.TweakListOptionsFunc
	namespace        string
}

// NewEvictionInformer constructs a new informer for Eviction 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.
// If you really need an independent one, prefer using the type-safe variant (see [NewTypedEvictionInformer]).
func NewEvictionInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
	return NewEvictionInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers})
}

// NewTypedEvictionInformer constructs a new informer for Eviction 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 NewTypedEvictionInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers EvictionIndexers) EvictionIndexInformer {
	return NewTypedEvictionInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers)})
}

// NewFilteredEvictionInformer constructs a new informer for Eviction 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.
// If you really need an independent one, prefer using the type-safe variant (see [NewTypedFilteredEvictionInformer]).
func NewFilteredEvictionInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
	return NewTypedEvictionInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers, TweakListOptions: tweakListOptions})
}

// NewTypedFilteredEvictionInformer constructs a new informer for Eviction 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 NewTypedFilteredEvictionInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers EvictionIndexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) EvictionIndexInformer {
	return NewTypedEvictionInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers), TweakListOptions: tweakListOptions})
}

// NewEvictionInformerWithOptions constructs a new informer for Eviction type with additional options.
// 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.
// If you really need an independent one, prefer using the type-safe variant (see [NewTypedEvictionInformerWithOptions]).
func NewEvictionInformerWithOptions(client kubernetes.Interface, namespace string, options internalinterfaces.InformerOptions) cache.SharedIndexInformer {
	return NewTypedEvictionInformerWithOptions(client, namespace, options)
}

// NewTypedEvictionInformerWithOptions constructs a new informer for Eviction type with additional options.
// 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 NewTypedEvictionInformerWithOptions(client kubernetes.Interface, namespace string, options internalinterfaces.InformerOptions) EvictionIndexInformer {
	gvr := schema.GroupVersionResource{Group: "lifecycle.k8s.io", Version: "v1alpha1", Resource: "evictions"}
	identifier := options.InformerName.WithResource(gvr)
	tweakListOptions := options.TweakListOptions
	return cache.NewTypedSharedIndexInformer[*apilifecyclev1alpha1.Eviction](cache.NewSharedIndexInformerWithOptions(
		cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{
			ListFunc: func(opts v1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.LifecycleV1alpha1().Evictions(namespace).List(context.Background(), opts)
			},
			WatchFunc: func(opts v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.LifecycleV1alpha1().Evictions(namespace).Watch(context.Background(), opts)
			},
			ListWithContextFunc: func(ctx context.Context, opts v1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.LifecycleV1alpha1().Evictions(namespace).List(ctx, opts)
			},
			WatchFuncWithContext: func(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.LifecycleV1alpha1().Evictions(namespace).Watch(ctx, opts)
			},
		}, client),
		&apilifecyclev1alpha1.Eviction{},
		cache.SharedIndexInformerOptions{
			ResyncPeriod: options.ResyncPeriod,
			Indexers:     options.Indexers,
			Identifier:   identifier,
		},
	))
}

func (f *evictionInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
	return NewTypedEvictionInformerWithOptions(client, f.namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, InformerName: f.factory.InformerName(), TweakListOptions: f.tweakListOptions})
}

func (f *evictionInformer) Informer() cache.SharedIndexInformer {
	return f.TypedInformer()
}

func (f *evictionInformer) TypedInformer() EvictionIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apilifecyclev1alpha1.Eviction](f.factory.InformerFor(&apilifecyclev1alpha1.Eviction{}, f.defaultInformer))
}

func (f *evictionInformer) Lister() lifecyclev1alpha1.EvictionLister {
	return lifecyclev1alpha1.NewEvictionLister(f.Informer().GetIndexer())
}

// ToTypedEvictionInformer converts an untyped informer into a TypedEvictionInformer.
//
// WARNING: this conversion is only safe if the informer handles objects of type
// *Eviction. If that is not the case, calling type-safe methods of the returned
// TypedEvictionInformer leads to runtime panics. A safer alternative is to pass
// around a TypedEvictionInformer instances that was obtained from a
// SharedInformerFactory.
func ToTypedEvictionInformer(informer EvictionInformer) TypedEvictionInformer {
	if informer, ok := informer.(TypedEvictionInformer); ok {
		return informer
	}
	return &evictionTypedInformerAdapter{informer}
}

type evictionTypedInformerAdapter struct {
	EvictionInformer
}

func (a *evictionTypedInformerAdapter) TypedInformer() EvictionIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apilifecyclev1alpha1.Eviction](a.Informer())
}

// ToEvictionIndexInformer converts an untyped informer into a EvictionIndexInformer.
//
// WARNING: this conversion is only safe if the informer handles objects of type
// *Eviction. If that is not the case, calling type-safe methods of the returned
// EvictionIndexInformer leads to runtime panics. A safer alternative is to pass
// around a EvictionIndexInformer instances that was obtained from a
// SharedInformerFactory.
func ToEvictionIndexInformer(informer cache.SharedIndexInformer) EvictionIndexInformer {
	if informer, ok := informer.(EvictionIndexInformer); ok {
		return informer
	}
	return cache.NewTypedSharedIndexInformer[*apilifecyclev1alpha1.Eviction](informer)
}
