Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / github.com / coreos / prometheus-operator / pkg / client / versioned / typed / monitoring / v1 / prometheusrule.go
1 // Copyright 2018 The prometheus-operator Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Code generated by client-gen. DO NOT EDIT.
16
17 package v1
18
19 import (
20         "time"
21
22         v1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
23         scheme "github.com/coreos/prometheus-operator/pkg/client/versioned/scheme"
24         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25         types "k8s.io/apimachinery/pkg/types"
26         watch "k8s.io/apimachinery/pkg/watch"
27         rest "k8s.io/client-go/rest"
28 )
29
30 // PrometheusRulesGetter has a method to return a PrometheusRuleInterface.
31 // A group's client should implement this interface.
32 type PrometheusRulesGetter interface {
33         PrometheusRules(namespace string) PrometheusRuleInterface
34 }
35
36 // PrometheusRuleInterface has methods to work with PrometheusRule resources.
37 type PrometheusRuleInterface interface {
38         Create(*v1.PrometheusRule) (*v1.PrometheusRule, error)
39         Update(*v1.PrometheusRule) (*v1.PrometheusRule, error)
40         Delete(name string, options *metav1.DeleteOptions) error
41         DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
42         Get(name string, options metav1.GetOptions) (*v1.PrometheusRule, error)
43         List(opts metav1.ListOptions) (*v1.PrometheusRuleList, error)
44         Watch(opts metav1.ListOptions) (watch.Interface, error)
45         Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.PrometheusRule, err error)
46         PrometheusRuleExpansion
47 }
48
49 // prometheusRules implements PrometheusRuleInterface
50 type prometheusRules struct {
51         client rest.Interface
52         ns     string
53 }
54
55 // newPrometheusRules returns a PrometheusRules
56 func newPrometheusRules(c *MonitoringV1Client, namespace string) *prometheusRules {
57         return &prometheusRules{
58                 client: c.RESTClient(),
59                 ns:     namespace,
60         }
61 }
62
63 // Get takes name of the prometheusRule, and returns the corresponding prometheusRule object, and an error if there is any.
64 func (c *prometheusRules) Get(name string, options metav1.GetOptions) (result *v1.PrometheusRule, err error) {
65         result = &v1.PrometheusRule{}
66         err = c.client.Get().
67                 Namespace(c.ns).
68                 Resource("prometheusrules").
69                 Name(name).
70                 VersionedParams(&options, scheme.ParameterCodec).
71                 Do().
72                 Into(result)
73         return
74 }
75
76 // List takes label and field selectors, and returns the list of PrometheusRules that match those selectors.
77 func (c *prometheusRules) List(opts metav1.ListOptions) (result *v1.PrometheusRuleList, err error) {
78         var timeout time.Duration
79         if opts.TimeoutSeconds != nil {
80                 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
81         }
82         result = &v1.PrometheusRuleList{}
83         err = c.client.Get().
84                 Namespace(c.ns).
85                 Resource("prometheusrules").
86                 VersionedParams(&opts, scheme.ParameterCodec).
87                 Timeout(timeout).
88                 Do().
89                 Into(result)
90         return
91 }
92
93 // Watch returns a watch.Interface that watches the requested prometheusRules.
94 func (c *prometheusRules) Watch(opts metav1.ListOptions) (watch.Interface, error) {
95         var timeout time.Duration
96         if opts.TimeoutSeconds != nil {
97                 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
98         }
99         opts.Watch = true
100         return c.client.Get().
101                 Namespace(c.ns).
102                 Resource("prometheusrules").
103                 VersionedParams(&opts, scheme.ParameterCodec).
104                 Timeout(timeout).
105                 Watch()
106 }
107
108 // Create takes the representation of a prometheusRule and creates it.  Returns the server's representation of the prometheusRule, and an error, if there is any.
109 func (c *prometheusRules) Create(prometheusRule *v1.PrometheusRule) (result *v1.PrometheusRule, err error) {
110         result = &v1.PrometheusRule{}
111         err = c.client.Post().
112                 Namespace(c.ns).
113                 Resource("prometheusrules").
114                 Body(prometheusRule).
115                 Do().
116                 Into(result)
117         return
118 }
119
120 // Update takes the representation of a prometheusRule and updates it. Returns the server's representation of the prometheusRule, and an error, if there is any.
121 func (c *prometheusRules) Update(prometheusRule *v1.PrometheusRule) (result *v1.PrometheusRule, err error) {
122         result = &v1.PrometheusRule{}
123         err = c.client.Put().
124                 Namespace(c.ns).
125                 Resource("prometheusrules").
126                 Name(prometheusRule.Name).
127                 Body(prometheusRule).
128                 Do().
129                 Into(result)
130         return
131 }
132
133 // Delete takes name of the prometheusRule and deletes it. Returns an error if one occurs.
134 func (c *prometheusRules) Delete(name string, options *metav1.DeleteOptions) error {
135         return c.client.Delete().
136                 Namespace(c.ns).
137                 Resource("prometheusrules").
138                 Name(name).
139                 Body(options).
140                 Do().
141                 Error()
142 }
143
144 // DeleteCollection deletes a collection of objects.
145 func (c *prometheusRules) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
146         var timeout time.Duration
147         if listOptions.TimeoutSeconds != nil {
148                 timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
149         }
150         return c.client.Delete().
151                 Namespace(c.ns).
152                 Resource("prometheusrules").
153                 VersionedParams(&listOptions, scheme.ParameterCodec).
154                 Timeout(timeout).
155                 Body(options).
156                 Do().
157                 Error()
158 }
159
160 // Patch applies the patch and returns the patched prometheusRule.
161 func (c *prometheusRules) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.PrometheusRule, err error) {
162         result = &v1.PrometheusRule{}
163         err = c.client.Patch(pt).
164                 Namespace(c.ns).
165                 Resource("prometheusrules").
166                 SubResource(subresources...).
167                 Name(name).
168                 Body(data).
169                 Do().
170                 Into(result)
171         return
172 }