github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v3/alert/alert.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/monitoring/proto/v3/alert.proto 3 // DO NOT EDIT!!! 4 5 package alert 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 alerting_condition "github.com/cloudwan/edgelq-sdk/monitoring/resources/v3/alerting_condition" 27 common "github.com/cloudwan/edgelq-sdk/monitoring/resources/v3/common" 28 meta "github.com/cloudwan/goten-sdk/types/meta" 29 ) 30 31 // ensure the imports are used 32 var ( 33 _ = new(json.Marshaler) 34 _ = new(fmt.Stringer) 35 _ = reflect.DeepEqual 36 _ = strings.Builder{} 37 _ = time.Second 38 39 _ = strcase.ToLowerCamel 40 _ = codes.NotFound 41 _ = status.Status{} 42 _ = protojson.UnmarshalOptions{} 43 _ = new(proto.Message) 44 _ = protoregistry.GlobalTypes 45 46 _ = new(gotenobject.FieldPath) 47 ) 48 49 // make sure we're using proto imports 50 var ( 51 _ = &alerting_condition.AlertingCondition{} 52 _ = &common.LabelDescriptor{} 53 _ = &meta.Meta{} 54 ) 55 56 // FieldPath provides implementation to handle 57 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 58 type Alert_FieldPath interface { 59 gotenobject.FieldPath 60 Selector() Alert_FieldPathSelector 61 Get(source *Alert) []interface{} 62 GetSingle(source *Alert) (interface{}, bool) 63 ClearValue(item *Alert) 64 65 // Those methods build corresponding Alert_FieldPathValue 66 // (or array of values) and holds passed value. Panics if injected type is incorrect. 67 WithIValue(value interface{}) Alert_FieldPathValue 68 WithIArrayOfValues(values interface{}) Alert_FieldPathArrayOfValues 69 WithIArrayItemValue(value interface{}) Alert_FieldPathArrayItemValue 70 } 71 72 type Alert_FieldPathSelector int32 73 74 const ( 75 Alert_FieldPathSelectorName Alert_FieldPathSelector = 0 76 Alert_FieldPathSelectorMetadata Alert_FieldPathSelector = 1 77 Alert_FieldPathSelectorDisplayName Alert_FieldPathSelector = 2 78 Alert_FieldPathSelectorInfo Alert_FieldPathSelector = 3 79 Alert_FieldPathSelectorState Alert_FieldPathSelector = 4 80 ) 81 82 func (s Alert_FieldPathSelector) String() string { 83 switch s { 84 case Alert_FieldPathSelectorName: 85 return "name" 86 case Alert_FieldPathSelectorMetadata: 87 return "metadata" 88 case Alert_FieldPathSelectorDisplayName: 89 return "display_name" 90 case Alert_FieldPathSelectorInfo: 91 return "info" 92 case Alert_FieldPathSelectorState: 93 return "state" 94 default: 95 panic(fmt.Sprintf("Invalid selector for Alert: %d", s)) 96 } 97 } 98 99 func BuildAlert_FieldPath(fp gotenobject.RawFieldPath) (Alert_FieldPath, error) { 100 if len(fp) == 0 { 101 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert") 102 } 103 if len(fp) == 1 { 104 switch fp[0] { 105 case "name": 106 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorName}, nil 107 case "metadata": 108 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorMetadata}, nil 109 case "display_name", "displayName", "display-name": 110 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorDisplayName}, nil 111 case "info": 112 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorInfo}, nil 113 case "state": 114 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorState}, nil 115 } 116 } else { 117 switch fp[0] { 118 case "metadata": 119 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 120 return nil, err 121 } else { 122 return &Alert_FieldSubPath{selector: Alert_FieldPathSelectorMetadata, subPath: subpath}, nil 123 } 124 case "info": 125 if subpath, err := BuildAlertInfo_FieldPath(fp[1:]); err != nil { 126 return nil, err 127 } else { 128 return &Alert_FieldSubPath{selector: Alert_FieldPathSelectorInfo, subPath: subpath}, nil 129 } 130 case "state": 131 if subpath, err := BuildAlertState_FieldPath(fp[1:]); err != nil { 132 return nil, err 133 } else { 134 return &Alert_FieldSubPath{selector: Alert_FieldPathSelectorState, subPath: subpath}, nil 135 } 136 } 137 } 138 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert", fp) 139 } 140 141 func ParseAlert_FieldPath(rawField string) (Alert_FieldPath, error) { 142 fp, err := gotenobject.ParseRawFieldPath(rawField) 143 if err != nil { 144 return nil, err 145 } 146 return BuildAlert_FieldPath(fp) 147 } 148 149 func MustParseAlert_FieldPath(rawField string) Alert_FieldPath { 150 fp, err := ParseAlert_FieldPath(rawField) 151 if err != nil { 152 panic(err) 153 } 154 return fp 155 } 156 157 type Alert_FieldTerminalPath struct { 158 selector Alert_FieldPathSelector 159 } 160 161 var _ Alert_FieldPath = (*Alert_FieldTerminalPath)(nil) 162 163 func (fp *Alert_FieldTerminalPath) Selector() Alert_FieldPathSelector { 164 return fp.selector 165 } 166 167 // String returns path representation in proto convention 168 func (fp *Alert_FieldTerminalPath) String() string { 169 return fp.selector.String() 170 } 171 172 // JSONString returns path representation is JSON convention 173 func (fp *Alert_FieldTerminalPath) JSONString() string { 174 return strcase.ToLowerCamel(fp.String()) 175 } 176 177 // Get returns all values pointed by specific field from source Alert 178 func (fp *Alert_FieldTerminalPath) Get(source *Alert) (values []interface{}) { 179 if source != nil { 180 switch fp.selector { 181 case Alert_FieldPathSelectorName: 182 if source.Name != nil { 183 values = append(values, source.Name) 184 } 185 case Alert_FieldPathSelectorMetadata: 186 if source.Metadata != nil { 187 values = append(values, source.Metadata) 188 } 189 case Alert_FieldPathSelectorDisplayName: 190 values = append(values, source.DisplayName) 191 case Alert_FieldPathSelectorInfo: 192 if source.Info != nil { 193 values = append(values, source.Info) 194 } 195 case Alert_FieldPathSelectorState: 196 if source.State != nil { 197 values = append(values, source.State) 198 } 199 default: 200 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 201 } 202 } 203 return 204 } 205 206 func (fp *Alert_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 207 return fp.Get(source.(*Alert)) 208 } 209 210 // GetSingle returns value pointed by specific field of from source Alert 211 func (fp *Alert_FieldTerminalPath) GetSingle(source *Alert) (interface{}, bool) { 212 switch fp.selector { 213 case Alert_FieldPathSelectorName: 214 res := source.GetName() 215 return res, res != nil 216 case Alert_FieldPathSelectorMetadata: 217 res := source.GetMetadata() 218 return res, res != nil 219 case Alert_FieldPathSelectorDisplayName: 220 return source.GetDisplayName(), source != nil 221 case Alert_FieldPathSelectorInfo: 222 res := source.GetInfo() 223 return res, res != nil 224 case Alert_FieldPathSelectorState: 225 res := source.GetState() 226 return res, res != nil 227 default: 228 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 229 } 230 } 231 232 func (fp *Alert_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 233 return fp.GetSingle(source.(*Alert)) 234 } 235 236 // GetDefault returns a default value of the field type 237 func (fp *Alert_FieldTerminalPath) GetDefault() interface{} { 238 switch fp.selector { 239 case Alert_FieldPathSelectorName: 240 return (*Name)(nil) 241 case Alert_FieldPathSelectorMetadata: 242 return (*meta.Meta)(nil) 243 case Alert_FieldPathSelectorDisplayName: 244 return "" 245 case Alert_FieldPathSelectorInfo: 246 return (*Alert_Info)(nil) 247 case Alert_FieldPathSelectorState: 248 return (*Alert_State)(nil) 249 default: 250 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 251 } 252 } 253 254 func (fp *Alert_FieldTerminalPath) ClearValue(item *Alert) { 255 if item != nil { 256 switch fp.selector { 257 case Alert_FieldPathSelectorName: 258 item.Name = nil 259 case Alert_FieldPathSelectorMetadata: 260 item.Metadata = nil 261 case Alert_FieldPathSelectorDisplayName: 262 item.DisplayName = "" 263 case Alert_FieldPathSelectorInfo: 264 item.Info = nil 265 case Alert_FieldPathSelectorState: 266 item.State = nil 267 default: 268 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 269 } 270 } 271 } 272 273 func (fp *Alert_FieldTerminalPath) ClearValueRaw(item proto.Message) { 274 fp.ClearValue(item.(*Alert)) 275 } 276 277 // IsLeaf - whether field path is holds simple value 278 func (fp *Alert_FieldTerminalPath) IsLeaf() bool { 279 return fp.selector == Alert_FieldPathSelectorName || 280 fp.selector == Alert_FieldPathSelectorDisplayName 281 } 282 283 func (fp *Alert_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 284 return []gotenobject.FieldPath{fp} 285 } 286 287 func (fp *Alert_FieldTerminalPath) WithIValue(value interface{}) Alert_FieldPathValue { 288 switch fp.selector { 289 case Alert_FieldPathSelectorName: 290 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*Name)} 291 case Alert_FieldPathSelectorMetadata: 292 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 293 case Alert_FieldPathSelectorDisplayName: 294 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(string)} 295 case Alert_FieldPathSelectorInfo: 296 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*Alert_Info)} 297 case Alert_FieldPathSelectorState: 298 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*Alert_State)} 299 default: 300 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 301 } 302 } 303 304 func (fp *Alert_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 305 return fp.WithIValue(value) 306 } 307 308 func (fp *Alert_FieldTerminalPath) WithIArrayOfValues(values interface{}) Alert_FieldPathArrayOfValues { 309 fpaov := &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp} 310 switch fp.selector { 311 case Alert_FieldPathSelectorName: 312 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*Name)} 313 case Alert_FieldPathSelectorMetadata: 314 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 315 case Alert_FieldPathSelectorDisplayName: 316 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]string)} 317 case Alert_FieldPathSelectorInfo: 318 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*Alert_Info)} 319 case Alert_FieldPathSelectorState: 320 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*Alert_State)} 321 default: 322 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 323 } 324 return fpaov 325 } 326 327 func (fp *Alert_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 328 return fp.WithIArrayOfValues(values) 329 } 330 331 func (fp *Alert_FieldTerminalPath) WithIArrayItemValue(value interface{}) Alert_FieldPathArrayItemValue { 332 switch fp.selector { 333 default: 334 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 335 } 336 } 337 338 func (fp *Alert_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 339 return fp.WithIArrayItemValue(value) 340 } 341 342 type Alert_FieldSubPath struct { 343 selector Alert_FieldPathSelector 344 subPath gotenobject.FieldPath 345 } 346 347 var _ Alert_FieldPath = (*Alert_FieldSubPath)(nil) 348 349 func (fps *Alert_FieldSubPath) Selector() Alert_FieldPathSelector { 350 return fps.selector 351 } 352 func (fps *Alert_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 353 res, ok := fps.subPath.(meta.Meta_FieldPath) 354 return res, ok 355 } 356 func (fps *Alert_FieldSubPath) AsInfoSubPath() (AlertInfo_FieldPath, bool) { 357 res, ok := fps.subPath.(AlertInfo_FieldPath) 358 return res, ok 359 } 360 func (fps *Alert_FieldSubPath) AsStateSubPath() (AlertState_FieldPath, bool) { 361 res, ok := fps.subPath.(AlertState_FieldPath) 362 return res, ok 363 } 364 365 // String returns path representation in proto convention 366 func (fps *Alert_FieldSubPath) String() string { 367 return fps.selector.String() + "." + fps.subPath.String() 368 } 369 370 // JSONString returns path representation is JSON convention 371 func (fps *Alert_FieldSubPath) JSONString() string { 372 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 373 } 374 375 // Get returns all values pointed by selected field from source Alert 376 func (fps *Alert_FieldSubPath) Get(source *Alert) (values []interface{}) { 377 switch fps.selector { 378 case Alert_FieldPathSelectorMetadata: 379 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 380 case Alert_FieldPathSelectorInfo: 381 values = append(values, fps.subPath.GetRaw(source.GetInfo())...) 382 case Alert_FieldPathSelectorState: 383 values = append(values, fps.subPath.GetRaw(source.GetState())...) 384 default: 385 panic(fmt.Sprintf("Invalid selector for Alert: %d", fps.selector)) 386 } 387 return 388 } 389 390 func (fps *Alert_FieldSubPath) GetRaw(source proto.Message) []interface{} { 391 return fps.Get(source.(*Alert)) 392 } 393 394 // GetSingle returns value of selected field from source Alert 395 func (fps *Alert_FieldSubPath) GetSingle(source *Alert) (interface{}, bool) { 396 switch fps.selector { 397 case Alert_FieldPathSelectorMetadata: 398 if source.GetMetadata() == nil { 399 return nil, false 400 } 401 return fps.subPath.GetSingleRaw(source.GetMetadata()) 402 case Alert_FieldPathSelectorInfo: 403 if source.GetInfo() == nil { 404 return nil, false 405 } 406 return fps.subPath.GetSingleRaw(source.GetInfo()) 407 case Alert_FieldPathSelectorState: 408 if source.GetState() == nil { 409 return nil, false 410 } 411 return fps.subPath.GetSingleRaw(source.GetState()) 412 default: 413 panic(fmt.Sprintf("Invalid selector for Alert: %d", fps.selector)) 414 } 415 } 416 417 func (fps *Alert_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 418 return fps.GetSingle(source.(*Alert)) 419 } 420 421 // GetDefault returns a default value of the field type 422 func (fps *Alert_FieldSubPath) GetDefault() interface{} { 423 return fps.subPath.GetDefault() 424 } 425 426 func (fps *Alert_FieldSubPath) ClearValue(item *Alert) { 427 if item != nil { 428 switch fps.selector { 429 case Alert_FieldPathSelectorMetadata: 430 fps.subPath.ClearValueRaw(item.Metadata) 431 case Alert_FieldPathSelectorInfo: 432 fps.subPath.ClearValueRaw(item.Info) 433 case Alert_FieldPathSelectorState: 434 fps.subPath.ClearValueRaw(item.State) 435 default: 436 panic(fmt.Sprintf("Invalid selector for Alert: %d", fps.selector)) 437 } 438 } 439 } 440 441 func (fps *Alert_FieldSubPath) ClearValueRaw(item proto.Message) { 442 fps.ClearValue(item.(*Alert)) 443 } 444 445 // IsLeaf - whether field path is holds simple value 446 func (fps *Alert_FieldSubPath) IsLeaf() bool { 447 return fps.subPath.IsLeaf() 448 } 449 450 func (fps *Alert_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 451 iPaths := []gotenobject.FieldPath{&Alert_FieldTerminalPath{selector: fps.selector}} 452 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 453 return iPaths 454 } 455 456 func (fps *Alert_FieldSubPath) WithIValue(value interface{}) Alert_FieldPathValue { 457 return &Alert_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 458 } 459 460 func (fps *Alert_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 461 return fps.WithIValue(value) 462 } 463 464 func (fps *Alert_FieldSubPath) WithIArrayOfValues(values interface{}) Alert_FieldPathArrayOfValues { 465 return &Alert_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 466 } 467 468 func (fps *Alert_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 469 return fps.WithIArrayOfValues(values) 470 } 471 472 func (fps *Alert_FieldSubPath) WithIArrayItemValue(value interface{}) Alert_FieldPathArrayItemValue { 473 return &Alert_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 474 } 475 476 func (fps *Alert_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 477 return fps.WithIArrayItemValue(value) 478 } 479 480 // Alert_FieldPathValue allows storing values for Alert fields according to their type 481 type Alert_FieldPathValue interface { 482 Alert_FieldPath 483 gotenobject.FieldPathValue 484 SetTo(target **Alert) 485 CompareWith(*Alert) (cmp int, comparable bool) 486 } 487 488 func ParseAlert_FieldPathValue(pathStr, valueStr string) (Alert_FieldPathValue, error) { 489 fp, err := ParseAlert_FieldPath(pathStr) 490 if err != nil { 491 return nil, err 492 } 493 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 494 if err != nil { 495 return nil, status.Errorf(codes.InvalidArgument, "error parsing Alert field path value from %s: %v", valueStr, err) 496 } 497 return fpv.(Alert_FieldPathValue), nil 498 } 499 500 func MustParseAlert_FieldPathValue(pathStr, valueStr string) Alert_FieldPathValue { 501 fpv, err := ParseAlert_FieldPathValue(pathStr, valueStr) 502 if err != nil { 503 panic(err) 504 } 505 return fpv 506 } 507 508 type Alert_FieldTerminalPathValue struct { 509 Alert_FieldTerminalPath 510 value interface{} 511 } 512 513 var _ Alert_FieldPathValue = (*Alert_FieldTerminalPathValue)(nil) 514 515 // GetRawValue returns raw value stored under selected path for 'Alert' as interface{} 516 func (fpv *Alert_FieldTerminalPathValue) GetRawValue() interface{} { 517 return fpv.value 518 } 519 func (fpv *Alert_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 520 res, ok := fpv.value.(*Name) 521 return res, ok 522 } 523 func (fpv *Alert_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 524 res, ok := fpv.value.(*meta.Meta) 525 return res, ok 526 } 527 func (fpv *Alert_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) { 528 res, ok := fpv.value.(string) 529 return res, ok 530 } 531 func (fpv *Alert_FieldTerminalPathValue) AsInfoValue() (*Alert_Info, bool) { 532 res, ok := fpv.value.(*Alert_Info) 533 return res, ok 534 } 535 func (fpv *Alert_FieldTerminalPathValue) AsStateValue() (*Alert_State, bool) { 536 res, ok := fpv.value.(*Alert_State) 537 return res, ok 538 } 539 540 // SetTo stores value for selected field for object Alert 541 func (fpv *Alert_FieldTerminalPathValue) SetTo(target **Alert) { 542 if *target == nil { 543 *target = new(Alert) 544 } 545 switch fpv.selector { 546 case Alert_FieldPathSelectorName: 547 (*target).Name = fpv.value.(*Name) 548 case Alert_FieldPathSelectorMetadata: 549 (*target).Metadata = fpv.value.(*meta.Meta) 550 case Alert_FieldPathSelectorDisplayName: 551 (*target).DisplayName = fpv.value.(string) 552 case Alert_FieldPathSelectorInfo: 553 (*target).Info = fpv.value.(*Alert_Info) 554 case Alert_FieldPathSelectorState: 555 (*target).State = fpv.value.(*Alert_State) 556 default: 557 panic(fmt.Sprintf("Invalid selector for Alert: %d", fpv.selector)) 558 } 559 } 560 561 func (fpv *Alert_FieldTerminalPathValue) SetToRaw(target proto.Message) { 562 typedObject := target.(*Alert) 563 fpv.SetTo(&typedObject) 564 } 565 566 // CompareWith compares value in the 'Alert_FieldTerminalPathValue' with the value under path in 'Alert'. 567 func (fpv *Alert_FieldTerminalPathValue) CompareWith(source *Alert) (int, bool) { 568 switch fpv.selector { 569 case Alert_FieldPathSelectorName: 570 leftValue := fpv.value.(*Name) 571 rightValue := source.GetName() 572 if leftValue == nil { 573 if rightValue != nil { 574 return -1, true 575 } 576 return 0, true 577 } 578 if rightValue == nil { 579 return 1, true 580 } 581 if leftValue.String() == rightValue.String() { 582 return 0, true 583 } else if leftValue.String() < rightValue.String() { 584 return -1, true 585 } else { 586 return 1, true 587 } 588 case Alert_FieldPathSelectorMetadata: 589 return 0, false 590 case Alert_FieldPathSelectorDisplayName: 591 leftValue := fpv.value.(string) 592 rightValue := source.GetDisplayName() 593 if (leftValue) == (rightValue) { 594 return 0, true 595 } else if (leftValue) < (rightValue) { 596 return -1, true 597 } else { 598 return 1, true 599 } 600 case Alert_FieldPathSelectorInfo: 601 return 0, false 602 case Alert_FieldPathSelectorState: 603 return 0, false 604 default: 605 panic(fmt.Sprintf("Invalid selector for Alert: %d", fpv.selector)) 606 } 607 } 608 609 func (fpv *Alert_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 610 return fpv.CompareWith(source.(*Alert)) 611 } 612 613 type Alert_FieldSubPathValue struct { 614 Alert_FieldPath 615 subPathValue gotenobject.FieldPathValue 616 } 617 618 var _ Alert_FieldPathValue = (*Alert_FieldSubPathValue)(nil) 619 620 func (fpvs *Alert_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 621 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 622 return res, ok 623 } 624 func (fpvs *Alert_FieldSubPathValue) AsInfoPathValue() (AlertInfo_FieldPathValue, bool) { 625 res, ok := fpvs.subPathValue.(AlertInfo_FieldPathValue) 626 return res, ok 627 } 628 func (fpvs *Alert_FieldSubPathValue) AsStatePathValue() (AlertState_FieldPathValue, bool) { 629 res, ok := fpvs.subPathValue.(AlertState_FieldPathValue) 630 return res, ok 631 } 632 633 func (fpvs *Alert_FieldSubPathValue) SetTo(target **Alert) { 634 if *target == nil { 635 *target = new(Alert) 636 } 637 switch fpvs.Selector() { 638 case Alert_FieldPathSelectorMetadata: 639 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 640 case Alert_FieldPathSelectorInfo: 641 fpvs.subPathValue.(AlertInfo_FieldPathValue).SetTo(&(*target).Info) 642 case Alert_FieldPathSelectorState: 643 fpvs.subPathValue.(AlertState_FieldPathValue).SetTo(&(*target).State) 644 default: 645 panic(fmt.Sprintf("Invalid selector for Alert: %d", fpvs.Selector())) 646 } 647 } 648 649 func (fpvs *Alert_FieldSubPathValue) SetToRaw(target proto.Message) { 650 typedObject := target.(*Alert) 651 fpvs.SetTo(&typedObject) 652 } 653 654 func (fpvs *Alert_FieldSubPathValue) GetRawValue() interface{} { 655 return fpvs.subPathValue.GetRawValue() 656 } 657 658 func (fpvs *Alert_FieldSubPathValue) CompareWith(source *Alert) (int, bool) { 659 switch fpvs.Selector() { 660 case Alert_FieldPathSelectorMetadata: 661 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 662 case Alert_FieldPathSelectorInfo: 663 return fpvs.subPathValue.(AlertInfo_FieldPathValue).CompareWith(source.GetInfo()) 664 case Alert_FieldPathSelectorState: 665 return fpvs.subPathValue.(AlertState_FieldPathValue).CompareWith(source.GetState()) 666 default: 667 panic(fmt.Sprintf("Invalid selector for Alert: %d", fpvs.Selector())) 668 } 669 } 670 671 func (fpvs *Alert_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 672 return fpvs.CompareWith(source.(*Alert)) 673 } 674 675 // Alert_FieldPathArrayItemValue allows storing single item in Path-specific values for Alert according to their type 676 // Present only for array (repeated) types. 677 type Alert_FieldPathArrayItemValue interface { 678 gotenobject.FieldPathArrayItemValue 679 Alert_FieldPath 680 ContainsValue(*Alert) bool 681 } 682 683 // ParseAlert_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 684 func ParseAlert_FieldPathArrayItemValue(pathStr, valueStr string) (Alert_FieldPathArrayItemValue, error) { 685 fp, err := ParseAlert_FieldPath(pathStr) 686 if err != nil { 687 return nil, err 688 } 689 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 690 if err != nil { 691 return nil, status.Errorf(codes.InvalidArgument, "error parsing Alert field path array item value from %s: %v", valueStr, err) 692 } 693 return fpaiv.(Alert_FieldPathArrayItemValue), nil 694 } 695 696 func MustParseAlert_FieldPathArrayItemValue(pathStr, valueStr string) Alert_FieldPathArrayItemValue { 697 fpaiv, err := ParseAlert_FieldPathArrayItemValue(pathStr, valueStr) 698 if err != nil { 699 panic(err) 700 } 701 return fpaiv 702 } 703 704 type Alert_FieldTerminalPathArrayItemValue struct { 705 Alert_FieldTerminalPath 706 value interface{} 707 } 708 709 var _ Alert_FieldPathArrayItemValue = (*Alert_FieldTerminalPathArrayItemValue)(nil) 710 711 // GetRawValue returns stored element value for array in object Alert as interface{} 712 func (fpaiv *Alert_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 713 return fpaiv.value 714 } 715 716 func (fpaiv *Alert_FieldTerminalPathArrayItemValue) GetSingle(source *Alert) (interface{}, bool) { 717 return nil, false 718 } 719 720 func (fpaiv *Alert_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 721 return fpaiv.GetSingle(source.(*Alert)) 722 } 723 724 // Contains returns a boolean indicating if value that is being held is present in given 'Alert' 725 func (fpaiv *Alert_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert) bool { 726 slice := fpaiv.Alert_FieldTerminalPath.Get(source) 727 for _, v := range slice { 728 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 729 if proto.Equal(asProtoMsg, v.(proto.Message)) { 730 return true 731 } 732 } else if reflect.DeepEqual(v, fpaiv.value) { 733 return true 734 } 735 } 736 return false 737 } 738 739 type Alert_FieldSubPathArrayItemValue struct { 740 Alert_FieldPath 741 subPathItemValue gotenobject.FieldPathArrayItemValue 742 } 743 744 // GetRawValue returns stored array item value 745 func (fpaivs *Alert_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 746 return fpaivs.subPathItemValue.GetRawItemValue() 747 } 748 func (fpaivs *Alert_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 749 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 750 return res, ok 751 } 752 func (fpaivs *Alert_FieldSubPathArrayItemValue) AsInfoPathItemValue() (AlertInfo_FieldPathArrayItemValue, bool) { 753 res, ok := fpaivs.subPathItemValue.(AlertInfo_FieldPathArrayItemValue) 754 return res, ok 755 } 756 func (fpaivs *Alert_FieldSubPathArrayItemValue) AsStatePathItemValue() (AlertState_FieldPathArrayItemValue, bool) { 757 res, ok := fpaivs.subPathItemValue.(AlertState_FieldPathArrayItemValue) 758 return res, ok 759 } 760 761 // Contains returns a boolean indicating if value that is being held is present in given 'Alert' 762 func (fpaivs *Alert_FieldSubPathArrayItemValue) ContainsValue(source *Alert) bool { 763 switch fpaivs.Selector() { 764 case Alert_FieldPathSelectorMetadata: 765 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 766 case Alert_FieldPathSelectorInfo: 767 return fpaivs.subPathItemValue.(AlertInfo_FieldPathArrayItemValue).ContainsValue(source.GetInfo()) 768 case Alert_FieldPathSelectorState: 769 return fpaivs.subPathItemValue.(AlertState_FieldPathArrayItemValue).ContainsValue(source.GetState()) 770 default: 771 panic(fmt.Sprintf("Invalid selector for Alert: %d", fpaivs.Selector())) 772 } 773 } 774 775 // Alert_FieldPathArrayOfValues allows storing slice of values for Alert fields according to their type 776 type Alert_FieldPathArrayOfValues interface { 777 gotenobject.FieldPathArrayOfValues 778 Alert_FieldPath 779 } 780 781 func ParseAlert_FieldPathArrayOfValues(pathStr, valuesStr string) (Alert_FieldPathArrayOfValues, error) { 782 fp, err := ParseAlert_FieldPath(pathStr) 783 if err != nil { 784 return nil, err 785 } 786 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 787 if err != nil { 788 return nil, status.Errorf(codes.InvalidArgument, "error parsing Alert field path array of values from %s: %v", valuesStr, err) 789 } 790 return fpaov.(Alert_FieldPathArrayOfValues), nil 791 } 792 793 func MustParseAlert_FieldPathArrayOfValues(pathStr, valuesStr string) Alert_FieldPathArrayOfValues { 794 fpaov, err := ParseAlert_FieldPathArrayOfValues(pathStr, valuesStr) 795 if err != nil { 796 panic(err) 797 } 798 return fpaov 799 } 800 801 type Alert_FieldTerminalPathArrayOfValues struct { 802 Alert_FieldTerminalPath 803 values interface{} 804 } 805 806 var _ Alert_FieldPathArrayOfValues = (*Alert_FieldTerminalPathArrayOfValues)(nil) 807 808 func (fpaov *Alert_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 809 switch fpaov.selector { 810 case Alert_FieldPathSelectorName: 811 for _, v := range fpaov.values.([]*Name) { 812 values = append(values, v) 813 } 814 case Alert_FieldPathSelectorMetadata: 815 for _, v := range fpaov.values.([]*meta.Meta) { 816 values = append(values, v) 817 } 818 case Alert_FieldPathSelectorDisplayName: 819 for _, v := range fpaov.values.([]string) { 820 values = append(values, v) 821 } 822 case Alert_FieldPathSelectorInfo: 823 for _, v := range fpaov.values.([]*Alert_Info) { 824 values = append(values, v) 825 } 826 case Alert_FieldPathSelectorState: 827 for _, v := range fpaov.values.([]*Alert_State) { 828 values = append(values, v) 829 } 830 } 831 return 832 } 833 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 834 res, ok := fpaov.values.([]*Name) 835 return res, ok 836 } 837 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 838 res, ok := fpaov.values.([]*meta.Meta) 839 return res, ok 840 } 841 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) { 842 res, ok := fpaov.values.([]string) 843 return res, ok 844 } 845 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsInfoArrayOfValues() ([]*Alert_Info, bool) { 846 res, ok := fpaov.values.([]*Alert_Info) 847 return res, ok 848 } 849 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsStateArrayOfValues() ([]*Alert_State, bool) { 850 res, ok := fpaov.values.([]*Alert_State) 851 return res, ok 852 } 853 854 type Alert_FieldSubPathArrayOfValues struct { 855 Alert_FieldPath 856 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 857 } 858 859 var _ Alert_FieldPathArrayOfValues = (*Alert_FieldSubPathArrayOfValues)(nil) 860 861 func (fpsaov *Alert_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 862 return fpsaov.subPathArrayOfValues.GetRawValues() 863 } 864 func (fpsaov *Alert_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 865 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 866 return res, ok 867 } 868 func (fpsaov *Alert_FieldSubPathArrayOfValues) AsInfoPathArrayOfValues() (AlertInfo_FieldPathArrayOfValues, bool) { 869 res, ok := fpsaov.subPathArrayOfValues.(AlertInfo_FieldPathArrayOfValues) 870 return res, ok 871 } 872 func (fpsaov *Alert_FieldSubPathArrayOfValues) AsStatePathArrayOfValues() (AlertState_FieldPathArrayOfValues, bool) { 873 res, ok := fpsaov.subPathArrayOfValues.(AlertState_FieldPathArrayOfValues) 874 return res, ok 875 } 876 877 // FieldPath provides implementation to handle 878 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 879 type AlertInfo_FieldPath interface { 880 gotenobject.FieldPath 881 Selector() AlertInfo_FieldPathSelector 882 Get(source *Alert_Info) []interface{} 883 GetSingle(source *Alert_Info) (interface{}, bool) 884 ClearValue(item *Alert_Info) 885 886 // Those methods build corresponding AlertInfo_FieldPathValue 887 // (or array of values) and holds passed value. Panics if injected type is incorrect. 888 WithIValue(value interface{}) AlertInfo_FieldPathValue 889 WithIArrayOfValues(values interface{}) AlertInfo_FieldPathArrayOfValues 890 WithIArrayItemValue(value interface{}) AlertInfo_FieldPathArrayItemValue 891 } 892 893 type AlertInfo_FieldPathSelector int32 894 895 const ( 896 AlertInfo_FieldPathSelectorTimeSerie AlertInfo_FieldPathSelector = 0 897 AlertInfo_FieldPathSelectorObservedValues AlertInfo_FieldPathSelector = 1 898 ) 899 900 func (s AlertInfo_FieldPathSelector) String() string { 901 switch s { 902 case AlertInfo_FieldPathSelectorTimeSerie: 903 return "time_serie" 904 case AlertInfo_FieldPathSelectorObservedValues: 905 return "observed_values" 906 default: 907 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", s)) 908 } 909 } 910 911 func BuildAlertInfo_FieldPath(fp gotenobject.RawFieldPath) (AlertInfo_FieldPath, error) { 912 if len(fp) == 0 { 913 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_Info") 914 } 915 if len(fp) == 1 { 916 switch fp[0] { 917 case "time_serie", "timeSerie", "time-serie": 918 return &AlertInfo_FieldTerminalPath{selector: AlertInfo_FieldPathSelectorTimeSerie}, nil 919 case "observed_values", "observedValues", "observed-values": 920 return &AlertInfo_FieldTerminalPath{selector: AlertInfo_FieldPathSelectorObservedValues}, nil 921 } 922 } else { 923 switch fp[0] { 924 case "time_serie", "timeSerie", "time-serie": 925 if subpath, err := BuildAlertInfoTimeSerie_FieldPath(fp[1:]); err != nil { 926 return nil, err 927 } else { 928 return &AlertInfo_FieldSubPath{selector: AlertInfo_FieldPathSelectorTimeSerie, subPath: subpath}, nil 929 } 930 case "observed_values", "observedValues", "observed-values": 931 if subpath, err := BuildAlertInfoObservedValues_FieldPath(fp[1:]); err != nil { 932 return nil, err 933 } else { 934 return &AlertInfo_FieldSubPath{selector: AlertInfo_FieldPathSelectorObservedValues, subPath: subpath}, nil 935 } 936 } 937 } 938 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_Info", fp) 939 } 940 941 func ParseAlertInfo_FieldPath(rawField string) (AlertInfo_FieldPath, error) { 942 fp, err := gotenobject.ParseRawFieldPath(rawField) 943 if err != nil { 944 return nil, err 945 } 946 return BuildAlertInfo_FieldPath(fp) 947 } 948 949 func MustParseAlertInfo_FieldPath(rawField string) AlertInfo_FieldPath { 950 fp, err := ParseAlertInfo_FieldPath(rawField) 951 if err != nil { 952 panic(err) 953 } 954 return fp 955 } 956 957 type AlertInfo_FieldTerminalPath struct { 958 selector AlertInfo_FieldPathSelector 959 } 960 961 var _ AlertInfo_FieldPath = (*AlertInfo_FieldTerminalPath)(nil) 962 963 func (fp *AlertInfo_FieldTerminalPath) Selector() AlertInfo_FieldPathSelector { 964 return fp.selector 965 } 966 967 // String returns path representation in proto convention 968 func (fp *AlertInfo_FieldTerminalPath) String() string { 969 return fp.selector.String() 970 } 971 972 // JSONString returns path representation is JSON convention 973 func (fp *AlertInfo_FieldTerminalPath) JSONString() string { 974 return strcase.ToLowerCamel(fp.String()) 975 } 976 977 // Get returns all values pointed by specific field from source Alert_Info 978 func (fp *AlertInfo_FieldTerminalPath) Get(source *Alert_Info) (values []interface{}) { 979 if source != nil { 980 switch fp.selector { 981 case AlertInfo_FieldPathSelectorTimeSerie: 982 if source.TimeSerie != nil { 983 values = append(values, source.TimeSerie) 984 } 985 case AlertInfo_FieldPathSelectorObservedValues: 986 if source.ObservedValues != nil { 987 values = append(values, source.ObservedValues) 988 } 989 default: 990 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fp.selector)) 991 } 992 } 993 return 994 } 995 996 func (fp *AlertInfo_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 997 return fp.Get(source.(*Alert_Info)) 998 } 999 1000 // GetSingle returns value pointed by specific field of from source Alert_Info 1001 func (fp *AlertInfo_FieldTerminalPath) GetSingle(source *Alert_Info) (interface{}, bool) { 1002 switch fp.selector { 1003 case AlertInfo_FieldPathSelectorTimeSerie: 1004 res := source.GetTimeSerie() 1005 return res, res != nil 1006 case AlertInfo_FieldPathSelectorObservedValues: 1007 res := source.GetObservedValues() 1008 return res, res != nil 1009 default: 1010 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fp.selector)) 1011 } 1012 } 1013 1014 func (fp *AlertInfo_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1015 return fp.GetSingle(source.(*Alert_Info)) 1016 } 1017 1018 // GetDefault returns a default value of the field type 1019 func (fp *AlertInfo_FieldTerminalPath) GetDefault() interface{} { 1020 switch fp.selector { 1021 case AlertInfo_FieldPathSelectorTimeSerie: 1022 return (*Alert_Info_TimeSerie)(nil) 1023 case AlertInfo_FieldPathSelectorObservedValues: 1024 return (*Alert_Info_ObservedValues)(nil) 1025 default: 1026 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fp.selector)) 1027 } 1028 } 1029 1030 func (fp *AlertInfo_FieldTerminalPath) ClearValue(item *Alert_Info) { 1031 if item != nil { 1032 switch fp.selector { 1033 case AlertInfo_FieldPathSelectorTimeSerie: 1034 item.TimeSerie = nil 1035 case AlertInfo_FieldPathSelectorObservedValues: 1036 item.ObservedValues = nil 1037 default: 1038 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fp.selector)) 1039 } 1040 } 1041 } 1042 1043 func (fp *AlertInfo_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1044 fp.ClearValue(item.(*Alert_Info)) 1045 } 1046 1047 // IsLeaf - whether field path is holds simple value 1048 func (fp *AlertInfo_FieldTerminalPath) IsLeaf() bool { 1049 return false 1050 } 1051 1052 func (fp *AlertInfo_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1053 return []gotenobject.FieldPath{fp} 1054 } 1055 1056 func (fp *AlertInfo_FieldTerminalPath) WithIValue(value interface{}) AlertInfo_FieldPathValue { 1057 switch fp.selector { 1058 case AlertInfo_FieldPathSelectorTimeSerie: 1059 return &AlertInfo_FieldTerminalPathValue{AlertInfo_FieldTerminalPath: *fp, value: value.(*Alert_Info_TimeSerie)} 1060 case AlertInfo_FieldPathSelectorObservedValues: 1061 return &AlertInfo_FieldTerminalPathValue{AlertInfo_FieldTerminalPath: *fp, value: value.(*Alert_Info_ObservedValues)} 1062 default: 1063 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fp.selector)) 1064 } 1065 } 1066 1067 func (fp *AlertInfo_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1068 return fp.WithIValue(value) 1069 } 1070 1071 func (fp *AlertInfo_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertInfo_FieldPathArrayOfValues { 1072 fpaov := &AlertInfo_FieldTerminalPathArrayOfValues{AlertInfo_FieldTerminalPath: *fp} 1073 switch fp.selector { 1074 case AlertInfo_FieldPathSelectorTimeSerie: 1075 return &AlertInfo_FieldTerminalPathArrayOfValues{AlertInfo_FieldTerminalPath: *fp, values: values.([]*Alert_Info_TimeSerie)} 1076 case AlertInfo_FieldPathSelectorObservedValues: 1077 return &AlertInfo_FieldTerminalPathArrayOfValues{AlertInfo_FieldTerminalPath: *fp, values: values.([]*Alert_Info_ObservedValues)} 1078 default: 1079 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fp.selector)) 1080 } 1081 return fpaov 1082 } 1083 1084 func (fp *AlertInfo_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1085 return fp.WithIArrayOfValues(values) 1086 } 1087 1088 func (fp *AlertInfo_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertInfo_FieldPathArrayItemValue { 1089 switch fp.selector { 1090 default: 1091 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fp.selector)) 1092 } 1093 } 1094 1095 func (fp *AlertInfo_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1096 return fp.WithIArrayItemValue(value) 1097 } 1098 1099 type AlertInfo_FieldSubPath struct { 1100 selector AlertInfo_FieldPathSelector 1101 subPath gotenobject.FieldPath 1102 } 1103 1104 var _ AlertInfo_FieldPath = (*AlertInfo_FieldSubPath)(nil) 1105 1106 func (fps *AlertInfo_FieldSubPath) Selector() AlertInfo_FieldPathSelector { 1107 return fps.selector 1108 } 1109 func (fps *AlertInfo_FieldSubPath) AsTimeSerieSubPath() (AlertInfoTimeSerie_FieldPath, bool) { 1110 res, ok := fps.subPath.(AlertInfoTimeSerie_FieldPath) 1111 return res, ok 1112 } 1113 func (fps *AlertInfo_FieldSubPath) AsObservedValuesSubPath() (AlertInfoObservedValues_FieldPath, bool) { 1114 res, ok := fps.subPath.(AlertInfoObservedValues_FieldPath) 1115 return res, ok 1116 } 1117 1118 // String returns path representation in proto convention 1119 func (fps *AlertInfo_FieldSubPath) String() string { 1120 return fps.selector.String() + "." + fps.subPath.String() 1121 } 1122 1123 // JSONString returns path representation is JSON convention 1124 func (fps *AlertInfo_FieldSubPath) JSONString() string { 1125 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 1126 } 1127 1128 // Get returns all values pointed by selected field from source Alert_Info 1129 func (fps *AlertInfo_FieldSubPath) Get(source *Alert_Info) (values []interface{}) { 1130 switch fps.selector { 1131 case AlertInfo_FieldPathSelectorTimeSerie: 1132 values = append(values, fps.subPath.GetRaw(source.GetTimeSerie())...) 1133 case AlertInfo_FieldPathSelectorObservedValues: 1134 values = append(values, fps.subPath.GetRaw(source.GetObservedValues())...) 1135 default: 1136 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fps.selector)) 1137 } 1138 return 1139 } 1140 1141 func (fps *AlertInfo_FieldSubPath) GetRaw(source proto.Message) []interface{} { 1142 return fps.Get(source.(*Alert_Info)) 1143 } 1144 1145 // GetSingle returns value of selected field from source Alert_Info 1146 func (fps *AlertInfo_FieldSubPath) GetSingle(source *Alert_Info) (interface{}, bool) { 1147 switch fps.selector { 1148 case AlertInfo_FieldPathSelectorTimeSerie: 1149 if source.GetTimeSerie() == nil { 1150 return nil, false 1151 } 1152 return fps.subPath.GetSingleRaw(source.GetTimeSerie()) 1153 case AlertInfo_FieldPathSelectorObservedValues: 1154 if source.GetObservedValues() == nil { 1155 return nil, false 1156 } 1157 return fps.subPath.GetSingleRaw(source.GetObservedValues()) 1158 default: 1159 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fps.selector)) 1160 } 1161 } 1162 1163 func (fps *AlertInfo_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1164 return fps.GetSingle(source.(*Alert_Info)) 1165 } 1166 1167 // GetDefault returns a default value of the field type 1168 func (fps *AlertInfo_FieldSubPath) GetDefault() interface{} { 1169 return fps.subPath.GetDefault() 1170 } 1171 1172 func (fps *AlertInfo_FieldSubPath) ClearValue(item *Alert_Info) { 1173 if item != nil { 1174 switch fps.selector { 1175 case AlertInfo_FieldPathSelectorTimeSerie: 1176 fps.subPath.ClearValueRaw(item.TimeSerie) 1177 case AlertInfo_FieldPathSelectorObservedValues: 1178 fps.subPath.ClearValueRaw(item.ObservedValues) 1179 default: 1180 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fps.selector)) 1181 } 1182 } 1183 } 1184 1185 func (fps *AlertInfo_FieldSubPath) ClearValueRaw(item proto.Message) { 1186 fps.ClearValue(item.(*Alert_Info)) 1187 } 1188 1189 // IsLeaf - whether field path is holds simple value 1190 func (fps *AlertInfo_FieldSubPath) IsLeaf() bool { 1191 return fps.subPath.IsLeaf() 1192 } 1193 1194 func (fps *AlertInfo_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1195 iPaths := []gotenobject.FieldPath{&AlertInfo_FieldTerminalPath{selector: fps.selector}} 1196 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 1197 return iPaths 1198 } 1199 1200 func (fps *AlertInfo_FieldSubPath) WithIValue(value interface{}) AlertInfo_FieldPathValue { 1201 return &AlertInfo_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 1202 } 1203 1204 func (fps *AlertInfo_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1205 return fps.WithIValue(value) 1206 } 1207 1208 func (fps *AlertInfo_FieldSubPath) WithIArrayOfValues(values interface{}) AlertInfo_FieldPathArrayOfValues { 1209 return &AlertInfo_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 1210 } 1211 1212 func (fps *AlertInfo_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1213 return fps.WithIArrayOfValues(values) 1214 } 1215 1216 func (fps *AlertInfo_FieldSubPath) WithIArrayItemValue(value interface{}) AlertInfo_FieldPathArrayItemValue { 1217 return &AlertInfo_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 1218 } 1219 1220 func (fps *AlertInfo_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1221 return fps.WithIArrayItemValue(value) 1222 } 1223 1224 // AlertInfo_FieldPathValue allows storing values for Info fields according to their type 1225 type AlertInfo_FieldPathValue interface { 1226 AlertInfo_FieldPath 1227 gotenobject.FieldPathValue 1228 SetTo(target **Alert_Info) 1229 CompareWith(*Alert_Info) (cmp int, comparable bool) 1230 } 1231 1232 func ParseAlertInfo_FieldPathValue(pathStr, valueStr string) (AlertInfo_FieldPathValue, error) { 1233 fp, err := ParseAlertInfo_FieldPath(pathStr) 1234 if err != nil { 1235 return nil, err 1236 } 1237 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1238 if err != nil { 1239 return nil, status.Errorf(codes.InvalidArgument, "error parsing Info field path value from %s: %v", valueStr, err) 1240 } 1241 return fpv.(AlertInfo_FieldPathValue), nil 1242 } 1243 1244 func MustParseAlertInfo_FieldPathValue(pathStr, valueStr string) AlertInfo_FieldPathValue { 1245 fpv, err := ParseAlertInfo_FieldPathValue(pathStr, valueStr) 1246 if err != nil { 1247 panic(err) 1248 } 1249 return fpv 1250 } 1251 1252 type AlertInfo_FieldTerminalPathValue struct { 1253 AlertInfo_FieldTerminalPath 1254 value interface{} 1255 } 1256 1257 var _ AlertInfo_FieldPathValue = (*AlertInfo_FieldTerminalPathValue)(nil) 1258 1259 // GetRawValue returns raw value stored under selected path for 'Info' as interface{} 1260 func (fpv *AlertInfo_FieldTerminalPathValue) GetRawValue() interface{} { 1261 return fpv.value 1262 } 1263 func (fpv *AlertInfo_FieldTerminalPathValue) AsTimeSerieValue() (*Alert_Info_TimeSerie, bool) { 1264 res, ok := fpv.value.(*Alert_Info_TimeSerie) 1265 return res, ok 1266 } 1267 func (fpv *AlertInfo_FieldTerminalPathValue) AsObservedValuesValue() (*Alert_Info_ObservedValues, bool) { 1268 res, ok := fpv.value.(*Alert_Info_ObservedValues) 1269 return res, ok 1270 } 1271 1272 // SetTo stores value for selected field for object Info 1273 func (fpv *AlertInfo_FieldTerminalPathValue) SetTo(target **Alert_Info) { 1274 if *target == nil { 1275 *target = new(Alert_Info) 1276 } 1277 switch fpv.selector { 1278 case AlertInfo_FieldPathSelectorTimeSerie: 1279 (*target).TimeSerie = fpv.value.(*Alert_Info_TimeSerie) 1280 case AlertInfo_FieldPathSelectorObservedValues: 1281 (*target).ObservedValues = fpv.value.(*Alert_Info_ObservedValues) 1282 default: 1283 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fpv.selector)) 1284 } 1285 } 1286 1287 func (fpv *AlertInfo_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1288 typedObject := target.(*Alert_Info) 1289 fpv.SetTo(&typedObject) 1290 } 1291 1292 // CompareWith compares value in the 'AlertInfo_FieldTerminalPathValue' with the value under path in 'Alert_Info'. 1293 func (fpv *AlertInfo_FieldTerminalPathValue) CompareWith(source *Alert_Info) (int, bool) { 1294 switch fpv.selector { 1295 case AlertInfo_FieldPathSelectorTimeSerie: 1296 return 0, false 1297 case AlertInfo_FieldPathSelectorObservedValues: 1298 return 0, false 1299 default: 1300 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fpv.selector)) 1301 } 1302 } 1303 1304 func (fpv *AlertInfo_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1305 return fpv.CompareWith(source.(*Alert_Info)) 1306 } 1307 1308 type AlertInfo_FieldSubPathValue struct { 1309 AlertInfo_FieldPath 1310 subPathValue gotenobject.FieldPathValue 1311 } 1312 1313 var _ AlertInfo_FieldPathValue = (*AlertInfo_FieldSubPathValue)(nil) 1314 1315 func (fpvs *AlertInfo_FieldSubPathValue) AsTimeSeriePathValue() (AlertInfoTimeSerie_FieldPathValue, bool) { 1316 res, ok := fpvs.subPathValue.(AlertInfoTimeSerie_FieldPathValue) 1317 return res, ok 1318 } 1319 func (fpvs *AlertInfo_FieldSubPathValue) AsObservedValuesPathValue() (AlertInfoObservedValues_FieldPathValue, bool) { 1320 res, ok := fpvs.subPathValue.(AlertInfoObservedValues_FieldPathValue) 1321 return res, ok 1322 } 1323 1324 func (fpvs *AlertInfo_FieldSubPathValue) SetTo(target **Alert_Info) { 1325 if *target == nil { 1326 *target = new(Alert_Info) 1327 } 1328 switch fpvs.Selector() { 1329 case AlertInfo_FieldPathSelectorTimeSerie: 1330 fpvs.subPathValue.(AlertInfoTimeSerie_FieldPathValue).SetTo(&(*target).TimeSerie) 1331 case AlertInfo_FieldPathSelectorObservedValues: 1332 fpvs.subPathValue.(AlertInfoObservedValues_FieldPathValue).SetTo(&(*target).ObservedValues) 1333 default: 1334 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fpvs.Selector())) 1335 } 1336 } 1337 1338 func (fpvs *AlertInfo_FieldSubPathValue) SetToRaw(target proto.Message) { 1339 typedObject := target.(*Alert_Info) 1340 fpvs.SetTo(&typedObject) 1341 } 1342 1343 func (fpvs *AlertInfo_FieldSubPathValue) GetRawValue() interface{} { 1344 return fpvs.subPathValue.GetRawValue() 1345 } 1346 1347 func (fpvs *AlertInfo_FieldSubPathValue) CompareWith(source *Alert_Info) (int, bool) { 1348 switch fpvs.Selector() { 1349 case AlertInfo_FieldPathSelectorTimeSerie: 1350 return fpvs.subPathValue.(AlertInfoTimeSerie_FieldPathValue).CompareWith(source.GetTimeSerie()) 1351 case AlertInfo_FieldPathSelectorObservedValues: 1352 return fpvs.subPathValue.(AlertInfoObservedValues_FieldPathValue).CompareWith(source.GetObservedValues()) 1353 default: 1354 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fpvs.Selector())) 1355 } 1356 } 1357 1358 func (fpvs *AlertInfo_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1359 return fpvs.CompareWith(source.(*Alert_Info)) 1360 } 1361 1362 // AlertInfo_FieldPathArrayItemValue allows storing single item in Path-specific values for Info according to their type 1363 // Present only for array (repeated) types. 1364 type AlertInfo_FieldPathArrayItemValue interface { 1365 gotenobject.FieldPathArrayItemValue 1366 AlertInfo_FieldPath 1367 ContainsValue(*Alert_Info) bool 1368 } 1369 1370 // ParseAlertInfo_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1371 func ParseAlertInfo_FieldPathArrayItemValue(pathStr, valueStr string) (AlertInfo_FieldPathArrayItemValue, error) { 1372 fp, err := ParseAlertInfo_FieldPath(pathStr) 1373 if err != nil { 1374 return nil, err 1375 } 1376 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1377 if err != nil { 1378 return nil, status.Errorf(codes.InvalidArgument, "error parsing Info field path array item value from %s: %v", valueStr, err) 1379 } 1380 return fpaiv.(AlertInfo_FieldPathArrayItemValue), nil 1381 } 1382 1383 func MustParseAlertInfo_FieldPathArrayItemValue(pathStr, valueStr string) AlertInfo_FieldPathArrayItemValue { 1384 fpaiv, err := ParseAlertInfo_FieldPathArrayItemValue(pathStr, valueStr) 1385 if err != nil { 1386 panic(err) 1387 } 1388 return fpaiv 1389 } 1390 1391 type AlertInfo_FieldTerminalPathArrayItemValue struct { 1392 AlertInfo_FieldTerminalPath 1393 value interface{} 1394 } 1395 1396 var _ AlertInfo_FieldPathArrayItemValue = (*AlertInfo_FieldTerminalPathArrayItemValue)(nil) 1397 1398 // GetRawValue returns stored element value for array in object Alert_Info as interface{} 1399 func (fpaiv *AlertInfo_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1400 return fpaiv.value 1401 } 1402 1403 func (fpaiv *AlertInfo_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_Info) (interface{}, bool) { 1404 return nil, false 1405 } 1406 1407 func (fpaiv *AlertInfo_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1408 return fpaiv.GetSingle(source.(*Alert_Info)) 1409 } 1410 1411 // Contains returns a boolean indicating if value that is being held is present in given 'Info' 1412 func (fpaiv *AlertInfo_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_Info) bool { 1413 slice := fpaiv.AlertInfo_FieldTerminalPath.Get(source) 1414 for _, v := range slice { 1415 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1416 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1417 return true 1418 } 1419 } else if reflect.DeepEqual(v, fpaiv.value) { 1420 return true 1421 } 1422 } 1423 return false 1424 } 1425 1426 type AlertInfo_FieldSubPathArrayItemValue struct { 1427 AlertInfo_FieldPath 1428 subPathItemValue gotenobject.FieldPathArrayItemValue 1429 } 1430 1431 // GetRawValue returns stored array item value 1432 func (fpaivs *AlertInfo_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 1433 return fpaivs.subPathItemValue.GetRawItemValue() 1434 } 1435 func (fpaivs *AlertInfo_FieldSubPathArrayItemValue) AsTimeSeriePathItemValue() (AlertInfoTimeSerie_FieldPathArrayItemValue, bool) { 1436 res, ok := fpaivs.subPathItemValue.(AlertInfoTimeSerie_FieldPathArrayItemValue) 1437 return res, ok 1438 } 1439 func (fpaivs *AlertInfo_FieldSubPathArrayItemValue) AsObservedValuesPathItemValue() (AlertInfoObservedValues_FieldPathArrayItemValue, bool) { 1440 res, ok := fpaivs.subPathItemValue.(AlertInfoObservedValues_FieldPathArrayItemValue) 1441 return res, ok 1442 } 1443 1444 // Contains returns a boolean indicating if value that is being held is present in given 'Info' 1445 func (fpaivs *AlertInfo_FieldSubPathArrayItemValue) ContainsValue(source *Alert_Info) bool { 1446 switch fpaivs.Selector() { 1447 case AlertInfo_FieldPathSelectorTimeSerie: 1448 return fpaivs.subPathItemValue.(AlertInfoTimeSerie_FieldPathArrayItemValue).ContainsValue(source.GetTimeSerie()) 1449 case AlertInfo_FieldPathSelectorObservedValues: 1450 return fpaivs.subPathItemValue.(AlertInfoObservedValues_FieldPathArrayItemValue).ContainsValue(source.GetObservedValues()) 1451 default: 1452 panic(fmt.Sprintf("Invalid selector for Alert_Info: %d", fpaivs.Selector())) 1453 } 1454 } 1455 1456 // AlertInfo_FieldPathArrayOfValues allows storing slice of values for Info fields according to their type 1457 type AlertInfo_FieldPathArrayOfValues interface { 1458 gotenobject.FieldPathArrayOfValues 1459 AlertInfo_FieldPath 1460 } 1461 1462 func ParseAlertInfo_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertInfo_FieldPathArrayOfValues, error) { 1463 fp, err := ParseAlertInfo_FieldPath(pathStr) 1464 if err != nil { 1465 return nil, err 1466 } 1467 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1468 if err != nil { 1469 return nil, status.Errorf(codes.InvalidArgument, "error parsing Info field path array of values from %s: %v", valuesStr, err) 1470 } 1471 return fpaov.(AlertInfo_FieldPathArrayOfValues), nil 1472 } 1473 1474 func MustParseAlertInfo_FieldPathArrayOfValues(pathStr, valuesStr string) AlertInfo_FieldPathArrayOfValues { 1475 fpaov, err := ParseAlertInfo_FieldPathArrayOfValues(pathStr, valuesStr) 1476 if err != nil { 1477 panic(err) 1478 } 1479 return fpaov 1480 } 1481 1482 type AlertInfo_FieldTerminalPathArrayOfValues struct { 1483 AlertInfo_FieldTerminalPath 1484 values interface{} 1485 } 1486 1487 var _ AlertInfo_FieldPathArrayOfValues = (*AlertInfo_FieldTerminalPathArrayOfValues)(nil) 1488 1489 func (fpaov *AlertInfo_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1490 switch fpaov.selector { 1491 case AlertInfo_FieldPathSelectorTimeSerie: 1492 for _, v := range fpaov.values.([]*Alert_Info_TimeSerie) { 1493 values = append(values, v) 1494 } 1495 case AlertInfo_FieldPathSelectorObservedValues: 1496 for _, v := range fpaov.values.([]*Alert_Info_ObservedValues) { 1497 values = append(values, v) 1498 } 1499 } 1500 return 1501 } 1502 func (fpaov *AlertInfo_FieldTerminalPathArrayOfValues) AsTimeSerieArrayOfValues() ([]*Alert_Info_TimeSerie, bool) { 1503 res, ok := fpaov.values.([]*Alert_Info_TimeSerie) 1504 return res, ok 1505 } 1506 func (fpaov *AlertInfo_FieldTerminalPathArrayOfValues) AsObservedValuesArrayOfValues() ([]*Alert_Info_ObservedValues, bool) { 1507 res, ok := fpaov.values.([]*Alert_Info_ObservedValues) 1508 return res, ok 1509 } 1510 1511 type AlertInfo_FieldSubPathArrayOfValues struct { 1512 AlertInfo_FieldPath 1513 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 1514 } 1515 1516 var _ AlertInfo_FieldPathArrayOfValues = (*AlertInfo_FieldSubPathArrayOfValues)(nil) 1517 1518 func (fpsaov *AlertInfo_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 1519 return fpsaov.subPathArrayOfValues.GetRawValues() 1520 } 1521 func (fpsaov *AlertInfo_FieldSubPathArrayOfValues) AsTimeSeriePathArrayOfValues() (AlertInfoTimeSerie_FieldPathArrayOfValues, bool) { 1522 res, ok := fpsaov.subPathArrayOfValues.(AlertInfoTimeSerie_FieldPathArrayOfValues) 1523 return res, ok 1524 } 1525 func (fpsaov *AlertInfo_FieldSubPathArrayOfValues) AsObservedValuesPathArrayOfValues() (AlertInfoObservedValues_FieldPathArrayOfValues, bool) { 1526 res, ok := fpsaov.subPathArrayOfValues.(AlertInfoObservedValues_FieldPathArrayOfValues) 1527 return res, ok 1528 } 1529 1530 // FieldPath provides implementation to handle 1531 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 1532 type AlertState_FieldPath interface { 1533 gotenobject.FieldPath 1534 Selector() AlertState_FieldPathSelector 1535 Get(source *Alert_State) []interface{} 1536 GetSingle(source *Alert_State) (interface{}, bool) 1537 ClearValue(item *Alert_State) 1538 1539 // Those methods build corresponding AlertState_FieldPathValue 1540 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1541 WithIValue(value interface{}) AlertState_FieldPathValue 1542 WithIArrayOfValues(values interface{}) AlertState_FieldPathArrayOfValues 1543 WithIArrayItemValue(value interface{}) AlertState_FieldPathArrayItemValue 1544 } 1545 1546 type AlertState_FieldPathSelector int32 1547 1548 const ( 1549 AlertState_FieldPathSelectorIsFiring AlertState_FieldPathSelector = 0 1550 AlertState_FieldPathSelectorIsAcknowledged AlertState_FieldPathSelector = 1 1551 AlertState_FieldPathSelectorIsSilenced AlertState_FieldPathSelector = 2 1552 AlertState_FieldPathSelectorLifetime AlertState_FieldPathSelector = 3 1553 AlertState_FieldPathSelectorNeedsNotification AlertState_FieldPathSelector = 4 1554 AlertState_FieldPathSelectorNotificationCreated AlertState_FieldPathSelector = 5 1555 AlertState_FieldPathSelectorLifecycleCompleted AlertState_FieldPathSelector = 6 1556 ) 1557 1558 func (s AlertState_FieldPathSelector) String() string { 1559 switch s { 1560 case AlertState_FieldPathSelectorIsFiring: 1561 return "is_firing" 1562 case AlertState_FieldPathSelectorIsAcknowledged: 1563 return "is_acknowledged" 1564 case AlertState_FieldPathSelectorIsSilenced: 1565 return "is_silenced" 1566 case AlertState_FieldPathSelectorLifetime: 1567 return "lifetime" 1568 case AlertState_FieldPathSelectorNeedsNotification: 1569 return "needs_notification" 1570 case AlertState_FieldPathSelectorNotificationCreated: 1571 return "notification_created" 1572 case AlertState_FieldPathSelectorLifecycleCompleted: 1573 return "lifecycle_completed" 1574 default: 1575 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", s)) 1576 } 1577 } 1578 1579 func BuildAlertState_FieldPath(fp gotenobject.RawFieldPath) (AlertState_FieldPath, error) { 1580 if len(fp) == 0 { 1581 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_State") 1582 } 1583 if len(fp) == 1 { 1584 switch fp[0] { 1585 case "is_firing", "isFiring", "is-firing": 1586 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorIsFiring}, nil 1587 case "is_acknowledged", "isAcknowledged", "is-acknowledged": 1588 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorIsAcknowledged}, nil 1589 case "is_silenced", "isSilenced", "is-silenced": 1590 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorIsSilenced}, nil 1591 case "lifetime": 1592 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorLifetime}, nil 1593 case "needs_notification", "needsNotification", "needs-notification": 1594 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorNeedsNotification}, nil 1595 case "notification_created", "notificationCreated", "notification-created": 1596 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorNotificationCreated}, nil 1597 case "lifecycle_completed", "lifecycleCompleted", "lifecycle-completed": 1598 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorLifecycleCompleted}, nil 1599 } 1600 } else { 1601 switch fp[0] { 1602 case "lifetime": 1603 if subpath, err := common.BuildTimeRange_FieldPath(fp[1:]); err != nil { 1604 return nil, err 1605 } else { 1606 return &AlertState_FieldSubPath{selector: AlertState_FieldPathSelectorLifetime, subPath: subpath}, nil 1607 } 1608 } 1609 } 1610 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_State", fp) 1611 } 1612 1613 func ParseAlertState_FieldPath(rawField string) (AlertState_FieldPath, error) { 1614 fp, err := gotenobject.ParseRawFieldPath(rawField) 1615 if err != nil { 1616 return nil, err 1617 } 1618 return BuildAlertState_FieldPath(fp) 1619 } 1620 1621 func MustParseAlertState_FieldPath(rawField string) AlertState_FieldPath { 1622 fp, err := ParseAlertState_FieldPath(rawField) 1623 if err != nil { 1624 panic(err) 1625 } 1626 return fp 1627 } 1628 1629 type AlertState_FieldTerminalPath struct { 1630 selector AlertState_FieldPathSelector 1631 } 1632 1633 var _ AlertState_FieldPath = (*AlertState_FieldTerminalPath)(nil) 1634 1635 func (fp *AlertState_FieldTerminalPath) Selector() AlertState_FieldPathSelector { 1636 return fp.selector 1637 } 1638 1639 // String returns path representation in proto convention 1640 func (fp *AlertState_FieldTerminalPath) String() string { 1641 return fp.selector.String() 1642 } 1643 1644 // JSONString returns path representation is JSON convention 1645 func (fp *AlertState_FieldTerminalPath) JSONString() string { 1646 return strcase.ToLowerCamel(fp.String()) 1647 } 1648 1649 // Get returns all values pointed by specific field from source Alert_State 1650 func (fp *AlertState_FieldTerminalPath) Get(source *Alert_State) (values []interface{}) { 1651 if source != nil { 1652 switch fp.selector { 1653 case AlertState_FieldPathSelectorIsFiring: 1654 values = append(values, source.IsFiring) 1655 case AlertState_FieldPathSelectorIsAcknowledged: 1656 values = append(values, source.IsAcknowledged) 1657 case AlertState_FieldPathSelectorIsSilenced: 1658 values = append(values, source.IsSilenced) 1659 case AlertState_FieldPathSelectorLifetime: 1660 if source.Lifetime != nil { 1661 values = append(values, source.Lifetime) 1662 } 1663 case AlertState_FieldPathSelectorNeedsNotification: 1664 values = append(values, source.NeedsNotification) 1665 case AlertState_FieldPathSelectorNotificationCreated: 1666 values = append(values, source.NotificationCreated) 1667 case AlertState_FieldPathSelectorLifecycleCompleted: 1668 values = append(values, source.LifecycleCompleted) 1669 default: 1670 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 1671 } 1672 } 1673 return 1674 } 1675 1676 func (fp *AlertState_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1677 return fp.Get(source.(*Alert_State)) 1678 } 1679 1680 // GetSingle returns value pointed by specific field of from source Alert_State 1681 func (fp *AlertState_FieldTerminalPath) GetSingle(source *Alert_State) (interface{}, bool) { 1682 switch fp.selector { 1683 case AlertState_FieldPathSelectorIsFiring: 1684 return source.GetIsFiring(), source != nil 1685 case AlertState_FieldPathSelectorIsAcknowledged: 1686 return source.GetIsAcknowledged(), source != nil 1687 case AlertState_FieldPathSelectorIsSilenced: 1688 return source.GetIsSilenced(), source != nil 1689 case AlertState_FieldPathSelectorLifetime: 1690 res := source.GetLifetime() 1691 return res, res != nil 1692 case AlertState_FieldPathSelectorNeedsNotification: 1693 return source.GetNeedsNotification(), source != nil 1694 case AlertState_FieldPathSelectorNotificationCreated: 1695 return source.GetNotificationCreated(), source != nil 1696 case AlertState_FieldPathSelectorLifecycleCompleted: 1697 return source.GetLifecycleCompleted(), source != nil 1698 default: 1699 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 1700 } 1701 } 1702 1703 func (fp *AlertState_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1704 return fp.GetSingle(source.(*Alert_State)) 1705 } 1706 1707 // GetDefault returns a default value of the field type 1708 func (fp *AlertState_FieldTerminalPath) GetDefault() interface{} { 1709 switch fp.selector { 1710 case AlertState_FieldPathSelectorIsFiring: 1711 return false 1712 case AlertState_FieldPathSelectorIsAcknowledged: 1713 return false 1714 case AlertState_FieldPathSelectorIsSilenced: 1715 return false 1716 case AlertState_FieldPathSelectorLifetime: 1717 return (*common.TimeRange)(nil) 1718 case AlertState_FieldPathSelectorNeedsNotification: 1719 return false 1720 case AlertState_FieldPathSelectorNotificationCreated: 1721 return false 1722 case AlertState_FieldPathSelectorLifecycleCompleted: 1723 return false 1724 default: 1725 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 1726 } 1727 } 1728 1729 func (fp *AlertState_FieldTerminalPath) ClearValue(item *Alert_State) { 1730 if item != nil { 1731 switch fp.selector { 1732 case AlertState_FieldPathSelectorIsFiring: 1733 item.IsFiring = false 1734 case AlertState_FieldPathSelectorIsAcknowledged: 1735 item.IsAcknowledged = false 1736 case AlertState_FieldPathSelectorIsSilenced: 1737 item.IsSilenced = false 1738 case AlertState_FieldPathSelectorLifetime: 1739 item.Lifetime = nil 1740 case AlertState_FieldPathSelectorNeedsNotification: 1741 item.NeedsNotification = false 1742 case AlertState_FieldPathSelectorNotificationCreated: 1743 item.NotificationCreated = false 1744 case AlertState_FieldPathSelectorLifecycleCompleted: 1745 item.LifecycleCompleted = false 1746 default: 1747 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 1748 } 1749 } 1750 } 1751 1752 func (fp *AlertState_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1753 fp.ClearValue(item.(*Alert_State)) 1754 } 1755 1756 // IsLeaf - whether field path is holds simple value 1757 func (fp *AlertState_FieldTerminalPath) IsLeaf() bool { 1758 return fp.selector == AlertState_FieldPathSelectorIsFiring || 1759 fp.selector == AlertState_FieldPathSelectorIsAcknowledged || 1760 fp.selector == AlertState_FieldPathSelectorIsSilenced || 1761 fp.selector == AlertState_FieldPathSelectorNeedsNotification || 1762 fp.selector == AlertState_FieldPathSelectorNotificationCreated || 1763 fp.selector == AlertState_FieldPathSelectorLifecycleCompleted 1764 } 1765 1766 func (fp *AlertState_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1767 return []gotenobject.FieldPath{fp} 1768 } 1769 1770 func (fp *AlertState_FieldTerminalPath) WithIValue(value interface{}) AlertState_FieldPathValue { 1771 switch fp.selector { 1772 case AlertState_FieldPathSelectorIsFiring: 1773 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(bool)} 1774 case AlertState_FieldPathSelectorIsAcknowledged: 1775 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(bool)} 1776 case AlertState_FieldPathSelectorIsSilenced: 1777 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(bool)} 1778 case AlertState_FieldPathSelectorLifetime: 1779 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(*common.TimeRange)} 1780 case AlertState_FieldPathSelectorNeedsNotification: 1781 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(bool)} 1782 case AlertState_FieldPathSelectorNotificationCreated: 1783 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(bool)} 1784 case AlertState_FieldPathSelectorLifecycleCompleted: 1785 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(bool)} 1786 default: 1787 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 1788 } 1789 } 1790 1791 func (fp *AlertState_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1792 return fp.WithIValue(value) 1793 } 1794 1795 func (fp *AlertState_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertState_FieldPathArrayOfValues { 1796 fpaov := &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp} 1797 switch fp.selector { 1798 case AlertState_FieldPathSelectorIsFiring: 1799 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]bool)} 1800 case AlertState_FieldPathSelectorIsAcknowledged: 1801 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]bool)} 1802 case AlertState_FieldPathSelectorIsSilenced: 1803 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]bool)} 1804 case AlertState_FieldPathSelectorLifetime: 1805 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]*common.TimeRange)} 1806 case AlertState_FieldPathSelectorNeedsNotification: 1807 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]bool)} 1808 case AlertState_FieldPathSelectorNotificationCreated: 1809 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]bool)} 1810 case AlertState_FieldPathSelectorLifecycleCompleted: 1811 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]bool)} 1812 default: 1813 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 1814 } 1815 return fpaov 1816 } 1817 1818 func (fp *AlertState_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1819 return fp.WithIArrayOfValues(values) 1820 } 1821 1822 func (fp *AlertState_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertState_FieldPathArrayItemValue { 1823 switch fp.selector { 1824 default: 1825 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 1826 } 1827 } 1828 1829 func (fp *AlertState_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1830 return fp.WithIArrayItemValue(value) 1831 } 1832 1833 type AlertState_FieldSubPath struct { 1834 selector AlertState_FieldPathSelector 1835 subPath gotenobject.FieldPath 1836 } 1837 1838 var _ AlertState_FieldPath = (*AlertState_FieldSubPath)(nil) 1839 1840 func (fps *AlertState_FieldSubPath) Selector() AlertState_FieldPathSelector { 1841 return fps.selector 1842 } 1843 func (fps *AlertState_FieldSubPath) AsLifetimeSubPath() (common.TimeRange_FieldPath, bool) { 1844 res, ok := fps.subPath.(common.TimeRange_FieldPath) 1845 return res, ok 1846 } 1847 1848 // String returns path representation in proto convention 1849 func (fps *AlertState_FieldSubPath) String() string { 1850 return fps.selector.String() + "." + fps.subPath.String() 1851 } 1852 1853 // JSONString returns path representation is JSON convention 1854 func (fps *AlertState_FieldSubPath) JSONString() string { 1855 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 1856 } 1857 1858 // Get returns all values pointed by selected field from source Alert_State 1859 func (fps *AlertState_FieldSubPath) Get(source *Alert_State) (values []interface{}) { 1860 switch fps.selector { 1861 case AlertState_FieldPathSelectorLifetime: 1862 values = append(values, fps.subPath.GetRaw(source.GetLifetime())...) 1863 default: 1864 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fps.selector)) 1865 } 1866 return 1867 } 1868 1869 func (fps *AlertState_FieldSubPath) GetRaw(source proto.Message) []interface{} { 1870 return fps.Get(source.(*Alert_State)) 1871 } 1872 1873 // GetSingle returns value of selected field from source Alert_State 1874 func (fps *AlertState_FieldSubPath) GetSingle(source *Alert_State) (interface{}, bool) { 1875 switch fps.selector { 1876 case AlertState_FieldPathSelectorLifetime: 1877 if source.GetLifetime() == nil { 1878 return nil, false 1879 } 1880 return fps.subPath.GetSingleRaw(source.GetLifetime()) 1881 default: 1882 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fps.selector)) 1883 } 1884 } 1885 1886 func (fps *AlertState_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1887 return fps.GetSingle(source.(*Alert_State)) 1888 } 1889 1890 // GetDefault returns a default value of the field type 1891 func (fps *AlertState_FieldSubPath) GetDefault() interface{} { 1892 return fps.subPath.GetDefault() 1893 } 1894 1895 func (fps *AlertState_FieldSubPath) ClearValue(item *Alert_State) { 1896 if item != nil { 1897 switch fps.selector { 1898 case AlertState_FieldPathSelectorLifetime: 1899 fps.subPath.ClearValueRaw(item.Lifetime) 1900 default: 1901 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fps.selector)) 1902 } 1903 } 1904 } 1905 1906 func (fps *AlertState_FieldSubPath) ClearValueRaw(item proto.Message) { 1907 fps.ClearValue(item.(*Alert_State)) 1908 } 1909 1910 // IsLeaf - whether field path is holds simple value 1911 func (fps *AlertState_FieldSubPath) IsLeaf() bool { 1912 return fps.subPath.IsLeaf() 1913 } 1914 1915 func (fps *AlertState_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1916 iPaths := []gotenobject.FieldPath{&AlertState_FieldTerminalPath{selector: fps.selector}} 1917 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 1918 return iPaths 1919 } 1920 1921 func (fps *AlertState_FieldSubPath) WithIValue(value interface{}) AlertState_FieldPathValue { 1922 return &AlertState_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 1923 } 1924 1925 func (fps *AlertState_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1926 return fps.WithIValue(value) 1927 } 1928 1929 func (fps *AlertState_FieldSubPath) WithIArrayOfValues(values interface{}) AlertState_FieldPathArrayOfValues { 1930 return &AlertState_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 1931 } 1932 1933 func (fps *AlertState_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1934 return fps.WithIArrayOfValues(values) 1935 } 1936 1937 func (fps *AlertState_FieldSubPath) WithIArrayItemValue(value interface{}) AlertState_FieldPathArrayItemValue { 1938 return &AlertState_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 1939 } 1940 1941 func (fps *AlertState_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1942 return fps.WithIArrayItemValue(value) 1943 } 1944 1945 // AlertState_FieldPathValue allows storing values for State fields according to their type 1946 type AlertState_FieldPathValue interface { 1947 AlertState_FieldPath 1948 gotenobject.FieldPathValue 1949 SetTo(target **Alert_State) 1950 CompareWith(*Alert_State) (cmp int, comparable bool) 1951 } 1952 1953 func ParseAlertState_FieldPathValue(pathStr, valueStr string) (AlertState_FieldPathValue, error) { 1954 fp, err := ParseAlertState_FieldPath(pathStr) 1955 if err != nil { 1956 return nil, err 1957 } 1958 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1959 if err != nil { 1960 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path value from %s: %v", valueStr, err) 1961 } 1962 return fpv.(AlertState_FieldPathValue), nil 1963 } 1964 1965 func MustParseAlertState_FieldPathValue(pathStr, valueStr string) AlertState_FieldPathValue { 1966 fpv, err := ParseAlertState_FieldPathValue(pathStr, valueStr) 1967 if err != nil { 1968 panic(err) 1969 } 1970 return fpv 1971 } 1972 1973 type AlertState_FieldTerminalPathValue struct { 1974 AlertState_FieldTerminalPath 1975 value interface{} 1976 } 1977 1978 var _ AlertState_FieldPathValue = (*AlertState_FieldTerminalPathValue)(nil) 1979 1980 // GetRawValue returns raw value stored under selected path for 'State' as interface{} 1981 func (fpv *AlertState_FieldTerminalPathValue) GetRawValue() interface{} { 1982 return fpv.value 1983 } 1984 func (fpv *AlertState_FieldTerminalPathValue) AsIsFiringValue() (bool, bool) { 1985 res, ok := fpv.value.(bool) 1986 return res, ok 1987 } 1988 func (fpv *AlertState_FieldTerminalPathValue) AsIsAcknowledgedValue() (bool, bool) { 1989 res, ok := fpv.value.(bool) 1990 return res, ok 1991 } 1992 func (fpv *AlertState_FieldTerminalPathValue) AsIsSilencedValue() (bool, bool) { 1993 res, ok := fpv.value.(bool) 1994 return res, ok 1995 } 1996 func (fpv *AlertState_FieldTerminalPathValue) AsLifetimeValue() (*common.TimeRange, bool) { 1997 res, ok := fpv.value.(*common.TimeRange) 1998 return res, ok 1999 } 2000 func (fpv *AlertState_FieldTerminalPathValue) AsNeedsNotificationValue() (bool, bool) { 2001 res, ok := fpv.value.(bool) 2002 return res, ok 2003 } 2004 func (fpv *AlertState_FieldTerminalPathValue) AsNotificationCreatedValue() (bool, bool) { 2005 res, ok := fpv.value.(bool) 2006 return res, ok 2007 } 2008 func (fpv *AlertState_FieldTerminalPathValue) AsLifecycleCompletedValue() (bool, bool) { 2009 res, ok := fpv.value.(bool) 2010 return res, ok 2011 } 2012 2013 // SetTo stores value for selected field for object State 2014 func (fpv *AlertState_FieldTerminalPathValue) SetTo(target **Alert_State) { 2015 if *target == nil { 2016 *target = new(Alert_State) 2017 } 2018 switch fpv.selector { 2019 case AlertState_FieldPathSelectorIsFiring: 2020 (*target).IsFiring = fpv.value.(bool) 2021 case AlertState_FieldPathSelectorIsAcknowledged: 2022 (*target).IsAcknowledged = fpv.value.(bool) 2023 case AlertState_FieldPathSelectorIsSilenced: 2024 (*target).IsSilenced = fpv.value.(bool) 2025 case AlertState_FieldPathSelectorLifetime: 2026 (*target).Lifetime = fpv.value.(*common.TimeRange) 2027 case AlertState_FieldPathSelectorNeedsNotification: 2028 (*target).NeedsNotification = fpv.value.(bool) 2029 case AlertState_FieldPathSelectorNotificationCreated: 2030 (*target).NotificationCreated = fpv.value.(bool) 2031 case AlertState_FieldPathSelectorLifecycleCompleted: 2032 (*target).LifecycleCompleted = fpv.value.(bool) 2033 default: 2034 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fpv.selector)) 2035 } 2036 } 2037 2038 func (fpv *AlertState_FieldTerminalPathValue) SetToRaw(target proto.Message) { 2039 typedObject := target.(*Alert_State) 2040 fpv.SetTo(&typedObject) 2041 } 2042 2043 // CompareWith compares value in the 'AlertState_FieldTerminalPathValue' with the value under path in 'Alert_State'. 2044 func (fpv *AlertState_FieldTerminalPathValue) CompareWith(source *Alert_State) (int, bool) { 2045 switch fpv.selector { 2046 case AlertState_FieldPathSelectorIsFiring: 2047 leftValue := fpv.value.(bool) 2048 rightValue := source.GetIsFiring() 2049 if (leftValue) == (rightValue) { 2050 return 0, true 2051 } else if !(leftValue) && (rightValue) { 2052 return -1, true 2053 } else { 2054 return 1, true 2055 } 2056 case AlertState_FieldPathSelectorIsAcknowledged: 2057 leftValue := fpv.value.(bool) 2058 rightValue := source.GetIsAcknowledged() 2059 if (leftValue) == (rightValue) { 2060 return 0, true 2061 } else if !(leftValue) && (rightValue) { 2062 return -1, true 2063 } else { 2064 return 1, true 2065 } 2066 case AlertState_FieldPathSelectorIsSilenced: 2067 leftValue := fpv.value.(bool) 2068 rightValue := source.GetIsSilenced() 2069 if (leftValue) == (rightValue) { 2070 return 0, true 2071 } else if !(leftValue) && (rightValue) { 2072 return -1, true 2073 } else { 2074 return 1, true 2075 } 2076 case AlertState_FieldPathSelectorLifetime: 2077 return 0, false 2078 case AlertState_FieldPathSelectorNeedsNotification: 2079 leftValue := fpv.value.(bool) 2080 rightValue := source.GetNeedsNotification() 2081 if (leftValue) == (rightValue) { 2082 return 0, true 2083 } else if !(leftValue) && (rightValue) { 2084 return -1, true 2085 } else { 2086 return 1, true 2087 } 2088 case AlertState_FieldPathSelectorNotificationCreated: 2089 leftValue := fpv.value.(bool) 2090 rightValue := source.GetNotificationCreated() 2091 if (leftValue) == (rightValue) { 2092 return 0, true 2093 } else if !(leftValue) && (rightValue) { 2094 return -1, true 2095 } else { 2096 return 1, true 2097 } 2098 case AlertState_FieldPathSelectorLifecycleCompleted: 2099 leftValue := fpv.value.(bool) 2100 rightValue := source.GetLifecycleCompleted() 2101 if (leftValue) == (rightValue) { 2102 return 0, true 2103 } else if !(leftValue) && (rightValue) { 2104 return -1, true 2105 } else { 2106 return 1, true 2107 } 2108 default: 2109 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fpv.selector)) 2110 } 2111 } 2112 2113 func (fpv *AlertState_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2114 return fpv.CompareWith(source.(*Alert_State)) 2115 } 2116 2117 type AlertState_FieldSubPathValue struct { 2118 AlertState_FieldPath 2119 subPathValue gotenobject.FieldPathValue 2120 } 2121 2122 var _ AlertState_FieldPathValue = (*AlertState_FieldSubPathValue)(nil) 2123 2124 func (fpvs *AlertState_FieldSubPathValue) AsLifetimePathValue() (common.TimeRange_FieldPathValue, bool) { 2125 res, ok := fpvs.subPathValue.(common.TimeRange_FieldPathValue) 2126 return res, ok 2127 } 2128 2129 func (fpvs *AlertState_FieldSubPathValue) SetTo(target **Alert_State) { 2130 if *target == nil { 2131 *target = new(Alert_State) 2132 } 2133 switch fpvs.Selector() { 2134 case AlertState_FieldPathSelectorLifetime: 2135 fpvs.subPathValue.(common.TimeRange_FieldPathValue).SetTo(&(*target).Lifetime) 2136 default: 2137 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fpvs.Selector())) 2138 } 2139 } 2140 2141 func (fpvs *AlertState_FieldSubPathValue) SetToRaw(target proto.Message) { 2142 typedObject := target.(*Alert_State) 2143 fpvs.SetTo(&typedObject) 2144 } 2145 2146 func (fpvs *AlertState_FieldSubPathValue) GetRawValue() interface{} { 2147 return fpvs.subPathValue.GetRawValue() 2148 } 2149 2150 func (fpvs *AlertState_FieldSubPathValue) CompareWith(source *Alert_State) (int, bool) { 2151 switch fpvs.Selector() { 2152 case AlertState_FieldPathSelectorLifetime: 2153 return fpvs.subPathValue.(common.TimeRange_FieldPathValue).CompareWith(source.GetLifetime()) 2154 default: 2155 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fpvs.Selector())) 2156 } 2157 } 2158 2159 func (fpvs *AlertState_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2160 return fpvs.CompareWith(source.(*Alert_State)) 2161 } 2162 2163 // AlertState_FieldPathArrayItemValue allows storing single item in Path-specific values for State according to their type 2164 // Present only for array (repeated) types. 2165 type AlertState_FieldPathArrayItemValue interface { 2166 gotenobject.FieldPathArrayItemValue 2167 AlertState_FieldPath 2168 ContainsValue(*Alert_State) bool 2169 } 2170 2171 // ParseAlertState_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 2172 func ParseAlertState_FieldPathArrayItemValue(pathStr, valueStr string) (AlertState_FieldPathArrayItemValue, error) { 2173 fp, err := ParseAlertState_FieldPath(pathStr) 2174 if err != nil { 2175 return nil, err 2176 } 2177 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 2178 if err != nil { 2179 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path array item value from %s: %v", valueStr, err) 2180 } 2181 return fpaiv.(AlertState_FieldPathArrayItemValue), nil 2182 } 2183 2184 func MustParseAlertState_FieldPathArrayItemValue(pathStr, valueStr string) AlertState_FieldPathArrayItemValue { 2185 fpaiv, err := ParseAlertState_FieldPathArrayItemValue(pathStr, valueStr) 2186 if err != nil { 2187 panic(err) 2188 } 2189 return fpaiv 2190 } 2191 2192 type AlertState_FieldTerminalPathArrayItemValue struct { 2193 AlertState_FieldTerminalPath 2194 value interface{} 2195 } 2196 2197 var _ AlertState_FieldPathArrayItemValue = (*AlertState_FieldTerminalPathArrayItemValue)(nil) 2198 2199 // GetRawValue returns stored element value for array in object Alert_State as interface{} 2200 func (fpaiv *AlertState_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 2201 return fpaiv.value 2202 } 2203 2204 func (fpaiv *AlertState_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_State) (interface{}, bool) { 2205 return nil, false 2206 } 2207 2208 func (fpaiv *AlertState_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 2209 return fpaiv.GetSingle(source.(*Alert_State)) 2210 } 2211 2212 // Contains returns a boolean indicating if value that is being held is present in given 'State' 2213 func (fpaiv *AlertState_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_State) bool { 2214 slice := fpaiv.AlertState_FieldTerminalPath.Get(source) 2215 for _, v := range slice { 2216 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 2217 if proto.Equal(asProtoMsg, v.(proto.Message)) { 2218 return true 2219 } 2220 } else if reflect.DeepEqual(v, fpaiv.value) { 2221 return true 2222 } 2223 } 2224 return false 2225 } 2226 2227 type AlertState_FieldSubPathArrayItemValue struct { 2228 AlertState_FieldPath 2229 subPathItemValue gotenobject.FieldPathArrayItemValue 2230 } 2231 2232 // GetRawValue returns stored array item value 2233 func (fpaivs *AlertState_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 2234 return fpaivs.subPathItemValue.GetRawItemValue() 2235 } 2236 func (fpaivs *AlertState_FieldSubPathArrayItemValue) AsLifetimePathItemValue() (common.TimeRange_FieldPathArrayItemValue, bool) { 2237 res, ok := fpaivs.subPathItemValue.(common.TimeRange_FieldPathArrayItemValue) 2238 return res, ok 2239 } 2240 2241 // Contains returns a boolean indicating if value that is being held is present in given 'State' 2242 func (fpaivs *AlertState_FieldSubPathArrayItemValue) ContainsValue(source *Alert_State) bool { 2243 switch fpaivs.Selector() { 2244 case AlertState_FieldPathSelectorLifetime: 2245 return fpaivs.subPathItemValue.(common.TimeRange_FieldPathArrayItemValue).ContainsValue(source.GetLifetime()) 2246 default: 2247 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fpaivs.Selector())) 2248 } 2249 } 2250 2251 // AlertState_FieldPathArrayOfValues allows storing slice of values for State fields according to their type 2252 type AlertState_FieldPathArrayOfValues interface { 2253 gotenobject.FieldPathArrayOfValues 2254 AlertState_FieldPath 2255 } 2256 2257 func ParseAlertState_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertState_FieldPathArrayOfValues, error) { 2258 fp, err := ParseAlertState_FieldPath(pathStr) 2259 if err != nil { 2260 return nil, err 2261 } 2262 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 2263 if err != nil { 2264 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path array of values from %s: %v", valuesStr, err) 2265 } 2266 return fpaov.(AlertState_FieldPathArrayOfValues), nil 2267 } 2268 2269 func MustParseAlertState_FieldPathArrayOfValues(pathStr, valuesStr string) AlertState_FieldPathArrayOfValues { 2270 fpaov, err := ParseAlertState_FieldPathArrayOfValues(pathStr, valuesStr) 2271 if err != nil { 2272 panic(err) 2273 } 2274 return fpaov 2275 } 2276 2277 type AlertState_FieldTerminalPathArrayOfValues struct { 2278 AlertState_FieldTerminalPath 2279 values interface{} 2280 } 2281 2282 var _ AlertState_FieldPathArrayOfValues = (*AlertState_FieldTerminalPathArrayOfValues)(nil) 2283 2284 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 2285 switch fpaov.selector { 2286 case AlertState_FieldPathSelectorIsFiring: 2287 for _, v := range fpaov.values.([]bool) { 2288 values = append(values, v) 2289 } 2290 case AlertState_FieldPathSelectorIsAcknowledged: 2291 for _, v := range fpaov.values.([]bool) { 2292 values = append(values, v) 2293 } 2294 case AlertState_FieldPathSelectorIsSilenced: 2295 for _, v := range fpaov.values.([]bool) { 2296 values = append(values, v) 2297 } 2298 case AlertState_FieldPathSelectorLifetime: 2299 for _, v := range fpaov.values.([]*common.TimeRange) { 2300 values = append(values, v) 2301 } 2302 case AlertState_FieldPathSelectorNeedsNotification: 2303 for _, v := range fpaov.values.([]bool) { 2304 values = append(values, v) 2305 } 2306 case AlertState_FieldPathSelectorNotificationCreated: 2307 for _, v := range fpaov.values.([]bool) { 2308 values = append(values, v) 2309 } 2310 case AlertState_FieldPathSelectorLifecycleCompleted: 2311 for _, v := range fpaov.values.([]bool) { 2312 values = append(values, v) 2313 } 2314 } 2315 return 2316 } 2317 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsIsFiringArrayOfValues() ([]bool, bool) { 2318 res, ok := fpaov.values.([]bool) 2319 return res, ok 2320 } 2321 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsIsAcknowledgedArrayOfValues() ([]bool, bool) { 2322 res, ok := fpaov.values.([]bool) 2323 return res, ok 2324 } 2325 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsIsSilencedArrayOfValues() ([]bool, bool) { 2326 res, ok := fpaov.values.([]bool) 2327 return res, ok 2328 } 2329 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsLifetimeArrayOfValues() ([]*common.TimeRange, bool) { 2330 res, ok := fpaov.values.([]*common.TimeRange) 2331 return res, ok 2332 } 2333 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsNeedsNotificationArrayOfValues() ([]bool, bool) { 2334 res, ok := fpaov.values.([]bool) 2335 return res, ok 2336 } 2337 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsNotificationCreatedArrayOfValues() ([]bool, bool) { 2338 res, ok := fpaov.values.([]bool) 2339 return res, ok 2340 } 2341 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsLifecycleCompletedArrayOfValues() ([]bool, bool) { 2342 res, ok := fpaov.values.([]bool) 2343 return res, ok 2344 } 2345 2346 type AlertState_FieldSubPathArrayOfValues struct { 2347 AlertState_FieldPath 2348 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 2349 } 2350 2351 var _ AlertState_FieldPathArrayOfValues = (*AlertState_FieldSubPathArrayOfValues)(nil) 2352 2353 func (fpsaov *AlertState_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 2354 return fpsaov.subPathArrayOfValues.GetRawValues() 2355 } 2356 func (fpsaov *AlertState_FieldSubPathArrayOfValues) AsLifetimePathArrayOfValues() (common.TimeRange_FieldPathArrayOfValues, bool) { 2357 res, ok := fpsaov.subPathArrayOfValues.(common.TimeRange_FieldPathArrayOfValues) 2358 return res, ok 2359 } 2360 2361 // FieldPath provides implementation to handle 2362 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 2363 type AlertInfoTimeSerie_FieldPath interface { 2364 gotenobject.FieldPath 2365 Selector() AlertInfoTimeSerie_FieldPathSelector 2366 Get(source *Alert_Info_TimeSerie) []interface{} 2367 GetSingle(source *Alert_Info_TimeSerie) (interface{}, bool) 2368 ClearValue(item *Alert_Info_TimeSerie) 2369 2370 // Those methods build corresponding AlertInfoTimeSerie_FieldPathValue 2371 // (or array of values) and holds passed value. Panics if injected type is incorrect. 2372 WithIValue(value interface{}) AlertInfoTimeSerie_FieldPathValue 2373 WithIArrayOfValues(values interface{}) AlertInfoTimeSerie_FieldPathArrayOfValues 2374 WithIArrayItemValue(value interface{}) AlertInfoTimeSerie_FieldPathArrayItemValue 2375 } 2376 2377 type AlertInfoTimeSerie_FieldPathSelector int32 2378 2379 const ( 2380 AlertInfoTimeSerie_FieldPathSelectorKey AlertInfoTimeSerie_FieldPathSelector = 0 2381 AlertInfoTimeSerie_FieldPathSelectorMetric AlertInfoTimeSerie_FieldPathSelector = 1 2382 AlertInfoTimeSerie_FieldPathSelectorMonitoredResource AlertInfoTimeSerie_FieldPathSelector = 2 2383 ) 2384 2385 func (s AlertInfoTimeSerie_FieldPathSelector) String() string { 2386 switch s { 2387 case AlertInfoTimeSerie_FieldPathSelectorKey: 2388 return "key" 2389 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2390 return "metric" 2391 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2392 return "monitored_resource" 2393 default: 2394 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", s)) 2395 } 2396 } 2397 2398 func BuildAlertInfoTimeSerie_FieldPath(fp gotenobject.RawFieldPath) (AlertInfoTimeSerie_FieldPath, error) { 2399 if len(fp) == 0 { 2400 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_Info_TimeSerie") 2401 } 2402 if len(fp) == 1 { 2403 switch fp[0] { 2404 case "key": 2405 return &AlertInfoTimeSerie_FieldTerminalPath{selector: AlertInfoTimeSerie_FieldPathSelectorKey}, nil 2406 case "metric": 2407 return &AlertInfoTimeSerie_FieldTerminalPath{selector: AlertInfoTimeSerie_FieldPathSelectorMetric}, nil 2408 case "monitored_resource", "monitoredResource", "monitored-resource": 2409 return &AlertInfoTimeSerie_FieldTerminalPath{selector: AlertInfoTimeSerie_FieldPathSelectorMonitoredResource}, nil 2410 } 2411 } else { 2412 switch fp[0] { 2413 case "metric": 2414 if subpath, err := common.BuildMetric_FieldPath(fp[1:]); err != nil { 2415 return nil, err 2416 } else { 2417 return &AlertInfoTimeSerie_FieldSubPath{selector: AlertInfoTimeSerie_FieldPathSelectorMetric, subPath: subpath}, nil 2418 } 2419 case "monitored_resource", "monitoredResource", "monitored-resource": 2420 if subpath, err := common.BuildMonitoredResource_FieldPath(fp[1:]); err != nil { 2421 return nil, err 2422 } else { 2423 return &AlertInfoTimeSerie_FieldSubPath{selector: AlertInfoTimeSerie_FieldPathSelectorMonitoredResource, subPath: subpath}, nil 2424 } 2425 } 2426 } 2427 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_Info_TimeSerie", fp) 2428 } 2429 2430 func ParseAlertInfoTimeSerie_FieldPath(rawField string) (AlertInfoTimeSerie_FieldPath, error) { 2431 fp, err := gotenobject.ParseRawFieldPath(rawField) 2432 if err != nil { 2433 return nil, err 2434 } 2435 return BuildAlertInfoTimeSerie_FieldPath(fp) 2436 } 2437 2438 func MustParseAlertInfoTimeSerie_FieldPath(rawField string) AlertInfoTimeSerie_FieldPath { 2439 fp, err := ParseAlertInfoTimeSerie_FieldPath(rawField) 2440 if err != nil { 2441 panic(err) 2442 } 2443 return fp 2444 } 2445 2446 type AlertInfoTimeSerie_FieldTerminalPath struct { 2447 selector AlertInfoTimeSerie_FieldPathSelector 2448 } 2449 2450 var _ AlertInfoTimeSerie_FieldPath = (*AlertInfoTimeSerie_FieldTerminalPath)(nil) 2451 2452 func (fp *AlertInfoTimeSerie_FieldTerminalPath) Selector() AlertInfoTimeSerie_FieldPathSelector { 2453 return fp.selector 2454 } 2455 2456 // String returns path representation in proto convention 2457 func (fp *AlertInfoTimeSerie_FieldTerminalPath) String() string { 2458 return fp.selector.String() 2459 } 2460 2461 // JSONString returns path representation is JSON convention 2462 func (fp *AlertInfoTimeSerie_FieldTerminalPath) JSONString() string { 2463 return strcase.ToLowerCamel(fp.String()) 2464 } 2465 2466 // Get returns all values pointed by specific field from source Alert_Info_TimeSerie 2467 func (fp *AlertInfoTimeSerie_FieldTerminalPath) Get(source *Alert_Info_TimeSerie) (values []interface{}) { 2468 if source != nil { 2469 switch fp.selector { 2470 case AlertInfoTimeSerie_FieldPathSelectorKey: 2471 values = append(values, source.Key) 2472 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2473 if source.Metric != nil { 2474 values = append(values, source.Metric) 2475 } 2476 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2477 if source.MonitoredResource != nil { 2478 values = append(values, source.MonitoredResource) 2479 } 2480 default: 2481 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fp.selector)) 2482 } 2483 } 2484 return 2485 } 2486 2487 func (fp *AlertInfoTimeSerie_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 2488 return fp.Get(source.(*Alert_Info_TimeSerie)) 2489 } 2490 2491 // GetSingle returns value pointed by specific field of from source Alert_Info_TimeSerie 2492 func (fp *AlertInfoTimeSerie_FieldTerminalPath) GetSingle(source *Alert_Info_TimeSerie) (interface{}, bool) { 2493 switch fp.selector { 2494 case AlertInfoTimeSerie_FieldPathSelectorKey: 2495 res := source.GetKey() 2496 return res, res != nil 2497 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2498 res := source.GetMetric() 2499 return res, res != nil 2500 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2501 res := source.GetMonitoredResource() 2502 return res, res != nil 2503 default: 2504 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fp.selector)) 2505 } 2506 } 2507 2508 func (fp *AlertInfoTimeSerie_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 2509 return fp.GetSingle(source.(*Alert_Info_TimeSerie)) 2510 } 2511 2512 // GetDefault returns a default value of the field type 2513 func (fp *AlertInfoTimeSerie_FieldTerminalPath) GetDefault() interface{} { 2514 switch fp.selector { 2515 case AlertInfoTimeSerie_FieldPathSelectorKey: 2516 return ([]byte)(nil) 2517 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2518 return (*common.Metric)(nil) 2519 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2520 return (*common.MonitoredResource)(nil) 2521 default: 2522 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fp.selector)) 2523 } 2524 } 2525 2526 func (fp *AlertInfoTimeSerie_FieldTerminalPath) ClearValue(item *Alert_Info_TimeSerie) { 2527 if item != nil { 2528 switch fp.selector { 2529 case AlertInfoTimeSerie_FieldPathSelectorKey: 2530 item.Key = nil 2531 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2532 item.Metric = nil 2533 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2534 item.MonitoredResource = nil 2535 default: 2536 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fp.selector)) 2537 } 2538 } 2539 } 2540 2541 func (fp *AlertInfoTimeSerie_FieldTerminalPath) ClearValueRaw(item proto.Message) { 2542 fp.ClearValue(item.(*Alert_Info_TimeSerie)) 2543 } 2544 2545 // IsLeaf - whether field path is holds simple value 2546 func (fp *AlertInfoTimeSerie_FieldTerminalPath) IsLeaf() bool { 2547 return fp.selector == AlertInfoTimeSerie_FieldPathSelectorKey 2548 } 2549 2550 func (fp *AlertInfoTimeSerie_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 2551 return []gotenobject.FieldPath{fp} 2552 } 2553 2554 func (fp *AlertInfoTimeSerie_FieldTerminalPath) WithIValue(value interface{}) AlertInfoTimeSerie_FieldPathValue { 2555 switch fp.selector { 2556 case AlertInfoTimeSerie_FieldPathSelectorKey: 2557 return &AlertInfoTimeSerie_FieldTerminalPathValue{AlertInfoTimeSerie_FieldTerminalPath: *fp, value: value.([]byte)} 2558 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2559 return &AlertInfoTimeSerie_FieldTerminalPathValue{AlertInfoTimeSerie_FieldTerminalPath: *fp, value: value.(*common.Metric)} 2560 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2561 return &AlertInfoTimeSerie_FieldTerminalPathValue{AlertInfoTimeSerie_FieldTerminalPath: *fp, value: value.(*common.MonitoredResource)} 2562 default: 2563 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fp.selector)) 2564 } 2565 } 2566 2567 func (fp *AlertInfoTimeSerie_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 2568 return fp.WithIValue(value) 2569 } 2570 2571 func (fp *AlertInfoTimeSerie_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertInfoTimeSerie_FieldPathArrayOfValues { 2572 fpaov := &AlertInfoTimeSerie_FieldTerminalPathArrayOfValues{AlertInfoTimeSerie_FieldTerminalPath: *fp} 2573 switch fp.selector { 2574 case AlertInfoTimeSerie_FieldPathSelectorKey: 2575 return &AlertInfoTimeSerie_FieldTerminalPathArrayOfValues{AlertInfoTimeSerie_FieldTerminalPath: *fp, values: values.([][]byte)} 2576 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2577 return &AlertInfoTimeSerie_FieldTerminalPathArrayOfValues{AlertInfoTimeSerie_FieldTerminalPath: *fp, values: values.([]*common.Metric)} 2578 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2579 return &AlertInfoTimeSerie_FieldTerminalPathArrayOfValues{AlertInfoTimeSerie_FieldTerminalPath: *fp, values: values.([]*common.MonitoredResource)} 2580 default: 2581 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fp.selector)) 2582 } 2583 return fpaov 2584 } 2585 2586 func (fp *AlertInfoTimeSerie_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 2587 return fp.WithIArrayOfValues(values) 2588 } 2589 2590 func (fp *AlertInfoTimeSerie_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertInfoTimeSerie_FieldPathArrayItemValue { 2591 switch fp.selector { 2592 default: 2593 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fp.selector)) 2594 } 2595 } 2596 2597 func (fp *AlertInfoTimeSerie_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 2598 return fp.WithIArrayItemValue(value) 2599 } 2600 2601 type AlertInfoTimeSerie_FieldSubPath struct { 2602 selector AlertInfoTimeSerie_FieldPathSelector 2603 subPath gotenobject.FieldPath 2604 } 2605 2606 var _ AlertInfoTimeSerie_FieldPath = (*AlertInfoTimeSerie_FieldSubPath)(nil) 2607 2608 func (fps *AlertInfoTimeSerie_FieldSubPath) Selector() AlertInfoTimeSerie_FieldPathSelector { 2609 return fps.selector 2610 } 2611 func (fps *AlertInfoTimeSerie_FieldSubPath) AsMetricSubPath() (common.Metric_FieldPath, bool) { 2612 res, ok := fps.subPath.(common.Metric_FieldPath) 2613 return res, ok 2614 } 2615 func (fps *AlertInfoTimeSerie_FieldSubPath) AsMonitoredResourceSubPath() (common.MonitoredResource_FieldPath, bool) { 2616 res, ok := fps.subPath.(common.MonitoredResource_FieldPath) 2617 return res, ok 2618 } 2619 2620 // String returns path representation in proto convention 2621 func (fps *AlertInfoTimeSerie_FieldSubPath) String() string { 2622 return fps.selector.String() + "." + fps.subPath.String() 2623 } 2624 2625 // JSONString returns path representation is JSON convention 2626 func (fps *AlertInfoTimeSerie_FieldSubPath) JSONString() string { 2627 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 2628 } 2629 2630 // Get returns all values pointed by selected field from source Alert_Info_TimeSerie 2631 func (fps *AlertInfoTimeSerie_FieldSubPath) Get(source *Alert_Info_TimeSerie) (values []interface{}) { 2632 switch fps.selector { 2633 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2634 values = append(values, fps.subPath.GetRaw(source.GetMetric())...) 2635 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2636 values = append(values, fps.subPath.GetRaw(source.GetMonitoredResource())...) 2637 default: 2638 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fps.selector)) 2639 } 2640 return 2641 } 2642 2643 func (fps *AlertInfoTimeSerie_FieldSubPath) GetRaw(source proto.Message) []interface{} { 2644 return fps.Get(source.(*Alert_Info_TimeSerie)) 2645 } 2646 2647 // GetSingle returns value of selected field from source Alert_Info_TimeSerie 2648 func (fps *AlertInfoTimeSerie_FieldSubPath) GetSingle(source *Alert_Info_TimeSerie) (interface{}, bool) { 2649 switch fps.selector { 2650 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2651 if source.GetMetric() == nil { 2652 return nil, false 2653 } 2654 return fps.subPath.GetSingleRaw(source.GetMetric()) 2655 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2656 if source.GetMonitoredResource() == nil { 2657 return nil, false 2658 } 2659 return fps.subPath.GetSingleRaw(source.GetMonitoredResource()) 2660 default: 2661 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fps.selector)) 2662 } 2663 } 2664 2665 func (fps *AlertInfoTimeSerie_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 2666 return fps.GetSingle(source.(*Alert_Info_TimeSerie)) 2667 } 2668 2669 // GetDefault returns a default value of the field type 2670 func (fps *AlertInfoTimeSerie_FieldSubPath) GetDefault() interface{} { 2671 return fps.subPath.GetDefault() 2672 } 2673 2674 func (fps *AlertInfoTimeSerie_FieldSubPath) ClearValue(item *Alert_Info_TimeSerie) { 2675 if item != nil { 2676 switch fps.selector { 2677 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2678 fps.subPath.ClearValueRaw(item.Metric) 2679 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2680 fps.subPath.ClearValueRaw(item.MonitoredResource) 2681 default: 2682 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fps.selector)) 2683 } 2684 } 2685 } 2686 2687 func (fps *AlertInfoTimeSerie_FieldSubPath) ClearValueRaw(item proto.Message) { 2688 fps.ClearValue(item.(*Alert_Info_TimeSerie)) 2689 } 2690 2691 // IsLeaf - whether field path is holds simple value 2692 func (fps *AlertInfoTimeSerie_FieldSubPath) IsLeaf() bool { 2693 return fps.subPath.IsLeaf() 2694 } 2695 2696 func (fps *AlertInfoTimeSerie_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 2697 iPaths := []gotenobject.FieldPath{&AlertInfoTimeSerie_FieldTerminalPath{selector: fps.selector}} 2698 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 2699 return iPaths 2700 } 2701 2702 func (fps *AlertInfoTimeSerie_FieldSubPath) WithIValue(value interface{}) AlertInfoTimeSerie_FieldPathValue { 2703 return &AlertInfoTimeSerie_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 2704 } 2705 2706 func (fps *AlertInfoTimeSerie_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 2707 return fps.WithIValue(value) 2708 } 2709 2710 func (fps *AlertInfoTimeSerie_FieldSubPath) WithIArrayOfValues(values interface{}) AlertInfoTimeSerie_FieldPathArrayOfValues { 2711 return &AlertInfoTimeSerie_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 2712 } 2713 2714 func (fps *AlertInfoTimeSerie_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 2715 return fps.WithIArrayOfValues(values) 2716 } 2717 2718 func (fps *AlertInfoTimeSerie_FieldSubPath) WithIArrayItemValue(value interface{}) AlertInfoTimeSerie_FieldPathArrayItemValue { 2719 return &AlertInfoTimeSerie_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 2720 } 2721 2722 func (fps *AlertInfoTimeSerie_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 2723 return fps.WithIArrayItemValue(value) 2724 } 2725 2726 // AlertInfoTimeSerie_FieldPathValue allows storing values for TimeSerie fields according to their type 2727 type AlertInfoTimeSerie_FieldPathValue interface { 2728 AlertInfoTimeSerie_FieldPath 2729 gotenobject.FieldPathValue 2730 SetTo(target **Alert_Info_TimeSerie) 2731 CompareWith(*Alert_Info_TimeSerie) (cmp int, comparable bool) 2732 } 2733 2734 func ParseAlertInfoTimeSerie_FieldPathValue(pathStr, valueStr string) (AlertInfoTimeSerie_FieldPathValue, error) { 2735 fp, err := ParseAlertInfoTimeSerie_FieldPath(pathStr) 2736 if err != nil { 2737 return nil, err 2738 } 2739 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 2740 if err != nil { 2741 return nil, status.Errorf(codes.InvalidArgument, "error parsing TimeSerie field path value from %s: %v", valueStr, err) 2742 } 2743 return fpv.(AlertInfoTimeSerie_FieldPathValue), nil 2744 } 2745 2746 func MustParseAlertInfoTimeSerie_FieldPathValue(pathStr, valueStr string) AlertInfoTimeSerie_FieldPathValue { 2747 fpv, err := ParseAlertInfoTimeSerie_FieldPathValue(pathStr, valueStr) 2748 if err != nil { 2749 panic(err) 2750 } 2751 return fpv 2752 } 2753 2754 type AlertInfoTimeSerie_FieldTerminalPathValue struct { 2755 AlertInfoTimeSerie_FieldTerminalPath 2756 value interface{} 2757 } 2758 2759 var _ AlertInfoTimeSerie_FieldPathValue = (*AlertInfoTimeSerie_FieldTerminalPathValue)(nil) 2760 2761 // GetRawValue returns raw value stored under selected path for 'TimeSerie' as interface{} 2762 func (fpv *AlertInfoTimeSerie_FieldTerminalPathValue) GetRawValue() interface{} { 2763 return fpv.value 2764 } 2765 func (fpv *AlertInfoTimeSerie_FieldTerminalPathValue) AsKeyValue() ([]byte, bool) { 2766 res, ok := fpv.value.([]byte) 2767 return res, ok 2768 } 2769 func (fpv *AlertInfoTimeSerie_FieldTerminalPathValue) AsMetricValue() (*common.Metric, bool) { 2770 res, ok := fpv.value.(*common.Metric) 2771 return res, ok 2772 } 2773 func (fpv *AlertInfoTimeSerie_FieldTerminalPathValue) AsMonitoredResourceValue() (*common.MonitoredResource, bool) { 2774 res, ok := fpv.value.(*common.MonitoredResource) 2775 return res, ok 2776 } 2777 2778 // SetTo stores value for selected field for object TimeSerie 2779 func (fpv *AlertInfoTimeSerie_FieldTerminalPathValue) SetTo(target **Alert_Info_TimeSerie) { 2780 if *target == nil { 2781 *target = new(Alert_Info_TimeSerie) 2782 } 2783 switch fpv.selector { 2784 case AlertInfoTimeSerie_FieldPathSelectorKey: 2785 (*target).Key = fpv.value.([]byte) 2786 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2787 (*target).Metric = fpv.value.(*common.Metric) 2788 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2789 (*target).MonitoredResource = fpv.value.(*common.MonitoredResource) 2790 default: 2791 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fpv.selector)) 2792 } 2793 } 2794 2795 func (fpv *AlertInfoTimeSerie_FieldTerminalPathValue) SetToRaw(target proto.Message) { 2796 typedObject := target.(*Alert_Info_TimeSerie) 2797 fpv.SetTo(&typedObject) 2798 } 2799 2800 // CompareWith compares value in the 'AlertInfoTimeSerie_FieldTerminalPathValue' with the value under path in 'Alert_Info_TimeSerie'. 2801 func (fpv *AlertInfoTimeSerie_FieldTerminalPathValue) CompareWith(source *Alert_Info_TimeSerie) (int, bool) { 2802 switch fpv.selector { 2803 case AlertInfoTimeSerie_FieldPathSelectorKey: 2804 return 0, false 2805 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2806 return 0, false 2807 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2808 return 0, false 2809 default: 2810 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fpv.selector)) 2811 } 2812 } 2813 2814 func (fpv *AlertInfoTimeSerie_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2815 return fpv.CompareWith(source.(*Alert_Info_TimeSerie)) 2816 } 2817 2818 type AlertInfoTimeSerie_FieldSubPathValue struct { 2819 AlertInfoTimeSerie_FieldPath 2820 subPathValue gotenobject.FieldPathValue 2821 } 2822 2823 var _ AlertInfoTimeSerie_FieldPathValue = (*AlertInfoTimeSerie_FieldSubPathValue)(nil) 2824 2825 func (fpvs *AlertInfoTimeSerie_FieldSubPathValue) AsMetricPathValue() (common.Metric_FieldPathValue, bool) { 2826 res, ok := fpvs.subPathValue.(common.Metric_FieldPathValue) 2827 return res, ok 2828 } 2829 func (fpvs *AlertInfoTimeSerie_FieldSubPathValue) AsMonitoredResourcePathValue() (common.MonitoredResource_FieldPathValue, bool) { 2830 res, ok := fpvs.subPathValue.(common.MonitoredResource_FieldPathValue) 2831 return res, ok 2832 } 2833 2834 func (fpvs *AlertInfoTimeSerie_FieldSubPathValue) SetTo(target **Alert_Info_TimeSerie) { 2835 if *target == nil { 2836 *target = new(Alert_Info_TimeSerie) 2837 } 2838 switch fpvs.Selector() { 2839 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2840 fpvs.subPathValue.(common.Metric_FieldPathValue).SetTo(&(*target).Metric) 2841 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2842 fpvs.subPathValue.(common.MonitoredResource_FieldPathValue).SetTo(&(*target).MonitoredResource) 2843 default: 2844 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fpvs.Selector())) 2845 } 2846 } 2847 2848 func (fpvs *AlertInfoTimeSerie_FieldSubPathValue) SetToRaw(target proto.Message) { 2849 typedObject := target.(*Alert_Info_TimeSerie) 2850 fpvs.SetTo(&typedObject) 2851 } 2852 2853 func (fpvs *AlertInfoTimeSerie_FieldSubPathValue) GetRawValue() interface{} { 2854 return fpvs.subPathValue.GetRawValue() 2855 } 2856 2857 func (fpvs *AlertInfoTimeSerie_FieldSubPathValue) CompareWith(source *Alert_Info_TimeSerie) (int, bool) { 2858 switch fpvs.Selector() { 2859 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2860 return fpvs.subPathValue.(common.Metric_FieldPathValue).CompareWith(source.GetMetric()) 2861 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2862 return fpvs.subPathValue.(common.MonitoredResource_FieldPathValue).CompareWith(source.GetMonitoredResource()) 2863 default: 2864 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fpvs.Selector())) 2865 } 2866 } 2867 2868 func (fpvs *AlertInfoTimeSerie_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2869 return fpvs.CompareWith(source.(*Alert_Info_TimeSerie)) 2870 } 2871 2872 // AlertInfoTimeSerie_FieldPathArrayItemValue allows storing single item in Path-specific values for TimeSerie according to their type 2873 // Present only for array (repeated) types. 2874 type AlertInfoTimeSerie_FieldPathArrayItemValue interface { 2875 gotenobject.FieldPathArrayItemValue 2876 AlertInfoTimeSerie_FieldPath 2877 ContainsValue(*Alert_Info_TimeSerie) bool 2878 } 2879 2880 // ParseAlertInfoTimeSerie_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 2881 func ParseAlertInfoTimeSerie_FieldPathArrayItemValue(pathStr, valueStr string) (AlertInfoTimeSerie_FieldPathArrayItemValue, error) { 2882 fp, err := ParseAlertInfoTimeSerie_FieldPath(pathStr) 2883 if err != nil { 2884 return nil, err 2885 } 2886 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 2887 if err != nil { 2888 return nil, status.Errorf(codes.InvalidArgument, "error parsing TimeSerie field path array item value from %s: %v", valueStr, err) 2889 } 2890 return fpaiv.(AlertInfoTimeSerie_FieldPathArrayItemValue), nil 2891 } 2892 2893 func MustParseAlertInfoTimeSerie_FieldPathArrayItemValue(pathStr, valueStr string) AlertInfoTimeSerie_FieldPathArrayItemValue { 2894 fpaiv, err := ParseAlertInfoTimeSerie_FieldPathArrayItemValue(pathStr, valueStr) 2895 if err != nil { 2896 panic(err) 2897 } 2898 return fpaiv 2899 } 2900 2901 type AlertInfoTimeSerie_FieldTerminalPathArrayItemValue struct { 2902 AlertInfoTimeSerie_FieldTerminalPath 2903 value interface{} 2904 } 2905 2906 var _ AlertInfoTimeSerie_FieldPathArrayItemValue = (*AlertInfoTimeSerie_FieldTerminalPathArrayItemValue)(nil) 2907 2908 // GetRawValue returns stored element value for array in object Alert_Info_TimeSerie as interface{} 2909 func (fpaiv *AlertInfoTimeSerie_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 2910 return fpaiv.value 2911 } 2912 2913 func (fpaiv *AlertInfoTimeSerie_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_Info_TimeSerie) (interface{}, bool) { 2914 return nil, false 2915 } 2916 2917 func (fpaiv *AlertInfoTimeSerie_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 2918 return fpaiv.GetSingle(source.(*Alert_Info_TimeSerie)) 2919 } 2920 2921 // Contains returns a boolean indicating if value that is being held is present in given 'TimeSerie' 2922 func (fpaiv *AlertInfoTimeSerie_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_Info_TimeSerie) bool { 2923 slice := fpaiv.AlertInfoTimeSerie_FieldTerminalPath.Get(source) 2924 for _, v := range slice { 2925 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 2926 if proto.Equal(asProtoMsg, v.(proto.Message)) { 2927 return true 2928 } 2929 } else if reflect.DeepEqual(v, fpaiv.value) { 2930 return true 2931 } 2932 } 2933 return false 2934 } 2935 2936 type AlertInfoTimeSerie_FieldSubPathArrayItemValue struct { 2937 AlertInfoTimeSerie_FieldPath 2938 subPathItemValue gotenobject.FieldPathArrayItemValue 2939 } 2940 2941 // GetRawValue returns stored array item value 2942 func (fpaivs *AlertInfoTimeSerie_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 2943 return fpaivs.subPathItemValue.GetRawItemValue() 2944 } 2945 func (fpaivs *AlertInfoTimeSerie_FieldSubPathArrayItemValue) AsMetricPathItemValue() (common.Metric_FieldPathArrayItemValue, bool) { 2946 res, ok := fpaivs.subPathItemValue.(common.Metric_FieldPathArrayItemValue) 2947 return res, ok 2948 } 2949 func (fpaivs *AlertInfoTimeSerie_FieldSubPathArrayItemValue) AsMonitoredResourcePathItemValue() (common.MonitoredResource_FieldPathArrayItemValue, bool) { 2950 res, ok := fpaivs.subPathItemValue.(common.MonitoredResource_FieldPathArrayItemValue) 2951 return res, ok 2952 } 2953 2954 // Contains returns a boolean indicating if value that is being held is present in given 'TimeSerie' 2955 func (fpaivs *AlertInfoTimeSerie_FieldSubPathArrayItemValue) ContainsValue(source *Alert_Info_TimeSerie) bool { 2956 switch fpaivs.Selector() { 2957 case AlertInfoTimeSerie_FieldPathSelectorMetric: 2958 return fpaivs.subPathItemValue.(common.Metric_FieldPathArrayItemValue).ContainsValue(source.GetMetric()) 2959 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 2960 return fpaivs.subPathItemValue.(common.MonitoredResource_FieldPathArrayItemValue).ContainsValue(source.GetMonitoredResource()) 2961 default: 2962 panic(fmt.Sprintf("Invalid selector for Alert_Info_TimeSerie: %d", fpaivs.Selector())) 2963 } 2964 } 2965 2966 // AlertInfoTimeSerie_FieldPathArrayOfValues allows storing slice of values for TimeSerie fields according to their type 2967 type AlertInfoTimeSerie_FieldPathArrayOfValues interface { 2968 gotenobject.FieldPathArrayOfValues 2969 AlertInfoTimeSerie_FieldPath 2970 } 2971 2972 func ParseAlertInfoTimeSerie_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertInfoTimeSerie_FieldPathArrayOfValues, error) { 2973 fp, err := ParseAlertInfoTimeSerie_FieldPath(pathStr) 2974 if err != nil { 2975 return nil, err 2976 } 2977 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 2978 if err != nil { 2979 return nil, status.Errorf(codes.InvalidArgument, "error parsing TimeSerie field path array of values from %s: %v", valuesStr, err) 2980 } 2981 return fpaov.(AlertInfoTimeSerie_FieldPathArrayOfValues), nil 2982 } 2983 2984 func MustParseAlertInfoTimeSerie_FieldPathArrayOfValues(pathStr, valuesStr string) AlertInfoTimeSerie_FieldPathArrayOfValues { 2985 fpaov, err := ParseAlertInfoTimeSerie_FieldPathArrayOfValues(pathStr, valuesStr) 2986 if err != nil { 2987 panic(err) 2988 } 2989 return fpaov 2990 } 2991 2992 type AlertInfoTimeSerie_FieldTerminalPathArrayOfValues struct { 2993 AlertInfoTimeSerie_FieldTerminalPath 2994 values interface{} 2995 } 2996 2997 var _ AlertInfoTimeSerie_FieldPathArrayOfValues = (*AlertInfoTimeSerie_FieldTerminalPathArrayOfValues)(nil) 2998 2999 func (fpaov *AlertInfoTimeSerie_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 3000 switch fpaov.selector { 3001 case AlertInfoTimeSerie_FieldPathSelectorKey: 3002 for _, v := range fpaov.values.([][]byte) { 3003 values = append(values, v) 3004 } 3005 case AlertInfoTimeSerie_FieldPathSelectorMetric: 3006 for _, v := range fpaov.values.([]*common.Metric) { 3007 values = append(values, v) 3008 } 3009 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 3010 for _, v := range fpaov.values.([]*common.MonitoredResource) { 3011 values = append(values, v) 3012 } 3013 } 3014 return 3015 } 3016 func (fpaov *AlertInfoTimeSerie_FieldTerminalPathArrayOfValues) AsKeyArrayOfValues() ([][]byte, bool) { 3017 res, ok := fpaov.values.([][]byte) 3018 return res, ok 3019 } 3020 func (fpaov *AlertInfoTimeSerie_FieldTerminalPathArrayOfValues) AsMetricArrayOfValues() ([]*common.Metric, bool) { 3021 res, ok := fpaov.values.([]*common.Metric) 3022 return res, ok 3023 } 3024 func (fpaov *AlertInfoTimeSerie_FieldTerminalPathArrayOfValues) AsMonitoredResourceArrayOfValues() ([]*common.MonitoredResource, bool) { 3025 res, ok := fpaov.values.([]*common.MonitoredResource) 3026 return res, ok 3027 } 3028 3029 type AlertInfoTimeSerie_FieldSubPathArrayOfValues struct { 3030 AlertInfoTimeSerie_FieldPath 3031 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 3032 } 3033 3034 var _ AlertInfoTimeSerie_FieldPathArrayOfValues = (*AlertInfoTimeSerie_FieldSubPathArrayOfValues)(nil) 3035 3036 func (fpsaov *AlertInfoTimeSerie_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 3037 return fpsaov.subPathArrayOfValues.GetRawValues() 3038 } 3039 func (fpsaov *AlertInfoTimeSerie_FieldSubPathArrayOfValues) AsMetricPathArrayOfValues() (common.Metric_FieldPathArrayOfValues, bool) { 3040 res, ok := fpsaov.subPathArrayOfValues.(common.Metric_FieldPathArrayOfValues) 3041 return res, ok 3042 } 3043 func (fpsaov *AlertInfoTimeSerie_FieldSubPathArrayOfValues) AsMonitoredResourcePathArrayOfValues() (common.MonitoredResource_FieldPathArrayOfValues, bool) { 3044 res, ok := fpsaov.subPathArrayOfValues.(common.MonitoredResource_FieldPathArrayOfValues) 3045 return res, ok 3046 } 3047 3048 // FieldPath provides implementation to handle 3049 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 3050 type AlertInfoObservedValues_FieldPath interface { 3051 gotenobject.FieldPath 3052 Selector() AlertInfoObservedValues_FieldPathSelector 3053 Get(source *Alert_Info_ObservedValues) []interface{} 3054 GetSingle(source *Alert_Info_ObservedValues) (interface{}, bool) 3055 ClearValue(item *Alert_Info_ObservedValues) 3056 3057 // Those methods build corresponding AlertInfoObservedValues_FieldPathValue 3058 // (or array of values) and holds passed value. Panics if injected type is incorrect. 3059 WithIValue(value interface{}) AlertInfoObservedValues_FieldPathValue 3060 WithIArrayOfValues(values interface{}) AlertInfoObservedValues_FieldPathArrayOfValues 3061 WithIArrayItemValue(value interface{}) AlertInfoObservedValues_FieldPathArrayItemValue 3062 } 3063 3064 type AlertInfoObservedValues_FieldPathSelector int32 3065 3066 const ( 3067 AlertInfoObservedValues_FieldPathSelectorExampleValue AlertInfoObservedValues_FieldPathSelector = 0 3068 AlertInfoObservedValues_FieldPathSelectorPerMetric AlertInfoObservedValues_FieldPathSelector = 1 3069 ) 3070 3071 func (s AlertInfoObservedValues_FieldPathSelector) String() string { 3072 switch s { 3073 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 3074 return "example_value" 3075 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3076 return "per_metric" 3077 default: 3078 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", s)) 3079 } 3080 } 3081 3082 func BuildAlertInfoObservedValues_FieldPath(fp gotenobject.RawFieldPath) (AlertInfoObservedValues_FieldPath, error) { 3083 if len(fp) == 0 { 3084 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_Info_ObservedValues") 3085 } 3086 if len(fp) == 1 { 3087 switch fp[0] { 3088 case "example_value", "exampleValue", "example-value": 3089 return &AlertInfoObservedValues_FieldTerminalPath{selector: AlertInfoObservedValues_FieldPathSelectorExampleValue}, nil 3090 case "per_metric", "perMetric", "per-metric": 3091 return &AlertInfoObservedValues_FieldTerminalPath{selector: AlertInfoObservedValues_FieldPathSelectorPerMetric}, nil 3092 } 3093 } else { 3094 switch fp[0] { 3095 case "per_metric", "perMetric", "per-metric": 3096 if len(fp) > 2 { 3097 return nil, status.Errorf(codes.InvalidArgument, "sub path for maps ('%s') are not supported (object Alert_Info_ObservedValues)", fp) 3098 } 3099 return &AlertInfoObservedValues_FieldPathMap{selector: AlertInfoObservedValues_FieldPathSelectorPerMetric, key: fp[1]}, nil 3100 } 3101 } 3102 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_Info_ObservedValues", fp) 3103 } 3104 3105 func ParseAlertInfoObservedValues_FieldPath(rawField string) (AlertInfoObservedValues_FieldPath, error) { 3106 fp, err := gotenobject.ParseRawFieldPath(rawField) 3107 if err != nil { 3108 return nil, err 3109 } 3110 return BuildAlertInfoObservedValues_FieldPath(fp) 3111 } 3112 3113 func MustParseAlertInfoObservedValues_FieldPath(rawField string) AlertInfoObservedValues_FieldPath { 3114 fp, err := ParseAlertInfoObservedValues_FieldPath(rawField) 3115 if err != nil { 3116 panic(err) 3117 } 3118 return fp 3119 } 3120 3121 type AlertInfoObservedValues_FieldTerminalPath struct { 3122 selector AlertInfoObservedValues_FieldPathSelector 3123 } 3124 3125 var _ AlertInfoObservedValues_FieldPath = (*AlertInfoObservedValues_FieldTerminalPath)(nil) 3126 3127 func (fp *AlertInfoObservedValues_FieldTerminalPath) Selector() AlertInfoObservedValues_FieldPathSelector { 3128 return fp.selector 3129 } 3130 3131 // String returns path representation in proto convention 3132 func (fp *AlertInfoObservedValues_FieldTerminalPath) String() string { 3133 return fp.selector.String() 3134 } 3135 3136 // JSONString returns path representation is JSON convention 3137 func (fp *AlertInfoObservedValues_FieldTerminalPath) JSONString() string { 3138 return strcase.ToLowerCamel(fp.String()) 3139 } 3140 3141 // Get returns all values pointed by specific field from source Alert_Info_ObservedValues 3142 func (fp *AlertInfoObservedValues_FieldTerminalPath) Get(source *Alert_Info_ObservedValues) (values []interface{}) { 3143 if source != nil { 3144 switch fp.selector { 3145 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 3146 values = append(values, source.ExampleValue) 3147 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3148 values = append(values, source.PerMetric) 3149 default: 3150 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fp.selector)) 3151 } 3152 } 3153 return 3154 } 3155 3156 func (fp *AlertInfoObservedValues_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 3157 return fp.Get(source.(*Alert_Info_ObservedValues)) 3158 } 3159 3160 // GetSingle returns value pointed by specific field of from source Alert_Info_ObservedValues 3161 func (fp *AlertInfoObservedValues_FieldTerminalPath) GetSingle(source *Alert_Info_ObservedValues) (interface{}, bool) { 3162 switch fp.selector { 3163 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 3164 return source.GetExampleValue(), source != nil 3165 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3166 res := source.GetPerMetric() 3167 return res, res != nil 3168 default: 3169 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fp.selector)) 3170 } 3171 } 3172 3173 func (fp *AlertInfoObservedValues_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 3174 return fp.GetSingle(source.(*Alert_Info_ObservedValues)) 3175 } 3176 3177 // GetDefault returns a default value of the field type 3178 func (fp *AlertInfoObservedValues_FieldTerminalPath) GetDefault() interface{} { 3179 switch fp.selector { 3180 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 3181 return float64(0) 3182 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3183 return (map[string]float64)(nil) 3184 default: 3185 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fp.selector)) 3186 } 3187 } 3188 3189 func (fp *AlertInfoObservedValues_FieldTerminalPath) ClearValue(item *Alert_Info_ObservedValues) { 3190 if item != nil { 3191 switch fp.selector { 3192 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 3193 item.ExampleValue = float64(0) 3194 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3195 item.PerMetric = nil 3196 default: 3197 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fp.selector)) 3198 } 3199 } 3200 } 3201 3202 func (fp *AlertInfoObservedValues_FieldTerminalPath) ClearValueRaw(item proto.Message) { 3203 fp.ClearValue(item.(*Alert_Info_ObservedValues)) 3204 } 3205 3206 // IsLeaf - whether field path is holds simple value 3207 func (fp *AlertInfoObservedValues_FieldTerminalPath) IsLeaf() bool { 3208 return fp.selector == AlertInfoObservedValues_FieldPathSelectorExampleValue || 3209 fp.selector == AlertInfoObservedValues_FieldPathSelectorPerMetric 3210 } 3211 3212 func (fp *AlertInfoObservedValues_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 3213 return []gotenobject.FieldPath{fp} 3214 } 3215 3216 func (fp *AlertInfoObservedValues_FieldTerminalPath) WithIValue(value interface{}) AlertInfoObservedValues_FieldPathValue { 3217 switch fp.selector { 3218 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 3219 return &AlertInfoObservedValues_FieldTerminalPathValue{AlertInfoObservedValues_FieldTerminalPath: *fp, value: value.(float64)} 3220 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3221 return &AlertInfoObservedValues_FieldTerminalPathValue{AlertInfoObservedValues_FieldTerminalPath: *fp, value: value.(map[string]float64)} 3222 default: 3223 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fp.selector)) 3224 } 3225 } 3226 3227 func (fp *AlertInfoObservedValues_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 3228 return fp.WithIValue(value) 3229 } 3230 3231 func (fp *AlertInfoObservedValues_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertInfoObservedValues_FieldPathArrayOfValues { 3232 fpaov := &AlertInfoObservedValues_FieldTerminalPathArrayOfValues{AlertInfoObservedValues_FieldTerminalPath: *fp} 3233 switch fp.selector { 3234 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 3235 return &AlertInfoObservedValues_FieldTerminalPathArrayOfValues{AlertInfoObservedValues_FieldTerminalPath: *fp, values: values.([]float64)} 3236 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3237 return &AlertInfoObservedValues_FieldTerminalPathArrayOfValues{AlertInfoObservedValues_FieldTerminalPath: *fp, values: values.([]map[string]float64)} 3238 default: 3239 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fp.selector)) 3240 } 3241 return fpaov 3242 } 3243 3244 func (fp *AlertInfoObservedValues_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 3245 return fp.WithIArrayOfValues(values) 3246 } 3247 3248 func (fp *AlertInfoObservedValues_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertInfoObservedValues_FieldPathArrayItemValue { 3249 switch fp.selector { 3250 default: 3251 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fp.selector)) 3252 } 3253 } 3254 3255 func (fp *AlertInfoObservedValues_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 3256 return fp.WithIArrayItemValue(value) 3257 } 3258 3259 // FieldPath for map type with additional Key information 3260 type AlertInfoObservedValues_FieldPathMap struct { 3261 key string 3262 selector AlertInfoObservedValues_FieldPathSelector 3263 } 3264 3265 var _ AlertInfoObservedValues_FieldPath = (*AlertInfoObservedValues_FieldPathMap)(nil) 3266 3267 func (fpm *AlertInfoObservedValues_FieldPathMap) Selector() AlertInfoObservedValues_FieldPathSelector { 3268 return fpm.selector 3269 } 3270 3271 func (fpm *AlertInfoObservedValues_FieldPathMap) Key() string { 3272 return fpm.key 3273 } 3274 3275 // String returns path representation in proto convention 3276 func (fpm *AlertInfoObservedValues_FieldPathMap) String() string { 3277 return fpm.selector.String() + "." + fpm.key 3278 } 3279 3280 // JSONString returns path representation is JSON convention. Note that map keys are not transformed 3281 func (fpm *AlertInfoObservedValues_FieldPathMap) JSONString() string { 3282 return strcase.ToLowerCamel(fpm.selector.String()) + "." + fpm.key 3283 } 3284 3285 // Get returns all values pointed by selected field map key from source Alert_Info_ObservedValues 3286 func (fpm *AlertInfoObservedValues_FieldPathMap) Get(source *Alert_Info_ObservedValues) (values []interface{}) { 3287 switch fpm.selector { 3288 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3289 if value, ok := source.GetPerMetric()[fpm.key]; ok { 3290 values = append(values, value) 3291 } 3292 default: 3293 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpm.selector)) 3294 } 3295 return 3296 } 3297 3298 func (fpm *AlertInfoObservedValues_FieldPathMap) GetRaw(source proto.Message) []interface{} { 3299 return fpm.Get(source.(*Alert_Info_ObservedValues)) 3300 } 3301 3302 // GetSingle returns value by selected field map key from source Alert_Info_ObservedValues 3303 func (fpm *AlertInfoObservedValues_FieldPathMap) GetSingle(source *Alert_Info_ObservedValues) (interface{}, bool) { 3304 switch fpm.selector { 3305 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3306 res, ok := source.GetPerMetric()[fpm.key] 3307 return res, ok 3308 default: 3309 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpm.selector)) 3310 } 3311 } 3312 3313 func (fpm *AlertInfoObservedValues_FieldPathMap) GetSingleRaw(source proto.Message) (interface{}, bool) { 3314 return fpm.GetSingle(source.(*Alert_Info_ObservedValues)) 3315 } 3316 3317 // GetDefault returns a default value of the field type 3318 func (fpm *AlertInfoObservedValues_FieldPathMap) GetDefault() interface{} { 3319 switch fpm.selector { 3320 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3321 var v float64 3322 return v 3323 default: 3324 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpm.selector)) 3325 } 3326 } 3327 3328 func (fpm *AlertInfoObservedValues_FieldPathMap) ClearValue(item *Alert_Info_ObservedValues) { 3329 if item != nil { 3330 switch fpm.selector { 3331 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3332 delete(item.PerMetric, fpm.key) 3333 default: 3334 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpm.selector)) 3335 } 3336 } 3337 } 3338 3339 func (fpm *AlertInfoObservedValues_FieldPathMap) ClearValueRaw(item proto.Message) { 3340 fpm.ClearValue(item.(*Alert_Info_ObservedValues)) 3341 } 3342 3343 // IsLeaf - whether field path is holds simple value 3344 func (fpm *AlertInfoObservedValues_FieldPathMap) IsLeaf() bool { 3345 switch fpm.selector { 3346 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3347 return true 3348 default: 3349 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpm.selector)) 3350 } 3351 } 3352 3353 func (fpm *AlertInfoObservedValues_FieldPathMap) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 3354 return []gotenobject.FieldPath{fpm} 3355 } 3356 3357 func (fpm *AlertInfoObservedValues_FieldPathMap) WithIValue(value interface{}) AlertInfoObservedValues_FieldPathValue { 3358 switch fpm.selector { 3359 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3360 return &AlertInfoObservedValues_FieldPathMapValue{AlertInfoObservedValues_FieldPathMap: *fpm, value: value.(float64)} 3361 default: 3362 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpm.selector)) 3363 } 3364 } 3365 3366 func (fpm *AlertInfoObservedValues_FieldPathMap) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 3367 return fpm.WithIValue(value) 3368 } 3369 3370 func (fpm *AlertInfoObservedValues_FieldPathMap) WithIArrayOfValues(values interface{}) AlertInfoObservedValues_FieldPathArrayOfValues { 3371 switch fpm.selector { 3372 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3373 return &AlertInfoObservedValues_FieldPathMapArrayOfValues{AlertInfoObservedValues_FieldPathMap: *fpm, values: values.([]float64)} 3374 default: 3375 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpm.selector)) 3376 } 3377 } 3378 3379 func (fpm *AlertInfoObservedValues_FieldPathMap) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 3380 return fpm.WithIArrayOfValues(values) 3381 } 3382 3383 func (fpm *AlertInfoObservedValues_FieldPathMap) WithIArrayItemValue(value interface{}) AlertInfoObservedValues_FieldPathArrayItemValue { 3384 panic("Cannot create array item value from map fieldpath") 3385 } 3386 3387 func (fpm *AlertInfoObservedValues_FieldPathMap) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 3388 return fpm.WithIArrayItemValue(value) 3389 } 3390 3391 // AlertInfoObservedValues_FieldPathValue allows storing values for ObservedValues fields according to their type 3392 type AlertInfoObservedValues_FieldPathValue interface { 3393 AlertInfoObservedValues_FieldPath 3394 gotenobject.FieldPathValue 3395 SetTo(target **Alert_Info_ObservedValues) 3396 CompareWith(*Alert_Info_ObservedValues) (cmp int, comparable bool) 3397 } 3398 3399 func ParseAlertInfoObservedValues_FieldPathValue(pathStr, valueStr string) (AlertInfoObservedValues_FieldPathValue, error) { 3400 fp, err := ParseAlertInfoObservedValues_FieldPath(pathStr) 3401 if err != nil { 3402 return nil, err 3403 } 3404 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 3405 if err != nil { 3406 return nil, status.Errorf(codes.InvalidArgument, "error parsing ObservedValues field path value from %s: %v", valueStr, err) 3407 } 3408 return fpv.(AlertInfoObservedValues_FieldPathValue), nil 3409 } 3410 3411 func MustParseAlertInfoObservedValues_FieldPathValue(pathStr, valueStr string) AlertInfoObservedValues_FieldPathValue { 3412 fpv, err := ParseAlertInfoObservedValues_FieldPathValue(pathStr, valueStr) 3413 if err != nil { 3414 panic(err) 3415 } 3416 return fpv 3417 } 3418 3419 type AlertInfoObservedValues_FieldTerminalPathValue struct { 3420 AlertInfoObservedValues_FieldTerminalPath 3421 value interface{} 3422 } 3423 3424 var _ AlertInfoObservedValues_FieldPathValue = (*AlertInfoObservedValues_FieldTerminalPathValue)(nil) 3425 3426 // GetRawValue returns raw value stored under selected path for 'ObservedValues' as interface{} 3427 func (fpv *AlertInfoObservedValues_FieldTerminalPathValue) GetRawValue() interface{} { 3428 return fpv.value 3429 } 3430 func (fpv *AlertInfoObservedValues_FieldTerminalPathValue) AsExampleValueValue() (float64, bool) { 3431 res, ok := fpv.value.(float64) 3432 return res, ok 3433 } 3434 func (fpv *AlertInfoObservedValues_FieldTerminalPathValue) AsPerMetricValue() (map[string]float64, bool) { 3435 res, ok := fpv.value.(map[string]float64) 3436 return res, ok 3437 } 3438 3439 // SetTo stores value for selected field for object ObservedValues 3440 func (fpv *AlertInfoObservedValues_FieldTerminalPathValue) SetTo(target **Alert_Info_ObservedValues) { 3441 if *target == nil { 3442 *target = new(Alert_Info_ObservedValues) 3443 } 3444 switch fpv.selector { 3445 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 3446 (*target).ExampleValue = fpv.value.(float64) 3447 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3448 (*target).PerMetric = fpv.value.(map[string]float64) 3449 default: 3450 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpv.selector)) 3451 } 3452 } 3453 3454 func (fpv *AlertInfoObservedValues_FieldTerminalPathValue) SetToRaw(target proto.Message) { 3455 typedObject := target.(*Alert_Info_ObservedValues) 3456 fpv.SetTo(&typedObject) 3457 } 3458 3459 // CompareWith compares value in the 'AlertInfoObservedValues_FieldTerminalPathValue' with the value under path in 'Alert_Info_ObservedValues'. 3460 func (fpv *AlertInfoObservedValues_FieldTerminalPathValue) CompareWith(source *Alert_Info_ObservedValues) (int, bool) { 3461 switch fpv.selector { 3462 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 3463 leftValue := fpv.value.(float64) 3464 rightValue := source.GetExampleValue() 3465 if (leftValue) == (rightValue) { 3466 return 0, true 3467 } else if (leftValue) < (rightValue) { 3468 return -1, true 3469 } else { 3470 return 1, true 3471 } 3472 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3473 return 0, false 3474 default: 3475 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpv.selector)) 3476 } 3477 } 3478 3479 func (fpv *AlertInfoObservedValues_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 3480 return fpv.CompareWith(source.(*Alert_Info_ObservedValues)) 3481 } 3482 3483 type AlertInfoObservedValues_FieldPathMapValue struct { 3484 AlertInfoObservedValues_FieldPathMap 3485 value interface{} 3486 } 3487 3488 var _ AlertInfoObservedValues_FieldPathValue = (*AlertInfoObservedValues_FieldPathMapValue)(nil) 3489 3490 // GetValue returns value stored under selected field in ObservedValues as interface{} 3491 func (fpmv *AlertInfoObservedValues_FieldPathMapValue) GetRawValue() interface{} { 3492 return fpmv.value 3493 } 3494 func (fpmv *AlertInfoObservedValues_FieldPathMapValue) AsPerMetricElementValue() (float64, bool) { 3495 res, ok := fpmv.value.(float64) 3496 return res, ok 3497 } 3498 3499 // SetTo stores value for selected field in ObservedValues 3500 func (fpmv *AlertInfoObservedValues_FieldPathMapValue) SetTo(target **Alert_Info_ObservedValues) { 3501 if *target == nil { 3502 *target = new(Alert_Info_ObservedValues) 3503 } 3504 switch fpmv.selector { 3505 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3506 if (*target).PerMetric == nil { 3507 (*target).PerMetric = make(map[string]float64) 3508 } 3509 (*target).PerMetric[fpmv.key] = fpmv.value.(float64) 3510 default: 3511 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpmv.selector)) 3512 } 3513 } 3514 3515 func (fpmv *AlertInfoObservedValues_FieldPathMapValue) SetToRaw(target proto.Message) { 3516 typedObject := target.(*Alert_Info_ObservedValues) 3517 fpmv.SetTo(&typedObject) 3518 } 3519 3520 // CompareWith compares value in the 'AlertInfoObservedValues_FieldPathMapValue' with the value under path in 'Alert_Info_ObservedValues'. 3521 func (fpmv *AlertInfoObservedValues_FieldPathMapValue) CompareWith(source *Alert_Info_ObservedValues) (int, bool) { 3522 switch fpmv.selector { 3523 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3524 leftValue := fpmv.value.(float64) 3525 rightValue := source.GetPerMetric()[fpmv.key] 3526 if (leftValue) == (rightValue) { 3527 return 0, true 3528 } else if (leftValue) < (rightValue) { 3529 return -1, true 3530 } else { 3531 return 1, true 3532 } 3533 default: 3534 panic(fmt.Sprintf("Invalid selector for Alert_Info_ObservedValues: %d", fpmv.selector)) 3535 } 3536 } 3537 3538 func (fpmv *AlertInfoObservedValues_FieldPathMapValue) CompareWithRaw(source proto.Message) (int, bool) { 3539 return fpmv.CompareWith(source.(*Alert_Info_ObservedValues)) 3540 } 3541 3542 // AlertInfoObservedValues_FieldPathArrayItemValue allows storing single item in Path-specific values for ObservedValues according to their type 3543 // Present only for array (repeated) types. 3544 type AlertInfoObservedValues_FieldPathArrayItemValue interface { 3545 gotenobject.FieldPathArrayItemValue 3546 AlertInfoObservedValues_FieldPath 3547 ContainsValue(*Alert_Info_ObservedValues) bool 3548 } 3549 3550 // ParseAlertInfoObservedValues_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 3551 func ParseAlertInfoObservedValues_FieldPathArrayItemValue(pathStr, valueStr string) (AlertInfoObservedValues_FieldPathArrayItemValue, error) { 3552 fp, err := ParseAlertInfoObservedValues_FieldPath(pathStr) 3553 if err != nil { 3554 return nil, err 3555 } 3556 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 3557 if err != nil { 3558 return nil, status.Errorf(codes.InvalidArgument, "error parsing ObservedValues field path array item value from %s: %v", valueStr, err) 3559 } 3560 return fpaiv.(AlertInfoObservedValues_FieldPathArrayItemValue), nil 3561 } 3562 3563 func MustParseAlertInfoObservedValues_FieldPathArrayItemValue(pathStr, valueStr string) AlertInfoObservedValues_FieldPathArrayItemValue { 3564 fpaiv, err := ParseAlertInfoObservedValues_FieldPathArrayItemValue(pathStr, valueStr) 3565 if err != nil { 3566 panic(err) 3567 } 3568 return fpaiv 3569 } 3570 3571 type AlertInfoObservedValues_FieldTerminalPathArrayItemValue struct { 3572 AlertInfoObservedValues_FieldTerminalPath 3573 value interface{} 3574 } 3575 3576 var _ AlertInfoObservedValues_FieldPathArrayItemValue = (*AlertInfoObservedValues_FieldTerminalPathArrayItemValue)(nil) 3577 3578 // GetRawValue returns stored element value for array in object Alert_Info_ObservedValues as interface{} 3579 func (fpaiv *AlertInfoObservedValues_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 3580 return fpaiv.value 3581 } 3582 3583 func (fpaiv *AlertInfoObservedValues_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_Info_ObservedValues) (interface{}, bool) { 3584 return nil, false 3585 } 3586 3587 func (fpaiv *AlertInfoObservedValues_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 3588 return fpaiv.GetSingle(source.(*Alert_Info_ObservedValues)) 3589 } 3590 3591 // Contains returns a boolean indicating if value that is being held is present in given 'ObservedValues' 3592 func (fpaiv *AlertInfoObservedValues_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_Info_ObservedValues) bool { 3593 slice := fpaiv.AlertInfoObservedValues_FieldTerminalPath.Get(source) 3594 for _, v := range slice { 3595 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 3596 if proto.Equal(asProtoMsg, v.(proto.Message)) { 3597 return true 3598 } 3599 } else if reflect.DeepEqual(v, fpaiv.value) { 3600 return true 3601 } 3602 } 3603 return false 3604 } 3605 3606 // AlertInfoObservedValues_FieldPathArrayOfValues allows storing slice of values for ObservedValues fields according to their type 3607 type AlertInfoObservedValues_FieldPathArrayOfValues interface { 3608 gotenobject.FieldPathArrayOfValues 3609 AlertInfoObservedValues_FieldPath 3610 } 3611 3612 func ParseAlertInfoObservedValues_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertInfoObservedValues_FieldPathArrayOfValues, error) { 3613 fp, err := ParseAlertInfoObservedValues_FieldPath(pathStr) 3614 if err != nil { 3615 return nil, err 3616 } 3617 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 3618 if err != nil { 3619 return nil, status.Errorf(codes.InvalidArgument, "error parsing ObservedValues field path array of values from %s: %v", valuesStr, err) 3620 } 3621 return fpaov.(AlertInfoObservedValues_FieldPathArrayOfValues), nil 3622 } 3623 3624 func MustParseAlertInfoObservedValues_FieldPathArrayOfValues(pathStr, valuesStr string) AlertInfoObservedValues_FieldPathArrayOfValues { 3625 fpaov, err := ParseAlertInfoObservedValues_FieldPathArrayOfValues(pathStr, valuesStr) 3626 if err != nil { 3627 panic(err) 3628 } 3629 return fpaov 3630 } 3631 3632 type AlertInfoObservedValues_FieldTerminalPathArrayOfValues struct { 3633 AlertInfoObservedValues_FieldTerminalPath 3634 values interface{} 3635 } 3636 3637 var _ AlertInfoObservedValues_FieldPathArrayOfValues = (*AlertInfoObservedValues_FieldTerminalPathArrayOfValues)(nil) 3638 3639 func (fpaov *AlertInfoObservedValues_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 3640 switch fpaov.selector { 3641 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 3642 for _, v := range fpaov.values.([]float64) { 3643 values = append(values, v) 3644 } 3645 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3646 for _, v := range fpaov.values.([]map[string]float64) { 3647 values = append(values, v) 3648 } 3649 } 3650 return 3651 } 3652 func (fpaov *AlertInfoObservedValues_FieldTerminalPathArrayOfValues) AsExampleValueArrayOfValues() ([]float64, bool) { 3653 res, ok := fpaov.values.([]float64) 3654 return res, ok 3655 } 3656 func (fpaov *AlertInfoObservedValues_FieldTerminalPathArrayOfValues) AsPerMetricArrayOfValues() ([]map[string]float64, bool) { 3657 res, ok := fpaov.values.([]map[string]float64) 3658 return res, ok 3659 } 3660 3661 type AlertInfoObservedValues_FieldPathMapArrayOfValues struct { 3662 AlertInfoObservedValues_FieldPathMap 3663 values interface{} 3664 } 3665 3666 var _ AlertInfoObservedValues_FieldPathArrayOfValues = (*AlertInfoObservedValues_FieldPathMapArrayOfValues)(nil) 3667 3668 func (fpmaov *AlertInfoObservedValues_FieldPathMapArrayOfValues) GetRawValues() (values []interface{}) { 3669 switch fpmaov.selector { 3670 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 3671 for _, v := range fpmaov.values.([]float64) { 3672 values = append(values, v) 3673 } 3674 } 3675 return 3676 } 3677 func (fpmaov *AlertInfoObservedValues_FieldPathMapArrayOfValues) AsPerMetricArrayOfElementValues() ([]float64, bool) { 3678 res, ok := fpmaov.values.([]float64) 3679 return res, ok 3680 } 3681 3682 // FieldPath provides implementation to handle 3683 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 3684 type AlertStateThreshold_FieldPath interface { 3685 gotenobject.FieldPath 3686 Selector() AlertStateThreshold_FieldPathSelector 3687 Get(source *Alert_State_Threshold) []interface{} 3688 GetSingle(source *Alert_State_Threshold) (interface{}, bool) 3689 ClearValue(item *Alert_State_Threshold) 3690 3691 // Those methods build corresponding AlertStateThreshold_FieldPathValue 3692 // (or array of values) and holds passed value. Panics if injected type is incorrect. 3693 WithIValue(value interface{}) AlertStateThreshold_FieldPathValue 3694 WithIArrayOfValues(values interface{}) AlertStateThreshold_FieldPathArrayOfValues 3695 WithIArrayItemValue(value interface{}) AlertStateThreshold_FieldPathArrayItemValue 3696 } 3697 3698 type AlertStateThreshold_FieldPathSelector int32 3699 3700 const ( 3701 AlertStateThreshold_FieldPathSelectorObservedValue AlertStateThreshold_FieldPathSelector = 0 3702 ) 3703 3704 func (s AlertStateThreshold_FieldPathSelector) String() string { 3705 switch s { 3706 case AlertStateThreshold_FieldPathSelectorObservedValue: 3707 return "observed_value" 3708 default: 3709 panic(fmt.Sprintf("Invalid selector for Alert_State_Threshold: %d", s)) 3710 } 3711 } 3712 3713 func BuildAlertStateThreshold_FieldPath(fp gotenobject.RawFieldPath) (AlertStateThreshold_FieldPath, error) { 3714 if len(fp) == 0 { 3715 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_State_Threshold") 3716 } 3717 if len(fp) == 1 { 3718 switch fp[0] { 3719 case "observed_value", "observedValue", "observed-value": 3720 return &AlertStateThreshold_FieldTerminalPath{selector: AlertStateThreshold_FieldPathSelectorObservedValue}, nil 3721 } 3722 } 3723 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_State_Threshold", fp) 3724 } 3725 3726 func ParseAlertStateThreshold_FieldPath(rawField string) (AlertStateThreshold_FieldPath, error) { 3727 fp, err := gotenobject.ParseRawFieldPath(rawField) 3728 if err != nil { 3729 return nil, err 3730 } 3731 return BuildAlertStateThreshold_FieldPath(fp) 3732 } 3733 3734 func MustParseAlertStateThreshold_FieldPath(rawField string) AlertStateThreshold_FieldPath { 3735 fp, err := ParseAlertStateThreshold_FieldPath(rawField) 3736 if err != nil { 3737 panic(err) 3738 } 3739 return fp 3740 } 3741 3742 type AlertStateThreshold_FieldTerminalPath struct { 3743 selector AlertStateThreshold_FieldPathSelector 3744 } 3745 3746 var _ AlertStateThreshold_FieldPath = (*AlertStateThreshold_FieldTerminalPath)(nil) 3747 3748 func (fp *AlertStateThreshold_FieldTerminalPath) Selector() AlertStateThreshold_FieldPathSelector { 3749 return fp.selector 3750 } 3751 3752 // String returns path representation in proto convention 3753 func (fp *AlertStateThreshold_FieldTerminalPath) String() string { 3754 return fp.selector.String() 3755 } 3756 3757 // JSONString returns path representation is JSON convention 3758 func (fp *AlertStateThreshold_FieldTerminalPath) JSONString() string { 3759 return strcase.ToLowerCamel(fp.String()) 3760 } 3761 3762 // Get returns all values pointed by specific field from source Alert_State_Threshold 3763 func (fp *AlertStateThreshold_FieldTerminalPath) Get(source *Alert_State_Threshold) (values []interface{}) { 3764 if source != nil { 3765 switch fp.selector { 3766 case AlertStateThreshold_FieldPathSelectorObservedValue: 3767 values = append(values, source.ObservedValue) 3768 default: 3769 panic(fmt.Sprintf("Invalid selector for Alert_State_Threshold: %d", fp.selector)) 3770 } 3771 } 3772 return 3773 } 3774 3775 func (fp *AlertStateThreshold_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 3776 return fp.Get(source.(*Alert_State_Threshold)) 3777 } 3778 3779 // GetSingle returns value pointed by specific field of from source Alert_State_Threshold 3780 func (fp *AlertStateThreshold_FieldTerminalPath) GetSingle(source *Alert_State_Threshold) (interface{}, bool) { 3781 switch fp.selector { 3782 case AlertStateThreshold_FieldPathSelectorObservedValue: 3783 return source.GetObservedValue(), source != nil 3784 default: 3785 panic(fmt.Sprintf("Invalid selector for Alert_State_Threshold: %d", fp.selector)) 3786 } 3787 } 3788 3789 func (fp *AlertStateThreshold_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 3790 return fp.GetSingle(source.(*Alert_State_Threshold)) 3791 } 3792 3793 // GetDefault returns a default value of the field type 3794 func (fp *AlertStateThreshold_FieldTerminalPath) GetDefault() interface{} { 3795 switch fp.selector { 3796 case AlertStateThreshold_FieldPathSelectorObservedValue: 3797 return float64(0) 3798 default: 3799 panic(fmt.Sprintf("Invalid selector for Alert_State_Threshold: %d", fp.selector)) 3800 } 3801 } 3802 3803 func (fp *AlertStateThreshold_FieldTerminalPath) ClearValue(item *Alert_State_Threshold) { 3804 if item != nil { 3805 switch fp.selector { 3806 case AlertStateThreshold_FieldPathSelectorObservedValue: 3807 item.ObservedValue = float64(0) 3808 default: 3809 panic(fmt.Sprintf("Invalid selector for Alert_State_Threshold: %d", fp.selector)) 3810 } 3811 } 3812 } 3813 3814 func (fp *AlertStateThreshold_FieldTerminalPath) ClearValueRaw(item proto.Message) { 3815 fp.ClearValue(item.(*Alert_State_Threshold)) 3816 } 3817 3818 // IsLeaf - whether field path is holds simple value 3819 func (fp *AlertStateThreshold_FieldTerminalPath) IsLeaf() bool { 3820 return fp.selector == AlertStateThreshold_FieldPathSelectorObservedValue 3821 } 3822 3823 func (fp *AlertStateThreshold_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 3824 return []gotenobject.FieldPath{fp} 3825 } 3826 3827 func (fp *AlertStateThreshold_FieldTerminalPath) WithIValue(value interface{}) AlertStateThreshold_FieldPathValue { 3828 switch fp.selector { 3829 case AlertStateThreshold_FieldPathSelectorObservedValue: 3830 return &AlertStateThreshold_FieldTerminalPathValue{AlertStateThreshold_FieldTerminalPath: *fp, value: value.(float64)} 3831 default: 3832 panic(fmt.Sprintf("Invalid selector for Alert_State_Threshold: %d", fp.selector)) 3833 } 3834 } 3835 3836 func (fp *AlertStateThreshold_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 3837 return fp.WithIValue(value) 3838 } 3839 3840 func (fp *AlertStateThreshold_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertStateThreshold_FieldPathArrayOfValues { 3841 fpaov := &AlertStateThreshold_FieldTerminalPathArrayOfValues{AlertStateThreshold_FieldTerminalPath: *fp} 3842 switch fp.selector { 3843 case AlertStateThreshold_FieldPathSelectorObservedValue: 3844 return &AlertStateThreshold_FieldTerminalPathArrayOfValues{AlertStateThreshold_FieldTerminalPath: *fp, values: values.([]float64)} 3845 default: 3846 panic(fmt.Sprintf("Invalid selector for Alert_State_Threshold: %d", fp.selector)) 3847 } 3848 return fpaov 3849 } 3850 3851 func (fp *AlertStateThreshold_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 3852 return fp.WithIArrayOfValues(values) 3853 } 3854 3855 func (fp *AlertStateThreshold_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertStateThreshold_FieldPathArrayItemValue { 3856 switch fp.selector { 3857 default: 3858 panic(fmt.Sprintf("Invalid selector for Alert_State_Threshold: %d", fp.selector)) 3859 } 3860 } 3861 3862 func (fp *AlertStateThreshold_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 3863 return fp.WithIArrayItemValue(value) 3864 } 3865 3866 // AlertStateThreshold_FieldPathValue allows storing values for Threshold fields according to their type 3867 type AlertStateThreshold_FieldPathValue interface { 3868 AlertStateThreshold_FieldPath 3869 gotenobject.FieldPathValue 3870 SetTo(target **Alert_State_Threshold) 3871 CompareWith(*Alert_State_Threshold) (cmp int, comparable bool) 3872 } 3873 3874 func ParseAlertStateThreshold_FieldPathValue(pathStr, valueStr string) (AlertStateThreshold_FieldPathValue, error) { 3875 fp, err := ParseAlertStateThreshold_FieldPath(pathStr) 3876 if err != nil { 3877 return nil, err 3878 } 3879 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 3880 if err != nil { 3881 return nil, status.Errorf(codes.InvalidArgument, "error parsing Threshold field path value from %s: %v", valueStr, err) 3882 } 3883 return fpv.(AlertStateThreshold_FieldPathValue), nil 3884 } 3885 3886 func MustParseAlertStateThreshold_FieldPathValue(pathStr, valueStr string) AlertStateThreshold_FieldPathValue { 3887 fpv, err := ParseAlertStateThreshold_FieldPathValue(pathStr, valueStr) 3888 if err != nil { 3889 panic(err) 3890 } 3891 return fpv 3892 } 3893 3894 type AlertStateThreshold_FieldTerminalPathValue struct { 3895 AlertStateThreshold_FieldTerminalPath 3896 value interface{} 3897 } 3898 3899 var _ AlertStateThreshold_FieldPathValue = (*AlertStateThreshold_FieldTerminalPathValue)(nil) 3900 3901 // GetRawValue returns raw value stored under selected path for 'Threshold' as interface{} 3902 func (fpv *AlertStateThreshold_FieldTerminalPathValue) GetRawValue() interface{} { 3903 return fpv.value 3904 } 3905 func (fpv *AlertStateThreshold_FieldTerminalPathValue) AsObservedValueValue() (float64, bool) { 3906 res, ok := fpv.value.(float64) 3907 return res, ok 3908 } 3909 3910 // SetTo stores value for selected field for object Threshold 3911 func (fpv *AlertStateThreshold_FieldTerminalPathValue) SetTo(target **Alert_State_Threshold) { 3912 if *target == nil { 3913 *target = new(Alert_State_Threshold) 3914 } 3915 switch fpv.selector { 3916 case AlertStateThreshold_FieldPathSelectorObservedValue: 3917 (*target).ObservedValue = fpv.value.(float64) 3918 default: 3919 panic(fmt.Sprintf("Invalid selector for Alert_State_Threshold: %d", fpv.selector)) 3920 } 3921 } 3922 3923 func (fpv *AlertStateThreshold_FieldTerminalPathValue) SetToRaw(target proto.Message) { 3924 typedObject := target.(*Alert_State_Threshold) 3925 fpv.SetTo(&typedObject) 3926 } 3927 3928 // CompareWith compares value in the 'AlertStateThreshold_FieldTerminalPathValue' with the value under path in 'Alert_State_Threshold'. 3929 func (fpv *AlertStateThreshold_FieldTerminalPathValue) CompareWith(source *Alert_State_Threshold) (int, bool) { 3930 switch fpv.selector { 3931 case AlertStateThreshold_FieldPathSelectorObservedValue: 3932 leftValue := fpv.value.(float64) 3933 rightValue := source.GetObservedValue() 3934 if (leftValue) == (rightValue) { 3935 return 0, true 3936 } else if (leftValue) < (rightValue) { 3937 return -1, true 3938 } else { 3939 return 1, true 3940 } 3941 default: 3942 panic(fmt.Sprintf("Invalid selector for Alert_State_Threshold: %d", fpv.selector)) 3943 } 3944 } 3945 3946 func (fpv *AlertStateThreshold_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 3947 return fpv.CompareWith(source.(*Alert_State_Threshold)) 3948 } 3949 3950 // AlertStateThreshold_FieldPathArrayItemValue allows storing single item in Path-specific values for Threshold according to their type 3951 // Present only for array (repeated) types. 3952 type AlertStateThreshold_FieldPathArrayItemValue interface { 3953 gotenobject.FieldPathArrayItemValue 3954 AlertStateThreshold_FieldPath 3955 ContainsValue(*Alert_State_Threshold) bool 3956 } 3957 3958 // ParseAlertStateThreshold_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 3959 func ParseAlertStateThreshold_FieldPathArrayItemValue(pathStr, valueStr string) (AlertStateThreshold_FieldPathArrayItemValue, error) { 3960 fp, err := ParseAlertStateThreshold_FieldPath(pathStr) 3961 if err != nil { 3962 return nil, err 3963 } 3964 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 3965 if err != nil { 3966 return nil, status.Errorf(codes.InvalidArgument, "error parsing Threshold field path array item value from %s: %v", valueStr, err) 3967 } 3968 return fpaiv.(AlertStateThreshold_FieldPathArrayItemValue), nil 3969 } 3970 3971 func MustParseAlertStateThreshold_FieldPathArrayItemValue(pathStr, valueStr string) AlertStateThreshold_FieldPathArrayItemValue { 3972 fpaiv, err := ParseAlertStateThreshold_FieldPathArrayItemValue(pathStr, valueStr) 3973 if err != nil { 3974 panic(err) 3975 } 3976 return fpaiv 3977 } 3978 3979 type AlertStateThreshold_FieldTerminalPathArrayItemValue struct { 3980 AlertStateThreshold_FieldTerminalPath 3981 value interface{} 3982 } 3983 3984 var _ AlertStateThreshold_FieldPathArrayItemValue = (*AlertStateThreshold_FieldTerminalPathArrayItemValue)(nil) 3985 3986 // GetRawValue returns stored element value for array in object Alert_State_Threshold as interface{} 3987 func (fpaiv *AlertStateThreshold_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 3988 return fpaiv.value 3989 } 3990 3991 func (fpaiv *AlertStateThreshold_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_State_Threshold) (interface{}, bool) { 3992 return nil, false 3993 } 3994 3995 func (fpaiv *AlertStateThreshold_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 3996 return fpaiv.GetSingle(source.(*Alert_State_Threshold)) 3997 } 3998 3999 // Contains returns a boolean indicating if value that is being held is present in given 'Threshold' 4000 func (fpaiv *AlertStateThreshold_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_State_Threshold) bool { 4001 slice := fpaiv.AlertStateThreshold_FieldTerminalPath.Get(source) 4002 for _, v := range slice { 4003 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 4004 if proto.Equal(asProtoMsg, v.(proto.Message)) { 4005 return true 4006 } 4007 } else if reflect.DeepEqual(v, fpaiv.value) { 4008 return true 4009 } 4010 } 4011 return false 4012 } 4013 4014 // AlertStateThreshold_FieldPathArrayOfValues allows storing slice of values for Threshold fields according to their type 4015 type AlertStateThreshold_FieldPathArrayOfValues interface { 4016 gotenobject.FieldPathArrayOfValues 4017 AlertStateThreshold_FieldPath 4018 } 4019 4020 func ParseAlertStateThreshold_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertStateThreshold_FieldPathArrayOfValues, error) { 4021 fp, err := ParseAlertStateThreshold_FieldPath(pathStr) 4022 if err != nil { 4023 return nil, err 4024 } 4025 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 4026 if err != nil { 4027 return nil, status.Errorf(codes.InvalidArgument, "error parsing Threshold field path array of values from %s: %v", valuesStr, err) 4028 } 4029 return fpaov.(AlertStateThreshold_FieldPathArrayOfValues), nil 4030 } 4031 4032 func MustParseAlertStateThreshold_FieldPathArrayOfValues(pathStr, valuesStr string) AlertStateThreshold_FieldPathArrayOfValues { 4033 fpaov, err := ParseAlertStateThreshold_FieldPathArrayOfValues(pathStr, valuesStr) 4034 if err != nil { 4035 panic(err) 4036 } 4037 return fpaov 4038 } 4039 4040 type AlertStateThreshold_FieldTerminalPathArrayOfValues struct { 4041 AlertStateThreshold_FieldTerminalPath 4042 values interface{} 4043 } 4044 4045 var _ AlertStateThreshold_FieldPathArrayOfValues = (*AlertStateThreshold_FieldTerminalPathArrayOfValues)(nil) 4046 4047 func (fpaov *AlertStateThreshold_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 4048 switch fpaov.selector { 4049 case AlertStateThreshold_FieldPathSelectorObservedValue: 4050 for _, v := range fpaov.values.([]float64) { 4051 values = append(values, v) 4052 } 4053 } 4054 return 4055 } 4056 func (fpaov *AlertStateThreshold_FieldTerminalPathArrayOfValues) AsObservedValueArrayOfValues() ([]float64, bool) { 4057 res, ok := fpaov.values.([]float64) 4058 return res, ok 4059 } 4060 4061 // FieldPath provides implementation to handle 4062 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 4063 type AlertStateCombineThreshold_FieldPath interface { 4064 gotenobject.FieldPath 4065 Selector() AlertStateCombineThreshold_FieldPathSelector 4066 Get(source *Alert_State_CombineThreshold) []interface{} 4067 GetSingle(source *Alert_State_CombineThreshold) (interface{}, bool) 4068 ClearValue(item *Alert_State_CombineThreshold) 4069 4070 // Those methods build corresponding AlertStateCombineThreshold_FieldPathValue 4071 // (or array of values) and holds passed value. Panics if injected type is incorrect. 4072 WithIValue(value interface{}) AlertStateCombineThreshold_FieldPathValue 4073 WithIArrayOfValues(values interface{}) AlertStateCombineThreshold_FieldPathArrayOfValues 4074 WithIArrayItemValue(value interface{}) AlertStateCombineThreshold_FieldPathArrayItemValue 4075 } 4076 4077 type AlertStateCombineThreshold_FieldPathSelector int32 4078 4079 func (s AlertStateCombineThreshold_FieldPathSelector) String() string { 4080 switch s { 4081 default: 4082 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold: %d", s)) 4083 } 4084 } 4085 4086 func BuildAlertStateCombineThreshold_FieldPath(fp gotenobject.RawFieldPath) (AlertStateCombineThreshold_FieldPath, error) { 4087 if len(fp) == 0 { 4088 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_State_CombineThreshold") 4089 } 4090 if len(fp) == 1 { 4091 switch fp[0] { 4092 } 4093 } 4094 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_State_CombineThreshold", fp) 4095 } 4096 4097 func ParseAlertStateCombineThreshold_FieldPath(rawField string) (AlertStateCombineThreshold_FieldPath, error) { 4098 fp, err := gotenobject.ParseRawFieldPath(rawField) 4099 if err != nil { 4100 return nil, err 4101 } 4102 return BuildAlertStateCombineThreshold_FieldPath(fp) 4103 } 4104 4105 func MustParseAlertStateCombineThreshold_FieldPath(rawField string) AlertStateCombineThreshold_FieldPath { 4106 fp, err := ParseAlertStateCombineThreshold_FieldPath(rawField) 4107 if err != nil { 4108 panic(err) 4109 } 4110 return fp 4111 } 4112 4113 type AlertStateCombineThreshold_FieldTerminalPath struct { 4114 selector AlertStateCombineThreshold_FieldPathSelector 4115 } 4116 4117 var _ AlertStateCombineThreshold_FieldPath = (*AlertStateCombineThreshold_FieldTerminalPath)(nil) 4118 4119 func (fp *AlertStateCombineThreshold_FieldTerminalPath) Selector() AlertStateCombineThreshold_FieldPathSelector { 4120 return fp.selector 4121 } 4122 4123 // String returns path representation in proto convention 4124 func (fp *AlertStateCombineThreshold_FieldTerminalPath) String() string { 4125 return fp.selector.String() 4126 } 4127 4128 // JSONString returns path representation is JSON convention 4129 func (fp *AlertStateCombineThreshold_FieldTerminalPath) JSONString() string { 4130 return strcase.ToLowerCamel(fp.String()) 4131 } 4132 4133 // Get returns all values pointed by specific field from source Alert_State_CombineThreshold 4134 func (fp *AlertStateCombineThreshold_FieldTerminalPath) Get(source *Alert_State_CombineThreshold) (values []interface{}) { 4135 if source != nil { 4136 switch fp.selector { 4137 default: 4138 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold: %d", fp.selector)) 4139 } 4140 } 4141 return 4142 } 4143 4144 func (fp *AlertStateCombineThreshold_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 4145 return fp.Get(source.(*Alert_State_CombineThreshold)) 4146 } 4147 4148 // GetSingle returns value pointed by specific field of from source Alert_State_CombineThreshold 4149 func (fp *AlertStateCombineThreshold_FieldTerminalPath) GetSingle(source *Alert_State_CombineThreshold) (interface{}, bool) { 4150 switch fp.selector { 4151 default: 4152 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold: %d", fp.selector)) 4153 } 4154 } 4155 4156 func (fp *AlertStateCombineThreshold_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 4157 return fp.GetSingle(source.(*Alert_State_CombineThreshold)) 4158 } 4159 4160 // GetDefault returns a default value of the field type 4161 func (fp *AlertStateCombineThreshold_FieldTerminalPath) GetDefault() interface{} { 4162 switch fp.selector { 4163 default: 4164 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold: %d", fp.selector)) 4165 } 4166 } 4167 4168 func (fp *AlertStateCombineThreshold_FieldTerminalPath) ClearValue(item *Alert_State_CombineThreshold) { 4169 if item != nil { 4170 switch fp.selector { 4171 default: 4172 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold: %d", fp.selector)) 4173 } 4174 } 4175 } 4176 4177 func (fp *AlertStateCombineThreshold_FieldTerminalPath) ClearValueRaw(item proto.Message) { 4178 fp.ClearValue(item.(*Alert_State_CombineThreshold)) 4179 } 4180 4181 // IsLeaf - whether field path is holds simple value 4182 func (fp *AlertStateCombineThreshold_FieldTerminalPath) IsLeaf() bool { 4183 return false 4184 } 4185 4186 func (fp *AlertStateCombineThreshold_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 4187 return []gotenobject.FieldPath{fp} 4188 } 4189 4190 func (fp *AlertStateCombineThreshold_FieldTerminalPath) WithIValue(value interface{}) AlertStateCombineThreshold_FieldPathValue { 4191 switch fp.selector { 4192 default: 4193 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold: %d", fp.selector)) 4194 } 4195 } 4196 4197 func (fp *AlertStateCombineThreshold_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 4198 return fp.WithIValue(value) 4199 } 4200 4201 func (fp *AlertStateCombineThreshold_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertStateCombineThreshold_FieldPathArrayOfValues { 4202 fpaov := &AlertStateCombineThreshold_FieldTerminalPathArrayOfValues{AlertStateCombineThreshold_FieldTerminalPath: *fp} 4203 switch fp.selector { 4204 default: 4205 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold: %d", fp.selector)) 4206 } 4207 return fpaov 4208 } 4209 4210 func (fp *AlertStateCombineThreshold_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 4211 return fp.WithIArrayOfValues(values) 4212 } 4213 4214 func (fp *AlertStateCombineThreshold_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertStateCombineThreshold_FieldPathArrayItemValue { 4215 switch fp.selector { 4216 default: 4217 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold: %d", fp.selector)) 4218 } 4219 } 4220 4221 func (fp *AlertStateCombineThreshold_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 4222 return fp.WithIArrayItemValue(value) 4223 } 4224 4225 // AlertStateCombineThreshold_FieldPathValue allows storing values for CombineThreshold fields according to their type 4226 type AlertStateCombineThreshold_FieldPathValue interface { 4227 AlertStateCombineThreshold_FieldPath 4228 gotenobject.FieldPathValue 4229 SetTo(target **Alert_State_CombineThreshold) 4230 CompareWith(*Alert_State_CombineThreshold) (cmp int, comparable bool) 4231 } 4232 4233 func ParseAlertStateCombineThreshold_FieldPathValue(pathStr, valueStr string) (AlertStateCombineThreshold_FieldPathValue, error) { 4234 fp, err := ParseAlertStateCombineThreshold_FieldPath(pathStr) 4235 if err != nil { 4236 return nil, err 4237 } 4238 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 4239 if err != nil { 4240 return nil, status.Errorf(codes.InvalidArgument, "error parsing CombineThreshold field path value from %s: %v", valueStr, err) 4241 } 4242 return fpv.(AlertStateCombineThreshold_FieldPathValue), nil 4243 } 4244 4245 func MustParseAlertStateCombineThreshold_FieldPathValue(pathStr, valueStr string) AlertStateCombineThreshold_FieldPathValue { 4246 fpv, err := ParseAlertStateCombineThreshold_FieldPathValue(pathStr, valueStr) 4247 if err != nil { 4248 panic(err) 4249 } 4250 return fpv 4251 } 4252 4253 type AlertStateCombineThreshold_FieldTerminalPathValue struct { 4254 AlertStateCombineThreshold_FieldTerminalPath 4255 value interface{} 4256 } 4257 4258 var _ AlertStateCombineThreshold_FieldPathValue = (*AlertStateCombineThreshold_FieldTerminalPathValue)(nil) 4259 4260 // GetRawValue returns raw value stored under selected path for 'CombineThreshold' as interface{} 4261 func (fpv *AlertStateCombineThreshold_FieldTerminalPathValue) GetRawValue() interface{} { 4262 return fpv.value 4263 } 4264 4265 // SetTo stores value for selected field for object CombineThreshold 4266 func (fpv *AlertStateCombineThreshold_FieldTerminalPathValue) SetTo(target **Alert_State_CombineThreshold) { 4267 if *target == nil { 4268 *target = new(Alert_State_CombineThreshold) 4269 } 4270 switch fpv.selector { 4271 default: 4272 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold: %d", fpv.selector)) 4273 } 4274 } 4275 4276 func (fpv *AlertStateCombineThreshold_FieldTerminalPathValue) SetToRaw(target proto.Message) { 4277 typedObject := target.(*Alert_State_CombineThreshold) 4278 fpv.SetTo(&typedObject) 4279 } 4280 4281 // CompareWith compares value in the 'AlertStateCombineThreshold_FieldTerminalPathValue' with the value under path in 'Alert_State_CombineThreshold'. 4282 func (fpv *AlertStateCombineThreshold_FieldTerminalPathValue) CompareWith(source *Alert_State_CombineThreshold) (int, bool) { 4283 switch fpv.selector { 4284 default: 4285 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold: %d", fpv.selector)) 4286 } 4287 } 4288 4289 func (fpv *AlertStateCombineThreshold_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 4290 return fpv.CompareWith(source.(*Alert_State_CombineThreshold)) 4291 } 4292 4293 // AlertStateCombineThreshold_FieldPathArrayItemValue allows storing single item in Path-specific values for CombineThreshold according to their type 4294 // Present only for array (repeated) types. 4295 type AlertStateCombineThreshold_FieldPathArrayItemValue interface { 4296 gotenobject.FieldPathArrayItemValue 4297 AlertStateCombineThreshold_FieldPath 4298 ContainsValue(*Alert_State_CombineThreshold) bool 4299 } 4300 4301 // ParseAlertStateCombineThreshold_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 4302 func ParseAlertStateCombineThreshold_FieldPathArrayItemValue(pathStr, valueStr string) (AlertStateCombineThreshold_FieldPathArrayItemValue, error) { 4303 fp, err := ParseAlertStateCombineThreshold_FieldPath(pathStr) 4304 if err != nil { 4305 return nil, err 4306 } 4307 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 4308 if err != nil { 4309 return nil, status.Errorf(codes.InvalidArgument, "error parsing CombineThreshold field path array item value from %s: %v", valueStr, err) 4310 } 4311 return fpaiv.(AlertStateCombineThreshold_FieldPathArrayItemValue), nil 4312 } 4313 4314 func MustParseAlertStateCombineThreshold_FieldPathArrayItemValue(pathStr, valueStr string) AlertStateCombineThreshold_FieldPathArrayItemValue { 4315 fpaiv, err := ParseAlertStateCombineThreshold_FieldPathArrayItemValue(pathStr, valueStr) 4316 if err != nil { 4317 panic(err) 4318 } 4319 return fpaiv 4320 } 4321 4322 type AlertStateCombineThreshold_FieldTerminalPathArrayItemValue struct { 4323 AlertStateCombineThreshold_FieldTerminalPath 4324 value interface{} 4325 } 4326 4327 var _ AlertStateCombineThreshold_FieldPathArrayItemValue = (*AlertStateCombineThreshold_FieldTerminalPathArrayItemValue)(nil) 4328 4329 // GetRawValue returns stored element value for array in object Alert_State_CombineThreshold as interface{} 4330 func (fpaiv *AlertStateCombineThreshold_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 4331 return fpaiv.value 4332 } 4333 4334 func (fpaiv *AlertStateCombineThreshold_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_State_CombineThreshold) (interface{}, bool) { 4335 return nil, false 4336 } 4337 4338 func (fpaiv *AlertStateCombineThreshold_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 4339 return fpaiv.GetSingle(source.(*Alert_State_CombineThreshold)) 4340 } 4341 4342 // Contains returns a boolean indicating if value that is being held is present in given 'CombineThreshold' 4343 func (fpaiv *AlertStateCombineThreshold_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_State_CombineThreshold) bool { 4344 slice := fpaiv.AlertStateCombineThreshold_FieldTerminalPath.Get(source) 4345 for _, v := range slice { 4346 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 4347 if proto.Equal(asProtoMsg, v.(proto.Message)) { 4348 return true 4349 } 4350 } else if reflect.DeepEqual(v, fpaiv.value) { 4351 return true 4352 } 4353 } 4354 return false 4355 } 4356 4357 // AlertStateCombineThreshold_FieldPathArrayOfValues allows storing slice of values for CombineThreshold fields according to their type 4358 type AlertStateCombineThreshold_FieldPathArrayOfValues interface { 4359 gotenobject.FieldPathArrayOfValues 4360 AlertStateCombineThreshold_FieldPath 4361 } 4362 4363 func ParseAlertStateCombineThreshold_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertStateCombineThreshold_FieldPathArrayOfValues, error) { 4364 fp, err := ParseAlertStateCombineThreshold_FieldPath(pathStr) 4365 if err != nil { 4366 return nil, err 4367 } 4368 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 4369 if err != nil { 4370 return nil, status.Errorf(codes.InvalidArgument, "error parsing CombineThreshold field path array of values from %s: %v", valuesStr, err) 4371 } 4372 return fpaov.(AlertStateCombineThreshold_FieldPathArrayOfValues), nil 4373 } 4374 4375 func MustParseAlertStateCombineThreshold_FieldPathArrayOfValues(pathStr, valuesStr string) AlertStateCombineThreshold_FieldPathArrayOfValues { 4376 fpaov, err := ParseAlertStateCombineThreshold_FieldPathArrayOfValues(pathStr, valuesStr) 4377 if err != nil { 4378 panic(err) 4379 } 4380 return fpaov 4381 } 4382 4383 type AlertStateCombineThreshold_FieldTerminalPathArrayOfValues struct { 4384 AlertStateCombineThreshold_FieldTerminalPath 4385 values interface{} 4386 } 4387 4388 var _ AlertStateCombineThreshold_FieldPathArrayOfValues = (*AlertStateCombineThreshold_FieldTerminalPathArrayOfValues)(nil) 4389 4390 func (fpaov *AlertStateCombineThreshold_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 4391 switch fpaov.selector { 4392 } 4393 return 4394 } 4395 4396 // FieldPath provides implementation to handle 4397 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 4398 type AlertStateCombineThresholdPerMetric_FieldPath interface { 4399 gotenobject.FieldPath 4400 Selector() AlertStateCombineThresholdPerMetric_FieldPathSelector 4401 Get(source *Alert_State_CombineThreshold_PerMetric) []interface{} 4402 GetSingle(source *Alert_State_CombineThreshold_PerMetric) (interface{}, bool) 4403 ClearValue(item *Alert_State_CombineThreshold_PerMetric) 4404 4405 // Those methods build corresponding AlertStateCombineThresholdPerMetric_FieldPathValue 4406 // (or array of values) and holds passed value. Panics if injected type is incorrect. 4407 WithIValue(value interface{}) AlertStateCombineThresholdPerMetric_FieldPathValue 4408 WithIArrayOfValues(values interface{}) AlertStateCombineThresholdPerMetric_FieldPathArrayOfValues 4409 WithIArrayItemValue(value interface{}) AlertStateCombineThresholdPerMetric_FieldPathArrayItemValue 4410 } 4411 4412 type AlertStateCombineThresholdPerMetric_FieldPathSelector int32 4413 4414 const ( 4415 AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues AlertStateCombineThresholdPerMetric_FieldPathSelector = 0 4416 ) 4417 4418 func (s AlertStateCombineThresholdPerMetric_FieldPathSelector) String() string { 4419 switch s { 4420 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4421 return "observed_values" 4422 default: 4423 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", s)) 4424 } 4425 } 4426 4427 func BuildAlertStateCombineThresholdPerMetric_FieldPath(fp gotenobject.RawFieldPath) (AlertStateCombineThresholdPerMetric_FieldPath, error) { 4428 if len(fp) == 0 { 4429 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_State_CombineThreshold_PerMetric") 4430 } 4431 if len(fp) == 1 { 4432 switch fp[0] { 4433 case "observed_values", "observedValues", "observed-values": 4434 return &AlertStateCombineThresholdPerMetric_FieldTerminalPath{selector: AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues}, nil 4435 } 4436 } else { 4437 switch fp[0] { 4438 case "observed_values", "observedValues", "observed-values": 4439 if len(fp) > 2 { 4440 return nil, status.Errorf(codes.InvalidArgument, "sub path for maps ('%s') are not supported (object Alert_State_CombineThreshold_PerMetric)", fp) 4441 } 4442 return &AlertStateCombineThresholdPerMetric_FieldPathMap{selector: AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues, key: fp[1]}, nil 4443 } 4444 } 4445 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_State_CombineThreshold_PerMetric", fp) 4446 } 4447 4448 func ParseAlertStateCombineThresholdPerMetric_FieldPath(rawField string) (AlertStateCombineThresholdPerMetric_FieldPath, error) { 4449 fp, err := gotenobject.ParseRawFieldPath(rawField) 4450 if err != nil { 4451 return nil, err 4452 } 4453 return BuildAlertStateCombineThresholdPerMetric_FieldPath(fp) 4454 } 4455 4456 func MustParseAlertStateCombineThresholdPerMetric_FieldPath(rawField string) AlertStateCombineThresholdPerMetric_FieldPath { 4457 fp, err := ParseAlertStateCombineThresholdPerMetric_FieldPath(rawField) 4458 if err != nil { 4459 panic(err) 4460 } 4461 return fp 4462 } 4463 4464 type AlertStateCombineThresholdPerMetric_FieldTerminalPath struct { 4465 selector AlertStateCombineThresholdPerMetric_FieldPathSelector 4466 } 4467 4468 var _ AlertStateCombineThresholdPerMetric_FieldPath = (*AlertStateCombineThresholdPerMetric_FieldTerminalPath)(nil) 4469 4470 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) Selector() AlertStateCombineThresholdPerMetric_FieldPathSelector { 4471 return fp.selector 4472 } 4473 4474 // String returns path representation in proto convention 4475 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) String() string { 4476 return fp.selector.String() 4477 } 4478 4479 // JSONString returns path representation is JSON convention 4480 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) JSONString() string { 4481 return strcase.ToLowerCamel(fp.String()) 4482 } 4483 4484 // Get returns all values pointed by specific field from source Alert_State_CombineThreshold_PerMetric 4485 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) Get(source *Alert_State_CombineThreshold_PerMetric) (values []interface{}) { 4486 if source != nil { 4487 switch fp.selector { 4488 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4489 values = append(values, source.ObservedValues) 4490 default: 4491 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fp.selector)) 4492 } 4493 } 4494 return 4495 } 4496 4497 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 4498 return fp.Get(source.(*Alert_State_CombineThreshold_PerMetric)) 4499 } 4500 4501 // GetSingle returns value pointed by specific field of from source Alert_State_CombineThreshold_PerMetric 4502 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) GetSingle(source *Alert_State_CombineThreshold_PerMetric) (interface{}, bool) { 4503 switch fp.selector { 4504 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4505 res := source.GetObservedValues() 4506 return res, res != nil 4507 default: 4508 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fp.selector)) 4509 } 4510 } 4511 4512 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 4513 return fp.GetSingle(source.(*Alert_State_CombineThreshold_PerMetric)) 4514 } 4515 4516 // GetDefault returns a default value of the field type 4517 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) GetDefault() interface{} { 4518 switch fp.selector { 4519 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4520 return (map[string]float64)(nil) 4521 default: 4522 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fp.selector)) 4523 } 4524 } 4525 4526 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) ClearValue(item *Alert_State_CombineThreshold_PerMetric) { 4527 if item != nil { 4528 switch fp.selector { 4529 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4530 item.ObservedValues = nil 4531 default: 4532 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fp.selector)) 4533 } 4534 } 4535 } 4536 4537 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) ClearValueRaw(item proto.Message) { 4538 fp.ClearValue(item.(*Alert_State_CombineThreshold_PerMetric)) 4539 } 4540 4541 // IsLeaf - whether field path is holds simple value 4542 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) IsLeaf() bool { 4543 return fp.selector == AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues 4544 } 4545 4546 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 4547 return []gotenobject.FieldPath{fp} 4548 } 4549 4550 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) WithIValue(value interface{}) AlertStateCombineThresholdPerMetric_FieldPathValue { 4551 switch fp.selector { 4552 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4553 return &AlertStateCombineThresholdPerMetric_FieldTerminalPathValue{AlertStateCombineThresholdPerMetric_FieldTerminalPath: *fp, value: value.(map[string]float64)} 4554 default: 4555 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fp.selector)) 4556 } 4557 } 4558 4559 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 4560 return fp.WithIValue(value) 4561 } 4562 4563 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertStateCombineThresholdPerMetric_FieldPathArrayOfValues { 4564 fpaov := &AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayOfValues{AlertStateCombineThresholdPerMetric_FieldTerminalPath: *fp} 4565 switch fp.selector { 4566 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4567 return &AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayOfValues{AlertStateCombineThresholdPerMetric_FieldTerminalPath: *fp, values: values.([]map[string]float64)} 4568 default: 4569 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fp.selector)) 4570 } 4571 return fpaov 4572 } 4573 4574 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 4575 return fp.WithIArrayOfValues(values) 4576 } 4577 4578 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertStateCombineThresholdPerMetric_FieldPathArrayItemValue { 4579 switch fp.selector { 4580 default: 4581 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fp.selector)) 4582 } 4583 } 4584 4585 func (fp *AlertStateCombineThresholdPerMetric_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 4586 return fp.WithIArrayItemValue(value) 4587 } 4588 4589 // FieldPath for map type with additional Key information 4590 type AlertStateCombineThresholdPerMetric_FieldPathMap struct { 4591 key string 4592 selector AlertStateCombineThresholdPerMetric_FieldPathSelector 4593 } 4594 4595 var _ AlertStateCombineThresholdPerMetric_FieldPath = (*AlertStateCombineThresholdPerMetric_FieldPathMap)(nil) 4596 4597 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) Selector() AlertStateCombineThresholdPerMetric_FieldPathSelector { 4598 return fpm.selector 4599 } 4600 4601 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) Key() string { 4602 return fpm.key 4603 } 4604 4605 // String returns path representation in proto convention 4606 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) String() string { 4607 return fpm.selector.String() + "." + fpm.key 4608 } 4609 4610 // JSONString returns path representation is JSON convention. Note that map keys are not transformed 4611 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) JSONString() string { 4612 return strcase.ToLowerCamel(fpm.selector.String()) + "." + fpm.key 4613 } 4614 4615 // Get returns all values pointed by selected field map key from source Alert_State_CombineThreshold_PerMetric 4616 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) Get(source *Alert_State_CombineThreshold_PerMetric) (values []interface{}) { 4617 switch fpm.selector { 4618 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4619 if value, ok := source.GetObservedValues()[fpm.key]; ok { 4620 values = append(values, value) 4621 } 4622 default: 4623 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpm.selector)) 4624 } 4625 return 4626 } 4627 4628 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) GetRaw(source proto.Message) []interface{} { 4629 return fpm.Get(source.(*Alert_State_CombineThreshold_PerMetric)) 4630 } 4631 4632 // GetSingle returns value by selected field map key from source Alert_State_CombineThreshold_PerMetric 4633 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) GetSingle(source *Alert_State_CombineThreshold_PerMetric) (interface{}, bool) { 4634 switch fpm.selector { 4635 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4636 res, ok := source.GetObservedValues()[fpm.key] 4637 return res, ok 4638 default: 4639 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpm.selector)) 4640 } 4641 } 4642 4643 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) GetSingleRaw(source proto.Message) (interface{}, bool) { 4644 return fpm.GetSingle(source.(*Alert_State_CombineThreshold_PerMetric)) 4645 } 4646 4647 // GetDefault returns a default value of the field type 4648 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) GetDefault() interface{} { 4649 switch fpm.selector { 4650 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4651 var v float64 4652 return v 4653 default: 4654 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpm.selector)) 4655 } 4656 } 4657 4658 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) ClearValue(item *Alert_State_CombineThreshold_PerMetric) { 4659 if item != nil { 4660 switch fpm.selector { 4661 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4662 delete(item.ObservedValues, fpm.key) 4663 default: 4664 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpm.selector)) 4665 } 4666 } 4667 } 4668 4669 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) ClearValueRaw(item proto.Message) { 4670 fpm.ClearValue(item.(*Alert_State_CombineThreshold_PerMetric)) 4671 } 4672 4673 // IsLeaf - whether field path is holds simple value 4674 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) IsLeaf() bool { 4675 switch fpm.selector { 4676 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4677 return true 4678 default: 4679 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpm.selector)) 4680 } 4681 } 4682 4683 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 4684 return []gotenobject.FieldPath{fpm} 4685 } 4686 4687 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) WithIValue(value interface{}) AlertStateCombineThresholdPerMetric_FieldPathValue { 4688 switch fpm.selector { 4689 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4690 return &AlertStateCombineThresholdPerMetric_FieldPathMapValue{AlertStateCombineThresholdPerMetric_FieldPathMap: *fpm, value: value.(float64)} 4691 default: 4692 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpm.selector)) 4693 } 4694 } 4695 4696 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 4697 return fpm.WithIValue(value) 4698 } 4699 4700 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) WithIArrayOfValues(values interface{}) AlertStateCombineThresholdPerMetric_FieldPathArrayOfValues { 4701 switch fpm.selector { 4702 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4703 return &AlertStateCombineThresholdPerMetric_FieldPathMapArrayOfValues{AlertStateCombineThresholdPerMetric_FieldPathMap: *fpm, values: values.([]float64)} 4704 default: 4705 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpm.selector)) 4706 } 4707 } 4708 4709 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 4710 return fpm.WithIArrayOfValues(values) 4711 } 4712 4713 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) WithIArrayItemValue(value interface{}) AlertStateCombineThresholdPerMetric_FieldPathArrayItemValue { 4714 panic("Cannot create array item value from map fieldpath") 4715 } 4716 4717 func (fpm *AlertStateCombineThresholdPerMetric_FieldPathMap) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 4718 return fpm.WithIArrayItemValue(value) 4719 } 4720 4721 // AlertStateCombineThresholdPerMetric_FieldPathValue allows storing values for PerMetric fields according to their type 4722 type AlertStateCombineThresholdPerMetric_FieldPathValue interface { 4723 AlertStateCombineThresholdPerMetric_FieldPath 4724 gotenobject.FieldPathValue 4725 SetTo(target **Alert_State_CombineThreshold_PerMetric) 4726 CompareWith(*Alert_State_CombineThreshold_PerMetric) (cmp int, comparable bool) 4727 } 4728 4729 func ParseAlertStateCombineThresholdPerMetric_FieldPathValue(pathStr, valueStr string) (AlertStateCombineThresholdPerMetric_FieldPathValue, error) { 4730 fp, err := ParseAlertStateCombineThresholdPerMetric_FieldPath(pathStr) 4731 if err != nil { 4732 return nil, err 4733 } 4734 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 4735 if err != nil { 4736 return nil, status.Errorf(codes.InvalidArgument, "error parsing PerMetric field path value from %s: %v", valueStr, err) 4737 } 4738 return fpv.(AlertStateCombineThresholdPerMetric_FieldPathValue), nil 4739 } 4740 4741 func MustParseAlertStateCombineThresholdPerMetric_FieldPathValue(pathStr, valueStr string) AlertStateCombineThresholdPerMetric_FieldPathValue { 4742 fpv, err := ParseAlertStateCombineThresholdPerMetric_FieldPathValue(pathStr, valueStr) 4743 if err != nil { 4744 panic(err) 4745 } 4746 return fpv 4747 } 4748 4749 type AlertStateCombineThresholdPerMetric_FieldTerminalPathValue struct { 4750 AlertStateCombineThresholdPerMetric_FieldTerminalPath 4751 value interface{} 4752 } 4753 4754 var _ AlertStateCombineThresholdPerMetric_FieldPathValue = (*AlertStateCombineThresholdPerMetric_FieldTerminalPathValue)(nil) 4755 4756 // GetRawValue returns raw value stored under selected path for 'PerMetric' as interface{} 4757 func (fpv *AlertStateCombineThresholdPerMetric_FieldTerminalPathValue) GetRawValue() interface{} { 4758 return fpv.value 4759 } 4760 func (fpv *AlertStateCombineThresholdPerMetric_FieldTerminalPathValue) AsObservedValuesValue() (map[string]float64, bool) { 4761 res, ok := fpv.value.(map[string]float64) 4762 return res, ok 4763 } 4764 4765 // SetTo stores value for selected field for object PerMetric 4766 func (fpv *AlertStateCombineThresholdPerMetric_FieldTerminalPathValue) SetTo(target **Alert_State_CombineThreshold_PerMetric) { 4767 if *target == nil { 4768 *target = new(Alert_State_CombineThreshold_PerMetric) 4769 } 4770 switch fpv.selector { 4771 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4772 (*target).ObservedValues = fpv.value.(map[string]float64) 4773 default: 4774 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpv.selector)) 4775 } 4776 } 4777 4778 func (fpv *AlertStateCombineThresholdPerMetric_FieldTerminalPathValue) SetToRaw(target proto.Message) { 4779 typedObject := target.(*Alert_State_CombineThreshold_PerMetric) 4780 fpv.SetTo(&typedObject) 4781 } 4782 4783 // CompareWith compares value in the 'AlertStateCombineThresholdPerMetric_FieldTerminalPathValue' with the value under path in 'Alert_State_CombineThreshold_PerMetric'. 4784 func (fpv *AlertStateCombineThresholdPerMetric_FieldTerminalPathValue) CompareWith(source *Alert_State_CombineThreshold_PerMetric) (int, bool) { 4785 switch fpv.selector { 4786 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4787 return 0, false 4788 default: 4789 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpv.selector)) 4790 } 4791 } 4792 4793 func (fpv *AlertStateCombineThresholdPerMetric_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 4794 return fpv.CompareWith(source.(*Alert_State_CombineThreshold_PerMetric)) 4795 } 4796 4797 type AlertStateCombineThresholdPerMetric_FieldPathMapValue struct { 4798 AlertStateCombineThresholdPerMetric_FieldPathMap 4799 value interface{} 4800 } 4801 4802 var _ AlertStateCombineThresholdPerMetric_FieldPathValue = (*AlertStateCombineThresholdPerMetric_FieldPathMapValue)(nil) 4803 4804 // GetValue returns value stored under selected field in PerMetric as interface{} 4805 func (fpmv *AlertStateCombineThresholdPerMetric_FieldPathMapValue) GetRawValue() interface{} { 4806 return fpmv.value 4807 } 4808 func (fpmv *AlertStateCombineThresholdPerMetric_FieldPathMapValue) AsObservedValuesElementValue() (float64, bool) { 4809 res, ok := fpmv.value.(float64) 4810 return res, ok 4811 } 4812 4813 // SetTo stores value for selected field in PerMetric 4814 func (fpmv *AlertStateCombineThresholdPerMetric_FieldPathMapValue) SetTo(target **Alert_State_CombineThreshold_PerMetric) { 4815 if *target == nil { 4816 *target = new(Alert_State_CombineThreshold_PerMetric) 4817 } 4818 switch fpmv.selector { 4819 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4820 if (*target).ObservedValues == nil { 4821 (*target).ObservedValues = make(map[string]float64) 4822 } 4823 (*target).ObservedValues[fpmv.key] = fpmv.value.(float64) 4824 default: 4825 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpmv.selector)) 4826 } 4827 } 4828 4829 func (fpmv *AlertStateCombineThresholdPerMetric_FieldPathMapValue) SetToRaw(target proto.Message) { 4830 typedObject := target.(*Alert_State_CombineThreshold_PerMetric) 4831 fpmv.SetTo(&typedObject) 4832 } 4833 4834 // CompareWith compares value in the 'AlertStateCombineThresholdPerMetric_FieldPathMapValue' with the value under path in 'Alert_State_CombineThreshold_PerMetric'. 4835 func (fpmv *AlertStateCombineThresholdPerMetric_FieldPathMapValue) CompareWith(source *Alert_State_CombineThreshold_PerMetric) (int, bool) { 4836 switch fpmv.selector { 4837 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4838 leftValue := fpmv.value.(float64) 4839 rightValue := source.GetObservedValues()[fpmv.key] 4840 if (leftValue) == (rightValue) { 4841 return 0, true 4842 } else if (leftValue) < (rightValue) { 4843 return -1, true 4844 } else { 4845 return 1, true 4846 } 4847 default: 4848 panic(fmt.Sprintf("Invalid selector for Alert_State_CombineThreshold_PerMetric: %d", fpmv.selector)) 4849 } 4850 } 4851 4852 func (fpmv *AlertStateCombineThresholdPerMetric_FieldPathMapValue) CompareWithRaw(source proto.Message) (int, bool) { 4853 return fpmv.CompareWith(source.(*Alert_State_CombineThreshold_PerMetric)) 4854 } 4855 4856 // AlertStateCombineThresholdPerMetric_FieldPathArrayItemValue allows storing single item in Path-specific values for PerMetric according to their type 4857 // Present only for array (repeated) types. 4858 type AlertStateCombineThresholdPerMetric_FieldPathArrayItemValue interface { 4859 gotenobject.FieldPathArrayItemValue 4860 AlertStateCombineThresholdPerMetric_FieldPath 4861 ContainsValue(*Alert_State_CombineThreshold_PerMetric) bool 4862 } 4863 4864 // ParseAlertStateCombineThresholdPerMetric_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 4865 func ParseAlertStateCombineThresholdPerMetric_FieldPathArrayItemValue(pathStr, valueStr string) (AlertStateCombineThresholdPerMetric_FieldPathArrayItemValue, error) { 4866 fp, err := ParseAlertStateCombineThresholdPerMetric_FieldPath(pathStr) 4867 if err != nil { 4868 return nil, err 4869 } 4870 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 4871 if err != nil { 4872 return nil, status.Errorf(codes.InvalidArgument, "error parsing PerMetric field path array item value from %s: %v", valueStr, err) 4873 } 4874 return fpaiv.(AlertStateCombineThresholdPerMetric_FieldPathArrayItemValue), nil 4875 } 4876 4877 func MustParseAlertStateCombineThresholdPerMetric_FieldPathArrayItemValue(pathStr, valueStr string) AlertStateCombineThresholdPerMetric_FieldPathArrayItemValue { 4878 fpaiv, err := ParseAlertStateCombineThresholdPerMetric_FieldPathArrayItemValue(pathStr, valueStr) 4879 if err != nil { 4880 panic(err) 4881 } 4882 return fpaiv 4883 } 4884 4885 type AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayItemValue struct { 4886 AlertStateCombineThresholdPerMetric_FieldTerminalPath 4887 value interface{} 4888 } 4889 4890 var _ AlertStateCombineThresholdPerMetric_FieldPathArrayItemValue = (*AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayItemValue)(nil) 4891 4892 // GetRawValue returns stored element value for array in object Alert_State_CombineThreshold_PerMetric as interface{} 4893 func (fpaiv *AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 4894 return fpaiv.value 4895 } 4896 4897 func (fpaiv *AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_State_CombineThreshold_PerMetric) (interface{}, bool) { 4898 return nil, false 4899 } 4900 4901 func (fpaiv *AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 4902 return fpaiv.GetSingle(source.(*Alert_State_CombineThreshold_PerMetric)) 4903 } 4904 4905 // Contains returns a boolean indicating if value that is being held is present in given 'PerMetric' 4906 func (fpaiv *AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_State_CombineThreshold_PerMetric) bool { 4907 slice := fpaiv.AlertStateCombineThresholdPerMetric_FieldTerminalPath.Get(source) 4908 for _, v := range slice { 4909 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 4910 if proto.Equal(asProtoMsg, v.(proto.Message)) { 4911 return true 4912 } 4913 } else if reflect.DeepEqual(v, fpaiv.value) { 4914 return true 4915 } 4916 } 4917 return false 4918 } 4919 4920 // AlertStateCombineThresholdPerMetric_FieldPathArrayOfValues allows storing slice of values for PerMetric fields according to their type 4921 type AlertStateCombineThresholdPerMetric_FieldPathArrayOfValues interface { 4922 gotenobject.FieldPathArrayOfValues 4923 AlertStateCombineThresholdPerMetric_FieldPath 4924 } 4925 4926 func ParseAlertStateCombineThresholdPerMetric_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertStateCombineThresholdPerMetric_FieldPathArrayOfValues, error) { 4927 fp, err := ParseAlertStateCombineThresholdPerMetric_FieldPath(pathStr) 4928 if err != nil { 4929 return nil, err 4930 } 4931 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 4932 if err != nil { 4933 return nil, status.Errorf(codes.InvalidArgument, "error parsing PerMetric field path array of values from %s: %v", valuesStr, err) 4934 } 4935 return fpaov.(AlertStateCombineThresholdPerMetric_FieldPathArrayOfValues), nil 4936 } 4937 4938 func MustParseAlertStateCombineThresholdPerMetric_FieldPathArrayOfValues(pathStr, valuesStr string) AlertStateCombineThresholdPerMetric_FieldPathArrayOfValues { 4939 fpaov, err := ParseAlertStateCombineThresholdPerMetric_FieldPathArrayOfValues(pathStr, valuesStr) 4940 if err != nil { 4941 panic(err) 4942 } 4943 return fpaov 4944 } 4945 4946 type AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayOfValues struct { 4947 AlertStateCombineThresholdPerMetric_FieldTerminalPath 4948 values interface{} 4949 } 4950 4951 var _ AlertStateCombineThresholdPerMetric_FieldPathArrayOfValues = (*AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayOfValues)(nil) 4952 4953 func (fpaov *AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 4954 switch fpaov.selector { 4955 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4956 for _, v := range fpaov.values.([]map[string]float64) { 4957 values = append(values, v) 4958 } 4959 } 4960 return 4961 } 4962 func (fpaov *AlertStateCombineThresholdPerMetric_FieldTerminalPathArrayOfValues) AsObservedValuesArrayOfValues() ([]map[string]float64, bool) { 4963 res, ok := fpaov.values.([]map[string]float64) 4964 return res, ok 4965 } 4966 4967 type AlertStateCombineThresholdPerMetric_FieldPathMapArrayOfValues struct { 4968 AlertStateCombineThresholdPerMetric_FieldPathMap 4969 values interface{} 4970 } 4971 4972 var _ AlertStateCombineThresholdPerMetric_FieldPathArrayOfValues = (*AlertStateCombineThresholdPerMetric_FieldPathMapArrayOfValues)(nil) 4973 4974 func (fpmaov *AlertStateCombineThresholdPerMetric_FieldPathMapArrayOfValues) GetRawValues() (values []interface{}) { 4975 switch fpmaov.selector { 4976 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 4977 for _, v := range fpmaov.values.([]float64) { 4978 values = append(values, v) 4979 } 4980 } 4981 return 4982 } 4983 func (fpmaov *AlertStateCombineThresholdPerMetric_FieldPathMapArrayOfValues) AsObservedValuesArrayOfElementValues() ([]float64, bool) { 4984 res, ok := fpmaov.values.([]float64) 4985 return res, ok 4986 }