github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/alert/alert.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/alerting/proto/v1/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 rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common" 27 log_condition "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/log_condition" 28 notification_channel "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/notification_channel" 29 ts_condition "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/ts_condition" 30 meta "github.com/cloudwan/goten-sdk/types/meta" 31 durationpb "google.golang.org/protobuf/types/known/durationpb" 32 timestamppb "google.golang.org/protobuf/types/known/timestamppb" 33 ) 34 35 // ensure the imports are used 36 var ( 37 _ = new(json.Marshaler) 38 _ = new(fmt.Stringer) 39 _ = reflect.DeepEqual 40 _ = strings.Builder{} 41 _ = time.Second 42 43 _ = strcase.ToLowerCamel 44 _ = codes.NotFound 45 _ = status.Status{} 46 _ = protojson.UnmarshalOptions{} 47 _ = new(proto.Message) 48 _ = protoregistry.GlobalTypes 49 50 _ = new(gotenobject.FieldPath) 51 ) 52 53 // make sure we're using proto imports 54 var ( 55 _ = &log_condition.LogCondition{} 56 _ = ¬ification_channel.NotificationChannel{} 57 _ = &rcommon.LogCndSpec{} 58 _ = &ts_condition.TsCondition{} 59 _ = &durationpb.Duration{} 60 _ = ×tamppb.Timestamp{} 61 _ = &meta.Meta{} 62 ) 63 64 // FieldPath provides implementation to handle 65 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 66 type Alert_FieldPath interface { 67 gotenobject.FieldPath 68 Selector() Alert_FieldPathSelector 69 Get(source *Alert) []interface{} 70 GetSingle(source *Alert) (interface{}, bool) 71 ClearValue(item *Alert) 72 73 // Those methods build corresponding Alert_FieldPathValue 74 // (or array of values) and holds passed value. Panics if injected type is incorrect. 75 WithIValue(value interface{}) Alert_FieldPathValue 76 WithIArrayOfValues(values interface{}) Alert_FieldPathArrayOfValues 77 WithIArrayItemValue(value interface{}) Alert_FieldPathArrayItemValue 78 } 79 80 type Alert_FieldPathSelector int32 81 82 const ( 83 Alert_FieldPathSelectorName Alert_FieldPathSelector = 0 84 Alert_FieldPathSelectorMetadata Alert_FieldPathSelector = 1 85 Alert_FieldPathSelectorDisplayName Alert_FieldPathSelector = 2 86 Alert_FieldPathSelectorAlertingResource Alert_FieldPathSelector = 3 87 Alert_FieldPathSelectorTsInfo Alert_FieldPathSelector = 4 88 Alert_FieldPathSelectorLogInfo Alert_FieldPathSelector = 5 89 Alert_FieldPathSelectorState Alert_FieldPathSelector = 6 90 Alert_FieldPathSelectorInternal Alert_FieldPathSelector = 7 91 ) 92 93 func (s Alert_FieldPathSelector) String() string { 94 switch s { 95 case Alert_FieldPathSelectorName: 96 return "name" 97 case Alert_FieldPathSelectorMetadata: 98 return "metadata" 99 case Alert_FieldPathSelectorDisplayName: 100 return "display_name" 101 case Alert_FieldPathSelectorAlertingResource: 102 return "alerting_resource" 103 case Alert_FieldPathSelectorTsInfo: 104 return "ts_info" 105 case Alert_FieldPathSelectorLogInfo: 106 return "log_info" 107 case Alert_FieldPathSelectorState: 108 return "state" 109 case Alert_FieldPathSelectorInternal: 110 return "internal" 111 default: 112 panic(fmt.Sprintf("Invalid selector for Alert: %d", s)) 113 } 114 } 115 116 func BuildAlert_FieldPath(fp gotenobject.RawFieldPath) (Alert_FieldPath, error) { 117 if len(fp) == 0 { 118 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert") 119 } 120 if len(fp) == 1 { 121 switch fp[0] { 122 case "name": 123 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorName}, nil 124 case "metadata": 125 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorMetadata}, nil 126 case "display_name", "displayName", "display-name": 127 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorDisplayName}, nil 128 case "alerting_resource", "alertingResource", "alerting-resource": 129 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorAlertingResource}, nil 130 case "ts_info", "tsInfo", "ts-info": 131 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorTsInfo}, nil 132 case "log_info", "logInfo", "log-info": 133 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorLogInfo}, nil 134 case "state": 135 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorState}, nil 136 case "internal": 137 return &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorInternal}, nil 138 } 139 } else { 140 switch fp[0] { 141 case "metadata": 142 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 143 return nil, err 144 } else { 145 return &Alert_FieldSubPath{selector: Alert_FieldPathSelectorMetadata, subPath: subpath}, nil 146 } 147 case "alerting_resource", "alertingResource", "alerting-resource": 148 if subpath, err := meta.BuildOwnerReference_FieldPath(fp[1:]); err != nil { 149 return nil, err 150 } else { 151 return &Alert_FieldSubPath{selector: Alert_FieldPathSelectorAlertingResource, subPath: subpath}, nil 152 } 153 case "ts_info", "tsInfo", "ts-info": 154 if subpath, err := BuildAlertTsInfo_FieldPath(fp[1:]); err != nil { 155 return nil, err 156 } else { 157 return &Alert_FieldSubPath{selector: Alert_FieldPathSelectorTsInfo, subPath: subpath}, nil 158 } 159 case "log_info", "logInfo", "log-info": 160 if subpath, err := BuildAlertLogInfo_FieldPath(fp[1:]); err != nil { 161 return nil, err 162 } else { 163 return &Alert_FieldSubPath{selector: Alert_FieldPathSelectorLogInfo, subPath: subpath}, nil 164 } 165 case "state": 166 if subpath, err := BuildAlertState_FieldPath(fp[1:]); err != nil { 167 return nil, err 168 } else { 169 return &Alert_FieldSubPath{selector: Alert_FieldPathSelectorState, subPath: subpath}, nil 170 } 171 case "internal": 172 if subpath, err := BuildAlertInternal_FieldPath(fp[1:]); err != nil { 173 return nil, err 174 } else { 175 return &Alert_FieldSubPath{selector: Alert_FieldPathSelectorInternal, subPath: subpath}, nil 176 } 177 } 178 } 179 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert", fp) 180 } 181 182 func ParseAlert_FieldPath(rawField string) (Alert_FieldPath, error) { 183 fp, err := gotenobject.ParseRawFieldPath(rawField) 184 if err != nil { 185 return nil, err 186 } 187 return BuildAlert_FieldPath(fp) 188 } 189 190 func MustParseAlert_FieldPath(rawField string) Alert_FieldPath { 191 fp, err := ParseAlert_FieldPath(rawField) 192 if err != nil { 193 panic(err) 194 } 195 return fp 196 } 197 198 type Alert_FieldTerminalPath struct { 199 selector Alert_FieldPathSelector 200 } 201 202 var _ Alert_FieldPath = (*Alert_FieldTerminalPath)(nil) 203 204 func (fp *Alert_FieldTerminalPath) Selector() Alert_FieldPathSelector { 205 return fp.selector 206 } 207 208 // String returns path representation in proto convention 209 func (fp *Alert_FieldTerminalPath) String() string { 210 return fp.selector.String() 211 } 212 213 // JSONString returns path representation is JSON convention 214 func (fp *Alert_FieldTerminalPath) JSONString() string { 215 return strcase.ToLowerCamel(fp.String()) 216 } 217 218 // Get returns all values pointed by specific field from source Alert 219 func (fp *Alert_FieldTerminalPath) Get(source *Alert) (values []interface{}) { 220 if source != nil { 221 switch fp.selector { 222 case Alert_FieldPathSelectorName: 223 if source.Name != nil { 224 values = append(values, source.Name) 225 } 226 case Alert_FieldPathSelectorMetadata: 227 if source.Metadata != nil { 228 values = append(values, source.Metadata) 229 } 230 case Alert_FieldPathSelectorDisplayName: 231 values = append(values, source.DisplayName) 232 case Alert_FieldPathSelectorAlertingResource: 233 if source.AlertingResource != nil { 234 values = append(values, source.AlertingResource) 235 } 236 case Alert_FieldPathSelectorTsInfo: 237 if source, ok := source.Info.(*Alert_TsInfo_); ok && source != nil { 238 if source.TsInfo != nil { 239 values = append(values, source.TsInfo) 240 } 241 } 242 case Alert_FieldPathSelectorLogInfo: 243 if source, ok := source.Info.(*Alert_LogInfo_); ok && source != nil { 244 if source.LogInfo != nil { 245 values = append(values, source.LogInfo) 246 } 247 } 248 case Alert_FieldPathSelectorState: 249 if source.State != nil { 250 values = append(values, source.State) 251 } 252 case Alert_FieldPathSelectorInternal: 253 if source.Internal != nil { 254 values = append(values, source.Internal) 255 } 256 default: 257 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 258 } 259 } 260 return 261 } 262 263 func (fp *Alert_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 264 return fp.Get(source.(*Alert)) 265 } 266 267 // GetSingle returns value pointed by specific field of from source Alert 268 func (fp *Alert_FieldTerminalPath) GetSingle(source *Alert) (interface{}, bool) { 269 switch fp.selector { 270 case Alert_FieldPathSelectorName: 271 res := source.GetName() 272 return res, res != nil 273 case Alert_FieldPathSelectorMetadata: 274 res := source.GetMetadata() 275 return res, res != nil 276 case Alert_FieldPathSelectorDisplayName: 277 return source.GetDisplayName(), source != nil 278 case Alert_FieldPathSelectorAlertingResource: 279 res := source.GetAlertingResource() 280 return res, res != nil 281 case Alert_FieldPathSelectorTsInfo: 282 // if object nil or oneof not active, return "default" type with false flag. 283 if source == nil { 284 return source.GetTsInfo(), false 285 } 286 _, oneOfSelected := source.Info.(*Alert_TsInfo_) 287 if !oneOfSelected { 288 return source.GetTsInfo(), false // to return "type" information 289 } 290 res := source.GetTsInfo() 291 return res, res != nil 292 case Alert_FieldPathSelectorLogInfo: 293 // if object nil or oneof not active, return "default" type with false flag. 294 if source == nil { 295 return source.GetLogInfo(), false 296 } 297 _, oneOfSelected := source.Info.(*Alert_LogInfo_) 298 if !oneOfSelected { 299 return source.GetLogInfo(), false // to return "type" information 300 } 301 res := source.GetLogInfo() 302 return res, res != nil 303 case Alert_FieldPathSelectorState: 304 res := source.GetState() 305 return res, res != nil 306 case Alert_FieldPathSelectorInternal: 307 res := source.GetInternal() 308 return res, res != nil 309 default: 310 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 311 } 312 } 313 314 func (fp *Alert_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 315 return fp.GetSingle(source.(*Alert)) 316 } 317 318 // GetDefault returns a default value of the field type 319 func (fp *Alert_FieldTerminalPath) GetDefault() interface{} { 320 switch fp.selector { 321 case Alert_FieldPathSelectorName: 322 return (*Name)(nil) 323 case Alert_FieldPathSelectorMetadata: 324 return (*meta.Meta)(nil) 325 case Alert_FieldPathSelectorDisplayName: 326 return "" 327 case Alert_FieldPathSelectorAlertingResource: 328 return (*meta.OwnerReference)(nil) 329 case Alert_FieldPathSelectorTsInfo: 330 return (*Alert_TsInfo)(nil) 331 case Alert_FieldPathSelectorLogInfo: 332 return (*Alert_LogInfo)(nil) 333 case Alert_FieldPathSelectorState: 334 return (*Alert_State)(nil) 335 case Alert_FieldPathSelectorInternal: 336 return (*Alert_Internal)(nil) 337 default: 338 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 339 } 340 } 341 342 func (fp *Alert_FieldTerminalPath) ClearValue(item *Alert) { 343 if item != nil { 344 switch fp.selector { 345 case Alert_FieldPathSelectorName: 346 item.Name = nil 347 case Alert_FieldPathSelectorMetadata: 348 item.Metadata = nil 349 case Alert_FieldPathSelectorDisplayName: 350 item.DisplayName = "" 351 case Alert_FieldPathSelectorAlertingResource: 352 item.AlertingResource = nil 353 case Alert_FieldPathSelectorTsInfo: 354 if item, ok := item.Info.(*Alert_TsInfo_); ok { 355 item.TsInfo = nil 356 } 357 case Alert_FieldPathSelectorLogInfo: 358 if item, ok := item.Info.(*Alert_LogInfo_); ok { 359 item.LogInfo = nil 360 } 361 case Alert_FieldPathSelectorState: 362 item.State = nil 363 case Alert_FieldPathSelectorInternal: 364 item.Internal = nil 365 default: 366 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 367 } 368 } 369 } 370 371 func (fp *Alert_FieldTerminalPath) ClearValueRaw(item proto.Message) { 372 fp.ClearValue(item.(*Alert)) 373 } 374 375 // IsLeaf - whether field path is holds simple value 376 func (fp *Alert_FieldTerminalPath) IsLeaf() bool { 377 return fp.selector == Alert_FieldPathSelectorName || 378 fp.selector == Alert_FieldPathSelectorDisplayName 379 } 380 381 func (fp *Alert_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 382 return []gotenobject.FieldPath{fp} 383 } 384 385 func (fp *Alert_FieldTerminalPath) WithIValue(value interface{}) Alert_FieldPathValue { 386 switch fp.selector { 387 case Alert_FieldPathSelectorName: 388 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*Name)} 389 case Alert_FieldPathSelectorMetadata: 390 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 391 case Alert_FieldPathSelectorDisplayName: 392 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(string)} 393 case Alert_FieldPathSelectorAlertingResource: 394 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*meta.OwnerReference)} 395 case Alert_FieldPathSelectorTsInfo: 396 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*Alert_TsInfo)} 397 case Alert_FieldPathSelectorLogInfo: 398 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*Alert_LogInfo)} 399 case Alert_FieldPathSelectorState: 400 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*Alert_State)} 401 case Alert_FieldPathSelectorInternal: 402 return &Alert_FieldTerminalPathValue{Alert_FieldTerminalPath: *fp, value: value.(*Alert_Internal)} 403 default: 404 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 405 } 406 } 407 408 func (fp *Alert_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 409 return fp.WithIValue(value) 410 } 411 412 func (fp *Alert_FieldTerminalPath) WithIArrayOfValues(values interface{}) Alert_FieldPathArrayOfValues { 413 fpaov := &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp} 414 switch fp.selector { 415 case Alert_FieldPathSelectorName: 416 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*Name)} 417 case Alert_FieldPathSelectorMetadata: 418 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 419 case Alert_FieldPathSelectorDisplayName: 420 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]string)} 421 case Alert_FieldPathSelectorAlertingResource: 422 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*meta.OwnerReference)} 423 case Alert_FieldPathSelectorTsInfo: 424 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*Alert_TsInfo)} 425 case Alert_FieldPathSelectorLogInfo: 426 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*Alert_LogInfo)} 427 case Alert_FieldPathSelectorState: 428 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*Alert_State)} 429 case Alert_FieldPathSelectorInternal: 430 return &Alert_FieldTerminalPathArrayOfValues{Alert_FieldTerminalPath: *fp, values: values.([]*Alert_Internal)} 431 default: 432 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 433 } 434 return fpaov 435 } 436 437 func (fp *Alert_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 438 return fp.WithIArrayOfValues(values) 439 } 440 441 func (fp *Alert_FieldTerminalPath) WithIArrayItemValue(value interface{}) Alert_FieldPathArrayItemValue { 442 switch fp.selector { 443 default: 444 panic(fmt.Sprintf("Invalid selector for Alert: %d", fp.selector)) 445 } 446 } 447 448 func (fp *Alert_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 449 return fp.WithIArrayItemValue(value) 450 } 451 452 type Alert_FieldSubPath struct { 453 selector Alert_FieldPathSelector 454 subPath gotenobject.FieldPath 455 } 456 457 var _ Alert_FieldPath = (*Alert_FieldSubPath)(nil) 458 459 func (fps *Alert_FieldSubPath) Selector() Alert_FieldPathSelector { 460 return fps.selector 461 } 462 func (fps *Alert_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 463 res, ok := fps.subPath.(meta.Meta_FieldPath) 464 return res, ok 465 } 466 func (fps *Alert_FieldSubPath) AsAlertingResourceSubPath() (meta.OwnerReference_FieldPath, bool) { 467 res, ok := fps.subPath.(meta.OwnerReference_FieldPath) 468 return res, ok 469 } 470 func (fps *Alert_FieldSubPath) AsTsInfoSubPath() (AlertTsInfo_FieldPath, bool) { 471 res, ok := fps.subPath.(AlertTsInfo_FieldPath) 472 return res, ok 473 } 474 func (fps *Alert_FieldSubPath) AsLogInfoSubPath() (AlertLogInfo_FieldPath, bool) { 475 res, ok := fps.subPath.(AlertLogInfo_FieldPath) 476 return res, ok 477 } 478 func (fps *Alert_FieldSubPath) AsStateSubPath() (AlertState_FieldPath, bool) { 479 res, ok := fps.subPath.(AlertState_FieldPath) 480 return res, ok 481 } 482 func (fps *Alert_FieldSubPath) AsInternalSubPath() (AlertInternal_FieldPath, bool) { 483 res, ok := fps.subPath.(AlertInternal_FieldPath) 484 return res, ok 485 } 486 487 // String returns path representation in proto convention 488 func (fps *Alert_FieldSubPath) String() string { 489 return fps.selector.String() + "." + fps.subPath.String() 490 } 491 492 // JSONString returns path representation is JSON convention 493 func (fps *Alert_FieldSubPath) JSONString() string { 494 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 495 } 496 497 // Get returns all values pointed by selected field from source Alert 498 func (fps *Alert_FieldSubPath) Get(source *Alert) (values []interface{}) { 499 switch fps.selector { 500 case Alert_FieldPathSelectorMetadata: 501 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 502 case Alert_FieldPathSelectorAlertingResource: 503 values = append(values, fps.subPath.GetRaw(source.GetAlertingResource())...) 504 case Alert_FieldPathSelectorTsInfo: 505 values = append(values, fps.subPath.GetRaw(source.GetTsInfo())...) 506 case Alert_FieldPathSelectorLogInfo: 507 values = append(values, fps.subPath.GetRaw(source.GetLogInfo())...) 508 case Alert_FieldPathSelectorState: 509 values = append(values, fps.subPath.GetRaw(source.GetState())...) 510 case Alert_FieldPathSelectorInternal: 511 values = append(values, fps.subPath.GetRaw(source.GetInternal())...) 512 default: 513 panic(fmt.Sprintf("Invalid selector for Alert: %d", fps.selector)) 514 } 515 return 516 } 517 518 func (fps *Alert_FieldSubPath) GetRaw(source proto.Message) []interface{} { 519 return fps.Get(source.(*Alert)) 520 } 521 522 // GetSingle returns value of selected field from source Alert 523 func (fps *Alert_FieldSubPath) GetSingle(source *Alert) (interface{}, bool) { 524 switch fps.selector { 525 case Alert_FieldPathSelectorMetadata: 526 if source.GetMetadata() == nil { 527 return nil, false 528 } 529 return fps.subPath.GetSingleRaw(source.GetMetadata()) 530 case Alert_FieldPathSelectorAlertingResource: 531 if source.GetAlertingResource() == nil { 532 return nil, false 533 } 534 return fps.subPath.GetSingleRaw(source.GetAlertingResource()) 535 case Alert_FieldPathSelectorTsInfo: 536 if source.GetTsInfo() == nil { 537 return nil, false 538 } 539 return fps.subPath.GetSingleRaw(source.GetTsInfo()) 540 case Alert_FieldPathSelectorLogInfo: 541 if source.GetLogInfo() == nil { 542 return nil, false 543 } 544 return fps.subPath.GetSingleRaw(source.GetLogInfo()) 545 case Alert_FieldPathSelectorState: 546 if source.GetState() == nil { 547 return nil, false 548 } 549 return fps.subPath.GetSingleRaw(source.GetState()) 550 case Alert_FieldPathSelectorInternal: 551 if source.GetInternal() == nil { 552 return nil, false 553 } 554 return fps.subPath.GetSingleRaw(source.GetInternal()) 555 default: 556 panic(fmt.Sprintf("Invalid selector for Alert: %d", fps.selector)) 557 } 558 } 559 560 func (fps *Alert_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 561 return fps.GetSingle(source.(*Alert)) 562 } 563 564 // GetDefault returns a default value of the field type 565 func (fps *Alert_FieldSubPath) GetDefault() interface{} { 566 return fps.subPath.GetDefault() 567 } 568 569 func (fps *Alert_FieldSubPath) ClearValue(item *Alert) { 570 if item != nil { 571 switch fps.selector { 572 case Alert_FieldPathSelectorMetadata: 573 fps.subPath.ClearValueRaw(item.Metadata) 574 case Alert_FieldPathSelectorAlertingResource: 575 fps.subPath.ClearValueRaw(item.AlertingResource) 576 case Alert_FieldPathSelectorTsInfo: 577 if item.Info != nil { 578 if item, ok := item.Info.(*Alert_TsInfo_); ok { 579 fps.subPath.ClearValueRaw(item.TsInfo) 580 } 581 } 582 case Alert_FieldPathSelectorLogInfo: 583 if item.Info != nil { 584 if item, ok := item.Info.(*Alert_LogInfo_); ok { 585 fps.subPath.ClearValueRaw(item.LogInfo) 586 } 587 } 588 case Alert_FieldPathSelectorState: 589 fps.subPath.ClearValueRaw(item.State) 590 case Alert_FieldPathSelectorInternal: 591 fps.subPath.ClearValueRaw(item.Internal) 592 default: 593 panic(fmt.Sprintf("Invalid selector for Alert: %d", fps.selector)) 594 } 595 } 596 } 597 598 func (fps *Alert_FieldSubPath) ClearValueRaw(item proto.Message) { 599 fps.ClearValue(item.(*Alert)) 600 } 601 602 // IsLeaf - whether field path is holds simple value 603 func (fps *Alert_FieldSubPath) IsLeaf() bool { 604 return fps.subPath.IsLeaf() 605 } 606 607 func (fps *Alert_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 608 iPaths := []gotenobject.FieldPath{&Alert_FieldTerminalPath{selector: fps.selector}} 609 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 610 return iPaths 611 } 612 613 func (fps *Alert_FieldSubPath) WithIValue(value interface{}) Alert_FieldPathValue { 614 return &Alert_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 615 } 616 617 func (fps *Alert_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 618 return fps.WithIValue(value) 619 } 620 621 func (fps *Alert_FieldSubPath) WithIArrayOfValues(values interface{}) Alert_FieldPathArrayOfValues { 622 return &Alert_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 623 } 624 625 func (fps *Alert_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 626 return fps.WithIArrayOfValues(values) 627 } 628 629 func (fps *Alert_FieldSubPath) WithIArrayItemValue(value interface{}) Alert_FieldPathArrayItemValue { 630 return &Alert_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 631 } 632 633 func (fps *Alert_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 634 return fps.WithIArrayItemValue(value) 635 } 636 637 // Alert_FieldPathValue allows storing values for Alert fields according to their type 638 type Alert_FieldPathValue interface { 639 Alert_FieldPath 640 gotenobject.FieldPathValue 641 SetTo(target **Alert) 642 CompareWith(*Alert) (cmp int, comparable bool) 643 } 644 645 func ParseAlert_FieldPathValue(pathStr, valueStr string) (Alert_FieldPathValue, error) { 646 fp, err := ParseAlert_FieldPath(pathStr) 647 if err != nil { 648 return nil, err 649 } 650 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 651 if err != nil { 652 return nil, status.Errorf(codes.InvalidArgument, "error parsing Alert field path value from %s: %v", valueStr, err) 653 } 654 return fpv.(Alert_FieldPathValue), nil 655 } 656 657 func MustParseAlert_FieldPathValue(pathStr, valueStr string) Alert_FieldPathValue { 658 fpv, err := ParseAlert_FieldPathValue(pathStr, valueStr) 659 if err != nil { 660 panic(err) 661 } 662 return fpv 663 } 664 665 type Alert_FieldTerminalPathValue struct { 666 Alert_FieldTerminalPath 667 value interface{} 668 } 669 670 var _ Alert_FieldPathValue = (*Alert_FieldTerminalPathValue)(nil) 671 672 // GetRawValue returns raw value stored under selected path for 'Alert' as interface{} 673 func (fpv *Alert_FieldTerminalPathValue) GetRawValue() interface{} { 674 return fpv.value 675 } 676 func (fpv *Alert_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 677 res, ok := fpv.value.(*Name) 678 return res, ok 679 } 680 func (fpv *Alert_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 681 res, ok := fpv.value.(*meta.Meta) 682 return res, ok 683 } 684 func (fpv *Alert_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) { 685 res, ok := fpv.value.(string) 686 return res, ok 687 } 688 func (fpv *Alert_FieldTerminalPathValue) AsAlertingResourceValue() (*meta.OwnerReference, bool) { 689 res, ok := fpv.value.(*meta.OwnerReference) 690 return res, ok 691 } 692 func (fpv *Alert_FieldTerminalPathValue) AsTsInfoValue() (*Alert_TsInfo, bool) { 693 res, ok := fpv.value.(*Alert_TsInfo) 694 return res, ok 695 } 696 func (fpv *Alert_FieldTerminalPathValue) AsLogInfoValue() (*Alert_LogInfo, bool) { 697 res, ok := fpv.value.(*Alert_LogInfo) 698 return res, ok 699 } 700 func (fpv *Alert_FieldTerminalPathValue) AsStateValue() (*Alert_State, bool) { 701 res, ok := fpv.value.(*Alert_State) 702 return res, ok 703 } 704 func (fpv *Alert_FieldTerminalPathValue) AsInternalValue() (*Alert_Internal, bool) { 705 res, ok := fpv.value.(*Alert_Internal) 706 return res, ok 707 } 708 709 // SetTo stores value for selected field for object Alert 710 func (fpv *Alert_FieldTerminalPathValue) SetTo(target **Alert) { 711 if *target == nil { 712 *target = new(Alert) 713 } 714 switch fpv.selector { 715 case Alert_FieldPathSelectorName: 716 (*target).Name = fpv.value.(*Name) 717 case Alert_FieldPathSelectorMetadata: 718 (*target).Metadata = fpv.value.(*meta.Meta) 719 case Alert_FieldPathSelectorDisplayName: 720 (*target).DisplayName = fpv.value.(string) 721 case Alert_FieldPathSelectorAlertingResource: 722 (*target).AlertingResource = fpv.value.(*meta.OwnerReference) 723 case Alert_FieldPathSelectorTsInfo: 724 if _, ok := (*target).Info.(*Alert_TsInfo_); !ok { 725 (*target).Info = &Alert_TsInfo_{} 726 } 727 (*target).Info.(*Alert_TsInfo_).TsInfo = fpv.value.(*Alert_TsInfo) 728 case Alert_FieldPathSelectorLogInfo: 729 if _, ok := (*target).Info.(*Alert_LogInfo_); !ok { 730 (*target).Info = &Alert_LogInfo_{} 731 } 732 (*target).Info.(*Alert_LogInfo_).LogInfo = fpv.value.(*Alert_LogInfo) 733 case Alert_FieldPathSelectorState: 734 (*target).State = fpv.value.(*Alert_State) 735 case Alert_FieldPathSelectorInternal: 736 (*target).Internal = fpv.value.(*Alert_Internal) 737 default: 738 panic(fmt.Sprintf("Invalid selector for Alert: %d", fpv.selector)) 739 } 740 } 741 742 func (fpv *Alert_FieldTerminalPathValue) SetToRaw(target proto.Message) { 743 typedObject := target.(*Alert) 744 fpv.SetTo(&typedObject) 745 } 746 747 // CompareWith compares value in the 'Alert_FieldTerminalPathValue' with the value under path in 'Alert'. 748 func (fpv *Alert_FieldTerminalPathValue) CompareWith(source *Alert) (int, bool) { 749 switch fpv.selector { 750 case Alert_FieldPathSelectorName: 751 leftValue := fpv.value.(*Name) 752 rightValue := source.GetName() 753 if leftValue == nil { 754 if rightValue != nil { 755 return -1, true 756 } 757 return 0, true 758 } 759 if rightValue == nil { 760 return 1, true 761 } 762 if leftValue.String() == rightValue.String() { 763 return 0, true 764 } else if leftValue.String() < rightValue.String() { 765 return -1, true 766 } else { 767 return 1, true 768 } 769 case Alert_FieldPathSelectorMetadata: 770 return 0, false 771 case Alert_FieldPathSelectorDisplayName: 772 leftValue := fpv.value.(string) 773 rightValue := source.GetDisplayName() 774 if (leftValue) == (rightValue) { 775 return 0, true 776 } else if (leftValue) < (rightValue) { 777 return -1, true 778 } else { 779 return 1, true 780 } 781 case Alert_FieldPathSelectorAlertingResource: 782 return 0, false 783 case Alert_FieldPathSelectorTsInfo: 784 return 0, false 785 case Alert_FieldPathSelectorLogInfo: 786 return 0, false 787 case Alert_FieldPathSelectorState: 788 return 0, false 789 case Alert_FieldPathSelectorInternal: 790 return 0, false 791 default: 792 panic(fmt.Sprintf("Invalid selector for Alert: %d", fpv.selector)) 793 } 794 } 795 796 func (fpv *Alert_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 797 return fpv.CompareWith(source.(*Alert)) 798 } 799 800 type Alert_FieldSubPathValue struct { 801 Alert_FieldPath 802 subPathValue gotenobject.FieldPathValue 803 } 804 805 var _ Alert_FieldPathValue = (*Alert_FieldSubPathValue)(nil) 806 807 func (fpvs *Alert_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 808 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 809 return res, ok 810 } 811 func (fpvs *Alert_FieldSubPathValue) AsAlertingResourcePathValue() (meta.OwnerReference_FieldPathValue, bool) { 812 res, ok := fpvs.subPathValue.(meta.OwnerReference_FieldPathValue) 813 return res, ok 814 } 815 func (fpvs *Alert_FieldSubPathValue) AsTsInfoPathValue() (AlertTsInfo_FieldPathValue, bool) { 816 res, ok := fpvs.subPathValue.(AlertTsInfo_FieldPathValue) 817 return res, ok 818 } 819 func (fpvs *Alert_FieldSubPathValue) AsLogInfoPathValue() (AlertLogInfo_FieldPathValue, bool) { 820 res, ok := fpvs.subPathValue.(AlertLogInfo_FieldPathValue) 821 return res, ok 822 } 823 func (fpvs *Alert_FieldSubPathValue) AsStatePathValue() (AlertState_FieldPathValue, bool) { 824 res, ok := fpvs.subPathValue.(AlertState_FieldPathValue) 825 return res, ok 826 } 827 func (fpvs *Alert_FieldSubPathValue) AsInternalPathValue() (AlertInternal_FieldPathValue, bool) { 828 res, ok := fpvs.subPathValue.(AlertInternal_FieldPathValue) 829 return res, ok 830 } 831 832 func (fpvs *Alert_FieldSubPathValue) SetTo(target **Alert) { 833 if *target == nil { 834 *target = new(Alert) 835 } 836 switch fpvs.Selector() { 837 case Alert_FieldPathSelectorMetadata: 838 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 839 case Alert_FieldPathSelectorAlertingResource: 840 fpvs.subPathValue.(meta.OwnerReference_FieldPathValue).SetTo(&(*target).AlertingResource) 841 case Alert_FieldPathSelectorTsInfo: 842 if _, ok := (*target).Info.(*Alert_TsInfo_); !ok { 843 (*target).Info = &Alert_TsInfo_{} 844 } 845 fpvs.subPathValue.(AlertTsInfo_FieldPathValue).SetTo(&(*target).Info.(*Alert_TsInfo_).TsInfo) 846 case Alert_FieldPathSelectorLogInfo: 847 if _, ok := (*target).Info.(*Alert_LogInfo_); !ok { 848 (*target).Info = &Alert_LogInfo_{} 849 } 850 fpvs.subPathValue.(AlertLogInfo_FieldPathValue).SetTo(&(*target).Info.(*Alert_LogInfo_).LogInfo) 851 case Alert_FieldPathSelectorState: 852 fpvs.subPathValue.(AlertState_FieldPathValue).SetTo(&(*target).State) 853 case Alert_FieldPathSelectorInternal: 854 fpvs.subPathValue.(AlertInternal_FieldPathValue).SetTo(&(*target).Internal) 855 default: 856 panic(fmt.Sprintf("Invalid selector for Alert: %d", fpvs.Selector())) 857 } 858 } 859 860 func (fpvs *Alert_FieldSubPathValue) SetToRaw(target proto.Message) { 861 typedObject := target.(*Alert) 862 fpvs.SetTo(&typedObject) 863 } 864 865 func (fpvs *Alert_FieldSubPathValue) GetRawValue() interface{} { 866 return fpvs.subPathValue.GetRawValue() 867 } 868 869 func (fpvs *Alert_FieldSubPathValue) CompareWith(source *Alert) (int, bool) { 870 switch fpvs.Selector() { 871 case Alert_FieldPathSelectorMetadata: 872 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 873 case Alert_FieldPathSelectorAlertingResource: 874 return fpvs.subPathValue.(meta.OwnerReference_FieldPathValue).CompareWith(source.GetAlertingResource()) 875 case Alert_FieldPathSelectorTsInfo: 876 return fpvs.subPathValue.(AlertTsInfo_FieldPathValue).CompareWith(source.GetTsInfo()) 877 case Alert_FieldPathSelectorLogInfo: 878 return fpvs.subPathValue.(AlertLogInfo_FieldPathValue).CompareWith(source.GetLogInfo()) 879 case Alert_FieldPathSelectorState: 880 return fpvs.subPathValue.(AlertState_FieldPathValue).CompareWith(source.GetState()) 881 case Alert_FieldPathSelectorInternal: 882 return fpvs.subPathValue.(AlertInternal_FieldPathValue).CompareWith(source.GetInternal()) 883 default: 884 panic(fmt.Sprintf("Invalid selector for Alert: %d", fpvs.Selector())) 885 } 886 } 887 888 func (fpvs *Alert_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 889 return fpvs.CompareWith(source.(*Alert)) 890 } 891 892 // Alert_FieldPathArrayItemValue allows storing single item in Path-specific values for Alert according to their type 893 // Present only for array (repeated) types. 894 type Alert_FieldPathArrayItemValue interface { 895 gotenobject.FieldPathArrayItemValue 896 Alert_FieldPath 897 ContainsValue(*Alert) bool 898 } 899 900 // ParseAlert_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 901 func ParseAlert_FieldPathArrayItemValue(pathStr, valueStr string) (Alert_FieldPathArrayItemValue, error) { 902 fp, err := ParseAlert_FieldPath(pathStr) 903 if err != nil { 904 return nil, err 905 } 906 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 907 if err != nil { 908 return nil, status.Errorf(codes.InvalidArgument, "error parsing Alert field path array item value from %s: %v", valueStr, err) 909 } 910 return fpaiv.(Alert_FieldPathArrayItemValue), nil 911 } 912 913 func MustParseAlert_FieldPathArrayItemValue(pathStr, valueStr string) Alert_FieldPathArrayItemValue { 914 fpaiv, err := ParseAlert_FieldPathArrayItemValue(pathStr, valueStr) 915 if err != nil { 916 panic(err) 917 } 918 return fpaiv 919 } 920 921 type Alert_FieldTerminalPathArrayItemValue struct { 922 Alert_FieldTerminalPath 923 value interface{} 924 } 925 926 var _ Alert_FieldPathArrayItemValue = (*Alert_FieldTerminalPathArrayItemValue)(nil) 927 928 // GetRawValue returns stored element value for array in object Alert as interface{} 929 func (fpaiv *Alert_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 930 return fpaiv.value 931 } 932 933 func (fpaiv *Alert_FieldTerminalPathArrayItemValue) GetSingle(source *Alert) (interface{}, bool) { 934 return nil, false 935 } 936 937 func (fpaiv *Alert_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 938 return fpaiv.GetSingle(source.(*Alert)) 939 } 940 941 // Contains returns a boolean indicating if value that is being held is present in given 'Alert' 942 func (fpaiv *Alert_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert) bool { 943 slice := fpaiv.Alert_FieldTerminalPath.Get(source) 944 for _, v := range slice { 945 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 946 if proto.Equal(asProtoMsg, v.(proto.Message)) { 947 return true 948 } 949 } else if reflect.DeepEqual(v, fpaiv.value) { 950 return true 951 } 952 } 953 return false 954 } 955 956 type Alert_FieldSubPathArrayItemValue struct { 957 Alert_FieldPath 958 subPathItemValue gotenobject.FieldPathArrayItemValue 959 } 960 961 // GetRawValue returns stored array item value 962 func (fpaivs *Alert_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 963 return fpaivs.subPathItemValue.GetRawItemValue() 964 } 965 func (fpaivs *Alert_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 966 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 967 return res, ok 968 } 969 func (fpaivs *Alert_FieldSubPathArrayItemValue) AsAlertingResourcePathItemValue() (meta.OwnerReference_FieldPathArrayItemValue, bool) { 970 res, ok := fpaivs.subPathItemValue.(meta.OwnerReference_FieldPathArrayItemValue) 971 return res, ok 972 } 973 func (fpaivs *Alert_FieldSubPathArrayItemValue) AsTsInfoPathItemValue() (AlertTsInfo_FieldPathArrayItemValue, bool) { 974 res, ok := fpaivs.subPathItemValue.(AlertTsInfo_FieldPathArrayItemValue) 975 return res, ok 976 } 977 func (fpaivs *Alert_FieldSubPathArrayItemValue) AsLogInfoPathItemValue() (AlertLogInfo_FieldPathArrayItemValue, bool) { 978 res, ok := fpaivs.subPathItemValue.(AlertLogInfo_FieldPathArrayItemValue) 979 return res, ok 980 } 981 func (fpaivs *Alert_FieldSubPathArrayItemValue) AsStatePathItemValue() (AlertState_FieldPathArrayItemValue, bool) { 982 res, ok := fpaivs.subPathItemValue.(AlertState_FieldPathArrayItemValue) 983 return res, ok 984 } 985 func (fpaivs *Alert_FieldSubPathArrayItemValue) AsInternalPathItemValue() (AlertInternal_FieldPathArrayItemValue, bool) { 986 res, ok := fpaivs.subPathItemValue.(AlertInternal_FieldPathArrayItemValue) 987 return res, ok 988 } 989 990 // Contains returns a boolean indicating if value that is being held is present in given 'Alert' 991 func (fpaivs *Alert_FieldSubPathArrayItemValue) ContainsValue(source *Alert) bool { 992 switch fpaivs.Selector() { 993 case Alert_FieldPathSelectorMetadata: 994 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 995 case Alert_FieldPathSelectorAlertingResource: 996 return fpaivs.subPathItemValue.(meta.OwnerReference_FieldPathArrayItemValue).ContainsValue(source.GetAlertingResource()) 997 case Alert_FieldPathSelectorTsInfo: 998 return fpaivs.subPathItemValue.(AlertTsInfo_FieldPathArrayItemValue).ContainsValue(source.GetTsInfo()) 999 case Alert_FieldPathSelectorLogInfo: 1000 return fpaivs.subPathItemValue.(AlertLogInfo_FieldPathArrayItemValue).ContainsValue(source.GetLogInfo()) 1001 case Alert_FieldPathSelectorState: 1002 return fpaivs.subPathItemValue.(AlertState_FieldPathArrayItemValue).ContainsValue(source.GetState()) 1003 case Alert_FieldPathSelectorInternal: 1004 return fpaivs.subPathItemValue.(AlertInternal_FieldPathArrayItemValue).ContainsValue(source.GetInternal()) 1005 default: 1006 panic(fmt.Sprintf("Invalid selector for Alert: %d", fpaivs.Selector())) 1007 } 1008 } 1009 1010 // Alert_FieldPathArrayOfValues allows storing slice of values for Alert fields according to their type 1011 type Alert_FieldPathArrayOfValues interface { 1012 gotenobject.FieldPathArrayOfValues 1013 Alert_FieldPath 1014 } 1015 1016 func ParseAlert_FieldPathArrayOfValues(pathStr, valuesStr string) (Alert_FieldPathArrayOfValues, error) { 1017 fp, err := ParseAlert_FieldPath(pathStr) 1018 if err != nil { 1019 return nil, err 1020 } 1021 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1022 if err != nil { 1023 return nil, status.Errorf(codes.InvalidArgument, "error parsing Alert field path array of values from %s: %v", valuesStr, err) 1024 } 1025 return fpaov.(Alert_FieldPathArrayOfValues), nil 1026 } 1027 1028 func MustParseAlert_FieldPathArrayOfValues(pathStr, valuesStr string) Alert_FieldPathArrayOfValues { 1029 fpaov, err := ParseAlert_FieldPathArrayOfValues(pathStr, valuesStr) 1030 if err != nil { 1031 panic(err) 1032 } 1033 return fpaov 1034 } 1035 1036 type Alert_FieldTerminalPathArrayOfValues struct { 1037 Alert_FieldTerminalPath 1038 values interface{} 1039 } 1040 1041 var _ Alert_FieldPathArrayOfValues = (*Alert_FieldTerminalPathArrayOfValues)(nil) 1042 1043 func (fpaov *Alert_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1044 switch fpaov.selector { 1045 case Alert_FieldPathSelectorName: 1046 for _, v := range fpaov.values.([]*Name) { 1047 values = append(values, v) 1048 } 1049 case Alert_FieldPathSelectorMetadata: 1050 for _, v := range fpaov.values.([]*meta.Meta) { 1051 values = append(values, v) 1052 } 1053 case Alert_FieldPathSelectorDisplayName: 1054 for _, v := range fpaov.values.([]string) { 1055 values = append(values, v) 1056 } 1057 case Alert_FieldPathSelectorAlertingResource: 1058 for _, v := range fpaov.values.([]*meta.OwnerReference) { 1059 values = append(values, v) 1060 } 1061 case Alert_FieldPathSelectorTsInfo: 1062 for _, v := range fpaov.values.([]*Alert_TsInfo) { 1063 values = append(values, v) 1064 } 1065 case Alert_FieldPathSelectorLogInfo: 1066 for _, v := range fpaov.values.([]*Alert_LogInfo) { 1067 values = append(values, v) 1068 } 1069 case Alert_FieldPathSelectorState: 1070 for _, v := range fpaov.values.([]*Alert_State) { 1071 values = append(values, v) 1072 } 1073 case Alert_FieldPathSelectorInternal: 1074 for _, v := range fpaov.values.([]*Alert_Internal) { 1075 values = append(values, v) 1076 } 1077 } 1078 return 1079 } 1080 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 1081 res, ok := fpaov.values.([]*Name) 1082 return res, ok 1083 } 1084 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 1085 res, ok := fpaov.values.([]*meta.Meta) 1086 return res, ok 1087 } 1088 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) { 1089 res, ok := fpaov.values.([]string) 1090 return res, ok 1091 } 1092 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsAlertingResourceArrayOfValues() ([]*meta.OwnerReference, bool) { 1093 res, ok := fpaov.values.([]*meta.OwnerReference) 1094 return res, ok 1095 } 1096 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsTsInfoArrayOfValues() ([]*Alert_TsInfo, bool) { 1097 res, ok := fpaov.values.([]*Alert_TsInfo) 1098 return res, ok 1099 } 1100 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsLogInfoArrayOfValues() ([]*Alert_LogInfo, bool) { 1101 res, ok := fpaov.values.([]*Alert_LogInfo) 1102 return res, ok 1103 } 1104 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsStateArrayOfValues() ([]*Alert_State, bool) { 1105 res, ok := fpaov.values.([]*Alert_State) 1106 return res, ok 1107 } 1108 func (fpaov *Alert_FieldTerminalPathArrayOfValues) AsInternalArrayOfValues() ([]*Alert_Internal, bool) { 1109 res, ok := fpaov.values.([]*Alert_Internal) 1110 return res, ok 1111 } 1112 1113 type Alert_FieldSubPathArrayOfValues struct { 1114 Alert_FieldPath 1115 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 1116 } 1117 1118 var _ Alert_FieldPathArrayOfValues = (*Alert_FieldSubPathArrayOfValues)(nil) 1119 1120 func (fpsaov *Alert_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 1121 return fpsaov.subPathArrayOfValues.GetRawValues() 1122 } 1123 func (fpsaov *Alert_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 1124 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 1125 return res, ok 1126 } 1127 func (fpsaov *Alert_FieldSubPathArrayOfValues) AsAlertingResourcePathArrayOfValues() (meta.OwnerReference_FieldPathArrayOfValues, bool) { 1128 res, ok := fpsaov.subPathArrayOfValues.(meta.OwnerReference_FieldPathArrayOfValues) 1129 return res, ok 1130 } 1131 func (fpsaov *Alert_FieldSubPathArrayOfValues) AsTsInfoPathArrayOfValues() (AlertTsInfo_FieldPathArrayOfValues, bool) { 1132 res, ok := fpsaov.subPathArrayOfValues.(AlertTsInfo_FieldPathArrayOfValues) 1133 return res, ok 1134 } 1135 func (fpsaov *Alert_FieldSubPathArrayOfValues) AsLogInfoPathArrayOfValues() (AlertLogInfo_FieldPathArrayOfValues, bool) { 1136 res, ok := fpsaov.subPathArrayOfValues.(AlertLogInfo_FieldPathArrayOfValues) 1137 return res, ok 1138 } 1139 func (fpsaov *Alert_FieldSubPathArrayOfValues) AsStatePathArrayOfValues() (AlertState_FieldPathArrayOfValues, bool) { 1140 res, ok := fpsaov.subPathArrayOfValues.(AlertState_FieldPathArrayOfValues) 1141 return res, ok 1142 } 1143 func (fpsaov *Alert_FieldSubPathArrayOfValues) AsInternalPathArrayOfValues() (AlertInternal_FieldPathArrayOfValues, bool) { 1144 res, ok := fpsaov.subPathArrayOfValues.(AlertInternal_FieldPathArrayOfValues) 1145 return res, ok 1146 } 1147 1148 // FieldPath provides implementation to handle 1149 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 1150 type AlertTsInfo_FieldPath interface { 1151 gotenobject.FieldPath 1152 Selector() AlertTsInfo_FieldPathSelector 1153 Get(source *Alert_TsInfo) []interface{} 1154 GetSingle(source *Alert_TsInfo) (interface{}, bool) 1155 ClearValue(item *Alert_TsInfo) 1156 1157 // Those methods build corresponding AlertTsInfo_FieldPathValue 1158 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1159 WithIValue(value interface{}) AlertTsInfo_FieldPathValue 1160 WithIArrayOfValues(values interface{}) AlertTsInfo_FieldPathArrayOfValues 1161 WithIArrayItemValue(value interface{}) AlertTsInfo_FieldPathArrayItemValue 1162 } 1163 1164 type AlertTsInfo_FieldPathSelector int32 1165 1166 const ( 1167 AlertTsInfo_FieldPathSelectorType AlertTsInfo_FieldPathSelector = 0 1168 AlertTsInfo_FieldPathSelectorAnomalyWindowSize AlertTsInfo_FieldPathSelector = 1 1169 AlertTsInfo_FieldPathSelectorCommonKey AlertTsInfo_FieldPathSelector = 2 1170 AlertTsInfo_FieldPathSelectorMetricTypes AlertTsInfo_FieldPathSelector = 3 1171 AlertTsInfo_FieldPathSelectorResourceTypes AlertTsInfo_FieldPathSelector = 4 1172 AlertTsInfo_FieldPathSelectorCommonMetricLabels AlertTsInfo_FieldPathSelector = 5 1173 AlertTsInfo_FieldPathSelectorCommonResourceLabels AlertTsInfo_FieldPathSelector = 6 1174 AlertTsInfo_FieldPathSelectorTimeSeries AlertTsInfo_FieldPathSelector = 7 1175 ) 1176 1177 func (s AlertTsInfo_FieldPathSelector) String() string { 1178 switch s { 1179 case AlertTsInfo_FieldPathSelectorType: 1180 return "type" 1181 case AlertTsInfo_FieldPathSelectorAnomalyWindowSize: 1182 return "anomaly_window_size" 1183 case AlertTsInfo_FieldPathSelectorCommonKey: 1184 return "common_key" 1185 case AlertTsInfo_FieldPathSelectorMetricTypes: 1186 return "metric_types" 1187 case AlertTsInfo_FieldPathSelectorResourceTypes: 1188 return "resource_types" 1189 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1190 return "common_metric_labels" 1191 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1192 return "common_resource_labels" 1193 case AlertTsInfo_FieldPathSelectorTimeSeries: 1194 return "time_series" 1195 default: 1196 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", s)) 1197 } 1198 } 1199 1200 func BuildAlertTsInfo_FieldPath(fp gotenobject.RawFieldPath) (AlertTsInfo_FieldPath, error) { 1201 if len(fp) == 0 { 1202 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_TsInfo") 1203 } 1204 if len(fp) == 1 { 1205 switch fp[0] { 1206 case "type": 1207 return &AlertTsInfo_FieldTerminalPath{selector: AlertTsInfo_FieldPathSelectorType}, nil 1208 case "anomaly_window_size", "anomalyWindowSize", "anomaly-window-size": 1209 return &AlertTsInfo_FieldTerminalPath{selector: AlertTsInfo_FieldPathSelectorAnomalyWindowSize}, nil 1210 case "common_key", "commonKey", "common-key": 1211 return &AlertTsInfo_FieldTerminalPath{selector: AlertTsInfo_FieldPathSelectorCommonKey}, nil 1212 case "metric_types", "metricTypes", "metric-types": 1213 return &AlertTsInfo_FieldTerminalPath{selector: AlertTsInfo_FieldPathSelectorMetricTypes}, nil 1214 case "resource_types", "resourceTypes", "resource-types": 1215 return &AlertTsInfo_FieldTerminalPath{selector: AlertTsInfo_FieldPathSelectorResourceTypes}, nil 1216 case "common_metric_labels", "commonMetricLabels", "common-metric-labels": 1217 return &AlertTsInfo_FieldTerminalPath{selector: AlertTsInfo_FieldPathSelectorCommonMetricLabels}, nil 1218 case "common_resource_labels", "commonResourceLabels", "common-resource-labels": 1219 return &AlertTsInfo_FieldTerminalPath{selector: AlertTsInfo_FieldPathSelectorCommonResourceLabels}, nil 1220 case "time_series", "timeSeries", "time-series": 1221 return &AlertTsInfo_FieldTerminalPath{selector: AlertTsInfo_FieldPathSelectorTimeSeries}, nil 1222 } 1223 } else { 1224 switch fp[0] { 1225 case "time_series", "timeSeries", "time-series": 1226 if subpath, err := BuildAlertTsInfoTimeSeries_FieldPath(fp[1:]); err != nil { 1227 return nil, err 1228 } else { 1229 return &AlertTsInfo_FieldSubPath{selector: AlertTsInfo_FieldPathSelectorTimeSeries, subPath: subpath}, nil 1230 } 1231 case "common_metric_labels", "commonMetricLabels", "common-metric-labels": 1232 if len(fp) > 2 { 1233 return nil, status.Errorf(codes.InvalidArgument, "sub path for maps ('%s') are not supported (object Alert_TsInfo)", fp) 1234 } 1235 return &AlertTsInfo_FieldPathMap{selector: AlertTsInfo_FieldPathSelectorCommonMetricLabels, key: fp[1]}, nil 1236 case "common_resource_labels", "commonResourceLabels", "common-resource-labels": 1237 if len(fp) > 2 { 1238 return nil, status.Errorf(codes.InvalidArgument, "sub path for maps ('%s') are not supported (object Alert_TsInfo)", fp) 1239 } 1240 return &AlertTsInfo_FieldPathMap{selector: AlertTsInfo_FieldPathSelectorCommonResourceLabels, key: fp[1]}, nil 1241 } 1242 } 1243 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_TsInfo", fp) 1244 } 1245 1246 func ParseAlertTsInfo_FieldPath(rawField string) (AlertTsInfo_FieldPath, error) { 1247 fp, err := gotenobject.ParseRawFieldPath(rawField) 1248 if err != nil { 1249 return nil, err 1250 } 1251 return BuildAlertTsInfo_FieldPath(fp) 1252 } 1253 1254 func MustParseAlertTsInfo_FieldPath(rawField string) AlertTsInfo_FieldPath { 1255 fp, err := ParseAlertTsInfo_FieldPath(rawField) 1256 if err != nil { 1257 panic(err) 1258 } 1259 return fp 1260 } 1261 1262 type AlertTsInfo_FieldTerminalPath struct { 1263 selector AlertTsInfo_FieldPathSelector 1264 } 1265 1266 var _ AlertTsInfo_FieldPath = (*AlertTsInfo_FieldTerminalPath)(nil) 1267 1268 func (fp *AlertTsInfo_FieldTerminalPath) Selector() AlertTsInfo_FieldPathSelector { 1269 return fp.selector 1270 } 1271 1272 // String returns path representation in proto convention 1273 func (fp *AlertTsInfo_FieldTerminalPath) String() string { 1274 return fp.selector.String() 1275 } 1276 1277 // JSONString returns path representation is JSON convention 1278 func (fp *AlertTsInfo_FieldTerminalPath) JSONString() string { 1279 return strcase.ToLowerCamel(fp.String()) 1280 } 1281 1282 // Get returns all values pointed by specific field from source Alert_TsInfo 1283 func (fp *AlertTsInfo_FieldTerminalPath) Get(source *Alert_TsInfo) (values []interface{}) { 1284 if source != nil { 1285 switch fp.selector { 1286 case AlertTsInfo_FieldPathSelectorType: 1287 values = append(values, source.Type) 1288 case AlertTsInfo_FieldPathSelectorAnomalyWindowSize: 1289 if source.AnomalyWindowSize != nil { 1290 values = append(values, source.AnomalyWindowSize) 1291 } 1292 case AlertTsInfo_FieldPathSelectorCommonKey: 1293 values = append(values, source.CommonKey) 1294 case AlertTsInfo_FieldPathSelectorMetricTypes: 1295 for _, value := range source.GetMetricTypes() { 1296 values = append(values, value) 1297 } 1298 case AlertTsInfo_FieldPathSelectorResourceTypes: 1299 for _, value := range source.GetResourceTypes() { 1300 values = append(values, value) 1301 } 1302 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1303 values = append(values, source.CommonMetricLabels) 1304 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1305 values = append(values, source.CommonResourceLabels) 1306 case AlertTsInfo_FieldPathSelectorTimeSeries: 1307 for _, value := range source.GetTimeSeries() { 1308 values = append(values, value) 1309 } 1310 default: 1311 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fp.selector)) 1312 } 1313 } 1314 return 1315 } 1316 1317 func (fp *AlertTsInfo_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1318 return fp.Get(source.(*Alert_TsInfo)) 1319 } 1320 1321 // GetSingle returns value pointed by specific field of from source Alert_TsInfo 1322 func (fp *AlertTsInfo_FieldTerminalPath) GetSingle(source *Alert_TsInfo) (interface{}, bool) { 1323 switch fp.selector { 1324 case AlertTsInfo_FieldPathSelectorType: 1325 return source.GetType(), source != nil 1326 case AlertTsInfo_FieldPathSelectorAnomalyWindowSize: 1327 res := source.GetAnomalyWindowSize() 1328 return res, res != nil 1329 case AlertTsInfo_FieldPathSelectorCommonKey: 1330 res := source.GetCommonKey() 1331 return res, res != nil 1332 case AlertTsInfo_FieldPathSelectorMetricTypes: 1333 res := source.GetMetricTypes() 1334 return res, res != nil 1335 case AlertTsInfo_FieldPathSelectorResourceTypes: 1336 res := source.GetResourceTypes() 1337 return res, res != nil 1338 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1339 res := source.GetCommonMetricLabels() 1340 return res, res != nil 1341 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1342 res := source.GetCommonResourceLabels() 1343 return res, res != nil 1344 case AlertTsInfo_FieldPathSelectorTimeSeries: 1345 res := source.GetTimeSeries() 1346 return res, res != nil 1347 default: 1348 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fp.selector)) 1349 } 1350 } 1351 1352 func (fp *AlertTsInfo_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1353 return fp.GetSingle(source.(*Alert_TsInfo)) 1354 } 1355 1356 // GetDefault returns a default value of the field type 1357 func (fp *AlertTsInfo_FieldTerminalPath) GetDefault() interface{} { 1358 switch fp.selector { 1359 case AlertTsInfo_FieldPathSelectorType: 1360 return Alert_TsInfo_UNDEFINED 1361 case AlertTsInfo_FieldPathSelectorAnomalyWindowSize: 1362 return (*durationpb.Duration)(nil) 1363 case AlertTsInfo_FieldPathSelectorCommonKey: 1364 return ([]byte)(nil) 1365 case AlertTsInfo_FieldPathSelectorMetricTypes: 1366 return ([]string)(nil) 1367 case AlertTsInfo_FieldPathSelectorResourceTypes: 1368 return ([]string)(nil) 1369 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1370 return (map[string]string)(nil) 1371 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1372 return (map[string]string)(nil) 1373 case AlertTsInfo_FieldPathSelectorTimeSeries: 1374 return ([]*Alert_TsInfo_TimeSeries)(nil) 1375 default: 1376 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fp.selector)) 1377 } 1378 } 1379 1380 func (fp *AlertTsInfo_FieldTerminalPath) ClearValue(item *Alert_TsInfo) { 1381 if item != nil { 1382 switch fp.selector { 1383 case AlertTsInfo_FieldPathSelectorType: 1384 item.Type = Alert_TsInfo_UNDEFINED 1385 case AlertTsInfo_FieldPathSelectorAnomalyWindowSize: 1386 item.AnomalyWindowSize = nil 1387 case AlertTsInfo_FieldPathSelectorCommonKey: 1388 item.CommonKey = nil 1389 case AlertTsInfo_FieldPathSelectorMetricTypes: 1390 item.MetricTypes = nil 1391 case AlertTsInfo_FieldPathSelectorResourceTypes: 1392 item.ResourceTypes = nil 1393 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1394 item.CommonMetricLabels = nil 1395 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1396 item.CommonResourceLabels = nil 1397 case AlertTsInfo_FieldPathSelectorTimeSeries: 1398 item.TimeSeries = nil 1399 default: 1400 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fp.selector)) 1401 } 1402 } 1403 } 1404 1405 func (fp *AlertTsInfo_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1406 fp.ClearValue(item.(*Alert_TsInfo)) 1407 } 1408 1409 // IsLeaf - whether field path is holds simple value 1410 func (fp *AlertTsInfo_FieldTerminalPath) IsLeaf() bool { 1411 return fp.selector == AlertTsInfo_FieldPathSelectorType || 1412 fp.selector == AlertTsInfo_FieldPathSelectorAnomalyWindowSize || 1413 fp.selector == AlertTsInfo_FieldPathSelectorCommonKey || 1414 fp.selector == AlertTsInfo_FieldPathSelectorMetricTypes || 1415 fp.selector == AlertTsInfo_FieldPathSelectorResourceTypes || 1416 fp.selector == AlertTsInfo_FieldPathSelectorCommonMetricLabels || 1417 fp.selector == AlertTsInfo_FieldPathSelectorCommonResourceLabels 1418 } 1419 1420 func (fp *AlertTsInfo_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1421 return []gotenobject.FieldPath{fp} 1422 } 1423 1424 func (fp *AlertTsInfo_FieldTerminalPath) WithIValue(value interface{}) AlertTsInfo_FieldPathValue { 1425 switch fp.selector { 1426 case AlertTsInfo_FieldPathSelectorType: 1427 return &AlertTsInfo_FieldTerminalPathValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.(Alert_TsInfo_Type)} 1428 case AlertTsInfo_FieldPathSelectorAnomalyWindowSize: 1429 return &AlertTsInfo_FieldTerminalPathValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.(*durationpb.Duration)} 1430 case AlertTsInfo_FieldPathSelectorCommonKey: 1431 return &AlertTsInfo_FieldTerminalPathValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.([]byte)} 1432 case AlertTsInfo_FieldPathSelectorMetricTypes: 1433 return &AlertTsInfo_FieldTerminalPathValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.([]string)} 1434 case AlertTsInfo_FieldPathSelectorResourceTypes: 1435 return &AlertTsInfo_FieldTerminalPathValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.([]string)} 1436 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1437 return &AlertTsInfo_FieldTerminalPathValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.(map[string]string)} 1438 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1439 return &AlertTsInfo_FieldTerminalPathValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.(map[string]string)} 1440 case AlertTsInfo_FieldPathSelectorTimeSeries: 1441 return &AlertTsInfo_FieldTerminalPathValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.([]*Alert_TsInfo_TimeSeries)} 1442 default: 1443 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fp.selector)) 1444 } 1445 } 1446 1447 func (fp *AlertTsInfo_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1448 return fp.WithIValue(value) 1449 } 1450 1451 func (fp *AlertTsInfo_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertTsInfo_FieldPathArrayOfValues { 1452 fpaov := &AlertTsInfo_FieldTerminalPathArrayOfValues{AlertTsInfo_FieldTerminalPath: *fp} 1453 switch fp.selector { 1454 case AlertTsInfo_FieldPathSelectorType: 1455 return &AlertTsInfo_FieldTerminalPathArrayOfValues{AlertTsInfo_FieldTerminalPath: *fp, values: values.([]Alert_TsInfo_Type)} 1456 case AlertTsInfo_FieldPathSelectorAnomalyWindowSize: 1457 return &AlertTsInfo_FieldTerminalPathArrayOfValues{AlertTsInfo_FieldTerminalPath: *fp, values: values.([]*durationpb.Duration)} 1458 case AlertTsInfo_FieldPathSelectorCommonKey: 1459 return &AlertTsInfo_FieldTerminalPathArrayOfValues{AlertTsInfo_FieldTerminalPath: *fp, values: values.([][]byte)} 1460 case AlertTsInfo_FieldPathSelectorMetricTypes: 1461 return &AlertTsInfo_FieldTerminalPathArrayOfValues{AlertTsInfo_FieldTerminalPath: *fp, values: values.([][]string)} 1462 case AlertTsInfo_FieldPathSelectorResourceTypes: 1463 return &AlertTsInfo_FieldTerminalPathArrayOfValues{AlertTsInfo_FieldTerminalPath: *fp, values: values.([][]string)} 1464 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1465 return &AlertTsInfo_FieldTerminalPathArrayOfValues{AlertTsInfo_FieldTerminalPath: *fp, values: values.([]map[string]string)} 1466 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1467 return &AlertTsInfo_FieldTerminalPathArrayOfValues{AlertTsInfo_FieldTerminalPath: *fp, values: values.([]map[string]string)} 1468 case AlertTsInfo_FieldPathSelectorTimeSeries: 1469 return &AlertTsInfo_FieldTerminalPathArrayOfValues{AlertTsInfo_FieldTerminalPath: *fp, values: values.([][]*Alert_TsInfo_TimeSeries)} 1470 default: 1471 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fp.selector)) 1472 } 1473 return fpaov 1474 } 1475 1476 func (fp *AlertTsInfo_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1477 return fp.WithIArrayOfValues(values) 1478 } 1479 1480 func (fp *AlertTsInfo_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertTsInfo_FieldPathArrayItemValue { 1481 switch fp.selector { 1482 case AlertTsInfo_FieldPathSelectorMetricTypes: 1483 return &AlertTsInfo_FieldTerminalPathArrayItemValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.(string)} 1484 case AlertTsInfo_FieldPathSelectorResourceTypes: 1485 return &AlertTsInfo_FieldTerminalPathArrayItemValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.(string)} 1486 case AlertTsInfo_FieldPathSelectorTimeSeries: 1487 return &AlertTsInfo_FieldTerminalPathArrayItemValue{AlertTsInfo_FieldTerminalPath: *fp, value: value.(*Alert_TsInfo_TimeSeries)} 1488 default: 1489 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fp.selector)) 1490 } 1491 } 1492 1493 func (fp *AlertTsInfo_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1494 return fp.WithIArrayItemValue(value) 1495 } 1496 1497 // FieldPath for map type with additional Key information 1498 type AlertTsInfo_FieldPathMap struct { 1499 key string 1500 selector AlertTsInfo_FieldPathSelector 1501 } 1502 1503 var _ AlertTsInfo_FieldPath = (*AlertTsInfo_FieldPathMap)(nil) 1504 1505 func (fpm *AlertTsInfo_FieldPathMap) Selector() AlertTsInfo_FieldPathSelector { 1506 return fpm.selector 1507 } 1508 1509 func (fpm *AlertTsInfo_FieldPathMap) Key() string { 1510 return fpm.key 1511 } 1512 1513 // String returns path representation in proto convention 1514 func (fpm *AlertTsInfo_FieldPathMap) String() string { 1515 return fpm.selector.String() + "." + fpm.key 1516 } 1517 1518 // JSONString returns path representation is JSON convention. Note that map keys are not transformed 1519 func (fpm *AlertTsInfo_FieldPathMap) JSONString() string { 1520 return strcase.ToLowerCamel(fpm.selector.String()) + "." + fpm.key 1521 } 1522 1523 // Get returns all values pointed by selected field map key from source Alert_TsInfo 1524 func (fpm *AlertTsInfo_FieldPathMap) Get(source *Alert_TsInfo) (values []interface{}) { 1525 switch fpm.selector { 1526 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1527 if value, ok := source.GetCommonMetricLabels()[fpm.key]; ok { 1528 values = append(values, value) 1529 } 1530 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1531 if value, ok := source.GetCommonResourceLabels()[fpm.key]; ok { 1532 values = append(values, value) 1533 } 1534 default: 1535 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpm.selector)) 1536 } 1537 return 1538 } 1539 1540 func (fpm *AlertTsInfo_FieldPathMap) GetRaw(source proto.Message) []interface{} { 1541 return fpm.Get(source.(*Alert_TsInfo)) 1542 } 1543 1544 // GetSingle returns value by selected field map key from source Alert_TsInfo 1545 func (fpm *AlertTsInfo_FieldPathMap) GetSingle(source *Alert_TsInfo) (interface{}, bool) { 1546 switch fpm.selector { 1547 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1548 res, ok := source.GetCommonMetricLabels()[fpm.key] 1549 return res, ok 1550 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1551 res, ok := source.GetCommonResourceLabels()[fpm.key] 1552 return res, ok 1553 default: 1554 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpm.selector)) 1555 } 1556 } 1557 1558 func (fpm *AlertTsInfo_FieldPathMap) GetSingleRaw(source proto.Message) (interface{}, bool) { 1559 return fpm.GetSingle(source.(*Alert_TsInfo)) 1560 } 1561 1562 // GetDefault returns a default value of the field type 1563 func (fpm *AlertTsInfo_FieldPathMap) GetDefault() interface{} { 1564 switch fpm.selector { 1565 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1566 var v string 1567 return v 1568 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1569 var v string 1570 return v 1571 default: 1572 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpm.selector)) 1573 } 1574 } 1575 1576 func (fpm *AlertTsInfo_FieldPathMap) ClearValue(item *Alert_TsInfo) { 1577 if item != nil { 1578 switch fpm.selector { 1579 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1580 delete(item.CommonMetricLabels, fpm.key) 1581 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1582 delete(item.CommonResourceLabels, fpm.key) 1583 default: 1584 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpm.selector)) 1585 } 1586 } 1587 } 1588 1589 func (fpm *AlertTsInfo_FieldPathMap) ClearValueRaw(item proto.Message) { 1590 fpm.ClearValue(item.(*Alert_TsInfo)) 1591 } 1592 1593 // IsLeaf - whether field path is holds simple value 1594 func (fpm *AlertTsInfo_FieldPathMap) IsLeaf() bool { 1595 switch fpm.selector { 1596 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1597 return true 1598 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1599 return true 1600 default: 1601 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpm.selector)) 1602 } 1603 } 1604 1605 func (fpm *AlertTsInfo_FieldPathMap) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1606 return []gotenobject.FieldPath{fpm} 1607 } 1608 1609 func (fpm *AlertTsInfo_FieldPathMap) WithIValue(value interface{}) AlertTsInfo_FieldPathValue { 1610 switch fpm.selector { 1611 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1612 return &AlertTsInfo_FieldPathMapValue{AlertTsInfo_FieldPathMap: *fpm, value: value.(string)} 1613 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1614 return &AlertTsInfo_FieldPathMapValue{AlertTsInfo_FieldPathMap: *fpm, value: value.(string)} 1615 default: 1616 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpm.selector)) 1617 } 1618 } 1619 1620 func (fpm *AlertTsInfo_FieldPathMap) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1621 return fpm.WithIValue(value) 1622 } 1623 1624 func (fpm *AlertTsInfo_FieldPathMap) WithIArrayOfValues(values interface{}) AlertTsInfo_FieldPathArrayOfValues { 1625 switch fpm.selector { 1626 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1627 return &AlertTsInfo_FieldPathMapArrayOfValues{AlertTsInfo_FieldPathMap: *fpm, values: values.([]string)} 1628 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1629 return &AlertTsInfo_FieldPathMapArrayOfValues{AlertTsInfo_FieldPathMap: *fpm, values: values.([]string)} 1630 default: 1631 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpm.selector)) 1632 } 1633 } 1634 1635 func (fpm *AlertTsInfo_FieldPathMap) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1636 return fpm.WithIArrayOfValues(values) 1637 } 1638 1639 func (fpm *AlertTsInfo_FieldPathMap) WithIArrayItemValue(value interface{}) AlertTsInfo_FieldPathArrayItemValue { 1640 panic("Cannot create array item value from map fieldpath") 1641 } 1642 1643 func (fpm *AlertTsInfo_FieldPathMap) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1644 return fpm.WithIArrayItemValue(value) 1645 } 1646 1647 type AlertTsInfo_FieldSubPath struct { 1648 selector AlertTsInfo_FieldPathSelector 1649 subPath gotenobject.FieldPath 1650 } 1651 1652 var _ AlertTsInfo_FieldPath = (*AlertTsInfo_FieldSubPath)(nil) 1653 1654 func (fps *AlertTsInfo_FieldSubPath) Selector() AlertTsInfo_FieldPathSelector { 1655 return fps.selector 1656 } 1657 func (fps *AlertTsInfo_FieldSubPath) AsTimeSeriesSubPath() (AlertTsInfoTimeSeries_FieldPath, bool) { 1658 res, ok := fps.subPath.(AlertTsInfoTimeSeries_FieldPath) 1659 return res, ok 1660 } 1661 1662 // String returns path representation in proto convention 1663 func (fps *AlertTsInfo_FieldSubPath) String() string { 1664 return fps.selector.String() + "." + fps.subPath.String() 1665 } 1666 1667 // JSONString returns path representation is JSON convention 1668 func (fps *AlertTsInfo_FieldSubPath) JSONString() string { 1669 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 1670 } 1671 1672 // Get returns all values pointed by selected field from source Alert_TsInfo 1673 func (fps *AlertTsInfo_FieldSubPath) Get(source *Alert_TsInfo) (values []interface{}) { 1674 switch fps.selector { 1675 case AlertTsInfo_FieldPathSelectorTimeSeries: 1676 for _, item := range source.GetTimeSeries() { 1677 values = append(values, fps.subPath.GetRaw(item)...) 1678 } 1679 default: 1680 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fps.selector)) 1681 } 1682 return 1683 } 1684 1685 func (fps *AlertTsInfo_FieldSubPath) GetRaw(source proto.Message) []interface{} { 1686 return fps.Get(source.(*Alert_TsInfo)) 1687 } 1688 1689 // GetSingle returns value of selected field from source Alert_TsInfo 1690 func (fps *AlertTsInfo_FieldSubPath) GetSingle(source *Alert_TsInfo) (interface{}, bool) { 1691 switch fps.selector { 1692 case AlertTsInfo_FieldPathSelectorTimeSeries: 1693 if len(source.GetTimeSeries()) == 0 { 1694 return nil, false 1695 } 1696 return fps.subPath.GetSingleRaw(source.GetTimeSeries()[0]) 1697 default: 1698 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fps.selector)) 1699 } 1700 } 1701 1702 func (fps *AlertTsInfo_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1703 return fps.GetSingle(source.(*Alert_TsInfo)) 1704 } 1705 1706 // GetDefault returns a default value of the field type 1707 func (fps *AlertTsInfo_FieldSubPath) GetDefault() interface{} { 1708 return fps.subPath.GetDefault() 1709 } 1710 1711 func (fps *AlertTsInfo_FieldSubPath) ClearValue(item *Alert_TsInfo) { 1712 if item != nil { 1713 switch fps.selector { 1714 case AlertTsInfo_FieldPathSelectorTimeSeries: 1715 for _, subItem := range item.TimeSeries { 1716 fps.subPath.ClearValueRaw(subItem) 1717 } 1718 default: 1719 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fps.selector)) 1720 } 1721 } 1722 } 1723 1724 func (fps *AlertTsInfo_FieldSubPath) ClearValueRaw(item proto.Message) { 1725 fps.ClearValue(item.(*Alert_TsInfo)) 1726 } 1727 1728 // IsLeaf - whether field path is holds simple value 1729 func (fps *AlertTsInfo_FieldSubPath) IsLeaf() bool { 1730 return fps.subPath.IsLeaf() 1731 } 1732 1733 func (fps *AlertTsInfo_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1734 iPaths := []gotenobject.FieldPath{&AlertTsInfo_FieldTerminalPath{selector: fps.selector}} 1735 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 1736 return iPaths 1737 } 1738 1739 func (fps *AlertTsInfo_FieldSubPath) WithIValue(value interface{}) AlertTsInfo_FieldPathValue { 1740 return &AlertTsInfo_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 1741 } 1742 1743 func (fps *AlertTsInfo_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1744 return fps.WithIValue(value) 1745 } 1746 1747 func (fps *AlertTsInfo_FieldSubPath) WithIArrayOfValues(values interface{}) AlertTsInfo_FieldPathArrayOfValues { 1748 return &AlertTsInfo_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 1749 } 1750 1751 func (fps *AlertTsInfo_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1752 return fps.WithIArrayOfValues(values) 1753 } 1754 1755 func (fps *AlertTsInfo_FieldSubPath) WithIArrayItemValue(value interface{}) AlertTsInfo_FieldPathArrayItemValue { 1756 return &AlertTsInfo_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 1757 } 1758 1759 func (fps *AlertTsInfo_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1760 return fps.WithIArrayItemValue(value) 1761 } 1762 1763 // AlertTsInfo_FieldPathValue allows storing values for TsInfo fields according to their type 1764 type AlertTsInfo_FieldPathValue interface { 1765 AlertTsInfo_FieldPath 1766 gotenobject.FieldPathValue 1767 SetTo(target **Alert_TsInfo) 1768 CompareWith(*Alert_TsInfo) (cmp int, comparable bool) 1769 } 1770 1771 func ParseAlertTsInfo_FieldPathValue(pathStr, valueStr string) (AlertTsInfo_FieldPathValue, error) { 1772 fp, err := ParseAlertTsInfo_FieldPath(pathStr) 1773 if err != nil { 1774 return nil, err 1775 } 1776 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1777 if err != nil { 1778 return nil, status.Errorf(codes.InvalidArgument, "error parsing TsInfo field path value from %s: %v", valueStr, err) 1779 } 1780 return fpv.(AlertTsInfo_FieldPathValue), nil 1781 } 1782 1783 func MustParseAlertTsInfo_FieldPathValue(pathStr, valueStr string) AlertTsInfo_FieldPathValue { 1784 fpv, err := ParseAlertTsInfo_FieldPathValue(pathStr, valueStr) 1785 if err != nil { 1786 panic(err) 1787 } 1788 return fpv 1789 } 1790 1791 type AlertTsInfo_FieldTerminalPathValue struct { 1792 AlertTsInfo_FieldTerminalPath 1793 value interface{} 1794 } 1795 1796 var _ AlertTsInfo_FieldPathValue = (*AlertTsInfo_FieldTerminalPathValue)(nil) 1797 1798 // GetRawValue returns raw value stored under selected path for 'TsInfo' as interface{} 1799 func (fpv *AlertTsInfo_FieldTerminalPathValue) GetRawValue() interface{} { 1800 return fpv.value 1801 } 1802 func (fpv *AlertTsInfo_FieldTerminalPathValue) AsTypeValue() (Alert_TsInfo_Type, bool) { 1803 res, ok := fpv.value.(Alert_TsInfo_Type) 1804 return res, ok 1805 } 1806 func (fpv *AlertTsInfo_FieldTerminalPathValue) AsAnomalyWindowSizeValue() (*durationpb.Duration, bool) { 1807 res, ok := fpv.value.(*durationpb.Duration) 1808 return res, ok 1809 } 1810 func (fpv *AlertTsInfo_FieldTerminalPathValue) AsCommonKeyValue() ([]byte, bool) { 1811 res, ok := fpv.value.([]byte) 1812 return res, ok 1813 } 1814 func (fpv *AlertTsInfo_FieldTerminalPathValue) AsMetricTypesValue() ([]string, bool) { 1815 res, ok := fpv.value.([]string) 1816 return res, ok 1817 } 1818 func (fpv *AlertTsInfo_FieldTerminalPathValue) AsResourceTypesValue() ([]string, bool) { 1819 res, ok := fpv.value.([]string) 1820 return res, ok 1821 } 1822 func (fpv *AlertTsInfo_FieldTerminalPathValue) AsCommonMetricLabelsValue() (map[string]string, bool) { 1823 res, ok := fpv.value.(map[string]string) 1824 return res, ok 1825 } 1826 func (fpv *AlertTsInfo_FieldTerminalPathValue) AsCommonResourceLabelsValue() (map[string]string, bool) { 1827 res, ok := fpv.value.(map[string]string) 1828 return res, ok 1829 } 1830 func (fpv *AlertTsInfo_FieldTerminalPathValue) AsTimeSeriesValue() ([]*Alert_TsInfo_TimeSeries, bool) { 1831 res, ok := fpv.value.([]*Alert_TsInfo_TimeSeries) 1832 return res, ok 1833 } 1834 1835 // SetTo stores value for selected field for object TsInfo 1836 func (fpv *AlertTsInfo_FieldTerminalPathValue) SetTo(target **Alert_TsInfo) { 1837 if *target == nil { 1838 *target = new(Alert_TsInfo) 1839 } 1840 switch fpv.selector { 1841 case AlertTsInfo_FieldPathSelectorType: 1842 (*target).Type = fpv.value.(Alert_TsInfo_Type) 1843 case AlertTsInfo_FieldPathSelectorAnomalyWindowSize: 1844 (*target).AnomalyWindowSize = fpv.value.(*durationpb.Duration) 1845 case AlertTsInfo_FieldPathSelectorCommonKey: 1846 (*target).CommonKey = fpv.value.([]byte) 1847 case AlertTsInfo_FieldPathSelectorMetricTypes: 1848 (*target).MetricTypes = fpv.value.([]string) 1849 case AlertTsInfo_FieldPathSelectorResourceTypes: 1850 (*target).ResourceTypes = fpv.value.([]string) 1851 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1852 (*target).CommonMetricLabels = fpv.value.(map[string]string) 1853 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1854 (*target).CommonResourceLabels = fpv.value.(map[string]string) 1855 case AlertTsInfo_FieldPathSelectorTimeSeries: 1856 (*target).TimeSeries = fpv.value.([]*Alert_TsInfo_TimeSeries) 1857 default: 1858 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpv.selector)) 1859 } 1860 } 1861 1862 func (fpv *AlertTsInfo_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1863 typedObject := target.(*Alert_TsInfo) 1864 fpv.SetTo(&typedObject) 1865 } 1866 1867 // CompareWith compares value in the 'AlertTsInfo_FieldTerminalPathValue' with the value under path in 'Alert_TsInfo'. 1868 func (fpv *AlertTsInfo_FieldTerminalPathValue) CompareWith(source *Alert_TsInfo) (int, bool) { 1869 switch fpv.selector { 1870 case AlertTsInfo_FieldPathSelectorType: 1871 leftValue := fpv.value.(Alert_TsInfo_Type) 1872 rightValue := source.GetType() 1873 if (leftValue) == (rightValue) { 1874 return 0, true 1875 } else if (leftValue) < (rightValue) { 1876 return -1, true 1877 } else { 1878 return 1, true 1879 } 1880 case AlertTsInfo_FieldPathSelectorAnomalyWindowSize: 1881 leftValue := fpv.value.(*durationpb.Duration) 1882 rightValue := source.GetAnomalyWindowSize() 1883 if leftValue == nil { 1884 if rightValue != nil { 1885 return -1, true 1886 } 1887 return 0, true 1888 } 1889 if rightValue == nil { 1890 return 1, true 1891 } 1892 if leftValue.AsDuration() == rightValue.AsDuration() { 1893 return 0, true 1894 } else if leftValue.AsDuration() < rightValue.AsDuration() { 1895 return -1, true 1896 } else { 1897 return 1, true 1898 } 1899 case AlertTsInfo_FieldPathSelectorCommonKey: 1900 return 0, false 1901 case AlertTsInfo_FieldPathSelectorMetricTypes: 1902 return 0, false 1903 case AlertTsInfo_FieldPathSelectorResourceTypes: 1904 return 0, false 1905 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1906 return 0, false 1907 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1908 return 0, false 1909 case AlertTsInfo_FieldPathSelectorTimeSeries: 1910 return 0, false 1911 default: 1912 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpv.selector)) 1913 } 1914 } 1915 1916 func (fpv *AlertTsInfo_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1917 return fpv.CompareWith(source.(*Alert_TsInfo)) 1918 } 1919 1920 type AlertTsInfo_FieldPathMapValue struct { 1921 AlertTsInfo_FieldPathMap 1922 value interface{} 1923 } 1924 1925 var _ AlertTsInfo_FieldPathValue = (*AlertTsInfo_FieldPathMapValue)(nil) 1926 1927 // GetValue returns value stored under selected field in TsInfo as interface{} 1928 func (fpmv *AlertTsInfo_FieldPathMapValue) GetRawValue() interface{} { 1929 return fpmv.value 1930 } 1931 func (fpmv *AlertTsInfo_FieldPathMapValue) AsCommonMetricLabelsElementValue() (string, bool) { 1932 res, ok := fpmv.value.(string) 1933 return res, ok 1934 } 1935 func (fpmv *AlertTsInfo_FieldPathMapValue) AsCommonResourceLabelsElementValue() (string, bool) { 1936 res, ok := fpmv.value.(string) 1937 return res, ok 1938 } 1939 1940 // SetTo stores value for selected field in TsInfo 1941 func (fpmv *AlertTsInfo_FieldPathMapValue) SetTo(target **Alert_TsInfo) { 1942 if *target == nil { 1943 *target = new(Alert_TsInfo) 1944 } 1945 switch fpmv.selector { 1946 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1947 if (*target).CommonMetricLabels == nil { 1948 (*target).CommonMetricLabels = make(map[string]string) 1949 } 1950 (*target).CommonMetricLabels[fpmv.key] = fpmv.value.(string) 1951 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1952 if (*target).CommonResourceLabels == nil { 1953 (*target).CommonResourceLabels = make(map[string]string) 1954 } 1955 (*target).CommonResourceLabels[fpmv.key] = fpmv.value.(string) 1956 default: 1957 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpmv.selector)) 1958 } 1959 } 1960 1961 func (fpmv *AlertTsInfo_FieldPathMapValue) SetToRaw(target proto.Message) { 1962 typedObject := target.(*Alert_TsInfo) 1963 fpmv.SetTo(&typedObject) 1964 } 1965 1966 // CompareWith compares value in the 'AlertTsInfo_FieldPathMapValue' with the value under path in 'Alert_TsInfo'. 1967 func (fpmv *AlertTsInfo_FieldPathMapValue) CompareWith(source *Alert_TsInfo) (int, bool) { 1968 switch fpmv.selector { 1969 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 1970 leftValue := fpmv.value.(string) 1971 rightValue := source.GetCommonMetricLabels()[fpmv.key] 1972 if (leftValue) == (rightValue) { 1973 return 0, true 1974 } else if (leftValue) < (rightValue) { 1975 return -1, true 1976 } else { 1977 return 1, true 1978 } 1979 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 1980 leftValue := fpmv.value.(string) 1981 rightValue := source.GetCommonResourceLabels()[fpmv.key] 1982 if (leftValue) == (rightValue) { 1983 return 0, true 1984 } else if (leftValue) < (rightValue) { 1985 return -1, true 1986 } else { 1987 return 1, true 1988 } 1989 default: 1990 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpmv.selector)) 1991 } 1992 } 1993 1994 func (fpmv *AlertTsInfo_FieldPathMapValue) CompareWithRaw(source proto.Message) (int, bool) { 1995 return fpmv.CompareWith(source.(*Alert_TsInfo)) 1996 } 1997 1998 type AlertTsInfo_FieldSubPathValue struct { 1999 AlertTsInfo_FieldPath 2000 subPathValue gotenobject.FieldPathValue 2001 } 2002 2003 var _ AlertTsInfo_FieldPathValue = (*AlertTsInfo_FieldSubPathValue)(nil) 2004 2005 func (fpvs *AlertTsInfo_FieldSubPathValue) AsTimeSeriesPathValue() (AlertTsInfoTimeSeries_FieldPathValue, bool) { 2006 res, ok := fpvs.subPathValue.(AlertTsInfoTimeSeries_FieldPathValue) 2007 return res, ok 2008 } 2009 2010 func (fpvs *AlertTsInfo_FieldSubPathValue) SetTo(target **Alert_TsInfo) { 2011 if *target == nil { 2012 *target = new(Alert_TsInfo) 2013 } 2014 switch fpvs.Selector() { 2015 case AlertTsInfo_FieldPathSelectorTimeSeries: 2016 panic("FieldPath setter is unsupported for array subpaths") 2017 default: 2018 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpvs.Selector())) 2019 } 2020 } 2021 2022 func (fpvs *AlertTsInfo_FieldSubPathValue) SetToRaw(target proto.Message) { 2023 typedObject := target.(*Alert_TsInfo) 2024 fpvs.SetTo(&typedObject) 2025 } 2026 2027 func (fpvs *AlertTsInfo_FieldSubPathValue) GetRawValue() interface{} { 2028 return fpvs.subPathValue.GetRawValue() 2029 } 2030 2031 func (fpvs *AlertTsInfo_FieldSubPathValue) CompareWith(source *Alert_TsInfo) (int, bool) { 2032 switch fpvs.Selector() { 2033 case AlertTsInfo_FieldPathSelectorTimeSeries: 2034 return 0, false // repeated field 2035 default: 2036 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpvs.Selector())) 2037 } 2038 } 2039 2040 func (fpvs *AlertTsInfo_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2041 return fpvs.CompareWith(source.(*Alert_TsInfo)) 2042 } 2043 2044 // AlertTsInfo_FieldPathArrayItemValue allows storing single item in Path-specific values for TsInfo according to their type 2045 // Present only for array (repeated) types. 2046 type AlertTsInfo_FieldPathArrayItemValue interface { 2047 gotenobject.FieldPathArrayItemValue 2048 AlertTsInfo_FieldPath 2049 ContainsValue(*Alert_TsInfo) bool 2050 } 2051 2052 // ParseAlertTsInfo_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 2053 func ParseAlertTsInfo_FieldPathArrayItemValue(pathStr, valueStr string) (AlertTsInfo_FieldPathArrayItemValue, error) { 2054 fp, err := ParseAlertTsInfo_FieldPath(pathStr) 2055 if err != nil { 2056 return nil, err 2057 } 2058 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 2059 if err != nil { 2060 return nil, status.Errorf(codes.InvalidArgument, "error parsing TsInfo field path array item value from %s: %v", valueStr, err) 2061 } 2062 return fpaiv.(AlertTsInfo_FieldPathArrayItemValue), nil 2063 } 2064 2065 func MustParseAlertTsInfo_FieldPathArrayItemValue(pathStr, valueStr string) AlertTsInfo_FieldPathArrayItemValue { 2066 fpaiv, err := ParseAlertTsInfo_FieldPathArrayItemValue(pathStr, valueStr) 2067 if err != nil { 2068 panic(err) 2069 } 2070 return fpaiv 2071 } 2072 2073 type AlertTsInfo_FieldTerminalPathArrayItemValue struct { 2074 AlertTsInfo_FieldTerminalPath 2075 value interface{} 2076 } 2077 2078 var _ AlertTsInfo_FieldPathArrayItemValue = (*AlertTsInfo_FieldTerminalPathArrayItemValue)(nil) 2079 2080 // GetRawValue returns stored element value for array in object Alert_TsInfo as interface{} 2081 func (fpaiv *AlertTsInfo_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 2082 return fpaiv.value 2083 } 2084 func (fpaiv *AlertTsInfo_FieldTerminalPathArrayItemValue) AsMetricTypesItemValue() (string, bool) { 2085 res, ok := fpaiv.value.(string) 2086 return res, ok 2087 } 2088 func (fpaiv *AlertTsInfo_FieldTerminalPathArrayItemValue) AsResourceTypesItemValue() (string, bool) { 2089 res, ok := fpaiv.value.(string) 2090 return res, ok 2091 } 2092 func (fpaiv *AlertTsInfo_FieldTerminalPathArrayItemValue) AsTimeSeriesItemValue() (*Alert_TsInfo_TimeSeries, bool) { 2093 res, ok := fpaiv.value.(*Alert_TsInfo_TimeSeries) 2094 return res, ok 2095 } 2096 2097 func (fpaiv *AlertTsInfo_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_TsInfo) (interface{}, bool) { 2098 return nil, false 2099 } 2100 2101 func (fpaiv *AlertTsInfo_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 2102 return fpaiv.GetSingle(source.(*Alert_TsInfo)) 2103 } 2104 2105 // Contains returns a boolean indicating if value that is being held is present in given 'TsInfo' 2106 func (fpaiv *AlertTsInfo_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_TsInfo) bool { 2107 slice := fpaiv.AlertTsInfo_FieldTerminalPath.Get(source) 2108 for _, v := range slice { 2109 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 2110 if proto.Equal(asProtoMsg, v.(proto.Message)) { 2111 return true 2112 } 2113 } else if reflect.DeepEqual(v, fpaiv.value) { 2114 return true 2115 } 2116 } 2117 return false 2118 } 2119 2120 type AlertTsInfo_FieldSubPathArrayItemValue struct { 2121 AlertTsInfo_FieldPath 2122 subPathItemValue gotenobject.FieldPathArrayItemValue 2123 } 2124 2125 // GetRawValue returns stored array item value 2126 func (fpaivs *AlertTsInfo_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 2127 return fpaivs.subPathItemValue.GetRawItemValue() 2128 } 2129 func (fpaivs *AlertTsInfo_FieldSubPathArrayItemValue) AsTimeSeriesPathItemValue() (AlertTsInfoTimeSeries_FieldPathArrayItemValue, bool) { 2130 res, ok := fpaivs.subPathItemValue.(AlertTsInfoTimeSeries_FieldPathArrayItemValue) 2131 return res, ok 2132 } 2133 2134 // Contains returns a boolean indicating if value that is being held is present in given 'TsInfo' 2135 func (fpaivs *AlertTsInfo_FieldSubPathArrayItemValue) ContainsValue(source *Alert_TsInfo) bool { 2136 switch fpaivs.Selector() { 2137 case AlertTsInfo_FieldPathSelectorTimeSeries: 2138 return false // repeated/map field 2139 default: 2140 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo: %d", fpaivs.Selector())) 2141 } 2142 } 2143 2144 // AlertTsInfo_FieldPathArrayOfValues allows storing slice of values for TsInfo fields according to their type 2145 type AlertTsInfo_FieldPathArrayOfValues interface { 2146 gotenobject.FieldPathArrayOfValues 2147 AlertTsInfo_FieldPath 2148 } 2149 2150 func ParseAlertTsInfo_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertTsInfo_FieldPathArrayOfValues, error) { 2151 fp, err := ParseAlertTsInfo_FieldPath(pathStr) 2152 if err != nil { 2153 return nil, err 2154 } 2155 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 2156 if err != nil { 2157 return nil, status.Errorf(codes.InvalidArgument, "error parsing TsInfo field path array of values from %s: %v", valuesStr, err) 2158 } 2159 return fpaov.(AlertTsInfo_FieldPathArrayOfValues), nil 2160 } 2161 2162 func MustParseAlertTsInfo_FieldPathArrayOfValues(pathStr, valuesStr string) AlertTsInfo_FieldPathArrayOfValues { 2163 fpaov, err := ParseAlertTsInfo_FieldPathArrayOfValues(pathStr, valuesStr) 2164 if err != nil { 2165 panic(err) 2166 } 2167 return fpaov 2168 } 2169 2170 type AlertTsInfo_FieldTerminalPathArrayOfValues struct { 2171 AlertTsInfo_FieldTerminalPath 2172 values interface{} 2173 } 2174 2175 var _ AlertTsInfo_FieldPathArrayOfValues = (*AlertTsInfo_FieldTerminalPathArrayOfValues)(nil) 2176 2177 func (fpaov *AlertTsInfo_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 2178 switch fpaov.selector { 2179 case AlertTsInfo_FieldPathSelectorType: 2180 for _, v := range fpaov.values.([]Alert_TsInfo_Type) { 2181 values = append(values, v) 2182 } 2183 case AlertTsInfo_FieldPathSelectorAnomalyWindowSize: 2184 for _, v := range fpaov.values.([]*durationpb.Duration) { 2185 values = append(values, v) 2186 } 2187 case AlertTsInfo_FieldPathSelectorCommonKey: 2188 for _, v := range fpaov.values.([][]byte) { 2189 values = append(values, v) 2190 } 2191 case AlertTsInfo_FieldPathSelectorMetricTypes: 2192 for _, v := range fpaov.values.([][]string) { 2193 values = append(values, v) 2194 } 2195 case AlertTsInfo_FieldPathSelectorResourceTypes: 2196 for _, v := range fpaov.values.([][]string) { 2197 values = append(values, v) 2198 } 2199 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 2200 for _, v := range fpaov.values.([]map[string]string) { 2201 values = append(values, v) 2202 } 2203 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 2204 for _, v := range fpaov.values.([]map[string]string) { 2205 values = append(values, v) 2206 } 2207 case AlertTsInfo_FieldPathSelectorTimeSeries: 2208 for _, v := range fpaov.values.([][]*Alert_TsInfo_TimeSeries) { 2209 values = append(values, v) 2210 } 2211 } 2212 return 2213 } 2214 func (fpaov *AlertTsInfo_FieldTerminalPathArrayOfValues) AsTypeArrayOfValues() ([]Alert_TsInfo_Type, bool) { 2215 res, ok := fpaov.values.([]Alert_TsInfo_Type) 2216 return res, ok 2217 } 2218 func (fpaov *AlertTsInfo_FieldTerminalPathArrayOfValues) AsAnomalyWindowSizeArrayOfValues() ([]*durationpb.Duration, bool) { 2219 res, ok := fpaov.values.([]*durationpb.Duration) 2220 return res, ok 2221 } 2222 func (fpaov *AlertTsInfo_FieldTerminalPathArrayOfValues) AsCommonKeyArrayOfValues() ([][]byte, bool) { 2223 res, ok := fpaov.values.([][]byte) 2224 return res, ok 2225 } 2226 func (fpaov *AlertTsInfo_FieldTerminalPathArrayOfValues) AsMetricTypesArrayOfValues() ([][]string, bool) { 2227 res, ok := fpaov.values.([][]string) 2228 return res, ok 2229 } 2230 func (fpaov *AlertTsInfo_FieldTerminalPathArrayOfValues) AsResourceTypesArrayOfValues() ([][]string, bool) { 2231 res, ok := fpaov.values.([][]string) 2232 return res, ok 2233 } 2234 func (fpaov *AlertTsInfo_FieldTerminalPathArrayOfValues) AsCommonMetricLabelsArrayOfValues() ([]map[string]string, bool) { 2235 res, ok := fpaov.values.([]map[string]string) 2236 return res, ok 2237 } 2238 func (fpaov *AlertTsInfo_FieldTerminalPathArrayOfValues) AsCommonResourceLabelsArrayOfValues() ([]map[string]string, bool) { 2239 res, ok := fpaov.values.([]map[string]string) 2240 return res, ok 2241 } 2242 func (fpaov *AlertTsInfo_FieldTerminalPathArrayOfValues) AsTimeSeriesArrayOfValues() ([][]*Alert_TsInfo_TimeSeries, bool) { 2243 res, ok := fpaov.values.([][]*Alert_TsInfo_TimeSeries) 2244 return res, ok 2245 } 2246 2247 type AlertTsInfo_FieldPathMapArrayOfValues struct { 2248 AlertTsInfo_FieldPathMap 2249 values interface{} 2250 } 2251 2252 var _ AlertTsInfo_FieldPathArrayOfValues = (*AlertTsInfo_FieldPathMapArrayOfValues)(nil) 2253 2254 func (fpmaov *AlertTsInfo_FieldPathMapArrayOfValues) GetRawValues() (values []interface{}) { 2255 switch fpmaov.selector { 2256 case AlertTsInfo_FieldPathSelectorCommonMetricLabels: 2257 for _, v := range fpmaov.values.([]string) { 2258 values = append(values, v) 2259 } 2260 case AlertTsInfo_FieldPathSelectorCommonResourceLabels: 2261 for _, v := range fpmaov.values.([]string) { 2262 values = append(values, v) 2263 } 2264 } 2265 return 2266 } 2267 func (fpmaov *AlertTsInfo_FieldPathMapArrayOfValues) AsCommonMetricLabelsArrayOfElementValues() ([]string, bool) { 2268 res, ok := fpmaov.values.([]string) 2269 return res, ok 2270 } 2271 func (fpmaov *AlertTsInfo_FieldPathMapArrayOfValues) AsCommonResourceLabelsArrayOfElementValues() ([]string, bool) { 2272 res, ok := fpmaov.values.([]string) 2273 return res, ok 2274 } 2275 2276 type AlertTsInfo_FieldSubPathArrayOfValues struct { 2277 AlertTsInfo_FieldPath 2278 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 2279 } 2280 2281 var _ AlertTsInfo_FieldPathArrayOfValues = (*AlertTsInfo_FieldSubPathArrayOfValues)(nil) 2282 2283 func (fpsaov *AlertTsInfo_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 2284 return fpsaov.subPathArrayOfValues.GetRawValues() 2285 } 2286 func (fpsaov *AlertTsInfo_FieldSubPathArrayOfValues) AsTimeSeriesPathArrayOfValues() (AlertTsInfoTimeSeries_FieldPathArrayOfValues, bool) { 2287 res, ok := fpsaov.subPathArrayOfValues.(AlertTsInfoTimeSeries_FieldPathArrayOfValues) 2288 return res, ok 2289 } 2290 2291 // FieldPath provides implementation to handle 2292 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 2293 type AlertLogInfo_FieldPath interface { 2294 gotenobject.FieldPath 2295 Selector() AlertLogInfo_FieldPathSelector 2296 Get(source *Alert_LogInfo) []interface{} 2297 GetSingle(source *Alert_LogInfo) (interface{}, bool) 2298 ClearValue(item *Alert_LogInfo) 2299 2300 // Those methods build corresponding AlertLogInfo_FieldPathValue 2301 // (or array of values) and holds passed value. Panics if injected type is incorrect. 2302 WithIValue(value interface{}) AlertLogInfo_FieldPathValue 2303 WithIArrayOfValues(values interface{}) AlertLogInfo_FieldPathArrayOfValues 2304 WithIArrayItemValue(value interface{}) AlertLogInfo_FieldPathArrayItemValue 2305 } 2306 2307 type AlertLogInfo_FieldPathSelector int32 2308 2309 const ( 2310 AlertLogInfo_FieldPathSelectorCommonKey AlertLogInfo_FieldPathSelector = 0 2311 AlertLogInfo_FieldPathSelectorLogTypes AlertLogInfo_FieldPathSelector = 1 2312 AlertLogInfo_FieldPathSelectorCommonLogLabels AlertLogInfo_FieldPathSelector = 2 2313 AlertLogInfo_FieldPathSelectorViolatingLog AlertLogInfo_FieldPathSelector = 3 2314 ) 2315 2316 func (s AlertLogInfo_FieldPathSelector) String() string { 2317 switch s { 2318 case AlertLogInfo_FieldPathSelectorCommonKey: 2319 return "common_key" 2320 case AlertLogInfo_FieldPathSelectorLogTypes: 2321 return "log_types" 2322 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2323 return "common_log_labels" 2324 case AlertLogInfo_FieldPathSelectorViolatingLog: 2325 return "violating_log" 2326 default: 2327 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", s)) 2328 } 2329 } 2330 2331 func BuildAlertLogInfo_FieldPath(fp gotenobject.RawFieldPath) (AlertLogInfo_FieldPath, error) { 2332 if len(fp) == 0 { 2333 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_LogInfo") 2334 } 2335 if len(fp) == 1 { 2336 switch fp[0] { 2337 case "common_key", "commonKey", "common-key": 2338 return &AlertLogInfo_FieldTerminalPath{selector: AlertLogInfo_FieldPathSelectorCommonKey}, nil 2339 case "log_types", "logTypes", "log-types": 2340 return &AlertLogInfo_FieldTerminalPath{selector: AlertLogInfo_FieldPathSelectorLogTypes}, nil 2341 case "common_log_labels", "commonLogLabels", "common-log-labels": 2342 return &AlertLogInfo_FieldTerminalPath{selector: AlertLogInfo_FieldPathSelectorCommonLogLabels}, nil 2343 case "violating_log", "violatingLog", "violating-log": 2344 return &AlertLogInfo_FieldTerminalPath{selector: AlertLogInfo_FieldPathSelectorViolatingLog}, nil 2345 } 2346 } else { 2347 switch fp[0] { 2348 case "common_log_labels", "commonLogLabels", "common-log-labels": 2349 if len(fp) > 2 { 2350 return nil, status.Errorf(codes.InvalidArgument, "sub path for maps ('%s') are not supported (object Alert_LogInfo)", fp) 2351 } 2352 return &AlertLogInfo_FieldPathMap{selector: AlertLogInfo_FieldPathSelectorCommonLogLabels, key: fp[1]}, nil 2353 } 2354 } 2355 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_LogInfo", fp) 2356 } 2357 2358 func ParseAlertLogInfo_FieldPath(rawField string) (AlertLogInfo_FieldPath, error) { 2359 fp, err := gotenobject.ParseRawFieldPath(rawField) 2360 if err != nil { 2361 return nil, err 2362 } 2363 return BuildAlertLogInfo_FieldPath(fp) 2364 } 2365 2366 func MustParseAlertLogInfo_FieldPath(rawField string) AlertLogInfo_FieldPath { 2367 fp, err := ParseAlertLogInfo_FieldPath(rawField) 2368 if err != nil { 2369 panic(err) 2370 } 2371 return fp 2372 } 2373 2374 type AlertLogInfo_FieldTerminalPath struct { 2375 selector AlertLogInfo_FieldPathSelector 2376 } 2377 2378 var _ AlertLogInfo_FieldPath = (*AlertLogInfo_FieldTerminalPath)(nil) 2379 2380 func (fp *AlertLogInfo_FieldTerminalPath) Selector() AlertLogInfo_FieldPathSelector { 2381 return fp.selector 2382 } 2383 2384 // String returns path representation in proto convention 2385 func (fp *AlertLogInfo_FieldTerminalPath) String() string { 2386 return fp.selector.String() 2387 } 2388 2389 // JSONString returns path representation is JSON convention 2390 func (fp *AlertLogInfo_FieldTerminalPath) JSONString() string { 2391 return strcase.ToLowerCamel(fp.String()) 2392 } 2393 2394 // Get returns all values pointed by specific field from source Alert_LogInfo 2395 func (fp *AlertLogInfo_FieldTerminalPath) Get(source *Alert_LogInfo) (values []interface{}) { 2396 if source != nil { 2397 switch fp.selector { 2398 case AlertLogInfo_FieldPathSelectorCommonKey: 2399 values = append(values, source.CommonKey) 2400 case AlertLogInfo_FieldPathSelectorLogTypes: 2401 for _, value := range source.GetLogTypes() { 2402 values = append(values, value) 2403 } 2404 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2405 values = append(values, source.CommonLogLabels) 2406 case AlertLogInfo_FieldPathSelectorViolatingLog: 2407 values = append(values, source.ViolatingLog) 2408 default: 2409 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fp.selector)) 2410 } 2411 } 2412 return 2413 } 2414 2415 func (fp *AlertLogInfo_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 2416 return fp.Get(source.(*Alert_LogInfo)) 2417 } 2418 2419 // GetSingle returns value pointed by specific field of from source Alert_LogInfo 2420 func (fp *AlertLogInfo_FieldTerminalPath) GetSingle(source *Alert_LogInfo) (interface{}, bool) { 2421 switch fp.selector { 2422 case AlertLogInfo_FieldPathSelectorCommonKey: 2423 res := source.GetCommonKey() 2424 return res, res != nil 2425 case AlertLogInfo_FieldPathSelectorLogTypes: 2426 res := source.GetLogTypes() 2427 return res, res != nil 2428 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2429 res := source.GetCommonLogLabels() 2430 return res, res != nil 2431 case AlertLogInfo_FieldPathSelectorViolatingLog: 2432 return source.GetViolatingLog(), source != nil 2433 default: 2434 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fp.selector)) 2435 } 2436 } 2437 2438 func (fp *AlertLogInfo_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 2439 return fp.GetSingle(source.(*Alert_LogInfo)) 2440 } 2441 2442 // GetDefault returns a default value of the field type 2443 func (fp *AlertLogInfo_FieldTerminalPath) GetDefault() interface{} { 2444 switch fp.selector { 2445 case AlertLogInfo_FieldPathSelectorCommonKey: 2446 return ([]byte)(nil) 2447 case AlertLogInfo_FieldPathSelectorLogTypes: 2448 return ([]string)(nil) 2449 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2450 return (map[string]string)(nil) 2451 case AlertLogInfo_FieldPathSelectorViolatingLog: 2452 return "" 2453 default: 2454 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fp.selector)) 2455 } 2456 } 2457 2458 func (fp *AlertLogInfo_FieldTerminalPath) ClearValue(item *Alert_LogInfo) { 2459 if item != nil { 2460 switch fp.selector { 2461 case AlertLogInfo_FieldPathSelectorCommonKey: 2462 item.CommonKey = nil 2463 case AlertLogInfo_FieldPathSelectorLogTypes: 2464 item.LogTypes = nil 2465 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2466 item.CommonLogLabels = nil 2467 case AlertLogInfo_FieldPathSelectorViolatingLog: 2468 item.ViolatingLog = "" 2469 default: 2470 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fp.selector)) 2471 } 2472 } 2473 } 2474 2475 func (fp *AlertLogInfo_FieldTerminalPath) ClearValueRaw(item proto.Message) { 2476 fp.ClearValue(item.(*Alert_LogInfo)) 2477 } 2478 2479 // IsLeaf - whether field path is holds simple value 2480 func (fp *AlertLogInfo_FieldTerminalPath) IsLeaf() bool { 2481 return fp.selector == AlertLogInfo_FieldPathSelectorCommonKey || 2482 fp.selector == AlertLogInfo_FieldPathSelectorLogTypes || 2483 fp.selector == AlertLogInfo_FieldPathSelectorCommonLogLabels || 2484 fp.selector == AlertLogInfo_FieldPathSelectorViolatingLog 2485 } 2486 2487 func (fp *AlertLogInfo_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 2488 return []gotenobject.FieldPath{fp} 2489 } 2490 2491 func (fp *AlertLogInfo_FieldTerminalPath) WithIValue(value interface{}) AlertLogInfo_FieldPathValue { 2492 switch fp.selector { 2493 case AlertLogInfo_FieldPathSelectorCommonKey: 2494 return &AlertLogInfo_FieldTerminalPathValue{AlertLogInfo_FieldTerminalPath: *fp, value: value.([]byte)} 2495 case AlertLogInfo_FieldPathSelectorLogTypes: 2496 return &AlertLogInfo_FieldTerminalPathValue{AlertLogInfo_FieldTerminalPath: *fp, value: value.([]string)} 2497 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2498 return &AlertLogInfo_FieldTerminalPathValue{AlertLogInfo_FieldTerminalPath: *fp, value: value.(map[string]string)} 2499 case AlertLogInfo_FieldPathSelectorViolatingLog: 2500 return &AlertLogInfo_FieldTerminalPathValue{AlertLogInfo_FieldTerminalPath: *fp, value: value.(string)} 2501 default: 2502 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fp.selector)) 2503 } 2504 } 2505 2506 func (fp *AlertLogInfo_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 2507 return fp.WithIValue(value) 2508 } 2509 2510 func (fp *AlertLogInfo_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertLogInfo_FieldPathArrayOfValues { 2511 fpaov := &AlertLogInfo_FieldTerminalPathArrayOfValues{AlertLogInfo_FieldTerminalPath: *fp} 2512 switch fp.selector { 2513 case AlertLogInfo_FieldPathSelectorCommonKey: 2514 return &AlertLogInfo_FieldTerminalPathArrayOfValues{AlertLogInfo_FieldTerminalPath: *fp, values: values.([][]byte)} 2515 case AlertLogInfo_FieldPathSelectorLogTypes: 2516 return &AlertLogInfo_FieldTerminalPathArrayOfValues{AlertLogInfo_FieldTerminalPath: *fp, values: values.([][]string)} 2517 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2518 return &AlertLogInfo_FieldTerminalPathArrayOfValues{AlertLogInfo_FieldTerminalPath: *fp, values: values.([]map[string]string)} 2519 case AlertLogInfo_FieldPathSelectorViolatingLog: 2520 return &AlertLogInfo_FieldTerminalPathArrayOfValues{AlertLogInfo_FieldTerminalPath: *fp, values: values.([]string)} 2521 default: 2522 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fp.selector)) 2523 } 2524 return fpaov 2525 } 2526 2527 func (fp *AlertLogInfo_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 2528 return fp.WithIArrayOfValues(values) 2529 } 2530 2531 func (fp *AlertLogInfo_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertLogInfo_FieldPathArrayItemValue { 2532 switch fp.selector { 2533 case AlertLogInfo_FieldPathSelectorLogTypes: 2534 return &AlertLogInfo_FieldTerminalPathArrayItemValue{AlertLogInfo_FieldTerminalPath: *fp, value: value.(string)} 2535 default: 2536 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fp.selector)) 2537 } 2538 } 2539 2540 func (fp *AlertLogInfo_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 2541 return fp.WithIArrayItemValue(value) 2542 } 2543 2544 // FieldPath for map type with additional Key information 2545 type AlertLogInfo_FieldPathMap struct { 2546 key string 2547 selector AlertLogInfo_FieldPathSelector 2548 } 2549 2550 var _ AlertLogInfo_FieldPath = (*AlertLogInfo_FieldPathMap)(nil) 2551 2552 func (fpm *AlertLogInfo_FieldPathMap) Selector() AlertLogInfo_FieldPathSelector { 2553 return fpm.selector 2554 } 2555 2556 func (fpm *AlertLogInfo_FieldPathMap) Key() string { 2557 return fpm.key 2558 } 2559 2560 // String returns path representation in proto convention 2561 func (fpm *AlertLogInfo_FieldPathMap) String() string { 2562 return fpm.selector.String() + "." + fpm.key 2563 } 2564 2565 // JSONString returns path representation is JSON convention. Note that map keys are not transformed 2566 func (fpm *AlertLogInfo_FieldPathMap) JSONString() string { 2567 return strcase.ToLowerCamel(fpm.selector.String()) + "." + fpm.key 2568 } 2569 2570 // Get returns all values pointed by selected field map key from source Alert_LogInfo 2571 func (fpm *AlertLogInfo_FieldPathMap) Get(source *Alert_LogInfo) (values []interface{}) { 2572 switch fpm.selector { 2573 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2574 if value, ok := source.GetCommonLogLabels()[fpm.key]; ok { 2575 values = append(values, value) 2576 } 2577 default: 2578 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpm.selector)) 2579 } 2580 return 2581 } 2582 2583 func (fpm *AlertLogInfo_FieldPathMap) GetRaw(source proto.Message) []interface{} { 2584 return fpm.Get(source.(*Alert_LogInfo)) 2585 } 2586 2587 // GetSingle returns value by selected field map key from source Alert_LogInfo 2588 func (fpm *AlertLogInfo_FieldPathMap) GetSingle(source *Alert_LogInfo) (interface{}, bool) { 2589 switch fpm.selector { 2590 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2591 res, ok := source.GetCommonLogLabels()[fpm.key] 2592 return res, ok 2593 default: 2594 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpm.selector)) 2595 } 2596 } 2597 2598 func (fpm *AlertLogInfo_FieldPathMap) GetSingleRaw(source proto.Message) (interface{}, bool) { 2599 return fpm.GetSingle(source.(*Alert_LogInfo)) 2600 } 2601 2602 // GetDefault returns a default value of the field type 2603 func (fpm *AlertLogInfo_FieldPathMap) GetDefault() interface{} { 2604 switch fpm.selector { 2605 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2606 var v string 2607 return v 2608 default: 2609 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpm.selector)) 2610 } 2611 } 2612 2613 func (fpm *AlertLogInfo_FieldPathMap) ClearValue(item *Alert_LogInfo) { 2614 if item != nil { 2615 switch fpm.selector { 2616 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2617 delete(item.CommonLogLabels, fpm.key) 2618 default: 2619 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpm.selector)) 2620 } 2621 } 2622 } 2623 2624 func (fpm *AlertLogInfo_FieldPathMap) ClearValueRaw(item proto.Message) { 2625 fpm.ClearValue(item.(*Alert_LogInfo)) 2626 } 2627 2628 // IsLeaf - whether field path is holds simple value 2629 func (fpm *AlertLogInfo_FieldPathMap) IsLeaf() bool { 2630 switch fpm.selector { 2631 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2632 return true 2633 default: 2634 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpm.selector)) 2635 } 2636 } 2637 2638 func (fpm *AlertLogInfo_FieldPathMap) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 2639 return []gotenobject.FieldPath{fpm} 2640 } 2641 2642 func (fpm *AlertLogInfo_FieldPathMap) WithIValue(value interface{}) AlertLogInfo_FieldPathValue { 2643 switch fpm.selector { 2644 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2645 return &AlertLogInfo_FieldPathMapValue{AlertLogInfo_FieldPathMap: *fpm, value: value.(string)} 2646 default: 2647 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpm.selector)) 2648 } 2649 } 2650 2651 func (fpm *AlertLogInfo_FieldPathMap) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 2652 return fpm.WithIValue(value) 2653 } 2654 2655 func (fpm *AlertLogInfo_FieldPathMap) WithIArrayOfValues(values interface{}) AlertLogInfo_FieldPathArrayOfValues { 2656 switch fpm.selector { 2657 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2658 return &AlertLogInfo_FieldPathMapArrayOfValues{AlertLogInfo_FieldPathMap: *fpm, values: values.([]string)} 2659 default: 2660 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpm.selector)) 2661 } 2662 } 2663 2664 func (fpm *AlertLogInfo_FieldPathMap) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 2665 return fpm.WithIArrayOfValues(values) 2666 } 2667 2668 func (fpm *AlertLogInfo_FieldPathMap) WithIArrayItemValue(value interface{}) AlertLogInfo_FieldPathArrayItemValue { 2669 panic("Cannot create array item value from map fieldpath") 2670 } 2671 2672 func (fpm *AlertLogInfo_FieldPathMap) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 2673 return fpm.WithIArrayItemValue(value) 2674 } 2675 2676 // AlertLogInfo_FieldPathValue allows storing values for LogInfo fields according to their type 2677 type AlertLogInfo_FieldPathValue interface { 2678 AlertLogInfo_FieldPath 2679 gotenobject.FieldPathValue 2680 SetTo(target **Alert_LogInfo) 2681 CompareWith(*Alert_LogInfo) (cmp int, comparable bool) 2682 } 2683 2684 func ParseAlertLogInfo_FieldPathValue(pathStr, valueStr string) (AlertLogInfo_FieldPathValue, error) { 2685 fp, err := ParseAlertLogInfo_FieldPath(pathStr) 2686 if err != nil { 2687 return nil, err 2688 } 2689 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 2690 if err != nil { 2691 return nil, status.Errorf(codes.InvalidArgument, "error parsing LogInfo field path value from %s: %v", valueStr, err) 2692 } 2693 return fpv.(AlertLogInfo_FieldPathValue), nil 2694 } 2695 2696 func MustParseAlertLogInfo_FieldPathValue(pathStr, valueStr string) AlertLogInfo_FieldPathValue { 2697 fpv, err := ParseAlertLogInfo_FieldPathValue(pathStr, valueStr) 2698 if err != nil { 2699 panic(err) 2700 } 2701 return fpv 2702 } 2703 2704 type AlertLogInfo_FieldTerminalPathValue struct { 2705 AlertLogInfo_FieldTerminalPath 2706 value interface{} 2707 } 2708 2709 var _ AlertLogInfo_FieldPathValue = (*AlertLogInfo_FieldTerminalPathValue)(nil) 2710 2711 // GetRawValue returns raw value stored under selected path for 'LogInfo' as interface{} 2712 func (fpv *AlertLogInfo_FieldTerminalPathValue) GetRawValue() interface{} { 2713 return fpv.value 2714 } 2715 func (fpv *AlertLogInfo_FieldTerminalPathValue) AsCommonKeyValue() ([]byte, bool) { 2716 res, ok := fpv.value.([]byte) 2717 return res, ok 2718 } 2719 func (fpv *AlertLogInfo_FieldTerminalPathValue) AsLogTypesValue() ([]string, bool) { 2720 res, ok := fpv.value.([]string) 2721 return res, ok 2722 } 2723 func (fpv *AlertLogInfo_FieldTerminalPathValue) AsCommonLogLabelsValue() (map[string]string, bool) { 2724 res, ok := fpv.value.(map[string]string) 2725 return res, ok 2726 } 2727 func (fpv *AlertLogInfo_FieldTerminalPathValue) AsViolatingLogValue() (string, bool) { 2728 res, ok := fpv.value.(string) 2729 return res, ok 2730 } 2731 2732 // SetTo stores value for selected field for object LogInfo 2733 func (fpv *AlertLogInfo_FieldTerminalPathValue) SetTo(target **Alert_LogInfo) { 2734 if *target == nil { 2735 *target = new(Alert_LogInfo) 2736 } 2737 switch fpv.selector { 2738 case AlertLogInfo_FieldPathSelectorCommonKey: 2739 (*target).CommonKey = fpv.value.([]byte) 2740 case AlertLogInfo_FieldPathSelectorLogTypes: 2741 (*target).LogTypes = fpv.value.([]string) 2742 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2743 (*target).CommonLogLabels = fpv.value.(map[string]string) 2744 case AlertLogInfo_FieldPathSelectorViolatingLog: 2745 (*target).ViolatingLog = fpv.value.(string) 2746 default: 2747 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpv.selector)) 2748 } 2749 } 2750 2751 func (fpv *AlertLogInfo_FieldTerminalPathValue) SetToRaw(target proto.Message) { 2752 typedObject := target.(*Alert_LogInfo) 2753 fpv.SetTo(&typedObject) 2754 } 2755 2756 // CompareWith compares value in the 'AlertLogInfo_FieldTerminalPathValue' with the value under path in 'Alert_LogInfo'. 2757 func (fpv *AlertLogInfo_FieldTerminalPathValue) CompareWith(source *Alert_LogInfo) (int, bool) { 2758 switch fpv.selector { 2759 case AlertLogInfo_FieldPathSelectorCommonKey: 2760 return 0, false 2761 case AlertLogInfo_FieldPathSelectorLogTypes: 2762 return 0, false 2763 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2764 return 0, false 2765 case AlertLogInfo_FieldPathSelectorViolatingLog: 2766 leftValue := fpv.value.(string) 2767 rightValue := source.GetViolatingLog() 2768 if (leftValue) == (rightValue) { 2769 return 0, true 2770 } else if (leftValue) < (rightValue) { 2771 return -1, true 2772 } else { 2773 return 1, true 2774 } 2775 default: 2776 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpv.selector)) 2777 } 2778 } 2779 2780 func (fpv *AlertLogInfo_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2781 return fpv.CompareWith(source.(*Alert_LogInfo)) 2782 } 2783 2784 type AlertLogInfo_FieldPathMapValue struct { 2785 AlertLogInfo_FieldPathMap 2786 value interface{} 2787 } 2788 2789 var _ AlertLogInfo_FieldPathValue = (*AlertLogInfo_FieldPathMapValue)(nil) 2790 2791 // GetValue returns value stored under selected field in LogInfo as interface{} 2792 func (fpmv *AlertLogInfo_FieldPathMapValue) GetRawValue() interface{} { 2793 return fpmv.value 2794 } 2795 func (fpmv *AlertLogInfo_FieldPathMapValue) AsCommonLogLabelsElementValue() (string, bool) { 2796 res, ok := fpmv.value.(string) 2797 return res, ok 2798 } 2799 2800 // SetTo stores value for selected field in LogInfo 2801 func (fpmv *AlertLogInfo_FieldPathMapValue) SetTo(target **Alert_LogInfo) { 2802 if *target == nil { 2803 *target = new(Alert_LogInfo) 2804 } 2805 switch fpmv.selector { 2806 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2807 if (*target).CommonLogLabels == nil { 2808 (*target).CommonLogLabels = make(map[string]string) 2809 } 2810 (*target).CommonLogLabels[fpmv.key] = fpmv.value.(string) 2811 default: 2812 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpmv.selector)) 2813 } 2814 } 2815 2816 func (fpmv *AlertLogInfo_FieldPathMapValue) SetToRaw(target proto.Message) { 2817 typedObject := target.(*Alert_LogInfo) 2818 fpmv.SetTo(&typedObject) 2819 } 2820 2821 // CompareWith compares value in the 'AlertLogInfo_FieldPathMapValue' with the value under path in 'Alert_LogInfo'. 2822 func (fpmv *AlertLogInfo_FieldPathMapValue) CompareWith(source *Alert_LogInfo) (int, bool) { 2823 switch fpmv.selector { 2824 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2825 leftValue := fpmv.value.(string) 2826 rightValue := source.GetCommonLogLabels()[fpmv.key] 2827 if (leftValue) == (rightValue) { 2828 return 0, true 2829 } else if (leftValue) < (rightValue) { 2830 return -1, true 2831 } else { 2832 return 1, true 2833 } 2834 default: 2835 panic(fmt.Sprintf("Invalid selector for Alert_LogInfo: %d", fpmv.selector)) 2836 } 2837 } 2838 2839 func (fpmv *AlertLogInfo_FieldPathMapValue) CompareWithRaw(source proto.Message) (int, bool) { 2840 return fpmv.CompareWith(source.(*Alert_LogInfo)) 2841 } 2842 2843 // AlertLogInfo_FieldPathArrayItemValue allows storing single item in Path-specific values for LogInfo according to their type 2844 // Present only for array (repeated) types. 2845 type AlertLogInfo_FieldPathArrayItemValue interface { 2846 gotenobject.FieldPathArrayItemValue 2847 AlertLogInfo_FieldPath 2848 ContainsValue(*Alert_LogInfo) bool 2849 } 2850 2851 // ParseAlertLogInfo_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 2852 func ParseAlertLogInfo_FieldPathArrayItemValue(pathStr, valueStr string) (AlertLogInfo_FieldPathArrayItemValue, error) { 2853 fp, err := ParseAlertLogInfo_FieldPath(pathStr) 2854 if err != nil { 2855 return nil, err 2856 } 2857 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 2858 if err != nil { 2859 return nil, status.Errorf(codes.InvalidArgument, "error parsing LogInfo field path array item value from %s: %v", valueStr, err) 2860 } 2861 return fpaiv.(AlertLogInfo_FieldPathArrayItemValue), nil 2862 } 2863 2864 func MustParseAlertLogInfo_FieldPathArrayItemValue(pathStr, valueStr string) AlertLogInfo_FieldPathArrayItemValue { 2865 fpaiv, err := ParseAlertLogInfo_FieldPathArrayItemValue(pathStr, valueStr) 2866 if err != nil { 2867 panic(err) 2868 } 2869 return fpaiv 2870 } 2871 2872 type AlertLogInfo_FieldTerminalPathArrayItemValue struct { 2873 AlertLogInfo_FieldTerminalPath 2874 value interface{} 2875 } 2876 2877 var _ AlertLogInfo_FieldPathArrayItemValue = (*AlertLogInfo_FieldTerminalPathArrayItemValue)(nil) 2878 2879 // GetRawValue returns stored element value for array in object Alert_LogInfo as interface{} 2880 func (fpaiv *AlertLogInfo_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 2881 return fpaiv.value 2882 } 2883 func (fpaiv *AlertLogInfo_FieldTerminalPathArrayItemValue) AsLogTypesItemValue() (string, bool) { 2884 res, ok := fpaiv.value.(string) 2885 return res, ok 2886 } 2887 2888 func (fpaiv *AlertLogInfo_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_LogInfo) (interface{}, bool) { 2889 return nil, false 2890 } 2891 2892 func (fpaiv *AlertLogInfo_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 2893 return fpaiv.GetSingle(source.(*Alert_LogInfo)) 2894 } 2895 2896 // Contains returns a boolean indicating if value that is being held is present in given 'LogInfo' 2897 func (fpaiv *AlertLogInfo_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_LogInfo) bool { 2898 slice := fpaiv.AlertLogInfo_FieldTerminalPath.Get(source) 2899 for _, v := range slice { 2900 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 2901 if proto.Equal(asProtoMsg, v.(proto.Message)) { 2902 return true 2903 } 2904 } else if reflect.DeepEqual(v, fpaiv.value) { 2905 return true 2906 } 2907 } 2908 return false 2909 } 2910 2911 // AlertLogInfo_FieldPathArrayOfValues allows storing slice of values for LogInfo fields according to their type 2912 type AlertLogInfo_FieldPathArrayOfValues interface { 2913 gotenobject.FieldPathArrayOfValues 2914 AlertLogInfo_FieldPath 2915 } 2916 2917 func ParseAlertLogInfo_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertLogInfo_FieldPathArrayOfValues, error) { 2918 fp, err := ParseAlertLogInfo_FieldPath(pathStr) 2919 if err != nil { 2920 return nil, err 2921 } 2922 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 2923 if err != nil { 2924 return nil, status.Errorf(codes.InvalidArgument, "error parsing LogInfo field path array of values from %s: %v", valuesStr, err) 2925 } 2926 return fpaov.(AlertLogInfo_FieldPathArrayOfValues), nil 2927 } 2928 2929 func MustParseAlertLogInfo_FieldPathArrayOfValues(pathStr, valuesStr string) AlertLogInfo_FieldPathArrayOfValues { 2930 fpaov, err := ParseAlertLogInfo_FieldPathArrayOfValues(pathStr, valuesStr) 2931 if err != nil { 2932 panic(err) 2933 } 2934 return fpaov 2935 } 2936 2937 type AlertLogInfo_FieldTerminalPathArrayOfValues struct { 2938 AlertLogInfo_FieldTerminalPath 2939 values interface{} 2940 } 2941 2942 var _ AlertLogInfo_FieldPathArrayOfValues = (*AlertLogInfo_FieldTerminalPathArrayOfValues)(nil) 2943 2944 func (fpaov *AlertLogInfo_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 2945 switch fpaov.selector { 2946 case AlertLogInfo_FieldPathSelectorCommonKey: 2947 for _, v := range fpaov.values.([][]byte) { 2948 values = append(values, v) 2949 } 2950 case AlertLogInfo_FieldPathSelectorLogTypes: 2951 for _, v := range fpaov.values.([][]string) { 2952 values = append(values, v) 2953 } 2954 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2955 for _, v := range fpaov.values.([]map[string]string) { 2956 values = append(values, v) 2957 } 2958 case AlertLogInfo_FieldPathSelectorViolatingLog: 2959 for _, v := range fpaov.values.([]string) { 2960 values = append(values, v) 2961 } 2962 } 2963 return 2964 } 2965 func (fpaov *AlertLogInfo_FieldTerminalPathArrayOfValues) AsCommonKeyArrayOfValues() ([][]byte, bool) { 2966 res, ok := fpaov.values.([][]byte) 2967 return res, ok 2968 } 2969 func (fpaov *AlertLogInfo_FieldTerminalPathArrayOfValues) AsLogTypesArrayOfValues() ([][]string, bool) { 2970 res, ok := fpaov.values.([][]string) 2971 return res, ok 2972 } 2973 func (fpaov *AlertLogInfo_FieldTerminalPathArrayOfValues) AsCommonLogLabelsArrayOfValues() ([]map[string]string, bool) { 2974 res, ok := fpaov.values.([]map[string]string) 2975 return res, ok 2976 } 2977 func (fpaov *AlertLogInfo_FieldTerminalPathArrayOfValues) AsViolatingLogArrayOfValues() ([]string, bool) { 2978 res, ok := fpaov.values.([]string) 2979 return res, ok 2980 } 2981 2982 type AlertLogInfo_FieldPathMapArrayOfValues struct { 2983 AlertLogInfo_FieldPathMap 2984 values interface{} 2985 } 2986 2987 var _ AlertLogInfo_FieldPathArrayOfValues = (*AlertLogInfo_FieldPathMapArrayOfValues)(nil) 2988 2989 func (fpmaov *AlertLogInfo_FieldPathMapArrayOfValues) GetRawValues() (values []interface{}) { 2990 switch fpmaov.selector { 2991 case AlertLogInfo_FieldPathSelectorCommonLogLabels: 2992 for _, v := range fpmaov.values.([]string) { 2993 values = append(values, v) 2994 } 2995 } 2996 return 2997 } 2998 func (fpmaov *AlertLogInfo_FieldPathMapArrayOfValues) AsCommonLogLabelsArrayOfElementValues() ([]string, bool) { 2999 res, ok := fpmaov.values.([]string) 3000 return res, ok 3001 } 3002 3003 // FieldPath provides implementation to handle 3004 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 3005 type AlertState_FieldPath interface { 3006 gotenobject.FieldPath 3007 Selector() AlertState_FieldPathSelector 3008 Get(source *Alert_State) []interface{} 3009 GetSingle(source *Alert_State) (interface{}, bool) 3010 ClearValue(item *Alert_State) 3011 3012 // Those methods build corresponding AlertState_FieldPathValue 3013 // (or array of values) and holds passed value. Panics if injected type is incorrect. 3014 WithIValue(value interface{}) AlertState_FieldPathValue 3015 WithIArrayOfValues(values interface{}) AlertState_FieldPathArrayOfValues 3016 WithIArrayItemValue(value interface{}) AlertState_FieldPathArrayItemValue 3017 } 3018 3019 type AlertState_FieldPathSelector int32 3020 3021 const ( 3022 AlertState_FieldPathSelectorIsFiring AlertState_FieldPathSelector = 0 3023 AlertState_FieldPathSelectorStartTime AlertState_FieldPathSelector = 1 3024 AlertState_FieldPathSelectorEndTime AlertState_FieldPathSelector = 2 3025 AlertState_FieldPathSelectorNotificationStatuses AlertState_FieldPathSelector = 3 3026 AlertState_FieldPathSelectorEscalationLevel AlertState_FieldPathSelector = 4 3027 AlertState_FieldPathSelectorAiAgentHandlingState AlertState_FieldPathSelector = 5 3028 AlertState_FieldPathSelectorAiAgentLastStateChangeTime AlertState_FieldPathSelector = 6 3029 AlertState_FieldPathSelectorAiAgentDiagnosisNotes AlertState_FieldPathSelector = 7 3030 AlertState_FieldPathSelectorAiRemediationArg AlertState_FieldPathSelector = 8 3031 AlertState_FieldPathSelectorAiRemediation AlertState_FieldPathSelector = 9 3032 AlertState_FieldPathSelectorOperatorHandlingState AlertState_FieldPathSelector = 10 3033 AlertState_FieldPathSelectorOperatorLastStateChangeTime AlertState_FieldPathSelector = 11 3034 AlertState_FieldPathSelectorOperatorNotes AlertState_FieldPathSelector = 12 3035 AlertState_FieldPathSelectorLifecycleCompleted AlertState_FieldPathSelector = 13 3036 ) 3037 3038 func (s AlertState_FieldPathSelector) String() string { 3039 switch s { 3040 case AlertState_FieldPathSelectorIsFiring: 3041 return "is_firing" 3042 case AlertState_FieldPathSelectorStartTime: 3043 return "start_time" 3044 case AlertState_FieldPathSelectorEndTime: 3045 return "end_time" 3046 case AlertState_FieldPathSelectorNotificationStatuses: 3047 return "notification_statuses" 3048 case AlertState_FieldPathSelectorEscalationLevel: 3049 return "escalation_level" 3050 case AlertState_FieldPathSelectorAiAgentHandlingState: 3051 return "ai_agent_handling_state" 3052 case AlertState_FieldPathSelectorAiAgentLastStateChangeTime: 3053 return "ai_agent_last_state_change_time" 3054 case AlertState_FieldPathSelectorAiAgentDiagnosisNotes: 3055 return "ai_agent_diagnosis_notes" 3056 case AlertState_FieldPathSelectorAiRemediationArg: 3057 return "ai_remediation_arg" 3058 case AlertState_FieldPathSelectorAiRemediation: 3059 return "ai_remediation" 3060 case AlertState_FieldPathSelectorOperatorHandlingState: 3061 return "operator_handling_state" 3062 case AlertState_FieldPathSelectorOperatorLastStateChangeTime: 3063 return "operator_last_state_change_time" 3064 case AlertState_FieldPathSelectorOperatorNotes: 3065 return "operator_notes" 3066 case AlertState_FieldPathSelectorLifecycleCompleted: 3067 return "lifecycle_completed" 3068 default: 3069 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", s)) 3070 } 3071 } 3072 3073 func BuildAlertState_FieldPath(fp gotenobject.RawFieldPath) (AlertState_FieldPath, error) { 3074 if len(fp) == 0 { 3075 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_State") 3076 } 3077 if len(fp) == 1 { 3078 switch fp[0] { 3079 case "is_firing", "isFiring", "is-firing": 3080 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorIsFiring}, nil 3081 case "start_time", "startTime", "start-time": 3082 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorStartTime}, nil 3083 case "end_time", "endTime", "end-time": 3084 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorEndTime}, nil 3085 case "notification_statuses", "notificationStatuses", "notification-statuses": 3086 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorNotificationStatuses}, nil 3087 case "escalation_level", "escalationLevel", "escalation-level": 3088 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorEscalationLevel}, nil 3089 case "ai_agent_handling_state", "aiAgentHandlingState", "ai-agent-handling-state": 3090 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorAiAgentHandlingState}, nil 3091 case "ai_agent_last_state_change_time", "aiAgentLastStateChangeTime", "ai-agent-last-state-change-time": 3092 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorAiAgentLastStateChangeTime}, nil 3093 case "ai_agent_diagnosis_notes", "aiAgentDiagnosisNotes", "ai-agent-diagnosis-notes": 3094 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorAiAgentDiagnosisNotes}, nil 3095 case "ai_remediation_arg", "aiRemediationArg", "ai-remediation-arg": 3096 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorAiRemediationArg}, nil 3097 case "ai_remediation", "aiRemediation", "ai-remediation": 3098 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorAiRemediation}, nil 3099 case "operator_handling_state", "operatorHandlingState", "operator-handling-state": 3100 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorOperatorHandlingState}, nil 3101 case "operator_last_state_change_time", "operatorLastStateChangeTime", "operator-last-state-change-time": 3102 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorOperatorLastStateChangeTime}, nil 3103 case "operator_notes", "operatorNotes", "operator-notes": 3104 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorOperatorNotes}, nil 3105 case "lifecycle_completed", "lifecycleCompleted", "lifecycle-completed": 3106 return &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorLifecycleCompleted}, nil 3107 } 3108 } else { 3109 switch fp[0] { 3110 case "notification_statuses", "notificationStatuses", "notification-statuses": 3111 if subpath, err := BuildAlertStateNotification_FieldPath(fp[1:]); err != nil { 3112 return nil, err 3113 } else { 3114 return &AlertState_FieldSubPath{selector: AlertState_FieldPathSelectorNotificationStatuses, subPath: subpath}, nil 3115 } 3116 case "ai_remediation", "aiRemediation", "ai-remediation": 3117 if subpath, err := rcommon.BuildPolicySpecAIAgentHandlingRemediation_FieldPath(fp[1:]); err != nil { 3118 return nil, err 3119 } else { 3120 return &AlertState_FieldSubPath{selector: AlertState_FieldPathSelectorAiRemediation, subPath: subpath}, nil 3121 } 3122 } 3123 } 3124 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_State", fp) 3125 } 3126 3127 func ParseAlertState_FieldPath(rawField string) (AlertState_FieldPath, error) { 3128 fp, err := gotenobject.ParseRawFieldPath(rawField) 3129 if err != nil { 3130 return nil, err 3131 } 3132 return BuildAlertState_FieldPath(fp) 3133 } 3134 3135 func MustParseAlertState_FieldPath(rawField string) AlertState_FieldPath { 3136 fp, err := ParseAlertState_FieldPath(rawField) 3137 if err != nil { 3138 panic(err) 3139 } 3140 return fp 3141 } 3142 3143 type AlertState_FieldTerminalPath struct { 3144 selector AlertState_FieldPathSelector 3145 } 3146 3147 var _ AlertState_FieldPath = (*AlertState_FieldTerminalPath)(nil) 3148 3149 func (fp *AlertState_FieldTerminalPath) Selector() AlertState_FieldPathSelector { 3150 return fp.selector 3151 } 3152 3153 // String returns path representation in proto convention 3154 func (fp *AlertState_FieldTerminalPath) String() string { 3155 return fp.selector.String() 3156 } 3157 3158 // JSONString returns path representation is JSON convention 3159 func (fp *AlertState_FieldTerminalPath) JSONString() string { 3160 return strcase.ToLowerCamel(fp.String()) 3161 } 3162 3163 // Get returns all values pointed by specific field from source Alert_State 3164 func (fp *AlertState_FieldTerminalPath) Get(source *Alert_State) (values []interface{}) { 3165 if source != nil { 3166 switch fp.selector { 3167 case AlertState_FieldPathSelectorIsFiring: 3168 values = append(values, source.IsFiring) 3169 case AlertState_FieldPathSelectorStartTime: 3170 if source.StartTime != nil { 3171 values = append(values, source.StartTime) 3172 } 3173 case AlertState_FieldPathSelectorEndTime: 3174 if source.EndTime != nil { 3175 values = append(values, source.EndTime) 3176 } 3177 case AlertState_FieldPathSelectorNotificationStatuses: 3178 for _, value := range source.GetNotificationStatuses() { 3179 values = append(values, value) 3180 } 3181 case AlertState_FieldPathSelectorEscalationLevel: 3182 values = append(values, source.EscalationLevel) 3183 case AlertState_FieldPathSelectorAiAgentHandlingState: 3184 values = append(values, source.AiAgentHandlingState) 3185 case AlertState_FieldPathSelectorAiAgentLastStateChangeTime: 3186 if source.AiAgentLastStateChangeTime != nil { 3187 values = append(values, source.AiAgentLastStateChangeTime) 3188 } 3189 case AlertState_FieldPathSelectorAiAgentDiagnosisNotes: 3190 values = append(values, source.AiAgentDiagnosisNotes) 3191 case AlertState_FieldPathSelectorAiRemediationArg: 3192 values = append(values, source.AiRemediationArg) 3193 case AlertState_FieldPathSelectorAiRemediation: 3194 if source.AiRemediation != nil { 3195 values = append(values, source.AiRemediation) 3196 } 3197 case AlertState_FieldPathSelectorOperatorHandlingState: 3198 values = append(values, source.OperatorHandlingState) 3199 case AlertState_FieldPathSelectorOperatorLastStateChangeTime: 3200 if source.OperatorLastStateChangeTime != nil { 3201 values = append(values, source.OperatorLastStateChangeTime) 3202 } 3203 case AlertState_FieldPathSelectorOperatorNotes: 3204 values = append(values, source.OperatorNotes) 3205 case AlertState_FieldPathSelectorLifecycleCompleted: 3206 values = append(values, source.LifecycleCompleted) 3207 default: 3208 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 3209 } 3210 } 3211 return 3212 } 3213 3214 func (fp *AlertState_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 3215 return fp.Get(source.(*Alert_State)) 3216 } 3217 3218 // GetSingle returns value pointed by specific field of from source Alert_State 3219 func (fp *AlertState_FieldTerminalPath) GetSingle(source *Alert_State) (interface{}, bool) { 3220 switch fp.selector { 3221 case AlertState_FieldPathSelectorIsFiring: 3222 return source.GetIsFiring(), source != nil 3223 case AlertState_FieldPathSelectorStartTime: 3224 res := source.GetStartTime() 3225 return res, res != nil 3226 case AlertState_FieldPathSelectorEndTime: 3227 res := source.GetEndTime() 3228 return res, res != nil 3229 case AlertState_FieldPathSelectorNotificationStatuses: 3230 res := source.GetNotificationStatuses() 3231 return res, res != nil 3232 case AlertState_FieldPathSelectorEscalationLevel: 3233 return source.GetEscalationLevel(), source != nil 3234 case AlertState_FieldPathSelectorAiAgentHandlingState: 3235 return source.GetAiAgentHandlingState(), source != nil 3236 case AlertState_FieldPathSelectorAiAgentLastStateChangeTime: 3237 res := source.GetAiAgentLastStateChangeTime() 3238 return res, res != nil 3239 case AlertState_FieldPathSelectorAiAgentDiagnosisNotes: 3240 return source.GetAiAgentDiagnosisNotes(), source != nil 3241 case AlertState_FieldPathSelectorAiRemediationArg: 3242 return source.GetAiRemediationArg(), source != nil 3243 case AlertState_FieldPathSelectorAiRemediation: 3244 res := source.GetAiRemediation() 3245 return res, res != nil 3246 case AlertState_FieldPathSelectorOperatorHandlingState: 3247 return source.GetOperatorHandlingState(), source != nil 3248 case AlertState_FieldPathSelectorOperatorLastStateChangeTime: 3249 res := source.GetOperatorLastStateChangeTime() 3250 return res, res != nil 3251 case AlertState_FieldPathSelectorOperatorNotes: 3252 return source.GetOperatorNotes(), source != nil 3253 case AlertState_FieldPathSelectorLifecycleCompleted: 3254 return source.GetLifecycleCompleted(), source != nil 3255 default: 3256 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 3257 } 3258 } 3259 3260 func (fp *AlertState_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 3261 return fp.GetSingle(source.(*Alert_State)) 3262 } 3263 3264 // GetDefault returns a default value of the field type 3265 func (fp *AlertState_FieldTerminalPath) GetDefault() interface{} { 3266 switch fp.selector { 3267 case AlertState_FieldPathSelectorIsFiring: 3268 return false 3269 case AlertState_FieldPathSelectorStartTime: 3270 return (*timestamppb.Timestamp)(nil) 3271 case AlertState_FieldPathSelectorEndTime: 3272 return (*timestamppb.Timestamp)(nil) 3273 case AlertState_FieldPathSelectorNotificationStatuses: 3274 return ([]*Alert_State_Notification)(nil) 3275 case AlertState_FieldPathSelectorEscalationLevel: 3276 return Alert_State_NONE 3277 case AlertState_FieldPathSelectorAiAgentHandlingState: 3278 return Alert_State_AI_AGENT_NOT_INVOLVED 3279 case AlertState_FieldPathSelectorAiAgentLastStateChangeTime: 3280 return (*timestamppb.Timestamp)(nil) 3281 case AlertState_FieldPathSelectorAiAgentDiagnosisNotes: 3282 return "" 3283 case AlertState_FieldPathSelectorAiRemediationArg: 3284 return "" 3285 case AlertState_FieldPathSelectorAiRemediation: 3286 return (*rcommon.PolicySpec_AIAgentHandling_Remediation)(nil) 3287 case AlertState_FieldPathSelectorOperatorHandlingState: 3288 return Alert_State_OP_NOT_INVOLVED 3289 case AlertState_FieldPathSelectorOperatorLastStateChangeTime: 3290 return (*timestamppb.Timestamp)(nil) 3291 case AlertState_FieldPathSelectorOperatorNotes: 3292 return "" 3293 case AlertState_FieldPathSelectorLifecycleCompleted: 3294 return false 3295 default: 3296 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 3297 } 3298 } 3299 3300 func (fp *AlertState_FieldTerminalPath) ClearValue(item *Alert_State) { 3301 if item != nil { 3302 switch fp.selector { 3303 case AlertState_FieldPathSelectorIsFiring: 3304 item.IsFiring = false 3305 case AlertState_FieldPathSelectorStartTime: 3306 item.StartTime = nil 3307 case AlertState_FieldPathSelectorEndTime: 3308 item.EndTime = nil 3309 case AlertState_FieldPathSelectorNotificationStatuses: 3310 item.NotificationStatuses = nil 3311 case AlertState_FieldPathSelectorEscalationLevel: 3312 item.EscalationLevel = Alert_State_NONE 3313 case AlertState_FieldPathSelectorAiAgentHandlingState: 3314 item.AiAgentHandlingState = Alert_State_AI_AGENT_NOT_INVOLVED 3315 case AlertState_FieldPathSelectorAiAgentLastStateChangeTime: 3316 item.AiAgentLastStateChangeTime = nil 3317 case AlertState_FieldPathSelectorAiAgentDiagnosisNotes: 3318 item.AiAgentDiagnosisNotes = "" 3319 case AlertState_FieldPathSelectorAiRemediationArg: 3320 item.AiRemediationArg = "" 3321 case AlertState_FieldPathSelectorAiRemediation: 3322 item.AiRemediation = nil 3323 case AlertState_FieldPathSelectorOperatorHandlingState: 3324 item.OperatorHandlingState = Alert_State_OP_NOT_INVOLVED 3325 case AlertState_FieldPathSelectorOperatorLastStateChangeTime: 3326 item.OperatorLastStateChangeTime = nil 3327 case AlertState_FieldPathSelectorOperatorNotes: 3328 item.OperatorNotes = "" 3329 case AlertState_FieldPathSelectorLifecycleCompleted: 3330 item.LifecycleCompleted = false 3331 default: 3332 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 3333 } 3334 } 3335 } 3336 3337 func (fp *AlertState_FieldTerminalPath) ClearValueRaw(item proto.Message) { 3338 fp.ClearValue(item.(*Alert_State)) 3339 } 3340 3341 // IsLeaf - whether field path is holds simple value 3342 func (fp *AlertState_FieldTerminalPath) IsLeaf() bool { 3343 return fp.selector == AlertState_FieldPathSelectorIsFiring || 3344 fp.selector == AlertState_FieldPathSelectorStartTime || 3345 fp.selector == AlertState_FieldPathSelectorEndTime || 3346 fp.selector == AlertState_FieldPathSelectorEscalationLevel || 3347 fp.selector == AlertState_FieldPathSelectorAiAgentHandlingState || 3348 fp.selector == AlertState_FieldPathSelectorAiAgentLastStateChangeTime || 3349 fp.selector == AlertState_FieldPathSelectorAiAgentDiagnosisNotes || 3350 fp.selector == AlertState_FieldPathSelectorAiRemediationArg || 3351 fp.selector == AlertState_FieldPathSelectorOperatorHandlingState || 3352 fp.selector == AlertState_FieldPathSelectorOperatorLastStateChangeTime || 3353 fp.selector == AlertState_FieldPathSelectorOperatorNotes || 3354 fp.selector == AlertState_FieldPathSelectorLifecycleCompleted 3355 } 3356 3357 func (fp *AlertState_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 3358 return []gotenobject.FieldPath{fp} 3359 } 3360 3361 func (fp *AlertState_FieldTerminalPath) WithIValue(value interface{}) AlertState_FieldPathValue { 3362 switch fp.selector { 3363 case AlertState_FieldPathSelectorIsFiring: 3364 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(bool)} 3365 case AlertState_FieldPathSelectorStartTime: 3366 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(*timestamppb.Timestamp)} 3367 case AlertState_FieldPathSelectorEndTime: 3368 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(*timestamppb.Timestamp)} 3369 case AlertState_FieldPathSelectorNotificationStatuses: 3370 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.([]*Alert_State_Notification)} 3371 case AlertState_FieldPathSelectorEscalationLevel: 3372 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(Alert_State_EscalationLevel)} 3373 case AlertState_FieldPathSelectorAiAgentHandlingState: 3374 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(Alert_State_AiHandlingState)} 3375 case AlertState_FieldPathSelectorAiAgentLastStateChangeTime: 3376 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(*timestamppb.Timestamp)} 3377 case AlertState_FieldPathSelectorAiAgentDiagnosisNotes: 3378 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(string)} 3379 case AlertState_FieldPathSelectorAiRemediationArg: 3380 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(string)} 3381 case AlertState_FieldPathSelectorAiRemediation: 3382 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(*rcommon.PolicySpec_AIAgentHandling_Remediation)} 3383 case AlertState_FieldPathSelectorOperatorHandlingState: 3384 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(Alert_State_OperatorHandlingState)} 3385 case AlertState_FieldPathSelectorOperatorLastStateChangeTime: 3386 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(*timestamppb.Timestamp)} 3387 case AlertState_FieldPathSelectorOperatorNotes: 3388 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(string)} 3389 case AlertState_FieldPathSelectorLifecycleCompleted: 3390 return &AlertState_FieldTerminalPathValue{AlertState_FieldTerminalPath: *fp, value: value.(bool)} 3391 default: 3392 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 3393 } 3394 } 3395 3396 func (fp *AlertState_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 3397 return fp.WithIValue(value) 3398 } 3399 3400 func (fp *AlertState_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertState_FieldPathArrayOfValues { 3401 fpaov := &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp} 3402 switch fp.selector { 3403 case AlertState_FieldPathSelectorIsFiring: 3404 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]bool)} 3405 case AlertState_FieldPathSelectorStartTime: 3406 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]*timestamppb.Timestamp)} 3407 case AlertState_FieldPathSelectorEndTime: 3408 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]*timestamppb.Timestamp)} 3409 case AlertState_FieldPathSelectorNotificationStatuses: 3410 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([][]*Alert_State_Notification)} 3411 case AlertState_FieldPathSelectorEscalationLevel: 3412 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]Alert_State_EscalationLevel)} 3413 case AlertState_FieldPathSelectorAiAgentHandlingState: 3414 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]Alert_State_AiHandlingState)} 3415 case AlertState_FieldPathSelectorAiAgentLastStateChangeTime: 3416 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]*timestamppb.Timestamp)} 3417 case AlertState_FieldPathSelectorAiAgentDiagnosisNotes: 3418 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]string)} 3419 case AlertState_FieldPathSelectorAiRemediationArg: 3420 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]string)} 3421 case AlertState_FieldPathSelectorAiRemediation: 3422 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]*rcommon.PolicySpec_AIAgentHandling_Remediation)} 3423 case AlertState_FieldPathSelectorOperatorHandlingState: 3424 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]Alert_State_OperatorHandlingState)} 3425 case AlertState_FieldPathSelectorOperatorLastStateChangeTime: 3426 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]*timestamppb.Timestamp)} 3427 case AlertState_FieldPathSelectorOperatorNotes: 3428 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]string)} 3429 case AlertState_FieldPathSelectorLifecycleCompleted: 3430 return &AlertState_FieldTerminalPathArrayOfValues{AlertState_FieldTerminalPath: *fp, values: values.([]bool)} 3431 default: 3432 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 3433 } 3434 return fpaov 3435 } 3436 3437 func (fp *AlertState_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 3438 return fp.WithIArrayOfValues(values) 3439 } 3440 3441 func (fp *AlertState_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertState_FieldPathArrayItemValue { 3442 switch fp.selector { 3443 case AlertState_FieldPathSelectorNotificationStatuses: 3444 return &AlertState_FieldTerminalPathArrayItemValue{AlertState_FieldTerminalPath: *fp, value: value.(*Alert_State_Notification)} 3445 default: 3446 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fp.selector)) 3447 } 3448 } 3449 3450 func (fp *AlertState_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 3451 return fp.WithIArrayItemValue(value) 3452 } 3453 3454 type AlertState_FieldSubPath struct { 3455 selector AlertState_FieldPathSelector 3456 subPath gotenobject.FieldPath 3457 } 3458 3459 var _ AlertState_FieldPath = (*AlertState_FieldSubPath)(nil) 3460 3461 func (fps *AlertState_FieldSubPath) Selector() AlertState_FieldPathSelector { 3462 return fps.selector 3463 } 3464 func (fps *AlertState_FieldSubPath) AsNotificationStatusesSubPath() (AlertStateNotification_FieldPath, bool) { 3465 res, ok := fps.subPath.(AlertStateNotification_FieldPath) 3466 return res, ok 3467 } 3468 func (fps *AlertState_FieldSubPath) AsAiRemediationSubPath() (rcommon.PolicySpecAIAgentHandlingRemediation_FieldPath, bool) { 3469 res, ok := fps.subPath.(rcommon.PolicySpecAIAgentHandlingRemediation_FieldPath) 3470 return res, ok 3471 } 3472 3473 // String returns path representation in proto convention 3474 func (fps *AlertState_FieldSubPath) String() string { 3475 return fps.selector.String() + "." + fps.subPath.String() 3476 } 3477 3478 // JSONString returns path representation is JSON convention 3479 func (fps *AlertState_FieldSubPath) JSONString() string { 3480 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 3481 } 3482 3483 // Get returns all values pointed by selected field from source Alert_State 3484 func (fps *AlertState_FieldSubPath) Get(source *Alert_State) (values []interface{}) { 3485 switch fps.selector { 3486 case AlertState_FieldPathSelectorNotificationStatuses: 3487 for _, item := range source.GetNotificationStatuses() { 3488 values = append(values, fps.subPath.GetRaw(item)...) 3489 } 3490 case AlertState_FieldPathSelectorAiRemediation: 3491 values = append(values, fps.subPath.GetRaw(source.GetAiRemediation())...) 3492 default: 3493 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fps.selector)) 3494 } 3495 return 3496 } 3497 3498 func (fps *AlertState_FieldSubPath) GetRaw(source proto.Message) []interface{} { 3499 return fps.Get(source.(*Alert_State)) 3500 } 3501 3502 // GetSingle returns value of selected field from source Alert_State 3503 func (fps *AlertState_FieldSubPath) GetSingle(source *Alert_State) (interface{}, bool) { 3504 switch fps.selector { 3505 case AlertState_FieldPathSelectorNotificationStatuses: 3506 if len(source.GetNotificationStatuses()) == 0 { 3507 return nil, false 3508 } 3509 return fps.subPath.GetSingleRaw(source.GetNotificationStatuses()[0]) 3510 case AlertState_FieldPathSelectorAiRemediation: 3511 if source.GetAiRemediation() == nil { 3512 return nil, false 3513 } 3514 return fps.subPath.GetSingleRaw(source.GetAiRemediation()) 3515 default: 3516 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fps.selector)) 3517 } 3518 } 3519 3520 func (fps *AlertState_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 3521 return fps.GetSingle(source.(*Alert_State)) 3522 } 3523 3524 // GetDefault returns a default value of the field type 3525 func (fps *AlertState_FieldSubPath) GetDefault() interface{} { 3526 return fps.subPath.GetDefault() 3527 } 3528 3529 func (fps *AlertState_FieldSubPath) ClearValue(item *Alert_State) { 3530 if item != nil { 3531 switch fps.selector { 3532 case AlertState_FieldPathSelectorNotificationStatuses: 3533 for _, subItem := range item.NotificationStatuses { 3534 fps.subPath.ClearValueRaw(subItem) 3535 } 3536 case AlertState_FieldPathSelectorAiRemediation: 3537 fps.subPath.ClearValueRaw(item.AiRemediation) 3538 default: 3539 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fps.selector)) 3540 } 3541 } 3542 } 3543 3544 func (fps *AlertState_FieldSubPath) ClearValueRaw(item proto.Message) { 3545 fps.ClearValue(item.(*Alert_State)) 3546 } 3547 3548 // IsLeaf - whether field path is holds simple value 3549 func (fps *AlertState_FieldSubPath) IsLeaf() bool { 3550 return fps.subPath.IsLeaf() 3551 } 3552 3553 func (fps *AlertState_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 3554 iPaths := []gotenobject.FieldPath{&AlertState_FieldTerminalPath{selector: fps.selector}} 3555 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 3556 return iPaths 3557 } 3558 3559 func (fps *AlertState_FieldSubPath) WithIValue(value interface{}) AlertState_FieldPathValue { 3560 return &AlertState_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 3561 } 3562 3563 func (fps *AlertState_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 3564 return fps.WithIValue(value) 3565 } 3566 3567 func (fps *AlertState_FieldSubPath) WithIArrayOfValues(values interface{}) AlertState_FieldPathArrayOfValues { 3568 return &AlertState_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 3569 } 3570 3571 func (fps *AlertState_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 3572 return fps.WithIArrayOfValues(values) 3573 } 3574 3575 func (fps *AlertState_FieldSubPath) WithIArrayItemValue(value interface{}) AlertState_FieldPathArrayItemValue { 3576 return &AlertState_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 3577 } 3578 3579 func (fps *AlertState_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 3580 return fps.WithIArrayItemValue(value) 3581 } 3582 3583 // AlertState_FieldPathValue allows storing values for State fields according to their type 3584 type AlertState_FieldPathValue interface { 3585 AlertState_FieldPath 3586 gotenobject.FieldPathValue 3587 SetTo(target **Alert_State) 3588 CompareWith(*Alert_State) (cmp int, comparable bool) 3589 } 3590 3591 func ParseAlertState_FieldPathValue(pathStr, valueStr string) (AlertState_FieldPathValue, error) { 3592 fp, err := ParseAlertState_FieldPath(pathStr) 3593 if err != nil { 3594 return nil, err 3595 } 3596 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 3597 if err != nil { 3598 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path value from %s: %v", valueStr, err) 3599 } 3600 return fpv.(AlertState_FieldPathValue), nil 3601 } 3602 3603 func MustParseAlertState_FieldPathValue(pathStr, valueStr string) AlertState_FieldPathValue { 3604 fpv, err := ParseAlertState_FieldPathValue(pathStr, valueStr) 3605 if err != nil { 3606 panic(err) 3607 } 3608 return fpv 3609 } 3610 3611 type AlertState_FieldTerminalPathValue struct { 3612 AlertState_FieldTerminalPath 3613 value interface{} 3614 } 3615 3616 var _ AlertState_FieldPathValue = (*AlertState_FieldTerminalPathValue)(nil) 3617 3618 // GetRawValue returns raw value stored under selected path for 'State' as interface{} 3619 func (fpv *AlertState_FieldTerminalPathValue) GetRawValue() interface{} { 3620 return fpv.value 3621 } 3622 func (fpv *AlertState_FieldTerminalPathValue) AsIsFiringValue() (bool, bool) { 3623 res, ok := fpv.value.(bool) 3624 return res, ok 3625 } 3626 func (fpv *AlertState_FieldTerminalPathValue) AsStartTimeValue() (*timestamppb.Timestamp, bool) { 3627 res, ok := fpv.value.(*timestamppb.Timestamp) 3628 return res, ok 3629 } 3630 func (fpv *AlertState_FieldTerminalPathValue) AsEndTimeValue() (*timestamppb.Timestamp, bool) { 3631 res, ok := fpv.value.(*timestamppb.Timestamp) 3632 return res, ok 3633 } 3634 func (fpv *AlertState_FieldTerminalPathValue) AsNotificationStatusesValue() ([]*Alert_State_Notification, bool) { 3635 res, ok := fpv.value.([]*Alert_State_Notification) 3636 return res, ok 3637 } 3638 func (fpv *AlertState_FieldTerminalPathValue) AsEscalationLevelValue() (Alert_State_EscalationLevel, bool) { 3639 res, ok := fpv.value.(Alert_State_EscalationLevel) 3640 return res, ok 3641 } 3642 func (fpv *AlertState_FieldTerminalPathValue) AsAiAgentHandlingStateValue() (Alert_State_AiHandlingState, bool) { 3643 res, ok := fpv.value.(Alert_State_AiHandlingState) 3644 return res, ok 3645 } 3646 func (fpv *AlertState_FieldTerminalPathValue) AsAiAgentLastStateChangeTimeValue() (*timestamppb.Timestamp, bool) { 3647 res, ok := fpv.value.(*timestamppb.Timestamp) 3648 return res, ok 3649 } 3650 func (fpv *AlertState_FieldTerminalPathValue) AsAiAgentDiagnosisNotesValue() (string, bool) { 3651 res, ok := fpv.value.(string) 3652 return res, ok 3653 } 3654 func (fpv *AlertState_FieldTerminalPathValue) AsAiRemediationArgValue() (string, bool) { 3655 res, ok := fpv.value.(string) 3656 return res, ok 3657 } 3658 func (fpv *AlertState_FieldTerminalPathValue) AsAiRemediationValue() (*rcommon.PolicySpec_AIAgentHandling_Remediation, bool) { 3659 res, ok := fpv.value.(*rcommon.PolicySpec_AIAgentHandling_Remediation) 3660 return res, ok 3661 } 3662 func (fpv *AlertState_FieldTerminalPathValue) AsOperatorHandlingStateValue() (Alert_State_OperatorHandlingState, bool) { 3663 res, ok := fpv.value.(Alert_State_OperatorHandlingState) 3664 return res, ok 3665 } 3666 func (fpv *AlertState_FieldTerminalPathValue) AsOperatorLastStateChangeTimeValue() (*timestamppb.Timestamp, bool) { 3667 res, ok := fpv.value.(*timestamppb.Timestamp) 3668 return res, ok 3669 } 3670 func (fpv *AlertState_FieldTerminalPathValue) AsOperatorNotesValue() (string, bool) { 3671 res, ok := fpv.value.(string) 3672 return res, ok 3673 } 3674 func (fpv *AlertState_FieldTerminalPathValue) AsLifecycleCompletedValue() (bool, bool) { 3675 res, ok := fpv.value.(bool) 3676 return res, ok 3677 } 3678 3679 // SetTo stores value for selected field for object State 3680 func (fpv *AlertState_FieldTerminalPathValue) SetTo(target **Alert_State) { 3681 if *target == nil { 3682 *target = new(Alert_State) 3683 } 3684 switch fpv.selector { 3685 case AlertState_FieldPathSelectorIsFiring: 3686 (*target).IsFiring = fpv.value.(bool) 3687 case AlertState_FieldPathSelectorStartTime: 3688 (*target).StartTime = fpv.value.(*timestamppb.Timestamp) 3689 case AlertState_FieldPathSelectorEndTime: 3690 (*target).EndTime = fpv.value.(*timestamppb.Timestamp) 3691 case AlertState_FieldPathSelectorNotificationStatuses: 3692 (*target).NotificationStatuses = fpv.value.([]*Alert_State_Notification) 3693 case AlertState_FieldPathSelectorEscalationLevel: 3694 (*target).EscalationLevel = fpv.value.(Alert_State_EscalationLevel) 3695 case AlertState_FieldPathSelectorAiAgentHandlingState: 3696 (*target).AiAgentHandlingState = fpv.value.(Alert_State_AiHandlingState) 3697 case AlertState_FieldPathSelectorAiAgentLastStateChangeTime: 3698 (*target).AiAgentLastStateChangeTime = fpv.value.(*timestamppb.Timestamp) 3699 case AlertState_FieldPathSelectorAiAgentDiagnosisNotes: 3700 (*target).AiAgentDiagnosisNotes = fpv.value.(string) 3701 case AlertState_FieldPathSelectorAiRemediationArg: 3702 (*target).AiRemediationArg = fpv.value.(string) 3703 case AlertState_FieldPathSelectorAiRemediation: 3704 (*target).AiRemediation = fpv.value.(*rcommon.PolicySpec_AIAgentHandling_Remediation) 3705 case AlertState_FieldPathSelectorOperatorHandlingState: 3706 (*target).OperatorHandlingState = fpv.value.(Alert_State_OperatorHandlingState) 3707 case AlertState_FieldPathSelectorOperatorLastStateChangeTime: 3708 (*target).OperatorLastStateChangeTime = fpv.value.(*timestamppb.Timestamp) 3709 case AlertState_FieldPathSelectorOperatorNotes: 3710 (*target).OperatorNotes = fpv.value.(string) 3711 case AlertState_FieldPathSelectorLifecycleCompleted: 3712 (*target).LifecycleCompleted = fpv.value.(bool) 3713 default: 3714 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fpv.selector)) 3715 } 3716 } 3717 3718 func (fpv *AlertState_FieldTerminalPathValue) SetToRaw(target proto.Message) { 3719 typedObject := target.(*Alert_State) 3720 fpv.SetTo(&typedObject) 3721 } 3722 3723 // CompareWith compares value in the 'AlertState_FieldTerminalPathValue' with the value under path in 'Alert_State'. 3724 func (fpv *AlertState_FieldTerminalPathValue) CompareWith(source *Alert_State) (int, bool) { 3725 switch fpv.selector { 3726 case AlertState_FieldPathSelectorIsFiring: 3727 leftValue := fpv.value.(bool) 3728 rightValue := source.GetIsFiring() 3729 if (leftValue) == (rightValue) { 3730 return 0, true 3731 } else if !(leftValue) && (rightValue) { 3732 return -1, true 3733 } else { 3734 return 1, true 3735 } 3736 case AlertState_FieldPathSelectorStartTime: 3737 leftValue := fpv.value.(*timestamppb.Timestamp) 3738 rightValue := source.GetStartTime() 3739 if leftValue == nil { 3740 if rightValue != nil { 3741 return -1, true 3742 } 3743 return 0, true 3744 } 3745 if rightValue == nil { 3746 return 1, true 3747 } 3748 if leftValue.AsTime().Equal(rightValue.AsTime()) { 3749 return 0, true 3750 } else if leftValue.AsTime().Before(rightValue.AsTime()) { 3751 return -1, true 3752 } else { 3753 return 1, true 3754 } 3755 case AlertState_FieldPathSelectorEndTime: 3756 leftValue := fpv.value.(*timestamppb.Timestamp) 3757 rightValue := source.GetEndTime() 3758 if leftValue == nil { 3759 if rightValue != nil { 3760 return -1, true 3761 } 3762 return 0, true 3763 } 3764 if rightValue == nil { 3765 return 1, true 3766 } 3767 if leftValue.AsTime().Equal(rightValue.AsTime()) { 3768 return 0, true 3769 } else if leftValue.AsTime().Before(rightValue.AsTime()) { 3770 return -1, true 3771 } else { 3772 return 1, true 3773 } 3774 case AlertState_FieldPathSelectorNotificationStatuses: 3775 return 0, false 3776 case AlertState_FieldPathSelectorEscalationLevel: 3777 leftValue := fpv.value.(Alert_State_EscalationLevel) 3778 rightValue := source.GetEscalationLevel() 3779 if (leftValue) == (rightValue) { 3780 return 0, true 3781 } else if (leftValue) < (rightValue) { 3782 return -1, true 3783 } else { 3784 return 1, true 3785 } 3786 case AlertState_FieldPathSelectorAiAgentHandlingState: 3787 leftValue := fpv.value.(Alert_State_AiHandlingState) 3788 rightValue := source.GetAiAgentHandlingState() 3789 if (leftValue) == (rightValue) { 3790 return 0, true 3791 } else if (leftValue) < (rightValue) { 3792 return -1, true 3793 } else { 3794 return 1, true 3795 } 3796 case AlertState_FieldPathSelectorAiAgentLastStateChangeTime: 3797 leftValue := fpv.value.(*timestamppb.Timestamp) 3798 rightValue := source.GetAiAgentLastStateChangeTime() 3799 if leftValue == nil { 3800 if rightValue != nil { 3801 return -1, true 3802 } 3803 return 0, true 3804 } 3805 if rightValue == nil { 3806 return 1, true 3807 } 3808 if leftValue.AsTime().Equal(rightValue.AsTime()) { 3809 return 0, true 3810 } else if leftValue.AsTime().Before(rightValue.AsTime()) { 3811 return -1, true 3812 } else { 3813 return 1, true 3814 } 3815 case AlertState_FieldPathSelectorAiAgentDiagnosisNotes: 3816 leftValue := fpv.value.(string) 3817 rightValue := source.GetAiAgentDiagnosisNotes() 3818 if (leftValue) == (rightValue) { 3819 return 0, true 3820 } else if (leftValue) < (rightValue) { 3821 return -1, true 3822 } else { 3823 return 1, true 3824 } 3825 case AlertState_FieldPathSelectorAiRemediationArg: 3826 leftValue := fpv.value.(string) 3827 rightValue := source.GetAiRemediationArg() 3828 if (leftValue) == (rightValue) { 3829 return 0, true 3830 } else if (leftValue) < (rightValue) { 3831 return -1, true 3832 } else { 3833 return 1, true 3834 } 3835 case AlertState_FieldPathSelectorAiRemediation: 3836 return 0, false 3837 case AlertState_FieldPathSelectorOperatorHandlingState: 3838 leftValue := fpv.value.(Alert_State_OperatorHandlingState) 3839 rightValue := source.GetOperatorHandlingState() 3840 if (leftValue) == (rightValue) { 3841 return 0, true 3842 } else if (leftValue) < (rightValue) { 3843 return -1, true 3844 } else { 3845 return 1, true 3846 } 3847 case AlertState_FieldPathSelectorOperatorLastStateChangeTime: 3848 leftValue := fpv.value.(*timestamppb.Timestamp) 3849 rightValue := source.GetOperatorLastStateChangeTime() 3850 if leftValue == nil { 3851 if rightValue != nil { 3852 return -1, true 3853 } 3854 return 0, true 3855 } 3856 if rightValue == nil { 3857 return 1, true 3858 } 3859 if leftValue.AsTime().Equal(rightValue.AsTime()) { 3860 return 0, true 3861 } else if leftValue.AsTime().Before(rightValue.AsTime()) { 3862 return -1, true 3863 } else { 3864 return 1, true 3865 } 3866 case AlertState_FieldPathSelectorOperatorNotes: 3867 leftValue := fpv.value.(string) 3868 rightValue := source.GetOperatorNotes() 3869 if (leftValue) == (rightValue) { 3870 return 0, true 3871 } else if (leftValue) < (rightValue) { 3872 return -1, true 3873 } else { 3874 return 1, true 3875 } 3876 case AlertState_FieldPathSelectorLifecycleCompleted: 3877 leftValue := fpv.value.(bool) 3878 rightValue := source.GetLifecycleCompleted() 3879 if (leftValue) == (rightValue) { 3880 return 0, true 3881 } else if !(leftValue) && (rightValue) { 3882 return -1, true 3883 } else { 3884 return 1, true 3885 } 3886 default: 3887 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fpv.selector)) 3888 } 3889 } 3890 3891 func (fpv *AlertState_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 3892 return fpv.CompareWith(source.(*Alert_State)) 3893 } 3894 3895 type AlertState_FieldSubPathValue struct { 3896 AlertState_FieldPath 3897 subPathValue gotenobject.FieldPathValue 3898 } 3899 3900 var _ AlertState_FieldPathValue = (*AlertState_FieldSubPathValue)(nil) 3901 3902 func (fpvs *AlertState_FieldSubPathValue) AsNotificationStatusesPathValue() (AlertStateNotification_FieldPathValue, bool) { 3903 res, ok := fpvs.subPathValue.(AlertStateNotification_FieldPathValue) 3904 return res, ok 3905 } 3906 func (fpvs *AlertState_FieldSubPathValue) AsAiRemediationPathValue() (rcommon.PolicySpecAIAgentHandlingRemediation_FieldPathValue, bool) { 3907 res, ok := fpvs.subPathValue.(rcommon.PolicySpecAIAgentHandlingRemediation_FieldPathValue) 3908 return res, ok 3909 } 3910 3911 func (fpvs *AlertState_FieldSubPathValue) SetTo(target **Alert_State) { 3912 if *target == nil { 3913 *target = new(Alert_State) 3914 } 3915 switch fpvs.Selector() { 3916 case AlertState_FieldPathSelectorNotificationStatuses: 3917 panic("FieldPath setter is unsupported for array subpaths") 3918 case AlertState_FieldPathSelectorAiRemediation: 3919 fpvs.subPathValue.(rcommon.PolicySpecAIAgentHandlingRemediation_FieldPathValue).SetTo(&(*target).AiRemediation) 3920 default: 3921 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fpvs.Selector())) 3922 } 3923 } 3924 3925 func (fpvs *AlertState_FieldSubPathValue) SetToRaw(target proto.Message) { 3926 typedObject := target.(*Alert_State) 3927 fpvs.SetTo(&typedObject) 3928 } 3929 3930 func (fpvs *AlertState_FieldSubPathValue) GetRawValue() interface{} { 3931 return fpvs.subPathValue.GetRawValue() 3932 } 3933 3934 func (fpvs *AlertState_FieldSubPathValue) CompareWith(source *Alert_State) (int, bool) { 3935 switch fpvs.Selector() { 3936 case AlertState_FieldPathSelectorNotificationStatuses: 3937 return 0, false // repeated field 3938 case AlertState_FieldPathSelectorAiRemediation: 3939 return fpvs.subPathValue.(rcommon.PolicySpecAIAgentHandlingRemediation_FieldPathValue).CompareWith(source.GetAiRemediation()) 3940 default: 3941 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fpvs.Selector())) 3942 } 3943 } 3944 3945 func (fpvs *AlertState_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 3946 return fpvs.CompareWith(source.(*Alert_State)) 3947 } 3948 3949 // AlertState_FieldPathArrayItemValue allows storing single item in Path-specific values for State according to their type 3950 // Present only for array (repeated) types. 3951 type AlertState_FieldPathArrayItemValue interface { 3952 gotenobject.FieldPathArrayItemValue 3953 AlertState_FieldPath 3954 ContainsValue(*Alert_State) bool 3955 } 3956 3957 // ParseAlertState_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 3958 func ParseAlertState_FieldPathArrayItemValue(pathStr, valueStr string) (AlertState_FieldPathArrayItemValue, error) { 3959 fp, err := ParseAlertState_FieldPath(pathStr) 3960 if err != nil { 3961 return nil, err 3962 } 3963 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 3964 if err != nil { 3965 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path array item value from %s: %v", valueStr, err) 3966 } 3967 return fpaiv.(AlertState_FieldPathArrayItemValue), nil 3968 } 3969 3970 func MustParseAlertState_FieldPathArrayItemValue(pathStr, valueStr string) AlertState_FieldPathArrayItemValue { 3971 fpaiv, err := ParseAlertState_FieldPathArrayItemValue(pathStr, valueStr) 3972 if err != nil { 3973 panic(err) 3974 } 3975 return fpaiv 3976 } 3977 3978 type AlertState_FieldTerminalPathArrayItemValue struct { 3979 AlertState_FieldTerminalPath 3980 value interface{} 3981 } 3982 3983 var _ AlertState_FieldPathArrayItemValue = (*AlertState_FieldTerminalPathArrayItemValue)(nil) 3984 3985 // GetRawValue returns stored element value for array in object Alert_State as interface{} 3986 func (fpaiv *AlertState_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 3987 return fpaiv.value 3988 } 3989 func (fpaiv *AlertState_FieldTerminalPathArrayItemValue) AsNotificationStatusesItemValue() (*Alert_State_Notification, bool) { 3990 res, ok := fpaiv.value.(*Alert_State_Notification) 3991 return res, ok 3992 } 3993 3994 func (fpaiv *AlertState_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_State) (interface{}, bool) { 3995 return nil, false 3996 } 3997 3998 func (fpaiv *AlertState_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 3999 return fpaiv.GetSingle(source.(*Alert_State)) 4000 } 4001 4002 // Contains returns a boolean indicating if value that is being held is present in given 'State' 4003 func (fpaiv *AlertState_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_State) bool { 4004 slice := fpaiv.AlertState_FieldTerminalPath.Get(source) 4005 for _, v := range slice { 4006 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 4007 if proto.Equal(asProtoMsg, v.(proto.Message)) { 4008 return true 4009 } 4010 } else if reflect.DeepEqual(v, fpaiv.value) { 4011 return true 4012 } 4013 } 4014 return false 4015 } 4016 4017 type AlertState_FieldSubPathArrayItemValue struct { 4018 AlertState_FieldPath 4019 subPathItemValue gotenobject.FieldPathArrayItemValue 4020 } 4021 4022 // GetRawValue returns stored array item value 4023 func (fpaivs *AlertState_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 4024 return fpaivs.subPathItemValue.GetRawItemValue() 4025 } 4026 func (fpaivs *AlertState_FieldSubPathArrayItemValue) AsNotificationStatusesPathItemValue() (AlertStateNotification_FieldPathArrayItemValue, bool) { 4027 res, ok := fpaivs.subPathItemValue.(AlertStateNotification_FieldPathArrayItemValue) 4028 return res, ok 4029 } 4030 func (fpaivs *AlertState_FieldSubPathArrayItemValue) AsAiRemediationPathItemValue() (rcommon.PolicySpecAIAgentHandlingRemediation_FieldPathArrayItemValue, bool) { 4031 res, ok := fpaivs.subPathItemValue.(rcommon.PolicySpecAIAgentHandlingRemediation_FieldPathArrayItemValue) 4032 return res, ok 4033 } 4034 4035 // Contains returns a boolean indicating if value that is being held is present in given 'State' 4036 func (fpaivs *AlertState_FieldSubPathArrayItemValue) ContainsValue(source *Alert_State) bool { 4037 switch fpaivs.Selector() { 4038 case AlertState_FieldPathSelectorNotificationStatuses: 4039 return false // repeated/map field 4040 case AlertState_FieldPathSelectorAiRemediation: 4041 return fpaivs.subPathItemValue.(rcommon.PolicySpecAIAgentHandlingRemediation_FieldPathArrayItemValue).ContainsValue(source.GetAiRemediation()) 4042 default: 4043 panic(fmt.Sprintf("Invalid selector for Alert_State: %d", fpaivs.Selector())) 4044 } 4045 } 4046 4047 // AlertState_FieldPathArrayOfValues allows storing slice of values for State fields according to their type 4048 type AlertState_FieldPathArrayOfValues interface { 4049 gotenobject.FieldPathArrayOfValues 4050 AlertState_FieldPath 4051 } 4052 4053 func ParseAlertState_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertState_FieldPathArrayOfValues, error) { 4054 fp, err := ParseAlertState_FieldPath(pathStr) 4055 if err != nil { 4056 return nil, err 4057 } 4058 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 4059 if err != nil { 4060 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path array of values from %s: %v", valuesStr, err) 4061 } 4062 return fpaov.(AlertState_FieldPathArrayOfValues), nil 4063 } 4064 4065 func MustParseAlertState_FieldPathArrayOfValues(pathStr, valuesStr string) AlertState_FieldPathArrayOfValues { 4066 fpaov, err := ParseAlertState_FieldPathArrayOfValues(pathStr, valuesStr) 4067 if err != nil { 4068 panic(err) 4069 } 4070 return fpaov 4071 } 4072 4073 type AlertState_FieldTerminalPathArrayOfValues struct { 4074 AlertState_FieldTerminalPath 4075 values interface{} 4076 } 4077 4078 var _ AlertState_FieldPathArrayOfValues = (*AlertState_FieldTerminalPathArrayOfValues)(nil) 4079 4080 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 4081 switch fpaov.selector { 4082 case AlertState_FieldPathSelectorIsFiring: 4083 for _, v := range fpaov.values.([]bool) { 4084 values = append(values, v) 4085 } 4086 case AlertState_FieldPathSelectorStartTime: 4087 for _, v := range fpaov.values.([]*timestamppb.Timestamp) { 4088 values = append(values, v) 4089 } 4090 case AlertState_FieldPathSelectorEndTime: 4091 for _, v := range fpaov.values.([]*timestamppb.Timestamp) { 4092 values = append(values, v) 4093 } 4094 case AlertState_FieldPathSelectorNotificationStatuses: 4095 for _, v := range fpaov.values.([][]*Alert_State_Notification) { 4096 values = append(values, v) 4097 } 4098 case AlertState_FieldPathSelectorEscalationLevel: 4099 for _, v := range fpaov.values.([]Alert_State_EscalationLevel) { 4100 values = append(values, v) 4101 } 4102 case AlertState_FieldPathSelectorAiAgentHandlingState: 4103 for _, v := range fpaov.values.([]Alert_State_AiHandlingState) { 4104 values = append(values, v) 4105 } 4106 case AlertState_FieldPathSelectorAiAgentLastStateChangeTime: 4107 for _, v := range fpaov.values.([]*timestamppb.Timestamp) { 4108 values = append(values, v) 4109 } 4110 case AlertState_FieldPathSelectorAiAgentDiagnosisNotes: 4111 for _, v := range fpaov.values.([]string) { 4112 values = append(values, v) 4113 } 4114 case AlertState_FieldPathSelectorAiRemediationArg: 4115 for _, v := range fpaov.values.([]string) { 4116 values = append(values, v) 4117 } 4118 case AlertState_FieldPathSelectorAiRemediation: 4119 for _, v := range fpaov.values.([]*rcommon.PolicySpec_AIAgentHandling_Remediation) { 4120 values = append(values, v) 4121 } 4122 case AlertState_FieldPathSelectorOperatorHandlingState: 4123 for _, v := range fpaov.values.([]Alert_State_OperatorHandlingState) { 4124 values = append(values, v) 4125 } 4126 case AlertState_FieldPathSelectorOperatorLastStateChangeTime: 4127 for _, v := range fpaov.values.([]*timestamppb.Timestamp) { 4128 values = append(values, v) 4129 } 4130 case AlertState_FieldPathSelectorOperatorNotes: 4131 for _, v := range fpaov.values.([]string) { 4132 values = append(values, v) 4133 } 4134 case AlertState_FieldPathSelectorLifecycleCompleted: 4135 for _, v := range fpaov.values.([]bool) { 4136 values = append(values, v) 4137 } 4138 } 4139 return 4140 } 4141 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsIsFiringArrayOfValues() ([]bool, bool) { 4142 res, ok := fpaov.values.([]bool) 4143 return res, ok 4144 } 4145 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsStartTimeArrayOfValues() ([]*timestamppb.Timestamp, bool) { 4146 res, ok := fpaov.values.([]*timestamppb.Timestamp) 4147 return res, ok 4148 } 4149 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsEndTimeArrayOfValues() ([]*timestamppb.Timestamp, bool) { 4150 res, ok := fpaov.values.([]*timestamppb.Timestamp) 4151 return res, ok 4152 } 4153 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsNotificationStatusesArrayOfValues() ([][]*Alert_State_Notification, bool) { 4154 res, ok := fpaov.values.([][]*Alert_State_Notification) 4155 return res, ok 4156 } 4157 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsEscalationLevelArrayOfValues() ([]Alert_State_EscalationLevel, bool) { 4158 res, ok := fpaov.values.([]Alert_State_EscalationLevel) 4159 return res, ok 4160 } 4161 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsAiAgentHandlingStateArrayOfValues() ([]Alert_State_AiHandlingState, bool) { 4162 res, ok := fpaov.values.([]Alert_State_AiHandlingState) 4163 return res, ok 4164 } 4165 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsAiAgentLastStateChangeTimeArrayOfValues() ([]*timestamppb.Timestamp, bool) { 4166 res, ok := fpaov.values.([]*timestamppb.Timestamp) 4167 return res, ok 4168 } 4169 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsAiAgentDiagnosisNotesArrayOfValues() ([]string, bool) { 4170 res, ok := fpaov.values.([]string) 4171 return res, ok 4172 } 4173 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsAiRemediationArgArrayOfValues() ([]string, bool) { 4174 res, ok := fpaov.values.([]string) 4175 return res, ok 4176 } 4177 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsAiRemediationArrayOfValues() ([]*rcommon.PolicySpec_AIAgentHandling_Remediation, bool) { 4178 res, ok := fpaov.values.([]*rcommon.PolicySpec_AIAgentHandling_Remediation) 4179 return res, ok 4180 } 4181 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsOperatorHandlingStateArrayOfValues() ([]Alert_State_OperatorHandlingState, bool) { 4182 res, ok := fpaov.values.([]Alert_State_OperatorHandlingState) 4183 return res, ok 4184 } 4185 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsOperatorLastStateChangeTimeArrayOfValues() ([]*timestamppb.Timestamp, bool) { 4186 res, ok := fpaov.values.([]*timestamppb.Timestamp) 4187 return res, ok 4188 } 4189 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsOperatorNotesArrayOfValues() ([]string, bool) { 4190 res, ok := fpaov.values.([]string) 4191 return res, ok 4192 } 4193 func (fpaov *AlertState_FieldTerminalPathArrayOfValues) AsLifecycleCompletedArrayOfValues() ([]bool, bool) { 4194 res, ok := fpaov.values.([]bool) 4195 return res, ok 4196 } 4197 4198 type AlertState_FieldSubPathArrayOfValues struct { 4199 AlertState_FieldPath 4200 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 4201 } 4202 4203 var _ AlertState_FieldPathArrayOfValues = (*AlertState_FieldSubPathArrayOfValues)(nil) 4204 4205 func (fpsaov *AlertState_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 4206 return fpsaov.subPathArrayOfValues.GetRawValues() 4207 } 4208 func (fpsaov *AlertState_FieldSubPathArrayOfValues) AsNotificationStatusesPathArrayOfValues() (AlertStateNotification_FieldPathArrayOfValues, bool) { 4209 res, ok := fpsaov.subPathArrayOfValues.(AlertStateNotification_FieldPathArrayOfValues) 4210 return res, ok 4211 } 4212 func (fpsaov *AlertState_FieldSubPathArrayOfValues) AsAiRemediationPathArrayOfValues() (rcommon.PolicySpecAIAgentHandlingRemediation_FieldPathArrayOfValues, bool) { 4213 res, ok := fpsaov.subPathArrayOfValues.(rcommon.PolicySpecAIAgentHandlingRemediation_FieldPathArrayOfValues) 4214 return res, ok 4215 } 4216 4217 // FieldPath provides implementation to handle 4218 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 4219 type AlertInternal_FieldPath interface { 4220 gotenobject.FieldPath 4221 Selector() AlertInternal_FieldPathSelector 4222 Get(source *Alert_Internal) []interface{} 4223 GetSingle(source *Alert_Internal) (interface{}, bool) 4224 ClearValue(item *Alert_Internal) 4225 4226 // Those methods build corresponding AlertInternal_FieldPathValue 4227 // (or array of values) and holds passed value. Panics if injected type is incorrect. 4228 WithIValue(value interface{}) AlertInternal_FieldPathValue 4229 WithIArrayOfValues(values interface{}) AlertInternal_FieldPathArrayOfValues 4230 WithIArrayItemValue(value interface{}) AlertInternal_FieldPathArrayItemValue 4231 } 4232 4233 type AlertInternal_FieldPathSelector int32 4234 4235 const ( 4236 AlertInternal_FieldPathSelectorAlertingLocation AlertInternal_FieldPathSelector = 0 4237 ) 4238 4239 func (s AlertInternal_FieldPathSelector) String() string { 4240 switch s { 4241 case AlertInternal_FieldPathSelectorAlertingLocation: 4242 return "alerting_location" 4243 default: 4244 panic(fmt.Sprintf("Invalid selector for Alert_Internal: %d", s)) 4245 } 4246 } 4247 4248 func BuildAlertInternal_FieldPath(fp gotenobject.RawFieldPath) (AlertInternal_FieldPath, error) { 4249 if len(fp) == 0 { 4250 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_Internal") 4251 } 4252 if len(fp) == 1 { 4253 switch fp[0] { 4254 case "alerting_location", "alertingLocation", "alerting-location": 4255 return &AlertInternal_FieldTerminalPath{selector: AlertInternal_FieldPathSelectorAlertingLocation}, nil 4256 } 4257 } 4258 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_Internal", fp) 4259 } 4260 4261 func ParseAlertInternal_FieldPath(rawField string) (AlertInternal_FieldPath, error) { 4262 fp, err := gotenobject.ParseRawFieldPath(rawField) 4263 if err != nil { 4264 return nil, err 4265 } 4266 return BuildAlertInternal_FieldPath(fp) 4267 } 4268 4269 func MustParseAlertInternal_FieldPath(rawField string) AlertInternal_FieldPath { 4270 fp, err := ParseAlertInternal_FieldPath(rawField) 4271 if err != nil { 4272 panic(err) 4273 } 4274 return fp 4275 } 4276 4277 type AlertInternal_FieldTerminalPath struct { 4278 selector AlertInternal_FieldPathSelector 4279 } 4280 4281 var _ AlertInternal_FieldPath = (*AlertInternal_FieldTerminalPath)(nil) 4282 4283 func (fp *AlertInternal_FieldTerminalPath) Selector() AlertInternal_FieldPathSelector { 4284 return fp.selector 4285 } 4286 4287 // String returns path representation in proto convention 4288 func (fp *AlertInternal_FieldTerminalPath) String() string { 4289 return fp.selector.String() 4290 } 4291 4292 // JSONString returns path representation is JSON convention 4293 func (fp *AlertInternal_FieldTerminalPath) JSONString() string { 4294 return strcase.ToLowerCamel(fp.String()) 4295 } 4296 4297 // Get returns all values pointed by specific field from source Alert_Internal 4298 func (fp *AlertInternal_FieldTerminalPath) Get(source *Alert_Internal) (values []interface{}) { 4299 if source != nil { 4300 switch fp.selector { 4301 case AlertInternal_FieldPathSelectorAlertingLocation: 4302 values = append(values, source.AlertingLocation) 4303 default: 4304 panic(fmt.Sprintf("Invalid selector for Alert_Internal: %d", fp.selector)) 4305 } 4306 } 4307 return 4308 } 4309 4310 func (fp *AlertInternal_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 4311 return fp.Get(source.(*Alert_Internal)) 4312 } 4313 4314 // GetSingle returns value pointed by specific field of from source Alert_Internal 4315 func (fp *AlertInternal_FieldTerminalPath) GetSingle(source *Alert_Internal) (interface{}, bool) { 4316 switch fp.selector { 4317 case AlertInternal_FieldPathSelectorAlertingLocation: 4318 return source.GetAlertingLocation(), source != nil 4319 default: 4320 panic(fmt.Sprintf("Invalid selector for Alert_Internal: %d", fp.selector)) 4321 } 4322 } 4323 4324 func (fp *AlertInternal_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 4325 return fp.GetSingle(source.(*Alert_Internal)) 4326 } 4327 4328 // GetDefault returns a default value of the field type 4329 func (fp *AlertInternal_FieldTerminalPath) GetDefault() interface{} { 4330 switch fp.selector { 4331 case AlertInternal_FieldPathSelectorAlertingLocation: 4332 return rcommon.PolicySpec_UNDEFINED 4333 default: 4334 panic(fmt.Sprintf("Invalid selector for Alert_Internal: %d", fp.selector)) 4335 } 4336 } 4337 4338 func (fp *AlertInternal_FieldTerminalPath) ClearValue(item *Alert_Internal) { 4339 if item != nil { 4340 switch fp.selector { 4341 case AlertInternal_FieldPathSelectorAlertingLocation: 4342 item.AlertingLocation = rcommon.PolicySpec_UNDEFINED 4343 default: 4344 panic(fmt.Sprintf("Invalid selector for Alert_Internal: %d", fp.selector)) 4345 } 4346 } 4347 } 4348 4349 func (fp *AlertInternal_FieldTerminalPath) ClearValueRaw(item proto.Message) { 4350 fp.ClearValue(item.(*Alert_Internal)) 4351 } 4352 4353 // IsLeaf - whether field path is holds simple value 4354 func (fp *AlertInternal_FieldTerminalPath) IsLeaf() bool { 4355 return fp.selector == AlertInternal_FieldPathSelectorAlertingLocation 4356 } 4357 4358 func (fp *AlertInternal_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 4359 return []gotenobject.FieldPath{fp} 4360 } 4361 4362 func (fp *AlertInternal_FieldTerminalPath) WithIValue(value interface{}) AlertInternal_FieldPathValue { 4363 switch fp.selector { 4364 case AlertInternal_FieldPathSelectorAlertingLocation: 4365 return &AlertInternal_FieldTerminalPathValue{AlertInternal_FieldTerminalPath: *fp, value: value.(rcommon.PolicySpec_ProcessingLocation)} 4366 default: 4367 panic(fmt.Sprintf("Invalid selector for Alert_Internal: %d", fp.selector)) 4368 } 4369 } 4370 4371 func (fp *AlertInternal_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 4372 return fp.WithIValue(value) 4373 } 4374 4375 func (fp *AlertInternal_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertInternal_FieldPathArrayOfValues { 4376 fpaov := &AlertInternal_FieldTerminalPathArrayOfValues{AlertInternal_FieldTerminalPath: *fp} 4377 switch fp.selector { 4378 case AlertInternal_FieldPathSelectorAlertingLocation: 4379 return &AlertInternal_FieldTerminalPathArrayOfValues{AlertInternal_FieldTerminalPath: *fp, values: values.([]rcommon.PolicySpec_ProcessingLocation)} 4380 default: 4381 panic(fmt.Sprintf("Invalid selector for Alert_Internal: %d", fp.selector)) 4382 } 4383 return fpaov 4384 } 4385 4386 func (fp *AlertInternal_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 4387 return fp.WithIArrayOfValues(values) 4388 } 4389 4390 func (fp *AlertInternal_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertInternal_FieldPathArrayItemValue { 4391 switch fp.selector { 4392 default: 4393 panic(fmt.Sprintf("Invalid selector for Alert_Internal: %d", fp.selector)) 4394 } 4395 } 4396 4397 func (fp *AlertInternal_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 4398 return fp.WithIArrayItemValue(value) 4399 } 4400 4401 // AlertInternal_FieldPathValue allows storing values for Internal fields according to their type 4402 type AlertInternal_FieldPathValue interface { 4403 AlertInternal_FieldPath 4404 gotenobject.FieldPathValue 4405 SetTo(target **Alert_Internal) 4406 CompareWith(*Alert_Internal) (cmp int, comparable bool) 4407 } 4408 4409 func ParseAlertInternal_FieldPathValue(pathStr, valueStr string) (AlertInternal_FieldPathValue, error) { 4410 fp, err := ParseAlertInternal_FieldPath(pathStr) 4411 if err != nil { 4412 return nil, err 4413 } 4414 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 4415 if err != nil { 4416 return nil, status.Errorf(codes.InvalidArgument, "error parsing Internal field path value from %s: %v", valueStr, err) 4417 } 4418 return fpv.(AlertInternal_FieldPathValue), nil 4419 } 4420 4421 func MustParseAlertInternal_FieldPathValue(pathStr, valueStr string) AlertInternal_FieldPathValue { 4422 fpv, err := ParseAlertInternal_FieldPathValue(pathStr, valueStr) 4423 if err != nil { 4424 panic(err) 4425 } 4426 return fpv 4427 } 4428 4429 type AlertInternal_FieldTerminalPathValue struct { 4430 AlertInternal_FieldTerminalPath 4431 value interface{} 4432 } 4433 4434 var _ AlertInternal_FieldPathValue = (*AlertInternal_FieldTerminalPathValue)(nil) 4435 4436 // GetRawValue returns raw value stored under selected path for 'Internal' as interface{} 4437 func (fpv *AlertInternal_FieldTerminalPathValue) GetRawValue() interface{} { 4438 return fpv.value 4439 } 4440 func (fpv *AlertInternal_FieldTerminalPathValue) AsAlertingLocationValue() (rcommon.PolicySpec_ProcessingLocation, bool) { 4441 res, ok := fpv.value.(rcommon.PolicySpec_ProcessingLocation) 4442 return res, ok 4443 } 4444 4445 // SetTo stores value for selected field for object Internal 4446 func (fpv *AlertInternal_FieldTerminalPathValue) SetTo(target **Alert_Internal) { 4447 if *target == nil { 4448 *target = new(Alert_Internal) 4449 } 4450 switch fpv.selector { 4451 case AlertInternal_FieldPathSelectorAlertingLocation: 4452 (*target).AlertingLocation = fpv.value.(rcommon.PolicySpec_ProcessingLocation) 4453 default: 4454 panic(fmt.Sprintf("Invalid selector for Alert_Internal: %d", fpv.selector)) 4455 } 4456 } 4457 4458 func (fpv *AlertInternal_FieldTerminalPathValue) SetToRaw(target proto.Message) { 4459 typedObject := target.(*Alert_Internal) 4460 fpv.SetTo(&typedObject) 4461 } 4462 4463 // CompareWith compares value in the 'AlertInternal_FieldTerminalPathValue' with the value under path in 'Alert_Internal'. 4464 func (fpv *AlertInternal_FieldTerminalPathValue) CompareWith(source *Alert_Internal) (int, bool) { 4465 switch fpv.selector { 4466 case AlertInternal_FieldPathSelectorAlertingLocation: 4467 leftValue := fpv.value.(rcommon.PolicySpec_ProcessingLocation) 4468 rightValue := source.GetAlertingLocation() 4469 if (leftValue) == (rightValue) { 4470 return 0, true 4471 } else if (leftValue) < (rightValue) { 4472 return -1, true 4473 } else { 4474 return 1, true 4475 } 4476 default: 4477 panic(fmt.Sprintf("Invalid selector for Alert_Internal: %d", fpv.selector)) 4478 } 4479 } 4480 4481 func (fpv *AlertInternal_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 4482 return fpv.CompareWith(source.(*Alert_Internal)) 4483 } 4484 4485 // AlertInternal_FieldPathArrayItemValue allows storing single item in Path-specific values for Internal according to their type 4486 // Present only for array (repeated) types. 4487 type AlertInternal_FieldPathArrayItemValue interface { 4488 gotenobject.FieldPathArrayItemValue 4489 AlertInternal_FieldPath 4490 ContainsValue(*Alert_Internal) bool 4491 } 4492 4493 // ParseAlertInternal_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 4494 func ParseAlertInternal_FieldPathArrayItemValue(pathStr, valueStr string) (AlertInternal_FieldPathArrayItemValue, error) { 4495 fp, err := ParseAlertInternal_FieldPath(pathStr) 4496 if err != nil { 4497 return nil, err 4498 } 4499 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 4500 if err != nil { 4501 return nil, status.Errorf(codes.InvalidArgument, "error parsing Internal field path array item value from %s: %v", valueStr, err) 4502 } 4503 return fpaiv.(AlertInternal_FieldPathArrayItemValue), nil 4504 } 4505 4506 func MustParseAlertInternal_FieldPathArrayItemValue(pathStr, valueStr string) AlertInternal_FieldPathArrayItemValue { 4507 fpaiv, err := ParseAlertInternal_FieldPathArrayItemValue(pathStr, valueStr) 4508 if err != nil { 4509 panic(err) 4510 } 4511 return fpaiv 4512 } 4513 4514 type AlertInternal_FieldTerminalPathArrayItemValue struct { 4515 AlertInternal_FieldTerminalPath 4516 value interface{} 4517 } 4518 4519 var _ AlertInternal_FieldPathArrayItemValue = (*AlertInternal_FieldTerminalPathArrayItemValue)(nil) 4520 4521 // GetRawValue returns stored element value for array in object Alert_Internal as interface{} 4522 func (fpaiv *AlertInternal_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 4523 return fpaiv.value 4524 } 4525 4526 func (fpaiv *AlertInternal_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_Internal) (interface{}, bool) { 4527 return nil, false 4528 } 4529 4530 func (fpaiv *AlertInternal_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 4531 return fpaiv.GetSingle(source.(*Alert_Internal)) 4532 } 4533 4534 // Contains returns a boolean indicating if value that is being held is present in given 'Internal' 4535 func (fpaiv *AlertInternal_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_Internal) bool { 4536 slice := fpaiv.AlertInternal_FieldTerminalPath.Get(source) 4537 for _, v := range slice { 4538 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 4539 if proto.Equal(asProtoMsg, v.(proto.Message)) { 4540 return true 4541 } 4542 } else if reflect.DeepEqual(v, fpaiv.value) { 4543 return true 4544 } 4545 } 4546 return false 4547 } 4548 4549 // AlertInternal_FieldPathArrayOfValues allows storing slice of values for Internal fields according to their type 4550 type AlertInternal_FieldPathArrayOfValues interface { 4551 gotenobject.FieldPathArrayOfValues 4552 AlertInternal_FieldPath 4553 } 4554 4555 func ParseAlertInternal_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertInternal_FieldPathArrayOfValues, error) { 4556 fp, err := ParseAlertInternal_FieldPath(pathStr) 4557 if err != nil { 4558 return nil, err 4559 } 4560 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 4561 if err != nil { 4562 return nil, status.Errorf(codes.InvalidArgument, "error parsing Internal field path array of values from %s: %v", valuesStr, err) 4563 } 4564 return fpaov.(AlertInternal_FieldPathArrayOfValues), nil 4565 } 4566 4567 func MustParseAlertInternal_FieldPathArrayOfValues(pathStr, valuesStr string) AlertInternal_FieldPathArrayOfValues { 4568 fpaov, err := ParseAlertInternal_FieldPathArrayOfValues(pathStr, valuesStr) 4569 if err != nil { 4570 panic(err) 4571 } 4572 return fpaov 4573 } 4574 4575 type AlertInternal_FieldTerminalPathArrayOfValues struct { 4576 AlertInternal_FieldTerminalPath 4577 values interface{} 4578 } 4579 4580 var _ AlertInternal_FieldPathArrayOfValues = (*AlertInternal_FieldTerminalPathArrayOfValues)(nil) 4581 4582 func (fpaov *AlertInternal_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 4583 switch fpaov.selector { 4584 case AlertInternal_FieldPathSelectorAlertingLocation: 4585 for _, v := range fpaov.values.([]rcommon.PolicySpec_ProcessingLocation) { 4586 values = append(values, v) 4587 } 4588 } 4589 return 4590 } 4591 func (fpaov *AlertInternal_FieldTerminalPathArrayOfValues) AsAlertingLocationArrayOfValues() ([]rcommon.PolicySpec_ProcessingLocation, bool) { 4592 res, ok := fpaov.values.([]rcommon.PolicySpec_ProcessingLocation) 4593 return res, ok 4594 } 4595 4596 // FieldPath provides implementation to handle 4597 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 4598 type AlertTsInfoTimeSeries_FieldPath interface { 4599 gotenobject.FieldPath 4600 Selector() AlertTsInfoTimeSeries_FieldPathSelector 4601 Get(source *Alert_TsInfo_TimeSeries) []interface{} 4602 GetSingle(source *Alert_TsInfo_TimeSeries) (interface{}, bool) 4603 ClearValue(item *Alert_TsInfo_TimeSeries) 4604 4605 // Those methods build corresponding AlertTsInfoTimeSeries_FieldPathValue 4606 // (or array of values) and holds passed value. Panics if injected type is incorrect. 4607 WithIValue(value interface{}) AlertTsInfoTimeSeries_FieldPathValue 4608 WithIArrayOfValues(values interface{}) AlertTsInfoTimeSeries_FieldPathArrayOfValues 4609 WithIArrayItemValue(value interface{}) AlertTsInfoTimeSeries_FieldPathArrayItemValue 4610 } 4611 4612 type AlertTsInfoTimeSeries_FieldPathSelector int32 4613 4614 const ( 4615 AlertTsInfoTimeSeries_FieldPathSelectorQueryName AlertTsInfoTimeSeries_FieldPathSelector = 0 4616 AlertTsInfoTimeSeries_FieldPathSelectorValues AlertTsInfoTimeSeries_FieldPathSelector = 1 4617 AlertTsInfoTimeSeries_FieldPathSelectorAnomalies AlertTsInfoTimeSeries_FieldPathSelector = 2 4618 AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold AlertTsInfoTimeSeries_FieldPathSelector = 3 4619 AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold AlertTsInfoTimeSeries_FieldPathSelector = 4 4620 AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold AlertTsInfoTimeSeries_FieldPathSelector = 5 4621 AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration AlertTsInfoTimeSeries_FieldPathSelector = 6 4622 ) 4623 4624 func (s AlertTsInfoTimeSeries_FieldPathSelector) String() string { 4625 switch s { 4626 case AlertTsInfoTimeSeries_FieldPathSelectorQueryName: 4627 return "query_name" 4628 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 4629 return "values" 4630 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 4631 return "anomalies" 4632 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 4633 return "upper_threshold" 4634 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 4635 return "lower_threshold" 4636 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold: 4637 return "anomaly_threshold" 4638 case AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration: 4639 return "after_duration" 4640 default: 4641 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", s)) 4642 } 4643 } 4644 4645 func BuildAlertTsInfoTimeSeries_FieldPath(fp gotenobject.RawFieldPath) (AlertTsInfoTimeSeries_FieldPath, error) { 4646 if len(fp) == 0 { 4647 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_TsInfo_TimeSeries") 4648 } 4649 if len(fp) == 1 { 4650 switch fp[0] { 4651 case "query_name", "queryName", "query-name": 4652 return &AlertTsInfoTimeSeries_FieldTerminalPath{selector: AlertTsInfoTimeSeries_FieldPathSelectorQueryName}, nil 4653 case "values": 4654 return &AlertTsInfoTimeSeries_FieldTerminalPath{selector: AlertTsInfoTimeSeries_FieldPathSelectorValues}, nil 4655 case "anomalies": 4656 return &AlertTsInfoTimeSeries_FieldTerminalPath{selector: AlertTsInfoTimeSeries_FieldPathSelectorAnomalies}, nil 4657 case "upper_threshold", "upperThreshold", "upper-threshold": 4658 return &AlertTsInfoTimeSeries_FieldTerminalPath{selector: AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold}, nil 4659 case "lower_threshold", "lowerThreshold", "lower-threshold": 4660 return &AlertTsInfoTimeSeries_FieldTerminalPath{selector: AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold}, nil 4661 case "anomaly_threshold", "anomalyThreshold", "anomaly-threshold": 4662 return &AlertTsInfoTimeSeries_FieldTerminalPath{selector: AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold}, nil 4663 case "after_duration", "afterDuration", "after-duration": 4664 return &AlertTsInfoTimeSeries_FieldTerminalPath{selector: AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration}, nil 4665 } 4666 } else { 4667 switch fp[0] { 4668 case "upper_threshold", "upperThreshold", "upper-threshold": 4669 if subpath, err := rcommon.BuildAlertingThreshold_FieldPath(fp[1:]); err != nil { 4670 return nil, err 4671 } else { 4672 return &AlertTsInfoTimeSeries_FieldSubPath{selector: AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold, subPath: subpath}, nil 4673 } 4674 case "lower_threshold", "lowerThreshold", "lower-threshold": 4675 if subpath, err := rcommon.BuildAlertingThreshold_FieldPath(fp[1:]); err != nil { 4676 return nil, err 4677 } else { 4678 return &AlertTsInfoTimeSeries_FieldSubPath{selector: AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold, subPath: subpath}, nil 4679 } 4680 } 4681 } 4682 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_TsInfo_TimeSeries", fp) 4683 } 4684 4685 func ParseAlertTsInfoTimeSeries_FieldPath(rawField string) (AlertTsInfoTimeSeries_FieldPath, error) { 4686 fp, err := gotenobject.ParseRawFieldPath(rawField) 4687 if err != nil { 4688 return nil, err 4689 } 4690 return BuildAlertTsInfoTimeSeries_FieldPath(fp) 4691 } 4692 4693 func MustParseAlertTsInfoTimeSeries_FieldPath(rawField string) AlertTsInfoTimeSeries_FieldPath { 4694 fp, err := ParseAlertTsInfoTimeSeries_FieldPath(rawField) 4695 if err != nil { 4696 panic(err) 4697 } 4698 return fp 4699 } 4700 4701 type AlertTsInfoTimeSeries_FieldTerminalPath struct { 4702 selector AlertTsInfoTimeSeries_FieldPathSelector 4703 } 4704 4705 var _ AlertTsInfoTimeSeries_FieldPath = (*AlertTsInfoTimeSeries_FieldTerminalPath)(nil) 4706 4707 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) Selector() AlertTsInfoTimeSeries_FieldPathSelector { 4708 return fp.selector 4709 } 4710 4711 // String returns path representation in proto convention 4712 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) String() string { 4713 return fp.selector.String() 4714 } 4715 4716 // JSONString returns path representation is JSON convention 4717 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) JSONString() string { 4718 return strcase.ToLowerCamel(fp.String()) 4719 } 4720 4721 // Get returns all values pointed by specific field from source Alert_TsInfo_TimeSeries 4722 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) Get(source *Alert_TsInfo_TimeSeries) (values []interface{}) { 4723 if source != nil { 4724 switch fp.selector { 4725 case AlertTsInfoTimeSeries_FieldPathSelectorQueryName: 4726 values = append(values, source.QueryName) 4727 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 4728 for _, value := range source.GetValues() { 4729 values = append(values, value) 4730 } 4731 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 4732 for _, value := range source.GetAnomalies() { 4733 values = append(values, value) 4734 } 4735 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 4736 if source.UpperThreshold != nil { 4737 values = append(values, source.UpperThreshold) 4738 } 4739 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 4740 if source.LowerThreshold != nil { 4741 values = append(values, source.LowerThreshold) 4742 } 4743 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold: 4744 values = append(values, source.AnomalyThreshold) 4745 case AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration: 4746 if source.AfterDuration != nil { 4747 values = append(values, source.AfterDuration) 4748 } 4749 default: 4750 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fp.selector)) 4751 } 4752 } 4753 return 4754 } 4755 4756 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 4757 return fp.Get(source.(*Alert_TsInfo_TimeSeries)) 4758 } 4759 4760 // GetSingle returns value pointed by specific field of from source Alert_TsInfo_TimeSeries 4761 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) GetSingle(source *Alert_TsInfo_TimeSeries) (interface{}, bool) { 4762 switch fp.selector { 4763 case AlertTsInfoTimeSeries_FieldPathSelectorQueryName: 4764 return source.GetQueryName(), source != nil 4765 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 4766 res := source.GetValues() 4767 return res, res != nil 4768 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 4769 res := source.GetAnomalies() 4770 return res, res != nil 4771 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 4772 res := source.GetUpperThreshold() 4773 return res, res != nil 4774 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 4775 res := source.GetLowerThreshold() 4776 return res, res != nil 4777 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold: 4778 return source.GetAnomalyThreshold(), source != nil 4779 case AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration: 4780 res := source.GetAfterDuration() 4781 return res, res != nil 4782 default: 4783 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fp.selector)) 4784 } 4785 } 4786 4787 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 4788 return fp.GetSingle(source.(*Alert_TsInfo_TimeSeries)) 4789 } 4790 4791 // GetDefault returns a default value of the field type 4792 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) GetDefault() interface{} { 4793 switch fp.selector { 4794 case AlertTsInfoTimeSeries_FieldPathSelectorQueryName: 4795 return "" 4796 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 4797 return ([]float64)(nil) 4798 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 4799 return ([]float64)(nil) 4800 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 4801 return (*rcommon.AlertingThreshold)(nil) 4802 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 4803 return (*rcommon.AlertingThreshold)(nil) 4804 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold: 4805 return float64(0) 4806 case AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration: 4807 return (*durationpb.Duration)(nil) 4808 default: 4809 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fp.selector)) 4810 } 4811 } 4812 4813 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) ClearValue(item *Alert_TsInfo_TimeSeries) { 4814 if item != nil { 4815 switch fp.selector { 4816 case AlertTsInfoTimeSeries_FieldPathSelectorQueryName: 4817 item.QueryName = "" 4818 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 4819 item.Values = nil 4820 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 4821 item.Anomalies = nil 4822 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 4823 item.UpperThreshold = nil 4824 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 4825 item.LowerThreshold = nil 4826 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold: 4827 item.AnomalyThreshold = float64(0) 4828 case AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration: 4829 item.AfterDuration = nil 4830 default: 4831 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fp.selector)) 4832 } 4833 } 4834 } 4835 4836 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) ClearValueRaw(item proto.Message) { 4837 fp.ClearValue(item.(*Alert_TsInfo_TimeSeries)) 4838 } 4839 4840 // IsLeaf - whether field path is holds simple value 4841 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) IsLeaf() bool { 4842 return fp.selector == AlertTsInfoTimeSeries_FieldPathSelectorQueryName || 4843 fp.selector == AlertTsInfoTimeSeries_FieldPathSelectorValues || 4844 fp.selector == AlertTsInfoTimeSeries_FieldPathSelectorAnomalies || 4845 fp.selector == AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold || 4846 fp.selector == AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration 4847 } 4848 4849 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 4850 return []gotenobject.FieldPath{fp} 4851 } 4852 4853 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) WithIValue(value interface{}) AlertTsInfoTimeSeries_FieldPathValue { 4854 switch fp.selector { 4855 case AlertTsInfoTimeSeries_FieldPathSelectorQueryName: 4856 return &AlertTsInfoTimeSeries_FieldTerminalPathValue{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, value: value.(string)} 4857 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 4858 return &AlertTsInfoTimeSeries_FieldTerminalPathValue{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, value: value.([]float64)} 4859 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 4860 return &AlertTsInfoTimeSeries_FieldTerminalPathValue{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, value: value.([]float64)} 4861 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 4862 return &AlertTsInfoTimeSeries_FieldTerminalPathValue{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, value: value.(*rcommon.AlertingThreshold)} 4863 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 4864 return &AlertTsInfoTimeSeries_FieldTerminalPathValue{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, value: value.(*rcommon.AlertingThreshold)} 4865 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold: 4866 return &AlertTsInfoTimeSeries_FieldTerminalPathValue{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, value: value.(float64)} 4867 case AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration: 4868 return &AlertTsInfoTimeSeries_FieldTerminalPathValue{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, value: value.(*durationpb.Duration)} 4869 default: 4870 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fp.selector)) 4871 } 4872 } 4873 4874 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 4875 return fp.WithIValue(value) 4876 } 4877 4878 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertTsInfoTimeSeries_FieldPathArrayOfValues { 4879 fpaov := &AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues{AlertTsInfoTimeSeries_FieldTerminalPath: *fp} 4880 switch fp.selector { 4881 case AlertTsInfoTimeSeries_FieldPathSelectorQueryName: 4882 return &AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, values: values.([]string)} 4883 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 4884 return &AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, values: values.([][]float64)} 4885 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 4886 return &AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, values: values.([][]float64)} 4887 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 4888 return &AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, values: values.([]*rcommon.AlertingThreshold)} 4889 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 4890 return &AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, values: values.([]*rcommon.AlertingThreshold)} 4891 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold: 4892 return &AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, values: values.([]float64)} 4893 case AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration: 4894 return &AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, values: values.([]*durationpb.Duration)} 4895 default: 4896 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fp.selector)) 4897 } 4898 return fpaov 4899 } 4900 4901 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 4902 return fp.WithIArrayOfValues(values) 4903 } 4904 4905 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertTsInfoTimeSeries_FieldPathArrayItemValue { 4906 switch fp.selector { 4907 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 4908 return &AlertTsInfoTimeSeries_FieldTerminalPathArrayItemValue{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, value: value.(float64)} 4909 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 4910 return &AlertTsInfoTimeSeries_FieldTerminalPathArrayItemValue{AlertTsInfoTimeSeries_FieldTerminalPath: *fp, value: value.(float64)} 4911 default: 4912 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fp.selector)) 4913 } 4914 } 4915 4916 func (fp *AlertTsInfoTimeSeries_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 4917 return fp.WithIArrayItemValue(value) 4918 } 4919 4920 type AlertTsInfoTimeSeries_FieldSubPath struct { 4921 selector AlertTsInfoTimeSeries_FieldPathSelector 4922 subPath gotenobject.FieldPath 4923 } 4924 4925 var _ AlertTsInfoTimeSeries_FieldPath = (*AlertTsInfoTimeSeries_FieldSubPath)(nil) 4926 4927 func (fps *AlertTsInfoTimeSeries_FieldSubPath) Selector() AlertTsInfoTimeSeries_FieldPathSelector { 4928 return fps.selector 4929 } 4930 func (fps *AlertTsInfoTimeSeries_FieldSubPath) AsUpperThresholdSubPath() (rcommon.AlertingThreshold_FieldPath, bool) { 4931 res, ok := fps.subPath.(rcommon.AlertingThreshold_FieldPath) 4932 return res, ok 4933 } 4934 func (fps *AlertTsInfoTimeSeries_FieldSubPath) AsLowerThresholdSubPath() (rcommon.AlertingThreshold_FieldPath, bool) { 4935 res, ok := fps.subPath.(rcommon.AlertingThreshold_FieldPath) 4936 return res, ok 4937 } 4938 4939 // String returns path representation in proto convention 4940 func (fps *AlertTsInfoTimeSeries_FieldSubPath) String() string { 4941 return fps.selector.String() + "." + fps.subPath.String() 4942 } 4943 4944 // JSONString returns path representation is JSON convention 4945 func (fps *AlertTsInfoTimeSeries_FieldSubPath) JSONString() string { 4946 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 4947 } 4948 4949 // Get returns all values pointed by selected field from source Alert_TsInfo_TimeSeries 4950 func (fps *AlertTsInfoTimeSeries_FieldSubPath) Get(source *Alert_TsInfo_TimeSeries) (values []interface{}) { 4951 switch fps.selector { 4952 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 4953 values = append(values, fps.subPath.GetRaw(source.GetUpperThreshold())...) 4954 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 4955 values = append(values, fps.subPath.GetRaw(source.GetLowerThreshold())...) 4956 default: 4957 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fps.selector)) 4958 } 4959 return 4960 } 4961 4962 func (fps *AlertTsInfoTimeSeries_FieldSubPath) GetRaw(source proto.Message) []interface{} { 4963 return fps.Get(source.(*Alert_TsInfo_TimeSeries)) 4964 } 4965 4966 // GetSingle returns value of selected field from source Alert_TsInfo_TimeSeries 4967 func (fps *AlertTsInfoTimeSeries_FieldSubPath) GetSingle(source *Alert_TsInfo_TimeSeries) (interface{}, bool) { 4968 switch fps.selector { 4969 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 4970 if source.GetUpperThreshold() == nil { 4971 return nil, false 4972 } 4973 return fps.subPath.GetSingleRaw(source.GetUpperThreshold()) 4974 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 4975 if source.GetLowerThreshold() == nil { 4976 return nil, false 4977 } 4978 return fps.subPath.GetSingleRaw(source.GetLowerThreshold()) 4979 default: 4980 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fps.selector)) 4981 } 4982 } 4983 4984 func (fps *AlertTsInfoTimeSeries_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 4985 return fps.GetSingle(source.(*Alert_TsInfo_TimeSeries)) 4986 } 4987 4988 // GetDefault returns a default value of the field type 4989 func (fps *AlertTsInfoTimeSeries_FieldSubPath) GetDefault() interface{} { 4990 return fps.subPath.GetDefault() 4991 } 4992 4993 func (fps *AlertTsInfoTimeSeries_FieldSubPath) ClearValue(item *Alert_TsInfo_TimeSeries) { 4994 if item != nil { 4995 switch fps.selector { 4996 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 4997 fps.subPath.ClearValueRaw(item.UpperThreshold) 4998 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 4999 fps.subPath.ClearValueRaw(item.LowerThreshold) 5000 default: 5001 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fps.selector)) 5002 } 5003 } 5004 } 5005 5006 func (fps *AlertTsInfoTimeSeries_FieldSubPath) ClearValueRaw(item proto.Message) { 5007 fps.ClearValue(item.(*Alert_TsInfo_TimeSeries)) 5008 } 5009 5010 // IsLeaf - whether field path is holds simple value 5011 func (fps *AlertTsInfoTimeSeries_FieldSubPath) IsLeaf() bool { 5012 return fps.subPath.IsLeaf() 5013 } 5014 5015 func (fps *AlertTsInfoTimeSeries_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 5016 iPaths := []gotenobject.FieldPath{&AlertTsInfoTimeSeries_FieldTerminalPath{selector: fps.selector}} 5017 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 5018 return iPaths 5019 } 5020 5021 func (fps *AlertTsInfoTimeSeries_FieldSubPath) WithIValue(value interface{}) AlertTsInfoTimeSeries_FieldPathValue { 5022 return &AlertTsInfoTimeSeries_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 5023 } 5024 5025 func (fps *AlertTsInfoTimeSeries_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 5026 return fps.WithIValue(value) 5027 } 5028 5029 func (fps *AlertTsInfoTimeSeries_FieldSubPath) WithIArrayOfValues(values interface{}) AlertTsInfoTimeSeries_FieldPathArrayOfValues { 5030 return &AlertTsInfoTimeSeries_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 5031 } 5032 5033 func (fps *AlertTsInfoTimeSeries_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 5034 return fps.WithIArrayOfValues(values) 5035 } 5036 5037 func (fps *AlertTsInfoTimeSeries_FieldSubPath) WithIArrayItemValue(value interface{}) AlertTsInfoTimeSeries_FieldPathArrayItemValue { 5038 return &AlertTsInfoTimeSeries_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 5039 } 5040 5041 func (fps *AlertTsInfoTimeSeries_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 5042 return fps.WithIArrayItemValue(value) 5043 } 5044 5045 // AlertTsInfoTimeSeries_FieldPathValue allows storing values for TimeSeries fields according to their type 5046 type AlertTsInfoTimeSeries_FieldPathValue interface { 5047 AlertTsInfoTimeSeries_FieldPath 5048 gotenobject.FieldPathValue 5049 SetTo(target **Alert_TsInfo_TimeSeries) 5050 CompareWith(*Alert_TsInfo_TimeSeries) (cmp int, comparable bool) 5051 } 5052 5053 func ParseAlertTsInfoTimeSeries_FieldPathValue(pathStr, valueStr string) (AlertTsInfoTimeSeries_FieldPathValue, error) { 5054 fp, err := ParseAlertTsInfoTimeSeries_FieldPath(pathStr) 5055 if err != nil { 5056 return nil, err 5057 } 5058 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 5059 if err != nil { 5060 return nil, status.Errorf(codes.InvalidArgument, "error parsing TimeSeries field path value from %s: %v", valueStr, err) 5061 } 5062 return fpv.(AlertTsInfoTimeSeries_FieldPathValue), nil 5063 } 5064 5065 func MustParseAlertTsInfoTimeSeries_FieldPathValue(pathStr, valueStr string) AlertTsInfoTimeSeries_FieldPathValue { 5066 fpv, err := ParseAlertTsInfoTimeSeries_FieldPathValue(pathStr, valueStr) 5067 if err != nil { 5068 panic(err) 5069 } 5070 return fpv 5071 } 5072 5073 type AlertTsInfoTimeSeries_FieldTerminalPathValue struct { 5074 AlertTsInfoTimeSeries_FieldTerminalPath 5075 value interface{} 5076 } 5077 5078 var _ AlertTsInfoTimeSeries_FieldPathValue = (*AlertTsInfoTimeSeries_FieldTerminalPathValue)(nil) 5079 5080 // GetRawValue returns raw value stored under selected path for 'TimeSeries' as interface{} 5081 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) GetRawValue() interface{} { 5082 return fpv.value 5083 } 5084 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) AsQueryNameValue() (string, bool) { 5085 res, ok := fpv.value.(string) 5086 return res, ok 5087 } 5088 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) AsValuesValue() ([]float64, bool) { 5089 res, ok := fpv.value.([]float64) 5090 return res, ok 5091 } 5092 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) AsAnomaliesValue() ([]float64, bool) { 5093 res, ok := fpv.value.([]float64) 5094 return res, ok 5095 } 5096 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) AsUpperThresholdValue() (*rcommon.AlertingThreshold, bool) { 5097 res, ok := fpv.value.(*rcommon.AlertingThreshold) 5098 return res, ok 5099 } 5100 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) AsLowerThresholdValue() (*rcommon.AlertingThreshold, bool) { 5101 res, ok := fpv.value.(*rcommon.AlertingThreshold) 5102 return res, ok 5103 } 5104 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) AsAnomalyThresholdValue() (float64, bool) { 5105 res, ok := fpv.value.(float64) 5106 return res, ok 5107 } 5108 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) AsAfterDurationValue() (*durationpb.Duration, bool) { 5109 res, ok := fpv.value.(*durationpb.Duration) 5110 return res, ok 5111 } 5112 5113 // SetTo stores value for selected field for object TimeSeries 5114 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) SetTo(target **Alert_TsInfo_TimeSeries) { 5115 if *target == nil { 5116 *target = new(Alert_TsInfo_TimeSeries) 5117 } 5118 switch fpv.selector { 5119 case AlertTsInfoTimeSeries_FieldPathSelectorQueryName: 5120 (*target).QueryName = fpv.value.(string) 5121 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 5122 (*target).Values = fpv.value.([]float64) 5123 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 5124 (*target).Anomalies = fpv.value.([]float64) 5125 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 5126 (*target).UpperThreshold = fpv.value.(*rcommon.AlertingThreshold) 5127 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 5128 (*target).LowerThreshold = fpv.value.(*rcommon.AlertingThreshold) 5129 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold: 5130 (*target).AnomalyThreshold = fpv.value.(float64) 5131 case AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration: 5132 (*target).AfterDuration = fpv.value.(*durationpb.Duration) 5133 default: 5134 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fpv.selector)) 5135 } 5136 } 5137 5138 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) SetToRaw(target proto.Message) { 5139 typedObject := target.(*Alert_TsInfo_TimeSeries) 5140 fpv.SetTo(&typedObject) 5141 } 5142 5143 // CompareWith compares value in the 'AlertTsInfoTimeSeries_FieldTerminalPathValue' with the value under path in 'Alert_TsInfo_TimeSeries'. 5144 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) CompareWith(source *Alert_TsInfo_TimeSeries) (int, bool) { 5145 switch fpv.selector { 5146 case AlertTsInfoTimeSeries_FieldPathSelectorQueryName: 5147 leftValue := fpv.value.(string) 5148 rightValue := source.GetQueryName() 5149 if (leftValue) == (rightValue) { 5150 return 0, true 5151 } else if (leftValue) < (rightValue) { 5152 return -1, true 5153 } else { 5154 return 1, true 5155 } 5156 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 5157 return 0, false 5158 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 5159 return 0, false 5160 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 5161 return 0, false 5162 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 5163 return 0, false 5164 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold: 5165 leftValue := fpv.value.(float64) 5166 rightValue := source.GetAnomalyThreshold() 5167 if (leftValue) == (rightValue) { 5168 return 0, true 5169 } else if (leftValue) < (rightValue) { 5170 return -1, true 5171 } else { 5172 return 1, true 5173 } 5174 case AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration: 5175 leftValue := fpv.value.(*durationpb.Duration) 5176 rightValue := source.GetAfterDuration() 5177 if leftValue == nil { 5178 if rightValue != nil { 5179 return -1, true 5180 } 5181 return 0, true 5182 } 5183 if rightValue == nil { 5184 return 1, true 5185 } 5186 if leftValue.AsDuration() == rightValue.AsDuration() { 5187 return 0, true 5188 } else if leftValue.AsDuration() < rightValue.AsDuration() { 5189 return -1, true 5190 } else { 5191 return 1, true 5192 } 5193 default: 5194 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fpv.selector)) 5195 } 5196 } 5197 5198 func (fpv *AlertTsInfoTimeSeries_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 5199 return fpv.CompareWith(source.(*Alert_TsInfo_TimeSeries)) 5200 } 5201 5202 type AlertTsInfoTimeSeries_FieldSubPathValue struct { 5203 AlertTsInfoTimeSeries_FieldPath 5204 subPathValue gotenobject.FieldPathValue 5205 } 5206 5207 var _ AlertTsInfoTimeSeries_FieldPathValue = (*AlertTsInfoTimeSeries_FieldSubPathValue)(nil) 5208 5209 func (fpvs *AlertTsInfoTimeSeries_FieldSubPathValue) AsUpperThresholdPathValue() (rcommon.AlertingThreshold_FieldPathValue, bool) { 5210 res, ok := fpvs.subPathValue.(rcommon.AlertingThreshold_FieldPathValue) 5211 return res, ok 5212 } 5213 func (fpvs *AlertTsInfoTimeSeries_FieldSubPathValue) AsLowerThresholdPathValue() (rcommon.AlertingThreshold_FieldPathValue, bool) { 5214 res, ok := fpvs.subPathValue.(rcommon.AlertingThreshold_FieldPathValue) 5215 return res, ok 5216 } 5217 5218 func (fpvs *AlertTsInfoTimeSeries_FieldSubPathValue) SetTo(target **Alert_TsInfo_TimeSeries) { 5219 if *target == nil { 5220 *target = new(Alert_TsInfo_TimeSeries) 5221 } 5222 switch fpvs.Selector() { 5223 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 5224 fpvs.subPathValue.(rcommon.AlertingThreshold_FieldPathValue).SetTo(&(*target).UpperThreshold) 5225 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 5226 fpvs.subPathValue.(rcommon.AlertingThreshold_FieldPathValue).SetTo(&(*target).LowerThreshold) 5227 default: 5228 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fpvs.Selector())) 5229 } 5230 } 5231 5232 func (fpvs *AlertTsInfoTimeSeries_FieldSubPathValue) SetToRaw(target proto.Message) { 5233 typedObject := target.(*Alert_TsInfo_TimeSeries) 5234 fpvs.SetTo(&typedObject) 5235 } 5236 5237 func (fpvs *AlertTsInfoTimeSeries_FieldSubPathValue) GetRawValue() interface{} { 5238 return fpvs.subPathValue.GetRawValue() 5239 } 5240 5241 func (fpvs *AlertTsInfoTimeSeries_FieldSubPathValue) CompareWith(source *Alert_TsInfo_TimeSeries) (int, bool) { 5242 switch fpvs.Selector() { 5243 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 5244 return fpvs.subPathValue.(rcommon.AlertingThreshold_FieldPathValue).CompareWith(source.GetUpperThreshold()) 5245 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 5246 return fpvs.subPathValue.(rcommon.AlertingThreshold_FieldPathValue).CompareWith(source.GetLowerThreshold()) 5247 default: 5248 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fpvs.Selector())) 5249 } 5250 } 5251 5252 func (fpvs *AlertTsInfoTimeSeries_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 5253 return fpvs.CompareWith(source.(*Alert_TsInfo_TimeSeries)) 5254 } 5255 5256 // AlertTsInfoTimeSeries_FieldPathArrayItemValue allows storing single item in Path-specific values for TimeSeries according to their type 5257 // Present only for array (repeated) types. 5258 type AlertTsInfoTimeSeries_FieldPathArrayItemValue interface { 5259 gotenobject.FieldPathArrayItemValue 5260 AlertTsInfoTimeSeries_FieldPath 5261 ContainsValue(*Alert_TsInfo_TimeSeries) bool 5262 } 5263 5264 // ParseAlertTsInfoTimeSeries_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 5265 func ParseAlertTsInfoTimeSeries_FieldPathArrayItemValue(pathStr, valueStr string) (AlertTsInfoTimeSeries_FieldPathArrayItemValue, error) { 5266 fp, err := ParseAlertTsInfoTimeSeries_FieldPath(pathStr) 5267 if err != nil { 5268 return nil, err 5269 } 5270 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 5271 if err != nil { 5272 return nil, status.Errorf(codes.InvalidArgument, "error parsing TimeSeries field path array item value from %s: %v", valueStr, err) 5273 } 5274 return fpaiv.(AlertTsInfoTimeSeries_FieldPathArrayItemValue), nil 5275 } 5276 5277 func MustParseAlertTsInfoTimeSeries_FieldPathArrayItemValue(pathStr, valueStr string) AlertTsInfoTimeSeries_FieldPathArrayItemValue { 5278 fpaiv, err := ParseAlertTsInfoTimeSeries_FieldPathArrayItemValue(pathStr, valueStr) 5279 if err != nil { 5280 panic(err) 5281 } 5282 return fpaiv 5283 } 5284 5285 type AlertTsInfoTimeSeries_FieldTerminalPathArrayItemValue struct { 5286 AlertTsInfoTimeSeries_FieldTerminalPath 5287 value interface{} 5288 } 5289 5290 var _ AlertTsInfoTimeSeries_FieldPathArrayItemValue = (*AlertTsInfoTimeSeries_FieldTerminalPathArrayItemValue)(nil) 5291 5292 // GetRawValue returns stored element value for array in object Alert_TsInfo_TimeSeries as interface{} 5293 func (fpaiv *AlertTsInfoTimeSeries_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 5294 return fpaiv.value 5295 } 5296 func (fpaiv *AlertTsInfoTimeSeries_FieldTerminalPathArrayItemValue) AsValuesItemValue() (float64, bool) { 5297 res, ok := fpaiv.value.(float64) 5298 return res, ok 5299 } 5300 func (fpaiv *AlertTsInfoTimeSeries_FieldTerminalPathArrayItemValue) AsAnomaliesItemValue() (float64, bool) { 5301 res, ok := fpaiv.value.(float64) 5302 return res, ok 5303 } 5304 5305 func (fpaiv *AlertTsInfoTimeSeries_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_TsInfo_TimeSeries) (interface{}, bool) { 5306 return nil, false 5307 } 5308 5309 func (fpaiv *AlertTsInfoTimeSeries_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 5310 return fpaiv.GetSingle(source.(*Alert_TsInfo_TimeSeries)) 5311 } 5312 5313 // Contains returns a boolean indicating if value that is being held is present in given 'TimeSeries' 5314 func (fpaiv *AlertTsInfoTimeSeries_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_TsInfo_TimeSeries) bool { 5315 slice := fpaiv.AlertTsInfoTimeSeries_FieldTerminalPath.Get(source) 5316 for _, v := range slice { 5317 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 5318 if proto.Equal(asProtoMsg, v.(proto.Message)) { 5319 return true 5320 } 5321 } else if reflect.DeepEqual(v, fpaiv.value) { 5322 return true 5323 } 5324 } 5325 return false 5326 } 5327 5328 type AlertTsInfoTimeSeries_FieldSubPathArrayItemValue struct { 5329 AlertTsInfoTimeSeries_FieldPath 5330 subPathItemValue gotenobject.FieldPathArrayItemValue 5331 } 5332 5333 // GetRawValue returns stored array item value 5334 func (fpaivs *AlertTsInfoTimeSeries_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 5335 return fpaivs.subPathItemValue.GetRawItemValue() 5336 } 5337 func (fpaivs *AlertTsInfoTimeSeries_FieldSubPathArrayItemValue) AsUpperThresholdPathItemValue() (rcommon.AlertingThreshold_FieldPathArrayItemValue, bool) { 5338 res, ok := fpaivs.subPathItemValue.(rcommon.AlertingThreshold_FieldPathArrayItemValue) 5339 return res, ok 5340 } 5341 func (fpaivs *AlertTsInfoTimeSeries_FieldSubPathArrayItemValue) AsLowerThresholdPathItemValue() (rcommon.AlertingThreshold_FieldPathArrayItemValue, bool) { 5342 res, ok := fpaivs.subPathItemValue.(rcommon.AlertingThreshold_FieldPathArrayItemValue) 5343 return res, ok 5344 } 5345 5346 // Contains returns a boolean indicating if value that is being held is present in given 'TimeSeries' 5347 func (fpaivs *AlertTsInfoTimeSeries_FieldSubPathArrayItemValue) ContainsValue(source *Alert_TsInfo_TimeSeries) bool { 5348 switch fpaivs.Selector() { 5349 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 5350 return fpaivs.subPathItemValue.(rcommon.AlertingThreshold_FieldPathArrayItemValue).ContainsValue(source.GetUpperThreshold()) 5351 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 5352 return fpaivs.subPathItemValue.(rcommon.AlertingThreshold_FieldPathArrayItemValue).ContainsValue(source.GetLowerThreshold()) 5353 default: 5354 panic(fmt.Sprintf("Invalid selector for Alert_TsInfo_TimeSeries: %d", fpaivs.Selector())) 5355 } 5356 } 5357 5358 // AlertTsInfoTimeSeries_FieldPathArrayOfValues allows storing slice of values for TimeSeries fields according to their type 5359 type AlertTsInfoTimeSeries_FieldPathArrayOfValues interface { 5360 gotenobject.FieldPathArrayOfValues 5361 AlertTsInfoTimeSeries_FieldPath 5362 } 5363 5364 func ParseAlertTsInfoTimeSeries_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertTsInfoTimeSeries_FieldPathArrayOfValues, error) { 5365 fp, err := ParseAlertTsInfoTimeSeries_FieldPath(pathStr) 5366 if err != nil { 5367 return nil, err 5368 } 5369 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 5370 if err != nil { 5371 return nil, status.Errorf(codes.InvalidArgument, "error parsing TimeSeries field path array of values from %s: %v", valuesStr, err) 5372 } 5373 return fpaov.(AlertTsInfoTimeSeries_FieldPathArrayOfValues), nil 5374 } 5375 5376 func MustParseAlertTsInfoTimeSeries_FieldPathArrayOfValues(pathStr, valuesStr string) AlertTsInfoTimeSeries_FieldPathArrayOfValues { 5377 fpaov, err := ParseAlertTsInfoTimeSeries_FieldPathArrayOfValues(pathStr, valuesStr) 5378 if err != nil { 5379 panic(err) 5380 } 5381 return fpaov 5382 } 5383 5384 type AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues struct { 5385 AlertTsInfoTimeSeries_FieldTerminalPath 5386 values interface{} 5387 } 5388 5389 var _ AlertTsInfoTimeSeries_FieldPathArrayOfValues = (*AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues)(nil) 5390 5391 func (fpaov *AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 5392 switch fpaov.selector { 5393 case AlertTsInfoTimeSeries_FieldPathSelectorQueryName: 5394 for _, v := range fpaov.values.([]string) { 5395 values = append(values, v) 5396 } 5397 case AlertTsInfoTimeSeries_FieldPathSelectorValues: 5398 for _, v := range fpaov.values.([][]float64) { 5399 values = append(values, v) 5400 } 5401 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalies: 5402 for _, v := range fpaov.values.([][]float64) { 5403 values = append(values, v) 5404 } 5405 case AlertTsInfoTimeSeries_FieldPathSelectorUpperThreshold: 5406 for _, v := range fpaov.values.([]*rcommon.AlertingThreshold) { 5407 values = append(values, v) 5408 } 5409 case AlertTsInfoTimeSeries_FieldPathSelectorLowerThreshold: 5410 for _, v := range fpaov.values.([]*rcommon.AlertingThreshold) { 5411 values = append(values, v) 5412 } 5413 case AlertTsInfoTimeSeries_FieldPathSelectorAnomalyThreshold: 5414 for _, v := range fpaov.values.([]float64) { 5415 values = append(values, v) 5416 } 5417 case AlertTsInfoTimeSeries_FieldPathSelectorAfterDuration: 5418 for _, v := range fpaov.values.([]*durationpb.Duration) { 5419 values = append(values, v) 5420 } 5421 } 5422 return 5423 } 5424 func (fpaov *AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues) AsQueryNameArrayOfValues() ([]string, bool) { 5425 res, ok := fpaov.values.([]string) 5426 return res, ok 5427 } 5428 func (fpaov *AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues) AsValuesArrayOfValues() ([][]float64, bool) { 5429 res, ok := fpaov.values.([][]float64) 5430 return res, ok 5431 } 5432 func (fpaov *AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues) AsAnomaliesArrayOfValues() ([][]float64, bool) { 5433 res, ok := fpaov.values.([][]float64) 5434 return res, ok 5435 } 5436 func (fpaov *AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues) AsUpperThresholdArrayOfValues() ([]*rcommon.AlertingThreshold, bool) { 5437 res, ok := fpaov.values.([]*rcommon.AlertingThreshold) 5438 return res, ok 5439 } 5440 func (fpaov *AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues) AsLowerThresholdArrayOfValues() ([]*rcommon.AlertingThreshold, bool) { 5441 res, ok := fpaov.values.([]*rcommon.AlertingThreshold) 5442 return res, ok 5443 } 5444 func (fpaov *AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues) AsAnomalyThresholdArrayOfValues() ([]float64, bool) { 5445 res, ok := fpaov.values.([]float64) 5446 return res, ok 5447 } 5448 func (fpaov *AlertTsInfoTimeSeries_FieldTerminalPathArrayOfValues) AsAfterDurationArrayOfValues() ([]*durationpb.Duration, bool) { 5449 res, ok := fpaov.values.([]*durationpb.Duration) 5450 return res, ok 5451 } 5452 5453 type AlertTsInfoTimeSeries_FieldSubPathArrayOfValues struct { 5454 AlertTsInfoTimeSeries_FieldPath 5455 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 5456 } 5457 5458 var _ AlertTsInfoTimeSeries_FieldPathArrayOfValues = (*AlertTsInfoTimeSeries_FieldSubPathArrayOfValues)(nil) 5459 5460 func (fpsaov *AlertTsInfoTimeSeries_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 5461 return fpsaov.subPathArrayOfValues.GetRawValues() 5462 } 5463 func (fpsaov *AlertTsInfoTimeSeries_FieldSubPathArrayOfValues) AsUpperThresholdPathArrayOfValues() (rcommon.AlertingThreshold_FieldPathArrayOfValues, bool) { 5464 res, ok := fpsaov.subPathArrayOfValues.(rcommon.AlertingThreshold_FieldPathArrayOfValues) 5465 return res, ok 5466 } 5467 func (fpsaov *AlertTsInfoTimeSeries_FieldSubPathArrayOfValues) AsLowerThresholdPathArrayOfValues() (rcommon.AlertingThreshold_FieldPathArrayOfValues, bool) { 5468 res, ok := fpsaov.subPathArrayOfValues.(rcommon.AlertingThreshold_FieldPathArrayOfValues) 5469 return res, ok 5470 } 5471 5472 // FieldPath provides implementation to handle 5473 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 5474 type AlertStateNotification_FieldPath interface { 5475 gotenobject.FieldPath 5476 Selector() AlertStateNotification_FieldPathSelector 5477 Get(source *Alert_State_Notification) []interface{} 5478 GetSingle(source *Alert_State_Notification) (interface{}, bool) 5479 ClearValue(item *Alert_State_Notification) 5480 5481 // Those methods build corresponding AlertStateNotification_FieldPathValue 5482 // (or array of values) and holds passed value. Panics if injected type is incorrect. 5483 WithIValue(value interface{}) AlertStateNotification_FieldPathValue 5484 WithIArrayOfValues(values interface{}) AlertStateNotification_FieldPathArrayOfValues 5485 WithIArrayItemValue(value interface{}) AlertStateNotification_FieldPathArrayItemValue 5486 } 5487 5488 type AlertStateNotification_FieldPathSelector int32 5489 5490 const ( 5491 AlertStateNotification_FieldPathSelectorKind AlertStateNotification_FieldPathSelector = 0 5492 AlertStateNotification_FieldPathSelectorPendingChannels AlertStateNotification_FieldPathSelector = 1 5493 ) 5494 5495 func (s AlertStateNotification_FieldPathSelector) String() string { 5496 switch s { 5497 case AlertStateNotification_FieldPathSelectorKind: 5498 return "kind" 5499 case AlertStateNotification_FieldPathSelectorPendingChannels: 5500 return "pending_channels" 5501 default: 5502 panic(fmt.Sprintf("Invalid selector for Alert_State_Notification: %d", s)) 5503 } 5504 } 5505 5506 func BuildAlertStateNotification_FieldPath(fp gotenobject.RawFieldPath) (AlertStateNotification_FieldPath, error) { 5507 if len(fp) == 0 { 5508 return nil, status.Error(codes.InvalidArgument, "empty field path for object Alert_State_Notification") 5509 } 5510 if len(fp) == 1 { 5511 switch fp[0] { 5512 case "kind": 5513 return &AlertStateNotification_FieldTerminalPath{selector: AlertStateNotification_FieldPathSelectorKind}, nil 5514 case "pending_channels", "pendingChannels", "pending-channels": 5515 return &AlertStateNotification_FieldTerminalPath{selector: AlertStateNotification_FieldPathSelectorPendingChannels}, nil 5516 } 5517 } 5518 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Alert_State_Notification", fp) 5519 } 5520 5521 func ParseAlertStateNotification_FieldPath(rawField string) (AlertStateNotification_FieldPath, error) { 5522 fp, err := gotenobject.ParseRawFieldPath(rawField) 5523 if err != nil { 5524 return nil, err 5525 } 5526 return BuildAlertStateNotification_FieldPath(fp) 5527 } 5528 5529 func MustParseAlertStateNotification_FieldPath(rawField string) AlertStateNotification_FieldPath { 5530 fp, err := ParseAlertStateNotification_FieldPath(rawField) 5531 if err != nil { 5532 panic(err) 5533 } 5534 return fp 5535 } 5536 5537 type AlertStateNotification_FieldTerminalPath struct { 5538 selector AlertStateNotification_FieldPathSelector 5539 } 5540 5541 var _ AlertStateNotification_FieldPath = (*AlertStateNotification_FieldTerminalPath)(nil) 5542 5543 func (fp *AlertStateNotification_FieldTerminalPath) Selector() AlertStateNotification_FieldPathSelector { 5544 return fp.selector 5545 } 5546 5547 // String returns path representation in proto convention 5548 func (fp *AlertStateNotification_FieldTerminalPath) String() string { 5549 return fp.selector.String() 5550 } 5551 5552 // JSONString returns path representation is JSON convention 5553 func (fp *AlertStateNotification_FieldTerminalPath) JSONString() string { 5554 return strcase.ToLowerCamel(fp.String()) 5555 } 5556 5557 // Get returns all values pointed by specific field from source Alert_State_Notification 5558 func (fp *AlertStateNotification_FieldTerminalPath) Get(source *Alert_State_Notification) (values []interface{}) { 5559 if source != nil { 5560 switch fp.selector { 5561 case AlertStateNotification_FieldPathSelectorKind: 5562 values = append(values, source.Kind) 5563 case AlertStateNotification_FieldPathSelectorPendingChannels: 5564 for _, value := range source.GetPendingChannels() { 5565 values = append(values, value) 5566 } 5567 default: 5568 panic(fmt.Sprintf("Invalid selector for Alert_State_Notification: %d", fp.selector)) 5569 } 5570 } 5571 return 5572 } 5573 5574 func (fp *AlertStateNotification_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 5575 return fp.Get(source.(*Alert_State_Notification)) 5576 } 5577 5578 // GetSingle returns value pointed by specific field of from source Alert_State_Notification 5579 func (fp *AlertStateNotification_FieldTerminalPath) GetSingle(source *Alert_State_Notification) (interface{}, bool) { 5580 switch fp.selector { 5581 case AlertStateNotification_FieldPathSelectorKind: 5582 return source.GetKind(), source != nil 5583 case AlertStateNotification_FieldPathSelectorPendingChannels: 5584 res := source.GetPendingChannels() 5585 return res, res != nil 5586 default: 5587 panic(fmt.Sprintf("Invalid selector for Alert_State_Notification: %d", fp.selector)) 5588 } 5589 } 5590 5591 func (fp *AlertStateNotification_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 5592 return fp.GetSingle(source.(*Alert_State_Notification)) 5593 } 5594 5595 // GetDefault returns a default value of the field type 5596 func (fp *AlertStateNotification_FieldTerminalPath) GetDefault() interface{} { 5597 switch fp.selector { 5598 case AlertStateNotification_FieldPathSelectorKind: 5599 return rcommon.NotificationChannelSpec_UNDEFINED 5600 case AlertStateNotification_FieldPathSelectorPendingChannels: 5601 return ([]*notification_channel.Reference)(nil) 5602 default: 5603 panic(fmt.Sprintf("Invalid selector for Alert_State_Notification: %d", fp.selector)) 5604 } 5605 } 5606 5607 func (fp *AlertStateNotification_FieldTerminalPath) ClearValue(item *Alert_State_Notification) { 5608 if item != nil { 5609 switch fp.selector { 5610 case AlertStateNotification_FieldPathSelectorKind: 5611 item.Kind = rcommon.NotificationChannelSpec_UNDEFINED 5612 case AlertStateNotification_FieldPathSelectorPendingChannels: 5613 item.PendingChannels = nil 5614 default: 5615 panic(fmt.Sprintf("Invalid selector for Alert_State_Notification: %d", fp.selector)) 5616 } 5617 } 5618 } 5619 5620 func (fp *AlertStateNotification_FieldTerminalPath) ClearValueRaw(item proto.Message) { 5621 fp.ClearValue(item.(*Alert_State_Notification)) 5622 } 5623 5624 // IsLeaf - whether field path is holds simple value 5625 func (fp *AlertStateNotification_FieldTerminalPath) IsLeaf() bool { 5626 return fp.selector == AlertStateNotification_FieldPathSelectorKind || 5627 fp.selector == AlertStateNotification_FieldPathSelectorPendingChannels 5628 } 5629 5630 func (fp *AlertStateNotification_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 5631 return []gotenobject.FieldPath{fp} 5632 } 5633 5634 func (fp *AlertStateNotification_FieldTerminalPath) WithIValue(value interface{}) AlertStateNotification_FieldPathValue { 5635 switch fp.selector { 5636 case AlertStateNotification_FieldPathSelectorKind: 5637 return &AlertStateNotification_FieldTerminalPathValue{AlertStateNotification_FieldTerminalPath: *fp, value: value.(rcommon.NotificationChannelSpec_EventKind)} 5638 case AlertStateNotification_FieldPathSelectorPendingChannels: 5639 return &AlertStateNotification_FieldTerminalPathValue{AlertStateNotification_FieldTerminalPath: *fp, value: value.([]*notification_channel.Reference)} 5640 default: 5641 panic(fmt.Sprintf("Invalid selector for Alert_State_Notification: %d", fp.selector)) 5642 } 5643 } 5644 5645 func (fp *AlertStateNotification_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 5646 return fp.WithIValue(value) 5647 } 5648 5649 func (fp *AlertStateNotification_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertStateNotification_FieldPathArrayOfValues { 5650 fpaov := &AlertStateNotification_FieldTerminalPathArrayOfValues{AlertStateNotification_FieldTerminalPath: *fp} 5651 switch fp.selector { 5652 case AlertStateNotification_FieldPathSelectorKind: 5653 return &AlertStateNotification_FieldTerminalPathArrayOfValues{AlertStateNotification_FieldTerminalPath: *fp, values: values.([]rcommon.NotificationChannelSpec_EventKind)} 5654 case AlertStateNotification_FieldPathSelectorPendingChannels: 5655 return &AlertStateNotification_FieldTerminalPathArrayOfValues{AlertStateNotification_FieldTerminalPath: *fp, values: values.([][]*notification_channel.Reference)} 5656 default: 5657 panic(fmt.Sprintf("Invalid selector for Alert_State_Notification: %d", fp.selector)) 5658 } 5659 return fpaov 5660 } 5661 5662 func (fp *AlertStateNotification_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 5663 return fp.WithIArrayOfValues(values) 5664 } 5665 5666 func (fp *AlertStateNotification_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertStateNotification_FieldPathArrayItemValue { 5667 switch fp.selector { 5668 case AlertStateNotification_FieldPathSelectorPendingChannels: 5669 return &AlertStateNotification_FieldTerminalPathArrayItemValue{AlertStateNotification_FieldTerminalPath: *fp, value: value.(*notification_channel.Reference)} 5670 default: 5671 panic(fmt.Sprintf("Invalid selector for Alert_State_Notification: %d", fp.selector)) 5672 } 5673 } 5674 5675 func (fp *AlertStateNotification_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 5676 return fp.WithIArrayItemValue(value) 5677 } 5678 5679 // AlertStateNotification_FieldPathValue allows storing values for Notification fields according to their type 5680 type AlertStateNotification_FieldPathValue interface { 5681 AlertStateNotification_FieldPath 5682 gotenobject.FieldPathValue 5683 SetTo(target **Alert_State_Notification) 5684 CompareWith(*Alert_State_Notification) (cmp int, comparable bool) 5685 } 5686 5687 func ParseAlertStateNotification_FieldPathValue(pathStr, valueStr string) (AlertStateNotification_FieldPathValue, error) { 5688 fp, err := ParseAlertStateNotification_FieldPath(pathStr) 5689 if err != nil { 5690 return nil, err 5691 } 5692 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 5693 if err != nil { 5694 return nil, status.Errorf(codes.InvalidArgument, "error parsing Notification field path value from %s: %v", valueStr, err) 5695 } 5696 return fpv.(AlertStateNotification_FieldPathValue), nil 5697 } 5698 5699 func MustParseAlertStateNotification_FieldPathValue(pathStr, valueStr string) AlertStateNotification_FieldPathValue { 5700 fpv, err := ParseAlertStateNotification_FieldPathValue(pathStr, valueStr) 5701 if err != nil { 5702 panic(err) 5703 } 5704 return fpv 5705 } 5706 5707 type AlertStateNotification_FieldTerminalPathValue struct { 5708 AlertStateNotification_FieldTerminalPath 5709 value interface{} 5710 } 5711 5712 var _ AlertStateNotification_FieldPathValue = (*AlertStateNotification_FieldTerminalPathValue)(nil) 5713 5714 // GetRawValue returns raw value stored under selected path for 'Notification' as interface{} 5715 func (fpv *AlertStateNotification_FieldTerminalPathValue) GetRawValue() interface{} { 5716 return fpv.value 5717 } 5718 func (fpv *AlertStateNotification_FieldTerminalPathValue) AsKindValue() (rcommon.NotificationChannelSpec_EventKind, bool) { 5719 res, ok := fpv.value.(rcommon.NotificationChannelSpec_EventKind) 5720 return res, ok 5721 } 5722 func (fpv *AlertStateNotification_FieldTerminalPathValue) AsPendingChannelsValue() ([]*notification_channel.Reference, bool) { 5723 res, ok := fpv.value.([]*notification_channel.Reference) 5724 return res, ok 5725 } 5726 5727 // SetTo stores value for selected field for object Notification 5728 func (fpv *AlertStateNotification_FieldTerminalPathValue) SetTo(target **Alert_State_Notification) { 5729 if *target == nil { 5730 *target = new(Alert_State_Notification) 5731 } 5732 switch fpv.selector { 5733 case AlertStateNotification_FieldPathSelectorKind: 5734 (*target).Kind = fpv.value.(rcommon.NotificationChannelSpec_EventKind) 5735 case AlertStateNotification_FieldPathSelectorPendingChannels: 5736 (*target).PendingChannels = fpv.value.([]*notification_channel.Reference) 5737 default: 5738 panic(fmt.Sprintf("Invalid selector for Alert_State_Notification: %d", fpv.selector)) 5739 } 5740 } 5741 5742 func (fpv *AlertStateNotification_FieldTerminalPathValue) SetToRaw(target proto.Message) { 5743 typedObject := target.(*Alert_State_Notification) 5744 fpv.SetTo(&typedObject) 5745 } 5746 5747 // CompareWith compares value in the 'AlertStateNotification_FieldTerminalPathValue' with the value under path in 'Alert_State_Notification'. 5748 func (fpv *AlertStateNotification_FieldTerminalPathValue) CompareWith(source *Alert_State_Notification) (int, bool) { 5749 switch fpv.selector { 5750 case AlertStateNotification_FieldPathSelectorKind: 5751 leftValue := fpv.value.(rcommon.NotificationChannelSpec_EventKind) 5752 rightValue := source.GetKind() 5753 if (leftValue) == (rightValue) { 5754 return 0, true 5755 } else if (leftValue) < (rightValue) { 5756 return -1, true 5757 } else { 5758 return 1, true 5759 } 5760 case AlertStateNotification_FieldPathSelectorPendingChannels: 5761 return 0, false 5762 default: 5763 panic(fmt.Sprintf("Invalid selector for Alert_State_Notification: %d", fpv.selector)) 5764 } 5765 } 5766 5767 func (fpv *AlertStateNotification_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 5768 return fpv.CompareWith(source.(*Alert_State_Notification)) 5769 } 5770 5771 // AlertStateNotification_FieldPathArrayItemValue allows storing single item in Path-specific values for Notification according to their type 5772 // Present only for array (repeated) types. 5773 type AlertStateNotification_FieldPathArrayItemValue interface { 5774 gotenobject.FieldPathArrayItemValue 5775 AlertStateNotification_FieldPath 5776 ContainsValue(*Alert_State_Notification) bool 5777 } 5778 5779 // ParseAlertStateNotification_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 5780 func ParseAlertStateNotification_FieldPathArrayItemValue(pathStr, valueStr string) (AlertStateNotification_FieldPathArrayItemValue, error) { 5781 fp, err := ParseAlertStateNotification_FieldPath(pathStr) 5782 if err != nil { 5783 return nil, err 5784 } 5785 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 5786 if err != nil { 5787 return nil, status.Errorf(codes.InvalidArgument, "error parsing Notification field path array item value from %s: %v", valueStr, err) 5788 } 5789 return fpaiv.(AlertStateNotification_FieldPathArrayItemValue), nil 5790 } 5791 5792 func MustParseAlertStateNotification_FieldPathArrayItemValue(pathStr, valueStr string) AlertStateNotification_FieldPathArrayItemValue { 5793 fpaiv, err := ParseAlertStateNotification_FieldPathArrayItemValue(pathStr, valueStr) 5794 if err != nil { 5795 panic(err) 5796 } 5797 return fpaiv 5798 } 5799 5800 type AlertStateNotification_FieldTerminalPathArrayItemValue struct { 5801 AlertStateNotification_FieldTerminalPath 5802 value interface{} 5803 } 5804 5805 var _ AlertStateNotification_FieldPathArrayItemValue = (*AlertStateNotification_FieldTerminalPathArrayItemValue)(nil) 5806 5807 // GetRawValue returns stored element value for array in object Alert_State_Notification as interface{} 5808 func (fpaiv *AlertStateNotification_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 5809 return fpaiv.value 5810 } 5811 func (fpaiv *AlertStateNotification_FieldTerminalPathArrayItemValue) AsPendingChannelsItemValue() (*notification_channel.Reference, bool) { 5812 res, ok := fpaiv.value.(*notification_channel.Reference) 5813 return res, ok 5814 } 5815 5816 func (fpaiv *AlertStateNotification_FieldTerminalPathArrayItemValue) GetSingle(source *Alert_State_Notification) (interface{}, bool) { 5817 return nil, false 5818 } 5819 5820 func (fpaiv *AlertStateNotification_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 5821 return fpaiv.GetSingle(source.(*Alert_State_Notification)) 5822 } 5823 5824 // Contains returns a boolean indicating if value that is being held is present in given 'Notification' 5825 func (fpaiv *AlertStateNotification_FieldTerminalPathArrayItemValue) ContainsValue(source *Alert_State_Notification) bool { 5826 slice := fpaiv.AlertStateNotification_FieldTerminalPath.Get(source) 5827 for _, v := range slice { 5828 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 5829 if proto.Equal(asProtoMsg, v.(proto.Message)) { 5830 return true 5831 } 5832 } else if reflect.DeepEqual(v, fpaiv.value) { 5833 return true 5834 } 5835 } 5836 return false 5837 } 5838 5839 // AlertStateNotification_FieldPathArrayOfValues allows storing slice of values for Notification fields according to their type 5840 type AlertStateNotification_FieldPathArrayOfValues interface { 5841 gotenobject.FieldPathArrayOfValues 5842 AlertStateNotification_FieldPath 5843 } 5844 5845 func ParseAlertStateNotification_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertStateNotification_FieldPathArrayOfValues, error) { 5846 fp, err := ParseAlertStateNotification_FieldPath(pathStr) 5847 if err != nil { 5848 return nil, err 5849 } 5850 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 5851 if err != nil { 5852 return nil, status.Errorf(codes.InvalidArgument, "error parsing Notification field path array of values from %s: %v", valuesStr, err) 5853 } 5854 return fpaov.(AlertStateNotification_FieldPathArrayOfValues), nil 5855 } 5856 5857 func MustParseAlertStateNotification_FieldPathArrayOfValues(pathStr, valuesStr string) AlertStateNotification_FieldPathArrayOfValues { 5858 fpaov, err := ParseAlertStateNotification_FieldPathArrayOfValues(pathStr, valuesStr) 5859 if err != nil { 5860 panic(err) 5861 } 5862 return fpaov 5863 } 5864 5865 type AlertStateNotification_FieldTerminalPathArrayOfValues struct { 5866 AlertStateNotification_FieldTerminalPath 5867 values interface{} 5868 } 5869 5870 var _ AlertStateNotification_FieldPathArrayOfValues = (*AlertStateNotification_FieldTerminalPathArrayOfValues)(nil) 5871 5872 func (fpaov *AlertStateNotification_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 5873 switch fpaov.selector { 5874 case AlertStateNotification_FieldPathSelectorKind: 5875 for _, v := range fpaov.values.([]rcommon.NotificationChannelSpec_EventKind) { 5876 values = append(values, v) 5877 } 5878 case AlertStateNotification_FieldPathSelectorPendingChannels: 5879 for _, v := range fpaov.values.([][]*notification_channel.Reference) { 5880 values = append(values, v) 5881 } 5882 } 5883 return 5884 } 5885 func (fpaov *AlertStateNotification_FieldTerminalPathArrayOfValues) AsKindArrayOfValues() ([]rcommon.NotificationChannelSpec_EventKind, bool) { 5886 res, ok := fpaov.values.([]rcommon.NotificationChannelSpec_EventKind) 5887 return res, ok 5888 } 5889 func (fpaov *AlertStateNotification_FieldTerminalPathArrayOfValues) AsPendingChannelsArrayOfValues() ([][]*notification_channel.Reference, bool) { 5890 res, ok := fpaov.values.([][]*notification_channel.Reference) 5891 return res, ok 5892 }