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

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

package fake

import (
	"context"

	v1alpha1 "github.com/sandbox0-ai/sandbox0/manager/pkg/apis/sandbox0/v1alpha1"
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	labels "k8s.io/apimachinery/pkg/labels"
	types "k8s.io/apimachinery/pkg/types"
	watch "k8s.io/apimachinery/pkg/watch"
	testing "k8s.io/client-go/testing"
)

// FakeSandboxTemplates implements SandboxTemplateInterface
type FakeSandboxTemplates struct {
	Fake *FakeSandbox0V1alpha1
	ns   string
}

var sandboxtemplatesResource = v1alpha1.SchemeGroupVersion.WithResource("sandboxtemplates")

var sandboxtemplatesKind = v1alpha1.SchemeGroupVersion.WithKind("SandboxTemplate")

// Get takes name of the sandboxTemplate, and returns the corresponding sandboxTemplate object, and an error if there is any.
func (c *FakeSandboxTemplates) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SandboxTemplate, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewGetAction(sandboxtemplatesResource, c.ns, name), &v1alpha1.SandboxTemplate{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.SandboxTemplate), err
}

// List takes label and field selectors, and returns the list of SandboxTemplates that match those selectors.
func (c *FakeSandboxTemplates) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SandboxTemplateList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(sandboxtemplatesResource, sandboxtemplatesKind, c.ns, opts), &v1alpha1.SandboxTemplateList{})

	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &v1alpha1.SandboxTemplateList{ListMeta: obj.(*v1alpha1.SandboxTemplateList).ListMeta}
	for _, item := range obj.(*v1alpha1.SandboxTemplateList).Items {
		if label.Matches(labels.Set(item.Labels)) {
			list.Items = append(list.Items, item)
		}
	}
	return list, err
}

// Watch returns a watch.Interface that watches the requested sandboxTemplates.
func (c *FakeSandboxTemplates) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return c.Fake.
		InvokesWatch(testing.NewWatchAction(sandboxtemplatesResource, c.ns, opts))

}

// Create takes the representation of a sandboxTemplate and creates it.  Returns the server's representation of the sandboxTemplate, and an error, if there is any.
func (c *FakeSandboxTemplates) Create(ctx context.Context, sandboxTemplate *v1alpha1.SandboxTemplate, opts v1.CreateOptions) (result *v1alpha1.SandboxTemplate, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewCreateAction(sandboxtemplatesResource, c.ns, sandboxTemplate), &v1alpha1.SandboxTemplate{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.SandboxTemplate), err
}

// Update takes the representation of a sandboxTemplate and updates it. Returns the server's representation of the sandboxTemplate, and an error, if there is any.
func (c *FakeSandboxTemplates) Update(ctx context.Context, sandboxTemplate *v1alpha1.SandboxTemplate, opts v1.UpdateOptions) (result *v1alpha1.SandboxTemplate, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateAction(sandboxtemplatesResource, c.ns, sandboxTemplate), &v1alpha1.SandboxTemplate{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.SandboxTemplate), err
}

// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeSandboxTemplates) UpdateStatus(ctx context.Context, sandboxTemplate *v1alpha1.SandboxTemplate, opts v1.UpdateOptions) (*v1alpha1.SandboxTemplate, error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateSubresourceAction(sandboxtemplatesResource, "status", c.ns, sandboxTemplate), &v1alpha1.SandboxTemplate{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.SandboxTemplate), err
}

// Delete takes name of the sandboxTemplate and deletes it. Returns an error if one occurs.
func (c *FakeSandboxTemplates) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	_, err := c.Fake.
		Invokes(testing.NewDeleteActionWithOptions(sandboxtemplatesResource, c.ns, name, opts), &v1alpha1.SandboxTemplate{})

	return err
}

// DeleteCollection deletes a collection of objects.
func (c *FakeSandboxTemplates) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
	action := testing.NewDeleteCollectionAction(sandboxtemplatesResource, c.ns, listOpts)

	_, err := c.Fake.Invokes(action, &v1alpha1.SandboxTemplateList{})
	return err
}

// Patch applies the patch and returns the patched sandboxTemplate.
func (c *FakeSandboxTemplates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SandboxTemplate, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewPatchSubresourceAction(sandboxtemplatesResource, c.ns, name, pt, data, subresources...), &v1alpha1.SandboxTemplate{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.SandboxTemplate), err
}
