// Copyright 2020 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

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

package v1alpha1

import (
	v1alpha1 "go.pinniped.dev/generated/1.19/apis/concierge/authentication/v1alpha1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// WebhookAuthenticatorLister helps list WebhookAuthenticators.
// All objects returned here must be treated as read-only.
type WebhookAuthenticatorLister interface {
	// List lists all WebhookAuthenticators in the indexer.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1alpha1.WebhookAuthenticator, err error)
	// WebhookAuthenticators returns an object that can list and get WebhookAuthenticators.
	WebhookAuthenticators(namespace string) WebhookAuthenticatorNamespaceLister
	WebhookAuthenticatorListerExpansion
}

// webhookAuthenticatorLister implements the WebhookAuthenticatorLister interface.
type webhookAuthenticatorLister struct {
	indexer cache.Indexer
}

// NewWebhookAuthenticatorLister returns a new WebhookAuthenticatorLister.
func NewWebhookAuthenticatorLister(indexer cache.Indexer) WebhookAuthenticatorLister {
	return &webhookAuthenticatorLister{indexer: indexer}
}

// List lists all WebhookAuthenticators in the indexer.
func (s *webhookAuthenticatorLister) List(selector labels.Selector) (ret []*v1alpha1.WebhookAuthenticator, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1alpha1.WebhookAuthenticator))
	})
	return ret, err
}

// WebhookAuthenticators returns an object that can list and get WebhookAuthenticators.
func (s *webhookAuthenticatorLister) WebhookAuthenticators(namespace string) WebhookAuthenticatorNamespaceLister {
	return webhookAuthenticatorNamespaceLister{indexer: s.indexer, namespace: namespace}
}

// WebhookAuthenticatorNamespaceLister helps list and get WebhookAuthenticators.
// All objects returned here must be treated as read-only.
type WebhookAuthenticatorNamespaceLister interface {
	// List lists all WebhookAuthenticators in the indexer for a given namespace.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v1alpha1.WebhookAuthenticator, err error)
	// Get retrieves the WebhookAuthenticator from the indexer for a given namespace and name.
	// Objects returned here must be treated as read-only.
	Get(name string) (*v1alpha1.WebhookAuthenticator, error)
	WebhookAuthenticatorNamespaceListerExpansion
}

// webhookAuthenticatorNamespaceLister implements the WebhookAuthenticatorNamespaceLister
// interface.
type webhookAuthenticatorNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

// List lists all WebhookAuthenticators in the indexer for a given namespace.
func (s webhookAuthenticatorNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.WebhookAuthenticator, err error) {
	err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
		ret = append(ret, m.(*v1alpha1.WebhookAuthenticator))
	})
	return ret, err
}

// Get retrieves the WebhookAuthenticator from the indexer for a given namespace and name.
func (s webhookAuthenticatorNamespaceLister) Get(name string) (*v1alpha1.WebhookAuthenticator, error) {
	obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
	if err != nil {
		return nil, err
	}
	if !exists {
		return nil, errors.NewNotFound(v1alpha1.Resource("webhookauthenticator"), name)
	}
	return obj.(*v1alpha1.WebhookAuthenticator), nil
}
