// SPDX-FileCopyrightText: 2022-present Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
// Code generated by client-gen. DO NOT EDIT.

package fake

import (
	"context"

	v3beta4 "github.com/atomix/atomix/controller/pkg/apis/atomix/v3beta4"
	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"
)

// FakeDataStores implements DataStoreInterface
type FakeDataStores struct {
	Fake *FakeAtomixV3beta4
	ns   string
}

var datastoresResource = schema.GroupVersionResource{Group: "atomix.io", Version: "v3beta4", Resource: "datastores"}

var datastoresKind = schema.GroupVersionKind{Group: "atomix.io", Version: "v3beta4", Kind: "DataStore"}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*v3beta4.DataStore), err
}

// List takes label and field selectors, and returns the list of DataStores that match those selectors.
func (c *FakeDataStores) List(ctx context.Context, opts v1.ListOptions) (result *v3beta4.DataStoreList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(datastoresResource, datastoresKind, c.ns, opts), &v3beta4.DataStoreList{})

	if obj == nil {
		return nil, err
	}

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

}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*v3beta4.DataStore), err
}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*v3beta4.DataStore), err
}

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

	return err
}

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

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

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

	if obj == nil {
		return nil, err
	}
	return obj.(*v3beta4.DataStore), err
}
