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

package fake

import (
	"context"

	securityinternalv1 "github.com/openshift/api/securityinternal/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"
)

// FakeRangeAllocations implements RangeAllocationInterface
type FakeRangeAllocations struct {
	Fake *FakeSecurityV1
}

var rangeallocationsResource = schema.GroupVersionResource{Group: "security.internal.openshift.io", Version: "v1", Resource: "rangeallocations"}

var rangeallocationsKind = schema.GroupVersionKind{Group: "security.internal.openshift.io", Version: "v1", Kind: "RangeAllocation"}

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

// List takes label and field selectors, and returns the list of RangeAllocations that match those selectors.
func (c *FakeRangeAllocations) List(ctx context.Context, opts v1.ListOptions) (result *securityinternalv1.RangeAllocationList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootListAction(rangeallocationsResource, rangeallocationsKind, opts), &securityinternalv1.RangeAllocationList{})
	if obj == nil {
		return nil, err
	}

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

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

// Update takes the representation of a rangeAllocation and updates it. Returns the server's representation of the rangeAllocation, and an error, if there is any.
func (c *FakeRangeAllocations) Update(ctx context.Context, rangeAllocation *securityinternalv1.RangeAllocation, opts v1.UpdateOptions) (result *securityinternalv1.RangeAllocation, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootUpdateAction(rangeallocationsResource, rangeAllocation), &securityinternalv1.RangeAllocation{})
	if obj == nil {
		return nil, err
	}
	return obj.(*securityinternalv1.RangeAllocation), err
}

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

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

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

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