github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v3/alert/alert.pb.fieldmask.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/monitoring/proto/v3/alert.proto 3 // DO NOT EDIT!!! 4 5 package alert 6 7 import ( 8 "encoding/json" 9 "strings" 10 11 "google.golang.org/grpc/codes" 12 "google.golang.org/grpc/status" 13 "google.golang.org/protobuf/proto" 14 preflect "google.golang.org/protobuf/reflect/protoreflect" 15 googlefieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" 16 17 gotenobject "github.com/cloudwan/goten-sdk/runtime/object" 18 ) 19 20 // proto imports 21 import ( 22 alerting_condition "github.com/cloudwan/edgelq-sdk/monitoring/resources/v3/alerting_condition" 23 common "github.com/cloudwan/edgelq-sdk/monitoring/resources/v3/common" 24 meta "github.com/cloudwan/goten-sdk/types/meta" 25 ) 26 27 // ensure the imports are used 28 var ( 29 _ = new(json.Marshaler) 30 _ = strings.Builder{} 31 32 _ = codes.NotFound 33 _ = status.Status{} 34 _ = new(proto.Message) 35 _ = new(preflect.Message) 36 _ = googlefieldmaskpb.FieldMask{} 37 38 _ = new(gotenobject.FieldMask) 39 ) 40 41 // make sure we're using proto imports 42 var ( 43 _ = &alerting_condition.AlertingCondition{} 44 _ = &common.LabelDescriptor{} 45 _ = &meta.Meta{} 46 ) 47 48 type Alert_FieldMask struct { 49 Paths []Alert_FieldPath 50 } 51 52 func FullAlert_FieldMask() *Alert_FieldMask { 53 res := &Alert_FieldMask{} 54 res.Paths = append(res.Paths, &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorName}) 55 res.Paths = append(res.Paths, &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorMetadata}) 56 res.Paths = append(res.Paths, &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorDisplayName}) 57 res.Paths = append(res.Paths, &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorInfo}) 58 res.Paths = append(res.Paths, &Alert_FieldTerminalPath{selector: Alert_FieldPathSelectorState}) 59 return res 60 } 61 62 func (fieldMask *Alert_FieldMask) String() string { 63 if fieldMask == nil { 64 return "<nil>" 65 } 66 pathsStr := make([]string, 0, len(fieldMask.Paths)) 67 for _, path := range fieldMask.Paths { 68 pathsStr = append(pathsStr, path.String()) 69 } 70 return strings.Join(pathsStr, ", ") 71 } 72 73 func (fieldMask *Alert_FieldMask) IsFull() bool { 74 if fieldMask == nil { 75 return false 76 } 77 presentSelectors := make([]bool, 5) 78 for _, path := range fieldMask.Paths { 79 if asFinal, ok := path.(*Alert_FieldTerminalPath); ok { 80 presentSelectors[int(asFinal.selector)] = true 81 } 82 } 83 for _, flag := range presentSelectors { 84 if !flag { 85 return false 86 } 87 } 88 return true 89 } 90 91 func (fieldMask *Alert_FieldMask) ProtoReflect() preflect.Message { 92 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 93 return ParseAlert_FieldPath(raw) 94 }) 95 } 96 97 func (fieldMask *Alert_FieldMask) ProtoMessage() {} 98 99 func (fieldMask *Alert_FieldMask) Reset() { 100 if fieldMask != nil { 101 fieldMask.Paths = nil 102 } 103 } 104 105 func (fieldMask *Alert_FieldMask) Subtract(other *Alert_FieldMask) *Alert_FieldMask { 106 result := &Alert_FieldMask{} 107 removedSelectors := make([]bool, 5) 108 otherSubMasks := map[Alert_FieldPathSelector]gotenobject.FieldMask{ 109 Alert_FieldPathSelectorMetadata: &meta.Meta_FieldMask{}, 110 Alert_FieldPathSelectorInfo: &Alert_Info_FieldMask{}, 111 Alert_FieldPathSelectorState: &Alert_State_FieldMask{}, 112 } 113 mySubMasks := map[Alert_FieldPathSelector]gotenobject.FieldMask{ 114 Alert_FieldPathSelectorMetadata: &meta.Meta_FieldMask{}, 115 Alert_FieldPathSelectorInfo: &Alert_Info_FieldMask{}, 116 Alert_FieldPathSelectorState: &Alert_State_FieldMask{}, 117 } 118 119 for _, path := range other.GetPaths() { 120 switch tp := path.(type) { 121 case *Alert_FieldTerminalPath: 122 removedSelectors[int(tp.selector)] = true 123 case *Alert_FieldSubPath: 124 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 125 } 126 } 127 for _, path := range fieldMask.GetPaths() { 128 if !removedSelectors[int(path.Selector())] { 129 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 130 if tp, ok := path.(*Alert_FieldTerminalPath); ok { 131 switch tp.selector { 132 case Alert_FieldPathSelectorMetadata: 133 mySubMasks[Alert_FieldPathSelectorMetadata] = meta.FullMeta_FieldMask() 134 case Alert_FieldPathSelectorInfo: 135 mySubMasks[Alert_FieldPathSelectorInfo] = FullAlert_Info_FieldMask() 136 case Alert_FieldPathSelectorState: 137 mySubMasks[Alert_FieldPathSelectorState] = FullAlert_State_FieldMask() 138 } 139 } else if tp, ok := path.(*Alert_FieldSubPath); ok { 140 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 141 } 142 } else { 143 result.Paths = append(result.Paths, path) 144 } 145 } 146 } 147 for selector, mySubMask := range mySubMasks { 148 if mySubMask.PathsCount() > 0 { 149 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 150 result.Paths = append(result.Paths, &Alert_FieldSubPath{selector: selector, subPath: allowedPath}) 151 } 152 } 153 } 154 155 if len(result.Paths) == 0 { 156 return nil 157 } 158 return result 159 } 160 161 func (fieldMask *Alert_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 162 return fieldMask.Subtract(other.(*Alert_FieldMask)) 163 } 164 165 // FilterInputFields generates copy of field paths with output_only field paths removed 166 func (fieldMask *Alert_FieldMask) FilterInputFields() *Alert_FieldMask { 167 result := &Alert_FieldMask{} 168 for _, path := range fieldMask.Paths { 169 switch path.Selector() { 170 case Alert_FieldPathSelectorMetadata: 171 if _, ok := path.(*Alert_FieldTerminalPath); ok { 172 for _, subpath := range meta.FullMeta_FieldMask().FilterInputFields().Paths { 173 result.Paths = append(result.Paths, &Alert_FieldSubPath{selector: path.Selector(), subPath: subpath}) 174 } 175 } else if sub, ok := path.(*Alert_FieldSubPath); ok { 176 selectedMask := &meta.Meta_FieldMask{ 177 Paths: []meta.Meta_FieldPath{sub.subPath.(meta.Meta_FieldPath)}, 178 } 179 for _, allowedPath := range selectedMask.FilterInputFields().Paths { 180 result.Paths = append(result.Paths, &Alert_FieldSubPath{selector: Alert_FieldPathSelectorMetadata, subPath: allowedPath}) 181 } 182 } 183 default: 184 result.Paths = append(result.Paths, path) 185 } 186 } 187 return result 188 } 189 190 // ToFieldMask is used for proto conversions 191 func (fieldMask *Alert_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 192 protoFieldMask := &googlefieldmaskpb.FieldMask{} 193 for _, path := range fieldMask.Paths { 194 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 195 } 196 return protoFieldMask 197 } 198 199 func (fieldMask *Alert_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 200 if fieldMask == nil { 201 return status.Error(codes.Internal, "target field mask is nil") 202 } 203 fieldMask.Paths = make([]Alert_FieldPath, 0, len(protoFieldMask.Paths)) 204 for _, strPath := range protoFieldMask.Paths { 205 path, err := ParseAlert_FieldPath(strPath) 206 if err != nil { 207 return err 208 } 209 fieldMask.Paths = append(fieldMask.Paths, path) 210 } 211 return nil 212 } 213 214 // implement methods required by customType 215 func (fieldMask Alert_FieldMask) Marshal() ([]byte, error) { 216 protoFieldMask := fieldMask.ToProtoFieldMask() 217 return proto.Marshal(protoFieldMask) 218 } 219 220 func (fieldMask *Alert_FieldMask) Unmarshal(data []byte) error { 221 protoFieldMask := &googlefieldmaskpb.FieldMask{} 222 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 223 return err 224 } 225 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 226 return err 227 } 228 return nil 229 } 230 231 func (fieldMask *Alert_FieldMask) Size() int { 232 return proto.Size(fieldMask.ToProtoFieldMask()) 233 } 234 235 func (fieldMask Alert_FieldMask) MarshalJSON() ([]byte, error) { 236 return json.Marshal(fieldMask.ToProtoFieldMask()) 237 } 238 239 func (fieldMask *Alert_FieldMask) UnmarshalJSON(data []byte) error { 240 protoFieldMask := &googlefieldmaskpb.FieldMask{} 241 if err := json.Unmarshal(data, protoFieldMask); err != nil { 242 return err 243 } 244 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 245 return err 246 } 247 return nil 248 } 249 250 func (fieldMask *Alert_FieldMask) AppendPath(path Alert_FieldPath) { 251 fieldMask.Paths = append(fieldMask.Paths, path) 252 } 253 254 func (fieldMask *Alert_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 255 fieldMask.Paths = append(fieldMask.Paths, path.(Alert_FieldPath)) 256 } 257 258 func (fieldMask *Alert_FieldMask) GetPaths() []Alert_FieldPath { 259 if fieldMask == nil { 260 return nil 261 } 262 return fieldMask.Paths 263 } 264 265 func (fieldMask *Alert_FieldMask) GetRawPaths() []gotenobject.FieldPath { 266 if fieldMask == nil { 267 return nil 268 } 269 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 270 for _, path := range fieldMask.Paths { 271 rawPaths = append(rawPaths, path) 272 } 273 return rawPaths 274 } 275 276 func (fieldMask *Alert_FieldMask) SetFromCliFlag(raw string) error { 277 path, err := ParseAlert_FieldPath(raw) 278 if err != nil { 279 return err 280 } 281 fieldMask.Paths = append(fieldMask.Paths, path) 282 return nil 283 } 284 285 func (fieldMask *Alert_FieldMask) Set(target, source *Alert) { 286 for _, path := range fieldMask.Paths { 287 val, _ := path.GetSingle(source) 288 // if val is nil, then field does not exist in source, skip 289 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 290 if val != nil { 291 path.WithIValue(val).SetTo(&target) 292 } 293 } 294 } 295 296 func (fieldMask *Alert_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 297 fieldMask.Set(target.(*Alert), source.(*Alert)) 298 } 299 300 func (fieldMask *Alert_FieldMask) Project(source *Alert) *Alert { 301 if source == nil { 302 return nil 303 } 304 if fieldMask == nil { 305 return source 306 } 307 result := &Alert{} 308 metadataMask := &meta.Meta_FieldMask{} 309 wholeMetadataAccepted := false 310 infoMask := &Alert_Info_FieldMask{} 311 wholeInfoAccepted := false 312 stateMask := &Alert_State_FieldMask{} 313 wholeStateAccepted := false 314 315 for _, p := range fieldMask.Paths { 316 switch tp := p.(type) { 317 case *Alert_FieldTerminalPath: 318 switch tp.selector { 319 case Alert_FieldPathSelectorName: 320 result.Name = source.Name 321 case Alert_FieldPathSelectorMetadata: 322 result.Metadata = source.Metadata 323 wholeMetadataAccepted = true 324 case Alert_FieldPathSelectorDisplayName: 325 result.DisplayName = source.DisplayName 326 case Alert_FieldPathSelectorInfo: 327 result.Info = source.Info 328 wholeInfoAccepted = true 329 case Alert_FieldPathSelectorState: 330 result.State = source.State 331 wholeStateAccepted = true 332 } 333 case *Alert_FieldSubPath: 334 switch tp.selector { 335 case Alert_FieldPathSelectorMetadata: 336 metadataMask.AppendPath(tp.subPath.(meta.Meta_FieldPath)) 337 case Alert_FieldPathSelectorInfo: 338 infoMask.AppendPath(tp.subPath.(AlertInfo_FieldPath)) 339 case Alert_FieldPathSelectorState: 340 stateMask.AppendPath(tp.subPath.(AlertState_FieldPath)) 341 } 342 } 343 } 344 if wholeMetadataAccepted == false && len(metadataMask.Paths) > 0 { 345 result.Metadata = metadataMask.Project(source.GetMetadata()) 346 } 347 if wholeInfoAccepted == false && len(infoMask.Paths) > 0 { 348 result.Info = infoMask.Project(source.GetInfo()) 349 } 350 if wholeStateAccepted == false && len(stateMask.Paths) > 0 { 351 result.State = stateMask.Project(source.GetState()) 352 } 353 return result 354 } 355 356 func (fieldMask *Alert_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 357 return fieldMask.Project(source.(*Alert)) 358 } 359 360 func (fieldMask *Alert_FieldMask) PathsCount() int { 361 if fieldMask == nil { 362 return 0 363 } 364 return len(fieldMask.Paths) 365 } 366 367 type Alert_Info_FieldMask struct { 368 Paths []AlertInfo_FieldPath 369 } 370 371 func FullAlert_Info_FieldMask() *Alert_Info_FieldMask { 372 res := &Alert_Info_FieldMask{} 373 res.Paths = append(res.Paths, &AlertInfo_FieldTerminalPath{selector: AlertInfo_FieldPathSelectorTimeSerie}) 374 res.Paths = append(res.Paths, &AlertInfo_FieldTerminalPath{selector: AlertInfo_FieldPathSelectorObservedValues}) 375 return res 376 } 377 378 func (fieldMask *Alert_Info_FieldMask) String() string { 379 if fieldMask == nil { 380 return "<nil>" 381 } 382 pathsStr := make([]string, 0, len(fieldMask.Paths)) 383 for _, path := range fieldMask.Paths { 384 pathsStr = append(pathsStr, path.String()) 385 } 386 return strings.Join(pathsStr, ", ") 387 } 388 389 func (fieldMask *Alert_Info_FieldMask) IsFull() bool { 390 if fieldMask == nil { 391 return false 392 } 393 presentSelectors := make([]bool, 2) 394 for _, path := range fieldMask.Paths { 395 if asFinal, ok := path.(*AlertInfo_FieldTerminalPath); ok { 396 presentSelectors[int(asFinal.selector)] = true 397 } 398 } 399 for _, flag := range presentSelectors { 400 if !flag { 401 return false 402 } 403 } 404 return true 405 } 406 407 func (fieldMask *Alert_Info_FieldMask) ProtoReflect() preflect.Message { 408 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 409 return ParseAlertInfo_FieldPath(raw) 410 }) 411 } 412 413 func (fieldMask *Alert_Info_FieldMask) ProtoMessage() {} 414 415 func (fieldMask *Alert_Info_FieldMask) Reset() { 416 if fieldMask != nil { 417 fieldMask.Paths = nil 418 } 419 } 420 421 func (fieldMask *Alert_Info_FieldMask) Subtract(other *Alert_Info_FieldMask) *Alert_Info_FieldMask { 422 result := &Alert_Info_FieldMask{} 423 removedSelectors := make([]bool, 2) 424 otherSubMasks := map[AlertInfo_FieldPathSelector]gotenobject.FieldMask{ 425 AlertInfo_FieldPathSelectorTimeSerie: &Alert_Info_TimeSerie_FieldMask{}, 426 AlertInfo_FieldPathSelectorObservedValues: &Alert_Info_ObservedValues_FieldMask{}, 427 } 428 mySubMasks := map[AlertInfo_FieldPathSelector]gotenobject.FieldMask{ 429 AlertInfo_FieldPathSelectorTimeSerie: &Alert_Info_TimeSerie_FieldMask{}, 430 AlertInfo_FieldPathSelectorObservedValues: &Alert_Info_ObservedValues_FieldMask{}, 431 } 432 433 for _, path := range other.GetPaths() { 434 switch tp := path.(type) { 435 case *AlertInfo_FieldTerminalPath: 436 removedSelectors[int(tp.selector)] = true 437 case *AlertInfo_FieldSubPath: 438 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 439 } 440 } 441 for _, path := range fieldMask.GetPaths() { 442 if !removedSelectors[int(path.Selector())] { 443 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 444 if tp, ok := path.(*AlertInfo_FieldTerminalPath); ok { 445 switch tp.selector { 446 case AlertInfo_FieldPathSelectorTimeSerie: 447 mySubMasks[AlertInfo_FieldPathSelectorTimeSerie] = FullAlert_Info_TimeSerie_FieldMask() 448 case AlertInfo_FieldPathSelectorObservedValues: 449 mySubMasks[AlertInfo_FieldPathSelectorObservedValues] = FullAlert_Info_ObservedValues_FieldMask() 450 } 451 } else if tp, ok := path.(*AlertInfo_FieldSubPath); ok { 452 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 453 } 454 } else { 455 result.Paths = append(result.Paths, path) 456 } 457 } 458 } 459 for selector, mySubMask := range mySubMasks { 460 if mySubMask.PathsCount() > 0 { 461 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 462 result.Paths = append(result.Paths, &AlertInfo_FieldSubPath{selector: selector, subPath: allowedPath}) 463 } 464 } 465 } 466 467 if len(result.Paths) == 0 { 468 return nil 469 } 470 return result 471 } 472 473 func (fieldMask *Alert_Info_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 474 return fieldMask.Subtract(other.(*Alert_Info_FieldMask)) 475 } 476 477 // FilterInputFields generates copy of field paths with output_only field paths removed 478 func (fieldMask *Alert_Info_FieldMask) FilterInputFields() *Alert_Info_FieldMask { 479 result := &Alert_Info_FieldMask{} 480 result.Paths = append(result.Paths, fieldMask.Paths...) 481 return result 482 } 483 484 // ToFieldMask is used for proto conversions 485 func (fieldMask *Alert_Info_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 486 protoFieldMask := &googlefieldmaskpb.FieldMask{} 487 for _, path := range fieldMask.Paths { 488 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 489 } 490 return protoFieldMask 491 } 492 493 func (fieldMask *Alert_Info_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 494 if fieldMask == nil { 495 return status.Error(codes.Internal, "target field mask is nil") 496 } 497 fieldMask.Paths = make([]AlertInfo_FieldPath, 0, len(protoFieldMask.Paths)) 498 for _, strPath := range protoFieldMask.Paths { 499 path, err := ParseAlertInfo_FieldPath(strPath) 500 if err != nil { 501 return err 502 } 503 fieldMask.Paths = append(fieldMask.Paths, path) 504 } 505 return nil 506 } 507 508 // implement methods required by customType 509 func (fieldMask Alert_Info_FieldMask) Marshal() ([]byte, error) { 510 protoFieldMask := fieldMask.ToProtoFieldMask() 511 return proto.Marshal(protoFieldMask) 512 } 513 514 func (fieldMask *Alert_Info_FieldMask) Unmarshal(data []byte) error { 515 protoFieldMask := &googlefieldmaskpb.FieldMask{} 516 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 517 return err 518 } 519 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 520 return err 521 } 522 return nil 523 } 524 525 func (fieldMask *Alert_Info_FieldMask) Size() int { 526 return proto.Size(fieldMask.ToProtoFieldMask()) 527 } 528 529 func (fieldMask Alert_Info_FieldMask) MarshalJSON() ([]byte, error) { 530 return json.Marshal(fieldMask.ToProtoFieldMask()) 531 } 532 533 func (fieldMask *Alert_Info_FieldMask) UnmarshalJSON(data []byte) error { 534 protoFieldMask := &googlefieldmaskpb.FieldMask{} 535 if err := json.Unmarshal(data, protoFieldMask); err != nil { 536 return err 537 } 538 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 539 return err 540 } 541 return nil 542 } 543 544 func (fieldMask *Alert_Info_FieldMask) AppendPath(path AlertInfo_FieldPath) { 545 fieldMask.Paths = append(fieldMask.Paths, path) 546 } 547 548 func (fieldMask *Alert_Info_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 549 fieldMask.Paths = append(fieldMask.Paths, path.(AlertInfo_FieldPath)) 550 } 551 552 func (fieldMask *Alert_Info_FieldMask) GetPaths() []AlertInfo_FieldPath { 553 if fieldMask == nil { 554 return nil 555 } 556 return fieldMask.Paths 557 } 558 559 func (fieldMask *Alert_Info_FieldMask) GetRawPaths() []gotenobject.FieldPath { 560 if fieldMask == nil { 561 return nil 562 } 563 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 564 for _, path := range fieldMask.Paths { 565 rawPaths = append(rawPaths, path) 566 } 567 return rawPaths 568 } 569 570 func (fieldMask *Alert_Info_FieldMask) SetFromCliFlag(raw string) error { 571 path, err := ParseAlertInfo_FieldPath(raw) 572 if err != nil { 573 return err 574 } 575 fieldMask.Paths = append(fieldMask.Paths, path) 576 return nil 577 } 578 579 func (fieldMask *Alert_Info_FieldMask) Set(target, source *Alert_Info) { 580 for _, path := range fieldMask.Paths { 581 val, _ := path.GetSingle(source) 582 // if val is nil, then field does not exist in source, skip 583 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 584 if val != nil { 585 path.WithIValue(val).SetTo(&target) 586 } 587 } 588 } 589 590 func (fieldMask *Alert_Info_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 591 fieldMask.Set(target.(*Alert_Info), source.(*Alert_Info)) 592 } 593 594 func (fieldMask *Alert_Info_FieldMask) Project(source *Alert_Info) *Alert_Info { 595 if source == nil { 596 return nil 597 } 598 if fieldMask == nil { 599 return source 600 } 601 result := &Alert_Info{} 602 timeSerieMask := &Alert_Info_TimeSerie_FieldMask{} 603 wholeTimeSerieAccepted := false 604 observedValuesMask := &Alert_Info_ObservedValues_FieldMask{} 605 wholeObservedValuesAccepted := false 606 607 for _, p := range fieldMask.Paths { 608 switch tp := p.(type) { 609 case *AlertInfo_FieldTerminalPath: 610 switch tp.selector { 611 case AlertInfo_FieldPathSelectorTimeSerie: 612 result.TimeSerie = source.TimeSerie 613 wholeTimeSerieAccepted = true 614 case AlertInfo_FieldPathSelectorObservedValues: 615 result.ObservedValues = source.ObservedValues 616 wholeObservedValuesAccepted = true 617 } 618 case *AlertInfo_FieldSubPath: 619 switch tp.selector { 620 case AlertInfo_FieldPathSelectorTimeSerie: 621 timeSerieMask.AppendPath(tp.subPath.(AlertInfoTimeSerie_FieldPath)) 622 case AlertInfo_FieldPathSelectorObservedValues: 623 observedValuesMask.AppendPath(tp.subPath.(AlertInfoObservedValues_FieldPath)) 624 } 625 } 626 } 627 if wholeTimeSerieAccepted == false && len(timeSerieMask.Paths) > 0 { 628 result.TimeSerie = timeSerieMask.Project(source.GetTimeSerie()) 629 } 630 if wholeObservedValuesAccepted == false && len(observedValuesMask.Paths) > 0 { 631 result.ObservedValues = observedValuesMask.Project(source.GetObservedValues()) 632 } 633 return result 634 } 635 636 func (fieldMask *Alert_Info_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 637 return fieldMask.Project(source.(*Alert_Info)) 638 } 639 640 func (fieldMask *Alert_Info_FieldMask) PathsCount() int { 641 if fieldMask == nil { 642 return 0 643 } 644 return len(fieldMask.Paths) 645 } 646 647 type Alert_State_FieldMask struct { 648 Paths []AlertState_FieldPath 649 } 650 651 func FullAlert_State_FieldMask() *Alert_State_FieldMask { 652 res := &Alert_State_FieldMask{} 653 res.Paths = append(res.Paths, &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorIsFiring}) 654 res.Paths = append(res.Paths, &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorIsAcknowledged}) 655 res.Paths = append(res.Paths, &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorIsSilenced}) 656 res.Paths = append(res.Paths, &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorLifetime}) 657 res.Paths = append(res.Paths, &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorNeedsNotification}) 658 res.Paths = append(res.Paths, &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorNotificationCreated}) 659 res.Paths = append(res.Paths, &AlertState_FieldTerminalPath{selector: AlertState_FieldPathSelectorLifecycleCompleted}) 660 return res 661 } 662 663 func (fieldMask *Alert_State_FieldMask) String() string { 664 if fieldMask == nil { 665 return "<nil>" 666 } 667 pathsStr := make([]string, 0, len(fieldMask.Paths)) 668 for _, path := range fieldMask.Paths { 669 pathsStr = append(pathsStr, path.String()) 670 } 671 return strings.Join(pathsStr, ", ") 672 } 673 674 func (fieldMask *Alert_State_FieldMask) IsFull() bool { 675 if fieldMask == nil { 676 return false 677 } 678 presentSelectors := make([]bool, 7) 679 for _, path := range fieldMask.Paths { 680 if asFinal, ok := path.(*AlertState_FieldTerminalPath); ok { 681 presentSelectors[int(asFinal.selector)] = true 682 } 683 } 684 for _, flag := range presentSelectors { 685 if !flag { 686 return false 687 } 688 } 689 return true 690 } 691 692 func (fieldMask *Alert_State_FieldMask) ProtoReflect() preflect.Message { 693 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 694 return ParseAlertState_FieldPath(raw) 695 }) 696 } 697 698 func (fieldMask *Alert_State_FieldMask) ProtoMessage() {} 699 700 func (fieldMask *Alert_State_FieldMask) Reset() { 701 if fieldMask != nil { 702 fieldMask.Paths = nil 703 } 704 } 705 706 func (fieldMask *Alert_State_FieldMask) Subtract(other *Alert_State_FieldMask) *Alert_State_FieldMask { 707 result := &Alert_State_FieldMask{} 708 removedSelectors := make([]bool, 7) 709 otherSubMasks := map[AlertState_FieldPathSelector]gotenobject.FieldMask{ 710 AlertState_FieldPathSelectorLifetime: &common.TimeRange_FieldMask{}, 711 } 712 mySubMasks := map[AlertState_FieldPathSelector]gotenobject.FieldMask{ 713 AlertState_FieldPathSelectorLifetime: &common.TimeRange_FieldMask{}, 714 } 715 716 for _, path := range other.GetPaths() { 717 switch tp := path.(type) { 718 case *AlertState_FieldTerminalPath: 719 removedSelectors[int(tp.selector)] = true 720 case *AlertState_FieldSubPath: 721 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 722 } 723 } 724 for _, path := range fieldMask.GetPaths() { 725 if !removedSelectors[int(path.Selector())] { 726 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 727 if tp, ok := path.(*AlertState_FieldTerminalPath); ok { 728 switch tp.selector { 729 case AlertState_FieldPathSelectorLifetime: 730 mySubMasks[AlertState_FieldPathSelectorLifetime] = common.FullTimeRange_FieldMask() 731 } 732 } else if tp, ok := path.(*AlertState_FieldSubPath); ok { 733 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 734 } 735 } else { 736 result.Paths = append(result.Paths, path) 737 } 738 } 739 } 740 for selector, mySubMask := range mySubMasks { 741 if mySubMask.PathsCount() > 0 { 742 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 743 result.Paths = append(result.Paths, &AlertState_FieldSubPath{selector: selector, subPath: allowedPath}) 744 } 745 } 746 } 747 748 if len(result.Paths) == 0 { 749 return nil 750 } 751 return result 752 } 753 754 func (fieldMask *Alert_State_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 755 return fieldMask.Subtract(other.(*Alert_State_FieldMask)) 756 } 757 758 // FilterInputFields generates copy of field paths with output_only field paths removed 759 func (fieldMask *Alert_State_FieldMask) FilterInputFields() *Alert_State_FieldMask { 760 result := &Alert_State_FieldMask{} 761 result.Paths = append(result.Paths, fieldMask.Paths...) 762 return result 763 } 764 765 // ToFieldMask is used for proto conversions 766 func (fieldMask *Alert_State_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 767 protoFieldMask := &googlefieldmaskpb.FieldMask{} 768 for _, path := range fieldMask.Paths { 769 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 770 } 771 return protoFieldMask 772 } 773 774 func (fieldMask *Alert_State_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 775 if fieldMask == nil { 776 return status.Error(codes.Internal, "target field mask is nil") 777 } 778 fieldMask.Paths = make([]AlertState_FieldPath, 0, len(protoFieldMask.Paths)) 779 for _, strPath := range protoFieldMask.Paths { 780 path, err := ParseAlertState_FieldPath(strPath) 781 if err != nil { 782 return err 783 } 784 fieldMask.Paths = append(fieldMask.Paths, path) 785 } 786 return nil 787 } 788 789 // implement methods required by customType 790 func (fieldMask Alert_State_FieldMask) Marshal() ([]byte, error) { 791 protoFieldMask := fieldMask.ToProtoFieldMask() 792 return proto.Marshal(protoFieldMask) 793 } 794 795 func (fieldMask *Alert_State_FieldMask) Unmarshal(data []byte) error { 796 protoFieldMask := &googlefieldmaskpb.FieldMask{} 797 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 798 return err 799 } 800 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 801 return err 802 } 803 return nil 804 } 805 806 func (fieldMask *Alert_State_FieldMask) Size() int { 807 return proto.Size(fieldMask.ToProtoFieldMask()) 808 } 809 810 func (fieldMask Alert_State_FieldMask) MarshalJSON() ([]byte, error) { 811 return json.Marshal(fieldMask.ToProtoFieldMask()) 812 } 813 814 func (fieldMask *Alert_State_FieldMask) UnmarshalJSON(data []byte) error { 815 protoFieldMask := &googlefieldmaskpb.FieldMask{} 816 if err := json.Unmarshal(data, protoFieldMask); err != nil { 817 return err 818 } 819 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 820 return err 821 } 822 return nil 823 } 824 825 func (fieldMask *Alert_State_FieldMask) AppendPath(path AlertState_FieldPath) { 826 fieldMask.Paths = append(fieldMask.Paths, path) 827 } 828 829 func (fieldMask *Alert_State_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 830 fieldMask.Paths = append(fieldMask.Paths, path.(AlertState_FieldPath)) 831 } 832 833 func (fieldMask *Alert_State_FieldMask) GetPaths() []AlertState_FieldPath { 834 if fieldMask == nil { 835 return nil 836 } 837 return fieldMask.Paths 838 } 839 840 func (fieldMask *Alert_State_FieldMask) GetRawPaths() []gotenobject.FieldPath { 841 if fieldMask == nil { 842 return nil 843 } 844 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 845 for _, path := range fieldMask.Paths { 846 rawPaths = append(rawPaths, path) 847 } 848 return rawPaths 849 } 850 851 func (fieldMask *Alert_State_FieldMask) SetFromCliFlag(raw string) error { 852 path, err := ParseAlertState_FieldPath(raw) 853 if err != nil { 854 return err 855 } 856 fieldMask.Paths = append(fieldMask.Paths, path) 857 return nil 858 } 859 860 func (fieldMask *Alert_State_FieldMask) Set(target, source *Alert_State) { 861 for _, path := range fieldMask.Paths { 862 val, _ := path.GetSingle(source) 863 // if val is nil, then field does not exist in source, skip 864 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 865 if val != nil { 866 path.WithIValue(val).SetTo(&target) 867 } 868 } 869 } 870 871 func (fieldMask *Alert_State_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 872 fieldMask.Set(target.(*Alert_State), source.(*Alert_State)) 873 } 874 875 func (fieldMask *Alert_State_FieldMask) Project(source *Alert_State) *Alert_State { 876 if source == nil { 877 return nil 878 } 879 if fieldMask == nil { 880 return source 881 } 882 result := &Alert_State{} 883 lifetimeMask := &common.TimeRange_FieldMask{} 884 wholeLifetimeAccepted := false 885 886 for _, p := range fieldMask.Paths { 887 switch tp := p.(type) { 888 case *AlertState_FieldTerminalPath: 889 switch tp.selector { 890 case AlertState_FieldPathSelectorIsFiring: 891 result.IsFiring = source.IsFiring 892 case AlertState_FieldPathSelectorIsAcknowledged: 893 result.IsAcknowledged = source.IsAcknowledged 894 case AlertState_FieldPathSelectorIsSilenced: 895 result.IsSilenced = source.IsSilenced 896 case AlertState_FieldPathSelectorLifetime: 897 result.Lifetime = source.Lifetime 898 wholeLifetimeAccepted = true 899 case AlertState_FieldPathSelectorNeedsNotification: 900 result.NeedsNotification = source.NeedsNotification 901 case AlertState_FieldPathSelectorNotificationCreated: 902 result.NotificationCreated = source.NotificationCreated 903 case AlertState_FieldPathSelectorLifecycleCompleted: 904 result.LifecycleCompleted = source.LifecycleCompleted 905 } 906 case *AlertState_FieldSubPath: 907 switch tp.selector { 908 case AlertState_FieldPathSelectorLifetime: 909 lifetimeMask.AppendPath(tp.subPath.(common.TimeRange_FieldPath)) 910 } 911 } 912 } 913 if wholeLifetimeAccepted == false && len(lifetimeMask.Paths) > 0 { 914 result.Lifetime = lifetimeMask.Project(source.GetLifetime()) 915 } 916 return result 917 } 918 919 func (fieldMask *Alert_State_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 920 return fieldMask.Project(source.(*Alert_State)) 921 } 922 923 func (fieldMask *Alert_State_FieldMask) PathsCount() int { 924 if fieldMask == nil { 925 return 0 926 } 927 return len(fieldMask.Paths) 928 } 929 930 type Alert_Info_TimeSerie_FieldMask struct { 931 Paths []AlertInfoTimeSerie_FieldPath 932 } 933 934 func FullAlert_Info_TimeSerie_FieldMask() *Alert_Info_TimeSerie_FieldMask { 935 res := &Alert_Info_TimeSerie_FieldMask{} 936 res.Paths = append(res.Paths, &AlertInfoTimeSerie_FieldTerminalPath{selector: AlertInfoTimeSerie_FieldPathSelectorKey}) 937 res.Paths = append(res.Paths, &AlertInfoTimeSerie_FieldTerminalPath{selector: AlertInfoTimeSerie_FieldPathSelectorMetric}) 938 res.Paths = append(res.Paths, &AlertInfoTimeSerie_FieldTerminalPath{selector: AlertInfoTimeSerie_FieldPathSelectorMonitoredResource}) 939 return res 940 } 941 942 func (fieldMask *Alert_Info_TimeSerie_FieldMask) String() string { 943 if fieldMask == nil { 944 return "<nil>" 945 } 946 pathsStr := make([]string, 0, len(fieldMask.Paths)) 947 for _, path := range fieldMask.Paths { 948 pathsStr = append(pathsStr, path.String()) 949 } 950 return strings.Join(pathsStr, ", ") 951 } 952 953 func (fieldMask *Alert_Info_TimeSerie_FieldMask) IsFull() bool { 954 if fieldMask == nil { 955 return false 956 } 957 presentSelectors := make([]bool, 3) 958 for _, path := range fieldMask.Paths { 959 if asFinal, ok := path.(*AlertInfoTimeSerie_FieldTerminalPath); ok { 960 presentSelectors[int(asFinal.selector)] = true 961 } 962 } 963 for _, flag := range presentSelectors { 964 if !flag { 965 return false 966 } 967 } 968 return true 969 } 970 971 func (fieldMask *Alert_Info_TimeSerie_FieldMask) ProtoReflect() preflect.Message { 972 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 973 return ParseAlertInfoTimeSerie_FieldPath(raw) 974 }) 975 } 976 977 func (fieldMask *Alert_Info_TimeSerie_FieldMask) ProtoMessage() {} 978 979 func (fieldMask *Alert_Info_TimeSerie_FieldMask) Reset() { 980 if fieldMask != nil { 981 fieldMask.Paths = nil 982 } 983 } 984 985 func (fieldMask *Alert_Info_TimeSerie_FieldMask) Subtract(other *Alert_Info_TimeSerie_FieldMask) *Alert_Info_TimeSerie_FieldMask { 986 result := &Alert_Info_TimeSerie_FieldMask{} 987 removedSelectors := make([]bool, 3) 988 otherSubMasks := map[AlertInfoTimeSerie_FieldPathSelector]gotenobject.FieldMask{ 989 AlertInfoTimeSerie_FieldPathSelectorMetric: &common.Metric_FieldMask{}, 990 AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: &common.MonitoredResource_FieldMask{}, 991 } 992 mySubMasks := map[AlertInfoTimeSerie_FieldPathSelector]gotenobject.FieldMask{ 993 AlertInfoTimeSerie_FieldPathSelectorMetric: &common.Metric_FieldMask{}, 994 AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: &common.MonitoredResource_FieldMask{}, 995 } 996 997 for _, path := range other.GetPaths() { 998 switch tp := path.(type) { 999 case *AlertInfoTimeSerie_FieldTerminalPath: 1000 removedSelectors[int(tp.selector)] = true 1001 case *AlertInfoTimeSerie_FieldSubPath: 1002 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 1003 } 1004 } 1005 for _, path := range fieldMask.GetPaths() { 1006 if !removedSelectors[int(path.Selector())] { 1007 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 1008 if tp, ok := path.(*AlertInfoTimeSerie_FieldTerminalPath); ok { 1009 switch tp.selector { 1010 case AlertInfoTimeSerie_FieldPathSelectorMetric: 1011 mySubMasks[AlertInfoTimeSerie_FieldPathSelectorMetric] = common.FullMetric_FieldMask() 1012 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 1013 mySubMasks[AlertInfoTimeSerie_FieldPathSelectorMonitoredResource] = common.FullMonitoredResource_FieldMask() 1014 } 1015 } else if tp, ok := path.(*AlertInfoTimeSerie_FieldSubPath); ok { 1016 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 1017 } 1018 } else { 1019 result.Paths = append(result.Paths, path) 1020 } 1021 } 1022 } 1023 for selector, mySubMask := range mySubMasks { 1024 if mySubMask.PathsCount() > 0 { 1025 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 1026 result.Paths = append(result.Paths, &AlertInfoTimeSerie_FieldSubPath{selector: selector, subPath: allowedPath}) 1027 } 1028 } 1029 } 1030 1031 if len(result.Paths) == 0 { 1032 return nil 1033 } 1034 return result 1035 } 1036 1037 func (fieldMask *Alert_Info_TimeSerie_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 1038 return fieldMask.Subtract(other.(*Alert_Info_TimeSerie_FieldMask)) 1039 } 1040 1041 // FilterInputFields generates copy of field paths with output_only field paths removed 1042 func (fieldMask *Alert_Info_TimeSerie_FieldMask) FilterInputFields() *Alert_Info_TimeSerie_FieldMask { 1043 result := &Alert_Info_TimeSerie_FieldMask{} 1044 result.Paths = append(result.Paths, fieldMask.Paths...) 1045 return result 1046 } 1047 1048 // ToFieldMask is used for proto conversions 1049 func (fieldMask *Alert_Info_TimeSerie_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 1050 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1051 for _, path := range fieldMask.Paths { 1052 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 1053 } 1054 return protoFieldMask 1055 } 1056 1057 func (fieldMask *Alert_Info_TimeSerie_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 1058 if fieldMask == nil { 1059 return status.Error(codes.Internal, "target field mask is nil") 1060 } 1061 fieldMask.Paths = make([]AlertInfoTimeSerie_FieldPath, 0, len(protoFieldMask.Paths)) 1062 for _, strPath := range protoFieldMask.Paths { 1063 path, err := ParseAlertInfoTimeSerie_FieldPath(strPath) 1064 if err != nil { 1065 return err 1066 } 1067 fieldMask.Paths = append(fieldMask.Paths, path) 1068 } 1069 return nil 1070 } 1071 1072 // implement methods required by customType 1073 func (fieldMask Alert_Info_TimeSerie_FieldMask) Marshal() ([]byte, error) { 1074 protoFieldMask := fieldMask.ToProtoFieldMask() 1075 return proto.Marshal(protoFieldMask) 1076 } 1077 1078 func (fieldMask *Alert_Info_TimeSerie_FieldMask) Unmarshal(data []byte) error { 1079 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1080 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 1081 return err 1082 } 1083 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1084 return err 1085 } 1086 return nil 1087 } 1088 1089 func (fieldMask *Alert_Info_TimeSerie_FieldMask) Size() int { 1090 return proto.Size(fieldMask.ToProtoFieldMask()) 1091 } 1092 1093 func (fieldMask Alert_Info_TimeSerie_FieldMask) MarshalJSON() ([]byte, error) { 1094 return json.Marshal(fieldMask.ToProtoFieldMask()) 1095 } 1096 1097 func (fieldMask *Alert_Info_TimeSerie_FieldMask) UnmarshalJSON(data []byte) error { 1098 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1099 if err := json.Unmarshal(data, protoFieldMask); err != nil { 1100 return err 1101 } 1102 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1103 return err 1104 } 1105 return nil 1106 } 1107 1108 func (fieldMask *Alert_Info_TimeSerie_FieldMask) AppendPath(path AlertInfoTimeSerie_FieldPath) { 1109 fieldMask.Paths = append(fieldMask.Paths, path) 1110 } 1111 1112 func (fieldMask *Alert_Info_TimeSerie_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 1113 fieldMask.Paths = append(fieldMask.Paths, path.(AlertInfoTimeSerie_FieldPath)) 1114 } 1115 1116 func (fieldMask *Alert_Info_TimeSerie_FieldMask) GetPaths() []AlertInfoTimeSerie_FieldPath { 1117 if fieldMask == nil { 1118 return nil 1119 } 1120 return fieldMask.Paths 1121 } 1122 1123 func (fieldMask *Alert_Info_TimeSerie_FieldMask) GetRawPaths() []gotenobject.FieldPath { 1124 if fieldMask == nil { 1125 return nil 1126 } 1127 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 1128 for _, path := range fieldMask.Paths { 1129 rawPaths = append(rawPaths, path) 1130 } 1131 return rawPaths 1132 } 1133 1134 func (fieldMask *Alert_Info_TimeSerie_FieldMask) SetFromCliFlag(raw string) error { 1135 path, err := ParseAlertInfoTimeSerie_FieldPath(raw) 1136 if err != nil { 1137 return err 1138 } 1139 fieldMask.Paths = append(fieldMask.Paths, path) 1140 return nil 1141 } 1142 1143 func (fieldMask *Alert_Info_TimeSerie_FieldMask) Set(target, source *Alert_Info_TimeSerie) { 1144 for _, path := range fieldMask.Paths { 1145 val, _ := path.GetSingle(source) 1146 // if val is nil, then field does not exist in source, skip 1147 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 1148 if val != nil { 1149 path.WithIValue(val).SetTo(&target) 1150 } 1151 } 1152 } 1153 1154 func (fieldMask *Alert_Info_TimeSerie_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 1155 fieldMask.Set(target.(*Alert_Info_TimeSerie), source.(*Alert_Info_TimeSerie)) 1156 } 1157 1158 func (fieldMask *Alert_Info_TimeSerie_FieldMask) Project(source *Alert_Info_TimeSerie) *Alert_Info_TimeSerie { 1159 if source == nil { 1160 return nil 1161 } 1162 if fieldMask == nil { 1163 return source 1164 } 1165 result := &Alert_Info_TimeSerie{} 1166 metricMask := &common.Metric_FieldMask{} 1167 wholeMetricAccepted := false 1168 monitoredResourceMask := &common.MonitoredResource_FieldMask{} 1169 wholeMonitoredResourceAccepted := false 1170 1171 for _, p := range fieldMask.Paths { 1172 switch tp := p.(type) { 1173 case *AlertInfoTimeSerie_FieldTerminalPath: 1174 switch tp.selector { 1175 case AlertInfoTimeSerie_FieldPathSelectorKey: 1176 result.Key = source.Key 1177 case AlertInfoTimeSerie_FieldPathSelectorMetric: 1178 result.Metric = source.Metric 1179 wholeMetricAccepted = true 1180 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 1181 result.MonitoredResource = source.MonitoredResource 1182 wholeMonitoredResourceAccepted = true 1183 } 1184 case *AlertInfoTimeSerie_FieldSubPath: 1185 switch tp.selector { 1186 case AlertInfoTimeSerie_FieldPathSelectorMetric: 1187 metricMask.AppendPath(tp.subPath.(common.Metric_FieldPath)) 1188 case AlertInfoTimeSerie_FieldPathSelectorMonitoredResource: 1189 monitoredResourceMask.AppendPath(tp.subPath.(common.MonitoredResource_FieldPath)) 1190 } 1191 } 1192 } 1193 if wholeMetricAccepted == false && len(metricMask.Paths) > 0 { 1194 result.Metric = metricMask.Project(source.GetMetric()) 1195 } 1196 if wholeMonitoredResourceAccepted == false && len(monitoredResourceMask.Paths) > 0 { 1197 result.MonitoredResource = monitoredResourceMask.Project(source.GetMonitoredResource()) 1198 } 1199 return result 1200 } 1201 1202 func (fieldMask *Alert_Info_TimeSerie_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 1203 return fieldMask.Project(source.(*Alert_Info_TimeSerie)) 1204 } 1205 1206 func (fieldMask *Alert_Info_TimeSerie_FieldMask) PathsCount() int { 1207 if fieldMask == nil { 1208 return 0 1209 } 1210 return len(fieldMask.Paths) 1211 } 1212 1213 type Alert_Info_ObservedValues_FieldMask struct { 1214 Paths []AlertInfoObservedValues_FieldPath 1215 } 1216 1217 func FullAlert_Info_ObservedValues_FieldMask() *Alert_Info_ObservedValues_FieldMask { 1218 res := &Alert_Info_ObservedValues_FieldMask{} 1219 res.Paths = append(res.Paths, &AlertInfoObservedValues_FieldTerminalPath{selector: AlertInfoObservedValues_FieldPathSelectorExampleValue}) 1220 res.Paths = append(res.Paths, &AlertInfoObservedValues_FieldTerminalPath{selector: AlertInfoObservedValues_FieldPathSelectorPerMetric}) 1221 return res 1222 } 1223 1224 func (fieldMask *Alert_Info_ObservedValues_FieldMask) String() string { 1225 if fieldMask == nil { 1226 return "<nil>" 1227 } 1228 pathsStr := make([]string, 0, len(fieldMask.Paths)) 1229 for _, path := range fieldMask.Paths { 1230 pathsStr = append(pathsStr, path.String()) 1231 } 1232 return strings.Join(pathsStr, ", ") 1233 } 1234 1235 func (fieldMask *Alert_Info_ObservedValues_FieldMask) IsFull() bool { 1236 if fieldMask == nil { 1237 return false 1238 } 1239 presentSelectors := make([]bool, 2) 1240 for _, path := range fieldMask.Paths { 1241 if asFinal, ok := path.(*AlertInfoObservedValues_FieldTerminalPath); ok { 1242 presentSelectors[int(asFinal.selector)] = true 1243 } 1244 } 1245 for _, flag := range presentSelectors { 1246 if !flag { 1247 return false 1248 } 1249 } 1250 return true 1251 } 1252 1253 func (fieldMask *Alert_Info_ObservedValues_FieldMask) ProtoReflect() preflect.Message { 1254 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 1255 return ParseAlertInfoObservedValues_FieldPath(raw) 1256 }) 1257 } 1258 1259 func (fieldMask *Alert_Info_ObservedValues_FieldMask) ProtoMessage() {} 1260 1261 func (fieldMask *Alert_Info_ObservedValues_FieldMask) Reset() { 1262 if fieldMask != nil { 1263 fieldMask.Paths = nil 1264 } 1265 } 1266 1267 func (fieldMask *Alert_Info_ObservedValues_FieldMask) Subtract(other *Alert_Info_ObservedValues_FieldMask) *Alert_Info_ObservedValues_FieldMask { 1268 result := &Alert_Info_ObservedValues_FieldMask{} 1269 removedSelectors := make([]bool, 2) 1270 1271 for _, path := range other.GetPaths() { 1272 switch tp := path.(type) { 1273 case *AlertInfoObservedValues_FieldTerminalPath: 1274 removedSelectors[int(tp.selector)] = true 1275 } 1276 } 1277 for _, path := range fieldMask.GetPaths() { 1278 if !removedSelectors[int(path.Selector())] { 1279 result.Paths = append(result.Paths, path) 1280 } 1281 } 1282 1283 if len(result.Paths) == 0 { 1284 return nil 1285 } 1286 return result 1287 } 1288 1289 func (fieldMask *Alert_Info_ObservedValues_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 1290 return fieldMask.Subtract(other.(*Alert_Info_ObservedValues_FieldMask)) 1291 } 1292 1293 // FilterInputFields generates copy of field paths with output_only field paths removed 1294 func (fieldMask *Alert_Info_ObservedValues_FieldMask) FilterInputFields() *Alert_Info_ObservedValues_FieldMask { 1295 result := &Alert_Info_ObservedValues_FieldMask{} 1296 result.Paths = append(result.Paths, fieldMask.Paths...) 1297 return result 1298 } 1299 1300 // ToFieldMask is used for proto conversions 1301 func (fieldMask *Alert_Info_ObservedValues_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 1302 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1303 for _, path := range fieldMask.Paths { 1304 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 1305 } 1306 return protoFieldMask 1307 } 1308 1309 func (fieldMask *Alert_Info_ObservedValues_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 1310 if fieldMask == nil { 1311 return status.Error(codes.Internal, "target field mask is nil") 1312 } 1313 fieldMask.Paths = make([]AlertInfoObservedValues_FieldPath, 0, len(protoFieldMask.Paths)) 1314 for _, strPath := range protoFieldMask.Paths { 1315 path, err := ParseAlertInfoObservedValues_FieldPath(strPath) 1316 if err != nil { 1317 return err 1318 } 1319 fieldMask.Paths = append(fieldMask.Paths, path) 1320 } 1321 return nil 1322 } 1323 1324 // implement methods required by customType 1325 func (fieldMask Alert_Info_ObservedValues_FieldMask) Marshal() ([]byte, error) { 1326 protoFieldMask := fieldMask.ToProtoFieldMask() 1327 return proto.Marshal(protoFieldMask) 1328 } 1329 1330 func (fieldMask *Alert_Info_ObservedValues_FieldMask) Unmarshal(data []byte) error { 1331 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1332 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 1333 return err 1334 } 1335 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1336 return err 1337 } 1338 return nil 1339 } 1340 1341 func (fieldMask *Alert_Info_ObservedValues_FieldMask) Size() int { 1342 return proto.Size(fieldMask.ToProtoFieldMask()) 1343 } 1344 1345 func (fieldMask Alert_Info_ObservedValues_FieldMask) MarshalJSON() ([]byte, error) { 1346 return json.Marshal(fieldMask.ToProtoFieldMask()) 1347 } 1348 1349 func (fieldMask *Alert_Info_ObservedValues_FieldMask) UnmarshalJSON(data []byte) error { 1350 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1351 if err := json.Unmarshal(data, protoFieldMask); err != nil { 1352 return err 1353 } 1354 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1355 return err 1356 } 1357 return nil 1358 } 1359 1360 func (fieldMask *Alert_Info_ObservedValues_FieldMask) AppendPath(path AlertInfoObservedValues_FieldPath) { 1361 fieldMask.Paths = append(fieldMask.Paths, path) 1362 } 1363 1364 func (fieldMask *Alert_Info_ObservedValues_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 1365 fieldMask.Paths = append(fieldMask.Paths, path.(AlertInfoObservedValues_FieldPath)) 1366 } 1367 1368 func (fieldMask *Alert_Info_ObservedValues_FieldMask) GetPaths() []AlertInfoObservedValues_FieldPath { 1369 if fieldMask == nil { 1370 return nil 1371 } 1372 return fieldMask.Paths 1373 } 1374 1375 func (fieldMask *Alert_Info_ObservedValues_FieldMask) GetRawPaths() []gotenobject.FieldPath { 1376 if fieldMask == nil { 1377 return nil 1378 } 1379 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 1380 for _, path := range fieldMask.Paths { 1381 rawPaths = append(rawPaths, path) 1382 } 1383 return rawPaths 1384 } 1385 1386 func (fieldMask *Alert_Info_ObservedValues_FieldMask) SetFromCliFlag(raw string) error { 1387 path, err := ParseAlertInfoObservedValues_FieldPath(raw) 1388 if err != nil { 1389 return err 1390 } 1391 fieldMask.Paths = append(fieldMask.Paths, path) 1392 return nil 1393 } 1394 1395 func (fieldMask *Alert_Info_ObservedValues_FieldMask) Set(target, source *Alert_Info_ObservedValues) { 1396 for _, path := range fieldMask.Paths { 1397 val, _ := path.GetSingle(source) 1398 // if val is nil, then field does not exist in source, skip 1399 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 1400 if val != nil { 1401 path.WithIValue(val).SetTo(&target) 1402 } 1403 } 1404 } 1405 1406 func (fieldMask *Alert_Info_ObservedValues_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 1407 fieldMask.Set(target.(*Alert_Info_ObservedValues), source.(*Alert_Info_ObservedValues)) 1408 } 1409 1410 func (fieldMask *Alert_Info_ObservedValues_FieldMask) Project(source *Alert_Info_ObservedValues) *Alert_Info_ObservedValues { 1411 if source == nil { 1412 return nil 1413 } 1414 if fieldMask == nil { 1415 return source 1416 } 1417 result := &Alert_Info_ObservedValues{} 1418 var perMetricMapKeys []string 1419 wholePerMetricAccepted := false 1420 1421 for _, p := range fieldMask.Paths { 1422 switch tp := p.(type) { 1423 case *AlertInfoObservedValues_FieldTerminalPath: 1424 switch tp.selector { 1425 case AlertInfoObservedValues_FieldPathSelectorExampleValue: 1426 result.ExampleValue = source.ExampleValue 1427 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 1428 result.PerMetric = source.PerMetric 1429 wholePerMetricAccepted = true 1430 } 1431 case *AlertInfoObservedValues_FieldPathMap: 1432 switch tp.selector { 1433 case AlertInfoObservedValues_FieldPathSelectorPerMetric: 1434 perMetricMapKeys = append(perMetricMapKeys, tp.key) 1435 } 1436 } 1437 } 1438 if wholePerMetricAccepted == false && len(perMetricMapKeys) > 0 && source.GetPerMetric() != nil { 1439 copiedMap := map[string]float64{} 1440 sourceMap := source.GetPerMetric() 1441 for _, key := range perMetricMapKeys { 1442 copiedMap[key] = sourceMap[key] 1443 } 1444 result.PerMetric = copiedMap 1445 } 1446 return result 1447 } 1448 1449 func (fieldMask *Alert_Info_ObservedValues_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 1450 return fieldMask.Project(source.(*Alert_Info_ObservedValues)) 1451 } 1452 1453 func (fieldMask *Alert_Info_ObservedValues_FieldMask) PathsCount() int { 1454 if fieldMask == nil { 1455 return 0 1456 } 1457 return len(fieldMask.Paths) 1458 } 1459 1460 type Alert_State_Threshold_FieldMask struct { 1461 Paths []AlertStateThreshold_FieldPath 1462 } 1463 1464 func FullAlert_State_Threshold_FieldMask() *Alert_State_Threshold_FieldMask { 1465 res := &Alert_State_Threshold_FieldMask{} 1466 res.Paths = append(res.Paths, &AlertStateThreshold_FieldTerminalPath{selector: AlertStateThreshold_FieldPathSelectorObservedValue}) 1467 return res 1468 } 1469 1470 func (fieldMask *Alert_State_Threshold_FieldMask) String() string { 1471 if fieldMask == nil { 1472 return "<nil>" 1473 } 1474 pathsStr := make([]string, 0, len(fieldMask.Paths)) 1475 for _, path := range fieldMask.Paths { 1476 pathsStr = append(pathsStr, path.String()) 1477 } 1478 return strings.Join(pathsStr, ", ") 1479 } 1480 1481 func (fieldMask *Alert_State_Threshold_FieldMask) IsFull() bool { 1482 if fieldMask == nil { 1483 return false 1484 } 1485 presentSelectors := make([]bool, 1) 1486 for _, path := range fieldMask.Paths { 1487 if asFinal, ok := path.(*AlertStateThreshold_FieldTerminalPath); ok { 1488 presentSelectors[int(asFinal.selector)] = true 1489 } 1490 } 1491 for _, flag := range presentSelectors { 1492 if !flag { 1493 return false 1494 } 1495 } 1496 return true 1497 } 1498 1499 func (fieldMask *Alert_State_Threshold_FieldMask) ProtoReflect() preflect.Message { 1500 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 1501 return ParseAlertStateThreshold_FieldPath(raw) 1502 }) 1503 } 1504 1505 func (fieldMask *Alert_State_Threshold_FieldMask) ProtoMessage() {} 1506 1507 func (fieldMask *Alert_State_Threshold_FieldMask) Reset() { 1508 if fieldMask != nil { 1509 fieldMask.Paths = nil 1510 } 1511 } 1512 1513 func (fieldMask *Alert_State_Threshold_FieldMask) Subtract(other *Alert_State_Threshold_FieldMask) *Alert_State_Threshold_FieldMask { 1514 result := &Alert_State_Threshold_FieldMask{} 1515 removedSelectors := make([]bool, 1) 1516 1517 for _, path := range other.GetPaths() { 1518 switch tp := path.(type) { 1519 case *AlertStateThreshold_FieldTerminalPath: 1520 removedSelectors[int(tp.selector)] = true 1521 } 1522 } 1523 for _, path := range fieldMask.GetPaths() { 1524 if !removedSelectors[int(path.Selector())] { 1525 result.Paths = append(result.Paths, path) 1526 } 1527 } 1528 1529 if len(result.Paths) == 0 { 1530 return nil 1531 } 1532 return result 1533 } 1534 1535 func (fieldMask *Alert_State_Threshold_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 1536 return fieldMask.Subtract(other.(*Alert_State_Threshold_FieldMask)) 1537 } 1538 1539 // FilterInputFields generates copy of field paths with output_only field paths removed 1540 func (fieldMask *Alert_State_Threshold_FieldMask) FilterInputFields() *Alert_State_Threshold_FieldMask { 1541 result := &Alert_State_Threshold_FieldMask{} 1542 result.Paths = append(result.Paths, fieldMask.Paths...) 1543 return result 1544 } 1545 1546 // ToFieldMask is used for proto conversions 1547 func (fieldMask *Alert_State_Threshold_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 1548 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1549 for _, path := range fieldMask.Paths { 1550 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 1551 } 1552 return protoFieldMask 1553 } 1554 1555 func (fieldMask *Alert_State_Threshold_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 1556 if fieldMask == nil { 1557 return status.Error(codes.Internal, "target field mask is nil") 1558 } 1559 fieldMask.Paths = make([]AlertStateThreshold_FieldPath, 0, len(protoFieldMask.Paths)) 1560 for _, strPath := range protoFieldMask.Paths { 1561 path, err := ParseAlertStateThreshold_FieldPath(strPath) 1562 if err != nil { 1563 return err 1564 } 1565 fieldMask.Paths = append(fieldMask.Paths, path) 1566 } 1567 return nil 1568 } 1569 1570 // implement methods required by customType 1571 func (fieldMask Alert_State_Threshold_FieldMask) Marshal() ([]byte, error) { 1572 protoFieldMask := fieldMask.ToProtoFieldMask() 1573 return proto.Marshal(protoFieldMask) 1574 } 1575 1576 func (fieldMask *Alert_State_Threshold_FieldMask) Unmarshal(data []byte) error { 1577 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1578 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 1579 return err 1580 } 1581 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1582 return err 1583 } 1584 return nil 1585 } 1586 1587 func (fieldMask *Alert_State_Threshold_FieldMask) Size() int { 1588 return proto.Size(fieldMask.ToProtoFieldMask()) 1589 } 1590 1591 func (fieldMask Alert_State_Threshold_FieldMask) MarshalJSON() ([]byte, error) { 1592 return json.Marshal(fieldMask.ToProtoFieldMask()) 1593 } 1594 1595 func (fieldMask *Alert_State_Threshold_FieldMask) UnmarshalJSON(data []byte) error { 1596 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1597 if err := json.Unmarshal(data, protoFieldMask); err != nil { 1598 return err 1599 } 1600 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1601 return err 1602 } 1603 return nil 1604 } 1605 1606 func (fieldMask *Alert_State_Threshold_FieldMask) AppendPath(path AlertStateThreshold_FieldPath) { 1607 fieldMask.Paths = append(fieldMask.Paths, path) 1608 } 1609 1610 func (fieldMask *Alert_State_Threshold_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 1611 fieldMask.Paths = append(fieldMask.Paths, path.(AlertStateThreshold_FieldPath)) 1612 } 1613 1614 func (fieldMask *Alert_State_Threshold_FieldMask) GetPaths() []AlertStateThreshold_FieldPath { 1615 if fieldMask == nil { 1616 return nil 1617 } 1618 return fieldMask.Paths 1619 } 1620 1621 func (fieldMask *Alert_State_Threshold_FieldMask) GetRawPaths() []gotenobject.FieldPath { 1622 if fieldMask == nil { 1623 return nil 1624 } 1625 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 1626 for _, path := range fieldMask.Paths { 1627 rawPaths = append(rawPaths, path) 1628 } 1629 return rawPaths 1630 } 1631 1632 func (fieldMask *Alert_State_Threshold_FieldMask) SetFromCliFlag(raw string) error { 1633 path, err := ParseAlertStateThreshold_FieldPath(raw) 1634 if err != nil { 1635 return err 1636 } 1637 fieldMask.Paths = append(fieldMask.Paths, path) 1638 return nil 1639 } 1640 1641 func (fieldMask *Alert_State_Threshold_FieldMask) Set(target, source *Alert_State_Threshold) { 1642 for _, path := range fieldMask.Paths { 1643 val, _ := path.GetSingle(source) 1644 // if val is nil, then field does not exist in source, skip 1645 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 1646 if val != nil { 1647 path.WithIValue(val).SetTo(&target) 1648 } 1649 } 1650 } 1651 1652 func (fieldMask *Alert_State_Threshold_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 1653 fieldMask.Set(target.(*Alert_State_Threshold), source.(*Alert_State_Threshold)) 1654 } 1655 1656 func (fieldMask *Alert_State_Threshold_FieldMask) Project(source *Alert_State_Threshold) *Alert_State_Threshold { 1657 if source == nil { 1658 return nil 1659 } 1660 if fieldMask == nil { 1661 return source 1662 } 1663 result := &Alert_State_Threshold{} 1664 1665 for _, p := range fieldMask.Paths { 1666 switch tp := p.(type) { 1667 case *AlertStateThreshold_FieldTerminalPath: 1668 switch tp.selector { 1669 case AlertStateThreshold_FieldPathSelectorObservedValue: 1670 result.ObservedValue = source.ObservedValue 1671 } 1672 } 1673 } 1674 return result 1675 } 1676 1677 func (fieldMask *Alert_State_Threshold_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 1678 return fieldMask.Project(source.(*Alert_State_Threshold)) 1679 } 1680 1681 func (fieldMask *Alert_State_Threshold_FieldMask) PathsCount() int { 1682 if fieldMask == nil { 1683 return 0 1684 } 1685 return len(fieldMask.Paths) 1686 } 1687 1688 type Alert_State_CombineThreshold_FieldMask struct { 1689 Paths []AlertStateCombineThreshold_FieldPath 1690 } 1691 1692 func FullAlert_State_CombineThreshold_FieldMask() *Alert_State_CombineThreshold_FieldMask { 1693 res := &Alert_State_CombineThreshold_FieldMask{} 1694 return res 1695 } 1696 1697 func (fieldMask *Alert_State_CombineThreshold_FieldMask) String() string { 1698 if fieldMask == nil { 1699 return "<nil>" 1700 } 1701 pathsStr := make([]string, 0, len(fieldMask.Paths)) 1702 for _, path := range fieldMask.Paths { 1703 pathsStr = append(pathsStr, path.String()) 1704 } 1705 return strings.Join(pathsStr, ", ") 1706 } 1707 1708 func (fieldMask *Alert_State_CombineThreshold_FieldMask) IsFull() bool { 1709 if fieldMask == nil { 1710 return false 1711 } 1712 presentSelectors := make([]bool, 0) 1713 for _, path := range fieldMask.Paths { 1714 if asFinal, ok := path.(*AlertStateCombineThreshold_FieldTerminalPath); ok { 1715 presentSelectors[int(asFinal.selector)] = true 1716 } 1717 } 1718 for _, flag := range presentSelectors { 1719 if !flag { 1720 return false 1721 } 1722 } 1723 return true 1724 } 1725 1726 func (fieldMask *Alert_State_CombineThreshold_FieldMask) ProtoReflect() preflect.Message { 1727 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 1728 return ParseAlertStateCombineThreshold_FieldPath(raw) 1729 }) 1730 } 1731 1732 func (fieldMask *Alert_State_CombineThreshold_FieldMask) ProtoMessage() {} 1733 1734 func (fieldMask *Alert_State_CombineThreshold_FieldMask) Reset() { 1735 if fieldMask != nil { 1736 fieldMask.Paths = nil 1737 } 1738 } 1739 1740 func (fieldMask *Alert_State_CombineThreshold_FieldMask) Subtract(other *Alert_State_CombineThreshold_FieldMask) *Alert_State_CombineThreshold_FieldMask { 1741 result := &Alert_State_CombineThreshold_FieldMask{} 1742 removedSelectors := make([]bool, 0) 1743 1744 for _, path := range other.GetPaths() { 1745 switch tp := path.(type) { 1746 case *AlertStateCombineThreshold_FieldTerminalPath: 1747 removedSelectors[int(tp.selector)] = true 1748 } 1749 } 1750 for _, path := range fieldMask.GetPaths() { 1751 if !removedSelectors[int(path.Selector())] { 1752 result.Paths = append(result.Paths, path) 1753 } 1754 } 1755 1756 if len(result.Paths) == 0 { 1757 return nil 1758 } 1759 return result 1760 } 1761 1762 func (fieldMask *Alert_State_CombineThreshold_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 1763 return fieldMask.Subtract(other.(*Alert_State_CombineThreshold_FieldMask)) 1764 } 1765 1766 // FilterInputFields generates copy of field paths with output_only field paths removed 1767 func (fieldMask *Alert_State_CombineThreshold_FieldMask) FilterInputFields() *Alert_State_CombineThreshold_FieldMask { 1768 result := &Alert_State_CombineThreshold_FieldMask{} 1769 result.Paths = append(result.Paths, fieldMask.Paths...) 1770 return result 1771 } 1772 1773 // ToFieldMask is used for proto conversions 1774 func (fieldMask *Alert_State_CombineThreshold_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 1775 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1776 for _, path := range fieldMask.Paths { 1777 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 1778 } 1779 return protoFieldMask 1780 } 1781 1782 func (fieldMask *Alert_State_CombineThreshold_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 1783 if fieldMask == nil { 1784 return status.Error(codes.Internal, "target field mask is nil") 1785 } 1786 fieldMask.Paths = make([]AlertStateCombineThreshold_FieldPath, 0, len(protoFieldMask.Paths)) 1787 for _, strPath := range protoFieldMask.Paths { 1788 path, err := ParseAlertStateCombineThreshold_FieldPath(strPath) 1789 if err != nil { 1790 return err 1791 } 1792 fieldMask.Paths = append(fieldMask.Paths, path) 1793 } 1794 return nil 1795 } 1796 1797 // implement methods required by customType 1798 func (fieldMask Alert_State_CombineThreshold_FieldMask) Marshal() ([]byte, error) { 1799 protoFieldMask := fieldMask.ToProtoFieldMask() 1800 return proto.Marshal(protoFieldMask) 1801 } 1802 1803 func (fieldMask *Alert_State_CombineThreshold_FieldMask) Unmarshal(data []byte) error { 1804 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1805 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 1806 return err 1807 } 1808 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1809 return err 1810 } 1811 return nil 1812 } 1813 1814 func (fieldMask *Alert_State_CombineThreshold_FieldMask) Size() int { 1815 return proto.Size(fieldMask.ToProtoFieldMask()) 1816 } 1817 1818 func (fieldMask Alert_State_CombineThreshold_FieldMask) MarshalJSON() ([]byte, error) { 1819 return json.Marshal(fieldMask.ToProtoFieldMask()) 1820 } 1821 1822 func (fieldMask *Alert_State_CombineThreshold_FieldMask) UnmarshalJSON(data []byte) error { 1823 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1824 if err := json.Unmarshal(data, protoFieldMask); err != nil { 1825 return err 1826 } 1827 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1828 return err 1829 } 1830 return nil 1831 } 1832 1833 func (fieldMask *Alert_State_CombineThreshold_FieldMask) AppendPath(path AlertStateCombineThreshold_FieldPath) { 1834 fieldMask.Paths = append(fieldMask.Paths, path) 1835 } 1836 1837 func (fieldMask *Alert_State_CombineThreshold_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 1838 fieldMask.Paths = append(fieldMask.Paths, path.(AlertStateCombineThreshold_FieldPath)) 1839 } 1840 1841 func (fieldMask *Alert_State_CombineThreshold_FieldMask) GetPaths() []AlertStateCombineThreshold_FieldPath { 1842 if fieldMask == nil { 1843 return nil 1844 } 1845 return fieldMask.Paths 1846 } 1847 1848 func (fieldMask *Alert_State_CombineThreshold_FieldMask) GetRawPaths() []gotenobject.FieldPath { 1849 if fieldMask == nil { 1850 return nil 1851 } 1852 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 1853 for _, path := range fieldMask.Paths { 1854 rawPaths = append(rawPaths, path) 1855 } 1856 return rawPaths 1857 } 1858 1859 func (fieldMask *Alert_State_CombineThreshold_FieldMask) SetFromCliFlag(raw string) error { 1860 path, err := ParseAlertStateCombineThreshold_FieldPath(raw) 1861 if err != nil { 1862 return err 1863 } 1864 fieldMask.Paths = append(fieldMask.Paths, path) 1865 return nil 1866 } 1867 1868 func (fieldMask *Alert_State_CombineThreshold_FieldMask) Set(target, source *Alert_State_CombineThreshold) { 1869 for _, path := range fieldMask.Paths { 1870 val, _ := path.GetSingle(source) 1871 // if val is nil, then field does not exist in source, skip 1872 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 1873 if val != nil { 1874 path.WithIValue(val).SetTo(&target) 1875 } 1876 } 1877 } 1878 1879 func (fieldMask *Alert_State_CombineThreshold_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 1880 fieldMask.Set(target.(*Alert_State_CombineThreshold), source.(*Alert_State_CombineThreshold)) 1881 } 1882 1883 func (fieldMask *Alert_State_CombineThreshold_FieldMask) Project(source *Alert_State_CombineThreshold) *Alert_State_CombineThreshold { 1884 if source == nil { 1885 return nil 1886 } 1887 if fieldMask == nil { 1888 return source 1889 } 1890 result := &Alert_State_CombineThreshold{} 1891 1892 for _, p := range fieldMask.Paths { 1893 switch tp := p.(type) { 1894 case *AlertStateCombineThreshold_FieldTerminalPath: 1895 switch tp.selector { 1896 } 1897 } 1898 } 1899 return result 1900 } 1901 1902 func (fieldMask *Alert_State_CombineThreshold_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 1903 return fieldMask.Project(source.(*Alert_State_CombineThreshold)) 1904 } 1905 1906 func (fieldMask *Alert_State_CombineThreshold_FieldMask) PathsCount() int { 1907 if fieldMask == nil { 1908 return 0 1909 } 1910 return len(fieldMask.Paths) 1911 } 1912 1913 type Alert_State_CombineThreshold_PerMetric_FieldMask struct { 1914 Paths []AlertStateCombineThresholdPerMetric_FieldPath 1915 } 1916 1917 func FullAlert_State_CombineThreshold_PerMetric_FieldMask() *Alert_State_CombineThreshold_PerMetric_FieldMask { 1918 res := &Alert_State_CombineThreshold_PerMetric_FieldMask{} 1919 res.Paths = append(res.Paths, &AlertStateCombineThresholdPerMetric_FieldTerminalPath{selector: AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues}) 1920 return res 1921 } 1922 1923 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) String() string { 1924 if fieldMask == nil { 1925 return "<nil>" 1926 } 1927 pathsStr := make([]string, 0, len(fieldMask.Paths)) 1928 for _, path := range fieldMask.Paths { 1929 pathsStr = append(pathsStr, path.String()) 1930 } 1931 return strings.Join(pathsStr, ", ") 1932 } 1933 1934 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) IsFull() bool { 1935 if fieldMask == nil { 1936 return false 1937 } 1938 presentSelectors := make([]bool, 1) 1939 for _, path := range fieldMask.Paths { 1940 if asFinal, ok := path.(*AlertStateCombineThresholdPerMetric_FieldTerminalPath); ok { 1941 presentSelectors[int(asFinal.selector)] = true 1942 } 1943 } 1944 for _, flag := range presentSelectors { 1945 if !flag { 1946 return false 1947 } 1948 } 1949 return true 1950 } 1951 1952 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) ProtoReflect() preflect.Message { 1953 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 1954 return ParseAlertStateCombineThresholdPerMetric_FieldPath(raw) 1955 }) 1956 } 1957 1958 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) ProtoMessage() {} 1959 1960 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) Reset() { 1961 if fieldMask != nil { 1962 fieldMask.Paths = nil 1963 } 1964 } 1965 1966 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) Subtract(other *Alert_State_CombineThreshold_PerMetric_FieldMask) *Alert_State_CombineThreshold_PerMetric_FieldMask { 1967 result := &Alert_State_CombineThreshold_PerMetric_FieldMask{} 1968 removedSelectors := make([]bool, 1) 1969 1970 for _, path := range other.GetPaths() { 1971 switch tp := path.(type) { 1972 case *AlertStateCombineThresholdPerMetric_FieldTerminalPath: 1973 removedSelectors[int(tp.selector)] = true 1974 } 1975 } 1976 for _, path := range fieldMask.GetPaths() { 1977 if !removedSelectors[int(path.Selector())] { 1978 result.Paths = append(result.Paths, path) 1979 } 1980 } 1981 1982 if len(result.Paths) == 0 { 1983 return nil 1984 } 1985 return result 1986 } 1987 1988 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 1989 return fieldMask.Subtract(other.(*Alert_State_CombineThreshold_PerMetric_FieldMask)) 1990 } 1991 1992 // FilterInputFields generates copy of field paths with output_only field paths removed 1993 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) FilterInputFields() *Alert_State_CombineThreshold_PerMetric_FieldMask { 1994 result := &Alert_State_CombineThreshold_PerMetric_FieldMask{} 1995 result.Paths = append(result.Paths, fieldMask.Paths...) 1996 return result 1997 } 1998 1999 // ToFieldMask is used for proto conversions 2000 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 2001 protoFieldMask := &googlefieldmaskpb.FieldMask{} 2002 for _, path := range fieldMask.Paths { 2003 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 2004 } 2005 return protoFieldMask 2006 } 2007 2008 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 2009 if fieldMask == nil { 2010 return status.Error(codes.Internal, "target field mask is nil") 2011 } 2012 fieldMask.Paths = make([]AlertStateCombineThresholdPerMetric_FieldPath, 0, len(protoFieldMask.Paths)) 2013 for _, strPath := range protoFieldMask.Paths { 2014 path, err := ParseAlertStateCombineThresholdPerMetric_FieldPath(strPath) 2015 if err != nil { 2016 return err 2017 } 2018 fieldMask.Paths = append(fieldMask.Paths, path) 2019 } 2020 return nil 2021 } 2022 2023 // implement methods required by customType 2024 func (fieldMask Alert_State_CombineThreshold_PerMetric_FieldMask) Marshal() ([]byte, error) { 2025 protoFieldMask := fieldMask.ToProtoFieldMask() 2026 return proto.Marshal(protoFieldMask) 2027 } 2028 2029 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) Unmarshal(data []byte) error { 2030 protoFieldMask := &googlefieldmaskpb.FieldMask{} 2031 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 2032 return err 2033 } 2034 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 2035 return err 2036 } 2037 return nil 2038 } 2039 2040 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) Size() int { 2041 return proto.Size(fieldMask.ToProtoFieldMask()) 2042 } 2043 2044 func (fieldMask Alert_State_CombineThreshold_PerMetric_FieldMask) MarshalJSON() ([]byte, error) { 2045 return json.Marshal(fieldMask.ToProtoFieldMask()) 2046 } 2047 2048 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) UnmarshalJSON(data []byte) error { 2049 protoFieldMask := &googlefieldmaskpb.FieldMask{} 2050 if err := json.Unmarshal(data, protoFieldMask); err != nil { 2051 return err 2052 } 2053 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 2054 return err 2055 } 2056 return nil 2057 } 2058 2059 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) AppendPath(path AlertStateCombineThresholdPerMetric_FieldPath) { 2060 fieldMask.Paths = append(fieldMask.Paths, path) 2061 } 2062 2063 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 2064 fieldMask.Paths = append(fieldMask.Paths, path.(AlertStateCombineThresholdPerMetric_FieldPath)) 2065 } 2066 2067 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) GetPaths() []AlertStateCombineThresholdPerMetric_FieldPath { 2068 if fieldMask == nil { 2069 return nil 2070 } 2071 return fieldMask.Paths 2072 } 2073 2074 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) GetRawPaths() []gotenobject.FieldPath { 2075 if fieldMask == nil { 2076 return nil 2077 } 2078 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 2079 for _, path := range fieldMask.Paths { 2080 rawPaths = append(rawPaths, path) 2081 } 2082 return rawPaths 2083 } 2084 2085 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) SetFromCliFlag(raw string) error { 2086 path, err := ParseAlertStateCombineThresholdPerMetric_FieldPath(raw) 2087 if err != nil { 2088 return err 2089 } 2090 fieldMask.Paths = append(fieldMask.Paths, path) 2091 return nil 2092 } 2093 2094 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) Set(target, source *Alert_State_CombineThreshold_PerMetric) { 2095 for _, path := range fieldMask.Paths { 2096 val, _ := path.GetSingle(source) 2097 // if val is nil, then field does not exist in source, skip 2098 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 2099 if val != nil { 2100 path.WithIValue(val).SetTo(&target) 2101 } 2102 } 2103 } 2104 2105 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 2106 fieldMask.Set(target.(*Alert_State_CombineThreshold_PerMetric), source.(*Alert_State_CombineThreshold_PerMetric)) 2107 } 2108 2109 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) Project(source *Alert_State_CombineThreshold_PerMetric) *Alert_State_CombineThreshold_PerMetric { 2110 if source == nil { 2111 return nil 2112 } 2113 if fieldMask == nil { 2114 return source 2115 } 2116 result := &Alert_State_CombineThreshold_PerMetric{} 2117 var observedValuesMapKeys []string 2118 wholeObservedValuesAccepted := false 2119 2120 for _, p := range fieldMask.Paths { 2121 switch tp := p.(type) { 2122 case *AlertStateCombineThresholdPerMetric_FieldTerminalPath: 2123 switch tp.selector { 2124 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 2125 result.ObservedValues = source.ObservedValues 2126 wholeObservedValuesAccepted = true 2127 } 2128 case *AlertStateCombineThresholdPerMetric_FieldPathMap: 2129 switch tp.selector { 2130 case AlertStateCombineThresholdPerMetric_FieldPathSelectorObservedValues: 2131 observedValuesMapKeys = append(observedValuesMapKeys, tp.key) 2132 } 2133 } 2134 } 2135 if wholeObservedValuesAccepted == false && len(observedValuesMapKeys) > 0 && source.GetObservedValues() != nil { 2136 copiedMap := map[string]float64{} 2137 sourceMap := source.GetObservedValues() 2138 for _, key := range observedValuesMapKeys { 2139 copiedMap[key] = sourceMap[key] 2140 } 2141 result.ObservedValues = copiedMap 2142 } 2143 return result 2144 } 2145 2146 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 2147 return fieldMask.Project(source.(*Alert_State_CombineThreshold_PerMetric)) 2148 } 2149 2150 func (fieldMask *Alert_State_CombineThreshold_PerMetric_FieldMask) PathsCount() int { 2151 if fieldMask == nil { 2152 return 0 2153 } 2154 return len(fieldMask.Paths) 2155 }