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

package fake

import (
	"context"

	v1alpha1 "github.com/openshift/hive/apis/hiveinternal/v1alpha1"
	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"
)

// FakeClusterSyncs implements ClusterSyncInterface
type FakeClusterSyncs struct {
	Fake *FakeHiveinternalV1alpha1
	ns   string
}

var clustersyncsResource = schema.GroupVersionResource{Group: "hiveinternal.openshift.io", Version: "v1alpha1", Resource: "clustersyncs"}

var clustersyncsKind = schema.GroupVersionKind{Group: "hiveinternal.openshift.io", Version: "v1alpha1", Kind: "ClusterSync"}

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

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

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

	if obj == nil {
		return nil, err
	}

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

}

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

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

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

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.ClusterSync), 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 *FakeClusterSyncs) UpdateStatus(ctx context.Context, clusterSync *v1alpha1.ClusterSync, opts v1.UpdateOptions) (*v1alpha1.ClusterSync, error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateSubresourceAction(clustersyncsResource, "status", c.ns, clusterSync), &v1alpha1.ClusterSync{})

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

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

	return err
}

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

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

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

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