/*
Copyright sandbox0.ai
All rights reserved.
*/

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

package v1alpha1

import (
	v1alpha1 "github.com/sandbox0-ai/sandbox0/manager/pkg/apis/sandbox0/v1alpha1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

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

// sandboxTemplateLister implements the SandboxTemplateLister interface.
type sandboxTemplateLister struct {
	indexer cache.Indexer
}

// NewSandboxTemplateLister returns a new SandboxTemplateLister.
func NewSandboxTemplateLister(indexer cache.Indexer) SandboxTemplateLister {
	return &sandboxTemplateLister{indexer: indexer}
}

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

// SandboxTemplates returns an object that can list and get SandboxTemplates.
func (s *sandboxTemplateLister) SandboxTemplates(namespace string) SandboxTemplateNamespaceLister {
	return sandboxTemplateNamespaceLister{indexer: s.indexer, namespace: namespace}
}

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

// sandboxTemplateNamespaceLister implements the SandboxTemplateNamespaceLister
// interface.
type sandboxTemplateNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

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

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