// 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"
)

// FakeQuotaSpecs implements QuotaSpecInterface
type FakeQuotaSpecs struct {
	Fake *FakeConfigV1alpha2
	ns   string
}

var quotaspecsResource = schema.GroupVersionResource{Group: "config", Version: "v1alpha2", Resource: "quotaspecs"}

var quotaspecsKind = schema.GroupVersionKind{Group: "config", Version: "v1alpha2", Kind: "QuotaSpec"}

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

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

// List takes label and field selectors, and returns the list of QuotaSpecs that match those selectors.
func (c *FakeQuotaSpecs) List(opts v1.ListOptions) (result *v1alpha2.QuotaSpecList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(quotaspecsResource, quotaspecsKind, c.ns, opts), &v1alpha2.QuotaSpecList{})

	if obj == nil {
		return nil, err
	}

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

}

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

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

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

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

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

	return err
}

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

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

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

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