// Copyright (c) Microsoft Corporation.
// Licensed under the Apache License 2.0.

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

package fake

import (
	"context"

	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"

	v1alpha1 "github.com/Azure/ARO-RP/pkg/operator/apis/preview.aro.openshift.io/v1alpha1"
)

// FakePreviewFeatures implements PreviewFeatureInterface
type FakePreviewFeatures struct {
	Fake *FakePreviewV1alpha1
}

var previewfeaturesResource = schema.GroupVersionResource{Group: "preview.aro.openshift.io", Version: "v1alpha1", Resource: "previewfeatures"}

var previewfeaturesKind = schema.GroupVersionKind{Group: "preview.aro.openshift.io", Version: "v1alpha1", Kind: "PreviewFeature"}

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

// List takes label and field selectors, and returns the list of PreviewFeatures that match those selectors.
func (c *FakePreviewFeatures) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PreviewFeatureList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootListAction(previewfeaturesResource, previewfeaturesKind, opts), &v1alpha1.PreviewFeatureList{})
	if obj == nil {
		return nil, err
	}

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

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

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

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

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

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

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