/*
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"
)

// EvictionRequestInformer provides access to a shared informer and lister for
// EvictionRequests. Prefer using the type-safe variant (see [TypedEvictionRequestInformer]).
type EvictionRequestInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() lifecyclev1alpha1.EvictionRequestLister
}

// TypedEvictionRequestInformer provides access to a shared informer and lister for
// EvictionRequests, including the type-safe TypedInformer variant.
// It is a superset of EvictionRequestInformer.
type TypedEvictionRequestInformer interface {
	Informer() cache.SharedIndexInformer
	TypedInformer() EvictionRequestIndexInformer
	Lister() lifecyclev1alpha1.EvictionRequestLister
}

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

// EvictionRequestHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerFuncs] for EvictionRequest.
type EvictionRequestHandlerFuncs = cache.TypedResourceEventHandlerFuncs[*apilifecyclev1alpha1.EvictionRequest]

// EvictionRequestDetailedHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerDetailedFuncs] for EvictionRequest.
type EvictionRequestDetailedHandlerFuncs = cache.TypedResourceEventHandlerDetailedFuncs[*apilifecyclev1alpha1.EvictionRequest]

// EvictionRequestFilteringHandler is a specialization of [cache.TypedFilteringResourceEventHandler] for EvictionRequest.
type EvictionRequestFilteringHandler = cache.TypedFilteringResourceEventHandler[*apilifecyclev1alpha1.EvictionRequest]

// EvictionRequestIndexers is a specialization of [cache.TypedIndexers] for EvictionRequest.
type EvictionRequestIndexers = cache.TypedIndexers[*apilifecyclev1alpha1.EvictionRequest]

// DeletedEvictionRequest is a specialization of [cache.DeletedObject] for EvictionRequest.
type DeletedEvictionRequest = cache.DeletedObject[*apilifecyclev1alpha1.EvictionRequest]

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

// NewEvictionRequestInformer constructs a new informer for EvictionRequest 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 [NewTypedEvictionRequestInformer]).
func NewEvictionRequestInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
	return NewEvictionRequestInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers})
}

// NewTypedEvictionRequestInformer constructs a new informer for EvictionRequest 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 NewTypedEvictionRequestInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers EvictionRequestIndexers) EvictionRequestIndexInformer {
	return NewTypedEvictionRequestInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers)})
}

// NewFilteredEvictionRequestInformer constructs a new informer for EvictionRequest 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 [NewTypedFilteredEvictionRequestInformer]).
func NewFilteredEvictionRequestInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
	return NewTypedEvictionRequestInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers, TweakListOptions: tweakListOptions})
}

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

// NewEvictionRequestInformerWithOptions constructs a new informer for EvictionRequest 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 [NewTypedEvictionRequestInformerWithOptions]).
func NewEvictionRequestInformerWithOptions(client kubernetes.Interface, namespace string, options internalinterfaces.InformerOptions) cache.SharedIndexInformer {
	return NewTypedEvictionRequestInformerWithOptions(client, namespace, options)
}

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

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

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

func (f *evictionRequestInformer) TypedInformer() EvictionRequestIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apilifecyclev1alpha1.EvictionRequest](f.factory.InformerFor(&apilifecyclev1alpha1.EvictionRequest{}, f.defaultInformer))
}

func (f *evictionRequestInformer) Lister() lifecyclev1alpha1.EvictionRequestLister {
	return lifecyclev1alpha1.NewEvictionRequestLister(f.Informer().GetIndexer())
}

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

type evictionRequestTypedInformerAdapter struct {
	EvictionRequestInformer
}

func (a *evictionRequestTypedInformerAdapter) TypedInformer() EvictionRequestIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apilifecyclev1alpha1.EvictionRequest](a.Informer())
}

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