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

package fake

import (
	"context"

	workv1 "github.com/open-cluster-management/api/work/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"
)

// FakeAppliedManifestWorks implements AppliedManifestWorkInterface
type FakeAppliedManifestWorks struct {
	Fake *FakeWorkV1
}

var appliedmanifestworksResource = schema.GroupVersionResource{Group: "work.open-cluster-management.io", Version: "v1", Resource: "appliedmanifestworks"}

var appliedmanifestworksKind = schema.GroupVersionKind{Group: "work.open-cluster-management.io", Version: "v1", Kind: "AppliedManifestWork"}

// Get takes name of the appliedManifestWork, and returns the corresponding appliedManifestWork object, and an error if there is any.
func (c *FakeAppliedManifestWorks) Get(ctx context.Context, name string, options v1.GetOptions) (result *workv1.AppliedManifestWork, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootGetAction(appliedmanifestworksResource, name), &workv1.AppliedManifestWork{})
	if obj == nil {
		return nil, err
	}
	return obj.(*workv1.AppliedManifestWork), err
}

// List takes label and field selectors, and returns the list of AppliedManifestWorks that match those selectors.
func (c *FakeAppliedManifestWorks) List(ctx context.Context, opts v1.ListOptions) (result *workv1.AppliedManifestWorkList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootListAction(appliedmanifestworksResource, appliedmanifestworksKind, opts), &workv1.AppliedManifestWorkList{})
	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &workv1.AppliedManifestWorkList{ListMeta: obj.(*workv1.AppliedManifestWorkList).ListMeta}
	for _, item := range obj.(*workv1.AppliedManifestWorkList).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 appliedManifestWorks.
func (c *FakeAppliedManifestWorks) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
	return c.Fake.
		InvokesWatch(testing.NewRootWatchAction(appliedmanifestworksResource, opts))
}

// Create takes the representation of a appliedManifestWork and creates it.  Returns the server's representation of the appliedManifestWork, and an error, if there is any.
func (c *FakeAppliedManifestWorks) Create(ctx context.Context, appliedManifestWork *workv1.AppliedManifestWork, opts v1.CreateOptions) (result *workv1.AppliedManifestWork, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootCreateAction(appliedmanifestworksResource, appliedManifestWork), &workv1.AppliedManifestWork{})
	if obj == nil {
		return nil, err
	}
	return obj.(*workv1.AppliedManifestWork), err
}

// Update takes the representation of a appliedManifestWork and updates it. Returns the server's representation of the appliedManifestWork, and an error, if there is any.
func (c *FakeAppliedManifestWorks) Update(ctx context.Context, appliedManifestWork *workv1.AppliedManifestWork, opts v1.UpdateOptions) (result *workv1.AppliedManifestWork, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootUpdateAction(appliedmanifestworksResource, appliedManifestWork), &workv1.AppliedManifestWork{})
	if obj == nil {
		return nil, err
	}
	return obj.(*workv1.AppliedManifestWork), 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 *FakeAppliedManifestWorks) UpdateStatus(ctx context.Context, appliedManifestWork *workv1.AppliedManifestWork, opts v1.UpdateOptions) (*workv1.AppliedManifestWork, error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootUpdateSubresourceAction(appliedmanifestworksResource, "status", appliedManifestWork), &workv1.AppliedManifestWork{})
	if obj == nil {
		return nil, err
	}
	return obj.(*workv1.AppliedManifestWork), err
}

// Delete takes name of the appliedManifestWork and deletes it. Returns an error if one occurs.
func (c *FakeAppliedManifestWorks) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
	_, err := c.Fake.
		Invokes(testing.NewRootDeleteAction(appliedmanifestworksResource, name), &workv1.AppliedManifestWork{})
	return err
}

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

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

// Patch applies the patch and returns the patched appliedManifestWork.
func (c *FakeAppliedManifestWorks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *workv1.AppliedManifestWork, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootPatchSubresourceAction(appliedmanifestworksResource, name, pt, data, subresources...), &workv1.AppliedManifestWork{})
	if obj == nil {
		return nil, err
	}
	return obj.(*workv1.AppliedManifestWork), err
}
