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

package fake

import (
	"context"

	meteringv1 "github.com/kube-reporting/metering-operator/pkg/apis/metering/v1"
	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"
)

// FakeHiveTables implements HiveTableInterface
type FakeHiveTables struct {
	Fake *FakeMeteringV1
	ns   string
}

var hivetablesResource = schema.GroupVersionResource{Group: "metering.openshift.io", Version: "v1", Resource: "hivetables"}

var hivetablesKind = schema.GroupVersionKind{Group: "metering.openshift.io", Version: "v1", Kind: "HiveTable"}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*meteringv1.HiveTable), err
}

// List takes label and field selectors, and returns the list of HiveTables that match those selectors.
func (c *FakeHiveTables) List(ctx context.Context, opts v1.ListOptions) (result *meteringv1.HiveTableList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(hivetablesResource, hivetablesKind, c.ns, opts), &meteringv1.HiveTableList{})

	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &meteringv1.HiveTableList{ListMeta: obj.(*meteringv1.HiveTableList).ListMeta}
	for _, item := range obj.(*meteringv1.HiveTableList).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 hiveTables.
func (c *FakeHiveTables) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return c.Fake.
		InvokesWatch(testing.NewWatchAction(hivetablesResource, c.ns, opts))

}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*meteringv1.HiveTable), err
}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*meteringv1.HiveTable), 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 *FakeHiveTables) UpdateStatus(ctx context.Context, hiveTable *meteringv1.HiveTable, opts v1.UpdateOptions) (*meteringv1.HiveTable, error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateSubresourceAction(hivetablesResource, "status", c.ns, hiveTable), &meteringv1.HiveTable{})

	if obj == nil {
		return nil, err
	}
	return obj.(*meteringv1.HiveTable), err
}

// Delete takes name of the hiveTable and deletes it. Returns an error if one occurs.
func (c *FakeHiveTables) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	_, err := c.Fake.
		Invokes(testing.NewDeleteAction(hivetablesResource, c.ns, name), &meteringv1.HiveTable{})

	return err
}

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

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

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

	if obj == nil {
		return nil, err
	}
	return obj.(*meteringv1.HiveTable), err
}
