github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/notification_channel/notification_channel.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/alerting/proto/v1/notification_channel.proto 3 // DO NOT EDIT!!! 4 5 package notification_channel 6 7 import ( 8 "encoding/json" 9 "fmt" 10 "reflect" 11 "strings" 12 "time" 13 14 "google.golang.org/grpc/codes" 15 "google.golang.org/grpc/status" 16 "google.golang.org/protobuf/encoding/protojson" 17 "google.golang.org/protobuf/proto" 18 "google.golang.org/protobuf/reflect/protoregistry" 19 20 gotenobject "github.com/cloudwan/goten-sdk/runtime/object" 21 "github.com/cloudwan/goten-sdk/runtime/strcase" 22 ) 23 24 // proto imports 25 import ( 26 rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common" 27 iam_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project" 28 meta "github.com/cloudwan/goten-sdk/types/meta" 29 timestamppb "google.golang.org/protobuf/types/known/timestamppb" 30 ) 31 32 // ensure the imports are used 33 var ( 34 _ = new(json.Marshaler) 35 _ = new(fmt.Stringer) 36 _ = reflect.DeepEqual 37 _ = strings.Builder{} 38 _ = time.Second 39 40 _ = strcase.ToLowerCamel 41 _ = codes.NotFound 42 _ = status.Status{} 43 _ = protojson.UnmarshalOptions{} 44 _ = new(proto.Message) 45 _ = protoregistry.GlobalTypes 46 47 _ = new(gotenobject.FieldPath) 48 ) 49 50 // make sure we're using proto imports 51 var ( 52 _ = &rcommon.LogCndSpec{} 53 _ = &iam_project.Project{} 54 _ = ×tamppb.Timestamp{} 55 _ = &meta.Meta{} 56 ) 57 58 // FieldPath provides implementation to handle 59 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 60 type NotificationChannel_FieldPath interface { 61 gotenobject.FieldPath 62 Selector() NotificationChannel_FieldPathSelector 63 Get(source *NotificationChannel) []interface{} 64 GetSingle(source *NotificationChannel) (interface{}, bool) 65 ClearValue(item *NotificationChannel) 66 67 // Those methods build corresponding NotificationChannel_FieldPathValue 68 // (or array of values) and holds passed value. Panics if injected type is incorrect. 69 WithIValue(value interface{}) NotificationChannel_FieldPathValue 70 WithIArrayOfValues(values interface{}) NotificationChannel_FieldPathArrayOfValues 71 WithIArrayItemValue(value interface{}) NotificationChannel_FieldPathArrayItemValue 72 } 73 74 type NotificationChannel_FieldPathSelector int32 75 76 const ( 77 NotificationChannel_FieldPathSelectorName NotificationChannel_FieldPathSelector = 0 78 NotificationChannel_FieldPathSelectorMetadata NotificationChannel_FieldPathSelector = 1 79 NotificationChannel_FieldPathSelectorDisplayName NotificationChannel_FieldPathSelector = 2 80 NotificationChannel_FieldPathSelectorDescription NotificationChannel_FieldPathSelector = 3 81 NotificationChannel_FieldPathSelectorSpec NotificationChannel_FieldPathSelector = 4 82 NotificationChannel_FieldPathSelectorState NotificationChannel_FieldPathSelector = 5 83 ) 84 85 func (s NotificationChannel_FieldPathSelector) String() string { 86 switch s { 87 case NotificationChannel_FieldPathSelectorName: 88 return "name" 89 case NotificationChannel_FieldPathSelectorMetadata: 90 return "metadata" 91 case NotificationChannel_FieldPathSelectorDisplayName: 92 return "display_name" 93 case NotificationChannel_FieldPathSelectorDescription: 94 return "description" 95 case NotificationChannel_FieldPathSelectorSpec: 96 return "spec" 97 case NotificationChannel_FieldPathSelectorState: 98 return "state" 99 default: 100 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", s)) 101 } 102 } 103 104 func BuildNotificationChannel_FieldPath(fp gotenobject.RawFieldPath) (NotificationChannel_FieldPath, error) { 105 if len(fp) == 0 { 106 return nil, status.Error(codes.InvalidArgument, "empty field path for object NotificationChannel") 107 } 108 if len(fp) == 1 { 109 switch fp[0] { 110 case "name": 111 return &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorName}, nil 112 case "metadata": 113 return &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorMetadata}, nil 114 case "display_name", "displayName", "display-name": 115 return &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorDisplayName}, nil 116 case "description": 117 return &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorDescription}, nil 118 case "spec": 119 return &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorSpec}, nil 120 case "state": 121 return &NotificationChannel_FieldTerminalPath{selector: NotificationChannel_FieldPathSelectorState}, nil 122 } 123 } else { 124 switch fp[0] { 125 case "metadata": 126 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 127 return nil, err 128 } else { 129 return &NotificationChannel_FieldSubPath{selector: NotificationChannel_FieldPathSelectorMetadata, subPath: subpath}, nil 130 } 131 case "spec": 132 if subpath, err := rcommon.BuildNotificationChannelSpec_FieldPath(fp[1:]); err != nil { 133 return nil, err 134 } else { 135 return &NotificationChannel_FieldSubPath{selector: NotificationChannel_FieldPathSelectorSpec, subPath: subpath}, nil 136 } 137 case "state": 138 if subpath, err := BuildNotificationChannelState_FieldPath(fp[1:]); err != nil { 139 return nil, err 140 } else { 141 return &NotificationChannel_FieldSubPath{selector: NotificationChannel_FieldPathSelectorState, subPath: subpath}, nil 142 } 143 } 144 } 145 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object NotificationChannel", fp) 146 } 147 148 func ParseNotificationChannel_FieldPath(rawField string) (NotificationChannel_FieldPath, error) { 149 fp, err := gotenobject.ParseRawFieldPath(rawField) 150 if err != nil { 151 return nil, err 152 } 153 return BuildNotificationChannel_FieldPath(fp) 154 } 155 156 func MustParseNotificationChannel_FieldPath(rawField string) NotificationChannel_FieldPath { 157 fp, err := ParseNotificationChannel_FieldPath(rawField) 158 if err != nil { 159 panic(err) 160 } 161 return fp 162 } 163 164 type NotificationChannel_FieldTerminalPath struct { 165 selector NotificationChannel_FieldPathSelector 166 } 167 168 var _ NotificationChannel_FieldPath = (*NotificationChannel_FieldTerminalPath)(nil) 169 170 func (fp *NotificationChannel_FieldTerminalPath) Selector() NotificationChannel_FieldPathSelector { 171 return fp.selector 172 } 173 174 // String returns path representation in proto convention 175 func (fp *NotificationChannel_FieldTerminalPath) String() string { 176 return fp.selector.String() 177 } 178 179 // JSONString returns path representation is JSON convention 180 func (fp *NotificationChannel_FieldTerminalPath) JSONString() string { 181 return strcase.ToLowerCamel(fp.String()) 182 } 183 184 // Get returns all values pointed by specific field from source NotificationChannel 185 func (fp *NotificationChannel_FieldTerminalPath) Get(source *NotificationChannel) (values []interface{}) { 186 if source != nil { 187 switch fp.selector { 188 case NotificationChannel_FieldPathSelectorName: 189 if source.Name != nil { 190 values = append(values, source.Name) 191 } 192 case NotificationChannel_FieldPathSelectorMetadata: 193 if source.Metadata != nil { 194 values = append(values, source.Metadata) 195 } 196 case NotificationChannel_FieldPathSelectorDisplayName: 197 values = append(values, source.DisplayName) 198 case NotificationChannel_FieldPathSelectorDescription: 199 values = append(values, source.Description) 200 case NotificationChannel_FieldPathSelectorSpec: 201 if source.Spec != nil { 202 values = append(values, source.Spec) 203 } 204 case NotificationChannel_FieldPathSelectorState: 205 if source.State != nil { 206 values = append(values, source.State) 207 } 208 default: 209 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fp.selector)) 210 } 211 } 212 return 213 } 214 215 func (fp *NotificationChannel_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 216 return fp.Get(source.(*NotificationChannel)) 217 } 218 219 // GetSingle returns value pointed by specific field of from source NotificationChannel 220 func (fp *NotificationChannel_FieldTerminalPath) GetSingle(source *NotificationChannel) (interface{}, bool) { 221 switch fp.selector { 222 case NotificationChannel_FieldPathSelectorName: 223 res := source.GetName() 224 return res, res != nil 225 case NotificationChannel_FieldPathSelectorMetadata: 226 res := source.GetMetadata() 227 return res, res != nil 228 case NotificationChannel_FieldPathSelectorDisplayName: 229 return source.GetDisplayName(), source != nil 230 case NotificationChannel_FieldPathSelectorDescription: 231 return source.GetDescription(), source != nil 232 case NotificationChannel_FieldPathSelectorSpec: 233 res := source.GetSpec() 234 return res, res != nil 235 case NotificationChannel_FieldPathSelectorState: 236 res := source.GetState() 237 return res, res != nil 238 default: 239 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fp.selector)) 240 } 241 } 242 243 func (fp *NotificationChannel_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 244 return fp.GetSingle(source.(*NotificationChannel)) 245 } 246 247 // GetDefault returns a default value of the field type 248 func (fp *NotificationChannel_FieldTerminalPath) GetDefault() interface{} { 249 switch fp.selector { 250 case NotificationChannel_FieldPathSelectorName: 251 return (*Name)(nil) 252 case NotificationChannel_FieldPathSelectorMetadata: 253 return (*meta.Meta)(nil) 254 case NotificationChannel_FieldPathSelectorDisplayName: 255 return "" 256 case NotificationChannel_FieldPathSelectorDescription: 257 return "" 258 case NotificationChannel_FieldPathSelectorSpec: 259 return (*rcommon.NotificationChannelSpec)(nil) 260 case NotificationChannel_FieldPathSelectorState: 261 return (*NotificationChannel_State)(nil) 262 default: 263 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fp.selector)) 264 } 265 } 266 267 func (fp *NotificationChannel_FieldTerminalPath) ClearValue(item *NotificationChannel) { 268 if item != nil { 269 switch fp.selector { 270 case NotificationChannel_FieldPathSelectorName: 271 item.Name = nil 272 case NotificationChannel_FieldPathSelectorMetadata: 273 item.Metadata = nil 274 case NotificationChannel_FieldPathSelectorDisplayName: 275 item.DisplayName = "" 276 case NotificationChannel_FieldPathSelectorDescription: 277 item.Description = "" 278 case NotificationChannel_FieldPathSelectorSpec: 279 item.Spec = nil 280 case NotificationChannel_FieldPathSelectorState: 281 item.State = nil 282 default: 283 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fp.selector)) 284 } 285 } 286 } 287 288 func (fp *NotificationChannel_FieldTerminalPath) ClearValueRaw(item proto.Message) { 289 fp.ClearValue(item.(*NotificationChannel)) 290 } 291 292 // IsLeaf - whether field path is holds simple value 293 func (fp *NotificationChannel_FieldTerminalPath) IsLeaf() bool { 294 return fp.selector == NotificationChannel_FieldPathSelectorName || 295 fp.selector == NotificationChannel_FieldPathSelectorDisplayName || 296 fp.selector == NotificationChannel_FieldPathSelectorDescription 297 } 298 299 func (fp *NotificationChannel_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 300 return []gotenobject.FieldPath{fp} 301 } 302 303 func (fp *NotificationChannel_FieldTerminalPath) WithIValue(value interface{}) NotificationChannel_FieldPathValue { 304 switch fp.selector { 305 case NotificationChannel_FieldPathSelectorName: 306 return &NotificationChannel_FieldTerminalPathValue{NotificationChannel_FieldTerminalPath: *fp, value: value.(*Name)} 307 case NotificationChannel_FieldPathSelectorMetadata: 308 return &NotificationChannel_FieldTerminalPathValue{NotificationChannel_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 309 case NotificationChannel_FieldPathSelectorDisplayName: 310 return &NotificationChannel_FieldTerminalPathValue{NotificationChannel_FieldTerminalPath: *fp, value: value.(string)} 311 case NotificationChannel_FieldPathSelectorDescription: 312 return &NotificationChannel_FieldTerminalPathValue{NotificationChannel_FieldTerminalPath: *fp, value: value.(string)} 313 case NotificationChannel_FieldPathSelectorSpec: 314 return &NotificationChannel_FieldTerminalPathValue{NotificationChannel_FieldTerminalPath: *fp, value: value.(*rcommon.NotificationChannelSpec)} 315 case NotificationChannel_FieldPathSelectorState: 316 return &NotificationChannel_FieldTerminalPathValue{NotificationChannel_FieldTerminalPath: *fp, value: value.(*NotificationChannel_State)} 317 default: 318 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fp.selector)) 319 } 320 } 321 322 func (fp *NotificationChannel_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 323 return fp.WithIValue(value) 324 } 325 326 func (fp *NotificationChannel_FieldTerminalPath) WithIArrayOfValues(values interface{}) NotificationChannel_FieldPathArrayOfValues { 327 fpaov := &NotificationChannel_FieldTerminalPathArrayOfValues{NotificationChannel_FieldTerminalPath: *fp} 328 switch fp.selector { 329 case NotificationChannel_FieldPathSelectorName: 330 return &NotificationChannel_FieldTerminalPathArrayOfValues{NotificationChannel_FieldTerminalPath: *fp, values: values.([]*Name)} 331 case NotificationChannel_FieldPathSelectorMetadata: 332 return &NotificationChannel_FieldTerminalPathArrayOfValues{NotificationChannel_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 333 case NotificationChannel_FieldPathSelectorDisplayName: 334 return &NotificationChannel_FieldTerminalPathArrayOfValues{NotificationChannel_FieldTerminalPath: *fp, values: values.([]string)} 335 case NotificationChannel_FieldPathSelectorDescription: 336 return &NotificationChannel_FieldTerminalPathArrayOfValues{NotificationChannel_FieldTerminalPath: *fp, values: values.([]string)} 337 case NotificationChannel_FieldPathSelectorSpec: 338 return &NotificationChannel_FieldTerminalPathArrayOfValues{NotificationChannel_FieldTerminalPath: *fp, values: values.([]*rcommon.NotificationChannelSpec)} 339 case NotificationChannel_FieldPathSelectorState: 340 return &NotificationChannel_FieldTerminalPathArrayOfValues{NotificationChannel_FieldTerminalPath: *fp, values: values.([]*NotificationChannel_State)} 341 default: 342 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fp.selector)) 343 } 344 return fpaov 345 } 346 347 func (fp *NotificationChannel_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 348 return fp.WithIArrayOfValues(values) 349 } 350 351 func (fp *NotificationChannel_FieldTerminalPath) WithIArrayItemValue(value interface{}) NotificationChannel_FieldPathArrayItemValue { 352 switch fp.selector { 353 default: 354 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fp.selector)) 355 } 356 } 357 358 func (fp *NotificationChannel_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 359 return fp.WithIArrayItemValue(value) 360 } 361 362 type NotificationChannel_FieldSubPath struct { 363 selector NotificationChannel_FieldPathSelector 364 subPath gotenobject.FieldPath 365 } 366 367 var _ NotificationChannel_FieldPath = (*NotificationChannel_FieldSubPath)(nil) 368 369 func (fps *NotificationChannel_FieldSubPath) Selector() NotificationChannel_FieldPathSelector { 370 return fps.selector 371 } 372 func (fps *NotificationChannel_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 373 res, ok := fps.subPath.(meta.Meta_FieldPath) 374 return res, ok 375 } 376 func (fps *NotificationChannel_FieldSubPath) AsSpecSubPath() (rcommon.NotificationChannelSpec_FieldPath, bool) { 377 res, ok := fps.subPath.(rcommon.NotificationChannelSpec_FieldPath) 378 return res, ok 379 } 380 func (fps *NotificationChannel_FieldSubPath) AsStateSubPath() (NotificationChannelState_FieldPath, bool) { 381 res, ok := fps.subPath.(NotificationChannelState_FieldPath) 382 return res, ok 383 } 384 385 // String returns path representation in proto convention 386 func (fps *NotificationChannel_FieldSubPath) String() string { 387 return fps.selector.String() + "." + fps.subPath.String() 388 } 389 390 // JSONString returns path representation is JSON convention 391 func (fps *NotificationChannel_FieldSubPath) JSONString() string { 392 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 393 } 394 395 // Get returns all values pointed by selected field from source NotificationChannel 396 func (fps *NotificationChannel_FieldSubPath) Get(source *NotificationChannel) (values []interface{}) { 397 switch fps.selector { 398 case NotificationChannel_FieldPathSelectorMetadata: 399 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 400 case NotificationChannel_FieldPathSelectorSpec: 401 values = append(values, fps.subPath.GetRaw(source.GetSpec())...) 402 case NotificationChannel_FieldPathSelectorState: 403 values = append(values, fps.subPath.GetRaw(source.GetState())...) 404 default: 405 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fps.selector)) 406 } 407 return 408 } 409 410 func (fps *NotificationChannel_FieldSubPath) GetRaw(source proto.Message) []interface{} { 411 return fps.Get(source.(*NotificationChannel)) 412 } 413 414 // GetSingle returns value of selected field from source NotificationChannel 415 func (fps *NotificationChannel_FieldSubPath) GetSingle(source *NotificationChannel) (interface{}, bool) { 416 switch fps.selector { 417 case NotificationChannel_FieldPathSelectorMetadata: 418 if source.GetMetadata() == nil { 419 return nil, false 420 } 421 return fps.subPath.GetSingleRaw(source.GetMetadata()) 422 case NotificationChannel_FieldPathSelectorSpec: 423 if source.GetSpec() == nil { 424 return nil, false 425 } 426 return fps.subPath.GetSingleRaw(source.GetSpec()) 427 case NotificationChannel_FieldPathSelectorState: 428 if source.GetState() == nil { 429 return nil, false 430 } 431 return fps.subPath.GetSingleRaw(source.GetState()) 432 default: 433 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fps.selector)) 434 } 435 } 436 437 func (fps *NotificationChannel_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 438 return fps.GetSingle(source.(*NotificationChannel)) 439 } 440 441 // GetDefault returns a default value of the field type 442 func (fps *NotificationChannel_FieldSubPath) GetDefault() interface{} { 443 return fps.subPath.GetDefault() 444 } 445 446 func (fps *NotificationChannel_FieldSubPath) ClearValue(item *NotificationChannel) { 447 if item != nil { 448 switch fps.selector { 449 case NotificationChannel_FieldPathSelectorMetadata: 450 fps.subPath.ClearValueRaw(item.Metadata) 451 case NotificationChannel_FieldPathSelectorSpec: 452 fps.subPath.ClearValueRaw(item.Spec) 453 case NotificationChannel_FieldPathSelectorState: 454 fps.subPath.ClearValueRaw(item.State) 455 default: 456 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fps.selector)) 457 } 458 } 459 } 460 461 func (fps *NotificationChannel_FieldSubPath) ClearValueRaw(item proto.Message) { 462 fps.ClearValue(item.(*NotificationChannel)) 463 } 464 465 // IsLeaf - whether field path is holds simple value 466 func (fps *NotificationChannel_FieldSubPath) IsLeaf() bool { 467 return fps.subPath.IsLeaf() 468 } 469 470 func (fps *NotificationChannel_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 471 iPaths := []gotenobject.FieldPath{&NotificationChannel_FieldTerminalPath{selector: fps.selector}} 472 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 473 return iPaths 474 } 475 476 func (fps *NotificationChannel_FieldSubPath) WithIValue(value interface{}) NotificationChannel_FieldPathValue { 477 return &NotificationChannel_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 478 } 479 480 func (fps *NotificationChannel_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 481 return fps.WithIValue(value) 482 } 483 484 func (fps *NotificationChannel_FieldSubPath) WithIArrayOfValues(values interface{}) NotificationChannel_FieldPathArrayOfValues { 485 return &NotificationChannel_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 486 } 487 488 func (fps *NotificationChannel_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 489 return fps.WithIArrayOfValues(values) 490 } 491 492 func (fps *NotificationChannel_FieldSubPath) WithIArrayItemValue(value interface{}) NotificationChannel_FieldPathArrayItemValue { 493 return &NotificationChannel_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 494 } 495 496 func (fps *NotificationChannel_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 497 return fps.WithIArrayItemValue(value) 498 } 499 500 // NotificationChannel_FieldPathValue allows storing values for NotificationChannel fields according to their type 501 type NotificationChannel_FieldPathValue interface { 502 NotificationChannel_FieldPath 503 gotenobject.FieldPathValue 504 SetTo(target **NotificationChannel) 505 CompareWith(*NotificationChannel) (cmp int, comparable bool) 506 } 507 508 func ParseNotificationChannel_FieldPathValue(pathStr, valueStr string) (NotificationChannel_FieldPathValue, error) { 509 fp, err := ParseNotificationChannel_FieldPath(pathStr) 510 if err != nil { 511 return nil, err 512 } 513 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 514 if err != nil { 515 return nil, status.Errorf(codes.InvalidArgument, "error parsing NotificationChannel field path value from %s: %v", valueStr, err) 516 } 517 return fpv.(NotificationChannel_FieldPathValue), nil 518 } 519 520 func MustParseNotificationChannel_FieldPathValue(pathStr, valueStr string) NotificationChannel_FieldPathValue { 521 fpv, err := ParseNotificationChannel_FieldPathValue(pathStr, valueStr) 522 if err != nil { 523 panic(err) 524 } 525 return fpv 526 } 527 528 type NotificationChannel_FieldTerminalPathValue struct { 529 NotificationChannel_FieldTerminalPath 530 value interface{} 531 } 532 533 var _ NotificationChannel_FieldPathValue = (*NotificationChannel_FieldTerminalPathValue)(nil) 534 535 // GetRawValue returns raw value stored under selected path for 'NotificationChannel' as interface{} 536 func (fpv *NotificationChannel_FieldTerminalPathValue) GetRawValue() interface{} { 537 return fpv.value 538 } 539 func (fpv *NotificationChannel_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 540 res, ok := fpv.value.(*Name) 541 return res, ok 542 } 543 func (fpv *NotificationChannel_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 544 res, ok := fpv.value.(*meta.Meta) 545 return res, ok 546 } 547 func (fpv *NotificationChannel_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) { 548 res, ok := fpv.value.(string) 549 return res, ok 550 } 551 func (fpv *NotificationChannel_FieldTerminalPathValue) AsDescriptionValue() (string, bool) { 552 res, ok := fpv.value.(string) 553 return res, ok 554 } 555 func (fpv *NotificationChannel_FieldTerminalPathValue) AsSpecValue() (*rcommon.NotificationChannelSpec, bool) { 556 res, ok := fpv.value.(*rcommon.NotificationChannelSpec) 557 return res, ok 558 } 559 func (fpv *NotificationChannel_FieldTerminalPathValue) AsStateValue() (*NotificationChannel_State, bool) { 560 res, ok := fpv.value.(*NotificationChannel_State) 561 return res, ok 562 } 563 564 // SetTo stores value for selected field for object NotificationChannel 565 func (fpv *NotificationChannel_FieldTerminalPathValue) SetTo(target **NotificationChannel) { 566 if *target == nil { 567 *target = new(NotificationChannel) 568 } 569 switch fpv.selector { 570 case NotificationChannel_FieldPathSelectorName: 571 (*target).Name = fpv.value.(*Name) 572 case NotificationChannel_FieldPathSelectorMetadata: 573 (*target).Metadata = fpv.value.(*meta.Meta) 574 case NotificationChannel_FieldPathSelectorDisplayName: 575 (*target).DisplayName = fpv.value.(string) 576 case NotificationChannel_FieldPathSelectorDescription: 577 (*target).Description = fpv.value.(string) 578 case NotificationChannel_FieldPathSelectorSpec: 579 (*target).Spec = fpv.value.(*rcommon.NotificationChannelSpec) 580 case NotificationChannel_FieldPathSelectorState: 581 (*target).State = fpv.value.(*NotificationChannel_State) 582 default: 583 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fpv.selector)) 584 } 585 } 586 587 func (fpv *NotificationChannel_FieldTerminalPathValue) SetToRaw(target proto.Message) { 588 typedObject := target.(*NotificationChannel) 589 fpv.SetTo(&typedObject) 590 } 591 592 // CompareWith compares value in the 'NotificationChannel_FieldTerminalPathValue' with the value under path in 'NotificationChannel'. 593 func (fpv *NotificationChannel_FieldTerminalPathValue) CompareWith(source *NotificationChannel) (int, bool) { 594 switch fpv.selector { 595 case NotificationChannel_FieldPathSelectorName: 596 leftValue := fpv.value.(*Name) 597 rightValue := source.GetName() 598 if leftValue == nil { 599 if rightValue != nil { 600 return -1, true 601 } 602 return 0, true 603 } 604 if rightValue == nil { 605 return 1, true 606 } 607 if leftValue.String() == rightValue.String() { 608 return 0, true 609 } else if leftValue.String() < rightValue.String() { 610 return -1, true 611 } else { 612 return 1, true 613 } 614 case NotificationChannel_FieldPathSelectorMetadata: 615 return 0, false 616 case NotificationChannel_FieldPathSelectorDisplayName: 617 leftValue := fpv.value.(string) 618 rightValue := source.GetDisplayName() 619 if (leftValue) == (rightValue) { 620 return 0, true 621 } else if (leftValue) < (rightValue) { 622 return -1, true 623 } else { 624 return 1, true 625 } 626 case NotificationChannel_FieldPathSelectorDescription: 627 leftValue := fpv.value.(string) 628 rightValue := source.GetDescription() 629 if (leftValue) == (rightValue) { 630 return 0, true 631 } else if (leftValue) < (rightValue) { 632 return -1, true 633 } else { 634 return 1, true 635 } 636 case NotificationChannel_FieldPathSelectorSpec: 637 return 0, false 638 case NotificationChannel_FieldPathSelectorState: 639 return 0, false 640 default: 641 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fpv.selector)) 642 } 643 } 644 645 func (fpv *NotificationChannel_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 646 return fpv.CompareWith(source.(*NotificationChannel)) 647 } 648 649 type NotificationChannel_FieldSubPathValue struct { 650 NotificationChannel_FieldPath 651 subPathValue gotenobject.FieldPathValue 652 } 653 654 var _ NotificationChannel_FieldPathValue = (*NotificationChannel_FieldSubPathValue)(nil) 655 656 func (fpvs *NotificationChannel_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 657 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 658 return res, ok 659 } 660 func (fpvs *NotificationChannel_FieldSubPathValue) AsSpecPathValue() (rcommon.NotificationChannelSpec_FieldPathValue, bool) { 661 res, ok := fpvs.subPathValue.(rcommon.NotificationChannelSpec_FieldPathValue) 662 return res, ok 663 } 664 func (fpvs *NotificationChannel_FieldSubPathValue) AsStatePathValue() (NotificationChannelState_FieldPathValue, bool) { 665 res, ok := fpvs.subPathValue.(NotificationChannelState_FieldPathValue) 666 return res, ok 667 } 668 669 func (fpvs *NotificationChannel_FieldSubPathValue) SetTo(target **NotificationChannel) { 670 if *target == nil { 671 *target = new(NotificationChannel) 672 } 673 switch fpvs.Selector() { 674 case NotificationChannel_FieldPathSelectorMetadata: 675 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 676 case NotificationChannel_FieldPathSelectorSpec: 677 fpvs.subPathValue.(rcommon.NotificationChannelSpec_FieldPathValue).SetTo(&(*target).Spec) 678 case NotificationChannel_FieldPathSelectorState: 679 fpvs.subPathValue.(NotificationChannelState_FieldPathValue).SetTo(&(*target).State) 680 default: 681 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fpvs.Selector())) 682 } 683 } 684 685 func (fpvs *NotificationChannel_FieldSubPathValue) SetToRaw(target proto.Message) { 686 typedObject := target.(*NotificationChannel) 687 fpvs.SetTo(&typedObject) 688 } 689 690 func (fpvs *NotificationChannel_FieldSubPathValue) GetRawValue() interface{} { 691 return fpvs.subPathValue.GetRawValue() 692 } 693 694 func (fpvs *NotificationChannel_FieldSubPathValue) CompareWith(source *NotificationChannel) (int, bool) { 695 switch fpvs.Selector() { 696 case NotificationChannel_FieldPathSelectorMetadata: 697 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 698 case NotificationChannel_FieldPathSelectorSpec: 699 return fpvs.subPathValue.(rcommon.NotificationChannelSpec_FieldPathValue).CompareWith(source.GetSpec()) 700 case NotificationChannel_FieldPathSelectorState: 701 return fpvs.subPathValue.(NotificationChannelState_FieldPathValue).CompareWith(source.GetState()) 702 default: 703 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fpvs.Selector())) 704 } 705 } 706 707 func (fpvs *NotificationChannel_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 708 return fpvs.CompareWith(source.(*NotificationChannel)) 709 } 710 711 // NotificationChannel_FieldPathArrayItemValue allows storing single item in Path-specific values for NotificationChannel according to their type 712 // Present only for array (repeated) types. 713 type NotificationChannel_FieldPathArrayItemValue interface { 714 gotenobject.FieldPathArrayItemValue 715 NotificationChannel_FieldPath 716 ContainsValue(*NotificationChannel) bool 717 } 718 719 // ParseNotificationChannel_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 720 func ParseNotificationChannel_FieldPathArrayItemValue(pathStr, valueStr string) (NotificationChannel_FieldPathArrayItemValue, error) { 721 fp, err := ParseNotificationChannel_FieldPath(pathStr) 722 if err != nil { 723 return nil, err 724 } 725 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 726 if err != nil { 727 return nil, status.Errorf(codes.InvalidArgument, "error parsing NotificationChannel field path array item value from %s: %v", valueStr, err) 728 } 729 return fpaiv.(NotificationChannel_FieldPathArrayItemValue), nil 730 } 731 732 func MustParseNotificationChannel_FieldPathArrayItemValue(pathStr, valueStr string) NotificationChannel_FieldPathArrayItemValue { 733 fpaiv, err := ParseNotificationChannel_FieldPathArrayItemValue(pathStr, valueStr) 734 if err != nil { 735 panic(err) 736 } 737 return fpaiv 738 } 739 740 type NotificationChannel_FieldTerminalPathArrayItemValue struct { 741 NotificationChannel_FieldTerminalPath 742 value interface{} 743 } 744 745 var _ NotificationChannel_FieldPathArrayItemValue = (*NotificationChannel_FieldTerminalPathArrayItemValue)(nil) 746 747 // GetRawValue returns stored element value for array in object NotificationChannel as interface{} 748 func (fpaiv *NotificationChannel_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 749 return fpaiv.value 750 } 751 752 func (fpaiv *NotificationChannel_FieldTerminalPathArrayItemValue) GetSingle(source *NotificationChannel) (interface{}, bool) { 753 return nil, false 754 } 755 756 func (fpaiv *NotificationChannel_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 757 return fpaiv.GetSingle(source.(*NotificationChannel)) 758 } 759 760 // Contains returns a boolean indicating if value that is being held is present in given 'NotificationChannel' 761 func (fpaiv *NotificationChannel_FieldTerminalPathArrayItemValue) ContainsValue(source *NotificationChannel) bool { 762 slice := fpaiv.NotificationChannel_FieldTerminalPath.Get(source) 763 for _, v := range slice { 764 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 765 if proto.Equal(asProtoMsg, v.(proto.Message)) { 766 return true 767 } 768 } else if reflect.DeepEqual(v, fpaiv.value) { 769 return true 770 } 771 } 772 return false 773 } 774 775 type NotificationChannel_FieldSubPathArrayItemValue struct { 776 NotificationChannel_FieldPath 777 subPathItemValue gotenobject.FieldPathArrayItemValue 778 } 779 780 // GetRawValue returns stored array item value 781 func (fpaivs *NotificationChannel_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 782 return fpaivs.subPathItemValue.GetRawItemValue() 783 } 784 func (fpaivs *NotificationChannel_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 785 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 786 return res, ok 787 } 788 func (fpaivs *NotificationChannel_FieldSubPathArrayItemValue) AsSpecPathItemValue() (rcommon.NotificationChannelSpec_FieldPathArrayItemValue, bool) { 789 res, ok := fpaivs.subPathItemValue.(rcommon.NotificationChannelSpec_FieldPathArrayItemValue) 790 return res, ok 791 } 792 func (fpaivs *NotificationChannel_FieldSubPathArrayItemValue) AsStatePathItemValue() (NotificationChannelState_FieldPathArrayItemValue, bool) { 793 res, ok := fpaivs.subPathItemValue.(NotificationChannelState_FieldPathArrayItemValue) 794 return res, ok 795 } 796 797 // Contains returns a boolean indicating if value that is being held is present in given 'NotificationChannel' 798 func (fpaivs *NotificationChannel_FieldSubPathArrayItemValue) ContainsValue(source *NotificationChannel) bool { 799 switch fpaivs.Selector() { 800 case NotificationChannel_FieldPathSelectorMetadata: 801 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 802 case NotificationChannel_FieldPathSelectorSpec: 803 return fpaivs.subPathItemValue.(rcommon.NotificationChannelSpec_FieldPathArrayItemValue).ContainsValue(source.GetSpec()) 804 case NotificationChannel_FieldPathSelectorState: 805 return fpaivs.subPathItemValue.(NotificationChannelState_FieldPathArrayItemValue).ContainsValue(source.GetState()) 806 default: 807 panic(fmt.Sprintf("Invalid selector for NotificationChannel: %d", fpaivs.Selector())) 808 } 809 } 810 811 // NotificationChannel_FieldPathArrayOfValues allows storing slice of values for NotificationChannel fields according to their type 812 type NotificationChannel_FieldPathArrayOfValues interface { 813 gotenobject.FieldPathArrayOfValues 814 NotificationChannel_FieldPath 815 } 816 817 func ParseNotificationChannel_FieldPathArrayOfValues(pathStr, valuesStr string) (NotificationChannel_FieldPathArrayOfValues, error) { 818 fp, err := ParseNotificationChannel_FieldPath(pathStr) 819 if err != nil { 820 return nil, err 821 } 822 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 823 if err != nil { 824 return nil, status.Errorf(codes.InvalidArgument, "error parsing NotificationChannel field path array of values from %s: %v", valuesStr, err) 825 } 826 return fpaov.(NotificationChannel_FieldPathArrayOfValues), nil 827 } 828 829 func MustParseNotificationChannel_FieldPathArrayOfValues(pathStr, valuesStr string) NotificationChannel_FieldPathArrayOfValues { 830 fpaov, err := ParseNotificationChannel_FieldPathArrayOfValues(pathStr, valuesStr) 831 if err != nil { 832 panic(err) 833 } 834 return fpaov 835 } 836 837 type NotificationChannel_FieldTerminalPathArrayOfValues struct { 838 NotificationChannel_FieldTerminalPath 839 values interface{} 840 } 841 842 var _ NotificationChannel_FieldPathArrayOfValues = (*NotificationChannel_FieldTerminalPathArrayOfValues)(nil) 843 844 func (fpaov *NotificationChannel_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 845 switch fpaov.selector { 846 case NotificationChannel_FieldPathSelectorName: 847 for _, v := range fpaov.values.([]*Name) { 848 values = append(values, v) 849 } 850 case NotificationChannel_FieldPathSelectorMetadata: 851 for _, v := range fpaov.values.([]*meta.Meta) { 852 values = append(values, v) 853 } 854 case NotificationChannel_FieldPathSelectorDisplayName: 855 for _, v := range fpaov.values.([]string) { 856 values = append(values, v) 857 } 858 case NotificationChannel_FieldPathSelectorDescription: 859 for _, v := range fpaov.values.([]string) { 860 values = append(values, v) 861 } 862 case NotificationChannel_FieldPathSelectorSpec: 863 for _, v := range fpaov.values.([]*rcommon.NotificationChannelSpec) { 864 values = append(values, v) 865 } 866 case NotificationChannel_FieldPathSelectorState: 867 for _, v := range fpaov.values.([]*NotificationChannel_State) { 868 values = append(values, v) 869 } 870 } 871 return 872 } 873 func (fpaov *NotificationChannel_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 874 res, ok := fpaov.values.([]*Name) 875 return res, ok 876 } 877 func (fpaov *NotificationChannel_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 878 res, ok := fpaov.values.([]*meta.Meta) 879 return res, ok 880 } 881 func (fpaov *NotificationChannel_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) { 882 res, ok := fpaov.values.([]string) 883 return res, ok 884 } 885 func (fpaov *NotificationChannel_FieldTerminalPathArrayOfValues) AsDescriptionArrayOfValues() ([]string, bool) { 886 res, ok := fpaov.values.([]string) 887 return res, ok 888 } 889 func (fpaov *NotificationChannel_FieldTerminalPathArrayOfValues) AsSpecArrayOfValues() ([]*rcommon.NotificationChannelSpec, bool) { 890 res, ok := fpaov.values.([]*rcommon.NotificationChannelSpec) 891 return res, ok 892 } 893 func (fpaov *NotificationChannel_FieldTerminalPathArrayOfValues) AsStateArrayOfValues() ([]*NotificationChannel_State, bool) { 894 res, ok := fpaov.values.([]*NotificationChannel_State) 895 return res, ok 896 } 897 898 type NotificationChannel_FieldSubPathArrayOfValues struct { 899 NotificationChannel_FieldPath 900 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 901 } 902 903 var _ NotificationChannel_FieldPathArrayOfValues = (*NotificationChannel_FieldSubPathArrayOfValues)(nil) 904 905 func (fpsaov *NotificationChannel_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 906 return fpsaov.subPathArrayOfValues.GetRawValues() 907 } 908 func (fpsaov *NotificationChannel_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 909 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 910 return res, ok 911 } 912 func (fpsaov *NotificationChannel_FieldSubPathArrayOfValues) AsSpecPathArrayOfValues() (rcommon.NotificationChannelSpec_FieldPathArrayOfValues, bool) { 913 res, ok := fpsaov.subPathArrayOfValues.(rcommon.NotificationChannelSpec_FieldPathArrayOfValues) 914 return res, ok 915 } 916 func (fpsaov *NotificationChannel_FieldSubPathArrayOfValues) AsStatePathArrayOfValues() (NotificationChannelState_FieldPathArrayOfValues, bool) { 917 res, ok := fpsaov.subPathArrayOfValues.(NotificationChannelState_FieldPathArrayOfValues) 918 return res, ok 919 } 920 921 // FieldPath provides implementation to handle 922 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 923 type NotificationChannelState_FieldPath interface { 924 gotenobject.FieldPath 925 Selector() NotificationChannelState_FieldPathSelector 926 Get(source *NotificationChannel_State) []interface{} 927 GetSingle(source *NotificationChannel_State) (interface{}, bool) 928 ClearValue(item *NotificationChannel_State) 929 930 // Those methods build corresponding NotificationChannelState_FieldPathValue 931 // (or array of values) and holds passed value. Panics if injected type is incorrect. 932 WithIValue(value interface{}) NotificationChannelState_FieldPathValue 933 WithIArrayOfValues(values interface{}) NotificationChannelState_FieldPathArrayOfValues 934 WithIArrayItemValue(value interface{}) NotificationChannelState_FieldPathArrayItemValue 935 } 936 937 type NotificationChannelState_FieldPathSelector int32 938 939 const ( 940 NotificationChannelState_FieldPathSelectorStatus NotificationChannelState_FieldPathSelector = 0 941 NotificationChannelState_FieldPathSelectorError NotificationChannelState_FieldPathSelector = 1 942 ) 943 944 func (s NotificationChannelState_FieldPathSelector) String() string { 945 switch s { 946 case NotificationChannelState_FieldPathSelectorStatus: 947 return "status" 948 case NotificationChannelState_FieldPathSelectorError: 949 return "error" 950 default: 951 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", s)) 952 } 953 } 954 955 func BuildNotificationChannelState_FieldPath(fp gotenobject.RawFieldPath) (NotificationChannelState_FieldPath, error) { 956 if len(fp) == 0 { 957 return nil, status.Error(codes.InvalidArgument, "empty field path for object NotificationChannel_State") 958 } 959 if len(fp) == 1 { 960 switch fp[0] { 961 case "status": 962 return &NotificationChannelState_FieldTerminalPath{selector: NotificationChannelState_FieldPathSelectorStatus}, nil 963 case "error": 964 return &NotificationChannelState_FieldTerminalPath{selector: NotificationChannelState_FieldPathSelectorError}, nil 965 } 966 } else { 967 switch fp[0] { 968 case "error": 969 if subpath, err := BuildNotificationChannelStateError_FieldPath(fp[1:]); err != nil { 970 return nil, err 971 } else { 972 return &NotificationChannelState_FieldSubPath{selector: NotificationChannelState_FieldPathSelectorError, subPath: subpath}, nil 973 } 974 } 975 } 976 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object NotificationChannel_State", fp) 977 } 978 979 func ParseNotificationChannelState_FieldPath(rawField string) (NotificationChannelState_FieldPath, error) { 980 fp, err := gotenobject.ParseRawFieldPath(rawField) 981 if err != nil { 982 return nil, err 983 } 984 return BuildNotificationChannelState_FieldPath(fp) 985 } 986 987 func MustParseNotificationChannelState_FieldPath(rawField string) NotificationChannelState_FieldPath { 988 fp, err := ParseNotificationChannelState_FieldPath(rawField) 989 if err != nil { 990 panic(err) 991 } 992 return fp 993 } 994 995 type NotificationChannelState_FieldTerminalPath struct { 996 selector NotificationChannelState_FieldPathSelector 997 } 998 999 var _ NotificationChannelState_FieldPath = (*NotificationChannelState_FieldTerminalPath)(nil) 1000 1001 func (fp *NotificationChannelState_FieldTerminalPath) Selector() NotificationChannelState_FieldPathSelector { 1002 return fp.selector 1003 } 1004 1005 // String returns path representation in proto convention 1006 func (fp *NotificationChannelState_FieldTerminalPath) String() string { 1007 return fp.selector.String() 1008 } 1009 1010 // JSONString returns path representation is JSON convention 1011 func (fp *NotificationChannelState_FieldTerminalPath) JSONString() string { 1012 return strcase.ToLowerCamel(fp.String()) 1013 } 1014 1015 // Get returns all values pointed by specific field from source NotificationChannel_State 1016 func (fp *NotificationChannelState_FieldTerminalPath) Get(source *NotificationChannel_State) (values []interface{}) { 1017 if source != nil { 1018 switch fp.selector { 1019 case NotificationChannelState_FieldPathSelectorStatus: 1020 values = append(values, source.Status) 1021 case NotificationChannelState_FieldPathSelectorError: 1022 if source.Error != nil { 1023 values = append(values, source.Error) 1024 } 1025 default: 1026 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fp.selector)) 1027 } 1028 } 1029 return 1030 } 1031 1032 func (fp *NotificationChannelState_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1033 return fp.Get(source.(*NotificationChannel_State)) 1034 } 1035 1036 // GetSingle returns value pointed by specific field of from source NotificationChannel_State 1037 func (fp *NotificationChannelState_FieldTerminalPath) GetSingle(source *NotificationChannel_State) (interface{}, bool) { 1038 switch fp.selector { 1039 case NotificationChannelState_FieldPathSelectorStatus: 1040 return source.GetStatus(), source != nil 1041 case NotificationChannelState_FieldPathSelectorError: 1042 res := source.GetError() 1043 return res, res != nil 1044 default: 1045 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fp.selector)) 1046 } 1047 } 1048 1049 func (fp *NotificationChannelState_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1050 return fp.GetSingle(source.(*NotificationChannel_State)) 1051 } 1052 1053 // GetDefault returns a default value of the field type 1054 func (fp *NotificationChannelState_FieldTerminalPath) GetDefault() interface{} { 1055 switch fp.selector { 1056 case NotificationChannelState_FieldPathSelectorStatus: 1057 return NotificationChannel_State_STATE_UNSPECIFIED 1058 case NotificationChannelState_FieldPathSelectorError: 1059 return (*NotificationChannel_State_Error)(nil) 1060 default: 1061 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fp.selector)) 1062 } 1063 } 1064 1065 func (fp *NotificationChannelState_FieldTerminalPath) ClearValue(item *NotificationChannel_State) { 1066 if item != nil { 1067 switch fp.selector { 1068 case NotificationChannelState_FieldPathSelectorStatus: 1069 item.Status = NotificationChannel_State_STATE_UNSPECIFIED 1070 case NotificationChannelState_FieldPathSelectorError: 1071 item.Error = nil 1072 default: 1073 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fp.selector)) 1074 } 1075 } 1076 } 1077 1078 func (fp *NotificationChannelState_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1079 fp.ClearValue(item.(*NotificationChannel_State)) 1080 } 1081 1082 // IsLeaf - whether field path is holds simple value 1083 func (fp *NotificationChannelState_FieldTerminalPath) IsLeaf() bool { 1084 return fp.selector == NotificationChannelState_FieldPathSelectorStatus 1085 } 1086 1087 func (fp *NotificationChannelState_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1088 return []gotenobject.FieldPath{fp} 1089 } 1090 1091 func (fp *NotificationChannelState_FieldTerminalPath) WithIValue(value interface{}) NotificationChannelState_FieldPathValue { 1092 switch fp.selector { 1093 case NotificationChannelState_FieldPathSelectorStatus: 1094 return &NotificationChannelState_FieldTerminalPathValue{NotificationChannelState_FieldTerminalPath: *fp, value: value.(NotificationChannel_State_Status)} 1095 case NotificationChannelState_FieldPathSelectorError: 1096 return &NotificationChannelState_FieldTerminalPathValue{NotificationChannelState_FieldTerminalPath: *fp, value: value.(*NotificationChannel_State_Error)} 1097 default: 1098 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fp.selector)) 1099 } 1100 } 1101 1102 func (fp *NotificationChannelState_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1103 return fp.WithIValue(value) 1104 } 1105 1106 func (fp *NotificationChannelState_FieldTerminalPath) WithIArrayOfValues(values interface{}) NotificationChannelState_FieldPathArrayOfValues { 1107 fpaov := &NotificationChannelState_FieldTerminalPathArrayOfValues{NotificationChannelState_FieldTerminalPath: *fp} 1108 switch fp.selector { 1109 case NotificationChannelState_FieldPathSelectorStatus: 1110 return &NotificationChannelState_FieldTerminalPathArrayOfValues{NotificationChannelState_FieldTerminalPath: *fp, values: values.([]NotificationChannel_State_Status)} 1111 case NotificationChannelState_FieldPathSelectorError: 1112 return &NotificationChannelState_FieldTerminalPathArrayOfValues{NotificationChannelState_FieldTerminalPath: *fp, values: values.([]*NotificationChannel_State_Error)} 1113 default: 1114 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fp.selector)) 1115 } 1116 return fpaov 1117 } 1118 1119 func (fp *NotificationChannelState_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1120 return fp.WithIArrayOfValues(values) 1121 } 1122 1123 func (fp *NotificationChannelState_FieldTerminalPath) WithIArrayItemValue(value interface{}) NotificationChannelState_FieldPathArrayItemValue { 1124 switch fp.selector { 1125 default: 1126 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fp.selector)) 1127 } 1128 } 1129 1130 func (fp *NotificationChannelState_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1131 return fp.WithIArrayItemValue(value) 1132 } 1133 1134 type NotificationChannelState_FieldSubPath struct { 1135 selector NotificationChannelState_FieldPathSelector 1136 subPath gotenobject.FieldPath 1137 } 1138 1139 var _ NotificationChannelState_FieldPath = (*NotificationChannelState_FieldSubPath)(nil) 1140 1141 func (fps *NotificationChannelState_FieldSubPath) Selector() NotificationChannelState_FieldPathSelector { 1142 return fps.selector 1143 } 1144 func (fps *NotificationChannelState_FieldSubPath) AsErrorSubPath() (NotificationChannelStateError_FieldPath, bool) { 1145 res, ok := fps.subPath.(NotificationChannelStateError_FieldPath) 1146 return res, ok 1147 } 1148 1149 // String returns path representation in proto convention 1150 func (fps *NotificationChannelState_FieldSubPath) String() string { 1151 return fps.selector.String() + "." + fps.subPath.String() 1152 } 1153 1154 // JSONString returns path representation is JSON convention 1155 func (fps *NotificationChannelState_FieldSubPath) JSONString() string { 1156 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 1157 } 1158 1159 // Get returns all values pointed by selected field from source NotificationChannel_State 1160 func (fps *NotificationChannelState_FieldSubPath) Get(source *NotificationChannel_State) (values []interface{}) { 1161 switch fps.selector { 1162 case NotificationChannelState_FieldPathSelectorError: 1163 values = append(values, fps.subPath.GetRaw(source.GetError())...) 1164 default: 1165 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fps.selector)) 1166 } 1167 return 1168 } 1169 1170 func (fps *NotificationChannelState_FieldSubPath) GetRaw(source proto.Message) []interface{} { 1171 return fps.Get(source.(*NotificationChannel_State)) 1172 } 1173 1174 // GetSingle returns value of selected field from source NotificationChannel_State 1175 func (fps *NotificationChannelState_FieldSubPath) GetSingle(source *NotificationChannel_State) (interface{}, bool) { 1176 switch fps.selector { 1177 case NotificationChannelState_FieldPathSelectorError: 1178 if source.GetError() == nil { 1179 return nil, false 1180 } 1181 return fps.subPath.GetSingleRaw(source.GetError()) 1182 default: 1183 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fps.selector)) 1184 } 1185 } 1186 1187 func (fps *NotificationChannelState_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1188 return fps.GetSingle(source.(*NotificationChannel_State)) 1189 } 1190 1191 // GetDefault returns a default value of the field type 1192 func (fps *NotificationChannelState_FieldSubPath) GetDefault() interface{} { 1193 return fps.subPath.GetDefault() 1194 } 1195 1196 func (fps *NotificationChannelState_FieldSubPath) ClearValue(item *NotificationChannel_State) { 1197 if item != nil { 1198 switch fps.selector { 1199 case NotificationChannelState_FieldPathSelectorError: 1200 fps.subPath.ClearValueRaw(item.Error) 1201 default: 1202 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fps.selector)) 1203 } 1204 } 1205 } 1206 1207 func (fps *NotificationChannelState_FieldSubPath) ClearValueRaw(item proto.Message) { 1208 fps.ClearValue(item.(*NotificationChannel_State)) 1209 } 1210 1211 // IsLeaf - whether field path is holds simple value 1212 func (fps *NotificationChannelState_FieldSubPath) IsLeaf() bool { 1213 return fps.subPath.IsLeaf() 1214 } 1215 1216 func (fps *NotificationChannelState_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1217 iPaths := []gotenobject.FieldPath{&NotificationChannelState_FieldTerminalPath{selector: fps.selector}} 1218 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 1219 return iPaths 1220 } 1221 1222 func (fps *NotificationChannelState_FieldSubPath) WithIValue(value interface{}) NotificationChannelState_FieldPathValue { 1223 return &NotificationChannelState_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 1224 } 1225 1226 func (fps *NotificationChannelState_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1227 return fps.WithIValue(value) 1228 } 1229 1230 func (fps *NotificationChannelState_FieldSubPath) WithIArrayOfValues(values interface{}) NotificationChannelState_FieldPathArrayOfValues { 1231 return &NotificationChannelState_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 1232 } 1233 1234 func (fps *NotificationChannelState_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1235 return fps.WithIArrayOfValues(values) 1236 } 1237 1238 func (fps *NotificationChannelState_FieldSubPath) WithIArrayItemValue(value interface{}) NotificationChannelState_FieldPathArrayItemValue { 1239 return &NotificationChannelState_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 1240 } 1241 1242 func (fps *NotificationChannelState_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1243 return fps.WithIArrayItemValue(value) 1244 } 1245 1246 // NotificationChannelState_FieldPathValue allows storing values for State fields according to their type 1247 type NotificationChannelState_FieldPathValue interface { 1248 NotificationChannelState_FieldPath 1249 gotenobject.FieldPathValue 1250 SetTo(target **NotificationChannel_State) 1251 CompareWith(*NotificationChannel_State) (cmp int, comparable bool) 1252 } 1253 1254 func ParseNotificationChannelState_FieldPathValue(pathStr, valueStr string) (NotificationChannelState_FieldPathValue, error) { 1255 fp, err := ParseNotificationChannelState_FieldPath(pathStr) 1256 if err != nil { 1257 return nil, err 1258 } 1259 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1260 if err != nil { 1261 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path value from %s: %v", valueStr, err) 1262 } 1263 return fpv.(NotificationChannelState_FieldPathValue), nil 1264 } 1265 1266 func MustParseNotificationChannelState_FieldPathValue(pathStr, valueStr string) NotificationChannelState_FieldPathValue { 1267 fpv, err := ParseNotificationChannelState_FieldPathValue(pathStr, valueStr) 1268 if err != nil { 1269 panic(err) 1270 } 1271 return fpv 1272 } 1273 1274 type NotificationChannelState_FieldTerminalPathValue struct { 1275 NotificationChannelState_FieldTerminalPath 1276 value interface{} 1277 } 1278 1279 var _ NotificationChannelState_FieldPathValue = (*NotificationChannelState_FieldTerminalPathValue)(nil) 1280 1281 // GetRawValue returns raw value stored under selected path for 'State' as interface{} 1282 func (fpv *NotificationChannelState_FieldTerminalPathValue) GetRawValue() interface{} { 1283 return fpv.value 1284 } 1285 func (fpv *NotificationChannelState_FieldTerminalPathValue) AsStatusValue() (NotificationChannel_State_Status, bool) { 1286 res, ok := fpv.value.(NotificationChannel_State_Status) 1287 return res, ok 1288 } 1289 func (fpv *NotificationChannelState_FieldTerminalPathValue) AsErrorValue() (*NotificationChannel_State_Error, bool) { 1290 res, ok := fpv.value.(*NotificationChannel_State_Error) 1291 return res, ok 1292 } 1293 1294 // SetTo stores value for selected field for object State 1295 func (fpv *NotificationChannelState_FieldTerminalPathValue) SetTo(target **NotificationChannel_State) { 1296 if *target == nil { 1297 *target = new(NotificationChannel_State) 1298 } 1299 switch fpv.selector { 1300 case NotificationChannelState_FieldPathSelectorStatus: 1301 (*target).Status = fpv.value.(NotificationChannel_State_Status) 1302 case NotificationChannelState_FieldPathSelectorError: 1303 (*target).Error = fpv.value.(*NotificationChannel_State_Error) 1304 default: 1305 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fpv.selector)) 1306 } 1307 } 1308 1309 func (fpv *NotificationChannelState_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1310 typedObject := target.(*NotificationChannel_State) 1311 fpv.SetTo(&typedObject) 1312 } 1313 1314 // CompareWith compares value in the 'NotificationChannelState_FieldTerminalPathValue' with the value under path in 'NotificationChannel_State'. 1315 func (fpv *NotificationChannelState_FieldTerminalPathValue) CompareWith(source *NotificationChannel_State) (int, bool) { 1316 switch fpv.selector { 1317 case NotificationChannelState_FieldPathSelectorStatus: 1318 leftValue := fpv.value.(NotificationChannel_State_Status) 1319 rightValue := source.GetStatus() 1320 if (leftValue) == (rightValue) { 1321 return 0, true 1322 } else if (leftValue) < (rightValue) { 1323 return -1, true 1324 } else { 1325 return 1, true 1326 } 1327 case NotificationChannelState_FieldPathSelectorError: 1328 return 0, false 1329 default: 1330 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fpv.selector)) 1331 } 1332 } 1333 1334 func (fpv *NotificationChannelState_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1335 return fpv.CompareWith(source.(*NotificationChannel_State)) 1336 } 1337 1338 type NotificationChannelState_FieldSubPathValue struct { 1339 NotificationChannelState_FieldPath 1340 subPathValue gotenobject.FieldPathValue 1341 } 1342 1343 var _ NotificationChannelState_FieldPathValue = (*NotificationChannelState_FieldSubPathValue)(nil) 1344 1345 func (fpvs *NotificationChannelState_FieldSubPathValue) AsErrorPathValue() (NotificationChannelStateError_FieldPathValue, bool) { 1346 res, ok := fpvs.subPathValue.(NotificationChannelStateError_FieldPathValue) 1347 return res, ok 1348 } 1349 1350 func (fpvs *NotificationChannelState_FieldSubPathValue) SetTo(target **NotificationChannel_State) { 1351 if *target == nil { 1352 *target = new(NotificationChannel_State) 1353 } 1354 switch fpvs.Selector() { 1355 case NotificationChannelState_FieldPathSelectorError: 1356 fpvs.subPathValue.(NotificationChannelStateError_FieldPathValue).SetTo(&(*target).Error) 1357 default: 1358 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fpvs.Selector())) 1359 } 1360 } 1361 1362 func (fpvs *NotificationChannelState_FieldSubPathValue) SetToRaw(target proto.Message) { 1363 typedObject := target.(*NotificationChannel_State) 1364 fpvs.SetTo(&typedObject) 1365 } 1366 1367 func (fpvs *NotificationChannelState_FieldSubPathValue) GetRawValue() interface{} { 1368 return fpvs.subPathValue.GetRawValue() 1369 } 1370 1371 func (fpvs *NotificationChannelState_FieldSubPathValue) CompareWith(source *NotificationChannel_State) (int, bool) { 1372 switch fpvs.Selector() { 1373 case NotificationChannelState_FieldPathSelectorError: 1374 return fpvs.subPathValue.(NotificationChannelStateError_FieldPathValue).CompareWith(source.GetError()) 1375 default: 1376 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fpvs.Selector())) 1377 } 1378 } 1379 1380 func (fpvs *NotificationChannelState_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1381 return fpvs.CompareWith(source.(*NotificationChannel_State)) 1382 } 1383 1384 // NotificationChannelState_FieldPathArrayItemValue allows storing single item in Path-specific values for State according to their type 1385 // Present only for array (repeated) types. 1386 type NotificationChannelState_FieldPathArrayItemValue interface { 1387 gotenobject.FieldPathArrayItemValue 1388 NotificationChannelState_FieldPath 1389 ContainsValue(*NotificationChannel_State) bool 1390 } 1391 1392 // ParseNotificationChannelState_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1393 func ParseNotificationChannelState_FieldPathArrayItemValue(pathStr, valueStr string) (NotificationChannelState_FieldPathArrayItemValue, error) { 1394 fp, err := ParseNotificationChannelState_FieldPath(pathStr) 1395 if err != nil { 1396 return nil, err 1397 } 1398 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1399 if err != nil { 1400 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path array item value from %s: %v", valueStr, err) 1401 } 1402 return fpaiv.(NotificationChannelState_FieldPathArrayItemValue), nil 1403 } 1404 1405 func MustParseNotificationChannelState_FieldPathArrayItemValue(pathStr, valueStr string) NotificationChannelState_FieldPathArrayItemValue { 1406 fpaiv, err := ParseNotificationChannelState_FieldPathArrayItemValue(pathStr, valueStr) 1407 if err != nil { 1408 panic(err) 1409 } 1410 return fpaiv 1411 } 1412 1413 type NotificationChannelState_FieldTerminalPathArrayItemValue struct { 1414 NotificationChannelState_FieldTerminalPath 1415 value interface{} 1416 } 1417 1418 var _ NotificationChannelState_FieldPathArrayItemValue = (*NotificationChannelState_FieldTerminalPathArrayItemValue)(nil) 1419 1420 // GetRawValue returns stored element value for array in object NotificationChannel_State as interface{} 1421 func (fpaiv *NotificationChannelState_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1422 return fpaiv.value 1423 } 1424 1425 func (fpaiv *NotificationChannelState_FieldTerminalPathArrayItemValue) GetSingle(source *NotificationChannel_State) (interface{}, bool) { 1426 return nil, false 1427 } 1428 1429 func (fpaiv *NotificationChannelState_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1430 return fpaiv.GetSingle(source.(*NotificationChannel_State)) 1431 } 1432 1433 // Contains returns a boolean indicating if value that is being held is present in given 'State' 1434 func (fpaiv *NotificationChannelState_FieldTerminalPathArrayItemValue) ContainsValue(source *NotificationChannel_State) bool { 1435 slice := fpaiv.NotificationChannelState_FieldTerminalPath.Get(source) 1436 for _, v := range slice { 1437 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1438 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1439 return true 1440 } 1441 } else if reflect.DeepEqual(v, fpaiv.value) { 1442 return true 1443 } 1444 } 1445 return false 1446 } 1447 1448 type NotificationChannelState_FieldSubPathArrayItemValue struct { 1449 NotificationChannelState_FieldPath 1450 subPathItemValue gotenobject.FieldPathArrayItemValue 1451 } 1452 1453 // GetRawValue returns stored array item value 1454 func (fpaivs *NotificationChannelState_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 1455 return fpaivs.subPathItemValue.GetRawItemValue() 1456 } 1457 func (fpaivs *NotificationChannelState_FieldSubPathArrayItemValue) AsErrorPathItemValue() (NotificationChannelStateError_FieldPathArrayItemValue, bool) { 1458 res, ok := fpaivs.subPathItemValue.(NotificationChannelStateError_FieldPathArrayItemValue) 1459 return res, ok 1460 } 1461 1462 // Contains returns a boolean indicating if value that is being held is present in given 'State' 1463 func (fpaivs *NotificationChannelState_FieldSubPathArrayItemValue) ContainsValue(source *NotificationChannel_State) bool { 1464 switch fpaivs.Selector() { 1465 case NotificationChannelState_FieldPathSelectorError: 1466 return fpaivs.subPathItemValue.(NotificationChannelStateError_FieldPathArrayItemValue).ContainsValue(source.GetError()) 1467 default: 1468 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State: %d", fpaivs.Selector())) 1469 } 1470 } 1471 1472 // NotificationChannelState_FieldPathArrayOfValues allows storing slice of values for State fields according to their type 1473 type NotificationChannelState_FieldPathArrayOfValues interface { 1474 gotenobject.FieldPathArrayOfValues 1475 NotificationChannelState_FieldPath 1476 } 1477 1478 func ParseNotificationChannelState_FieldPathArrayOfValues(pathStr, valuesStr string) (NotificationChannelState_FieldPathArrayOfValues, error) { 1479 fp, err := ParseNotificationChannelState_FieldPath(pathStr) 1480 if err != nil { 1481 return nil, err 1482 } 1483 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1484 if err != nil { 1485 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path array of values from %s: %v", valuesStr, err) 1486 } 1487 return fpaov.(NotificationChannelState_FieldPathArrayOfValues), nil 1488 } 1489 1490 func MustParseNotificationChannelState_FieldPathArrayOfValues(pathStr, valuesStr string) NotificationChannelState_FieldPathArrayOfValues { 1491 fpaov, err := ParseNotificationChannelState_FieldPathArrayOfValues(pathStr, valuesStr) 1492 if err != nil { 1493 panic(err) 1494 } 1495 return fpaov 1496 } 1497 1498 type NotificationChannelState_FieldTerminalPathArrayOfValues struct { 1499 NotificationChannelState_FieldTerminalPath 1500 values interface{} 1501 } 1502 1503 var _ NotificationChannelState_FieldPathArrayOfValues = (*NotificationChannelState_FieldTerminalPathArrayOfValues)(nil) 1504 1505 func (fpaov *NotificationChannelState_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1506 switch fpaov.selector { 1507 case NotificationChannelState_FieldPathSelectorStatus: 1508 for _, v := range fpaov.values.([]NotificationChannel_State_Status) { 1509 values = append(values, v) 1510 } 1511 case NotificationChannelState_FieldPathSelectorError: 1512 for _, v := range fpaov.values.([]*NotificationChannel_State_Error) { 1513 values = append(values, v) 1514 } 1515 } 1516 return 1517 } 1518 func (fpaov *NotificationChannelState_FieldTerminalPathArrayOfValues) AsStatusArrayOfValues() ([]NotificationChannel_State_Status, bool) { 1519 res, ok := fpaov.values.([]NotificationChannel_State_Status) 1520 return res, ok 1521 } 1522 func (fpaov *NotificationChannelState_FieldTerminalPathArrayOfValues) AsErrorArrayOfValues() ([]*NotificationChannel_State_Error, bool) { 1523 res, ok := fpaov.values.([]*NotificationChannel_State_Error) 1524 return res, ok 1525 } 1526 1527 type NotificationChannelState_FieldSubPathArrayOfValues struct { 1528 NotificationChannelState_FieldPath 1529 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 1530 } 1531 1532 var _ NotificationChannelState_FieldPathArrayOfValues = (*NotificationChannelState_FieldSubPathArrayOfValues)(nil) 1533 1534 func (fpsaov *NotificationChannelState_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 1535 return fpsaov.subPathArrayOfValues.GetRawValues() 1536 } 1537 func (fpsaov *NotificationChannelState_FieldSubPathArrayOfValues) AsErrorPathArrayOfValues() (NotificationChannelStateError_FieldPathArrayOfValues, bool) { 1538 res, ok := fpsaov.subPathArrayOfValues.(NotificationChannelStateError_FieldPathArrayOfValues) 1539 return res, ok 1540 } 1541 1542 // FieldPath provides implementation to handle 1543 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 1544 type NotificationChannelStateError_FieldPath interface { 1545 gotenobject.FieldPath 1546 Selector() NotificationChannelStateError_FieldPathSelector 1547 Get(source *NotificationChannel_State_Error) []interface{} 1548 GetSingle(source *NotificationChannel_State_Error) (interface{}, bool) 1549 ClearValue(item *NotificationChannel_State_Error) 1550 1551 // Those methods build corresponding NotificationChannelStateError_FieldPathValue 1552 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1553 WithIValue(value interface{}) NotificationChannelStateError_FieldPathValue 1554 WithIArrayOfValues(values interface{}) NotificationChannelStateError_FieldPathArrayOfValues 1555 WithIArrayItemValue(value interface{}) NotificationChannelStateError_FieldPathArrayItemValue 1556 } 1557 1558 type NotificationChannelStateError_FieldPathSelector int32 1559 1560 const ( 1561 NotificationChannelStateError_FieldPathSelectorTime NotificationChannelStateError_FieldPathSelector = 0 1562 NotificationChannelStateError_FieldPathSelectorMessage NotificationChannelStateError_FieldPathSelector = 1 1563 ) 1564 1565 func (s NotificationChannelStateError_FieldPathSelector) String() string { 1566 switch s { 1567 case NotificationChannelStateError_FieldPathSelectorTime: 1568 return "time" 1569 case NotificationChannelStateError_FieldPathSelectorMessage: 1570 return "message" 1571 default: 1572 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State_Error: %d", s)) 1573 } 1574 } 1575 1576 func BuildNotificationChannelStateError_FieldPath(fp gotenobject.RawFieldPath) (NotificationChannelStateError_FieldPath, error) { 1577 if len(fp) == 0 { 1578 return nil, status.Error(codes.InvalidArgument, "empty field path for object NotificationChannel_State_Error") 1579 } 1580 if len(fp) == 1 { 1581 switch fp[0] { 1582 case "time": 1583 return &NotificationChannelStateError_FieldTerminalPath{selector: NotificationChannelStateError_FieldPathSelectorTime}, nil 1584 case "message": 1585 return &NotificationChannelStateError_FieldTerminalPath{selector: NotificationChannelStateError_FieldPathSelectorMessage}, nil 1586 } 1587 } 1588 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object NotificationChannel_State_Error", fp) 1589 } 1590 1591 func ParseNotificationChannelStateError_FieldPath(rawField string) (NotificationChannelStateError_FieldPath, error) { 1592 fp, err := gotenobject.ParseRawFieldPath(rawField) 1593 if err != nil { 1594 return nil, err 1595 } 1596 return BuildNotificationChannelStateError_FieldPath(fp) 1597 } 1598 1599 func MustParseNotificationChannelStateError_FieldPath(rawField string) NotificationChannelStateError_FieldPath { 1600 fp, err := ParseNotificationChannelStateError_FieldPath(rawField) 1601 if err != nil { 1602 panic(err) 1603 } 1604 return fp 1605 } 1606 1607 type NotificationChannelStateError_FieldTerminalPath struct { 1608 selector NotificationChannelStateError_FieldPathSelector 1609 } 1610 1611 var _ NotificationChannelStateError_FieldPath = (*NotificationChannelStateError_FieldTerminalPath)(nil) 1612 1613 func (fp *NotificationChannelStateError_FieldTerminalPath) Selector() NotificationChannelStateError_FieldPathSelector { 1614 return fp.selector 1615 } 1616 1617 // String returns path representation in proto convention 1618 func (fp *NotificationChannelStateError_FieldTerminalPath) String() string { 1619 return fp.selector.String() 1620 } 1621 1622 // JSONString returns path representation is JSON convention 1623 func (fp *NotificationChannelStateError_FieldTerminalPath) JSONString() string { 1624 return strcase.ToLowerCamel(fp.String()) 1625 } 1626 1627 // Get returns all values pointed by specific field from source NotificationChannel_State_Error 1628 func (fp *NotificationChannelStateError_FieldTerminalPath) Get(source *NotificationChannel_State_Error) (values []interface{}) { 1629 if source != nil { 1630 switch fp.selector { 1631 case NotificationChannelStateError_FieldPathSelectorTime: 1632 if source.Time != nil { 1633 values = append(values, source.Time) 1634 } 1635 case NotificationChannelStateError_FieldPathSelectorMessage: 1636 values = append(values, source.Message) 1637 default: 1638 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State_Error: %d", fp.selector)) 1639 } 1640 } 1641 return 1642 } 1643 1644 func (fp *NotificationChannelStateError_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1645 return fp.Get(source.(*NotificationChannel_State_Error)) 1646 } 1647 1648 // GetSingle returns value pointed by specific field of from source NotificationChannel_State_Error 1649 func (fp *NotificationChannelStateError_FieldTerminalPath) GetSingle(source *NotificationChannel_State_Error) (interface{}, bool) { 1650 switch fp.selector { 1651 case NotificationChannelStateError_FieldPathSelectorTime: 1652 res := source.GetTime() 1653 return res, res != nil 1654 case NotificationChannelStateError_FieldPathSelectorMessage: 1655 return source.GetMessage(), source != nil 1656 default: 1657 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State_Error: %d", fp.selector)) 1658 } 1659 } 1660 1661 func (fp *NotificationChannelStateError_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1662 return fp.GetSingle(source.(*NotificationChannel_State_Error)) 1663 } 1664 1665 // GetDefault returns a default value of the field type 1666 func (fp *NotificationChannelStateError_FieldTerminalPath) GetDefault() interface{} { 1667 switch fp.selector { 1668 case NotificationChannelStateError_FieldPathSelectorTime: 1669 return (*timestamppb.Timestamp)(nil) 1670 case NotificationChannelStateError_FieldPathSelectorMessage: 1671 return "" 1672 default: 1673 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State_Error: %d", fp.selector)) 1674 } 1675 } 1676 1677 func (fp *NotificationChannelStateError_FieldTerminalPath) ClearValue(item *NotificationChannel_State_Error) { 1678 if item != nil { 1679 switch fp.selector { 1680 case NotificationChannelStateError_FieldPathSelectorTime: 1681 item.Time = nil 1682 case NotificationChannelStateError_FieldPathSelectorMessage: 1683 item.Message = "" 1684 default: 1685 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State_Error: %d", fp.selector)) 1686 } 1687 } 1688 } 1689 1690 func (fp *NotificationChannelStateError_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1691 fp.ClearValue(item.(*NotificationChannel_State_Error)) 1692 } 1693 1694 // IsLeaf - whether field path is holds simple value 1695 func (fp *NotificationChannelStateError_FieldTerminalPath) IsLeaf() bool { 1696 return fp.selector == NotificationChannelStateError_FieldPathSelectorTime || 1697 fp.selector == NotificationChannelStateError_FieldPathSelectorMessage 1698 } 1699 1700 func (fp *NotificationChannelStateError_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1701 return []gotenobject.FieldPath{fp} 1702 } 1703 1704 func (fp *NotificationChannelStateError_FieldTerminalPath) WithIValue(value interface{}) NotificationChannelStateError_FieldPathValue { 1705 switch fp.selector { 1706 case NotificationChannelStateError_FieldPathSelectorTime: 1707 return &NotificationChannelStateError_FieldTerminalPathValue{NotificationChannelStateError_FieldTerminalPath: *fp, value: value.(*timestamppb.Timestamp)} 1708 case NotificationChannelStateError_FieldPathSelectorMessage: 1709 return &NotificationChannelStateError_FieldTerminalPathValue{NotificationChannelStateError_FieldTerminalPath: *fp, value: value.(string)} 1710 default: 1711 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State_Error: %d", fp.selector)) 1712 } 1713 } 1714 1715 func (fp *NotificationChannelStateError_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1716 return fp.WithIValue(value) 1717 } 1718 1719 func (fp *NotificationChannelStateError_FieldTerminalPath) WithIArrayOfValues(values interface{}) NotificationChannelStateError_FieldPathArrayOfValues { 1720 fpaov := &NotificationChannelStateError_FieldTerminalPathArrayOfValues{NotificationChannelStateError_FieldTerminalPath: *fp} 1721 switch fp.selector { 1722 case NotificationChannelStateError_FieldPathSelectorTime: 1723 return &NotificationChannelStateError_FieldTerminalPathArrayOfValues{NotificationChannelStateError_FieldTerminalPath: *fp, values: values.([]*timestamppb.Timestamp)} 1724 case NotificationChannelStateError_FieldPathSelectorMessage: 1725 return &NotificationChannelStateError_FieldTerminalPathArrayOfValues{NotificationChannelStateError_FieldTerminalPath: *fp, values: values.([]string)} 1726 default: 1727 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State_Error: %d", fp.selector)) 1728 } 1729 return fpaov 1730 } 1731 1732 func (fp *NotificationChannelStateError_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1733 return fp.WithIArrayOfValues(values) 1734 } 1735 1736 func (fp *NotificationChannelStateError_FieldTerminalPath) WithIArrayItemValue(value interface{}) NotificationChannelStateError_FieldPathArrayItemValue { 1737 switch fp.selector { 1738 default: 1739 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State_Error: %d", fp.selector)) 1740 } 1741 } 1742 1743 func (fp *NotificationChannelStateError_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1744 return fp.WithIArrayItemValue(value) 1745 } 1746 1747 // NotificationChannelStateError_FieldPathValue allows storing values for Error fields according to their type 1748 type NotificationChannelStateError_FieldPathValue interface { 1749 NotificationChannelStateError_FieldPath 1750 gotenobject.FieldPathValue 1751 SetTo(target **NotificationChannel_State_Error) 1752 CompareWith(*NotificationChannel_State_Error) (cmp int, comparable bool) 1753 } 1754 1755 func ParseNotificationChannelStateError_FieldPathValue(pathStr, valueStr string) (NotificationChannelStateError_FieldPathValue, error) { 1756 fp, err := ParseNotificationChannelStateError_FieldPath(pathStr) 1757 if err != nil { 1758 return nil, err 1759 } 1760 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1761 if err != nil { 1762 return nil, status.Errorf(codes.InvalidArgument, "error parsing Error field path value from %s: %v", valueStr, err) 1763 } 1764 return fpv.(NotificationChannelStateError_FieldPathValue), nil 1765 } 1766 1767 func MustParseNotificationChannelStateError_FieldPathValue(pathStr, valueStr string) NotificationChannelStateError_FieldPathValue { 1768 fpv, err := ParseNotificationChannelStateError_FieldPathValue(pathStr, valueStr) 1769 if err != nil { 1770 panic(err) 1771 } 1772 return fpv 1773 } 1774 1775 type NotificationChannelStateError_FieldTerminalPathValue struct { 1776 NotificationChannelStateError_FieldTerminalPath 1777 value interface{} 1778 } 1779 1780 var _ NotificationChannelStateError_FieldPathValue = (*NotificationChannelStateError_FieldTerminalPathValue)(nil) 1781 1782 // GetRawValue returns raw value stored under selected path for 'Error' as interface{} 1783 func (fpv *NotificationChannelStateError_FieldTerminalPathValue) GetRawValue() interface{} { 1784 return fpv.value 1785 } 1786 func (fpv *NotificationChannelStateError_FieldTerminalPathValue) AsTimeValue() (*timestamppb.Timestamp, bool) { 1787 res, ok := fpv.value.(*timestamppb.Timestamp) 1788 return res, ok 1789 } 1790 func (fpv *NotificationChannelStateError_FieldTerminalPathValue) AsMessageValue() (string, bool) { 1791 res, ok := fpv.value.(string) 1792 return res, ok 1793 } 1794 1795 // SetTo stores value for selected field for object Error 1796 func (fpv *NotificationChannelStateError_FieldTerminalPathValue) SetTo(target **NotificationChannel_State_Error) { 1797 if *target == nil { 1798 *target = new(NotificationChannel_State_Error) 1799 } 1800 switch fpv.selector { 1801 case NotificationChannelStateError_FieldPathSelectorTime: 1802 (*target).Time = fpv.value.(*timestamppb.Timestamp) 1803 case NotificationChannelStateError_FieldPathSelectorMessage: 1804 (*target).Message = fpv.value.(string) 1805 default: 1806 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State_Error: %d", fpv.selector)) 1807 } 1808 } 1809 1810 func (fpv *NotificationChannelStateError_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1811 typedObject := target.(*NotificationChannel_State_Error) 1812 fpv.SetTo(&typedObject) 1813 } 1814 1815 // CompareWith compares value in the 'NotificationChannelStateError_FieldTerminalPathValue' with the value under path in 'NotificationChannel_State_Error'. 1816 func (fpv *NotificationChannelStateError_FieldTerminalPathValue) CompareWith(source *NotificationChannel_State_Error) (int, bool) { 1817 switch fpv.selector { 1818 case NotificationChannelStateError_FieldPathSelectorTime: 1819 leftValue := fpv.value.(*timestamppb.Timestamp) 1820 rightValue := source.GetTime() 1821 if leftValue == nil { 1822 if rightValue != nil { 1823 return -1, true 1824 } 1825 return 0, true 1826 } 1827 if rightValue == nil { 1828 return 1, true 1829 } 1830 if leftValue.AsTime().Equal(rightValue.AsTime()) { 1831 return 0, true 1832 } else if leftValue.AsTime().Before(rightValue.AsTime()) { 1833 return -1, true 1834 } else { 1835 return 1, true 1836 } 1837 case NotificationChannelStateError_FieldPathSelectorMessage: 1838 leftValue := fpv.value.(string) 1839 rightValue := source.GetMessage() 1840 if (leftValue) == (rightValue) { 1841 return 0, true 1842 } else if (leftValue) < (rightValue) { 1843 return -1, true 1844 } else { 1845 return 1, true 1846 } 1847 default: 1848 panic(fmt.Sprintf("Invalid selector for NotificationChannel_State_Error: %d", fpv.selector)) 1849 } 1850 } 1851 1852 func (fpv *NotificationChannelStateError_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1853 return fpv.CompareWith(source.(*NotificationChannel_State_Error)) 1854 } 1855 1856 // NotificationChannelStateError_FieldPathArrayItemValue allows storing single item in Path-specific values for Error according to their type 1857 // Present only for array (repeated) types. 1858 type NotificationChannelStateError_FieldPathArrayItemValue interface { 1859 gotenobject.FieldPathArrayItemValue 1860 NotificationChannelStateError_FieldPath 1861 ContainsValue(*NotificationChannel_State_Error) bool 1862 } 1863 1864 // ParseNotificationChannelStateError_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1865 func ParseNotificationChannelStateError_FieldPathArrayItemValue(pathStr, valueStr string) (NotificationChannelStateError_FieldPathArrayItemValue, error) { 1866 fp, err := ParseNotificationChannelStateError_FieldPath(pathStr) 1867 if err != nil { 1868 return nil, err 1869 } 1870 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1871 if err != nil { 1872 return nil, status.Errorf(codes.InvalidArgument, "error parsing Error field path array item value from %s: %v", valueStr, err) 1873 } 1874 return fpaiv.(NotificationChannelStateError_FieldPathArrayItemValue), nil 1875 } 1876 1877 func MustParseNotificationChannelStateError_FieldPathArrayItemValue(pathStr, valueStr string) NotificationChannelStateError_FieldPathArrayItemValue { 1878 fpaiv, err := ParseNotificationChannelStateError_FieldPathArrayItemValue(pathStr, valueStr) 1879 if err != nil { 1880 panic(err) 1881 } 1882 return fpaiv 1883 } 1884 1885 type NotificationChannelStateError_FieldTerminalPathArrayItemValue struct { 1886 NotificationChannelStateError_FieldTerminalPath 1887 value interface{} 1888 } 1889 1890 var _ NotificationChannelStateError_FieldPathArrayItemValue = (*NotificationChannelStateError_FieldTerminalPathArrayItemValue)(nil) 1891 1892 // GetRawValue returns stored element value for array in object NotificationChannel_State_Error as interface{} 1893 func (fpaiv *NotificationChannelStateError_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1894 return fpaiv.value 1895 } 1896 1897 func (fpaiv *NotificationChannelStateError_FieldTerminalPathArrayItemValue) GetSingle(source *NotificationChannel_State_Error) (interface{}, bool) { 1898 return nil, false 1899 } 1900 1901 func (fpaiv *NotificationChannelStateError_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1902 return fpaiv.GetSingle(source.(*NotificationChannel_State_Error)) 1903 } 1904 1905 // Contains returns a boolean indicating if value that is being held is present in given 'Error' 1906 func (fpaiv *NotificationChannelStateError_FieldTerminalPathArrayItemValue) ContainsValue(source *NotificationChannel_State_Error) bool { 1907 slice := fpaiv.NotificationChannelStateError_FieldTerminalPath.Get(source) 1908 for _, v := range slice { 1909 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1910 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1911 return true 1912 } 1913 } else if reflect.DeepEqual(v, fpaiv.value) { 1914 return true 1915 } 1916 } 1917 return false 1918 } 1919 1920 // NotificationChannelStateError_FieldPathArrayOfValues allows storing slice of values for Error fields according to their type 1921 type NotificationChannelStateError_FieldPathArrayOfValues interface { 1922 gotenobject.FieldPathArrayOfValues 1923 NotificationChannelStateError_FieldPath 1924 } 1925 1926 func ParseNotificationChannelStateError_FieldPathArrayOfValues(pathStr, valuesStr string) (NotificationChannelStateError_FieldPathArrayOfValues, error) { 1927 fp, err := ParseNotificationChannelStateError_FieldPath(pathStr) 1928 if err != nil { 1929 return nil, err 1930 } 1931 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1932 if err != nil { 1933 return nil, status.Errorf(codes.InvalidArgument, "error parsing Error field path array of values from %s: %v", valuesStr, err) 1934 } 1935 return fpaov.(NotificationChannelStateError_FieldPathArrayOfValues), nil 1936 } 1937 1938 func MustParseNotificationChannelStateError_FieldPathArrayOfValues(pathStr, valuesStr string) NotificationChannelStateError_FieldPathArrayOfValues { 1939 fpaov, err := ParseNotificationChannelStateError_FieldPathArrayOfValues(pathStr, valuesStr) 1940 if err != nil { 1941 panic(err) 1942 } 1943 return fpaov 1944 } 1945 1946 type NotificationChannelStateError_FieldTerminalPathArrayOfValues struct { 1947 NotificationChannelStateError_FieldTerminalPath 1948 values interface{} 1949 } 1950 1951 var _ NotificationChannelStateError_FieldPathArrayOfValues = (*NotificationChannelStateError_FieldTerminalPathArrayOfValues)(nil) 1952 1953 func (fpaov *NotificationChannelStateError_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1954 switch fpaov.selector { 1955 case NotificationChannelStateError_FieldPathSelectorTime: 1956 for _, v := range fpaov.values.([]*timestamppb.Timestamp) { 1957 values = append(values, v) 1958 } 1959 case NotificationChannelStateError_FieldPathSelectorMessage: 1960 for _, v := range fpaov.values.([]string) { 1961 values = append(values, v) 1962 } 1963 } 1964 return 1965 } 1966 func (fpaov *NotificationChannelStateError_FieldTerminalPathArrayOfValues) AsTimeArrayOfValues() ([]*timestamppb.Timestamp, bool) { 1967 res, ok := fpaov.values.([]*timestamppb.Timestamp) 1968 return res, ok 1969 } 1970 func (fpaov *NotificationChannelStateError_FieldTerminalPathArrayOfValues) AsMessageArrayOfValues() ([]string, bool) { 1971 res, ok := fpaov.values.([]string) 1972 return res, ok 1973 }