github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v4/common/common.pb.validate.go (about) 1 // Code generated by protoc-gen-goten-validate 2 // File: edgelq/monitoring/proto/v4/common.proto 3 // DO NOT EDIT!!! 4 5 package common 6 7 import ( 8 "bytes" 9 "errors" 10 "fmt" 11 "net" 12 "net/url" 13 "regexp" 14 "strings" 15 "time" 16 "unicode/utf8" 17 18 gotenvalidate "github.com/cloudwan/goten-sdk/runtime/validate" 19 ) 20 21 // proto imports 22 import ( 23 durationpb "google.golang.org/protobuf/types/known/durationpb" 24 timestamppb "google.golang.org/protobuf/types/known/timestamppb" 25 ) 26 27 var ( 28 _ = bytes.Equal 29 _ = errors.New 30 _ = fmt.Errorf 31 _ = net.ParseIP 32 _ = regexp.Match 33 _ = strings.Split 34 _ = time.Now 35 _ = utf8.RuneCountInString 36 _ = url.Parse 37 _ = gotenvalidate.NewValidationError 38 39 validation_regex_LabelDescriptor_key_3767d375e69c51f9742b2f17e9eb21a2 = regexp.MustCompile("^[_A-Za-z][_A-Za-z0-9]{0,31}$") 40 validation_regex_Metric_type_e8902cb4d938f84496a381cb8dc140e5 = regexp.MustCompile("^[A-Za-z0-9_\\-.,+!*()%\\\\/]{1,256}$") 41 ) 42 43 // make sure we're using proto imports 44 var ( 45 _ = &durationpb.Duration{} 46 _ = ×tamppb.Timestamp{} 47 ) 48 49 func (obj *LabelDescriptor) GotenValidate() error { 50 if obj == nil { 51 return nil 52 } 53 if !validation_regex_LabelDescriptor_key_3767d375e69c51f9742b2f17e9eb21a2.Match([]byte(obj.Key)) { 54 return gotenvalidate.NewValidationError("LabelDescriptor", "key", obj.Key, "field must match the regex ^[_A-Za-z][_A-Za-z0-9]{0,31}$", nil) 55 } 56 if int32(obj.ValueType) != 0 { 57 return gotenvalidate.NewValidationError("LabelDescriptor", "valueType", obj.ValueType, "field must be set to the value 0", nil) 58 } 59 { 60 rlen := utf8.RuneCountInString(obj.Description) 61 if rlen > 1024 { 62 return gotenvalidate.NewValidationError("LabelDescriptor", "description", obj.Description, "field must contain at most 1024 characters", nil) 63 } 64 } 65 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 66 return cvobj.GotenCustomValidate() 67 } 68 return nil 69 } 70 func (obj *LabelKeySet) GotenValidate() error { 71 if obj == nil { 72 return nil 73 } 74 if len(obj.LabelKeys) > 1 { 75 values := make(map[string]struct{}) 76 for _, v := range obj.LabelKeys { 77 if _, ok := values[v]; ok { 78 return gotenvalidate.NewValidationError("LabelKeySet", "labelKeys", obj.LabelKeys, "field must contain unique items", nil) 79 } 80 values[v] = struct{}{} 81 } 82 } 83 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 84 return cvobj.GotenCustomValidate() 85 } 86 return nil 87 } 88 func (obj *Distribution) GotenValidate() error { 89 if obj == nil { 90 return nil 91 } 92 if subobj, ok := interface{}(obj.Range).(gotenvalidate.Validator); ok { 93 if err := subobj.GotenValidate(); err != nil { 94 return gotenvalidate.NewValidationError("Distribution", "range", obj.Range, "nested object validation failed", err) 95 } 96 } 97 if subobj, ok := interface{}(obj.BucketOptions).(gotenvalidate.Validator); ok { 98 if err := subobj.GotenValidate(); err != nil { 99 return gotenvalidate.NewValidationError("Distribution", "bucketOptions", obj.BucketOptions, "nested object validation failed", err) 100 } 101 } 102 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 103 return cvobj.GotenCustomValidate() 104 } 105 return nil 106 } 107 func (obj *Distribution_Range) GotenValidate() error { 108 if obj == nil { 109 return nil 110 } 111 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 112 return cvobj.GotenCustomValidate() 113 } 114 return nil 115 } 116 func (obj *Distribution_BucketOptions) GotenValidate() error { 117 if obj == nil { 118 return nil 119 } 120 switch opt := obj.Options.(type) { 121 case *Distribution_BucketOptions_LinearBuckets: 122 if subobj, ok := interface{}(opt.LinearBuckets).(gotenvalidate.Validator); ok { 123 if err := subobj.GotenValidate(); err != nil { 124 return gotenvalidate.NewValidationError("BucketOptions", "linearBuckets", opt.LinearBuckets, "nested object validation failed", err) 125 } 126 } 127 case *Distribution_BucketOptions_ExponentialBuckets: 128 if subobj, ok := interface{}(opt.ExponentialBuckets).(gotenvalidate.Validator); ok { 129 if err := subobj.GotenValidate(); err != nil { 130 return gotenvalidate.NewValidationError("BucketOptions", "exponentialBuckets", opt.ExponentialBuckets, "nested object validation failed", err) 131 } 132 } 133 case *Distribution_BucketOptions_ExplicitBuckets: 134 if subobj, ok := interface{}(opt.ExplicitBuckets).(gotenvalidate.Validator); ok { 135 if err := subobj.GotenValidate(); err != nil { 136 return gotenvalidate.NewValidationError("BucketOptions", "explicitBuckets", opt.ExplicitBuckets, "nested object validation failed", err) 137 } 138 } 139 case *Distribution_BucketOptions_DynamicBuckets: 140 if subobj, ok := interface{}(opt.DynamicBuckets).(gotenvalidate.Validator); ok { 141 if err := subobj.GotenValidate(); err != nil { 142 return gotenvalidate.NewValidationError("BucketOptions", "dynamicBuckets", opt.DynamicBuckets, "nested object validation failed", err) 143 } 144 } 145 default: 146 _ = opt 147 } 148 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 149 return cvobj.GotenCustomValidate() 150 } 151 return nil 152 } 153 func (obj *Distribution_BucketOptions_Linear) GotenValidate() error { 154 if obj == nil { 155 return nil 156 } 157 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 158 return cvobj.GotenCustomValidate() 159 } 160 return nil 161 } 162 func (obj *Distribution_BucketOptions_Exponential) GotenValidate() error { 163 if obj == nil { 164 return nil 165 } 166 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 167 return cvobj.GotenCustomValidate() 168 } 169 return nil 170 } 171 func (obj *Distribution_BucketOptions_Explicit) GotenValidate() error { 172 if obj == nil { 173 return nil 174 } 175 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 176 return cvobj.GotenCustomValidate() 177 } 178 return nil 179 } 180 func (obj *Distribution_BucketOptions_Dynamic) GotenValidate() error { 181 if obj == nil { 182 return nil 183 } 184 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 185 return cvobj.GotenCustomValidate() 186 } 187 return nil 188 } 189 func (obj *TypedValue) GotenValidate() error { 190 if obj == nil { 191 return nil 192 } 193 switch opt := obj.Value.(type) { 194 case *TypedValue_BoolValue: 195 case *TypedValue_Int64Value: 196 case *TypedValue_DoubleValue: 197 case *TypedValue_StringValue: 198 case *TypedValue_DistributionValue: 199 if subobj, ok := interface{}(opt.DistributionValue).(gotenvalidate.Validator); ok { 200 if err := subobj.GotenValidate(); err != nil { 201 return gotenvalidate.NewValidationError("TypedValue", "distributionValue", opt.DistributionValue, "nested object validation failed", err) 202 } 203 } 204 default: 205 _ = opt 206 } 207 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 208 return cvobj.GotenCustomValidate() 209 } 210 return nil 211 } 212 func (obj *TimeInterval) GotenValidate() error { 213 if obj == nil { 214 return nil 215 } 216 if obj.EndTime == nil { 217 return gotenvalidate.NewValidationError("TimeInterval", "endTime", obj.EndTime, "field is required", nil) 218 } 219 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 220 return cvobj.GotenCustomValidate() 221 } 222 return nil 223 } 224 func (obj *TimeRange) GotenValidate() error { 225 if obj == nil { 226 return nil 227 } 228 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 229 return cvobj.GotenCustomValidate() 230 } 231 return nil 232 } 233 func (obj *Aggregation) GotenValidate() error { 234 if obj == nil { 235 return nil 236 } 237 if obj.AlignmentPeriod != nil && obj.AlignmentPeriod.CheckValid() != nil { 238 err := obj.AlignmentPeriod.CheckValid() 239 return gotenvalidate.NewValidationError("Aggregation", "alignmentPeriod", obj.AlignmentPeriod, "could not validate duration", err) 240 } else { 241 d := obj.AlignmentPeriod.AsDuration() 242 243 if obj.AlignmentPeriod != nil { 244 if d != time.Duration(0) && d != time.Duration(60000000000) && d != time.Duration(180000000000) && d != time.Duration(300000000000) && d != time.Duration(900000000000) && d != time.Duration(1800000000000) && d != time.Duration(3600000000000) && d != time.Duration(10800000000000) && d != time.Duration(21600000000000) && d != time.Duration(43200000000000) && d != time.Duration(86400000000000) { 245 return gotenvalidate.NewValidationError("Aggregation", "alignmentPeriod", d, "field must be equal to exactly one of the following values: 0s, 1m0s, 3m0s, 5m0s, 15m0s, 30m0s, 1h0m0s, 3h0m0s, 6h0m0s, 12h0m0s, 24h0m0s", nil) 246 } 247 } 248 } 249 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 250 return cvobj.GotenCustomValidate() 251 } 252 return nil 253 } 254 func (obj *Pagination) GotenValidate() error { 255 if obj == nil { 256 return nil 257 } 258 if obj.View == "" { 259 return gotenvalidate.NewValidationError("Pagination", "view", obj.View, "field is required", nil) 260 } 261 if obj.Function == "" { 262 return gotenvalidate.NewValidationError("Pagination", "function", obj.Function, "field is required", nil) 263 } 264 if obj.AlignmentPeriod != nil && obj.AlignmentPeriod.CheckValid() != nil { 265 err := obj.AlignmentPeriod.CheckValid() 266 return gotenvalidate.NewValidationError("Pagination", "alignmentPeriod", obj.AlignmentPeriod, "could not validate duration", err) 267 } else { 268 d := obj.AlignmentPeriod.AsDuration() 269 270 if obj.AlignmentPeriod != nil { 271 if d != time.Duration(0) && d != time.Duration(60000000000) && d != time.Duration(180000000000) && d != time.Duration(300000000000) && d != time.Duration(900000000000) && d != time.Duration(1800000000000) && d != time.Duration(3600000000000) && d != time.Duration(10800000000000) && d != time.Duration(21600000000000) && d != time.Duration(43200000000000) && d != time.Duration(86400000000000) && d != time.Duration(604800000000000) && d != time.Duration(2419200000000000) { 272 return gotenvalidate.NewValidationError("Pagination", "alignmentPeriod", d, "field must be equal to exactly one of the following values: 0s, 1m0s, 3m0s, 5m0s, 15m0s, 30m0s, 1h0m0s, 3h0m0s, 6h0m0s, 12h0m0s, 24h0m0s, 168h0m0s, 672h0m0s", nil) 273 } 274 } 275 } 276 if !(obj.Limit >= 0 && obj.Limit <= 100) { 277 return gotenvalidate.NewValidationError("Pagination", "limit", obj.Limit, "field must be in range [0, 100]", nil) 278 } 279 if !(obj.Offset >= 0) { 280 return gotenvalidate.NewValidationError("Pagination", "offset", obj.Offset, "field must be greater or equal to 0", nil) 281 } 282 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 283 return cvobj.GotenCustomValidate() 284 } 285 return nil 286 } 287 func (obj *Metric) GotenValidate() error { 288 if obj == nil { 289 return nil 290 } 291 if !validation_regex_Metric_type_e8902cb4d938f84496a381cb8dc140e5.Match([]byte(obj.Type)) { 292 return gotenvalidate.NewValidationError("Metric", "type", obj.Type, "field must match the regex ^[A-Za-z0-9_\\-.,+!*()%\\\\/]{1,256}$", nil) 293 } 294 for k, v := range obj.Labels { 295 _, _ = k, v 296 { 297 rlen := utf8.RuneCountInString(v) 298 if rlen > 1024 { 299 return gotenvalidate.NewValidationError("Metric", "labels", v, "field must contain at most 1024 characters", nil) 300 } 301 } 302 } 303 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 304 return cvobj.GotenCustomValidate() 305 } 306 return nil 307 } 308 func (obj *MonitoredResource) GotenValidate() error { 309 if obj == nil { 310 return nil 311 } 312 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 313 return cvobj.GotenCustomValidate() 314 } 315 return nil 316 } 317 func (obj *Strings) GotenValidate() error { 318 if obj == nil { 319 return nil 320 } 321 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 322 return cvobj.GotenCustomValidate() 323 } 324 return nil 325 } 326 func (obj *MonitoredResourceSelector) GotenValidate() error { 327 if obj == nil { 328 return nil 329 } 330 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 331 return cvobj.GotenCustomValidate() 332 } 333 return nil 334 } 335 func (obj *MetricSelector) GotenValidate() error { 336 if obj == nil { 337 return nil 338 } 339 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 340 return cvobj.GotenCustomValidate() 341 } 342 return nil 343 } 344 func (obj *TimeSeriesSelector) GotenValidate() error { 345 if obj == nil { 346 return nil 347 } 348 if subobj, ok := interface{}(obj.Metric).(gotenvalidate.Validator); ok { 349 if err := subobj.GotenValidate(); err != nil { 350 return gotenvalidate.NewValidationError("TimeSeriesSelector", "metric", obj.Metric, "nested object validation failed", err) 351 } 352 } 353 if subobj, ok := interface{}(obj.Resource).(gotenvalidate.Validator); ok { 354 if err := subobj.GotenValidate(); err != nil { 355 return gotenvalidate.NewValidationError("TimeSeriesSelector", "resource", obj.Resource, "nested object validation failed", err) 356 } 357 } 358 if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok { 359 return cvobj.GotenCustomValidate() 360 } 361 return nil 362 }