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

package v1

import (
	v1 "github.com/kube-reporting/metering-operator/pkg/apis/metering/v1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// MeteringConfigLister helps list MeteringConfigs.
type MeteringConfigLister interface {
	// List lists all MeteringConfigs in the indexer.
	List(selector labels.Selector) (ret []*v1.MeteringConfig, err error)
	// MeteringConfigs returns an object that can list and get MeteringConfigs.
	MeteringConfigs(namespace string) MeteringConfigNamespaceLister
	MeteringConfigListerExpansion
}

// meteringConfigLister implements the MeteringConfigLister interface.
type meteringConfigLister struct {
	indexer cache.Indexer
}

// NewMeteringConfigLister returns a new MeteringConfigLister.
func NewMeteringConfigLister(indexer cache.Indexer) MeteringConfigLister {
	return &meteringConfigLister{indexer: indexer}
}

// List lists all MeteringConfigs in the indexer.
func (s *meteringConfigLister) List(selector labels.Selector) (ret []*v1.MeteringConfig, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1.MeteringConfig))
	})
	return ret, err
}

// MeteringConfigs returns an object that can list and get MeteringConfigs.
func (s *meteringConfigLister) MeteringConfigs(namespace string) MeteringConfigNamespaceLister {
	return meteringConfigNamespaceLister{indexer: s.indexer, namespace: namespace}
}

// MeteringConfigNamespaceLister helps list and get MeteringConfigs.
type MeteringConfigNamespaceLister interface {
	// List lists all MeteringConfigs in the indexer for a given namespace.
	List(selector labels.Selector) (ret []*v1.MeteringConfig, err error)
	// Get retrieves the MeteringConfig from the indexer for a given namespace and name.
	Get(name string) (*v1.MeteringConfig, error)
	MeteringConfigNamespaceListerExpansion
}

// meteringConfigNamespaceLister implements the MeteringConfigNamespaceLister
// interface.
type meteringConfigNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

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

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