1/*
2Copyright The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17// Code generated by client-gen. DO NOT EDIT.
18
19package fake
20
21import (
22	"context"
23
24	crv1 "k8s.io/apiextensions-apiserver/examples/client-go/pkg/apis/cr/v1"
25	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26	labels "k8s.io/apimachinery/pkg/labels"
27	schema "k8s.io/apimachinery/pkg/runtime/schema"
28	types "k8s.io/apimachinery/pkg/types"
29	watch "k8s.io/apimachinery/pkg/watch"
30	testing "k8s.io/client-go/testing"
31)
32
33// FakeExamples implements ExampleInterface
34type FakeExamples struct {
35	Fake *FakeCrV1
36	ns   string
37}
38
39var examplesResource = schema.GroupVersionResource{Group: "cr.example.apiextensions.k8s.io", Version: "v1", Resource: "examples"}
40
41var examplesKind = schema.GroupVersionKind{Group: "cr.example.apiextensions.k8s.io", Version: "v1", Kind: "Example"}
42
43// Get takes name of the example, and returns the corresponding example object, and an error if there is any.
44func (c *FakeExamples) Get(ctx context.Context, name string, options v1.GetOptions) (result *crv1.Example, err error) {
45	obj, err := c.Fake.
46		Invokes(testing.NewGetAction(examplesResource, c.ns, name), &crv1.Example{})
47
48	if obj == nil {
49		return nil, err
50	}
51	return obj.(*crv1.Example), err
52}
53
54// List takes label and field selectors, and returns the list of Examples that match those selectors.
55func (c *FakeExamples) List(ctx context.Context, opts v1.ListOptions) (result *crv1.ExampleList, err error) {
56	obj, err := c.Fake.
57		Invokes(testing.NewListAction(examplesResource, examplesKind, c.ns, opts), &crv1.ExampleList{})
58
59	if obj == nil {
60		return nil, err
61	}
62
63	label, _, _ := testing.ExtractFromListOptions(opts)
64	if label == nil {
65		label = labels.Everything()
66	}
67	list := &crv1.ExampleList{ListMeta: obj.(*crv1.ExampleList).ListMeta}
68	for _, item := range obj.(*crv1.ExampleList).Items {
69		if label.Matches(labels.Set(item.Labels)) {
70			list.Items = append(list.Items, item)
71		}
72	}
73	return list, err
74}
75
76// Watch returns a watch.Interface that watches the requested examples.
77func (c *FakeExamples) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
78	return c.Fake.
79		InvokesWatch(testing.NewWatchAction(examplesResource, c.ns, opts))
80
81}
82
83// Create takes the representation of a example and creates it.  Returns the server's representation of the example, and an error, if there is any.
84func (c *FakeExamples) Create(ctx context.Context, example *crv1.Example, opts v1.CreateOptions) (result *crv1.Example, err error) {
85	obj, err := c.Fake.
86		Invokes(testing.NewCreateAction(examplesResource, c.ns, example), &crv1.Example{})
87
88	if obj == nil {
89		return nil, err
90	}
91	return obj.(*crv1.Example), err
92}
93
94// Update takes the representation of a example and updates it. Returns the server's representation of the example, and an error, if there is any.
95func (c *FakeExamples) Update(ctx context.Context, example *crv1.Example, opts v1.UpdateOptions) (result *crv1.Example, err error) {
96	obj, err := c.Fake.
97		Invokes(testing.NewUpdateAction(examplesResource, c.ns, example), &crv1.Example{})
98
99	if obj == nil {
100		return nil, err
101	}
102	return obj.(*crv1.Example), err
103}
104
105// Delete takes name of the example and deletes it. Returns an error if one occurs.
106func (c *FakeExamples) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
107	_, err := c.Fake.
108		Invokes(testing.NewDeleteAction(examplesResource, c.ns, name), &crv1.Example{})
109
110	return err
111}
112
113// DeleteCollection deletes a collection of objects.
114func (c *FakeExamples) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
115	action := testing.NewDeleteCollectionAction(examplesResource, c.ns, listOpts)
116
117	_, err := c.Fake.Invokes(action, &crv1.ExampleList{})
118	return err
119}
120
121// Patch applies the patch and returns the patched example.
122func (c *FakeExamples) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *crv1.Example, err error) {
123	obj, err := c.Fake.
124		Invokes(testing.NewPatchSubresourceAction(examplesResource, c.ns, name, pt, data, subresources...), &crv1.Example{})
125
126	if obj == nil {
127		return nil, err
128	}
129	return obj.(*crv1.Example), err
130}
131