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