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 v1beta1
20
21import (
22	"context"
23	"time"
24
25	v1beta1 "k8s.io/api/storage/v1beta1"
26	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27	types "k8s.io/apimachinery/pkg/types"
28	watch "k8s.io/apimachinery/pkg/watch"
29	scheme "k8s.io/client-go/deprecated/scheme"
30	rest "k8s.io/client-go/rest"
31)
32
33// CSIDriversGetter has a method to return a CSIDriverInterface.
34// A group's client should implement this interface.
35type CSIDriversGetter interface {
36	CSIDrivers() CSIDriverInterface
37}
38
39// CSIDriverInterface has methods to work with CSIDriver resources.
40type CSIDriverInterface interface {
41	Create(*v1beta1.CSIDriver) (*v1beta1.CSIDriver, error)
42	Update(*v1beta1.CSIDriver) (*v1beta1.CSIDriver, error)
43	Delete(name string, options *v1.DeleteOptions) error
44	DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
45	Get(name string, options v1.GetOptions) (*v1beta1.CSIDriver, error)
46	List(opts v1.ListOptions) (*v1beta1.CSIDriverList, error)
47	Watch(opts v1.ListOptions) (watch.Interface, error)
48	Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.CSIDriver, err error)
49	CSIDriverExpansion
50}
51
52// cSIDrivers implements CSIDriverInterface
53type cSIDrivers struct {
54	client rest.Interface
55}
56
57// newCSIDrivers returns a CSIDrivers
58func newCSIDrivers(c *StorageV1beta1Client) *cSIDrivers {
59	return &cSIDrivers{
60		client: c.RESTClient(),
61	}
62}
63
64// Get takes name of the cSIDriver, and returns the corresponding cSIDriver object, and an error if there is any.
65func (c *cSIDrivers) Get(name string, options v1.GetOptions) (result *v1beta1.CSIDriver, err error) {
66	result = &v1beta1.CSIDriver{}
67	err = c.client.Get().
68		Resource("csidrivers").
69		Name(name).
70		VersionedParams(&options, scheme.ParameterCodec).
71		Do(context.TODO()).
72		Into(result)
73	return
74}
75
76// List takes label and field selectors, and returns the list of CSIDrivers that match those selectors.
77func (c *cSIDrivers) List(opts v1.ListOptions) (result *v1beta1.CSIDriverList, err error) {
78	var timeout time.Duration
79	if opts.TimeoutSeconds != nil {
80		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
81	}
82	result = &v1beta1.CSIDriverList{}
83	err = c.client.Get().
84		Resource("csidrivers").
85		VersionedParams(&opts, scheme.ParameterCodec).
86		Timeout(timeout).
87		Do(context.TODO()).
88		Into(result)
89	return
90}
91
92// Watch returns a watch.Interface that watches the requested cSIDrivers.
93func (c *cSIDrivers) Watch(opts v1.ListOptions) (watch.Interface, error) {
94	var timeout time.Duration
95	if opts.TimeoutSeconds != nil {
96		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
97	}
98	opts.Watch = true
99	return c.client.Get().
100		Resource("csidrivers").
101		VersionedParams(&opts, scheme.ParameterCodec).
102		Timeout(timeout).
103		Watch(context.TODO())
104}
105
106// Create takes the representation of a cSIDriver and creates it.  Returns the server's representation of the cSIDriver, and an error, if there is any.
107func (c *cSIDrivers) Create(cSIDriver *v1beta1.CSIDriver) (result *v1beta1.CSIDriver, err error) {
108	result = &v1beta1.CSIDriver{}
109	err = c.client.Post().
110		Resource("csidrivers").
111		Body(cSIDriver).
112		Do(context.TODO()).
113		Into(result)
114	return
115}
116
117// Update takes the representation of a cSIDriver and updates it. Returns the server's representation of the cSIDriver, and an error, if there is any.
118func (c *cSIDrivers) Update(cSIDriver *v1beta1.CSIDriver) (result *v1beta1.CSIDriver, err error) {
119	result = &v1beta1.CSIDriver{}
120	err = c.client.Put().
121		Resource("csidrivers").
122		Name(cSIDriver.Name).
123		Body(cSIDriver).
124		Do(context.TODO()).
125		Into(result)
126	return
127}
128
129// Delete takes name of the cSIDriver and deletes it. Returns an error if one occurs.
130func (c *cSIDrivers) Delete(name string, options *v1.DeleteOptions) error {
131	return c.client.Delete().
132		Resource("csidrivers").
133		Name(name).
134		Body(options).
135		Do(context.TODO()).
136		Error()
137}
138
139// DeleteCollection deletes a collection of objects.
140func (c *cSIDrivers) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
141	var timeout time.Duration
142	if listOptions.TimeoutSeconds != nil {
143		timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
144	}
145	return c.client.Delete().
146		Resource("csidrivers").
147		VersionedParams(&listOptions, scheme.ParameterCodec).
148		Timeout(timeout).
149		Body(options).
150		Do(context.TODO()).
151		Error()
152}
153
154// Patch applies the patch and returns the patched cSIDriver.
155func (c *cSIDrivers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.CSIDriver, err error) {
156	result = &v1beta1.CSIDriver{}
157	err = c.client.Patch(pt).
158		Resource("csidrivers").
159		SubResource(subresources...).
160		Name(name).
161		Body(data).
162		Do(context.TODO()).
163		Into(result)
164	return
165}
166