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

package fake

import (
	v1alpha2 "istio.io/client-go/pkg/apis/config/v1alpha2"
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	labels "k8s.io/apimachinery/pkg/labels"
	schema "k8s.io/apimachinery/pkg/runtime/schema"
	types "k8s.io/apimachinery/pkg/types"
	watch "k8s.io/apimachinery/pkg/watch"
	testing "k8s.io/client-go/testing"
)

// FakeHandlers implements HandlerInterface
type FakeHandlers struct {
	Fake *FakeConfigV1alpha2
	ns   string
}

var handlersResource = schema.GroupVersionResource{Group: "config", Version: "v1alpha2", Resource: "handlers"}

var handlersKind = schema.GroupVersionKind{Group: "config", Version: "v1alpha2", Kind: "Handler"}

// Get takes name of the handler, and returns the corresponding handler object, and an error if there is any.
func (c *FakeHandlers) Get(name string, options v1.GetOptions) (result *v1alpha2.Handler, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewGetAction(handlersResource, c.ns, name), &v1alpha2.Handler{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha2.Handler), err
}

// List takes label and field selectors, and returns the list of Handlers that match those selectors.
func (c *FakeHandlers) List(opts v1.ListOptions) (result *v1alpha2.HandlerList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(handlersResource, handlersKind, c.ns, opts), &v1alpha2.HandlerList{})

	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &v1alpha2.HandlerList{ListMeta: obj.(*v1alpha2.HandlerList).ListMeta}
	for _, item := range obj.(*v1alpha2.HandlerList).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 handlers.
func (c *FakeHandlers) Watch(opts v1.ListOptions) (watch.Interface, error) {
	return c.Fake.
		InvokesWatch(testing.NewWatchAction(handlersResource, c.ns, opts))

}

// Create takes the representation of a handler and creates it.  Returns the server's representation of the handler, and an error, if there is any.
func (c *FakeHandlers) Create(handler *v1alpha2.Handler) (result *v1alpha2.Handler, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewCreateAction(handlersResource, c.ns, handler), &v1alpha2.Handler{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha2.Handler), err
}

// Update takes the representation of a handler and updates it. Returns the server's representation of the handler, and an error, if there is any.
func (c *FakeHandlers) Update(handler *v1alpha2.Handler) (result *v1alpha2.Handler, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateAction(handlersResource, c.ns, handler), &v1alpha2.Handler{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha2.Handler), err
}

// Delete takes name of the handler and deletes it. Returns an error if one occurs.
func (c *FakeHandlers) Delete(name string, options *v1.DeleteOptions) error {
	_, err := c.Fake.
		Invokes(testing.NewDeleteAction(handlersResource, c.ns, name), &v1alpha2.Handler{})

	return err
}

// DeleteCollection deletes a collection of objects.
func (c *FakeHandlers) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
	action := testing.NewDeleteCollectionAction(handlersResource, c.ns, listOptions)

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

// Patch applies the patch and returns the patched handler.
func (c *FakeHandlers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.Handler, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewPatchSubresourceAction(handlersResource, c.ns, name, pt, data, subresources...), &v1alpha2.Handler{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha2.Handler), err
}
