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

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

// tokenCredentialRequestLister implements the TokenCredentialRequestLister interface.
type tokenCredentialRequestLister struct {
	indexer cache.Indexer
}

// NewTokenCredentialRequestLister returns a new TokenCredentialRequestLister.
func NewTokenCredentialRequestLister(indexer cache.Indexer) TokenCredentialRequestLister {
	return &tokenCredentialRequestLister{indexer: indexer}
}

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

// TokenCredentialRequests returns an object that can list and get TokenCredentialRequests.
func (s *tokenCredentialRequestLister) TokenCredentialRequests(namespace string) TokenCredentialRequestNamespaceLister {
	return tokenCredentialRequestNamespaceLister{indexer: s.indexer, namespace: namespace}
}

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

// tokenCredentialRequestNamespaceLister implements the TokenCredentialRequestNamespaceLister
// interface.
type tokenCredentialRequestNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

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

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