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

package fake

import (
	"context"

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

// FakeStorageProfiles implements StorageProfileInterface
type FakeStorageProfiles struct {
	Fake *FakeAtomixV3beta3
	ns   string
}

var storageprofilesResource = schema.GroupVersionResource{Group: "atomix.io", Version: "v3beta3", Resource: "storageprofiles"}

var storageprofilesKind = schema.GroupVersionKind{Group: "atomix.io", Version: "v3beta3", Kind: "StorageProfile"}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*v3beta3.StorageProfile), err
}

// List takes label and field selectors, and returns the list of StorageProfiles that match those selectors.
func (c *FakeStorageProfiles) List(ctx context.Context, opts v1.ListOptions) (result *v3beta3.StorageProfileList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(storageprofilesResource, storageprofilesKind, c.ns, opts), &v3beta3.StorageProfileList{})

	if obj == nil {
		return nil, err
	}

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

}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*v3beta3.StorageProfile), err
}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*v3beta3.StorageProfile), 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 *FakeStorageProfiles) UpdateStatus(ctx context.Context, storageProfile *v3beta3.StorageProfile, opts v1.UpdateOptions) (*v3beta3.StorageProfile, error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateSubresourceAction(storageprofilesResource, "status", c.ns, storageProfile), &v3beta3.StorageProfile{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v3beta3.StorageProfile), err
}

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

	return err
}

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

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

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

	if obj == nil {
		return nil, err
	}
	return obj.(*v3beta3.StorageProfile), err
}
