// 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.17/apis/supervisor/config/v1alpha1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// OIDCProviderLister helps list OIDCProviders.
type OIDCProviderLister interface {
	// List lists all OIDCProviders in the indexer.
	List(selector labels.Selector) (ret []*v1alpha1.OIDCProvider, err error)
	// OIDCProviders returns an object that can list and get OIDCProviders.
	OIDCProviders(namespace string) OIDCProviderNamespaceLister
	OIDCProviderListerExpansion
}

// oIDCProviderLister implements the OIDCProviderLister interface.
type oIDCProviderLister struct {
	indexer cache.Indexer
}

// NewOIDCProviderLister returns a new OIDCProviderLister.
func NewOIDCProviderLister(indexer cache.Indexer) OIDCProviderLister {
	return &oIDCProviderLister{indexer: indexer}
}

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

// OIDCProviders returns an object that can list and get OIDCProviders.
func (s *oIDCProviderLister) OIDCProviders(namespace string) OIDCProviderNamespaceLister {
	return oIDCProviderNamespaceLister{indexer: s.indexer, namespace: namespace}
}

// OIDCProviderNamespaceLister helps list and get OIDCProviders.
type OIDCProviderNamespaceLister interface {
	// List lists all OIDCProviders in the indexer for a given namespace.
	List(selector labels.Selector) (ret []*v1alpha1.OIDCProvider, err error)
	// Get retrieves the OIDCProvider from the indexer for a given namespace and name.
	Get(name string) (*v1alpha1.OIDCProvider, error)
	OIDCProviderNamespaceListerExpansion
}

// oIDCProviderNamespaceLister implements the OIDCProviderNamespaceLister
// interface.
type oIDCProviderNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

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

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