github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/log_condition/log_condition.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/alerting/proto/v1/log_condition.proto 3 // DO NOT EDIT!!! 4 5 package log_condition 6 7 import ( 8 "encoding/json" 9 "fmt" 10 "reflect" 11 "strings" 12 "time" 13 14 "google.golang.org/grpc/codes" 15 "google.golang.org/grpc/status" 16 "google.golang.org/protobuf/encoding/protojson" 17 "google.golang.org/protobuf/proto" 18 "google.golang.org/protobuf/reflect/protoregistry" 19 20 gotenobject "github.com/cloudwan/goten-sdk/runtime/object" 21 "github.com/cloudwan/goten-sdk/runtime/strcase" 22 ) 23 24 // proto imports 25 import ( 26 rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common" 27 document "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/document" 28 log_condition_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/log_condition_template" 29 policy "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy" 30 meta "github.com/cloudwan/goten-sdk/types/meta" 31 fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" 32 ) 33 34 // ensure the imports are used 35 var ( 36 _ = new(json.Marshaler) 37 _ = new(fmt.Stringer) 38 _ = reflect.DeepEqual 39 _ = strings.Builder{} 40 _ = time.Second 41 42 _ = strcase.ToLowerCamel 43 _ = codes.NotFound 44 _ = status.Status{} 45 _ = protojson.UnmarshalOptions{} 46 _ = new(proto.Message) 47 _ = protoregistry.GlobalTypes 48 49 _ = new(gotenobject.FieldPath) 50 ) 51 52 // make sure we're using proto imports 53 var ( 54 _ = &document.Document{} 55 _ = &log_condition_template.LogConditionTemplate{} 56 _ = &policy.Policy{} 57 _ = &rcommon.LogCndSpec{} 58 _ = &fieldmaskpb.FieldMask{} 59 _ = &meta.Meta{} 60 ) 61 62 // FieldPath provides implementation to handle 63 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 64 type LogCondition_FieldPath interface { 65 gotenobject.FieldPath 66 Selector() LogCondition_FieldPathSelector 67 Get(source *LogCondition) []interface{} 68 GetSingle(source *LogCondition) (interface{}, bool) 69 ClearValue(item *LogCondition) 70 71 // Those methods build corresponding LogCondition_FieldPathValue 72 // (or array of values) and holds passed value. Panics if injected type is incorrect. 73 WithIValue(value interface{}) LogCondition_FieldPathValue 74 WithIArrayOfValues(values interface{}) LogCondition_FieldPathArrayOfValues 75 WithIArrayItemValue(value interface{}) LogCondition_FieldPathArrayItemValue 76 } 77 78 type LogCondition_FieldPathSelector int32 79 80 const ( 81 LogCondition_FieldPathSelectorName LogCondition_FieldPathSelector = 0 82 LogCondition_FieldPathSelectorMetadata LogCondition_FieldPathSelector = 1 83 LogCondition_FieldPathSelectorDisplayName LogCondition_FieldPathSelector = 2 84 LogCondition_FieldPathSelectorDescription LogCondition_FieldPathSelector = 3 85 LogCondition_FieldPathSelectorSupportingDocs LogCondition_FieldPathSelector = 4 86 LogCondition_FieldPathSelectorSpec LogCondition_FieldPathSelector = 5 87 LogCondition_FieldPathSelectorInternal LogCondition_FieldPathSelector = 6 88 LogCondition_FieldPathSelectorTemplateSource LogCondition_FieldPathSelector = 7 89 ) 90 91 func (s LogCondition_FieldPathSelector) String() string { 92 switch s { 93 case LogCondition_FieldPathSelectorName: 94 return "name" 95 case LogCondition_FieldPathSelectorMetadata: 96 return "metadata" 97 case LogCondition_FieldPathSelectorDisplayName: 98 return "display_name" 99 case LogCondition_FieldPathSelectorDescription: 100 return "description" 101 case LogCondition_FieldPathSelectorSupportingDocs: 102 return "supporting_docs" 103 case LogCondition_FieldPathSelectorSpec: 104 return "spec" 105 case LogCondition_FieldPathSelectorInternal: 106 return "internal" 107 case LogCondition_FieldPathSelectorTemplateSource: 108 return "template_source" 109 default: 110 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", s)) 111 } 112 } 113 114 func BuildLogCondition_FieldPath(fp gotenobject.RawFieldPath) (LogCondition_FieldPath, error) { 115 if len(fp) == 0 { 116 return nil, status.Error(codes.InvalidArgument, "empty field path for object LogCondition") 117 } 118 if len(fp) == 1 { 119 switch fp[0] { 120 case "name": 121 return &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorName}, nil 122 case "metadata": 123 return &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorMetadata}, nil 124 case "display_name", "displayName", "display-name": 125 return &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorDisplayName}, nil 126 case "description": 127 return &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorDescription}, nil 128 case "supporting_docs", "supportingDocs", "supporting-docs": 129 return &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorSupportingDocs}, nil 130 case "spec": 131 return &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorSpec}, nil 132 case "internal": 133 return &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorInternal}, nil 134 case "template_source", "templateSource", "template-source": 135 return &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorTemplateSource}, nil 136 } 137 } else { 138 switch fp[0] { 139 case "metadata": 140 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 141 return nil, err 142 } else { 143 return &LogCondition_FieldSubPath{selector: LogCondition_FieldPathSelectorMetadata, subPath: subpath}, nil 144 } 145 case "spec": 146 if subpath, err := rcommon.BuildLogCndSpec_FieldPath(fp[1:]); err != nil { 147 return nil, err 148 } else { 149 return &LogCondition_FieldSubPath{selector: LogCondition_FieldPathSelectorSpec, subPath: subpath}, nil 150 } 151 case "internal": 152 if subpath, err := BuildLogConditionInternal_FieldPath(fp[1:]); err != nil { 153 return nil, err 154 } else { 155 return &LogCondition_FieldSubPath{selector: LogCondition_FieldPathSelectorInternal, subPath: subpath}, nil 156 } 157 case "template_source", "templateSource", "template-source": 158 if subpath, err := BuildLogConditionTemplateSource_FieldPath(fp[1:]); err != nil { 159 return nil, err 160 } else { 161 return &LogCondition_FieldSubPath{selector: LogCondition_FieldPathSelectorTemplateSource, subPath: subpath}, nil 162 } 163 } 164 } 165 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object LogCondition", fp) 166 } 167 168 func ParseLogCondition_FieldPath(rawField string) (LogCondition_FieldPath, error) { 169 fp, err := gotenobject.ParseRawFieldPath(rawField) 170 if err != nil { 171 return nil, err 172 } 173 return BuildLogCondition_FieldPath(fp) 174 } 175 176 func MustParseLogCondition_FieldPath(rawField string) LogCondition_FieldPath { 177 fp, err := ParseLogCondition_FieldPath(rawField) 178 if err != nil { 179 panic(err) 180 } 181 return fp 182 } 183 184 type LogCondition_FieldTerminalPath struct { 185 selector LogCondition_FieldPathSelector 186 } 187 188 var _ LogCondition_FieldPath = (*LogCondition_FieldTerminalPath)(nil) 189 190 func (fp *LogCondition_FieldTerminalPath) Selector() LogCondition_FieldPathSelector { 191 return fp.selector 192 } 193 194 // String returns path representation in proto convention 195 func (fp *LogCondition_FieldTerminalPath) String() string { 196 return fp.selector.String() 197 } 198 199 // JSONString returns path representation is JSON convention 200 func (fp *LogCondition_FieldTerminalPath) JSONString() string { 201 return strcase.ToLowerCamel(fp.String()) 202 } 203 204 // Get returns all values pointed by specific field from source LogCondition 205 func (fp *LogCondition_FieldTerminalPath) Get(source *LogCondition) (values []interface{}) { 206 if source != nil { 207 switch fp.selector { 208 case LogCondition_FieldPathSelectorName: 209 if source.Name != nil { 210 values = append(values, source.Name) 211 } 212 case LogCondition_FieldPathSelectorMetadata: 213 if source.Metadata != nil { 214 values = append(values, source.Metadata) 215 } 216 case LogCondition_FieldPathSelectorDisplayName: 217 values = append(values, source.DisplayName) 218 case LogCondition_FieldPathSelectorDescription: 219 values = append(values, source.Description) 220 case LogCondition_FieldPathSelectorSupportingDocs: 221 for _, value := range source.GetSupportingDocs() { 222 values = append(values, value) 223 } 224 case LogCondition_FieldPathSelectorSpec: 225 if source.Spec != nil { 226 values = append(values, source.Spec) 227 } 228 case LogCondition_FieldPathSelectorInternal: 229 if source.Internal != nil { 230 values = append(values, source.Internal) 231 } 232 case LogCondition_FieldPathSelectorTemplateSource: 233 if source.TemplateSource != nil { 234 values = append(values, source.TemplateSource) 235 } 236 default: 237 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fp.selector)) 238 } 239 } 240 return 241 } 242 243 func (fp *LogCondition_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 244 return fp.Get(source.(*LogCondition)) 245 } 246 247 // GetSingle returns value pointed by specific field of from source LogCondition 248 func (fp *LogCondition_FieldTerminalPath) GetSingle(source *LogCondition) (interface{}, bool) { 249 switch fp.selector { 250 case LogCondition_FieldPathSelectorName: 251 res := source.GetName() 252 return res, res != nil 253 case LogCondition_FieldPathSelectorMetadata: 254 res := source.GetMetadata() 255 return res, res != nil 256 case LogCondition_FieldPathSelectorDisplayName: 257 return source.GetDisplayName(), source != nil 258 case LogCondition_FieldPathSelectorDescription: 259 return source.GetDescription(), source != nil 260 case LogCondition_FieldPathSelectorSupportingDocs: 261 res := source.GetSupportingDocs() 262 return res, res != nil 263 case LogCondition_FieldPathSelectorSpec: 264 res := source.GetSpec() 265 return res, res != nil 266 case LogCondition_FieldPathSelectorInternal: 267 res := source.GetInternal() 268 return res, res != nil 269 case LogCondition_FieldPathSelectorTemplateSource: 270 res := source.GetTemplateSource() 271 return res, res != nil 272 default: 273 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fp.selector)) 274 } 275 } 276 277 func (fp *LogCondition_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 278 return fp.GetSingle(source.(*LogCondition)) 279 } 280 281 // GetDefault returns a default value of the field type 282 func (fp *LogCondition_FieldTerminalPath) GetDefault() interface{} { 283 switch fp.selector { 284 case LogCondition_FieldPathSelectorName: 285 return (*Name)(nil) 286 case LogCondition_FieldPathSelectorMetadata: 287 return (*meta.Meta)(nil) 288 case LogCondition_FieldPathSelectorDisplayName: 289 return "" 290 case LogCondition_FieldPathSelectorDescription: 291 return "" 292 case LogCondition_FieldPathSelectorSupportingDocs: 293 return ([]*document.Reference)(nil) 294 case LogCondition_FieldPathSelectorSpec: 295 return (*rcommon.LogCndSpec)(nil) 296 case LogCondition_FieldPathSelectorInternal: 297 return (*LogCondition_Internal)(nil) 298 case LogCondition_FieldPathSelectorTemplateSource: 299 return (*LogCondition_TemplateSource)(nil) 300 default: 301 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fp.selector)) 302 } 303 } 304 305 func (fp *LogCondition_FieldTerminalPath) ClearValue(item *LogCondition) { 306 if item != nil { 307 switch fp.selector { 308 case LogCondition_FieldPathSelectorName: 309 item.Name = nil 310 case LogCondition_FieldPathSelectorMetadata: 311 item.Metadata = nil 312 case LogCondition_FieldPathSelectorDisplayName: 313 item.DisplayName = "" 314 case LogCondition_FieldPathSelectorDescription: 315 item.Description = "" 316 case LogCondition_FieldPathSelectorSupportingDocs: 317 item.SupportingDocs = nil 318 case LogCondition_FieldPathSelectorSpec: 319 item.Spec = nil 320 case LogCondition_FieldPathSelectorInternal: 321 item.Internal = nil 322 case LogCondition_FieldPathSelectorTemplateSource: 323 item.TemplateSource = nil 324 default: 325 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fp.selector)) 326 } 327 } 328 } 329 330 func (fp *LogCondition_FieldTerminalPath) ClearValueRaw(item proto.Message) { 331 fp.ClearValue(item.(*LogCondition)) 332 } 333 334 // IsLeaf - whether field path is holds simple value 335 func (fp *LogCondition_FieldTerminalPath) IsLeaf() bool { 336 return fp.selector == LogCondition_FieldPathSelectorName || 337 fp.selector == LogCondition_FieldPathSelectorDisplayName || 338 fp.selector == LogCondition_FieldPathSelectorDescription || 339 fp.selector == LogCondition_FieldPathSelectorSupportingDocs 340 } 341 342 func (fp *LogCondition_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 343 return []gotenobject.FieldPath{fp} 344 } 345 346 func (fp *LogCondition_FieldTerminalPath) WithIValue(value interface{}) LogCondition_FieldPathValue { 347 switch fp.selector { 348 case LogCondition_FieldPathSelectorName: 349 return &LogCondition_FieldTerminalPathValue{LogCondition_FieldTerminalPath: *fp, value: value.(*Name)} 350 case LogCondition_FieldPathSelectorMetadata: 351 return &LogCondition_FieldTerminalPathValue{LogCondition_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 352 case LogCondition_FieldPathSelectorDisplayName: 353 return &LogCondition_FieldTerminalPathValue{LogCondition_FieldTerminalPath: *fp, value: value.(string)} 354 case LogCondition_FieldPathSelectorDescription: 355 return &LogCondition_FieldTerminalPathValue{LogCondition_FieldTerminalPath: *fp, value: value.(string)} 356 case LogCondition_FieldPathSelectorSupportingDocs: 357 return &LogCondition_FieldTerminalPathValue{LogCondition_FieldTerminalPath: *fp, value: value.([]*document.Reference)} 358 case LogCondition_FieldPathSelectorSpec: 359 return &LogCondition_FieldTerminalPathValue{LogCondition_FieldTerminalPath: *fp, value: value.(*rcommon.LogCndSpec)} 360 case LogCondition_FieldPathSelectorInternal: 361 return &LogCondition_FieldTerminalPathValue{LogCondition_FieldTerminalPath: *fp, value: value.(*LogCondition_Internal)} 362 case LogCondition_FieldPathSelectorTemplateSource: 363 return &LogCondition_FieldTerminalPathValue{LogCondition_FieldTerminalPath: *fp, value: value.(*LogCondition_TemplateSource)} 364 default: 365 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fp.selector)) 366 } 367 } 368 369 func (fp *LogCondition_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 370 return fp.WithIValue(value) 371 } 372 373 func (fp *LogCondition_FieldTerminalPath) WithIArrayOfValues(values interface{}) LogCondition_FieldPathArrayOfValues { 374 fpaov := &LogCondition_FieldTerminalPathArrayOfValues{LogCondition_FieldTerminalPath: *fp} 375 switch fp.selector { 376 case LogCondition_FieldPathSelectorName: 377 return &LogCondition_FieldTerminalPathArrayOfValues{LogCondition_FieldTerminalPath: *fp, values: values.([]*Name)} 378 case LogCondition_FieldPathSelectorMetadata: 379 return &LogCondition_FieldTerminalPathArrayOfValues{LogCondition_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 380 case LogCondition_FieldPathSelectorDisplayName: 381 return &LogCondition_FieldTerminalPathArrayOfValues{LogCondition_FieldTerminalPath: *fp, values: values.([]string)} 382 case LogCondition_FieldPathSelectorDescription: 383 return &LogCondition_FieldTerminalPathArrayOfValues{LogCondition_FieldTerminalPath: *fp, values: values.([]string)} 384 case LogCondition_FieldPathSelectorSupportingDocs: 385 return &LogCondition_FieldTerminalPathArrayOfValues{LogCondition_FieldTerminalPath: *fp, values: values.([][]*document.Reference)} 386 case LogCondition_FieldPathSelectorSpec: 387 return &LogCondition_FieldTerminalPathArrayOfValues{LogCondition_FieldTerminalPath: *fp, values: values.([]*rcommon.LogCndSpec)} 388 case LogCondition_FieldPathSelectorInternal: 389 return &LogCondition_FieldTerminalPathArrayOfValues{LogCondition_FieldTerminalPath: *fp, values: values.([]*LogCondition_Internal)} 390 case LogCondition_FieldPathSelectorTemplateSource: 391 return &LogCondition_FieldTerminalPathArrayOfValues{LogCondition_FieldTerminalPath: *fp, values: values.([]*LogCondition_TemplateSource)} 392 default: 393 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fp.selector)) 394 } 395 return fpaov 396 } 397 398 func (fp *LogCondition_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 399 return fp.WithIArrayOfValues(values) 400 } 401 402 func (fp *LogCondition_FieldTerminalPath) WithIArrayItemValue(value interface{}) LogCondition_FieldPathArrayItemValue { 403 switch fp.selector { 404 case LogCondition_FieldPathSelectorSupportingDocs: 405 return &LogCondition_FieldTerminalPathArrayItemValue{LogCondition_FieldTerminalPath: *fp, value: value.(*document.Reference)} 406 default: 407 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fp.selector)) 408 } 409 } 410 411 func (fp *LogCondition_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 412 return fp.WithIArrayItemValue(value) 413 } 414 415 type LogCondition_FieldSubPath struct { 416 selector LogCondition_FieldPathSelector 417 subPath gotenobject.FieldPath 418 } 419 420 var _ LogCondition_FieldPath = (*LogCondition_FieldSubPath)(nil) 421 422 func (fps *LogCondition_FieldSubPath) Selector() LogCondition_FieldPathSelector { 423 return fps.selector 424 } 425 func (fps *LogCondition_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 426 res, ok := fps.subPath.(meta.Meta_FieldPath) 427 return res, ok 428 } 429 func (fps *LogCondition_FieldSubPath) AsSpecSubPath() (rcommon.LogCndSpec_FieldPath, bool) { 430 res, ok := fps.subPath.(rcommon.LogCndSpec_FieldPath) 431 return res, ok 432 } 433 func (fps *LogCondition_FieldSubPath) AsInternalSubPath() (LogConditionInternal_FieldPath, bool) { 434 res, ok := fps.subPath.(LogConditionInternal_FieldPath) 435 return res, ok 436 } 437 func (fps *LogCondition_FieldSubPath) AsTemplateSourceSubPath() (LogConditionTemplateSource_FieldPath, bool) { 438 res, ok := fps.subPath.(LogConditionTemplateSource_FieldPath) 439 return res, ok 440 } 441 442 // String returns path representation in proto convention 443 func (fps *LogCondition_FieldSubPath) String() string { 444 return fps.selector.String() + "." + fps.subPath.String() 445 } 446 447 // JSONString returns path representation is JSON convention 448 func (fps *LogCondition_FieldSubPath) JSONString() string { 449 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 450 } 451 452 // Get returns all values pointed by selected field from source LogCondition 453 func (fps *LogCondition_FieldSubPath) Get(source *LogCondition) (values []interface{}) { 454 switch fps.selector { 455 case LogCondition_FieldPathSelectorMetadata: 456 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 457 case LogCondition_FieldPathSelectorSpec: 458 values = append(values, fps.subPath.GetRaw(source.GetSpec())...) 459 case LogCondition_FieldPathSelectorInternal: 460 values = append(values, fps.subPath.GetRaw(source.GetInternal())...) 461 case LogCondition_FieldPathSelectorTemplateSource: 462 values = append(values, fps.subPath.GetRaw(source.GetTemplateSource())...) 463 default: 464 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fps.selector)) 465 } 466 return 467 } 468 469 func (fps *LogCondition_FieldSubPath) GetRaw(source proto.Message) []interface{} { 470 return fps.Get(source.(*LogCondition)) 471 } 472 473 // GetSingle returns value of selected field from source LogCondition 474 func (fps *LogCondition_FieldSubPath) GetSingle(source *LogCondition) (interface{}, bool) { 475 switch fps.selector { 476 case LogCondition_FieldPathSelectorMetadata: 477 if source.GetMetadata() == nil { 478 return nil, false 479 } 480 return fps.subPath.GetSingleRaw(source.GetMetadata()) 481 case LogCondition_FieldPathSelectorSpec: 482 if source.GetSpec() == nil { 483 return nil, false 484 } 485 return fps.subPath.GetSingleRaw(source.GetSpec()) 486 case LogCondition_FieldPathSelectorInternal: 487 if source.GetInternal() == nil { 488 return nil, false 489 } 490 return fps.subPath.GetSingleRaw(source.GetInternal()) 491 case LogCondition_FieldPathSelectorTemplateSource: 492 if source.GetTemplateSource() == nil { 493 return nil, false 494 } 495 return fps.subPath.GetSingleRaw(source.GetTemplateSource()) 496 default: 497 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fps.selector)) 498 } 499 } 500 501 func (fps *LogCondition_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 502 return fps.GetSingle(source.(*LogCondition)) 503 } 504 505 // GetDefault returns a default value of the field type 506 func (fps *LogCondition_FieldSubPath) GetDefault() interface{} { 507 return fps.subPath.GetDefault() 508 } 509 510 func (fps *LogCondition_FieldSubPath) ClearValue(item *LogCondition) { 511 if item != nil { 512 switch fps.selector { 513 case LogCondition_FieldPathSelectorMetadata: 514 fps.subPath.ClearValueRaw(item.Metadata) 515 case LogCondition_FieldPathSelectorSpec: 516 fps.subPath.ClearValueRaw(item.Spec) 517 case LogCondition_FieldPathSelectorInternal: 518 fps.subPath.ClearValueRaw(item.Internal) 519 case LogCondition_FieldPathSelectorTemplateSource: 520 fps.subPath.ClearValueRaw(item.TemplateSource) 521 default: 522 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fps.selector)) 523 } 524 } 525 } 526 527 func (fps *LogCondition_FieldSubPath) ClearValueRaw(item proto.Message) { 528 fps.ClearValue(item.(*LogCondition)) 529 } 530 531 // IsLeaf - whether field path is holds simple value 532 func (fps *LogCondition_FieldSubPath) IsLeaf() bool { 533 return fps.subPath.IsLeaf() 534 } 535 536 func (fps *LogCondition_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 537 iPaths := []gotenobject.FieldPath{&LogCondition_FieldTerminalPath{selector: fps.selector}} 538 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 539 return iPaths 540 } 541 542 func (fps *LogCondition_FieldSubPath) WithIValue(value interface{}) LogCondition_FieldPathValue { 543 return &LogCondition_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 544 } 545 546 func (fps *LogCondition_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 547 return fps.WithIValue(value) 548 } 549 550 func (fps *LogCondition_FieldSubPath) WithIArrayOfValues(values interface{}) LogCondition_FieldPathArrayOfValues { 551 return &LogCondition_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 552 } 553 554 func (fps *LogCondition_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 555 return fps.WithIArrayOfValues(values) 556 } 557 558 func (fps *LogCondition_FieldSubPath) WithIArrayItemValue(value interface{}) LogCondition_FieldPathArrayItemValue { 559 return &LogCondition_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 560 } 561 562 func (fps *LogCondition_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 563 return fps.WithIArrayItemValue(value) 564 } 565 566 // LogCondition_FieldPathValue allows storing values for LogCondition fields according to their type 567 type LogCondition_FieldPathValue interface { 568 LogCondition_FieldPath 569 gotenobject.FieldPathValue 570 SetTo(target **LogCondition) 571 CompareWith(*LogCondition) (cmp int, comparable bool) 572 } 573 574 func ParseLogCondition_FieldPathValue(pathStr, valueStr string) (LogCondition_FieldPathValue, error) { 575 fp, err := ParseLogCondition_FieldPath(pathStr) 576 if err != nil { 577 return nil, err 578 } 579 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 580 if err != nil { 581 return nil, status.Errorf(codes.InvalidArgument, "error parsing LogCondition field path value from %s: %v", valueStr, err) 582 } 583 return fpv.(LogCondition_FieldPathValue), nil 584 } 585 586 func MustParseLogCondition_FieldPathValue(pathStr, valueStr string) LogCondition_FieldPathValue { 587 fpv, err := ParseLogCondition_FieldPathValue(pathStr, valueStr) 588 if err != nil { 589 panic(err) 590 } 591 return fpv 592 } 593 594 type LogCondition_FieldTerminalPathValue struct { 595 LogCondition_FieldTerminalPath 596 value interface{} 597 } 598 599 var _ LogCondition_FieldPathValue = (*LogCondition_FieldTerminalPathValue)(nil) 600 601 // GetRawValue returns raw value stored under selected path for 'LogCondition' as interface{} 602 func (fpv *LogCondition_FieldTerminalPathValue) GetRawValue() interface{} { 603 return fpv.value 604 } 605 func (fpv *LogCondition_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 606 res, ok := fpv.value.(*Name) 607 return res, ok 608 } 609 func (fpv *LogCondition_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 610 res, ok := fpv.value.(*meta.Meta) 611 return res, ok 612 } 613 func (fpv *LogCondition_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) { 614 res, ok := fpv.value.(string) 615 return res, ok 616 } 617 func (fpv *LogCondition_FieldTerminalPathValue) AsDescriptionValue() (string, bool) { 618 res, ok := fpv.value.(string) 619 return res, ok 620 } 621 func (fpv *LogCondition_FieldTerminalPathValue) AsSupportingDocsValue() ([]*document.Reference, bool) { 622 res, ok := fpv.value.([]*document.Reference) 623 return res, ok 624 } 625 func (fpv *LogCondition_FieldTerminalPathValue) AsSpecValue() (*rcommon.LogCndSpec, bool) { 626 res, ok := fpv.value.(*rcommon.LogCndSpec) 627 return res, ok 628 } 629 func (fpv *LogCondition_FieldTerminalPathValue) AsInternalValue() (*LogCondition_Internal, bool) { 630 res, ok := fpv.value.(*LogCondition_Internal) 631 return res, ok 632 } 633 func (fpv *LogCondition_FieldTerminalPathValue) AsTemplateSourceValue() (*LogCondition_TemplateSource, bool) { 634 res, ok := fpv.value.(*LogCondition_TemplateSource) 635 return res, ok 636 } 637 638 // SetTo stores value for selected field for object LogCondition 639 func (fpv *LogCondition_FieldTerminalPathValue) SetTo(target **LogCondition) { 640 if *target == nil { 641 *target = new(LogCondition) 642 } 643 switch fpv.selector { 644 case LogCondition_FieldPathSelectorName: 645 (*target).Name = fpv.value.(*Name) 646 case LogCondition_FieldPathSelectorMetadata: 647 (*target).Metadata = fpv.value.(*meta.Meta) 648 case LogCondition_FieldPathSelectorDisplayName: 649 (*target).DisplayName = fpv.value.(string) 650 case LogCondition_FieldPathSelectorDescription: 651 (*target).Description = fpv.value.(string) 652 case LogCondition_FieldPathSelectorSupportingDocs: 653 (*target).SupportingDocs = fpv.value.([]*document.Reference) 654 case LogCondition_FieldPathSelectorSpec: 655 (*target).Spec = fpv.value.(*rcommon.LogCndSpec) 656 case LogCondition_FieldPathSelectorInternal: 657 (*target).Internal = fpv.value.(*LogCondition_Internal) 658 case LogCondition_FieldPathSelectorTemplateSource: 659 (*target).TemplateSource = fpv.value.(*LogCondition_TemplateSource) 660 default: 661 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fpv.selector)) 662 } 663 } 664 665 func (fpv *LogCondition_FieldTerminalPathValue) SetToRaw(target proto.Message) { 666 typedObject := target.(*LogCondition) 667 fpv.SetTo(&typedObject) 668 } 669 670 // CompareWith compares value in the 'LogCondition_FieldTerminalPathValue' with the value under path in 'LogCondition'. 671 func (fpv *LogCondition_FieldTerminalPathValue) CompareWith(source *LogCondition) (int, bool) { 672 switch fpv.selector { 673 case LogCondition_FieldPathSelectorName: 674 leftValue := fpv.value.(*Name) 675 rightValue := source.GetName() 676 if leftValue == nil { 677 if rightValue != nil { 678 return -1, true 679 } 680 return 0, true 681 } 682 if rightValue == nil { 683 return 1, true 684 } 685 if leftValue.String() == rightValue.String() { 686 return 0, true 687 } else if leftValue.String() < rightValue.String() { 688 return -1, true 689 } else { 690 return 1, true 691 } 692 case LogCondition_FieldPathSelectorMetadata: 693 return 0, false 694 case LogCondition_FieldPathSelectorDisplayName: 695 leftValue := fpv.value.(string) 696 rightValue := source.GetDisplayName() 697 if (leftValue) == (rightValue) { 698 return 0, true 699 } else if (leftValue) < (rightValue) { 700 return -1, true 701 } else { 702 return 1, true 703 } 704 case LogCondition_FieldPathSelectorDescription: 705 leftValue := fpv.value.(string) 706 rightValue := source.GetDescription() 707 if (leftValue) == (rightValue) { 708 return 0, true 709 } else if (leftValue) < (rightValue) { 710 return -1, true 711 } else { 712 return 1, true 713 } 714 case LogCondition_FieldPathSelectorSupportingDocs: 715 return 0, false 716 case LogCondition_FieldPathSelectorSpec: 717 return 0, false 718 case LogCondition_FieldPathSelectorInternal: 719 return 0, false 720 case LogCondition_FieldPathSelectorTemplateSource: 721 return 0, false 722 default: 723 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fpv.selector)) 724 } 725 } 726 727 func (fpv *LogCondition_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 728 return fpv.CompareWith(source.(*LogCondition)) 729 } 730 731 type LogCondition_FieldSubPathValue struct { 732 LogCondition_FieldPath 733 subPathValue gotenobject.FieldPathValue 734 } 735 736 var _ LogCondition_FieldPathValue = (*LogCondition_FieldSubPathValue)(nil) 737 738 func (fpvs *LogCondition_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 739 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 740 return res, ok 741 } 742 func (fpvs *LogCondition_FieldSubPathValue) AsSpecPathValue() (rcommon.LogCndSpec_FieldPathValue, bool) { 743 res, ok := fpvs.subPathValue.(rcommon.LogCndSpec_FieldPathValue) 744 return res, ok 745 } 746 func (fpvs *LogCondition_FieldSubPathValue) AsInternalPathValue() (LogConditionInternal_FieldPathValue, bool) { 747 res, ok := fpvs.subPathValue.(LogConditionInternal_FieldPathValue) 748 return res, ok 749 } 750 func (fpvs *LogCondition_FieldSubPathValue) AsTemplateSourcePathValue() (LogConditionTemplateSource_FieldPathValue, bool) { 751 res, ok := fpvs.subPathValue.(LogConditionTemplateSource_FieldPathValue) 752 return res, ok 753 } 754 755 func (fpvs *LogCondition_FieldSubPathValue) SetTo(target **LogCondition) { 756 if *target == nil { 757 *target = new(LogCondition) 758 } 759 switch fpvs.Selector() { 760 case LogCondition_FieldPathSelectorMetadata: 761 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 762 case LogCondition_FieldPathSelectorSpec: 763 fpvs.subPathValue.(rcommon.LogCndSpec_FieldPathValue).SetTo(&(*target).Spec) 764 case LogCondition_FieldPathSelectorInternal: 765 fpvs.subPathValue.(LogConditionInternal_FieldPathValue).SetTo(&(*target).Internal) 766 case LogCondition_FieldPathSelectorTemplateSource: 767 fpvs.subPathValue.(LogConditionTemplateSource_FieldPathValue).SetTo(&(*target).TemplateSource) 768 default: 769 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fpvs.Selector())) 770 } 771 } 772 773 func (fpvs *LogCondition_FieldSubPathValue) SetToRaw(target proto.Message) { 774 typedObject := target.(*LogCondition) 775 fpvs.SetTo(&typedObject) 776 } 777 778 func (fpvs *LogCondition_FieldSubPathValue) GetRawValue() interface{} { 779 return fpvs.subPathValue.GetRawValue() 780 } 781 782 func (fpvs *LogCondition_FieldSubPathValue) CompareWith(source *LogCondition) (int, bool) { 783 switch fpvs.Selector() { 784 case LogCondition_FieldPathSelectorMetadata: 785 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 786 case LogCondition_FieldPathSelectorSpec: 787 return fpvs.subPathValue.(rcommon.LogCndSpec_FieldPathValue).CompareWith(source.GetSpec()) 788 case LogCondition_FieldPathSelectorInternal: 789 return fpvs.subPathValue.(LogConditionInternal_FieldPathValue).CompareWith(source.GetInternal()) 790 case LogCondition_FieldPathSelectorTemplateSource: 791 return fpvs.subPathValue.(LogConditionTemplateSource_FieldPathValue).CompareWith(source.GetTemplateSource()) 792 default: 793 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fpvs.Selector())) 794 } 795 } 796 797 func (fpvs *LogCondition_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 798 return fpvs.CompareWith(source.(*LogCondition)) 799 } 800 801 // LogCondition_FieldPathArrayItemValue allows storing single item in Path-specific values for LogCondition according to their type 802 // Present only for array (repeated) types. 803 type LogCondition_FieldPathArrayItemValue interface { 804 gotenobject.FieldPathArrayItemValue 805 LogCondition_FieldPath 806 ContainsValue(*LogCondition) bool 807 } 808 809 // ParseLogCondition_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 810 func ParseLogCondition_FieldPathArrayItemValue(pathStr, valueStr string) (LogCondition_FieldPathArrayItemValue, error) { 811 fp, err := ParseLogCondition_FieldPath(pathStr) 812 if err != nil { 813 return nil, err 814 } 815 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 816 if err != nil { 817 return nil, status.Errorf(codes.InvalidArgument, "error parsing LogCondition field path array item value from %s: %v", valueStr, err) 818 } 819 return fpaiv.(LogCondition_FieldPathArrayItemValue), nil 820 } 821 822 func MustParseLogCondition_FieldPathArrayItemValue(pathStr, valueStr string) LogCondition_FieldPathArrayItemValue { 823 fpaiv, err := ParseLogCondition_FieldPathArrayItemValue(pathStr, valueStr) 824 if err != nil { 825 panic(err) 826 } 827 return fpaiv 828 } 829 830 type LogCondition_FieldTerminalPathArrayItemValue struct { 831 LogCondition_FieldTerminalPath 832 value interface{} 833 } 834 835 var _ LogCondition_FieldPathArrayItemValue = (*LogCondition_FieldTerminalPathArrayItemValue)(nil) 836 837 // GetRawValue returns stored element value for array in object LogCondition as interface{} 838 func (fpaiv *LogCondition_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 839 return fpaiv.value 840 } 841 func (fpaiv *LogCondition_FieldTerminalPathArrayItemValue) AsSupportingDocsItemValue() (*document.Reference, bool) { 842 res, ok := fpaiv.value.(*document.Reference) 843 return res, ok 844 } 845 846 func (fpaiv *LogCondition_FieldTerminalPathArrayItemValue) GetSingle(source *LogCondition) (interface{}, bool) { 847 return nil, false 848 } 849 850 func (fpaiv *LogCondition_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 851 return fpaiv.GetSingle(source.(*LogCondition)) 852 } 853 854 // Contains returns a boolean indicating if value that is being held is present in given 'LogCondition' 855 func (fpaiv *LogCondition_FieldTerminalPathArrayItemValue) ContainsValue(source *LogCondition) bool { 856 slice := fpaiv.LogCondition_FieldTerminalPath.Get(source) 857 for _, v := range slice { 858 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 859 if proto.Equal(asProtoMsg, v.(proto.Message)) { 860 return true 861 } 862 } else if reflect.DeepEqual(v, fpaiv.value) { 863 return true 864 } 865 } 866 return false 867 } 868 869 type LogCondition_FieldSubPathArrayItemValue struct { 870 LogCondition_FieldPath 871 subPathItemValue gotenobject.FieldPathArrayItemValue 872 } 873 874 // GetRawValue returns stored array item value 875 func (fpaivs *LogCondition_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 876 return fpaivs.subPathItemValue.GetRawItemValue() 877 } 878 func (fpaivs *LogCondition_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 879 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 880 return res, ok 881 } 882 func (fpaivs *LogCondition_FieldSubPathArrayItemValue) AsSpecPathItemValue() (rcommon.LogCndSpec_FieldPathArrayItemValue, bool) { 883 res, ok := fpaivs.subPathItemValue.(rcommon.LogCndSpec_FieldPathArrayItemValue) 884 return res, ok 885 } 886 func (fpaivs *LogCondition_FieldSubPathArrayItemValue) AsInternalPathItemValue() (LogConditionInternal_FieldPathArrayItemValue, bool) { 887 res, ok := fpaivs.subPathItemValue.(LogConditionInternal_FieldPathArrayItemValue) 888 return res, ok 889 } 890 func (fpaivs *LogCondition_FieldSubPathArrayItemValue) AsTemplateSourcePathItemValue() (LogConditionTemplateSource_FieldPathArrayItemValue, bool) { 891 res, ok := fpaivs.subPathItemValue.(LogConditionTemplateSource_FieldPathArrayItemValue) 892 return res, ok 893 } 894 895 // Contains returns a boolean indicating if value that is being held is present in given 'LogCondition' 896 func (fpaivs *LogCondition_FieldSubPathArrayItemValue) ContainsValue(source *LogCondition) bool { 897 switch fpaivs.Selector() { 898 case LogCondition_FieldPathSelectorMetadata: 899 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 900 case LogCondition_FieldPathSelectorSpec: 901 return fpaivs.subPathItemValue.(rcommon.LogCndSpec_FieldPathArrayItemValue).ContainsValue(source.GetSpec()) 902 case LogCondition_FieldPathSelectorInternal: 903 return fpaivs.subPathItemValue.(LogConditionInternal_FieldPathArrayItemValue).ContainsValue(source.GetInternal()) 904 case LogCondition_FieldPathSelectorTemplateSource: 905 return fpaivs.subPathItemValue.(LogConditionTemplateSource_FieldPathArrayItemValue).ContainsValue(source.GetTemplateSource()) 906 default: 907 panic(fmt.Sprintf("Invalid selector for LogCondition: %d", fpaivs.Selector())) 908 } 909 } 910 911 // LogCondition_FieldPathArrayOfValues allows storing slice of values for LogCondition fields according to their type 912 type LogCondition_FieldPathArrayOfValues interface { 913 gotenobject.FieldPathArrayOfValues 914 LogCondition_FieldPath 915 } 916 917 func ParseLogCondition_FieldPathArrayOfValues(pathStr, valuesStr string) (LogCondition_FieldPathArrayOfValues, error) { 918 fp, err := ParseLogCondition_FieldPath(pathStr) 919 if err != nil { 920 return nil, err 921 } 922 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 923 if err != nil { 924 return nil, status.Errorf(codes.InvalidArgument, "error parsing LogCondition field path array of values from %s: %v", valuesStr, err) 925 } 926 return fpaov.(LogCondition_FieldPathArrayOfValues), nil 927 } 928 929 func MustParseLogCondition_FieldPathArrayOfValues(pathStr, valuesStr string) LogCondition_FieldPathArrayOfValues { 930 fpaov, err := ParseLogCondition_FieldPathArrayOfValues(pathStr, valuesStr) 931 if err != nil { 932 panic(err) 933 } 934 return fpaov 935 } 936 937 type LogCondition_FieldTerminalPathArrayOfValues struct { 938 LogCondition_FieldTerminalPath 939 values interface{} 940 } 941 942 var _ LogCondition_FieldPathArrayOfValues = (*LogCondition_FieldTerminalPathArrayOfValues)(nil) 943 944 func (fpaov *LogCondition_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 945 switch fpaov.selector { 946 case LogCondition_FieldPathSelectorName: 947 for _, v := range fpaov.values.([]*Name) { 948 values = append(values, v) 949 } 950 case LogCondition_FieldPathSelectorMetadata: 951 for _, v := range fpaov.values.([]*meta.Meta) { 952 values = append(values, v) 953 } 954 case LogCondition_FieldPathSelectorDisplayName: 955 for _, v := range fpaov.values.([]string) { 956 values = append(values, v) 957 } 958 case LogCondition_FieldPathSelectorDescription: 959 for _, v := range fpaov.values.([]string) { 960 values = append(values, v) 961 } 962 case LogCondition_FieldPathSelectorSupportingDocs: 963 for _, v := range fpaov.values.([][]*document.Reference) { 964 values = append(values, v) 965 } 966 case LogCondition_FieldPathSelectorSpec: 967 for _, v := range fpaov.values.([]*rcommon.LogCndSpec) { 968 values = append(values, v) 969 } 970 case LogCondition_FieldPathSelectorInternal: 971 for _, v := range fpaov.values.([]*LogCondition_Internal) { 972 values = append(values, v) 973 } 974 case LogCondition_FieldPathSelectorTemplateSource: 975 for _, v := range fpaov.values.([]*LogCondition_TemplateSource) { 976 values = append(values, v) 977 } 978 } 979 return 980 } 981 func (fpaov *LogCondition_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 982 res, ok := fpaov.values.([]*Name) 983 return res, ok 984 } 985 func (fpaov *LogCondition_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 986 res, ok := fpaov.values.([]*meta.Meta) 987 return res, ok 988 } 989 func (fpaov *LogCondition_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) { 990 res, ok := fpaov.values.([]string) 991 return res, ok 992 } 993 func (fpaov *LogCondition_FieldTerminalPathArrayOfValues) AsDescriptionArrayOfValues() ([]string, bool) { 994 res, ok := fpaov.values.([]string) 995 return res, ok 996 } 997 func (fpaov *LogCondition_FieldTerminalPathArrayOfValues) AsSupportingDocsArrayOfValues() ([][]*document.Reference, bool) { 998 res, ok := fpaov.values.([][]*document.Reference) 999 return res, ok 1000 } 1001 func (fpaov *LogCondition_FieldTerminalPathArrayOfValues) AsSpecArrayOfValues() ([]*rcommon.LogCndSpec, bool) { 1002 res, ok := fpaov.values.([]*rcommon.LogCndSpec) 1003 return res, ok 1004 } 1005 func (fpaov *LogCondition_FieldTerminalPathArrayOfValues) AsInternalArrayOfValues() ([]*LogCondition_Internal, bool) { 1006 res, ok := fpaov.values.([]*LogCondition_Internal) 1007 return res, ok 1008 } 1009 func (fpaov *LogCondition_FieldTerminalPathArrayOfValues) AsTemplateSourceArrayOfValues() ([]*LogCondition_TemplateSource, bool) { 1010 res, ok := fpaov.values.([]*LogCondition_TemplateSource) 1011 return res, ok 1012 } 1013 1014 type LogCondition_FieldSubPathArrayOfValues struct { 1015 LogCondition_FieldPath 1016 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 1017 } 1018 1019 var _ LogCondition_FieldPathArrayOfValues = (*LogCondition_FieldSubPathArrayOfValues)(nil) 1020 1021 func (fpsaov *LogCondition_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 1022 return fpsaov.subPathArrayOfValues.GetRawValues() 1023 } 1024 func (fpsaov *LogCondition_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 1025 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 1026 return res, ok 1027 } 1028 func (fpsaov *LogCondition_FieldSubPathArrayOfValues) AsSpecPathArrayOfValues() (rcommon.LogCndSpec_FieldPathArrayOfValues, bool) { 1029 res, ok := fpsaov.subPathArrayOfValues.(rcommon.LogCndSpec_FieldPathArrayOfValues) 1030 return res, ok 1031 } 1032 func (fpsaov *LogCondition_FieldSubPathArrayOfValues) AsInternalPathArrayOfValues() (LogConditionInternal_FieldPathArrayOfValues, bool) { 1033 res, ok := fpsaov.subPathArrayOfValues.(LogConditionInternal_FieldPathArrayOfValues) 1034 return res, ok 1035 } 1036 func (fpsaov *LogCondition_FieldSubPathArrayOfValues) AsTemplateSourcePathArrayOfValues() (LogConditionTemplateSource_FieldPathArrayOfValues, bool) { 1037 res, ok := fpsaov.subPathArrayOfValues.(LogConditionTemplateSource_FieldPathArrayOfValues) 1038 return res, ok 1039 } 1040 1041 // FieldPath provides implementation to handle 1042 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 1043 type LogConditionInternal_FieldPath interface { 1044 gotenobject.FieldPath 1045 Selector() LogConditionInternal_FieldPathSelector 1046 Get(source *LogCondition_Internal) []interface{} 1047 GetSingle(source *LogCondition_Internal) (interface{}, bool) 1048 ClearValue(item *LogCondition_Internal) 1049 1050 // Those methods build corresponding LogConditionInternal_FieldPathValue 1051 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1052 WithIValue(value interface{}) LogConditionInternal_FieldPathValue 1053 WithIArrayOfValues(values interface{}) LogConditionInternal_FieldPathArrayOfValues 1054 WithIArrayItemValue(value interface{}) LogConditionInternal_FieldPathArrayItemValue 1055 } 1056 1057 type LogConditionInternal_FieldPathSelector int32 1058 1059 const ( 1060 LogConditionInternal_FieldPathSelectorAlertingLocation LogConditionInternal_FieldPathSelector = 0 1061 ) 1062 1063 func (s LogConditionInternal_FieldPathSelector) String() string { 1064 switch s { 1065 case LogConditionInternal_FieldPathSelectorAlertingLocation: 1066 return "alerting_location" 1067 default: 1068 panic(fmt.Sprintf("Invalid selector for LogCondition_Internal: %d", s)) 1069 } 1070 } 1071 1072 func BuildLogConditionInternal_FieldPath(fp gotenobject.RawFieldPath) (LogConditionInternal_FieldPath, error) { 1073 if len(fp) == 0 { 1074 return nil, status.Error(codes.InvalidArgument, "empty field path for object LogCondition_Internal") 1075 } 1076 if len(fp) == 1 { 1077 switch fp[0] { 1078 case "alerting_location", "alertingLocation", "alerting-location": 1079 return &LogConditionInternal_FieldTerminalPath{selector: LogConditionInternal_FieldPathSelectorAlertingLocation}, nil 1080 } 1081 } 1082 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object LogCondition_Internal", fp) 1083 } 1084 1085 func ParseLogConditionInternal_FieldPath(rawField string) (LogConditionInternal_FieldPath, error) { 1086 fp, err := gotenobject.ParseRawFieldPath(rawField) 1087 if err != nil { 1088 return nil, err 1089 } 1090 return BuildLogConditionInternal_FieldPath(fp) 1091 } 1092 1093 func MustParseLogConditionInternal_FieldPath(rawField string) LogConditionInternal_FieldPath { 1094 fp, err := ParseLogConditionInternal_FieldPath(rawField) 1095 if err != nil { 1096 panic(err) 1097 } 1098 return fp 1099 } 1100 1101 type LogConditionInternal_FieldTerminalPath struct { 1102 selector LogConditionInternal_FieldPathSelector 1103 } 1104 1105 var _ LogConditionInternal_FieldPath = (*LogConditionInternal_FieldTerminalPath)(nil) 1106 1107 func (fp *LogConditionInternal_FieldTerminalPath) Selector() LogConditionInternal_FieldPathSelector { 1108 return fp.selector 1109 } 1110 1111 // String returns path representation in proto convention 1112 func (fp *LogConditionInternal_FieldTerminalPath) String() string { 1113 return fp.selector.String() 1114 } 1115 1116 // JSONString returns path representation is JSON convention 1117 func (fp *LogConditionInternal_FieldTerminalPath) JSONString() string { 1118 return strcase.ToLowerCamel(fp.String()) 1119 } 1120 1121 // Get returns all values pointed by specific field from source LogCondition_Internal 1122 func (fp *LogConditionInternal_FieldTerminalPath) Get(source *LogCondition_Internal) (values []interface{}) { 1123 if source != nil { 1124 switch fp.selector { 1125 case LogConditionInternal_FieldPathSelectorAlertingLocation: 1126 values = append(values, source.AlertingLocation) 1127 default: 1128 panic(fmt.Sprintf("Invalid selector for LogCondition_Internal: %d", fp.selector)) 1129 } 1130 } 1131 return 1132 } 1133 1134 func (fp *LogConditionInternal_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1135 return fp.Get(source.(*LogCondition_Internal)) 1136 } 1137 1138 // GetSingle returns value pointed by specific field of from source LogCondition_Internal 1139 func (fp *LogConditionInternal_FieldTerminalPath) GetSingle(source *LogCondition_Internal) (interface{}, bool) { 1140 switch fp.selector { 1141 case LogConditionInternal_FieldPathSelectorAlertingLocation: 1142 return source.GetAlertingLocation(), source != nil 1143 default: 1144 panic(fmt.Sprintf("Invalid selector for LogCondition_Internal: %d", fp.selector)) 1145 } 1146 } 1147 1148 func (fp *LogConditionInternal_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1149 return fp.GetSingle(source.(*LogCondition_Internal)) 1150 } 1151 1152 // GetDefault returns a default value of the field type 1153 func (fp *LogConditionInternal_FieldTerminalPath) GetDefault() interface{} { 1154 switch fp.selector { 1155 case LogConditionInternal_FieldPathSelectorAlertingLocation: 1156 return rcommon.PolicySpec_UNDEFINED 1157 default: 1158 panic(fmt.Sprintf("Invalid selector for LogCondition_Internal: %d", fp.selector)) 1159 } 1160 } 1161 1162 func (fp *LogConditionInternal_FieldTerminalPath) ClearValue(item *LogCondition_Internal) { 1163 if item != nil { 1164 switch fp.selector { 1165 case LogConditionInternal_FieldPathSelectorAlertingLocation: 1166 item.AlertingLocation = rcommon.PolicySpec_UNDEFINED 1167 default: 1168 panic(fmt.Sprintf("Invalid selector for LogCondition_Internal: %d", fp.selector)) 1169 } 1170 } 1171 } 1172 1173 func (fp *LogConditionInternal_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1174 fp.ClearValue(item.(*LogCondition_Internal)) 1175 } 1176 1177 // IsLeaf - whether field path is holds simple value 1178 func (fp *LogConditionInternal_FieldTerminalPath) IsLeaf() bool { 1179 return fp.selector == LogConditionInternal_FieldPathSelectorAlertingLocation 1180 } 1181 1182 func (fp *LogConditionInternal_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1183 return []gotenobject.FieldPath{fp} 1184 } 1185 1186 func (fp *LogConditionInternal_FieldTerminalPath) WithIValue(value interface{}) LogConditionInternal_FieldPathValue { 1187 switch fp.selector { 1188 case LogConditionInternal_FieldPathSelectorAlertingLocation: 1189 return &LogConditionInternal_FieldTerminalPathValue{LogConditionInternal_FieldTerminalPath: *fp, value: value.(rcommon.PolicySpec_ProcessingLocation)} 1190 default: 1191 panic(fmt.Sprintf("Invalid selector for LogCondition_Internal: %d", fp.selector)) 1192 } 1193 } 1194 1195 func (fp *LogConditionInternal_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1196 return fp.WithIValue(value) 1197 } 1198 1199 func (fp *LogConditionInternal_FieldTerminalPath) WithIArrayOfValues(values interface{}) LogConditionInternal_FieldPathArrayOfValues { 1200 fpaov := &LogConditionInternal_FieldTerminalPathArrayOfValues{LogConditionInternal_FieldTerminalPath: *fp} 1201 switch fp.selector { 1202 case LogConditionInternal_FieldPathSelectorAlertingLocation: 1203 return &LogConditionInternal_FieldTerminalPathArrayOfValues{LogConditionInternal_FieldTerminalPath: *fp, values: values.([]rcommon.PolicySpec_ProcessingLocation)} 1204 default: 1205 panic(fmt.Sprintf("Invalid selector for LogCondition_Internal: %d", fp.selector)) 1206 } 1207 return fpaov 1208 } 1209 1210 func (fp *LogConditionInternal_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1211 return fp.WithIArrayOfValues(values) 1212 } 1213 1214 func (fp *LogConditionInternal_FieldTerminalPath) WithIArrayItemValue(value interface{}) LogConditionInternal_FieldPathArrayItemValue { 1215 switch fp.selector { 1216 default: 1217 panic(fmt.Sprintf("Invalid selector for LogCondition_Internal: %d", fp.selector)) 1218 } 1219 } 1220 1221 func (fp *LogConditionInternal_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1222 return fp.WithIArrayItemValue(value) 1223 } 1224 1225 // LogConditionInternal_FieldPathValue allows storing values for Internal fields according to their type 1226 type LogConditionInternal_FieldPathValue interface { 1227 LogConditionInternal_FieldPath 1228 gotenobject.FieldPathValue 1229 SetTo(target **LogCondition_Internal) 1230 CompareWith(*LogCondition_Internal) (cmp int, comparable bool) 1231 } 1232 1233 func ParseLogConditionInternal_FieldPathValue(pathStr, valueStr string) (LogConditionInternal_FieldPathValue, error) { 1234 fp, err := ParseLogConditionInternal_FieldPath(pathStr) 1235 if err != nil { 1236 return nil, err 1237 } 1238 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1239 if err != nil { 1240 return nil, status.Errorf(codes.InvalidArgument, "error parsing Internal field path value from %s: %v", valueStr, err) 1241 } 1242 return fpv.(LogConditionInternal_FieldPathValue), nil 1243 } 1244 1245 func MustParseLogConditionInternal_FieldPathValue(pathStr, valueStr string) LogConditionInternal_FieldPathValue { 1246 fpv, err := ParseLogConditionInternal_FieldPathValue(pathStr, valueStr) 1247 if err != nil { 1248 panic(err) 1249 } 1250 return fpv 1251 } 1252 1253 type LogConditionInternal_FieldTerminalPathValue struct { 1254 LogConditionInternal_FieldTerminalPath 1255 value interface{} 1256 } 1257 1258 var _ LogConditionInternal_FieldPathValue = (*LogConditionInternal_FieldTerminalPathValue)(nil) 1259 1260 // GetRawValue returns raw value stored under selected path for 'Internal' as interface{} 1261 func (fpv *LogConditionInternal_FieldTerminalPathValue) GetRawValue() interface{} { 1262 return fpv.value 1263 } 1264 func (fpv *LogConditionInternal_FieldTerminalPathValue) AsAlertingLocationValue() (rcommon.PolicySpec_ProcessingLocation, bool) { 1265 res, ok := fpv.value.(rcommon.PolicySpec_ProcessingLocation) 1266 return res, ok 1267 } 1268 1269 // SetTo stores value for selected field for object Internal 1270 func (fpv *LogConditionInternal_FieldTerminalPathValue) SetTo(target **LogCondition_Internal) { 1271 if *target == nil { 1272 *target = new(LogCondition_Internal) 1273 } 1274 switch fpv.selector { 1275 case LogConditionInternal_FieldPathSelectorAlertingLocation: 1276 (*target).AlertingLocation = fpv.value.(rcommon.PolicySpec_ProcessingLocation) 1277 default: 1278 panic(fmt.Sprintf("Invalid selector for LogCondition_Internal: %d", fpv.selector)) 1279 } 1280 } 1281 1282 func (fpv *LogConditionInternal_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1283 typedObject := target.(*LogCondition_Internal) 1284 fpv.SetTo(&typedObject) 1285 } 1286 1287 // CompareWith compares value in the 'LogConditionInternal_FieldTerminalPathValue' with the value under path in 'LogCondition_Internal'. 1288 func (fpv *LogConditionInternal_FieldTerminalPathValue) CompareWith(source *LogCondition_Internal) (int, bool) { 1289 switch fpv.selector { 1290 case LogConditionInternal_FieldPathSelectorAlertingLocation: 1291 leftValue := fpv.value.(rcommon.PolicySpec_ProcessingLocation) 1292 rightValue := source.GetAlertingLocation() 1293 if (leftValue) == (rightValue) { 1294 return 0, true 1295 } else if (leftValue) < (rightValue) { 1296 return -1, true 1297 } else { 1298 return 1, true 1299 } 1300 default: 1301 panic(fmt.Sprintf("Invalid selector for LogCondition_Internal: %d", fpv.selector)) 1302 } 1303 } 1304 1305 func (fpv *LogConditionInternal_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1306 return fpv.CompareWith(source.(*LogCondition_Internal)) 1307 } 1308 1309 // LogConditionInternal_FieldPathArrayItemValue allows storing single item in Path-specific values for Internal according to their type 1310 // Present only for array (repeated) types. 1311 type LogConditionInternal_FieldPathArrayItemValue interface { 1312 gotenobject.FieldPathArrayItemValue 1313 LogConditionInternal_FieldPath 1314 ContainsValue(*LogCondition_Internal) bool 1315 } 1316 1317 // ParseLogConditionInternal_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1318 func ParseLogConditionInternal_FieldPathArrayItemValue(pathStr, valueStr string) (LogConditionInternal_FieldPathArrayItemValue, error) { 1319 fp, err := ParseLogConditionInternal_FieldPath(pathStr) 1320 if err != nil { 1321 return nil, err 1322 } 1323 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1324 if err != nil { 1325 return nil, status.Errorf(codes.InvalidArgument, "error parsing Internal field path array item value from %s: %v", valueStr, err) 1326 } 1327 return fpaiv.(LogConditionInternal_FieldPathArrayItemValue), nil 1328 } 1329 1330 func MustParseLogConditionInternal_FieldPathArrayItemValue(pathStr, valueStr string) LogConditionInternal_FieldPathArrayItemValue { 1331 fpaiv, err := ParseLogConditionInternal_FieldPathArrayItemValue(pathStr, valueStr) 1332 if err != nil { 1333 panic(err) 1334 } 1335 return fpaiv 1336 } 1337 1338 type LogConditionInternal_FieldTerminalPathArrayItemValue struct { 1339 LogConditionInternal_FieldTerminalPath 1340 value interface{} 1341 } 1342 1343 var _ LogConditionInternal_FieldPathArrayItemValue = (*LogConditionInternal_FieldTerminalPathArrayItemValue)(nil) 1344 1345 // GetRawValue returns stored element value for array in object LogCondition_Internal as interface{} 1346 func (fpaiv *LogConditionInternal_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1347 return fpaiv.value 1348 } 1349 1350 func (fpaiv *LogConditionInternal_FieldTerminalPathArrayItemValue) GetSingle(source *LogCondition_Internal) (interface{}, bool) { 1351 return nil, false 1352 } 1353 1354 func (fpaiv *LogConditionInternal_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1355 return fpaiv.GetSingle(source.(*LogCondition_Internal)) 1356 } 1357 1358 // Contains returns a boolean indicating if value that is being held is present in given 'Internal' 1359 func (fpaiv *LogConditionInternal_FieldTerminalPathArrayItemValue) ContainsValue(source *LogCondition_Internal) bool { 1360 slice := fpaiv.LogConditionInternal_FieldTerminalPath.Get(source) 1361 for _, v := range slice { 1362 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1363 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1364 return true 1365 } 1366 } else if reflect.DeepEqual(v, fpaiv.value) { 1367 return true 1368 } 1369 } 1370 return false 1371 } 1372 1373 // LogConditionInternal_FieldPathArrayOfValues allows storing slice of values for Internal fields according to their type 1374 type LogConditionInternal_FieldPathArrayOfValues interface { 1375 gotenobject.FieldPathArrayOfValues 1376 LogConditionInternal_FieldPath 1377 } 1378 1379 func ParseLogConditionInternal_FieldPathArrayOfValues(pathStr, valuesStr string) (LogConditionInternal_FieldPathArrayOfValues, error) { 1380 fp, err := ParseLogConditionInternal_FieldPath(pathStr) 1381 if err != nil { 1382 return nil, err 1383 } 1384 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1385 if err != nil { 1386 return nil, status.Errorf(codes.InvalidArgument, "error parsing Internal field path array of values from %s: %v", valuesStr, err) 1387 } 1388 return fpaov.(LogConditionInternal_FieldPathArrayOfValues), nil 1389 } 1390 1391 func MustParseLogConditionInternal_FieldPathArrayOfValues(pathStr, valuesStr string) LogConditionInternal_FieldPathArrayOfValues { 1392 fpaov, err := ParseLogConditionInternal_FieldPathArrayOfValues(pathStr, valuesStr) 1393 if err != nil { 1394 panic(err) 1395 } 1396 return fpaov 1397 } 1398 1399 type LogConditionInternal_FieldTerminalPathArrayOfValues struct { 1400 LogConditionInternal_FieldTerminalPath 1401 values interface{} 1402 } 1403 1404 var _ LogConditionInternal_FieldPathArrayOfValues = (*LogConditionInternal_FieldTerminalPathArrayOfValues)(nil) 1405 1406 func (fpaov *LogConditionInternal_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1407 switch fpaov.selector { 1408 case LogConditionInternal_FieldPathSelectorAlertingLocation: 1409 for _, v := range fpaov.values.([]rcommon.PolicySpec_ProcessingLocation) { 1410 values = append(values, v) 1411 } 1412 } 1413 return 1414 } 1415 func (fpaov *LogConditionInternal_FieldTerminalPathArrayOfValues) AsAlertingLocationArrayOfValues() ([]rcommon.PolicySpec_ProcessingLocation, bool) { 1416 res, ok := fpaov.values.([]rcommon.PolicySpec_ProcessingLocation) 1417 return res, ok 1418 } 1419 1420 // FieldPath provides implementation to handle 1421 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 1422 type LogConditionTemplateSource_FieldPath interface { 1423 gotenobject.FieldPath 1424 Selector() LogConditionTemplateSource_FieldPathSelector 1425 Get(source *LogCondition_TemplateSource) []interface{} 1426 GetSingle(source *LogCondition_TemplateSource) (interface{}, bool) 1427 ClearValue(item *LogCondition_TemplateSource) 1428 1429 // Those methods build corresponding LogConditionTemplateSource_FieldPathValue 1430 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1431 WithIValue(value interface{}) LogConditionTemplateSource_FieldPathValue 1432 WithIArrayOfValues(values interface{}) LogConditionTemplateSource_FieldPathArrayOfValues 1433 WithIArrayItemValue(value interface{}) LogConditionTemplateSource_FieldPathArrayItemValue 1434 } 1435 1436 type LogConditionTemplateSource_FieldPathSelector int32 1437 1438 const ( 1439 LogConditionTemplateSource_FieldPathSelectorTemplate LogConditionTemplateSource_FieldPathSelector = 0 1440 LogConditionTemplateSource_FieldPathSelectorUpdatedFields LogConditionTemplateSource_FieldPathSelector = 1 1441 ) 1442 1443 func (s LogConditionTemplateSource_FieldPathSelector) String() string { 1444 switch s { 1445 case LogConditionTemplateSource_FieldPathSelectorTemplate: 1446 return "template" 1447 case LogConditionTemplateSource_FieldPathSelectorUpdatedFields: 1448 return "updated_fields" 1449 default: 1450 panic(fmt.Sprintf("Invalid selector for LogCondition_TemplateSource: %d", s)) 1451 } 1452 } 1453 1454 func BuildLogConditionTemplateSource_FieldPath(fp gotenobject.RawFieldPath) (LogConditionTemplateSource_FieldPath, error) { 1455 if len(fp) == 0 { 1456 return nil, status.Error(codes.InvalidArgument, "empty field path for object LogCondition_TemplateSource") 1457 } 1458 if len(fp) == 1 { 1459 switch fp[0] { 1460 case "template": 1461 return &LogConditionTemplateSource_FieldTerminalPath{selector: LogConditionTemplateSource_FieldPathSelectorTemplate}, nil 1462 case "updated_fields", "updatedFields", "updated-fields": 1463 return &LogConditionTemplateSource_FieldTerminalPath{selector: LogConditionTemplateSource_FieldPathSelectorUpdatedFields}, nil 1464 } 1465 } 1466 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object LogCondition_TemplateSource", fp) 1467 } 1468 1469 func ParseLogConditionTemplateSource_FieldPath(rawField string) (LogConditionTemplateSource_FieldPath, error) { 1470 fp, err := gotenobject.ParseRawFieldPath(rawField) 1471 if err != nil { 1472 return nil, err 1473 } 1474 return BuildLogConditionTemplateSource_FieldPath(fp) 1475 } 1476 1477 func MustParseLogConditionTemplateSource_FieldPath(rawField string) LogConditionTemplateSource_FieldPath { 1478 fp, err := ParseLogConditionTemplateSource_FieldPath(rawField) 1479 if err != nil { 1480 panic(err) 1481 } 1482 return fp 1483 } 1484 1485 type LogConditionTemplateSource_FieldTerminalPath struct { 1486 selector LogConditionTemplateSource_FieldPathSelector 1487 } 1488 1489 var _ LogConditionTemplateSource_FieldPath = (*LogConditionTemplateSource_FieldTerminalPath)(nil) 1490 1491 func (fp *LogConditionTemplateSource_FieldTerminalPath) Selector() LogConditionTemplateSource_FieldPathSelector { 1492 return fp.selector 1493 } 1494 1495 // String returns path representation in proto convention 1496 func (fp *LogConditionTemplateSource_FieldTerminalPath) String() string { 1497 return fp.selector.String() 1498 } 1499 1500 // JSONString returns path representation is JSON convention 1501 func (fp *LogConditionTemplateSource_FieldTerminalPath) JSONString() string { 1502 return strcase.ToLowerCamel(fp.String()) 1503 } 1504 1505 // Get returns all values pointed by specific field from source LogCondition_TemplateSource 1506 func (fp *LogConditionTemplateSource_FieldTerminalPath) Get(source *LogCondition_TemplateSource) (values []interface{}) { 1507 if source != nil { 1508 switch fp.selector { 1509 case LogConditionTemplateSource_FieldPathSelectorTemplate: 1510 if source.Template != nil { 1511 values = append(values, source.Template) 1512 } 1513 case LogConditionTemplateSource_FieldPathSelectorUpdatedFields: 1514 if source.UpdatedFields != nil { 1515 values = append(values, source.UpdatedFields) 1516 } 1517 default: 1518 panic(fmt.Sprintf("Invalid selector for LogCondition_TemplateSource: %d", fp.selector)) 1519 } 1520 } 1521 return 1522 } 1523 1524 func (fp *LogConditionTemplateSource_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1525 return fp.Get(source.(*LogCondition_TemplateSource)) 1526 } 1527 1528 // GetSingle returns value pointed by specific field of from source LogCondition_TemplateSource 1529 func (fp *LogConditionTemplateSource_FieldTerminalPath) GetSingle(source *LogCondition_TemplateSource) (interface{}, bool) { 1530 switch fp.selector { 1531 case LogConditionTemplateSource_FieldPathSelectorTemplate: 1532 res := source.GetTemplate() 1533 return res, res != nil 1534 case LogConditionTemplateSource_FieldPathSelectorUpdatedFields: 1535 res := source.GetUpdatedFields() 1536 return res, res != nil 1537 default: 1538 panic(fmt.Sprintf("Invalid selector for LogCondition_TemplateSource: %d", fp.selector)) 1539 } 1540 } 1541 1542 func (fp *LogConditionTemplateSource_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1543 return fp.GetSingle(source.(*LogCondition_TemplateSource)) 1544 } 1545 1546 // GetDefault returns a default value of the field type 1547 func (fp *LogConditionTemplateSource_FieldTerminalPath) GetDefault() interface{} { 1548 switch fp.selector { 1549 case LogConditionTemplateSource_FieldPathSelectorTemplate: 1550 return (*log_condition_template.Reference)(nil) 1551 case LogConditionTemplateSource_FieldPathSelectorUpdatedFields: 1552 return (*fieldmaskpb.FieldMask)(nil) 1553 default: 1554 panic(fmt.Sprintf("Invalid selector for LogCondition_TemplateSource: %d", fp.selector)) 1555 } 1556 } 1557 1558 func (fp *LogConditionTemplateSource_FieldTerminalPath) ClearValue(item *LogCondition_TemplateSource) { 1559 if item != nil { 1560 switch fp.selector { 1561 case LogConditionTemplateSource_FieldPathSelectorTemplate: 1562 item.Template = nil 1563 case LogConditionTemplateSource_FieldPathSelectorUpdatedFields: 1564 item.UpdatedFields = nil 1565 default: 1566 panic(fmt.Sprintf("Invalid selector for LogCondition_TemplateSource: %d", fp.selector)) 1567 } 1568 } 1569 } 1570 1571 func (fp *LogConditionTemplateSource_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1572 fp.ClearValue(item.(*LogCondition_TemplateSource)) 1573 } 1574 1575 // IsLeaf - whether field path is holds simple value 1576 func (fp *LogConditionTemplateSource_FieldTerminalPath) IsLeaf() bool { 1577 return fp.selector == LogConditionTemplateSource_FieldPathSelectorTemplate || 1578 fp.selector == LogConditionTemplateSource_FieldPathSelectorUpdatedFields 1579 } 1580 1581 func (fp *LogConditionTemplateSource_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1582 return []gotenobject.FieldPath{fp} 1583 } 1584 1585 func (fp *LogConditionTemplateSource_FieldTerminalPath) WithIValue(value interface{}) LogConditionTemplateSource_FieldPathValue { 1586 switch fp.selector { 1587 case LogConditionTemplateSource_FieldPathSelectorTemplate: 1588 return &LogConditionTemplateSource_FieldTerminalPathValue{LogConditionTemplateSource_FieldTerminalPath: *fp, value: value.(*log_condition_template.Reference)} 1589 case LogConditionTemplateSource_FieldPathSelectorUpdatedFields: 1590 return &LogConditionTemplateSource_FieldTerminalPathValue{LogConditionTemplateSource_FieldTerminalPath: *fp, value: value.(*fieldmaskpb.FieldMask)} 1591 default: 1592 panic(fmt.Sprintf("Invalid selector for LogCondition_TemplateSource: %d", fp.selector)) 1593 } 1594 } 1595 1596 func (fp *LogConditionTemplateSource_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1597 return fp.WithIValue(value) 1598 } 1599 1600 func (fp *LogConditionTemplateSource_FieldTerminalPath) WithIArrayOfValues(values interface{}) LogConditionTemplateSource_FieldPathArrayOfValues { 1601 fpaov := &LogConditionTemplateSource_FieldTerminalPathArrayOfValues{LogConditionTemplateSource_FieldTerminalPath: *fp} 1602 switch fp.selector { 1603 case LogConditionTemplateSource_FieldPathSelectorTemplate: 1604 return &LogConditionTemplateSource_FieldTerminalPathArrayOfValues{LogConditionTemplateSource_FieldTerminalPath: *fp, values: values.([]*log_condition_template.Reference)} 1605 case LogConditionTemplateSource_FieldPathSelectorUpdatedFields: 1606 return &LogConditionTemplateSource_FieldTerminalPathArrayOfValues{LogConditionTemplateSource_FieldTerminalPath: *fp, values: values.([]*fieldmaskpb.FieldMask)} 1607 default: 1608 panic(fmt.Sprintf("Invalid selector for LogCondition_TemplateSource: %d", fp.selector)) 1609 } 1610 return fpaov 1611 } 1612 1613 func (fp *LogConditionTemplateSource_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1614 return fp.WithIArrayOfValues(values) 1615 } 1616 1617 func (fp *LogConditionTemplateSource_FieldTerminalPath) WithIArrayItemValue(value interface{}) LogConditionTemplateSource_FieldPathArrayItemValue { 1618 switch fp.selector { 1619 default: 1620 panic(fmt.Sprintf("Invalid selector for LogCondition_TemplateSource: %d", fp.selector)) 1621 } 1622 } 1623 1624 func (fp *LogConditionTemplateSource_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1625 return fp.WithIArrayItemValue(value) 1626 } 1627 1628 // LogConditionTemplateSource_FieldPathValue allows storing values for TemplateSource fields according to their type 1629 type LogConditionTemplateSource_FieldPathValue interface { 1630 LogConditionTemplateSource_FieldPath 1631 gotenobject.FieldPathValue 1632 SetTo(target **LogCondition_TemplateSource) 1633 CompareWith(*LogCondition_TemplateSource) (cmp int, comparable bool) 1634 } 1635 1636 func ParseLogConditionTemplateSource_FieldPathValue(pathStr, valueStr string) (LogConditionTemplateSource_FieldPathValue, error) { 1637 fp, err := ParseLogConditionTemplateSource_FieldPath(pathStr) 1638 if err != nil { 1639 return nil, err 1640 } 1641 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1642 if err != nil { 1643 return nil, status.Errorf(codes.InvalidArgument, "error parsing TemplateSource field path value from %s: %v", valueStr, err) 1644 } 1645 return fpv.(LogConditionTemplateSource_FieldPathValue), nil 1646 } 1647 1648 func MustParseLogConditionTemplateSource_FieldPathValue(pathStr, valueStr string) LogConditionTemplateSource_FieldPathValue { 1649 fpv, err := ParseLogConditionTemplateSource_FieldPathValue(pathStr, valueStr) 1650 if err != nil { 1651 panic(err) 1652 } 1653 return fpv 1654 } 1655 1656 type LogConditionTemplateSource_FieldTerminalPathValue struct { 1657 LogConditionTemplateSource_FieldTerminalPath 1658 value interface{} 1659 } 1660 1661 var _ LogConditionTemplateSource_FieldPathValue = (*LogConditionTemplateSource_FieldTerminalPathValue)(nil) 1662 1663 // GetRawValue returns raw value stored under selected path for 'TemplateSource' as interface{} 1664 func (fpv *LogConditionTemplateSource_FieldTerminalPathValue) GetRawValue() interface{} { 1665 return fpv.value 1666 } 1667 func (fpv *LogConditionTemplateSource_FieldTerminalPathValue) AsTemplateValue() (*log_condition_template.Reference, bool) { 1668 res, ok := fpv.value.(*log_condition_template.Reference) 1669 return res, ok 1670 } 1671 func (fpv *LogConditionTemplateSource_FieldTerminalPathValue) AsUpdatedFieldsValue() (*fieldmaskpb.FieldMask, bool) { 1672 res, ok := fpv.value.(*fieldmaskpb.FieldMask) 1673 return res, ok 1674 } 1675 1676 // SetTo stores value for selected field for object TemplateSource 1677 func (fpv *LogConditionTemplateSource_FieldTerminalPathValue) SetTo(target **LogCondition_TemplateSource) { 1678 if *target == nil { 1679 *target = new(LogCondition_TemplateSource) 1680 } 1681 switch fpv.selector { 1682 case LogConditionTemplateSource_FieldPathSelectorTemplate: 1683 (*target).Template = fpv.value.(*log_condition_template.Reference) 1684 case LogConditionTemplateSource_FieldPathSelectorUpdatedFields: 1685 (*target).UpdatedFields = fpv.value.(*fieldmaskpb.FieldMask) 1686 default: 1687 panic(fmt.Sprintf("Invalid selector for LogCondition_TemplateSource: %d", fpv.selector)) 1688 } 1689 } 1690 1691 func (fpv *LogConditionTemplateSource_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1692 typedObject := target.(*LogCondition_TemplateSource) 1693 fpv.SetTo(&typedObject) 1694 } 1695 1696 // CompareWith compares value in the 'LogConditionTemplateSource_FieldTerminalPathValue' with the value under path in 'LogCondition_TemplateSource'. 1697 func (fpv *LogConditionTemplateSource_FieldTerminalPathValue) CompareWith(source *LogCondition_TemplateSource) (int, bool) { 1698 switch fpv.selector { 1699 case LogConditionTemplateSource_FieldPathSelectorTemplate: 1700 leftValue := fpv.value.(*log_condition_template.Reference) 1701 rightValue := source.GetTemplate() 1702 if leftValue == nil { 1703 if rightValue != nil { 1704 return -1, true 1705 } 1706 return 0, true 1707 } 1708 if rightValue == nil { 1709 return 1, true 1710 } 1711 if leftValue.String() == rightValue.String() { 1712 return 0, true 1713 } else if leftValue.String() < rightValue.String() { 1714 return -1, true 1715 } else { 1716 return 1, true 1717 } 1718 case LogConditionTemplateSource_FieldPathSelectorUpdatedFields: 1719 return 0, false 1720 default: 1721 panic(fmt.Sprintf("Invalid selector for LogCondition_TemplateSource: %d", fpv.selector)) 1722 } 1723 } 1724 1725 func (fpv *LogConditionTemplateSource_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1726 return fpv.CompareWith(source.(*LogCondition_TemplateSource)) 1727 } 1728 1729 // LogConditionTemplateSource_FieldPathArrayItemValue allows storing single item in Path-specific values for TemplateSource according to their type 1730 // Present only for array (repeated) types. 1731 type LogConditionTemplateSource_FieldPathArrayItemValue interface { 1732 gotenobject.FieldPathArrayItemValue 1733 LogConditionTemplateSource_FieldPath 1734 ContainsValue(*LogCondition_TemplateSource) bool 1735 } 1736 1737 // ParseLogConditionTemplateSource_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1738 func ParseLogConditionTemplateSource_FieldPathArrayItemValue(pathStr, valueStr string) (LogConditionTemplateSource_FieldPathArrayItemValue, error) { 1739 fp, err := ParseLogConditionTemplateSource_FieldPath(pathStr) 1740 if err != nil { 1741 return nil, err 1742 } 1743 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1744 if err != nil { 1745 return nil, status.Errorf(codes.InvalidArgument, "error parsing TemplateSource field path array item value from %s: %v", valueStr, err) 1746 } 1747 return fpaiv.(LogConditionTemplateSource_FieldPathArrayItemValue), nil 1748 } 1749 1750 func MustParseLogConditionTemplateSource_FieldPathArrayItemValue(pathStr, valueStr string) LogConditionTemplateSource_FieldPathArrayItemValue { 1751 fpaiv, err := ParseLogConditionTemplateSource_FieldPathArrayItemValue(pathStr, valueStr) 1752 if err != nil { 1753 panic(err) 1754 } 1755 return fpaiv 1756 } 1757 1758 type LogConditionTemplateSource_FieldTerminalPathArrayItemValue struct { 1759 LogConditionTemplateSource_FieldTerminalPath 1760 value interface{} 1761 } 1762 1763 var _ LogConditionTemplateSource_FieldPathArrayItemValue = (*LogConditionTemplateSource_FieldTerminalPathArrayItemValue)(nil) 1764 1765 // GetRawValue returns stored element value for array in object LogCondition_TemplateSource as interface{} 1766 func (fpaiv *LogConditionTemplateSource_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1767 return fpaiv.value 1768 } 1769 1770 func (fpaiv *LogConditionTemplateSource_FieldTerminalPathArrayItemValue) GetSingle(source *LogCondition_TemplateSource) (interface{}, bool) { 1771 return nil, false 1772 } 1773 1774 func (fpaiv *LogConditionTemplateSource_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1775 return fpaiv.GetSingle(source.(*LogCondition_TemplateSource)) 1776 } 1777 1778 // Contains returns a boolean indicating if value that is being held is present in given 'TemplateSource' 1779 func (fpaiv *LogConditionTemplateSource_FieldTerminalPathArrayItemValue) ContainsValue(source *LogCondition_TemplateSource) bool { 1780 slice := fpaiv.LogConditionTemplateSource_FieldTerminalPath.Get(source) 1781 for _, v := range slice { 1782 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1783 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1784 return true 1785 } 1786 } else if reflect.DeepEqual(v, fpaiv.value) { 1787 return true 1788 } 1789 } 1790 return false 1791 } 1792 1793 // LogConditionTemplateSource_FieldPathArrayOfValues allows storing slice of values for TemplateSource fields according to their type 1794 type LogConditionTemplateSource_FieldPathArrayOfValues interface { 1795 gotenobject.FieldPathArrayOfValues 1796 LogConditionTemplateSource_FieldPath 1797 } 1798 1799 func ParseLogConditionTemplateSource_FieldPathArrayOfValues(pathStr, valuesStr string) (LogConditionTemplateSource_FieldPathArrayOfValues, error) { 1800 fp, err := ParseLogConditionTemplateSource_FieldPath(pathStr) 1801 if err != nil { 1802 return nil, err 1803 } 1804 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1805 if err != nil { 1806 return nil, status.Errorf(codes.InvalidArgument, "error parsing TemplateSource field path array of values from %s: %v", valuesStr, err) 1807 } 1808 return fpaov.(LogConditionTemplateSource_FieldPathArrayOfValues), nil 1809 } 1810 1811 func MustParseLogConditionTemplateSource_FieldPathArrayOfValues(pathStr, valuesStr string) LogConditionTemplateSource_FieldPathArrayOfValues { 1812 fpaov, err := ParseLogConditionTemplateSource_FieldPathArrayOfValues(pathStr, valuesStr) 1813 if err != nil { 1814 panic(err) 1815 } 1816 return fpaov 1817 } 1818 1819 type LogConditionTemplateSource_FieldTerminalPathArrayOfValues struct { 1820 LogConditionTemplateSource_FieldTerminalPath 1821 values interface{} 1822 } 1823 1824 var _ LogConditionTemplateSource_FieldPathArrayOfValues = (*LogConditionTemplateSource_FieldTerminalPathArrayOfValues)(nil) 1825 1826 func (fpaov *LogConditionTemplateSource_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1827 switch fpaov.selector { 1828 case LogConditionTemplateSource_FieldPathSelectorTemplate: 1829 for _, v := range fpaov.values.([]*log_condition_template.Reference) { 1830 values = append(values, v) 1831 } 1832 case LogConditionTemplateSource_FieldPathSelectorUpdatedFields: 1833 for _, v := range fpaov.values.([]*fieldmaskpb.FieldMask) { 1834 values = append(values, v) 1835 } 1836 } 1837 return 1838 } 1839 func (fpaov *LogConditionTemplateSource_FieldTerminalPathArrayOfValues) AsTemplateArrayOfValues() ([]*log_condition_template.Reference, bool) { 1840 res, ok := fpaov.values.([]*log_condition_template.Reference) 1841 return res, ok 1842 } 1843 func (fpaov *LogConditionTemplateSource_FieldTerminalPathArrayOfValues) AsUpdatedFieldsArrayOfValues() ([]*fieldmaskpb.FieldMask, bool) { 1844 res, ok := fpaov.values.([]*fieldmaskpb.FieldMask) 1845 return res, ok 1846 }