// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-2019 Datadog, Inc.

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

package fake

import (
	v1alpha1 "github.com/datadog/extendeddaemonset/pkg/apis/datadoghq/v1alpha1"
	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"
)

// FakeExtendedDaemonSets implements ExtendedDaemonSetInterface
type FakeExtendedDaemonSets struct {
	Fake *FakeDatadoghqV1alpha1
	ns   string
}

var extendeddaemonsetsResource = schema.GroupVersionResource{Group: "datadoghq.com", Version: "v1alpha1", Resource: "extendeddaemonsets"}

var extendeddaemonsetsKind = schema.GroupVersionKind{Group: "datadoghq.com", Version: "v1alpha1", Kind: "ExtendedDaemonSet"}

// Get takes name of the extendedDaemonSet, and returns the corresponding extendedDaemonSet object, and an error if there is any.
func (c *FakeExtendedDaemonSets) Get(name string, options v1.GetOptions) (result *v1alpha1.ExtendedDaemonSet, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewGetAction(extendeddaemonsetsResource, c.ns, name), &v1alpha1.ExtendedDaemonSet{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.ExtendedDaemonSet), err
}

// List takes label and field selectors, and returns the list of ExtendedDaemonSets that match those selectors.
func (c *FakeExtendedDaemonSets) List(opts v1.ListOptions) (result *v1alpha1.ExtendedDaemonSetList, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewListAction(extendeddaemonsetsResource, extendeddaemonsetsKind, c.ns, opts), &v1alpha1.ExtendedDaemonSetList{})

	if obj == nil {
		return nil, err
	}

	label, _, _ := testing.ExtractFromListOptions(opts)
	if label == nil {
		label = labels.Everything()
	}
	list := &v1alpha1.ExtendedDaemonSetList{ListMeta: obj.(*v1alpha1.ExtendedDaemonSetList).ListMeta}
	for _, item := range obj.(*v1alpha1.ExtendedDaemonSetList).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 extendedDaemonSets.
func (c *FakeExtendedDaemonSets) Watch(opts v1.ListOptions) (watch.Interface, error) {
	return c.Fake.
		InvokesWatch(testing.NewWatchAction(extendeddaemonsetsResource, c.ns, opts))

}

// Create takes the representation of a extendedDaemonSet and creates it.  Returns the server's representation of the extendedDaemonSet, and an error, if there is any.
func (c *FakeExtendedDaemonSets) Create(extendedDaemonSet *v1alpha1.ExtendedDaemonSet) (result *v1alpha1.ExtendedDaemonSet, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewCreateAction(extendeddaemonsetsResource, c.ns, extendedDaemonSet), &v1alpha1.ExtendedDaemonSet{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.ExtendedDaemonSet), err
}

// Update takes the representation of a extendedDaemonSet and updates it. Returns the server's representation of the extendedDaemonSet, and an error, if there is any.
func (c *FakeExtendedDaemonSets) Update(extendedDaemonSet *v1alpha1.ExtendedDaemonSet) (result *v1alpha1.ExtendedDaemonSet, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateAction(extendeddaemonsetsResource, c.ns, extendedDaemonSet), &v1alpha1.ExtendedDaemonSet{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.ExtendedDaemonSet), 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 *FakeExtendedDaemonSets) UpdateStatus(extendedDaemonSet *v1alpha1.ExtendedDaemonSet) (*v1alpha1.ExtendedDaemonSet, error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateSubresourceAction(extendeddaemonsetsResource, "status", c.ns, extendedDaemonSet), &v1alpha1.ExtendedDaemonSet{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.ExtendedDaemonSet), err
}

// Delete takes name of the extendedDaemonSet and deletes it. Returns an error if one occurs.
func (c *FakeExtendedDaemonSets) Delete(name string, options *v1.DeleteOptions) error {
	_, err := c.Fake.
		Invokes(testing.NewDeleteAction(extendeddaemonsetsResource, c.ns, name), &v1alpha1.ExtendedDaemonSet{})

	return err
}

// DeleteCollection deletes a collection of objects.
func (c *FakeExtendedDaemonSets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
	action := testing.NewDeleteCollectionAction(extendeddaemonsetsResource, c.ns, listOptions)

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

// Patch applies the patch and returns the patched extendedDaemonSet.
func (c *FakeExtendedDaemonSets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ExtendedDaemonSet, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewPatchSubresourceAction(extendeddaemonsetsResource, c.ns, name, pt, data, subresources...), &v1alpha1.ExtendedDaemonSet{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.ExtendedDaemonSet), err
}
