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

// ServiceCIDRInformer provides access to a shared informer and lister for
// ServiceCIDRs. Prefer using the type-safe variant (see [TypedServiceCIDRInformer]).
type ServiceCIDRInformer interface {
	Informer() cache.SharedIndexInformer
	Lister() networkingv1beta1.ServiceCIDRLister
}

// TypedServiceCIDRInformer provides access to a shared informer and lister for
// ServiceCIDRs, including the type-safe TypedInformer variant.
// It is a superset of ServiceCIDRInformer.
type TypedServiceCIDRInformer interface {
	Informer() cache.SharedIndexInformer
	TypedInformer() ServiceCIDRIndexInformer
	Lister() networkingv1beta1.ServiceCIDRLister
}

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

// ServiceCIDRHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerFuncs] for ServiceCIDR.
type ServiceCIDRHandlerFuncs = cache.TypedResourceEventHandlerFuncs[*apinetworkingv1beta1.ServiceCIDR]

// ServiceCIDRDetailedHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerDetailedFuncs] for ServiceCIDR.
type ServiceCIDRDetailedHandlerFuncs = cache.TypedResourceEventHandlerDetailedFuncs[*apinetworkingv1beta1.ServiceCIDR]

// ServiceCIDRFilteringHandler is a specialization of [cache.TypedFilteringResourceEventHandler] for ServiceCIDR.
type ServiceCIDRFilteringHandler = cache.TypedFilteringResourceEventHandler[*apinetworkingv1beta1.ServiceCIDR]

// ServiceCIDRIndexers is a specialization of [cache.TypedIndexers] for ServiceCIDR.
type ServiceCIDRIndexers = cache.TypedIndexers[*apinetworkingv1beta1.ServiceCIDR]

// DeletedServiceCIDR is a specialization of [cache.DeletedObject] for ServiceCIDR.
type DeletedServiceCIDR = cache.DeletedObject[*apinetworkingv1beta1.ServiceCIDR]

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

// NewServiceCIDRInformer constructs a new informer for ServiceCIDR 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 [NewTypedServiceCIDRInformer]).
func NewServiceCIDRInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
	return NewServiceCIDRInformerWithOptions(client, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers})
}

// NewTypedServiceCIDRInformer constructs a new informer for ServiceCIDR 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 NewTypedServiceCIDRInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers ServiceCIDRIndexers) ServiceCIDRIndexInformer {
	return NewTypedServiceCIDRInformerWithOptions(client, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers)})
}

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

// NewTypedFilteredServiceCIDRInformer constructs a new informer for ServiceCIDR 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 NewTypedFilteredServiceCIDRInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers ServiceCIDRIndexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) ServiceCIDRIndexInformer {
	return NewTypedServiceCIDRInformerWithOptions(client, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers), TweakListOptions: tweakListOptions})
}

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

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

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

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

func (f *serviceCIDRInformer) TypedInformer() ServiceCIDRIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apinetworkingv1beta1.ServiceCIDR](f.factory.InformerFor(&apinetworkingv1beta1.ServiceCIDR{}, f.defaultInformer))
}

func (f *serviceCIDRInformer) Lister() networkingv1beta1.ServiceCIDRLister {
	return networkingv1beta1.NewServiceCIDRLister(f.Informer().GetIndexer())
}

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

type serviceCIDRTypedInformerAdapter struct {
	ServiceCIDRInformer
}

func (a *serviceCIDRTypedInformerAdapter) TypedInformer() ServiceCIDRIndexInformer {
	return cache.NewTypedSharedIndexInformer[*apinetworkingv1beta1.ServiceCIDR](a.Informer())
}

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