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

	apiextensionsv1beta1 "k8s.io/api/extensions/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"
	extensionsv1beta1 "k8s.io/client-go/listers/extensions/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() extensionsv1beta1.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() extensionsv1beta1.IngressLister
}

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

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

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

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

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

// DeletedIngress is a specialization of [cache.DeletedObject] for Ingress.
type DeletedIngress = cache.DeletedObject[*apiextensionsv1beta1.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: "extensions", Version: "v1beta1", Resource: "ingresss"}
	identifier := options.InformerName.WithResource(gvr)
	tweakListOptions := options.TweakListOptions
	return cache.NewTypedSharedIndexInformer[*apiextensionsv1beta1.Ingress](cache.NewSharedIndexInformerWithOptions(
		cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{
			ListFunc: func(opts v1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.ExtensionsV1beta1().Ingresses(namespace).List(context.Background(), opts)
			},
			WatchFunc: func(opts v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.ExtensionsV1beta1().Ingresses(namespace).Watch(context.Background(), opts)
			},
			ListWithContextFunc: func(ctx context.Context, opts v1.ListOptions) (runtime.Object, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.ExtensionsV1beta1().Ingresses(namespace).List(ctx, opts)
			},
			WatchFuncWithContext: func(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
				if tweakListOptions != nil {
					tweakListOptions(&opts)
				}
				return client.ExtensionsV1beta1().Ingresses(namespace).Watch(ctx, opts)
			},
		}, client),
		&apiextensionsv1beta1.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[*apiextensionsv1beta1.Ingress](f.factory.InformerFor(&apiextensionsv1beta1.Ingress{}, f.defaultInformer))
}

func (f *ingressInformer) Lister() extensionsv1beta1.IngressLister {
	return extensionsv1beta1.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[*apiextensionsv1beta1.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[*apiextensionsv1beta1.Ingress](informer)
}
