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

package fake

import (
	"context"

	ptpv1 "github.com/openshift/ptp-operator/pkg/apis/ptp/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"
)

// FakePtpConfigs implements PtpConfigInterface
type FakePtpConfigs struct {
	Fake *FakePtpV1
	ns   string
}

var ptpconfigsResource = schema.GroupVersionResource{Group: "ptp.openshift.io", Version: "v1", Resource: "ptpconfigs"}

var ptpconfigsKind = schema.GroupVersionKind{Group: "ptp.openshift.io", Version: "v1", Kind: "PtpConfig"}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*ptpv1.PtpConfig), err
}

// List takes label and field selectors, and returns the list of PtpConfigs that match those selectors.
func (c *FakePtpConfigs) List(ctx context.Context, opts v1.ListOptions) (result *ptpv1.PtpConfigList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(ptpconfigsResource, ptpconfigsKind, c.ns, opts), &ptpv1.PtpConfigList{})

	if obj == nil {
		return nil, err
	}

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

}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*ptpv1.PtpConfig), err
}

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

	if obj == nil {
		return nil, err
	}
	return obj.(*ptpv1.PtpConfig), 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 *FakePtpConfigs) UpdateStatus(ctx context.Context, ptpConfig *ptpv1.PtpConfig, opts v1.UpdateOptions) (*ptpv1.PtpConfig, error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateSubresourceAction(ptpconfigsResource, "status", c.ns, ptpConfig), &ptpv1.PtpConfig{})

	if obj == nil {
		return nil, err
	}
	return obj.(*ptpv1.PtpConfig), err
}

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

	return err
}

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

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

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

	if obj == nil {
		return nil, err
	}
	return obj.(*ptpv1.PtpConfig), err
}
