/*
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 v1beta1

import (
	context "context"
	time "time"

	apinetworkingv1beta1 "k8s.io/api/networking/v1beta1"
	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"
	networkingv1beta1 "k8s.io/client-go/listers/networking/v1beta1"
	cache "k8s.io/client-go/tools/cache"
)

// IngressInformer provides access to a shared informer and lister for
// Ingresses. Prefer using the type-safe variant (see [TypedIngressInformer]).
type IngressInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() networkingv1beta1.IngressLister
}

// TypedIngressInformer provides access to a shared informer and lister for
// Ingresses, including the type-safe TypedInformer variant.
// It is a superset of IngressInformer.
type TypedIngressInformer interface {
	Informer() cache.SharedIndexInformer
	TypedInformer() IngressIndexInformer
	Lister() networkingv1beta1.IngressLister
}

// IngressIndexInformer is a wrapper around the underlying [cache.SharedIndexInformer]
// with type-safe variants of several methods.
type IngressIndexInformer cache.TypedSharedIndexInformer[*apinetworkingv1beta1.Ingress]

// IngressHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerFuncs] for Ingress.
type IngressHandlerFuncs = cache.TypedResourceEventHandlerFuncs[*apinetworkingv1beta1.Ingress]

// IngressDetailedHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerDetailedFuncs] for Ingress.
type IngressDetailedHandlerFuncs = cache.TypedResourceEventHandlerDetailedFuncs[*apinetworkingv1beta1.Ingress]

// IngressFilteringHandler is a specialization of [cache.TypedFilteringResourceEventHandler] for Ingress.
type IngressFilteringHandler = cache.TypedFilteringResourceEventHandler[*apinetworkingv1beta1.Ingress]

// IngressIndexers is a specialization of [cache.TypedIndexers] for Ingress.
type IngressIndexers = cache.TypedIndexers[*apinetworkingv1beta1.Ingress]

// DeletedIngress is a specialization of [cache.DeletedObject] for Ingress.
type DeletedIngress = cache.DeletedObject[*apinetworkingv1beta1.Ingress]

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

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

// NewTypedIngressInformer constructs a new informer for Ingress 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 NewTypedIngressInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers IngressIndexers) IngressIndexInformer {
	return NewTypedIngressInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers)})
}

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

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

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

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

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

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

func (f *ingressInformer) TypedInformer() IngressIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apinetworkingv1beta1.Ingress](f.factory.InformerFor(&apinetworkingv1beta1.Ingress{}, f.defaultInformer))
}

func (f *ingressInformer) Lister() networkingv1beta1.IngressLister {
	return networkingv1beta1.NewIngressLister(f.Informer().GetIndexer())
}

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

type ingressTypedInformerAdapter struct {
	IngressInformer
}

func (a *ingressTypedInformerAdapter) TypedInformer() IngressIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apinetworkingv1beta1.Ingress](a.Informer())
}

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