github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/log_condition_template/log_condition_template.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/alerting/proto/v1/log_condition_template.proto 3 // DO NOT EDIT!!! 4 5 package log_condition_template 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 policy_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy_template" 29 meta "github.com/cloudwan/goten-sdk/types/meta" 30 ) 31 32 // ensure the imports are used 33 var ( 34 _ = new(json.Marshaler) 35 _ = new(fmt.Stringer) 36 _ = reflect.DeepEqual 37 _ = strings.Builder{} 38 _ = time.Second 39 40 _ = strcase.ToLowerCamel 41 _ = codes.NotFound 42 _ = status.Status{} 43 _ = protojson.UnmarshalOptions{} 44 _ = new(proto.Message) 45 _ = protoregistry.GlobalTypes 46 47 _ = new(gotenobject.FieldPath) 48 ) 49 50 // make sure we're using proto imports 51 var ( 52 _ = &document.Document{} 53 _ = &policy_template.PolicyTemplate{} 54 _ = &rcommon.LogCndSpec{} 55 _ = &meta.Meta{} 56 ) 57 58 // FieldPath provides implementation to handle 59 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 60 type LogConditionTemplate_FieldPath interface { 61 gotenobject.FieldPath 62 Selector() LogConditionTemplate_FieldPathSelector 63 Get(source *LogConditionTemplate) []interface{} 64 GetSingle(source *LogConditionTemplate) (interface{}, bool) 65 ClearValue(item *LogConditionTemplate) 66 67 // Those methods build corresponding LogConditionTemplate_FieldPathValue 68 // (or array of values) and holds passed value. Panics if injected type is incorrect. 69 WithIValue(value interface{}) LogConditionTemplate_FieldPathValue 70 WithIArrayOfValues(values interface{}) LogConditionTemplate_FieldPathArrayOfValues 71 WithIArrayItemValue(value interface{}) LogConditionTemplate_FieldPathArrayItemValue 72 } 73 74 type LogConditionTemplate_FieldPathSelector int32 75 76 const ( 77 LogConditionTemplate_FieldPathSelectorName LogConditionTemplate_FieldPathSelector = 0 78 LogConditionTemplate_FieldPathSelectorMetadata LogConditionTemplate_FieldPathSelector = 1 79 LogConditionTemplate_FieldPathSelectorDisplayName LogConditionTemplate_FieldPathSelector = 2 80 LogConditionTemplate_FieldPathSelectorDescription LogConditionTemplate_FieldPathSelector = 3 81 LogConditionTemplate_FieldPathSelectorSupportingDocs LogConditionTemplate_FieldPathSelector = 4 82 LogConditionTemplate_FieldPathSelectorSpecTemplate LogConditionTemplate_FieldPathSelector = 5 83 ) 84 85 func (s LogConditionTemplate_FieldPathSelector) String() string { 86 switch s { 87 case LogConditionTemplate_FieldPathSelectorName: 88 return "name" 89 case LogConditionTemplate_FieldPathSelectorMetadata: 90 return "metadata" 91 case LogConditionTemplate_FieldPathSelectorDisplayName: 92 return "display_name" 93 case LogConditionTemplate_FieldPathSelectorDescription: 94 return "description" 95 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 96 return "supporting_docs" 97 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 98 return "spec_template" 99 default: 100 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", s)) 101 } 102 } 103 104 func BuildLogConditionTemplate_FieldPath(fp gotenobject.RawFieldPath) (LogConditionTemplate_FieldPath, error) { 105 if len(fp) == 0 { 106 return nil, status.Error(codes.InvalidArgument, "empty field path for object LogConditionTemplate") 107 } 108 if len(fp) == 1 { 109 switch fp[0] { 110 case "name": 111 return &LogConditionTemplate_FieldTerminalPath{selector: LogConditionTemplate_FieldPathSelectorName}, nil 112 case "metadata": 113 return &LogConditionTemplate_FieldTerminalPath{selector: LogConditionTemplate_FieldPathSelectorMetadata}, nil 114 case "display_name", "displayName", "display-name": 115 return &LogConditionTemplate_FieldTerminalPath{selector: LogConditionTemplate_FieldPathSelectorDisplayName}, nil 116 case "description": 117 return &LogConditionTemplate_FieldTerminalPath{selector: LogConditionTemplate_FieldPathSelectorDescription}, nil 118 case "supporting_docs", "supportingDocs", "supporting-docs": 119 return &LogConditionTemplate_FieldTerminalPath{selector: LogConditionTemplate_FieldPathSelectorSupportingDocs}, nil 120 case "spec_template", "specTemplate", "spec-template": 121 return &LogConditionTemplate_FieldTerminalPath{selector: LogConditionTemplate_FieldPathSelectorSpecTemplate}, nil 122 } 123 } else { 124 switch fp[0] { 125 case "metadata": 126 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 127 return nil, err 128 } else { 129 return &LogConditionTemplate_FieldSubPath{selector: LogConditionTemplate_FieldPathSelectorMetadata, subPath: subpath}, nil 130 } 131 case "spec_template", "specTemplate", "spec-template": 132 if subpath, err := rcommon.BuildLogCndSpec_FieldPath(fp[1:]); err != nil { 133 return nil, err 134 } else { 135 return &LogConditionTemplate_FieldSubPath{selector: LogConditionTemplate_FieldPathSelectorSpecTemplate, subPath: subpath}, nil 136 } 137 } 138 } 139 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object LogConditionTemplate", fp) 140 } 141 142 func ParseLogConditionTemplate_FieldPath(rawField string) (LogConditionTemplate_FieldPath, error) { 143 fp, err := gotenobject.ParseRawFieldPath(rawField) 144 if err != nil { 145 return nil, err 146 } 147 return BuildLogConditionTemplate_FieldPath(fp) 148 } 149 150 func MustParseLogConditionTemplate_FieldPath(rawField string) LogConditionTemplate_FieldPath { 151 fp, err := ParseLogConditionTemplate_FieldPath(rawField) 152 if err != nil { 153 panic(err) 154 } 155 return fp 156 } 157 158 type LogConditionTemplate_FieldTerminalPath struct { 159 selector LogConditionTemplate_FieldPathSelector 160 } 161 162 var _ LogConditionTemplate_FieldPath = (*LogConditionTemplate_FieldTerminalPath)(nil) 163 164 func (fp *LogConditionTemplate_FieldTerminalPath) Selector() LogConditionTemplate_FieldPathSelector { 165 return fp.selector 166 } 167 168 // String returns path representation in proto convention 169 func (fp *LogConditionTemplate_FieldTerminalPath) String() string { 170 return fp.selector.String() 171 } 172 173 // JSONString returns path representation is JSON convention 174 func (fp *LogConditionTemplate_FieldTerminalPath) JSONString() string { 175 return strcase.ToLowerCamel(fp.String()) 176 } 177 178 // Get returns all values pointed by specific field from source LogConditionTemplate 179 func (fp *LogConditionTemplate_FieldTerminalPath) Get(source *LogConditionTemplate) (values []interface{}) { 180 if source != nil { 181 switch fp.selector { 182 case LogConditionTemplate_FieldPathSelectorName: 183 if source.Name != nil { 184 values = append(values, source.Name) 185 } 186 case LogConditionTemplate_FieldPathSelectorMetadata: 187 if source.Metadata != nil { 188 values = append(values, source.Metadata) 189 } 190 case LogConditionTemplate_FieldPathSelectorDisplayName: 191 values = append(values, source.DisplayName) 192 case LogConditionTemplate_FieldPathSelectorDescription: 193 values = append(values, source.Description) 194 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 195 for _, value := range source.GetSupportingDocs() { 196 values = append(values, value) 197 } 198 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 199 if source.SpecTemplate != nil { 200 values = append(values, source.SpecTemplate) 201 } 202 default: 203 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fp.selector)) 204 } 205 } 206 return 207 } 208 209 func (fp *LogConditionTemplate_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 210 return fp.Get(source.(*LogConditionTemplate)) 211 } 212 213 // GetSingle returns value pointed by specific field of from source LogConditionTemplate 214 func (fp *LogConditionTemplate_FieldTerminalPath) GetSingle(source *LogConditionTemplate) (interface{}, bool) { 215 switch fp.selector { 216 case LogConditionTemplate_FieldPathSelectorName: 217 res := source.GetName() 218 return res, res != nil 219 case LogConditionTemplate_FieldPathSelectorMetadata: 220 res := source.GetMetadata() 221 return res, res != nil 222 case LogConditionTemplate_FieldPathSelectorDisplayName: 223 return source.GetDisplayName(), source != nil 224 case LogConditionTemplate_FieldPathSelectorDescription: 225 return source.GetDescription(), source != nil 226 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 227 res := source.GetSupportingDocs() 228 return res, res != nil 229 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 230 res := source.GetSpecTemplate() 231 return res, res != nil 232 default: 233 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fp.selector)) 234 } 235 } 236 237 func (fp *LogConditionTemplate_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 238 return fp.GetSingle(source.(*LogConditionTemplate)) 239 } 240 241 // GetDefault returns a default value of the field type 242 func (fp *LogConditionTemplate_FieldTerminalPath) GetDefault() interface{} { 243 switch fp.selector { 244 case LogConditionTemplate_FieldPathSelectorName: 245 return (*Name)(nil) 246 case LogConditionTemplate_FieldPathSelectorMetadata: 247 return (*meta.Meta)(nil) 248 case LogConditionTemplate_FieldPathSelectorDisplayName: 249 return "" 250 case LogConditionTemplate_FieldPathSelectorDescription: 251 return "" 252 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 253 return ([]*document.Reference)(nil) 254 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 255 return (*rcommon.LogCndSpec)(nil) 256 default: 257 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fp.selector)) 258 } 259 } 260 261 func (fp *LogConditionTemplate_FieldTerminalPath) ClearValue(item *LogConditionTemplate) { 262 if item != nil { 263 switch fp.selector { 264 case LogConditionTemplate_FieldPathSelectorName: 265 item.Name = nil 266 case LogConditionTemplate_FieldPathSelectorMetadata: 267 item.Metadata = nil 268 case LogConditionTemplate_FieldPathSelectorDisplayName: 269 item.DisplayName = "" 270 case LogConditionTemplate_FieldPathSelectorDescription: 271 item.Description = "" 272 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 273 item.SupportingDocs = nil 274 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 275 item.SpecTemplate = nil 276 default: 277 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fp.selector)) 278 } 279 } 280 } 281 282 func (fp *LogConditionTemplate_FieldTerminalPath) ClearValueRaw(item proto.Message) { 283 fp.ClearValue(item.(*LogConditionTemplate)) 284 } 285 286 // IsLeaf - whether field path is holds simple value 287 func (fp *LogConditionTemplate_FieldTerminalPath) IsLeaf() bool { 288 return fp.selector == LogConditionTemplate_FieldPathSelectorName || 289 fp.selector == LogConditionTemplate_FieldPathSelectorDisplayName || 290 fp.selector == LogConditionTemplate_FieldPathSelectorDescription || 291 fp.selector == LogConditionTemplate_FieldPathSelectorSupportingDocs 292 } 293 294 func (fp *LogConditionTemplate_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 295 return []gotenobject.FieldPath{fp} 296 } 297 298 func (fp *LogConditionTemplate_FieldTerminalPath) WithIValue(value interface{}) LogConditionTemplate_FieldPathValue { 299 switch fp.selector { 300 case LogConditionTemplate_FieldPathSelectorName: 301 return &LogConditionTemplate_FieldTerminalPathValue{LogConditionTemplate_FieldTerminalPath: *fp, value: value.(*Name)} 302 case LogConditionTemplate_FieldPathSelectorMetadata: 303 return &LogConditionTemplate_FieldTerminalPathValue{LogConditionTemplate_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 304 case LogConditionTemplate_FieldPathSelectorDisplayName: 305 return &LogConditionTemplate_FieldTerminalPathValue{LogConditionTemplate_FieldTerminalPath: *fp, value: value.(string)} 306 case LogConditionTemplate_FieldPathSelectorDescription: 307 return &LogConditionTemplate_FieldTerminalPathValue{LogConditionTemplate_FieldTerminalPath: *fp, value: value.(string)} 308 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 309 return &LogConditionTemplate_FieldTerminalPathValue{LogConditionTemplate_FieldTerminalPath: *fp, value: value.([]*document.Reference)} 310 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 311 return &LogConditionTemplate_FieldTerminalPathValue{LogConditionTemplate_FieldTerminalPath: *fp, value: value.(*rcommon.LogCndSpec)} 312 default: 313 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fp.selector)) 314 } 315 } 316 317 func (fp *LogConditionTemplate_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 318 return fp.WithIValue(value) 319 } 320 321 func (fp *LogConditionTemplate_FieldTerminalPath) WithIArrayOfValues(values interface{}) LogConditionTemplate_FieldPathArrayOfValues { 322 fpaov := &LogConditionTemplate_FieldTerminalPathArrayOfValues{LogConditionTemplate_FieldTerminalPath: *fp} 323 switch fp.selector { 324 case LogConditionTemplate_FieldPathSelectorName: 325 return &LogConditionTemplate_FieldTerminalPathArrayOfValues{LogConditionTemplate_FieldTerminalPath: *fp, values: values.([]*Name)} 326 case LogConditionTemplate_FieldPathSelectorMetadata: 327 return &LogConditionTemplate_FieldTerminalPathArrayOfValues{LogConditionTemplate_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 328 case LogConditionTemplate_FieldPathSelectorDisplayName: 329 return &LogConditionTemplate_FieldTerminalPathArrayOfValues{LogConditionTemplate_FieldTerminalPath: *fp, values: values.([]string)} 330 case LogConditionTemplate_FieldPathSelectorDescription: 331 return &LogConditionTemplate_FieldTerminalPathArrayOfValues{LogConditionTemplate_FieldTerminalPath: *fp, values: values.([]string)} 332 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 333 return &LogConditionTemplate_FieldTerminalPathArrayOfValues{LogConditionTemplate_FieldTerminalPath: *fp, values: values.([][]*document.Reference)} 334 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 335 return &LogConditionTemplate_FieldTerminalPathArrayOfValues{LogConditionTemplate_FieldTerminalPath: *fp, values: values.([]*rcommon.LogCndSpec)} 336 default: 337 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fp.selector)) 338 } 339 return fpaov 340 } 341 342 func (fp *LogConditionTemplate_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 343 return fp.WithIArrayOfValues(values) 344 } 345 346 func (fp *LogConditionTemplate_FieldTerminalPath) WithIArrayItemValue(value interface{}) LogConditionTemplate_FieldPathArrayItemValue { 347 switch fp.selector { 348 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 349 return &LogConditionTemplate_FieldTerminalPathArrayItemValue{LogConditionTemplate_FieldTerminalPath: *fp, value: value.(*document.Reference)} 350 default: 351 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fp.selector)) 352 } 353 } 354 355 func (fp *LogConditionTemplate_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 356 return fp.WithIArrayItemValue(value) 357 } 358 359 type LogConditionTemplate_FieldSubPath struct { 360 selector LogConditionTemplate_FieldPathSelector 361 subPath gotenobject.FieldPath 362 } 363 364 var _ LogConditionTemplate_FieldPath = (*LogConditionTemplate_FieldSubPath)(nil) 365 366 func (fps *LogConditionTemplate_FieldSubPath) Selector() LogConditionTemplate_FieldPathSelector { 367 return fps.selector 368 } 369 func (fps *LogConditionTemplate_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 370 res, ok := fps.subPath.(meta.Meta_FieldPath) 371 return res, ok 372 } 373 func (fps *LogConditionTemplate_FieldSubPath) AsSpecTemplateSubPath() (rcommon.LogCndSpec_FieldPath, bool) { 374 res, ok := fps.subPath.(rcommon.LogCndSpec_FieldPath) 375 return res, ok 376 } 377 378 // String returns path representation in proto convention 379 func (fps *LogConditionTemplate_FieldSubPath) String() string { 380 return fps.selector.String() + "." + fps.subPath.String() 381 } 382 383 // JSONString returns path representation is JSON convention 384 func (fps *LogConditionTemplate_FieldSubPath) JSONString() string { 385 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 386 } 387 388 // Get returns all values pointed by selected field from source LogConditionTemplate 389 func (fps *LogConditionTemplate_FieldSubPath) Get(source *LogConditionTemplate) (values []interface{}) { 390 switch fps.selector { 391 case LogConditionTemplate_FieldPathSelectorMetadata: 392 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 393 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 394 values = append(values, fps.subPath.GetRaw(source.GetSpecTemplate())...) 395 default: 396 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fps.selector)) 397 } 398 return 399 } 400 401 func (fps *LogConditionTemplate_FieldSubPath) GetRaw(source proto.Message) []interface{} { 402 return fps.Get(source.(*LogConditionTemplate)) 403 } 404 405 // GetSingle returns value of selected field from source LogConditionTemplate 406 func (fps *LogConditionTemplate_FieldSubPath) GetSingle(source *LogConditionTemplate) (interface{}, bool) { 407 switch fps.selector { 408 case LogConditionTemplate_FieldPathSelectorMetadata: 409 if source.GetMetadata() == nil { 410 return nil, false 411 } 412 return fps.subPath.GetSingleRaw(source.GetMetadata()) 413 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 414 if source.GetSpecTemplate() == nil { 415 return nil, false 416 } 417 return fps.subPath.GetSingleRaw(source.GetSpecTemplate()) 418 default: 419 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fps.selector)) 420 } 421 } 422 423 func (fps *LogConditionTemplate_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 424 return fps.GetSingle(source.(*LogConditionTemplate)) 425 } 426 427 // GetDefault returns a default value of the field type 428 func (fps *LogConditionTemplate_FieldSubPath) GetDefault() interface{} { 429 return fps.subPath.GetDefault() 430 } 431 432 func (fps *LogConditionTemplate_FieldSubPath) ClearValue(item *LogConditionTemplate) { 433 if item != nil { 434 switch fps.selector { 435 case LogConditionTemplate_FieldPathSelectorMetadata: 436 fps.subPath.ClearValueRaw(item.Metadata) 437 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 438 fps.subPath.ClearValueRaw(item.SpecTemplate) 439 default: 440 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fps.selector)) 441 } 442 } 443 } 444 445 func (fps *LogConditionTemplate_FieldSubPath) ClearValueRaw(item proto.Message) { 446 fps.ClearValue(item.(*LogConditionTemplate)) 447 } 448 449 // IsLeaf - whether field path is holds simple value 450 func (fps *LogConditionTemplate_FieldSubPath) IsLeaf() bool { 451 return fps.subPath.IsLeaf() 452 } 453 454 func (fps *LogConditionTemplate_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 455 iPaths := []gotenobject.FieldPath{&LogConditionTemplate_FieldTerminalPath{selector: fps.selector}} 456 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 457 return iPaths 458 } 459 460 func (fps *LogConditionTemplate_FieldSubPath) WithIValue(value interface{}) LogConditionTemplate_FieldPathValue { 461 return &LogConditionTemplate_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 462 } 463 464 func (fps *LogConditionTemplate_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 465 return fps.WithIValue(value) 466 } 467 468 func (fps *LogConditionTemplate_FieldSubPath) WithIArrayOfValues(values interface{}) LogConditionTemplate_FieldPathArrayOfValues { 469 return &LogConditionTemplate_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 470 } 471 472 func (fps *LogConditionTemplate_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 473 return fps.WithIArrayOfValues(values) 474 } 475 476 func (fps *LogConditionTemplate_FieldSubPath) WithIArrayItemValue(value interface{}) LogConditionTemplate_FieldPathArrayItemValue { 477 return &LogConditionTemplate_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 478 } 479 480 func (fps *LogConditionTemplate_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 481 return fps.WithIArrayItemValue(value) 482 } 483 484 // LogConditionTemplate_FieldPathValue allows storing values for LogConditionTemplate fields according to their type 485 type LogConditionTemplate_FieldPathValue interface { 486 LogConditionTemplate_FieldPath 487 gotenobject.FieldPathValue 488 SetTo(target **LogConditionTemplate) 489 CompareWith(*LogConditionTemplate) (cmp int, comparable bool) 490 } 491 492 func ParseLogConditionTemplate_FieldPathValue(pathStr, valueStr string) (LogConditionTemplate_FieldPathValue, error) { 493 fp, err := ParseLogConditionTemplate_FieldPath(pathStr) 494 if err != nil { 495 return nil, err 496 } 497 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 498 if err != nil { 499 return nil, status.Errorf(codes.InvalidArgument, "error parsing LogConditionTemplate field path value from %s: %v", valueStr, err) 500 } 501 return fpv.(LogConditionTemplate_FieldPathValue), nil 502 } 503 504 func MustParseLogConditionTemplate_FieldPathValue(pathStr, valueStr string) LogConditionTemplate_FieldPathValue { 505 fpv, err := ParseLogConditionTemplate_FieldPathValue(pathStr, valueStr) 506 if err != nil { 507 panic(err) 508 } 509 return fpv 510 } 511 512 type LogConditionTemplate_FieldTerminalPathValue struct { 513 LogConditionTemplate_FieldTerminalPath 514 value interface{} 515 } 516 517 var _ LogConditionTemplate_FieldPathValue = (*LogConditionTemplate_FieldTerminalPathValue)(nil) 518 519 // GetRawValue returns raw value stored under selected path for 'LogConditionTemplate' as interface{} 520 func (fpv *LogConditionTemplate_FieldTerminalPathValue) GetRawValue() interface{} { 521 return fpv.value 522 } 523 func (fpv *LogConditionTemplate_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 524 res, ok := fpv.value.(*Name) 525 return res, ok 526 } 527 func (fpv *LogConditionTemplate_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 528 res, ok := fpv.value.(*meta.Meta) 529 return res, ok 530 } 531 func (fpv *LogConditionTemplate_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) { 532 res, ok := fpv.value.(string) 533 return res, ok 534 } 535 func (fpv *LogConditionTemplate_FieldTerminalPathValue) AsDescriptionValue() (string, bool) { 536 res, ok := fpv.value.(string) 537 return res, ok 538 } 539 func (fpv *LogConditionTemplate_FieldTerminalPathValue) AsSupportingDocsValue() ([]*document.Reference, bool) { 540 res, ok := fpv.value.([]*document.Reference) 541 return res, ok 542 } 543 func (fpv *LogConditionTemplate_FieldTerminalPathValue) AsSpecTemplateValue() (*rcommon.LogCndSpec, bool) { 544 res, ok := fpv.value.(*rcommon.LogCndSpec) 545 return res, ok 546 } 547 548 // SetTo stores value for selected field for object LogConditionTemplate 549 func (fpv *LogConditionTemplate_FieldTerminalPathValue) SetTo(target **LogConditionTemplate) { 550 if *target == nil { 551 *target = new(LogConditionTemplate) 552 } 553 switch fpv.selector { 554 case LogConditionTemplate_FieldPathSelectorName: 555 (*target).Name = fpv.value.(*Name) 556 case LogConditionTemplate_FieldPathSelectorMetadata: 557 (*target).Metadata = fpv.value.(*meta.Meta) 558 case LogConditionTemplate_FieldPathSelectorDisplayName: 559 (*target).DisplayName = fpv.value.(string) 560 case LogConditionTemplate_FieldPathSelectorDescription: 561 (*target).Description = fpv.value.(string) 562 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 563 (*target).SupportingDocs = fpv.value.([]*document.Reference) 564 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 565 (*target).SpecTemplate = fpv.value.(*rcommon.LogCndSpec) 566 default: 567 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fpv.selector)) 568 } 569 } 570 571 func (fpv *LogConditionTemplate_FieldTerminalPathValue) SetToRaw(target proto.Message) { 572 typedObject := target.(*LogConditionTemplate) 573 fpv.SetTo(&typedObject) 574 } 575 576 // CompareWith compares value in the 'LogConditionTemplate_FieldTerminalPathValue' with the value under path in 'LogConditionTemplate'. 577 func (fpv *LogConditionTemplate_FieldTerminalPathValue) CompareWith(source *LogConditionTemplate) (int, bool) { 578 switch fpv.selector { 579 case LogConditionTemplate_FieldPathSelectorName: 580 leftValue := fpv.value.(*Name) 581 rightValue := source.GetName() 582 if leftValue == nil { 583 if rightValue != nil { 584 return -1, true 585 } 586 return 0, true 587 } 588 if rightValue == nil { 589 return 1, true 590 } 591 if leftValue.String() == rightValue.String() { 592 return 0, true 593 } else if leftValue.String() < rightValue.String() { 594 return -1, true 595 } else { 596 return 1, true 597 } 598 case LogConditionTemplate_FieldPathSelectorMetadata: 599 return 0, false 600 case LogConditionTemplate_FieldPathSelectorDisplayName: 601 leftValue := fpv.value.(string) 602 rightValue := source.GetDisplayName() 603 if (leftValue) == (rightValue) { 604 return 0, true 605 } else if (leftValue) < (rightValue) { 606 return -1, true 607 } else { 608 return 1, true 609 } 610 case LogConditionTemplate_FieldPathSelectorDescription: 611 leftValue := fpv.value.(string) 612 rightValue := source.GetDescription() 613 if (leftValue) == (rightValue) { 614 return 0, true 615 } else if (leftValue) < (rightValue) { 616 return -1, true 617 } else { 618 return 1, true 619 } 620 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 621 return 0, false 622 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 623 return 0, false 624 default: 625 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fpv.selector)) 626 } 627 } 628 629 func (fpv *LogConditionTemplate_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 630 return fpv.CompareWith(source.(*LogConditionTemplate)) 631 } 632 633 type LogConditionTemplate_FieldSubPathValue struct { 634 LogConditionTemplate_FieldPath 635 subPathValue gotenobject.FieldPathValue 636 } 637 638 var _ LogConditionTemplate_FieldPathValue = (*LogConditionTemplate_FieldSubPathValue)(nil) 639 640 func (fpvs *LogConditionTemplate_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 641 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 642 return res, ok 643 } 644 func (fpvs *LogConditionTemplate_FieldSubPathValue) AsSpecTemplatePathValue() (rcommon.LogCndSpec_FieldPathValue, bool) { 645 res, ok := fpvs.subPathValue.(rcommon.LogCndSpec_FieldPathValue) 646 return res, ok 647 } 648 649 func (fpvs *LogConditionTemplate_FieldSubPathValue) SetTo(target **LogConditionTemplate) { 650 if *target == nil { 651 *target = new(LogConditionTemplate) 652 } 653 switch fpvs.Selector() { 654 case LogConditionTemplate_FieldPathSelectorMetadata: 655 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 656 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 657 fpvs.subPathValue.(rcommon.LogCndSpec_FieldPathValue).SetTo(&(*target).SpecTemplate) 658 default: 659 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fpvs.Selector())) 660 } 661 } 662 663 func (fpvs *LogConditionTemplate_FieldSubPathValue) SetToRaw(target proto.Message) { 664 typedObject := target.(*LogConditionTemplate) 665 fpvs.SetTo(&typedObject) 666 } 667 668 func (fpvs *LogConditionTemplate_FieldSubPathValue) GetRawValue() interface{} { 669 return fpvs.subPathValue.GetRawValue() 670 } 671 672 func (fpvs *LogConditionTemplate_FieldSubPathValue) CompareWith(source *LogConditionTemplate) (int, bool) { 673 switch fpvs.Selector() { 674 case LogConditionTemplate_FieldPathSelectorMetadata: 675 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 676 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 677 return fpvs.subPathValue.(rcommon.LogCndSpec_FieldPathValue).CompareWith(source.GetSpecTemplate()) 678 default: 679 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fpvs.Selector())) 680 } 681 } 682 683 func (fpvs *LogConditionTemplate_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 684 return fpvs.CompareWith(source.(*LogConditionTemplate)) 685 } 686 687 // LogConditionTemplate_FieldPathArrayItemValue allows storing single item in Path-specific values for LogConditionTemplate according to their type 688 // Present only for array (repeated) types. 689 type LogConditionTemplate_FieldPathArrayItemValue interface { 690 gotenobject.FieldPathArrayItemValue 691 LogConditionTemplate_FieldPath 692 ContainsValue(*LogConditionTemplate) bool 693 } 694 695 // ParseLogConditionTemplate_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 696 func ParseLogConditionTemplate_FieldPathArrayItemValue(pathStr, valueStr string) (LogConditionTemplate_FieldPathArrayItemValue, error) { 697 fp, err := ParseLogConditionTemplate_FieldPath(pathStr) 698 if err != nil { 699 return nil, err 700 } 701 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 702 if err != nil { 703 return nil, status.Errorf(codes.InvalidArgument, "error parsing LogConditionTemplate field path array item value from %s: %v", valueStr, err) 704 } 705 return fpaiv.(LogConditionTemplate_FieldPathArrayItemValue), nil 706 } 707 708 func MustParseLogConditionTemplate_FieldPathArrayItemValue(pathStr, valueStr string) LogConditionTemplate_FieldPathArrayItemValue { 709 fpaiv, err := ParseLogConditionTemplate_FieldPathArrayItemValue(pathStr, valueStr) 710 if err != nil { 711 panic(err) 712 } 713 return fpaiv 714 } 715 716 type LogConditionTemplate_FieldTerminalPathArrayItemValue struct { 717 LogConditionTemplate_FieldTerminalPath 718 value interface{} 719 } 720 721 var _ LogConditionTemplate_FieldPathArrayItemValue = (*LogConditionTemplate_FieldTerminalPathArrayItemValue)(nil) 722 723 // GetRawValue returns stored element value for array in object LogConditionTemplate as interface{} 724 func (fpaiv *LogConditionTemplate_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 725 return fpaiv.value 726 } 727 func (fpaiv *LogConditionTemplate_FieldTerminalPathArrayItemValue) AsSupportingDocsItemValue() (*document.Reference, bool) { 728 res, ok := fpaiv.value.(*document.Reference) 729 return res, ok 730 } 731 732 func (fpaiv *LogConditionTemplate_FieldTerminalPathArrayItemValue) GetSingle(source *LogConditionTemplate) (interface{}, bool) { 733 return nil, false 734 } 735 736 func (fpaiv *LogConditionTemplate_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 737 return fpaiv.GetSingle(source.(*LogConditionTemplate)) 738 } 739 740 // Contains returns a boolean indicating if value that is being held is present in given 'LogConditionTemplate' 741 func (fpaiv *LogConditionTemplate_FieldTerminalPathArrayItemValue) ContainsValue(source *LogConditionTemplate) bool { 742 slice := fpaiv.LogConditionTemplate_FieldTerminalPath.Get(source) 743 for _, v := range slice { 744 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 745 if proto.Equal(asProtoMsg, v.(proto.Message)) { 746 return true 747 } 748 } else if reflect.DeepEqual(v, fpaiv.value) { 749 return true 750 } 751 } 752 return false 753 } 754 755 type LogConditionTemplate_FieldSubPathArrayItemValue struct { 756 LogConditionTemplate_FieldPath 757 subPathItemValue gotenobject.FieldPathArrayItemValue 758 } 759 760 // GetRawValue returns stored array item value 761 func (fpaivs *LogConditionTemplate_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 762 return fpaivs.subPathItemValue.GetRawItemValue() 763 } 764 func (fpaivs *LogConditionTemplate_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 765 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 766 return res, ok 767 } 768 func (fpaivs *LogConditionTemplate_FieldSubPathArrayItemValue) AsSpecTemplatePathItemValue() (rcommon.LogCndSpec_FieldPathArrayItemValue, bool) { 769 res, ok := fpaivs.subPathItemValue.(rcommon.LogCndSpec_FieldPathArrayItemValue) 770 return res, ok 771 } 772 773 // Contains returns a boolean indicating if value that is being held is present in given 'LogConditionTemplate' 774 func (fpaivs *LogConditionTemplate_FieldSubPathArrayItemValue) ContainsValue(source *LogConditionTemplate) bool { 775 switch fpaivs.Selector() { 776 case LogConditionTemplate_FieldPathSelectorMetadata: 777 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 778 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 779 return fpaivs.subPathItemValue.(rcommon.LogCndSpec_FieldPathArrayItemValue).ContainsValue(source.GetSpecTemplate()) 780 default: 781 panic(fmt.Sprintf("Invalid selector for LogConditionTemplate: %d", fpaivs.Selector())) 782 } 783 } 784 785 // LogConditionTemplate_FieldPathArrayOfValues allows storing slice of values for LogConditionTemplate fields according to their type 786 type LogConditionTemplate_FieldPathArrayOfValues interface { 787 gotenobject.FieldPathArrayOfValues 788 LogConditionTemplate_FieldPath 789 } 790 791 func ParseLogConditionTemplate_FieldPathArrayOfValues(pathStr, valuesStr string) (LogConditionTemplate_FieldPathArrayOfValues, error) { 792 fp, err := ParseLogConditionTemplate_FieldPath(pathStr) 793 if err != nil { 794 return nil, err 795 } 796 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 797 if err != nil { 798 return nil, status.Errorf(codes.InvalidArgument, "error parsing LogConditionTemplate field path array of values from %s: %v", valuesStr, err) 799 } 800 return fpaov.(LogConditionTemplate_FieldPathArrayOfValues), nil 801 } 802 803 func MustParseLogConditionTemplate_FieldPathArrayOfValues(pathStr, valuesStr string) LogConditionTemplate_FieldPathArrayOfValues { 804 fpaov, err := ParseLogConditionTemplate_FieldPathArrayOfValues(pathStr, valuesStr) 805 if err != nil { 806 panic(err) 807 } 808 return fpaov 809 } 810 811 type LogConditionTemplate_FieldTerminalPathArrayOfValues struct { 812 LogConditionTemplate_FieldTerminalPath 813 values interface{} 814 } 815 816 var _ LogConditionTemplate_FieldPathArrayOfValues = (*LogConditionTemplate_FieldTerminalPathArrayOfValues)(nil) 817 818 func (fpaov *LogConditionTemplate_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 819 switch fpaov.selector { 820 case LogConditionTemplate_FieldPathSelectorName: 821 for _, v := range fpaov.values.([]*Name) { 822 values = append(values, v) 823 } 824 case LogConditionTemplate_FieldPathSelectorMetadata: 825 for _, v := range fpaov.values.([]*meta.Meta) { 826 values = append(values, v) 827 } 828 case LogConditionTemplate_FieldPathSelectorDisplayName: 829 for _, v := range fpaov.values.([]string) { 830 values = append(values, v) 831 } 832 case LogConditionTemplate_FieldPathSelectorDescription: 833 for _, v := range fpaov.values.([]string) { 834 values = append(values, v) 835 } 836 case LogConditionTemplate_FieldPathSelectorSupportingDocs: 837 for _, v := range fpaov.values.([][]*document.Reference) { 838 values = append(values, v) 839 } 840 case LogConditionTemplate_FieldPathSelectorSpecTemplate: 841 for _, v := range fpaov.values.([]*rcommon.LogCndSpec) { 842 values = append(values, v) 843 } 844 } 845 return 846 } 847 func (fpaov *LogConditionTemplate_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 848 res, ok := fpaov.values.([]*Name) 849 return res, ok 850 } 851 func (fpaov *LogConditionTemplate_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 852 res, ok := fpaov.values.([]*meta.Meta) 853 return res, ok 854 } 855 func (fpaov *LogConditionTemplate_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) { 856 res, ok := fpaov.values.([]string) 857 return res, ok 858 } 859 func (fpaov *LogConditionTemplate_FieldTerminalPathArrayOfValues) AsDescriptionArrayOfValues() ([]string, bool) { 860 res, ok := fpaov.values.([]string) 861 return res, ok 862 } 863 func (fpaov *LogConditionTemplate_FieldTerminalPathArrayOfValues) AsSupportingDocsArrayOfValues() ([][]*document.Reference, bool) { 864 res, ok := fpaov.values.([][]*document.Reference) 865 return res, ok 866 } 867 func (fpaov *LogConditionTemplate_FieldTerminalPathArrayOfValues) AsSpecTemplateArrayOfValues() ([]*rcommon.LogCndSpec, bool) { 868 res, ok := fpaov.values.([]*rcommon.LogCndSpec) 869 return res, ok 870 } 871 872 type LogConditionTemplate_FieldSubPathArrayOfValues struct { 873 LogConditionTemplate_FieldPath 874 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 875 } 876 877 var _ LogConditionTemplate_FieldPathArrayOfValues = (*LogConditionTemplate_FieldSubPathArrayOfValues)(nil) 878 879 func (fpsaov *LogConditionTemplate_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 880 return fpsaov.subPathArrayOfValues.GetRawValues() 881 } 882 func (fpsaov *LogConditionTemplate_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 883 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 884 return res, ok 885 } 886 func (fpsaov *LogConditionTemplate_FieldSubPathArrayOfValues) AsSpecTemplatePathArrayOfValues() (rcommon.LogCndSpec_FieldPathArrayOfValues, bool) { 887 res, ok := fpsaov.subPathArrayOfValues.(rcommon.LogCndSpec_FieldPathArrayOfValues) 888 return res, ok 889 }