github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v4/notification/notification.pb.fieldmask.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/monitoring/proto/v4/notification.proto 3 // DO NOT EDIT!!! 4 5 package notification 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 alert "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/alert" 23 alerting_condition "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/alerting_condition" 24 alerting_policy "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/alerting_policy" 25 common "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/common" 26 notification_channel "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/notification_channel" 27 project "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/project" 28 meta "github.com/cloudwan/goten-sdk/types/meta" 29 ) 30 31 // ensure the imports are used 32 var ( 33 _ = new(json.Marshaler) 34 _ = strings.Builder{} 35 36 _ = codes.NotFound 37 _ = status.Status{} 38 _ = new(proto.Message) 39 _ = new(preflect.Message) 40 _ = googlefieldmaskpb.FieldMask{} 41 42 _ = new(gotenobject.FieldMask) 43 ) 44 45 // make sure we're using proto imports 46 var ( 47 _ = &alert.Alert{} 48 _ = &alerting_condition.AlertingCondition{} 49 _ = &alerting_policy.AlertingPolicy{} 50 _ = &common.LabelDescriptor{} 51 _ = ¬ification_channel.NotificationChannel{} 52 _ = &project.Project{} 53 _ = &meta.Meta{} 54 ) 55 56 type Notification_FieldMask struct { 57 Paths []Notification_FieldPath 58 } 59 60 func FullNotification_FieldMask() *Notification_FieldMask { 61 res := &Notification_FieldMask{} 62 res.Paths = append(res.Paths, &Notification_FieldTerminalPath{selector: Notification_FieldPathSelectorName}) 63 res.Paths = append(res.Paths, &Notification_FieldTerminalPath{selector: Notification_FieldPathSelectorMetadata}) 64 res.Paths = append(res.Paths, &Notification_FieldTerminalPath{selector: Notification_FieldPathSelectorAlerts}) 65 res.Paths = append(res.Paths, &Notification_FieldTerminalPath{selector: Notification_FieldPathSelectorAlertSets}) 66 res.Paths = append(res.Paths, &Notification_FieldTerminalPath{selector: Notification_FieldPathSelectorState}) 67 return res 68 } 69 70 func (fieldMask *Notification_FieldMask) String() string { 71 if fieldMask == nil { 72 return "<nil>" 73 } 74 pathsStr := make([]string, 0, len(fieldMask.Paths)) 75 for _, path := range fieldMask.Paths { 76 pathsStr = append(pathsStr, path.String()) 77 } 78 return strings.Join(pathsStr, ", ") 79 } 80 81 func (fieldMask *Notification_FieldMask) IsFull() bool { 82 if fieldMask == nil { 83 return false 84 } 85 presentSelectors := make([]bool, 5) 86 for _, path := range fieldMask.Paths { 87 if asFinal, ok := path.(*Notification_FieldTerminalPath); ok { 88 presentSelectors[int(asFinal.selector)] = true 89 } 90 } 91 for _, flag := range presentSelectors { 92 if !flag { 93 return false 94 } 95 } 96 return true 97 } 98 99 func (fieldMask *Notification_FieldMask) ProtoReflect() preflect.Message { 100 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 101 return ParseNotification_FieldPath(raw) 102 }) 103 } 104 105 func (fieldMask *Notification_FieldMask) ProtoMessage() {} 106 107 func (fieldMask *Notification_FieldMask) Reset() { 108 if fieldMask != nil { 109 fieldMask.Paths = nil 110 } 111 } 112 113 func (fieldMask *Notification_FieldMask) Subtract(other *Notification_FieldMask) *Notification_FieldMask { 114 result := &Notification_FieldMask{} 115 removedSelectors := make([]bool, 5) 116 otherSubMasks := map[Notification_FieldPathSelector]gotenobject.FieldMask{ 117 Notification_FieldPathSelectorMetadata: &meta.Meta_FieldMask{}, 118 Notification_FieldPathSelectorAlertSets: &Notification_AlertsSet_FieldMask{}, 119 Notification_FieldPathSelectorState: &Notification_State_FieldMask{}, 120 } 121 mySubMasks := map[Notification_FieldPathSelector]gotenobject.FieldMask{ 122 Notification_FieldPathSelectorMetadata: &meta.Meta_FieldMask{}, 123 Notification_FieldPathSelectorAlertSets: &Notification_AlertsSet_FieldMask{}, 124 Notification_FieldPathSelectorState: &Notification_State_FieldMask{}, 125 } 126 127 for _, path := range other.GetPaths() { 128 switch tp := path.(type) { 129 case *Notification_FieldTerminalPath: 130 removedSelectors[int(tp.selector)] = true 131 case *Notification_FieldSubPath: 132 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 133 } 134 } 135 for _, path := range fieldMask.GetPaths() { 136 if !removedSelectors[int(path.Selector())] { 137 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 138 if tp, ok := path.(*Notification_FieldTerminalPath); ok { 139 switch tp.selector { 140 case Notification_FieldPathSelectorMetadata: 141 mySubMasks[Notification_FieldPathSelectorMetadata] = meta.FullMeta_FieldMask() 142 case Notification_FieldPathSelectorAlertSets: 143 mySubMasks[Notification_FieldPathSelectorAlertSets] = FullNotification_AlertsSet_FieldMask() 144 case Notification_FieldPathSelectorState: 145 mySubMasks[Notification_FieldPathSelectorState] = FullNotification_State_FieldMask() 146 } 147 } else if tp, ok := path.(*Notification_FieldSubPath); ok { 148 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 149 } 150 } else { 151 result.Paths = append(result.Paths, path) 152 } 153 } 154 } 155 for selector, mySubMask := range mySubMasks { 156 if mySubMask.PathsCount() > 0 { 157 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 158 result.Paths = append(result.Paths, &Notification_FieldSubPath{selector: selector, subPath: allowedPath}) 159 } 160 } 161 } 162 163 if len(result.Paths) == 0 { 164 return nil 165 } 166 return result 167 } 168 169 func (fieldMask *Notification_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 170 return fieldMask.Subtract(other.(*Notification_FieldMask)) 171 } 172 173 // FilterInputFields generates copy of field paths with output_only field paths removed 174 func (fieldMask *Notification_FieldMask) FilterInputFields() *Notification_FieldMask { 175 result := &Notification_FieldMask{} 176 for _, path := range fieldMask.Paths { 177 switch path.Selector() { 178 case Notification_FieldPathSelectorMetadata: 179 if _, ok := path.(*Notification_FieldTerminalPath); ok { 180 for _, subpath := range meta.FullMeta_FieldMask().FilterInputFields().Paths { 181 result.Paths = append(result.Paths, &Notification_FieldSubPath{selector: path.Selector(), subPath: subpath}) 182 } 183 } else if sub, ok := path.(*Notification_FieldSubPath); ok { 184 selectedMask := &meta.Meta_FieldMask{ 185 Paths: []meta.Meta_FieldPath{sub.subPath.(meta.Meta_FieldPath)}, 186 } 187 for _, allowedPath := range selectedMask.FilterInputFields().Paths { 188 result.Paths = append(result.Paths, &Notification_FieldSubPath{selector: Notification_FieldPathSelectorMetadata, subPath: allowedPath}) 189 } 190 } 191 default: 192 result.Paths = append(result.Paths, path) 193 } 194 } 195 return result 196 } 197 198 // ToFieldMask is used for proto conversions 199 func (fieldMask *Notification_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 200 protoFieldMask := &googlefieldmaskpb.FieldMask{} 201 for _, path := range fieldMask.Paths { 202 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 203 } 204 return protoFieldMask 205 } 206 207 func (fieldMask *Notification_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 208 if fieldMask == nil { 209 return status.Error(codes.Internal, "target field mask is nil") 210 } 211 fieldMask.Paths = make([]Notification_FieldPath, 0, len(protoFieldMask.Paths)) 212 for _, strPath := range protoFieldMask.Paths { 213 path, err := ParseNotification_FieldPath(strPath) 214 if err != nil { 215 return err 216 } 217 fieldMask.Paths = append(fieldMask.Paths, path) 218 } 219 return nil 220 } 221 222 // implement methods required by customType 223 func (fieldMask Notification_FieldMask) Marshal() ([]byte, error) { 224 protoFieldMask := fieldMask.ToProtoFieldMask() 225 return proto.Marshal(protoFieldMask) 226 } 227 228 func (fieldMask *Notification_FieldMask) Unmarshal(data []byte) error { 229 protoFieldMask := &googlefieldmaskpb.FieldMask{} 230 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 231 return err 232 } 233 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 234 return err 235 } 236 return nil 237 } 238 239 func (fieldMask *Notification_FieldMask) Size() int { 240 return proto.Size(fieldMask.ToProtoFieldMask()) 241 } 242 243 func (fieldMask Notification_FieldMask) MarshalJSON() ([]byte, error) { 244 return json.Marshal(fieldMask.ToProtoFieldMask()) 245 } 246 247 func (fieldMask *Notification_FieldMask) UnmarshalJSON(data []byte) error { 248 protoFieldMask := &googlefieldmaskpb.FieldMask{} 249 if err := json.Unmarshal(data, protoFieldMask); err != nil { 250 return err 251 } 252 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 253 return err 254 } 255 return nil 256 } 257 258 func (fieldMask *Notification_FieldMask) AppendPath(path Notification_FieldPath) { 259 fieldMask.Paths = append(fieldMask.Paths, path) 260 } 261 262 func (fieldMask *Notification_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 263 fieldMask.Paths = append(fieldMask.Paths, path.(Notification_FieldPath)) 264 } 265 266 func (fieldMask *Notification_FieldMask) GetPaths() []Notification_FieldPath { 267 if fieldMask == nil { 268 return nil 269 } 270 return fieldMask.Paths 271 } 272 273 func (fieldMask *Notification_FieldMask) GetRawPaths() []gotenobject.FieldPath { 274 if fieldMask == nil { 275 return nil 276 } 277 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 278 for _, path := range fieldMask.Paths { 279 rawPaths = append(rawPaths, path) 280 } 281 return rawPaths 282 } 283 284 func (fieldMask *Notification_FieldMask) SetFromCliFlag(raw string) error { 285 path, err := ParseNotification_FieldPath(raw) 286 if err != nil { 287 return err 288 } 289 fieldMask.Paths = append(fieldMask.Paths, path) 290 return nil 291 } 292 293 func (fieldMask *Notification_FieldMask) Set(target, source *Notification) { 294 for _, path := range fieldMask.Paths { 295 val, _ := path.GetSingle(source) 296 // if val is nil, then field does not exist in source, skip 297 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 298 if val != nil { 299 path.WithIValue(val).SetTo(&target) 300 } 301 } 302 } 303 304 func (fieldMask *Notification_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 305 fieldMask.Set(target.(*Notification), source.(*Notification)) 306 } 307 308 func (fieldMask *Notification_FieldMask) Project(source *Notification) *Notification { 309 if source == nil { 310 return nil 311 } 312 if fieldMask == nil { 313 return source 314 } 315 result := &Notification{} 316 metadataMask := &meta.Meta_FieldMask{} 317 wholeMetadataAccepted := false 318 alertSetsMask := &Notification_AlertsSet_FieldMask{} 319 wholeAlertSetsAccepted := false 320 stateMask := &Notification_State_FieldMask{} 321 wholeStateAccepted := false 322 323 for _, p := range fieldMask.Paths { 324 switch tp := p.(type) { 325 case *Notification_FieldTerminalPath: 326 switch tp.selector { 327 case Notification_FieldPathSelectorName: 328 result.Name = source.Name 329 case Notification_FieldPathSelectorMetadata: 330 result.Metadata = source.Metadata 331 wholeMetadataAccepted = true 332 case Notification_FieldPathSelectorAlerts: 333 result.Alerts = source.Alerts 334 case Notification_FieldPathSelectorAlertSets: 335 result.AlertSets = source.AlertSets 336 wholeAlertSetsAccepted = true 337 case Notification_FieldPathSelectorState: 338 result.State = source.State 339 wholeStateAccepted = true 340 } 341 case *Notification_FieldSubPath: 342 switch tp.selector { 343 case Notification_FieldPathSelectorMetadata: 344 metadataMask.AppendPath(tp.subPath.(meta.Meta_FieldPath)) 345 case Notification_FieldPathSelectorAlertSets: 346 alertSetsMask.AppendPath(tp.subPath.(NotificationAlertsSet_FieldPath)) 347 case Notification_FieldPathSelectorState: 348 stateMask.AppendPath(tp.subPath.(NotificationState_FieldPath)) 349 } 350 } 351 } 352 if wholeMetadataAccepted == false && len(metadataMask.Paths) > 0 { 353 result.Metadata = metadataMask.Project(source.GetMetadata()) 354 } 355 if wholeAlertSetsAccepted == false && len(alertSetsMask.Paths) > 0 { 356 for _, sourceItem := range source.GetAlertSets() { 357 result.AlertSets = append(result.AlertSets, alertSetsMask.Project(sourceItem)) 358 } 359 } 360 if wholeStateAccepted == false && len(stateMask.Paths) > 0 { 361 result.State = stateMask.Project(source.GetState()) 362 } 363 return result 364 } 365 366 func (fieldMask *Notification_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 367 return fieldMask.Project(source.(*Notification)) 368 } 369 370 func (fieldMask *Notification_FieldMask) PathsCount() int { 371 if fieldMask == nil { 372 return 0 373 } 374 return len(fieldMask.Paths) 375 } 376 377 type Notification_AlertsSet_FieldMask struct { 378 Paths []NotificationAlertsSet_FieldPath 379 } 380 381 func FullNotification_AlertsSet_FieldMask() *Notification_AlertsSet_FieldMask { 382 res := &Notification_AlertsSet_FieldMask{} 383 res.Paths = append(res.Paths, &NotificationAlertsSet_FieldTerminalPath{selector: NotificationAlertsSet_FieldPathSelectorCondition}) 384 res.Paths = append(res.Paths, &NotificationAlertsSet_FieldTerminalPath{selector: NotificationAlertsSet_FieldPathSelectorIds}) 385 return res 386 } 387 388 func (fieldMask *Notification_AlertsSet_FieldMask) String() string { 389 if fieldMask == nil { 390 return "<nil>" 391 } 392 pathsStr := make([]string, 0, len(fieldMask.Paths)) 393 for _, path := range fieldMask.Paths { 394 pathsStr = append(pathsStr, path.String()) 395 } 396 return strings.Join(pathsStr, ", ") 397 } 398 399 func (fieldMask *Notification_AlertsSet_FieldMask) IsFull() bool { 400 if fieldMask == nil { 401 return false 402 } 403 presentSelectors := make([]bool, 2) 404 for _, path := range fieldMask.Paths { 405 if asFinal, ok := path.(*NotificationAlertsSet_FieldTerminalPath); ok { 406 presentSelectors[int(asFinal.selector)] = true 407 } 408 } 409 for _, flag := range presentSelectors { 410 if !flag { 411 return false 412 } 413 } 414 return true 415 } 416 417 func (fieldMask *Notification_AlertsSet_FieldMask) ProtoReflect() preflect.Message { 418 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 419 return ParseNotificationAlertsSet_FieldPath(raw) 420 }) 421 } 422 423 func (fieldMask *Notification_AlertsSet_FieldMask) ProtoMessage() {} 424 425 func (fieldMask *Notification_AlertsSet_FieldMask) Reset() { 426 if fieldMask != nil { 427 fieldMask.Paths = nil 428 } 429 } 430 431 func (fieldMask *Notification_AlertsSet_FieldMask) Subtract(other *Notification_AlertsSet_FieldMask) *Notification_AlertsSet_FieldMask { 432 result := &Notification_AlertsSet_FieldMask{} 433 removedSelectors := make([]bool, 2) 434 435 for _, path := range other.GetPaths() { 436 switch tp := path.(type) { 437 case *NotificationAlertsSet_FieldTerminalPath: 438 removedSelectors[int(tp.selector)] = true 439 } 440 } 441 for _, path := range fieldMask.GetPaths() { 442 if !removedSelectors[int(path.Selector())] { 443 result.Paths = append(result.Paths, path) 444 } 445 } 446 447 if len(result.Paths) == 0 { 448 return nil 449 } 450 return result 451 } 452 453 func (fieldMask *Notification_AlertsSet_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 454 return fieldMask.Subtract(other.(*Notification_AlertsSet_FieldMask)) 455 } 456 457 // FilterInputFields generates copy of field paths with output_only field paths removed 458 func (fieldMask *Notification_AlertsSet_FieldMask) FilterInputFields() *Notification_AlertsSet_FieldMask { 459 result := &Notification_AlertsSet_FieldMask{} 460 result.Paths = append(result.Paths, fieldMask.Paths...) 461 return result 462 } 463 464 // ToFieldMask is used for proto conversions 465 func (fieldMask *Notification_AlertsSet_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 466 protoFieldMask := &googlefieldmaskpb.FieldMask{} 467 for _, path := range fieldMask.Paths { 468 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 469 } 470 return protoFieldMask 471 } 472 473 func (fieldMask *Notification_AlertsSet_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 474 if fieldMask == nil { 475 return status.Error(codes.Internal, "target field mask is nil") 476 } 477 fieldMask.Paths = make([]NotificationAlertsSet_FieldPath, 0, len(protoFieldMask.Paths)) 478 for _, strPath := range protoFieldMask.Paths { 479 path, err := ParseNotificationAlertsSet_FieldPath(strPath) 480 if err != nil { 481 return err 482 } 483 fieldMask.Paths = append(fieldMask.Paths, path) 484 } 485 return nil 486 } 487 488 // implement methods required by customType 489 func (fieldMask Notification_AlertsSet_FieldMask) Marshal() ([]byte, error) { 490 protoFieldMask := fieldMask.ToProtoFieldMask() 491 return proto.Marshal(protoFieldMask) 492 } 493 494 func (fieldMask *Notification_AlertsSet_FieldMask) Unmarshal(data []byte) error { 495 protoFieldMask := &googlefieldmaskpb.FieldMask{} 496 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 497 return err 498 } 499 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 500 return err 501 } 502 return nil 503 } 504 505 func (fieldMask *Notification_AlertsSet_FieldMask) Size() int { 506 return proto.Size(fieldMask.ToProtoFieldMask()) 507 } 508 509 func (fieldMask Notification_AlertsSet_FieldMask) MarshalJSON() ([]byte, error) { 510 return json.Marshal(fieldMask.ToProtoFieldMask()) 511 } 512 513 func (fieldMask *Notification_AlertsSet_FieldMask) UnmarshalJSON(data []byte) error { 514 protoFieldMask := &googlefieldmaskpb.FieldMask{} 515 if err := json.Unmarshal(data, protoFieldMask); err != nil { 516 return err 517 } 518 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 519 return err 520 } 521 return nil 522 } 523 524 func (fieldMask *Notification_AlertsSet_FieldMask) AppendPath(path NotificationAlertsSet_FieldPath) { 525 fieldMask.Paths = append(fieldMask.Paths, path) 526 } 527 528 func (fieldMask *Notification_AlertsSet_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 529 fieldMask.Paths = append(fieldMask.Paths, path.(NotificationAlertsSet_FieldPath)) 530 } 531 532 func (fieldMask *Notification_AlertsSet_FieldMask) GetPaths() []NotificationAlertsSet_FieldPath { 533 if fieldMask == nil { 534 return nil 535 } 536 return fieldMask.Paths 537 } 538 539 func (fieldMask *Notification_AlertsSet_FieldMask) GetRawPaths() []gotenobject.FieldPath { 540 if fieldMask == nil { 541 return nil 542 } 543 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 544 for _, path := range fieldMask.Paths { 545 rawPaths = append(rawPaths, path) 546 } 547 return rawPaths 548 } 549 550 func (fieldMask *Notification_AlertsSet_FieldMask) SetFromCliFlag(raw string) error { 551 path, err := ParseNotificationAlertsSet_FieldPath(raw) 552 if err != nil { 553 return err 554 } 555 fieldMask.Paths = append(fieldMask.Paths, path) 556 return nil 557 } 558 559 func (fieldMask *Notification_AlertsSet_FieldMask) Set(target, source *Notification_AlertsSet) { 560 for _, path := range fieldMask.Paths { 561 val, _ := path.GetSingle(source) 562 // if val is nil, then field does not exist in source, skip 563 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 564 if val != nil { 565 path.WithIValue(val).SetTo(&target) 566 } 567 } 568 } 569 570 func (fieldMask *Notification_AlertsSet_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 571 fieldMask.Set(target.(*Notification_AlertsSet), source.(*Notification_AlertsSet)) 572 } 573 574 func (fieldMask *Notification_AlertsSet_FieldMask) Project(source *Notification_AlertsSet) *Notification_AlertsSet { 575 if source == nil { 576 return nil 577 } 578 if fieldMask == nil { 579 return source 580 } 581 result := &Notification_AlertsSet{} 582 583 for _, p := range fieldMask.Paths { 584 switch tp := p.(type) { 585 case *NotificationAlertsSet_FieldTerminalPath: 586 switch tp.selector { 587 case NotificationAlertsSet_FieldPathSelectorCondition: 588 result.Condition = source.Condition 589 case NotificationAlertsSet_FieldPathSelectorIds: 590 result.Ids = source.Ids 591 } 592 } 593 } 594 return result 595 } 596 597 func (fieldMask *Notification_AlertsSet_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 598 return fieldMask.Project(source.(*Notification_AlertsSet)) 599 } 600 601 func (fieldMask *Notification_AlertsSet_FieldMask) PathsCount() int { 602 if fieldMask == nil { 603 return 0 604 } 605 return len(fieldMask.Paths) 606 } 607 608 type Notification_State_FieldMask struct { 609 Paths []NotificationState_FieldPath 610 } 611 612 func FullNotification_State_FieldMask() *Notification_State_FieldMask { 613 res := &Notification_State_FieldMask{} 614 res.Paths = append(res.Paths, &NotificationState_FieldTerminalPath{selector: NotificationState_FieldPathSelectorIsResolved}) 615 res.Paths = append(res.Paths, &NotificationState_FieldTerminalPath{selector: NotificationState_FieldPathSelectorNotificationState}) 616 res.Paths = append(res.Paths, &NotificationState_FieldTerminalPath{selector: NotificationState_FieldPathSelectorIncidentNotifyAttemptsDone}) 617 res.Paths = append(res.Paths, &NotificationState_FieldTerminalPath{selector: NotificationState_FieldPathSelectorResolutionNotifyAttemptsDone}) 618 res.Paths = append(res.Paths, &NotificationState_FieldTerminalPath{selector: NotificationState_FieldPathSelectorAlertsLifetime}) 619 res.Paths = append(res.Paths, &NotificationState_FieldTerminalPath{selector: NotificationState_FieldPathSelectorResolutionNotificationState}) 620 res.Paths = append(res.Paths, &NotificationState_FieldTerminalPath{selector: NotificationState_FieldPathSelectorLifecycleCompleted}) 621 return res 622 } 623 624 func (fieldMask *Notification_State_FieldMask) String() string { 625 if fieldMask == nil { 626 return "<nil>" 627 } 628 pathsStr := make([]string, 0, len(fieldMask.Paths)) 629 for _, path := range fieldMask.Paths { 630 pathsStr = append(pathsStr, path.String()) 631 } 632 return strings.Join(pathsStr, ", ") 633 } 634 635 func (fieldMask *Notification_State_FieldMask) IsFull() bool { 636 if fieldMask == nil { 637 return false 638 } 639 presentSelectors := make([]bool, 7) 640 for _, path := range fieldMask.Paths { 641 if asFinal, ok := path.(*NotificationState_FieldTerminalPath); ok { 642 presentSelectors[int(asFinal.selector)] = true 643 } 644 } 645 for _, flag := range presentSelectors { 646 if !flag { 647 return false 648 } 649 } 650 return true 651 } 652 653 func (fieldMask *Notification_State_FieldMask) ProtoReflect() preflect.Message { 654 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 655 return ParseNotificationState_FieldPath(raw) 656 }) 657 } 658 659 func (fieldMask *Notification_State_FieldMask) ProtoMessage() {} 660 661 func (fieldMask *Notification_State_FieldMask) Reset() { 662 if fieldMask != nil { 663 fieldMask.Paths = nil 664 } 665 } 666 667 func (fieldMask *Notification_State_FieldMask) Subtract(other *Notification_State_FieldMask) *Notification_State_FieldMask { 668 result := &Notification_State_FieldMask{} 669 removedSelectors := make([]bool, 7) 670 otherSubMasks := map[NotificationState_FieldPathSelector]gotenobject.FieldMask{ 671 NotificationState_FieldPathSelectorNotificationState: &Notification_State_NotificationState_FieldMask{}, 672 NotificationState_FieldPathSelectorAlertsLifetime: &common.TimeRange_FieldMask{}, 673 NotificationState_FieldPathSelectorResolutionNotificationState: &Notification_State_NotificationState_FieldMask{}, 674 } 675 mySubMasks := map[NotificationState_FieldPathSelector]gotenobject.FieldMask{ 676 NotificationState_FieldPathSelectorNotificationState: &Notification_State_NotificationState_FieldMask{}, 677 NotificationState_FieldPathSelectorAlertsLifetime: &common.TimeRange_FieldMask{}, 678 NotificationState_FieldPathSelectorResolutionNotificationState: &Notification_State_NotificationState_FieldMask{}, 679 } 680 681 for _, path := range other.GetPaths() { 682 switch tp := path.(type) { 683 case *NotificationState_FieldTerminalPath: 684 removedSelectors[int(tp.selector)] = true 685 case *NotificationState_FieldSubPath: 686 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 687 } 688 } 689 for _, path := range fieldMask.GetPaths() { 690 if !removedSelectors[int(path.Selector())] { 691 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 692 if tp, ok := path.(*NotificationState_FieldTerminalPath); ok { 693 switch tp.selector { 694 case NotificationState_FieldPathSelectorNotificationState: 695 mySubMasks[NotificationState_FieldPathSelectorNotificationState] = FullNotification_State_NotificationState_FieldMask() 696 case NotificationState_FieldPathSelectorAlertsLifetime: 697 mySubMasks[NotificationState_FieldPathSelectorAlertsLifetime] = common.FullTimeRange_FieldMask() 698 case NotificationState_FieldPathSelectorResolutionNotificationState: 699 mySubMasks[NotificationState_FieldPathSelectorResolutionNotificationState] = FullNotification_State_NotificationState_FieldMask() 700 } 701 } else if tp, ok := path.(*NotificationState_FieldSubPath); ok { 702 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 703 } 704 } else { 705 result.Paths = append(result.Paths, path) 706 } 707 } 708 } 709 for selector, mySubMask := range mySubMasks { 710 if mySubMask.PathsCount() > 0 { 711 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 712 result.Paths = append(result.Paths, &NotificationState_FieldSubPath{selector: selector, subPath: allowedPath}) 713 } 714 } 715 } 716 717 if len(result.Paths) == 0 { 718 return nil 719 } 720 return result 721 } 722 723 func (fieldMask *Notification_State_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 724 return fieldMask.Subtract(other.(*Notification_State_FieldMask)) 725 } 726 727 // FilterInputFields generates copy of field paths with output_only field paths removed 728 func (fieldMask *Notification_State_FieldMask) FilterInputFields() *Notification_State_FieldMask { 729 result := &Notification_State_FieldMask{} 730 result.Paths = append(result.Paths, fieldMask.Paths...) 731 return result 732 } 733 734 // ToFieldMask is used for proto conversions 735 func (fieldMask *Notification_State_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 736 protoFieldMask := &googlefieldmaskpb.FieldMask{} 737 for _, path := range fieldMask.Paths { 738 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 739 } 740 return protoFieldMask 741 } 742 743 func (fieldMask *Notification_State_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 744 if fieldMask == nil { 745 return status.Error(codes.Internal, "target field mask is nil") 746 } 747 fieldMask.Paths = make([]NotificationState_FieldPath, 0, len(protoFieldMask.Paths)) 748 for _, strPath := range protoFieldMask.Paths { 749 path, err := ParseNotificationState_FieldPath(strPath) 750 if err != nil { 751 return err 752 } 753 fieldMask.Paths = append(fieldMask.Paths, path) 754 } 755 return nil 756 } 757 758 // implement methods required by customType 759 func (fieldMask Notification_State_FieldMask) Marshal() ([]byte, error) { 760 protoFieldMask := fieldMask.ToProtoFieldMask() 761 return proto.Marshal(protoFieldMask) 762 } 763 764 func (fieldMask *Notification_State_FieldMask) Unmarshal(data []byte) error { 765 protoFieldMask := &googlefieldmaskpb.FieldMask{} 766 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 767 return err 768 } 769 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 770 return err 771 } 772 return nil 773 } 774 775 func (fieldMask *Notification_State_FieldMask) Size() int { 776 return proto.Size(fieldMask.ToProtoFieldMask()) 777 } 778 779 func (fieldMask Notification_State_FieldMask) MarshalJSON() ([]byte, error) { 780 return json.Marshal(fieldMask.ToProtoFieldMask()) 781 } 782 783 func (fieldMask *Notification_State_FieldMask) UnmarshalJSON(data []byte) error { 784 protoFieldMask := &googlefieldmaskpb.FieldMask{} 785 if err := json.Unmarshal(data, protoFieldMask); err != nil { 786 return err 787 } 788 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 789 return err 790 } 791 return nil 792 } 793 794 func (fieldMask *Notification_State_FieldMask) AppendPath(path NotificationState_FieldPath) { 795 fieldMask.Paths = append(fieldMask.Paths, path) 796 } 797 798 func (fieldMask *Notification_State_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 799 fieldMask.Paths = append(fieldMask.Paths, path.(NotificationState_FieldPath)) 800 } 801 802 func (fieldMask *Notification_State_FieldMask) GetPaths() []NotificationState_FieldPath { 803 if fieldMask == nil { 804 return nil 805 } 806 return fieldMask.Paths 807 } 808 809 func (fieldMask *Notification_State_FieldMask) GetRawPaths() []gotenobject.FieldPath { 810 if fieldMask == nil { 811 return nil 812 } 813 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 814 for _, path := range fieldMask.Paths { 815 rawPaths = append(rawPaths, path) 816 } 817 return rawPaths 818 } 819 820 func (fieldMask *Notification_State_FieldMask) SetFromCliFlag(raw string) error { 821 path, err := ParseNotificationState_FieldPath(raw) 822 if err != nil { 823 return err 824 } 825 fieldMask.Paths = append(fieldMask.Paths, path) 826 return nil 827 } 828 829 func (fieldMask *Notification_State_FieldMask) Set(target, source *Notification_State) { 830 for _, path := range fieldMask.Paths { 831 val, _ := path.GetSingle(source) 832 // if val is nil, then field does not exist in source, skip 833 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 834 if val != nil { 835 path.WithIValue(val).SetTo(&target) 836 } 837 } 838 } 839 840 func (fieldMask *Notification_State_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 841 fieldMask.Set(target.(*Notification_State), source.(*Notification_State)) 842 } 843 844 func (fieldMask *Notification_State_FieldMask) Project(source *Notification_State) *Notification_State { 845 if source == nil { 846 return nil 847 } 848 if fieldMask == nil { 849 return source 850 } 851 result := &Notification_State{} 852 notificationStateMask := &Notification_State_NotificationState_FieldMask{} 853 wholeNotificationStateAccepted := false 854 alertsLifetimeMask := &common.TimeRange_FieldMask{} 855 wholeAlertsLifetimeAccepted := false 856 resolutionNotificationStateMask := &Notification_State_NotificationState_FieldMask{} 857 wholeResolutionNotificationStateAccepted := false 858 859 for _, p := range fieldMask.Paths { 860 switch tp := p.(type) { 861 case *NotificationState_FieldTerminalPath: 862 switch tp.selector { 863 case NotificationState_FieldPathSelectorIsResolved: 864 result.IsResolved = source.IsResolved 865 case NotificationState_FieldPathSelectorNotificationState: 866 result.NotificationState = source.NotificationState 867 wholeNotificationStateAccepted = true 868 case NotificationState_FieldPathSelectorIncidentNotifyAttemptsDone: 869 result.IncidentNotifyAttemptsDone = source.IncidentNotifyAttemptsDone 870 case NotificationState_FieldPathSelectorResolutionNotifyAttemptsDone: 871 result.ResolutionNotifyAttemptsDone = source.ResolutionNotifyAttemptsDone 872 case NotificationState_FieldPathSelectorAlertsLifetime: 873 result.AlertsLifetime = source.AlertsLifetime 874 wholeAlertsLifetimeAccepted = true 875 case NotificationState_FieldPathSelectorResolutionNotificationState: 876 result.ResolutionNotificationState = source.ResolutionNotificationState 877 wholeResolutionNotificationStateAccepted = true 878 case NotificationState_FieldPathSelectorLifecycleCompleted: 879 result.LifecycleCompleted = source.LifecycleCompleted 880 } 881 case *NotificationState_FieldSubPath: 882 switch tp.selector { 883 case NotificationState_FieldPathSelectorNotificationState: 884 notificationStateMask.AppendPath(tp.subPath.(NotificationStateNotificationState_FieldPath)) 885 case NotificationState_FieldPathSelectorAlertsLifetime: 886 alertsLifetimeMask.AppendPath(tp.subPath.(common.TimeRange_FieldPath)) 887 case NotificationState_FieldPathSelectorResolutionNotificationState: 888 resolutionNotificationStateMask.AppendPath(tp.subPath.(NotificationStateNotificationState_FieldPath)) 889 } 890 } 891 } 892 if wholeNotificationStateAccepted == false && len(notificationStateMask.Paths) > 0 { 893 for _, sourceItem := range source.GetNotificationState() { 894 result.NotificationState = append(result.NotificationState, notificationStateMask.Project(sourceItem)) 895 } 896 } 897 if wholeAlertsLifetimeAccepted == false && len(alertsLifetimeMask.Paths) > 0 { 898 result.AlertsLifetime = alertsLifetimeMask.Project(source.GetAlertsLifetime()) 899 } 900 if wholeResolutionNotificationStateAccepted == false && len(resolutionNotificationStateMask.Paths) > 0 { 901 for _, sourceItem := range source.GetResolutionNotificationState() { 902 result.ResolutionNotificationState = append(result.ResolutionNotificationState, resolutionNotificationStateMask.Project(sourceItem)) 903 } 904 } 905 return result 906 } 907 908 func (fieldMask *Notification_State_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 909 return fieldMask.Project(source.(*Notification_State)) 910 } 911 912 func (fieldMask *Notification_State_FieldMask) PathsCount() int { 913 if fieldMask == nil { 914 return 0 915 } 916 return len(fieldMask.Paths) 917 } 918 919 type Notification_State_NotificationState_FieldMask struct { 920 Paths []NotificationStateNotificationState_FieldPath 921 } 922 923 func FullNotification_State_NotificationState_FieldMask() *Notification_State_NotificationState_FieldMask { 924 res := &Notification_State_NotificationState_FieldMask{} 925 res.Paths = append(res.Paths, &NotificationStateNotificationState_FieldTerminalPath{selector: NotificationStateNotificationState_FieldPathSelectorNotificationChannel}) 926 res.Paths = append(res.Paths, &NotificationStateNotificationState_FieldTerminalPath{selector: NotificationStateNotificationState_FieldPathSelectorStatus}) 927 res.Paths = append(res.Paths, &NotificationStateNotificationState_FieldTerminalPath{selector: NotificationStateNotificationState_FieldPathSelectorError}) 928 res.Paths = append(res.Paths, &NotificationStateNotificationState_FieldTerminalPath{selector: NotificationStateNotificationState_FieldPathSelectorProviderData}) 929 res.Paths = append(res.Paths, &NotificationStateNotificationState_FieldTerminalPath{selector: NotificationStateNotificationState_FieldPathSelectorNotifyAttempts}) 930 return res 931 } 932 933 func (fieldMask *Notification_State_NotificationState_FieldMask) String() string { 934 if fieldMask == nil { 935 return "<nil>" 936 } 937 pathsStr := make([]string, 0, len(fieldMask.Paths)) 938 for _, path := range fieldMask.Paths { 939 pathsStr = append(pathsStr, path.String()) 940 } 941 return strings.Join(pathsStr, ", ") 942 } 943 944 func (fieldMask *Notification_State_NotificationState_FieldMask) IsFull() bool { 945 if fieldMask == nil { 946 return false 947 } 948 presentSelectors := make([]bool, 5) 949 for _, path := range fieldMask.Paths { 950 if asFinal, ok := path.(*NotificationStateNotificationState_FieldTerminalPath); ok { 951 presentSelectors[int(asFinal.selector)] = true 952 } 953 } 954 for _, flag := range presentSelectors { 955 if !flag { 956 return false 957 } 958 } 959 return true 960 } 961 962 func (fieldMask *Notification_State_NotificationState_FieldMask) ProtoReflect() preflect.Message { 963 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 964 return ParseNotificationStateNotificationState_FieldPath(raw) 965 }) 966 } 967 968 func (fieldMask *Notification_State_NotificationState_FieldMask) ProtoMessage() {} 969 970 func (fieldMask *Notification_State_NotificationState_FieldMask) Reset() { 971 if fieldMask != nil { 972 fieldMask.Paths = nil 973 } 974 } 975 976 func (fieldMask *Notification_State_NotificationState_FieldMask) Subtract(other *Notification_State_NotificationState_FieldMask) *Notification_State_NotificationState_FieldMask { 977 result := &Notification_State_NotificationState_FieldMask{} 978 removedSelectors := make([]bool, 5) 979 otherSubMasks := map[NotificationStateNotificationState_FieldPathSelector]gotenobject.FieldMask{ 980 NotificationStateNotificationState_FieldPathSelectorProviderData: &Notification_State_NotificationState_ProviderData_FieldMask{}, 981 } 982 mySubMasks := map[NotificationStateNotificationState_FieldPathSelector]gotenobject.FieldMask{ 983 NotificationStateNotificationState_FieldPathSelectorProviderData: &Notification_State_NotificationState_ProviderData_FieldMask{}, 984 } 985 986 for _, path := range other.GetPaths() { 987 switch tp := path.(type) { 988 case *NotificationStateNotificationState_FieldTerminalPath: 989 removedSelectors[int(tp.selector)] = true 990 case *NotificationStateNotificationState_FieldSubPath: 991 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 992 } 993 } 994 for _, path := range fieldMask.GetPaths() { 995 if !removedSelectors[int(path.Selector())] { 996 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 997 if tp, ok := path.(*NotificationStateNotificationState_FieldTerminalPath); ok { 998 switch tp.selector { 999 case NotificationStateNotificationState_FieldPathSelectorProviderData: 1000 mySubMasks[NotificationStateNotificationState_FieldPathSelectorProviderData] = FullNotification_State_NotificationState_ProviderData_FieldMask() 1001 } 1002 } else if tp, ok := path.(*NotificationStateNotificationState_FieldSubPath); ok { 1003 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 1004 } 1005 } else { 1006 result.Paths = append(result.Paths, path) 1007 } 1008 } 1009 } 1010 for selector, mySubMask := range mySubMasks { 1011 if mySubMask.PathsCount() > 0 { 1012 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 1013 result.Paths = append(result.Paths, &NotificationStateNotificationState_FieldSubPath{selector: selector, subPath: allowedPath}) 1014 } 1015 } 1016 } 1017 1018 if len(result.Paths) == 0 { 1019 return nil 1020 } 1021 return result 1022 } 1023 1024 func (fieldMask *Notification_State_NotificationState_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 1025 return fieldMask.Subtract(other.(*Notification_State_NotificationState_FieldMask)) 1026 } 1027 1028 // FilterInputFields generates copy of field paths with output_only field paths removed 1029 func (fieldMask *Notification_State_NotificationState_FieldMask) FilterInputFields() *Notification_State_NotificationState_FieldMask { 1030 result := &Notification_State_NotificationState_FieldMask{} 1031 result.Paths = append(result.Paths, fieldMask.Paths...) 1032 return result 1033 } 1034 1035 // ToFieldMask is used for proto conversions 1036 func (fieldMask *Notification_State_NotificationState_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 1037 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1038 for _, path := range fieldMask.Paths { 1039 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 1040 } 1041 return protoFieldMask 1042 } 1043 1044 func (fieldMask *Notification_State_NotificationState_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 1045 if fieldMask == nil { 1046 return status.Error(codes.Internal, "target field mask is nil") 1047 } 1048 fieldMask.Paths = make([]NotificationStateNotificationState_FieldPath, 0, len(protoFieldMask.Paths)) 1049 for _, strPath := range protoFieldMask.Paths { 1050 path, err := ParseNotificationStateNotificationState_FieldPath(strPath) 1051 if err != nil { 1052 return err 1053 } 1054 fieldMask.Paths = append(fieldMask.Paths, path) 1055 } 1056 return nil 1057 } 1058 1059 // implement methods required by customType 1060 func (fieldMask Notification_State_NotificationState_FieldMask) Marshal() ([]byte, error) { 1061 protoFieldMask := fieldMask.ToProtoFieldMask() 1062 return proto.Marshal(protoFieldMask) 1063 } 1064 1065 func (fieldMask *Notification_State_NotificationState_FieldMask) Unmarshal(data []byte) error { 1066 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1067 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 1068 return err 1069 } 1070 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1071 return err 1072 } 1073 return nil 1074 } 1075 1076 func (fieldMask *Notification_State_NotificationState_FieldMask) Size() int { 1077 return proto.Size(fieldMask.ToProtoFieldMask()) 1078 } 1079 1080 func (fieldMask Notification_State_NotificationState_FieldMask) MarshalJSON() ([]byte, error) { 1081 return json.Marshal(fieldMask.ToProtoFieldMask()) 1082 } 1083 1084 func (fieldMask *Notification_State_NotificationState_FieldMask) UnmarshalJSON(data []byte) error { 1085 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1086 if err := json.Unmarshal(data, protoFieldMask); err != nil { 1087 return err 1088 } 1089 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1090 return err 1091 } 1092 return nil 1093 } 1094 1095 func (fieldMask *Notification_State_NotificationState_FieldMask) AppendPath(path NotificationStateNotificationState_FieldPath) { 1096 fieldMask.Paths = append(fieldMask.Paths, path) 1097 } 1098 1099 func (fieldMask *Notification_State_NotificationState_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 1100 fieldMask.Paths = append(fieldMask.Paths, path.(NotificationStateNotificationState_FieldPath)) 1101 } 1102 1103 func (fieldMask *Notification_State_NotificationState_FieldMask) GetPaths() []NotificationStateNotificationState_FieldPath { 1104 if fieldMask == nil { 1105 return nil 1106 } 1107 return fieldMask.Paths 1108 } 1109 1110 func (fieldMask *Notification_State_NotificationState_FieldMask) GetRawPaths() []gotenobject.FieldPath { 1111 if fieldMask == nil { 1112 return nil 1113 } 1114 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 1115 for _, path := range fieldMask.Paths { 1116 rawPaths = append(rawPaths, path) 1117 } 1118 return rawPaths 1119 } 1120 1121 func (fieldMask *Notification_State_NotificationState_FieldMask) SetFromCliFlag(raw string) error { 1122 path, err := ParseNotificationStateNotificationState_FieldPath(raw) 1123 if err != nil { 1124 return err 1125 } 1126 fieldMask.Paths = append(fieldMask.Paths, path) 1127 return nil 1128 } 1129 1130 func (fieldMask *Notification_State_NotificationState_FieldMask) Set(target, source *Notification_State_NotificationState) { 1131 for _, path := range fieldMask.Paths { 1132 val, _ := path.GetSingle(source) 1133 // if val is nil, then field does not exist in source, skip 1134 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 1135 if val != nil { 1136 path.WithIValue(val).SetTo(&target) 1137 } 1138 } 1139 } 1140 1141 func (fieldMask *Notification_State_NotificationState_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 1142 fieldMask.Set(target.(*Notification_State_NotificationState), source.(*Notification_State_NotificationState)) 1143 } 1144 1145 func (fieldMask *Notification_State_NotificationState_FieldMask) Project(source *Notification_State_NotificationState) *Notification_State_NotificationState { 1146 if source == nil { 1147 return nil 1148 } 1149 if fieldMask == nil { 1150 return source 1151 } 1152 result := &Notification_State_NotificationState{} 1153 providerDataMask := &Notification_State_NotificationState_ProviderData_FieldMask{} 1154 wholeProviderDataAccepted := false 1155 1156 for _, p := range fieldMask.Paths { 1157 switch tp := p.(type) { 1158 case *NotificationStateNotificationState_FieldTerminalPath: 1159 switch tp.selector { 1160 case NotificationStateNotificationState_FieldPathSelectorNotificationChannel: 1161 result.NotificationChannel = source.NotificationChannel 1162 case NotificationStateNotificationState_FieldPathSelectorStatus: 1163 result.Status = source.Status 1164 case NotificationStateNotificationState_FieldPathSelectorError: 1165 result.Error = source.Error 1166 case NotificationStateNotificationState_FieldPathSelectorProviderData: 1167 result.ProviderData = source.ProviderData 1168 wholeProviderDataAccepted = true 1169 case NotificationStateNotificationState_FieldPathSelectorNotifyAttempts: 1170 result.NotifyAttempts = source.NotifyAttempts 1171 } 1172 case *NotificationStateNotificationState_FieldSubPath: 1173 switch tp.selector { 1174 case NotificationStateNotificationState_FieldPathSelectorProviderData: 1175 providerDataMask.AppendPath(tp.subPath.(NotificationStateNotificationStateProviderData_FieldPath)) 1176 } 1177 } 1178 } 1179 if wholeProviderDataAccepted == false && len(providerDataMask.Paths) > 0 { 1180 result.ProviderData = providerDataMask.Project(source.GetProviderData()) 1181 } 1182 return result 1183 } 1184 1185 func (fieldMask *Notification_State_NotificationState_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 1186 return fieldMask.Project(source.(*Notification_State_NotificationState)) 1187 } 1188 1189 func (fieldMask *Notification_State_NotificationState_FieldMask) PathsCount() int { 1190 if fieldMask == nil { 1191 return 0 1192 } 1193 return len(fieldMask.Paths) 1194 } 1195 1196 type Notification_State_NotificationState_ProviderData_FieldMask struct { 1197 Paths []NotificationStateNotificationStateProviderData_FieldPath 1198 } 1199 1200 func FullNotification_State_NotificationState_ProviderData_FieldMask() *Notification_State_NotificationState_ProviderData_FieldMask { 1201 res := &Notification_State_NotificationState_ProviderData_FieldMask{} 1202 res.Paths = append(res.Paths, &NotificationStateNotificationStateProviderData_FieldTerminalPath{selector: NotificationStateNotificationStateProviderData_FieldPathSelectorSlack}) 1203 res.Paths = append(res.Paths, &NotificationStateNotificationStateProviderData_FieldTerminalPath{selector: NotificationStateNotificationStateProviderData_FieldPathSelectorPagerDuty}) 1204 res.Paths = append(res.Paths, &NotificationStateNotificationStateProviderData_FieldTerminalPath{selector: NotificationStateNotificationStateProviderData_FieldPathSelectorWebhook}) 1205 return res 1206 } 1207 1208 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) String() string { 1209 if fieldMask == nil { 1210 return "<nil>" 1211 } 1212 pathsStr := make([]string, 0, len(fieldMask.Paths)) 1213 for _, path := range fieldMask.Paths { 1214 pathsStr = append(pathsStr, path.String()) 1215 } 1216 return strings.Join(pathsStr, ", ") 1217 } 1218 1219 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) IsFull() bool { 1220 if fieldMask == nil { 1221 return false 1222 } 1223 presentSelectors := make([]bool, 3) 1224 for _, path := range fieldMask.Paths { 1225 if asFinal, ok := path.(*NotificationStateNotificationStateProviderData_FieldTerminalPath); ok { 1226 presentSelectors[int(asFinal.selector)] = true 1227 } 1228 } 1229 for _, flag := range presentSelectors { 1230 if !flag { 1231 return false 1232 } 1233 } 1234 return true 1235 } 1236 1237 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) ProtoReflect() preflect.Message { 1238 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 1239 return ParseNotificationStateNotificationStateProviderData_FieldPath(raw) 1240 }) 1241 } 1242 1243 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) ProtoMessage() {} 1244 1245 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) Reset() { 1246 if fieldMask != nil { 1247 fieldMask.Paths = nil 1248 } 1249 } 1250 1251 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) Subtract(other *Notification_State_NotificationState_ProviderData_FieldMask) *Notification_State_NotificationState_ProviderData_FieldMask { 1252 result := &Notification_State_NotificationState_ProviderData_FieldMask{} 1253 removedSelectors := make([]bool, 3) 1254 otherSubMasks := map[NotificationStateNotificationStateProviderData_FieldPathSelector]gotenobject.FieldMask{ 1255 NotificationStateNotificationStateProviderData_FieldPathSelectorSlack: &Notification_State_NotificationState_ProviderData_Slack_FieldMask{}, 1256 NotificationStateNotificationStateProviderData_FieldPathSelectorPagerDuty: &Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask{}, 1257 NotificationStateNotificationStateProviderData_FieldPathSelectorWebhook: &Notification_State_NotificationState_ProviderData_WebHook_FieldMask{}, 1258 } 1259 mySubMasks := map[NotificationStateNotificationStateProviderData_FieldPathSelector]gotenobject.FieldMask{ 1260 NotificationStateNotificationStateProviderData_FieldPathSelectorSlack: &Notification_State_NotificationState_ProviderData_Slack_FieldMask{}, 1261 NotificationStateNotificationStateProviderData_FieldPathSelectorPagerDuty: &Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask{}, 1262 NotificationStateNotificationStateProviderData_FieldPathSelectorWebhook: &Notification_State_NotificationState_ProviderData_WebHook_FieldMask{}, 1263 } 1264 1265 for _, path := range other.GetPaths() { 1266 switch tp := path.(type) { 1267 case *NotificationStateNotificationStateProviderData_FieldTerminalPath: 1268 removedSelectors[int(tp.selector)] = true 1269 case *NotificationStateNotificationStateProviderData_FieldSubPath: 1270 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 1271 } 1272 } 1273 for _, path := range fieldMask.GetPaths() { 1274 if !removedSelectors[int(path.Selector())] { 1275 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 1276 if tp, ok := path.(*NotificationStateNotificationStateProviderData_FieldTerminalPath); ok { 1277 switch tp.selector { 1278 case NotificationStateNotificationStateProviderData_FieldPathSelectorSlack: 1279 mySubMasks[NotificationStateNotificationStateProviderData_FieldPathSelectorSlack] = FullNotification_State_NotificationState_ProviderData_Slack_FieldMask() 1280 case NotificationStateNotificationStateProviderData_FieldPathSelectorPagerDuty: 1281 mySubMasks[NotificationStateNotificationStateProviderData_FieldPathSelectorPagerDuty] = FullNotification_State_NotificationState_ProviderData_PagerDuty_FieldMask() 1282 case NotificationStateNotificationStateProviderData_FieldPathSelectorWebhook: 1283 mySubMasks[NotificationStateNotificationStateProviderData_FieldPathSelectorWebhook] = FullNotification_State_NotificationState_ProviderData_WebHook_FieldMask() 1284 } 1285 } else if tp, ok := path.(*NotificationStateNotificationStateProviderData_FieldSubPath); ok { 1286 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 1287 } 1288 } else { 1289 result.Paths = append(result.Paths, path) 1290 } 1291 } 1292 } 1293 for selector, mySubMask := range mySubMasks { 1294 if mySubMask.PathsCount() > 0 { 1295 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 1296 result.Paths = append(result.Paths, &NotificationStateNotificationStateProviderData_FieldSubPath{selector: selector, subPath: allowedPath}) 1297 } 1298 } 1299 } 1300 1301 if len(result.Paths) == 0 { 1302 return nil 1303 } 1304 return result 1305 } 1306 1307 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 1308 return fieldMask.Subtract(other.(*Notification_State_NotificationState_ProviderData_FieldMask)) 1309 } 1310 1311 // FilterInputFields generates copy of field paths with output_only field paths removed 1312 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) FilterInputFields() *Notification_State_NotificationState_ProviderData_FieldMask { 1313 result := &Notification_State_NotificationState_ProviderData_FieldMask{} 1314 result.Paths = append(result.Paths, fieldMask.Paths...) 1315 return result 1316 } 1317 1318 // ToFieldMask is used for proto conversions 1319 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 1320 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1321 for _, path := range fieldMask.Paths { 1322 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 1323 } 1324 return protoFieldMask 1325 } 1326 1327 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 1328 if fieldMask == nil { 1329 return status.Error(codes.Internal, "target field mask is nil") 1330 } 1331 fieldMask.Paths = make([]NotificationStateNotificationStateProviderData_FieldPath, 0, len(protoFieldMask.Paths)) 1332 for _, strPath := range protoFieldMask.Paths { 1333 path, err := ParseNotificationStateNotificationStateProviderData_FieldPath(strPath) 1334 if err != nil { 1335 return err 1336 } 1337 fieldMask.Paths = append(fieldMask.Paths, path) 1338 } 1339 return nil 1340 } 1341 1342 // implement methods required by customType 1343 func (fieldMask Notification_State_NotificationState_ProviderData_FieldMask) Marshal() ([]byte, error) { 1344 protoFieldMask := fieldMask.ToProtoFieldMask() 1345 return proto.Marshal(protoFieldMask) 1346 } 1347 1348 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) Unmarshal(data []byte) error { 1349 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1350 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 1351 return err 1352 } 1353 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1354 return err 1355 } 1356 return nil 1357 } 1358 1359 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) Size() int { 1360 return proto.Size(fieldMask.ToProtoFieldMask()) 1361 } 1362 1363 func (fieldMask Notification_State_NotificationState_ProviderData_FieldMask) MarshalJSON() ([]byte, error) { 1364 return json.Marshal(fieldMask.ToProtoFieldMask()) 1365 } 1366 1367 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) UnmarshalJSON(data []byte) error { 1368 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1369 if err := json.Unmarshal(data, protoFieldMask); err != nil { 1370 return err 1371 } 1372 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1373 return err 1374 } 1375 return nil 1376 } 1377 1378 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) AppendPath(path NotificationStateNotificationStateProviderData_FieldPath) { 1379 fieldMask.Paths = append(fieldMask.Paths, path) 1380 } 1381 1382 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 1383 fieldMask.Paths = append(fieldMask.Paths, path.(NotificationStateNotificationStateProviderData_FieldPath)) 1384 } 1385 1386 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) GetPaths() []NotificationStateNotificationStateProviderData_FieldPath { 1387 if fieldMask == nil { 1388 return nil 1389 } 1390 return fieldMask.Paths 1391 } 1392 1393 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) GetRawPaths() []gotenobject.FieldPath { 1394 if fieldMask == nil { 1395 return nil 1396 } 1397 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 1398 for _, path := range fieldMask.Paths { 1399 rawPaths = append(rawPaths, path) 1400 } 1401 return rawPaths 1402 } 1403 1404 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) SetFromCliFlag(raw string) error { 1405 path, err := ParseNotificationStateNotificationStateProviderData_FieldPath(raw) 1406 if err != nil { 1407 return err 1408 } 1409 fieldMask.Paths = append(fieldMask.Paths, path) 1410 return nil 1411 } 1412 1413 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) Set(target, source *Notification_State_NotificationState_ProviderData) { 1414 for _, path := range fieldMask.Paths { 1415 val, _ := path.GetSingle(source) 1416 // if val is nil, then field does not exist in source, skip 1417 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 1418 if val != nil { 1419 path.WithIValue(val).SetTo(&target) 1420 } 1421 } 1422 } 1423 1424 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 1425 fieldMask.Set(target.(*Notification_State_NotificationState_ProviderData), source.(*Notification_State_NotificationState_ProviderData)) 1426 } 1427 1428 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) Project(source *Notification_State_NotificationState_ProviderData) *Notification_State_NotificationState_ProviderData { 1429 if source == nil { 1430 return nil 1431 } 1432 if fieldMask == nil { 1433 return source 1434 } 1435 result := &Notification_State_NotificationState_ProviderData{} 1436 slackMask := &Notification_State_NotificationState_ProviderData_Slack_FieldMask{} 1437 wholeSlackAccepted := false 1438 pagerDutyMask := &Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask{} 1439 wholePagerDutyAccepted := false 1440 webhookMask := &Notification_State_NotificationState_ProviderData_WebHook_FieldMask{} 1441 wholeWebhookAccepted := false 1442 1443 for _, p := range fieldMask.Paths { 1444 switch tp := p.(type) { 1445 case *NotificationStateNotificationStateProviderData_FieldTerminalPath: 1446 switch tp.selector { 1447 case NotificationStateNotificationStateProviderData_FieldPathSelectorSlack: 1448 result.Slack = source.Slack 1449 wholeSlackAccepted = true 1450 case NotificationStateNotificationStateProviderData_FieldPathSelectorPagerDuty: 1451 result.PagerDuty = source.PagerDuty 1452 wholePagerDutyAccepted = true 1453 case NotificationStateNotificationStateProviderData_FieldPathSelectorWebhook: 1454 result.Webhook = source.Webhook 1455 wholeWebhookAccepted = true 1456 } 1457 case *NotificationStateNotificationStateProviderData_FieldSubPath: 1458 switch tp.selector { 1459 case NotificationStateNotificationStateProviderData_FieldPathSelectorSlack: 1460 slackMask.AppendPath(tp.subPath.(NotificationStateNotificationStateProviderDataSlack_FieldPath)) 1461 case NotificationStateNotificationStateProviderData_FieldPathSelectorPagerDuty: 1462 pagerDutyMask.AppendPath(tp.subPath.(NotificationStateNotificationStateProviderDataPagerDuty_FieldPath)) 1463 case NotificationStateNotificationStateProviderData_FieldPathSelectorWebhook: 1464 webhookMask.AppendPath(tp.subPath.(NotificationStateNotificationStateProviderDataWebHook_FieldPath)) 1465 } 1466 } 1467 } 1468 if wholeSlackAccepted == false && len(slackMask.Paths) > 0 { 1469 result.Slack = slackMask.Project(source.GetSlack()) 1470 } 1471 if wholePagerDutyAccepted == false && len(pagerDutyMask.Paths) > 0 { 1472 result.PagerDuty = pagerDutyMask.Project(source.GetPagerDuty()) 1473 } 1474 if wholeWebhookAccepted == false && len(webhookMask.Paths) > 0 { 1475 result.Webhook = webhookMask.Project(source.GetWebhook()) 1476 } 1477 return result 1478 } 1479 1480 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 1481 return fieldMask.Project(source.(*Notification_State_NotificationState_ProviderData)) 1482 } 1483 1484 func (fieldMask *Notification_State_NotificationState_ProviderData_FieldMask) PathsCount() int { 1485 if fieldMask == nil { 1486 return 0 1487 } 1488 return len(fieldMask.Paths) 1489 } 1490 1491 type Notification_State_NotificationState_ProviderData_Slack_FieldMask struct { 1492 Paths []NotificationStateNotificationStateProviderDataSlack_FieldPath 1493 } 1494 1495 func FullNotification_State_NotificationState_ProviderData_Slack_FieldMask() *Notification_State_NotificationState_ProviderData_Slack_FieldMask { 1496 res := &Notification_State_NotificationState_ProviderData_Slack_FieldMask{} 1497 res.Paths = append(res.Paths, &NotificationStateNotificationStateProviderDataSlack_FieldTerminalPath{selector: NotificationStateNotificationStateProviderDataSlack_FieldPathSelectorTs}) 1498 return res 1499 } 1500 1501 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) String() string { 1502 if fieldMask == nil { 1503 return "<nil>" 1504 } 1505 pathsStr := make([]string, 0, len(fieldMask.Paths)) 1506 for _, path := range fieldMask.Paths { 1507 pathsStr = append(pathsStr, path.String()) 1508 } 1509 return strings.Join(pathsStr, ", ") 1510 } 1511 1512 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) IsFull() bool { 1513 if fieldMask == nil { 1514 return false 1515 } 1516 presentSelectors := make([]bool, 1) 1517 for _, path := range fieldMask.Paths { 1518 if asFinal, ok := path.(*NotificationStateNotificationStateProviderDataSlack_FieldTerminalPath); ok { 1519 presentSelectors[int(asFinal.selector)] = true 1520 } 1521 } 1522 for _, flag := range presentSelectors { 1523 if !flag { 1524 return false 1525 } 1526 } 1527 return true 1528 } 1529 1530 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) ProtoReflect() preflect.Message { 1531 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 1532 return ParseNotificationStateNotificationStateProviderDataSlack_FieldPath(raw) 1533 }) 1534 } 1535 1536 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) ProtoMessage() {} 1537 1538 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) Reset() { 1539 if fieldMask != nil { 1540 fieldMask.Paths = nil 1541 } 1542 } 1543 1544 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) Subtract(other *Notification_State_NotificationState_ProviderData_Slack_FieldMask) *Notification_State_NotificationState_ProviderData_Slack_FieldMask { 1545 result := &Notification_State_NotificationState_ProviderData_Slack_FieldMask{} 1546 removedSelectors := make([]bool, 1) 1547 1548 for _, path := range other.GetPaths() { 1549 switch tp := path.(type) { 1550 case *NotificationStateNotificationStateProviderDataSlack_FieldTerminalPath: 1551 removedSelectors[int(tp.selector)] = true 1552 } 1553 } 1554 for _, path := range fieldMask.GetPaths() { 1555 if !removedSelectors[int(path.Selector())] { 1556 result.Paths = append(result.Paths, path) 1557 } 1558 } 1559 1560 if len(result.Paths) == 0 { 1561 return nil 1562 } 1563 return result 1564 } 1565 1566 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 1567 return fieldMask.Subtract(other.(*Notification_State_NotificationState_ProviderData_Slack_FieldMask)) 1568 } 1569 1570 // FilterInputFields generates copy of field paths with output_only field paths removed 1571 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) FilterInputFields() *Notification_State_NotificationState_ProviderData_Slack_FieldMask { 1572 result := &Notification_State_NotificationState_ProviderData_Slack_FieldMask{} 1573 result.Paths = append(result.Paths, fieldMask.Paths...) 1574 return result 1575 } 1576 1577 // ToFieldMask is used for proto conversions 1578 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 1579 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1580 for _, path := range fieldMask.Paths { 1581 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 1582 } 1583 return protoFieldMask 1584 } 1585 1586 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 1587 if fieldMask == nil { 1588 return status.Error(codes.Internal, "target field mask is nil") 1589 } 1590 fieldMask.Paths = make([]NotificationStateNotificationStateProviderDataSlack_FieldPath, 0, len(protoFieldMask.Paths)) 1591 for _, strPath := range protoFieldMask.Paths { 1592 path, err := ParseNotificationStateNotificationStateProviderDataSlack_FieldPath(strPath) 1593 if err != nil { 1594 return err 1595 } 1596 fieldMask.Paths = append(fieldMask.Paths, path) 1597 } 1598 return nil 1599 } 1600 1601 // implement methods required by customType 1602 func (fieldMask Notification_State_NotificationState_ProviderData_Slack_FieldMask) Marshal() ([]byte, error) { 1603 protoFieldMask := fieldMask.ToProtoFieldMask() 1604 return proto.Marshal(protoFieldMask) 1605 } 1606 1607 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) Unmarshal(data []byte) error { 1608 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1609 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 1610 return err 1611 } 1612 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1613 return err 1614 } 1615 return nil 1616 } 1617 1618 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) Size() int { 1619 return proto.Size(fieldMask.ToProtoFieldMask()) 1620 } 1621 1622 func (fieldMask Notification_State_NotificationState_ProviderData_Slack_FieldMask) MarshalJSON() ([]byte, error) { 1623 return json.Marshal(fieldMask.ToProtoFieldMask()) 1624 } 1625 1626 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) UnmarshalJSON(data []byte) error { 1627 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1628 if err := json.Unmarshal(data, protoFieldMask); err != nil { 1629 return err 1630 } 1631 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1632 return err 1633 } 1634 return nil 1635 } 1636 1637 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) AppendPath(path NotificationStateNotificationStateProviderDataSlack_FieldPath) { 1638 fieldMask.Paths = append(fieldMask.Paths, path) 1639 } 1640 1641 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 1642 fieldMask.Paths = append(fieldMask.Paths, path.(NotificationStateNotificationStateProviderDataSlack_FieldPath)) 1643 } 1644 1645 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) GetPaths() []NotificationStateNotificationStateProviderDataSlack_FieldPath { 1646 if fieldMask == nil { 1647 return nil 1648 } 1649 return fieldMask.Paths 1650 } 1651 1652 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) GetRawPaths() []gotenobject.FieldPath { 1653 if fieldMask == nil { 1654 return nil 1655 } 1656 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 1657 for _, path := range fieldMask.Paths { 1658 rawPaths = append(rawPaths, path) 1659 } 1660 return rawPaths 1661 } 1662 1663 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) SetFromCliFlag(raw string) error { 1664 path, err := ParseNotificationStateNotificationStateProviderDataSlack_FieldPath(raw) 1665 if err != nil { 1666 return err 1667 } 1668 fieldMask.Paths = append(fieldMask.Paths, path) 1669 return nil 1670 } 1671 1672 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) Set(target, source *Notification_State_NotificationState_ProviderData_Slack) { 1673 for _, path := range fieldMask.Paths { 1674 val, _ := path.GetSingle(source) 1675 // if val is nil, then field does not exist in source, skip 1676 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 1677 if val != nil { 1678 path.WithIValue(val).SetTo(&target) 1679 } 1680 } 1681 } 1682 1683 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 1684 fieldMask.Set(target.(*Notification_State_NotificationState_ProviderData_Slack), source.(*Notification_State_NotificationState_ProviderData_Slack)) 1685 } 1686 1687 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) Project(source *Notification_State_NotificationState_ProviderData_Slack) *Notification_State_NotificationState_ProviderData_Slack { 1688 if source == nil { 1689 return nil 1690 } 1691 if fieldMask == nil { 1692 return source 1693 } 1694 result := &Notification_State_NotificationState_ProviderData_Slack{} 1695 1696 for _, p := range fieldMask.Paths { 1697 switch tp := p.(type) { 1698 case *NotificationStateNotificationStateProviderDataSlack_FieldTerminalPath: 1699 switch tp.selector { 1700 case NotificationStateNotificationStateProviderDataSlack_FieldPathSelectorTs: 1701 result.Ts = source.Ts 1702 } 1703 } 1704 } 1705 return result 1706 } 1707 1708 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 1709 return fieldMask.Project(source.(*Notification_State_NotificationState_ProviderData_Slack)) 1710 } 1711 1712 func (fieldMask *Notification_State_NotificationState_ProviderData_Slack_FieldMask) PathsCount() int { 1713 if fieldMask == nil { 1714 return 0 1715 } 1716 return len(fieldMask.Paths) 1717 } 1718 1719 type Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask struct { 1720 Paths []NotificationStateNotificationStateProviderDataPagerDuty_FieldPath 1721 } 1722 1723 func FullNotification_State_NotificationState_ProviderData_PagerDuty_FieldMask() *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask { 1724 res := &Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask{} 1725 res.Paths = append(res.Paths, &NotificationStateNotificationStateProviderDataPagerDuty_FieldTerminalPath{selector: NotificationStateNotificationStateProviderDataPagerDuty_FieldPathSelectorIncidentKey}) 1726 return res 1727 } 1728 1729 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) String() string { 1730 if fieldMask == nil { 1731 return "<nil>" 1732 } 1733 pathsStr := make([]string, 0, len(fieldMask.Paths)) 1734 for _, path := range fieldMask.Paths { 1735 pathsStr = append(pathsStr, path.String()) 1736 } 1737 return strings.Join(pathsStr, ", ") 1738 } 1739 1740 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) IsFull() bool { 1741 if fieldMask == nil { 1742 return false 1743 } 1744 presentSelectors := make([]bool, 1) 1745 for _, path := range fieldMask.Paths { 1746 if asFinal, ok := path.(*NotificationStateNotificationStateProviderDataPagerDuty_FieldTerminalPath); ok { 1747 presentSelectors[int(asFinal.selector)] = true 1748 } 1749 } 1750 for _, flag := range presentSelectors { 1751 if !flag { 1752 return false 1753 } 1754 } 1755 return true 1756 } 1757 1758 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) ProtoReflect() preflect.Message { 1759 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 1760 return ParseNotificationStateNotificationStateProviderDataPagerDuty_FieldPath(raw) 1761 }) 1762 } 1763 1764 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) ProtoMessage() { 1765 } 1766 1767 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) Reset() { 1768 if fieldMask != nil { 1769 fieldMask.Paths = nil 1770 } 1771 } 1772 1773 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) Subtract(other *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask { 1774 result := &Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask{} 1775 removedSelectors := make([]bool, 1) 1776 1777 for _, path := range other.GetPaths() { 1778 switch tp := path.(type) { 1779 case *NotificationStateNotificationStateProviderDataPagerDuty_FieldTerminalPath: 1780 removedSelectors[int(tp.selector)] = true 1781 } 1782 } 1783 for _, path := range fieldMask.GetPaths() { 1784 if !removedSelectors[int(path.Selector())] { 1785 result.Paths = append(result.Paths, path) 1786 } 1787 } 1788 1789 if len(result.Paths) == 0 { 1790 return nil 1791 } 1792 return result 1793 } 1794 1795 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 1796 return fieldMask.Subtract(other.(*Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask)) 1797 } 1798 1799 // FilterInputFields generates copy of field paths with output_only field paths removed 1800 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) FilterInputFields() *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask { 1801 result := &Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask{} 1802 result.Paths = append(result.Paths, fieldMask.Paths...) 1803 return result 1804 } 1805 1806 // ToFieldMask is used for proto conversions 1807 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 1808 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1809 for _, path := range fieldMask.Paths { 1810 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 1811 } 1812 return protoFieldMask 1813 } 1814 1815 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 1816 if fieldMask == nil { 1817 return status.Error(codes.Internal, "target field mask is nil") 1818 } 1819 fieldMask.Paths = make([]NotificationStateNotificationStateProviderDataPagerDuty_FieldPath, 0, len(protoFieldMask.Paths)) 1820 for _, strPath := range protoFieldMask.Paths { 1821 path, err := ParseNotificationStateNotificationStateProviderDataPagerDuty_FieldPath(strPath) 1822 if err != nil { 1823 return err 1824 } 1825 fieldMask.Paths = append(fieldMask.Paths, path) 1826 } 1827 return nil 1828 } 1829 1830 // implement methods required by customType 1831 func (fieldMask Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) Marshal() ([]byte, error) { 1832 protoFieldMask := fieldMask.ToProtoFieldMask() 1833 return proto.Marshal(protoFieldMask) 1834 } 1835 1836 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) Unmarshal(data []byte) error { 1837 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1838 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 1839 return err 1840 } 1841 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1842 return err 1843 } 1844 return nil 1845 } 1846 1847 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) Size() int { 1848 return proto.Size(fieldMask.ToProtoFieldMask()) 1849 } 1850 1851 func (fieldMask Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) MarshalJSON() ([]byte, error) { 1852 return json.Marshal(fieldMask.ToProtoFieldMask()) 1853 } 1854 1855 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) UnmarshalJSON(data []byte) error { 1856 protoFieldMask := &googlefieldmaskpb.FieldMask{} 1857 if err := json.Unmarshal(data, protoFieldMask); err != nil { 1858 return err 1859 } 1860 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 1861 return err 1862 } 1863 return nil 1864 } 1865 1866 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) AppendPath(path NotificationStateNotificationStateProviderDataPagerDuty_FieldPath) { 1867 fieldMask.Paths = append(fieldMask.Paths, path) 1868 } 1869 1870 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 1871 fieldMask.Paths = append(fieldMask.Paths, path.(NotificationStateNotificationStateProviderDataPagerDuty_FieldPath)) 1872 } 1873 1874 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) GetPaths() []NotificationStateNotificationStateProviderDataPagerDuty_FieldPath { 1875 if fieldMask == nil { 1876 return nil 1877 } 1878 return fieldMask.Paths 1879 } 1880 1881 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) GetRawPaths() []gotenobject.FieldPath { 1882 if fieldMask == nil { 1883 return nil 1884 } 1885 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 1886 for _, path := range fieldMask.Paths { 1887 rawPaths = append(rawPaths, path) 1888 } 1889 return rawPaths 1890 } 1891 1892 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) SetFromCliFlag(raw string) error { 1893 path, err := ParseNotificationStateNotificationStateProviderDataPagerDuty_FieldPath(raw) 1894 if err != nil { 1895 return err 1896 } 1897 fieldMask.Paths = append(fieldMask.Paths, path) 1898 return nil 1899 } 1900 1901 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) Set(target, source *Notification_State_NotificationState_ProviderData_PagerDuty) { 1902 for _, path := range fieldMask.Paths { 1903 val, _ := path.GetSingle(source) 1904 // if val is nil, then field does not exist in source, skip 1905 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 1906 if val != nil { 1907 path.WithIValue(val).SetTo(&target) 1908 } 1909 } 1910 } 1911 1912 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 1913 fieldMask.Set(target.(*Notification_State_NotificationState_ProviderData_PagerDuty), source.(*Notification_State_NotificationState_ProviderData_PagerDuty)) 1914 } 1915 1916 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) Project(source *Notification_State_NotificationState_ProviderData_PagerDuty) *Notification_State_NotificationState_ProviderData_PagerDuty { 1917 if source == nil { 1918 return nil 1919 } 1920 if fieldMask == nil { 1921 return source 1922 } 1923 result := &Notification_State_NotificationState_ProviderData_PagerDuty{} 1924 1925 for _, p := range fieldMask.Paths { 1926 switch tp := p.(type) { 1927 case *NotificationStateNotificationStateProviderDataPagerDuty_FieldTerminalPath: 1928 switch tp.selector { 1929 case NotificationStateNotificationStateProviderDataPagerDuty_FieldPathSelectorIncidentKey: 1930 result.IncidentKey = source.IncidentKey 1931 } 1932 } 1933 } 1934 return result 1935 } 1936 1937 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 1938 return fieldMask.Project(source.(*Notification_State_NotificationState_ProviderData_PagerDuty)) 1939 } 1940 1941 func (fieldMask *Notification_State_NotificationState_ProviderData_PagerDuty_FieldMask) PathsCount() int { 1942 if fieldMask == nil { 1943 return 0 1944 } 1945 return len(fieldMask.Paths) 1946 } 1947 1948 type Notification_State_NotificationState_ProviderData_WebHook_FieldMask struct { 1949 Paths []NotificationStateNotificationStateProviderDataWebHook_FieldPath 1950 } 1951 1952 func FullNotification_State_NotificationState_ProviderData_WebHook_FieldMask() *Notification_State_NotificationState_ProviderData_WebHook_FieldMask { 1953 res := &Notification_State_NotificationState_ProviderData_WebHook_FieldMask{} 1954 res.Paths = append(res.Paths, &NotificationStateNotificationStateProviderDataWebHook_FieldTerminalPath{selector: NotificationStateNotificationStateProviderDataWebHook_FieldPathSelectorTotalChunks}) 1955 res.Paths = append(res.Paths, &NotificationStateNotificationStateProviderDataWebHook_FieldTerminalPath{selector: NotificationStateNotificationStateProviderDataWebHook_FieldPathSelectorFailedChunks}) 1956 return res 1957 } 1958 1959 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) String() string { 1960 if fieldMask == nil { 1961 return "<nil>" 1962 } 1963 pathsStr := make([]string, 0, len(fieldMask.Paths)) 1964 for _, path := range fieldMask.Paths { 1965 pathsStr = append(pathsStr, path.String()) 1966 } 1967 return strings.Join(pathsStr, ", ") 1968 } 1969 1970 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) IsFull() bool { 1971 if fieldMask == nil { 1972 return false 1973 } 1974 presentSelectors := make([]bool, 2) 1975 for _, path := range fieldMask.Paths { 1976 if asFinal, ok := path.(*NotificationStateNotificationStateProviderDataWebHook_FieldTerminalPath); ok { 1977 presentSelectors[int(asFinal.selector)] = true 1978 } 1979 } 1980 for _, flag := range presentSelectors { 1981 if !flag { 1982 return false 1983 } 1984 } 1985 return true 1986 } 1987 1988 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) ProtoReflect() preflect.Message { 1989 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 1990 return ParseNotificationStateNotificationStateProviderDataWebHook_FieldPath(raw) 1991 }) 1992 } 1993 1994 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) ProtoMessage() { 1995 } 1996 1997 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) Reset() { 1998 if fieldMask != nil { 1999 fieldMask.Paths = nil 2000 } 2001 } 2002 2003 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) Subtract(other *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) *Notification_State_NotificationState_ProviderData_WebHook_FieldMask { 2004 result := &Notification_State_NotificationState_ProviderData_WebHook_FieldMask{} 2005 removedSelectors := make([]bool, 2) 2006 otherSubMasks := map[NotificationStateNotificationStateProviderDataWebHook_FieldPathSelector]gotenobject.FieldMask{ 2007 NotificationStateNotificationStateProviderDataWebHook_FieldPathSelectorFailedChunks: &Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask{}, 2008 } 2009 mySubMasks := map[NotificationStateNotificationStateProviderDataWebHook_FieldPathSelector]gotenobject.FieldMask{ 2010 NotificationStateNotificationStateProviderDataWebHook_FieldPathSelectorFailedChunks: &Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask{}, 2011 } 2012 2013 for _, path := range other.GetPaths() { 2014 switch tp := path.(type) { 2015 case *NotificationStateNotificationStateProviderDataWebHook_FieldTerminalPath: 2016 removedSelectors[int(tp.selector)] = true 2017 case *NotificationStateNotificationStateProviderDataWebHook_FieldSubPath: 2018 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 2019 } 2020 } 2021 for _, path := range fieldMask.GetPaths() { 2022 if !removedSelectors[int(path.Selector())] { 2023 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 2024 if tp, ok := path.(*NotificationStateNotificationStateProviderDataWebHook_FieldTerminalPath); ok { 2025 switch tp.selector { 2026 case NotificationStateNotificationStateProviderDataWebHook_FieldPathSelectorFailedChunks: 2027 mySubMasks[NotificationStateNotificationStateProviderDataWebHook_FieldPathSelectorFailedChunks] = FullNotification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask() 2028 } 2029 } else if tp, ok := path.(*NotificationStateNotificationStateProviderDataWebHook_FieldSubPath); ok { 2030 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 2031 } 2032 } else { 2033 result.Paths = append(result.Paths, path) 2034 } 2035 } 2036 } 2037 for selector, mySubMask := range mySubMasks { 2038 if mySubMask.PathsCount() > 0 { 2039 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 2040 result.Paths = append(result.Paths, &NotificationStateNotificationStateProviderDataWebHook_FieldSubPath{selector: selector, subPath: allowedPath}) 2041 } 2042 } 2043 } 2044 2045 if len(result.Paths) == 0 { 2046 return nil 2047 } 2048 return result 2049 } 2050 2051 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 2052 return fieldMask.Subtract(other.(*Notification_State_NotificationState_ProviderData_WebHook_FieldMask)) 2053 } 2054 2055 // FilterInputFields generates copy of field paths with output_only field paths removed 2056 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) FilterInputFields() *Notification_State_NotificationState_ProviderData_WebHook_FieldMask { 2057 result := &Notification_State_NotificationState_ProviderData_WebHook_FieldMask{} 2058 result.Paths = append(result.Paths, fieldMask.Paths...) 2059 return result 2060 } 2061 2062 // ToFieldMask is used for proto conversions 2063 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 2064 protoFieldMask := &googlefieldmaskpb.FieldMask{} 2065 for _, path := range fieldMask.Paths { 2066 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 2067 } 2068 return protoFieldMask 2069 } 2070 2071 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 2072 if fieldMask == nil { 2073 return status.Error(codes.Internal, "target field mask is nil") 2074 } 2075 fieldMask.Paths = make([]NotificationStateNotificationStateProviderDataWebHook_FieldPath, 0, len(protoFieldMask.Paths)) 2076 for _, strPath := range protoFieldMask.Paths { 2077 path, err := ParseNotificationStateNotificationStateProviderDataWebHook_FieldPath(strPath) 2078 if err != nil { 2079 return err 2080 } 2081 fieldMask.Paths = append(fieldMask.Paths, path) 2082 } 2083 return nil 2084 } 2085 2086 // implement methods required by customType 2087 func (fieldMask Notification_State_NotificationState_ProviderData_WebHook_FieldMask) Marshal() ([]byte, error) { 2088 protoFieldMask := fieldMask.ToProtoFieldMask() 2089 return proto.Marshal(protoFieldMask) 2090 } 2091 2092 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) Unmarshal(data []byte) error { 2093 protoFieldMask := &googlefieldmaskpb.FieldMask{} 2094 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 2095 return err 2096 } 2097 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 2098 return err 2099 } 2100 return nil 2101 } 2102 2103 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) Size() int { 2104 return proto.Size(fieldMask.ToProtoFieldMask()) 2105 } 2106 2107 func (fieldMask Notification_State_NotificationState_ProviderData_WebHook_FieldMask) MarshalJSON() ([]byte, error) { 2108 return json.Marshal(fieldMask.ToProtoFieldMask()) 2109 } 2110 2111 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) UnmarshalJSON(data []byte) error { 2112 protoFieldMask := &googlefieldmaskpb.FieldMask{} 2113 if err := json.Unmarshal(data, protoFieldMask); err != nil { 2114 return err 2115 } 2116 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 2117 return err 2118 } 2119 return nil 2120 } 2121 2122 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) AppendPath(path NotificationStateNotificationStateProviderDataWebHook_FieldPath) { 2123 fieldMask.Paths = append(fieldMask.Paths, path) 2124 } 2125 2126 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 2127 fieldMask.Paths = append(fieldMask.Paths, path.(NotificationStateNotificationStateProviderDataWebHook_FieldPath)) 2128 } 2129 2130 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) GetPaths() []NotificationStateNotificationStateProviderDataWebHook_FieldPath { 2131 if fieldMask == nil { 2132 return nil 2133 } 2134 return fieldMask.Paths 2135 } 2136 2137 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) GetRawPaths() []gotenobject.FieldPath { 2138 if fieldMask == nil { 2139 return nil 2140 } 2141 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 2142 for _, path := range fieldMask.Paths { 2143 rawPaths = append(rawPaths, path) 2144 } 2145 return rawPaths 2146 } 2147 2148 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) SetFromCliFlag(raw string) error { 2149 path, err := ParseNotificationStateNotificationStateProviderDataWebHook_FieldPath(raw) 2150 if err != nil { 2151 return err 2152 } 2153 fieldMask.Paths = append(fieldMask.Paths, path) 2154 return nil 2155 } 2156 2157 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) Set(target, source *Notification_State_NotificationState_ProviderData_WebHook) { 2158 for _, path := range fieldMask.Paths { 2159 val, _ := path.GetSingle(source) 2160 // if val is nil, then field does not exist in source, skip 2161 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 2162 if val != nil { 2163 path.WithIValue(val).SetTo(&target) 2164 } 2165 } 2166 } 2167 2168 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 2169 fieldMask.Set(target.(*Notification_State_NotificationState_ProviderData_WebHook), source.(*Notification_State_NotificationState_ProviderData_WebHook)) 2170 } 2171 2172 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) Project(source *Notification_State_NotificationState_ProviderData_WebHook) *Notification_State_NotificationState_ProviderData_WebHook { 2173 if source == nil { 2174 return nil 2175 } 2176 if fieldMask == nil { 2177 return source 2178 } 2179 result := &Notification_State_NotificationState_ProviderData_WebHook{} 2180 failedChunksMask := &Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask{} 2181 wholeFailedChunksAccepted := false 2182 2183 for _, p := range fieldMask.Paths { 2184 switch tp := p.(type) { 2185 case *NotificationStateNotificationStateProviderDataWebHook_FieldTerminalPath: 2186 switch tp.selector { 2187 case NotificationStateNotificationStateProviderDataWebHook_FieldPathSelectorTotalChunks: 2188 result.TotalChunks = source.TotalChunks 2189 case NotificationStateNotificationStateProviderDataWebHook_FieldPathSelectorFailedChunks: 2190 result.FailedChunks = source.FailedChunks 2191 wholeFailedChunksAccepted = true 2192 } 2193 case *NotificationStateNotificationStateProviderDataWebHook_FieldSubPath: 2194 switch tp.selector { 2195 case NotificationStateNotificationStateProviderDataWebHook_FieldPathSelectorFailedChunks: 2196 failedChunksMask.AppendPath(tp.subPath.(NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPath)) 2197 } 2198 } 2199 } 2200 if wholeFailedChunksAccepted == false && len(failedChunksMask.Paths) > 0 { 2201 for _, sourceItem := range source.GetFailedChunks() { 2202 result.FailedChunks = append(result.FailedChunks, failedChunksMask.Project(sourceItem)) 2203 } 2204 } 2205 return result 2206 } 2207 2208 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 2209 return fieldMask.Project(source.(*Notification_State_NotificationState_ProviderData_WebHook)) 2210 } 2211 2212 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FieldMask) PathsCount() int { 2213 if fieldMask == nil { 2214 return 0 2215 } 2216 return len(fieldMask.Paths) 2217 } 2218 2219 type Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask struct { 2220 Paths []NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPath 2221 } 2222 2223 func FullNotification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask() *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask { 2224 res := &Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask{} 2225 res.Paths = append(res.Paths, &NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldTerminalPath{selector: NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPathSelectorAlertOffset}) 2226 res.Paths = append(res.Paths, &NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldTerminalPath{selector: NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPathSelectorError}) 2227 return res 2228 } 2229 2230 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) String() string { 2231 if fieldMask == nil { 2232 return "<nil>" 2233 } 2234 pathsStr := make([]string, 0, len(fieldMask.Paths)) 2235 for _, path := range fieldMask.Paths { 2236 pathsStr = append(pathsStr, path.String()) 2237 } 2238 return strings.Join(pathsStr, ", ") 2239 } 2240 2241 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) IsFull() bool { 2242 if fieldMask == nil { 2243 return false 2244 } 2245 presentSelectors := make([]bool, 2) 2246 for _, path := range fieldMask.Paths { 2247 if asFinal, ok := path.(*NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldTerminalPath); ok { 2248 presentSelectors[int(asFinal.selector)] = true 2249 } 2250 } 2251 for _, flag := range presentSelectors { 2252 if !flag { 2253 return false 2254 } 2255 } 2256 return true 2257 } 2258 2259 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) ProtoReflect() preflect.Message { 2260 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 2261 return ParseNotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPath(raw) 2262 }) 2263 } 2264 2265 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) ProtoMessage() { 2266 } 2267 2268 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) Reset() { 2269 if fieldMask != nil { 2270 fieldMask.Paths = nil 2271 } 2272 } 2273 2274 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) Subtract(other *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask { 2275 result := &Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask{} 2276 removedSelectors := make([]bool, 2) 2277 2278 for _, path := range other.GetPaths() { 2279 switch tp := path.(type) { 2280 case *NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldTerminalPath: 2281 removedSelectors[int(tp.selector)] = true 2282 } 2283 } 2284 for _, path := range fieldMask.GetPaths() { 2285 if !removedSelectors[int(path.Selector())] { 2286 result.Paths = append(result.Paths, path) 2287 } 2288 } 2289 2290 if len(result.Paths) == 0 { 2291 return nil 2292 } 2293 return result 2294 } 2295 2296 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 2297 return fieldMask.Subtract(other.(*Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask)) 2298 } 2299 2300 // FilterInputFields generates copy of field paths with output_only field paths removed 2301 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) FilterInputFields() *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask { 2302 result := &Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask{} 2303 result.Paths = append(result.Paths, fieldMask.Paths...) 2304 return result 2305 } 2306 2307 // ToFieldMask is used for proto conversions 2308 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 2309 protoFieldMask := &googlefieldmaskpb.FieldMask{} 2310 for _, path := range fieldMask.Paths { 2311 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 2312 } 2313 return protoFieldMask 2314 } 2315 2316 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 2317 if fieldMask == nil { 2318 return status.Error(codes.Internal, "target field mask is nil") 2319 } 2320 fieldMask.Paths = make([]NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPath, 0, len(protoFieldMask.Paths)) 2321 for _, strPath := range protoFieldMask.Paths { 2322 path, err := ParseNotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPath(strPath) 2323 if err != nil { 2324 return err 2325 } 2326 fieldMask.Paths = append(fieldMask.Paths, path) 2327 } 2328 return nil 2329 } 2330 2331 // implement methods required by customType 2332 func (fieldMask Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) Marshal() ([]byte, error) { 2333 protoFieldMask := fieldMask.ToProtoFieldMask() 2334 return proto.Marshal(protoFieldMask) 2335 } 2336 2337 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) Unmarshal(data []byte) error { 2338 protoFieldMask := &googlefieldmaskpb.FieldMask{} 2339 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 2340 return err 2341 } 2342 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 2343 return err 2344 } 2345 return nil 2346 } 2347 2348 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) Size() int { 2349 return proto.Size(fieldMask.ToProtoFieldMask()) 2350 } 2351 2352 func (fieldMask Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) MarshalJSON() ([]byte, error) { 2353 return json.Marshal(fieldMask.ToProtoFieldMask()) 2354 } 2355 2356 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) UnmarshalJSON(data []byte) error { 2357 protoFieldMask := &googlefieldmaskpb.FieldMask{} 2358 if err := json.Unmarshal(data, protoFieldMask); err != nil { 2359 return err 2360 } 2361 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 2362 return err 2363 } 2364 return nil 2365 } 2366 2367 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) AppendPath(path NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPath) { 2368 fieldMask.Paths = append(fieldMask.Paths, path) 2369 } 2370 2371 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 2372 fieldMask.Paths = append(fieldMask.Paths, path.(NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPath)) 2373 } 2374 2375 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) GetPaths() []NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPath { 2376 if fieldMask == nil { 2377 return nil 2378 } 2379 return fieldMask.Paths 2380 } 2381 2382 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) GetRawPaths() []gotenobject.FieldPath { 2383 if fieldMask == nil { 2384 return nil 2385 } 2386 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 2387 for _, path := range fieldMask.Paths { 2388 rawPaths = append(rawPaths, path) 2389 } 2390 return rawPaths 2391 } 2392 2393 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) SetFromCliFlag(raw string) error { 2394 path, err := ParseNotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPath(raw) 2395 if err != nil { 2396 return err 2397 } 2398 fieldMask.Paths = append(fieldMask.Paths, path) 2399 return nil 2400 } 2401 2402 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) Set(target, source *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks) { 2403 for _, path := range fieldMask.Paths { 2404 val, _ := path.GetSingle(source) 2405 // if val is nil, then field does not exist in source, skip 2406 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 2407 if val != nil { 2408 path.WithIValue(val).SetTo(&target) 2409 } 2410 } 2411 } 2412 2413 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 2414 fieldMask.Set(target.(*Notification_State_NotificationState_ProviderData_WebHook_FailedChunks), source.(*Notification_State_NotificationState_ProviderData_WebHook_FailedChunks)) 2415 } 2416 2417 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) Project(source *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks) *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks { 2418 if source == nil { 2419 return nil 2420 } 2421 if fieldMask == nil { 2422 return source 2423 } 2424 result := &Notification_State_NotificationState_ProviderData_WebHook_FailedChunks{} 2425 2426 for _, p := range fieldMask.Paths { 2427 switch tp := p.(type) { 2428 case *NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldTerminalPath: 2429 switch tp.selector { 2430 case NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPathSelectorAlertOffset: 2431 result.AlertOffset = source.AlertOffset 2432 case NotificationStateNotificationStateProviderDataWebHookFailedChunks_FieldPathSelectorError: 2433 result.Error = source.Error 2434 } 2435 } 2436 } 2437 return result 2438 } 2439 2440 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 2441 return fieldMask.Project(source.(*Notification_State_NotificationState_ProviderData_WebHook_FailedChunks)) 2442 } 2443 2444 func (fieldMask *Notification_State_NotificationState_ProviderData_WebHook_FailedChunks_FieldMask) PathsCount() int { 2445 if fieldMask == nil { 2446 return 0 2447 } 2448 return len(fieldMask.Paths) 2449 }