1
2
3
4 package accesslogv2
5
6 import (
7 "bytes"
8 "errors"
9 "fmt"
10 "net"
11 "net/mail"
12 "net/url"
13 "regexp"
14 "sort"
15 "strings"
16 "time"
17 "unicode/utf8"
18
19 "google.golang.org/protobuf/types/known/anypb"
20 )
21
22
23 var (
24 _ = bytes.MinRead
25 _ = errors.New("")
26 _ = fmt.Print
27 _ = utf8.UTFMax
28 _ = (*regexp.Regexp)(nil)
29 _ = (*strings.Reader)(nil)
30 _ = net.IPv4len
31 _ = time.Duration(0)
32 _ = (*url.URL)(nil)
33 _ = (*mail.Address)(nil)
34 _ = anypb.Any{}
35 _ = sort.Sort
36 )
37
38
39
40
41 func (m *HttpGrpcAccessLogConfig) Validate() error {
42 return m.validate(false)
43 }
44
45
46
47
48
49 func (m *HttpGrpcAccessLogConfig) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *HttpGrpcAccessLogConfig) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if m.GetCommonConfig() == nil {
61 err := HttpGrpcAccessLogConfigValidationError{
62 field: "CommonConfig",
63 reason: "value is required",
64 }
65 if !all {
66 return err
67 }
68 errors = append(errors, err)
69 }
70
71 if all {
72 switch v := interface{}(m.GetCommonConfig()).(type) {
73 case interface{ ValidateAll() error }:
74 if err := v.ValidateAll(); err != nil {
75 errors = append(errors, HttpGrpcAccessLogConfigValidationError{
76 field: "CommonConfig",
77 reason: "embedded message failed validation",
78 cause: err,
79 })
80 }
81 case interface{ Validate() error }:
82 if err := v.Validate(); err != nil {
83 errors = append(errors, HttpGrpcAccessLogConfigValidationError{
84 field: "CommonConfig",
85 reason: "embedded message failed validation",
86 cause: err,
87 })
88 }
89 }
90 } else if v, ok := interface{}(m.GetCommonConfig()).(interface{ Validate() error }); ok {
91 if err := v.Validate(); err != nil {
92 return HttpGrpcAccessLogConfigValidationError{
93 field: "CommonConfig",
94 reason: "embedded message failed validation",
95 cause: err,
96 }
97 }
98 }
99
100 if len(errors) > 0 {
101 return HttpGrpcAccessLogConfigMultiError(errors)
102 }
103
104 return nil
105 }
106
107
108
109
110 type HttpGrpcAccessLogConfigMultiError []error
111
112
113 func (m HttpGrpcAccessLogConfigMultiError) Error() string {
114 var msgs []string
115 for _, err := range m {
116 msgs = append(msgs, err.Error())
117 }
118 return strings.Join(msgs, "; ")
119 }
120
121
122 func (m HttpGrpcAccessLogConfigMultiError) AllErrors() []error { return m }
123
124
125
126 type HttpGrpcAccessLogConfigValidationError struct {
127 field string
128 reason string
129 cause error
130 key bool
131 }
132
133
134 func (e HttpGrpcAccessLogConfigValidationError) Field() string { return e.field }
135
136
137 func (e HttpGrpcAccessLogConfigValidationError) Reason() string { return e.reason }
138
139
140 func (e HttpGrpcAccessLogConfigValidationError) Cause() error { return e.cause }
141
142
143 func (e HttpGrpcAccessLogConfigValidationError) Key() bool { return e.key }
144
145
146 func (e HttpGrpcAccessLogConfigValidationError) ErrorName() string {
147 return "HttpGrpcAccessLogConfigValidationError"
148 }
149
150
151 func (e HttpGrpcAccessLogConfigValidationError) Error() string {
152 cause := ""
153 if e.cause != nil {
154 cause = fmt.Sprintf(" | caused by: %v", e.cause)
155 }
156
157 key := ""
158 if e.key {
159 key = "key for "
160 }
161
162 return fmt.Sprintf(
163 "invalid %sHttpGrpcAccessLogConfig.%s: %s%s",
164 key,
165 e.field,
166 e.reason,
167 cause)
168 }
169
170 var _ error = HttpGrpcAccessLogConfigValidationError{}
171
172 var _ interface {
173 Field() string
174 Reason() string
175 Key() bool
176 Cause() error
177 ErrorName() string
178 } = HttpGrpcAccessLogConfigValidationError{}
179
180
181
182
183 func (m *TcpGrpcAccessLogConfig) Validate() error {
184 return m.validate(false)
185 }
186
187
188
189
190
191 func (m *TcpGrpcAccessLogConfig) ValidateAll() error {
192 return m.validate(true)
193 }
194
195 func (m *TcpGrpcAccessLogConfig) validate(all bool) error {
196 if m == nil {
197 return nil
198 }
199
200 var errors []error
201
202 if m.GetCommonConfig() == nil {
203 err := TcpGrpcAccessLogConfigValidationError{
204 field: "CommonConfig",
205 reason: "value is required",
206 }
207 if !all {
208 return err
209 }
210 errors = append(errors, err)
211 }
212
213 if all {
214 switch v := interface{}(m.GetCommonConfig()).(type) {
215 case interface{ ValidateAll() error }:
216 if err := v.ValidateAll(); err != nil {
217 errors = append(errors, TcpGrpcAccessLogConfigValidationError{
218 field: "CommonConfig",
219 reason: "embedded message failed validation",
220 cause: err,
221 })
222 }
223 case interface{ Validate() error }:
224 if err := v.Validate(); err != nil {
225 errors = append(errors, TcpGrpcAccessLogConfigValidationError{
226 field: "CommonConfig",
227 reason: "embedded message failed validation",
228 cause: err,
229 })
230 }
231 }
232 } else if v, ok := interface{}(m.GetCommonConfig()).(interface{ Validate() error }); ok {
233 if err := v.Validate(); err != nil {
234 return TcpGrpcAccessLogConfigValidationError{
235 field: "CommonConfig",
236 reason: "embedded message failed validation",
237 cause: err,
238 }
239 }
240 }
241
242 if len(errors) > 0 {
243 return TcpGrpcAccessLogConfigMultiError(errors)
244 }
245
246 return nil
247 }
248
249
250
251
252 type TcpGrpcAccessLogConfigMultiError []error
253
254
255 func (m TcpGrpcAccessLogConfigMultiError) Error() string {
256 var msgs []string
257 for _, err := range m {
258 msgs = append(msgs, err.Error())
259 }
260 return strings.Join(msgs, "; ")
261 }
262
263
264 func (m TcpGrpcAccessLogConfigMultiError) AllErrors() []error { return m }
265
266
267
268 type TcpGrpcAccessLogConfigValidationError struct {
269 field string
270 reason string
271 cause error
272 key bool
273 }
274
275
276 func (e TcpGrpcAccessLogConfigValidationError) Field() string { return e.field }
277
278
279 func (e TcpGrpcAccessLogConfigValidationError) Reason() string { return e.reason }
280
281
282 func (e TcpGrpcAccessLogConfigValidationError) Cause() error { return e.cause }
283
284
285 func (e TcpGrpcAccessLogConfigValidationError) Key() bool { return e.key }
286
287
288 func (e TcpGrpcAccessLogConfigValidationError) ErrorName() string {
289 return "TcpGrpcAccessLogConfigValidationError"
290 }
291
292
293 func (e TcpGrpcAccessLogConfigValidationError) Error() string {
294 cause := ""
295 if e.cause != nil {
296 cause = fmt.Sprintf(" | caused by: %v", e.cause)
297 }
298
299 key := ""
300 if e.key {
301 key = "key for "
302 }
303
304 return fmt.Sprintf(
305 "invalid %sTcpGrpcAccessLogConfig.%s: %s%s",
306 key,
307 e.field,
308 e.reason,
309 cause)
310 }
311
312 var _ error = TcpGrpcAccessLogConfigValidationError{}
313
314 var _ interface {
315 Field() string
316 Reason() string
317 Key() bool
318 Cause() error
319 ErrorName() string
320 } = TcpGrpcAccessLogConfigValidationError{}
321
322
323
324
325 func (m *CommonGrpcAccessLogConfig) Validate() error {
326 return m.validate(false)
327 }
328
329
330
331
332
333 func (m *CommonGrpcAccessLogConfig) ValidateAll() error {
334 return m.validate(true)
335 }
336
337 func (m *CommonGrpcAccessLogConfig) validate(all bool) error {
338 if m == nil {
339 return nil
340 }
341
342 var errors []error
343
344 if len(m.GetLogName()) < 1 {
345 err := CommonGrpcAccessLogConfigValidationError{
346 field: "LogName",
347 reason: "value length must be at least 1 bytes",
348 }
349 if !all {
350 return err
351 }
352 errors = append(errors, err)
353 }
354
355 if m.GetGrpcService() == nil {
356 err := CommonGrpcAccessLogConfigValidationError{
357 field: "GrpcService",
358 reason: "value is required",
359 }
360 if !all {
361 return err
362 }
363 errors = append(errors, err)
364 }
365
366 if all {
367 switch v := interface{}(m.GetGrpcService()).(type) {
368 case interface{ ValidateAll() error }:
369 if err := v.ValidateAll(); err != nil {
370 errors = append(errors, CommonGrpcAccessLogConfigValidationError{
371 field: "GrpcService",
372 reason: "embedded message failed validation",
373 cause: err,
374 })
375 }
376 case interface{ Validate() error }:
377 if err := v.Validate(); err != nil {
378 errors = append(errors, CommonGrpcAccessLogConfigValidationError{
379 field: "GrpcService",
380 reason: "embedded message failed validation",
381 cause: err,
382 })
383 }
384 }
385 } else if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok {
386 if err := v.Validate(); err != nil {
387 return CommonGrpcAccessLogConfigValidationError{
388 field: "GrpcService",
389 reason: "embedded message failed validation",
390 cause: err,
391 }
392 }
393 }
394
395 if d := m.GetBufferFlushInterval(); d != nil {
396 dur, err := d.AsDuration(), d.CheckValid()
397 if err != nil {
398 err = CommonGrpcAccessLogConfigValidationError{
399 field: "BufferFlushInterval",
400 reason: "value is not a valid duration",
401 cause: err,
402 }
403 if !all {
404 return err
405 }
406 errors = append(errors, err)
407 } else {
408
409 gt := time.Duration(0*time.Second + 0*time.Nanosecond)
410
411 if dur <= gt {
412 err := CommonGrpcAccessLogConfigValidationError{
413 field: "BufferFlushInterval",
414 reason: "value must be greater than 0s",
415 }
416 if !all {
417 return err
418 }
419 errors = append(errors, err)
420 }
421
422 }
423 }
424
425 if all {
426 switch v := interface{}(m.GetBufferSizeBytes()).(type) {
427 case interface{ ValidateAll() error }:
428 if err := v.ValidateAll(); err != nil {
429 errors = append(errors, CommonGrpcAccessLogConfigValidationError{
430 field: "BufferSizeBytes",
431 reason: "embedded message failed validation",
432 cause: err,
433 })
434 }
435 case interface{ Validate() error }:
436 if err := v.Validate(); err != nil {
437 errors = append(errors, CommonGrpcAccessLogConfigValidationError{
438 field: "BufferSizeBytes",
439 reason: "embedded message failed validation",
440 cause: err,
441 })
442 }
443 }
444 } else if v, ok := interface{}(m.GetBufferSizeBytes()).(interface{ Validate() error }); ok {
445 if err := v.Validate(); err != nil {
446 return CommonGrpcAccessLogConfigValidationError{
447 field: "BufferSizeBytes",
448 reason: "embedded message failed validation",
449 cause: err,
450 }
451 }
452 }
453
454 if len(errors) > 0 {
455 return CommonGrpcAccessLogConfigMultiError(errors)
456 }
457
458 return nil
459 }
460
461
462
463
464 type CommonGrpcAccessLogConfigMultiError []error
465
466
467 func (m CommonGrpcAccessLogConfigMultiError) Error() string {
468 var msgs []string
469 for _, err := range m {
470 msgs = append(msgs, err.Error())
471 }
472 return strings.Join(msgs, "; ")
473 }
474
475
476 func (m CommonGrpcAccessLogConfigMultiError) AllErrors() []error { return m }
477
478
479
480 type CommonGrpcAccessLogConfigValidationError struct {
481 field string
482 reason string
483 cause error
484 key bool
485 }
486
487
488 func (e CommonGrpcAccessLogConfigValidationError) Field() string { return e.field }
489
490
491 func (e CommonGrpcAccessLogConfigValidationError) Reason() string { return e.reason }
492
493
494 func (e CommonGrpcAccessLogConfigValidationError) Cause() error { return e.cause }
495
496
497 func (e CommonGrpcAccessLogConfigValidationError) Key() bool { return e.key }
498
499
500 func (e CommonGrpcAccessLogConfigValidationError) ErrorName() string {
501 return "CommonGrpcAccessLogConfigValidationError"
502 }
503
504
505 func (e CommonGrpcAccessLogConfigValidationError) Error() string {
506 cause := ""
507 if e.cause != nil {
508 cause = fmt.Sprintf(" | caused by: %v", e.cause)
509 }
510
511 key := ""
512 if e.key {
513 key = "key for "
514 }
515
516 return fmt.Sprintf(
517 "invalid %sCommonGrpcAccessLogConfig.%s: %s%s",
518 key,
519 e.field,
520 e.reason,
521 cause)
522 }
523
524 var _ error = CommonGrpcAccessLogConfigValidationError{}
525
526 var _ interface {
527 Field() string
528 Reason() string
529 Key() bool
530 Cause() error
531 ErrorName() string
532 } = CommonGrpcAccessLogConfigValidationError{}
533
View as plain text