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