Debian Codegraph @

envoy/service/metrics/v2/metrics_service.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/service/metrics/v2/metrics_service.proto
4
5 package metricsv2
6
7 import (
8 "bytes"
9 "errors"
10 "fmt"
11 "net"
12 "net/mail"
13 "net/url"
14 "regexp"
15 "sort"
16 "strings"
17 "time"
18 "unicode/utf8"
19
20 "google.golang.org/protobuf/types/known/anypb"
21 )
22
23 // ensure the imports are used
24 var (
25 _ = bytes.MinRead
26 _ = errors.New("")
27 _ = fmt.Print
28 _ = utf8.UTFMax
29 _ = (*regexp.Regexp)(nil)
30 _ = (*strings.Reader)(nil)
31 _ = net.IPv4len
32 _ = time.Duration(0)
33 _ = (*url.URL)(nil)
34 _ = (*mail.Address)(nil)
35 _ = anypb.Any{}
36 _ = sort.Sort
37 )
38
39 // Validate checks the field values on StreamMetricsResponse with the rules
40 // defined in the proto definition for this message. If any rules are
41 // violated, the first error encountered is returned, or nil if there are no violations.
42 func (m *StreamMetricsResponse) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on StreamMetricsResponse with the rules
47 // defined in the proto definition for this message. If any rules are
48 // violated, the result is a list of violation errors wrapped in
49 // StreamMetricsResponseMultiError, or nil if none found.
50 func (m *StreamMetricsResponse) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *StreamMetricsResponse) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if len(errors) > 0 {
62 return StreamMetricsResponseMultiError(errors)
63 }
64
65 return nil
66 }
67
68 // StreamMetricsResponseMultiError is an error wrapping multiple validation
69 // errors returned by StreamMetricsResponse.ValidateAll() if the designated
70 // constraints aren't met.
71 type StreamMetricsResponseMultiError []error
72
73 // Error returns a concatenation of all the error messages it wraps.
74 func (m StreamMetricsResponseMultiError) Error() string {
75 var msgs []string
76 for _, err := range m {
77 msgs = append(msgs, err.Error())
78 }
79 return strings.Join(msgs, "; ")
80 }
81
82 // AllErrors returns a list of validation violation errors.
83 func (m StreamMetricsResponseMultiError) AllErrors() []error { return m }
84
85 // StreamMetricsResponseValidationError is the validation error returned by
86 // StreamMetricsResponse.Validate if the designated constraints aren't met.
87 type StreamMetricsResponseValidationError struct {
88 field string
89 reason string
90 cause error
91 key bool
92 }
93
94 // Field function returns field value.
95 func (e StreamMetricsResponseValidationError) Field() string { return e.field }
96
97 // Reason function returns reason value.
98 func (e StreamMetricsResponseValidationError) Reason() string { return e.reason }
99
100 // Cause function returns cause value.
101 func (e StreamMetricsResponseValidationError) Cause() error { return e.cause }
102
103 // Key function returns key value.
104 func (e StreamMetricsResponseValidationError) Key() bool { return e.key }
105
106 // ErrorName returns error name.
107 func (e StreamMetricsResponseValidationError) ErrorName() string {
108 return "StreamMetricsResponseValidationError"
109 }
110
111 // Error satisfies the builtin error interface
112 func (e StreamMetricsResponseValidationError) Error() string {
113 cause := ""
114 if e.cause != nil {
115 cause = fmt.Sprintf(" | caused by: %v", e.cause)
116 }
117
118 key := ""
119 if e.key {
120 key = "key for "
121 }
122
123 return fmt.Sprintf(
124 "invalid %sStreamMetricsResponse.%s: %s%s",
125 key,
126 e.field,
127 e.reason,
128 cause)
129 }
130
131 var _ error = StreamMetricsResponseValidationError{}
132
133 var _ interface {
134 Field() string
135 Reason() string
136 Key() bool
137 Cause() error
138 ErrorName() string
139 } = StreamMetricsResponseValidationError{}
140
141 // Validate checks the field values on StreamMetricsMessage with the rules
142 // defined in the proto definition for this message. If any rules are
143 // violated, the first error encountered is returned, or nil if there are no violations.
144 func (m *StreamMetricsMessage) Validate() error {
145 return m.validate(false)
146 }
147
148 // ValidateAll checks the field values on StreamMetricsMessage with the rules
149 // defined in the proto definition for this message. If any rules are
150 // violated, the result is a list of violation errors wrapped in
151 // StreamMetricsMessageMultiError, or nil if none found.
152 func (m *StreamMetricsMessage) ValidateAll() error {
153 return m.validate(true)
154 }
155
156 func (m *StreamMetricsMessage) validate(all bool) error {
157 if m == nil {
158 return nil
159 }
160
161 var errors []error
162
163 if all {
164 switch v := interface{}(m.GetIdentifier()).(type) {
165 case interface{ ValidateAll() error }:
166 if err := v.ValidateAll(); err != nil {
167 errors = append(errors, StreamMetricsMessageValidationError{
168 field: "Identifier",
169 reason: "embedded message failed validation",
170 cause: err,
171 })
172 }
173 case interface{ Validate() error }:
174 if err := v.Validate(); err != nil {
175 errors = append(errors, StreamMetricsMessageValidationError{
176 field: "Identifier",
177 reason: "embedded message failed validation",
178 cause: err,
179 })
180 }
181 }
182 } else if v, ok := interface{}(m.GetIdentifier()).(interface{ Validate() error }); ok {
183 if err := v.Validate(); err != nil {
184 return StreamMetricsMessageValidationError{
185 field: "Identifier",
186 reason: "embedded message failed validation",
187 cause: err,
188 }
189 }
190 }
191
192 for idx, item := range m.GetEnvoyMetrics() {
193 _, _ = idx, item
194
195 if all {
196 switch v := interface{}(item).(type) {
197 case interface{ ValidateAll() error }:
198 if err := v.ValidateAll(); err != nil {
199 errors = append(errors, StreamMetricsMessageValidationError{
200 field: fmt.Sprintf("EnvoyMetrics[%v]", idx),
201 reason: "embedded message failed validation",
202 cause: err,
203 })
204 }
205 case interface{ Validate() error }:
206 if err := v.Validate(); err != nil {
207 errors = append(errors, StreamMetricsMessageValidationError{
208 field: fmt.Sprintf("EnvoyMetrics[%v]", idx),
209 reason: "embedded message failed validation",
210 cause: err,
211 })
212 }
213 }
214 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
215 if err := v.Validate(); err != nil {
216 return StreamMetricsMessageValidationError{
217 field: fmt.Sprintf("EnvoyMetrics[%v]", idx),
218 reason: "embedded message failed validation",
219 cause: err,
220 }
221 }
222 }
223
224 }
225
226 if len(errors) > 0 {
227 return StreamMetricsMessageMultiError(errors)
228 }
229
230 return nil
231 }
232
233 // StreamMetricsMessageMultiError is an error wrapping multiple validation
234 // errors returned by StreamMetricsMessage.ValidateAll() if the designated
235 // constraints aren't met.
236 type StreamMetricsMessageMultiError []error
237
238 // Error returns a concatenation of all the error messages it wraps.
239 func (m StreamMetricsMessageMultiError) Error() string {
240 var msgs []string
241 for _, err := range m {
242 msgs = append(msgs, err.Error())
243 }
244 return strings.Join(msgs, "; ")
245 }
246
247 // AllErrors returns a list of validation violation errors.
248 func (m StreamMetricsMessageMultiError) AllErrors() []error { return m }
249
250 // StreamMetricsMessageValidationError is the validation error returned by
251 // StreamMetricsMessage.Validate if the designated constraints aren't met.
252 type StreamMetricsMessageValidationError struct {
253 field string
254 reason string
255 cause error
256 key bool
257 }
258
259 // Field function returns field value.
260 func (e StreamMetricsMessageValidationError) Field() string { return e.field }
261
262 // Reason function returns reason value.
263 func (e StreamMetricsMessageValidationError) Reason() string { return e.reason }
264
265 // Cause function returns cause value.
266 func (e StreamMetricsMessageValidationError) Cause() error { return e.cause }
267
268 // Key function returns key value.
269 func (e StreamMetricsMessageValidationError) Key() bool { return e.key }
270
271 // ErrorName returns error name.
272 func (e StreamMetricsMessageValidationError) ErrorName() string {
273 return "StreamMetricsMessageValidationError"
274 }
275
276 // Error satisfies the builtin error interface
277 func (e StreamMetricsMessageValidationError) Error() string {
278 cause := ""
279 if e.cause != nil {
280 cause = fmt.Sprintf(" | caused by: %v", e.cause)
281 }
282
283 key := ""
284 if e.key {
285 key = "key for "
286 }
287
288 return fmt.Sprintf(
289 "invalid %sStreamMetricsMessage.%s: %s%s",
290 key,
291 e.field,
292 e.reason,
293 cause)
294 }
295
296 var _ error = StreamMetricsMessageValidationError{}
297
298 var _ interface {
299 Field() string
300 Reason() string
301 Key() bool
302 Cause() error
303 ErrorName() string
304 } = StreamMetricsMessageValidationError{}
305
306 // Validate checks the field values on StreamMetricsMessage_Identifier with the
307 // rules defined in the proto definition for this message. If any rules are
308 // violated, the first error encountered is returned, or nil if there are no violations.
309 func (m *StreamMetricsMessage_Identifier) Validate() error {
310 return m.validate(false)
311 }
312
313 // ValidateAll checks the field values on StreamMetricsMessage_Identifier with
314 // the rules defined in the proto definition for this message. If any rules
315 // are violated, the result is a list of violation errors wrapped in
316 // StreamMetricsMessage_IdentifierMultiError, or nil if none found.
317 func (m *StreamMetricsMessage_Identifier) ValidateAll() error {
318 return m.validate(true)
319 }
320
321 func (m *StreamMetricsMessage_Identifier) validate(all bool) error {
322 if m == nil {
323 return nil
324 }
325
326 var errors []error
327
328 if m.GetNode() == nil {
329 err := StreamMetricsMessage_IdentifierValidationError{
330 field: "Node",
331 reason: "value is required",
332 }
333 if !all {
334 return err
335 }
336 errors = append(errors, err)
337 }
338
339 if all {
340 switch v := interface{}(m.GetNode()).(type) {
341 case interface{ ValidateAll() error }:
342 if err := v.ValidateAll(); err != nil {
343 errors = append(errors, StreamMetricsMessage_IdentifierValidationError{
344 field: "Node",
345 reason: "embedded message failed validation",
346 cause: err,
347 })
348 }
349 case interface{ Validate() error }:
350 if err := v.Validate(); err != nil {
351 errors = append(errors, StreamMetricsMessage_IdentifierValidationError{
352 field: "Node",
353 reason: "embedded message failed validation",
354 cause: err,
355 })
356 }
357 }
358 } else if v, ok := interface{}(m.GetNode()).(interface{ Validate() error }); ok {
359 if err := v.Validate(); err != nil {
360 return StreamMetricsMessage_IdentifierValidationError{
361 field: "Node",
362 reason: "embedded message failed validation",
363 cause: err,
364 }
365 }
366 }
367
368 if len(errors) > 0 {
369 return StreamMetricsMessage_IdentifierMultiError(errors)
370 }
371
372 return nil
373 }
374
375 // StreamMetricsMessage_IdentifierMultiError is an error wrapping multiple
376 // validation errors returned by StreamMetricsMessage_Identifier.ValidateAll()
377 // if the designated constraints aren't met.
378 type StreamMetricsMessage_IdentifierMultiError []error
379
380 // Error returns a concatenation of all the error messages it wraps.
381 func (m StreamMetricsMessage_IdentifierMultiError) Error() string {
382 var msgs []string
383 for _, err := range m {
384 msgs = append(msgs, err.Error())
385 }
386 return strings.Join(msgs, "; ")
387 }
388
389 // AllErrors returns a list of validation violation errors.
390 func (m StreamMetricsMessage_IdentifierMultiError) AllErrors() []error { return m }
391
392 // StreamMetricsMessage_IdentifierValidationError is the validation error
393 // returned by StreamMetricsMessage_Identifier.Validate if the designated
394 // constraints aren't met.
395 type StreamMetricsMessage_IdentifierValidationError struct {
396 field string
397 reason string
398 cause error
399 key bool
400 }
401
402 // Field function returns field value.
403 func (e StreamMetricsMessage_IdentifierValidationError) Field() string { return e.field }
404
405 // Reason function returns reason value.
406 func (e StreamMetricsMessage_IdentifierValidationError) Reason() string { return e.reason }
407
408 // Cause function returns cause value.
409 func (e StreamMetricsMessage_IdentifierValidationError) Cause() error { return e.cause }
410
411 // Key function returns key value.
412 func (e StreamMetricsMessage_IdentifierValidationError) Key() bool { return e.key }
413
414 // ErrorName returns error name.
415 func (e StreamMetricsMessage_IdentifierValidationError) ErrorName() string {
416 return "StreamMetricsMessage_IdentifierValidationError"
417 }
418
419 // Error satisfies the builtin error interface
420 func (e StreamMetricsMessage_IdentifierValidationError) Error() string {
421 cause := ""
422 if e.cause != nil {
423 cause = fmt.Sprintf(" | caused by: %v", e.cause)
424 }
425
426 key := ""
427 if e.key {
428 key = "key for "
429 }
430
431 return fmt.Sprintf(
432 "invalid %sStreamMetricsMessage_Identifier.%s: %s%s",
433 key,
434 e.field,
435 e.reason,
436 cause)
437 }
438
439 var _ error = StreamMetricsMessage_IdentifierValidationError{}
440
441 var _ interface {
442 Field() string
443 Reason() string
444 Key() bool
445 Cause() error
446 ErrorName() string
447 } = StreamMetricsMessage_IdentifierValidationError{}