github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v4/alerting_policy/alerting_policy.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/monitoring/proto/v4/alerting_policy.proto 3 // DO NOT EDIT!!! 4 5 package alerting_policy 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 notification_channel "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/notification_channel" 27 project "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/project" 28 meta "github.com/cloudwan/goten-sdk/types/meta" 29 ) 30 31 // ensure the imports are used 32 var ( 33 _ = new(json.Marshaler) 34 _ = new(fmt.Stringer) 35 _ = reflect.DeepEqual 36 _ = strings.Builder{} 37 _ = time.Second 38 39 _ = strcase.ToLowerCamel 40 _ = codes.NotFound 41 _ = status.Status{} 42 _ = protojson.UnmarshalOptions{} 43 _ = new(proto.Message) 44 _ = protoregistry.GlobalTypes 45 46 _ = new(gotenobject.FieldPath) 47 ) 48 49 // make sure we're using proto imports 50 var ( 51 _ = ¬ification_channel.NotificationChannel{} 52 _ = &project.Project{} 53 _ = &meta.Meta{} 54 ) 55 56 // FieldPath provides implementation to handle 57 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 58 type AlertingPolicy_FieldPath interface { 59 gotenobject.FieldPath 60 Selector() AlertingPolicy_FieldPathSelector 61 Get(source *AlertingPolicy) []interface{} 62 GetSingle(source *AlertingPolicy) (interface{}, bool) 63 ClearValue(item *AlertingPolicy) 64 65 // Those methods build corresponding AlertingPolicy_FieldPathValue 66 // (or array of values) and holds passed value. Panics if injected type is incorrect. 67 WithIValue(value interface{}) AlertingPolicy_FieldPathValue 68 WithIArrayOfValues(values interface{}) AlertingPolicy_FieldPathArrayOfValues 69 WithIArrayItemValue(value interface{}) AlertingPolicy_FieldPathArrayItemValue 70 } 71 72 type AlertingPolicy_FieldPathSelector int32 73 74 const ( 75 AlertingPolicy_FieldPathSelectorName AlertingPolicy_FieldPathSelector = 0 76 AlertingPolicy_FieldPathSelectorMetadata AlertingPolicy_FieldPathSelector = 1 77 AlertingPolicy_FieldPathSelectorDisplayName AlertingPolicy_FieldPathSelector = 2 78 AlertingPolicy_FieldPathSelectorDescription AlertingPolicy_FieldPathSelector = 3 79 AlertingPolicy_FieldPathSelectorDocumentation AlertingPolicy_FieldPathSelector = 4 80 AlertingPolicy_FieldPathSelectorSpec AlertingPolicy_FieldPathSelector = 5 81 AlertingPolicy_FieldPathSelectorState AlertingPolicy_FieldPathSelector = 6 82 ) 83 84 func (s AlertingPolicy_FieldPathSelector) String() string { 85 switch s { 86 case AlertingPolicy_FieldPathSelectorName: 87 return "name" 88 case AlertingPolicy_FieldPathSelectorMetadata: 89 return "metadata" 90 case AlertingPolicy_FieldPathSelectorDisplayName: 91 return "display_name" 92 case AlertingPolicy_FieldPathSelectorDescription: 93 return "description" 94 case AlertingPolicy_FieldPathSelectorDocumentation: 95 return "documentation" 96 case AlertingPolicy_FieldPathSelectorSpec: 97 return "spec" 98 case AlertingPolicy_FieldPathSelectorState: 99 return "state" 100 default: 101 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", s)) 102 } 103 } 104 105 func BuildAlertingPolicy_FieldPath(fp gotenobject.RawFieldPath) (AlertingPolicy_FieldPath, error) { 106 if len(fp) == 0 { 107 return nil, status.Error(codes.InvalidArgument, "empty field path for object AlertingPolicy") 108 } 109 if len(fp) == 1 { 110 switch fp[0] { 111 case "name": 112 return &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorName}, nil 113 case "metadata": 114 return &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorMetadata}, nil 115 case "display_name", "displayName", "display-name": 116 return &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorDisplayName}, nil 117 case "description": 118 return &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorDescription}, nil 119 case "documentation": 120 return &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorDocumentation}, nil 121 case "spec": 122 return &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorSpec}, nil 123 case "state": 124 return &AlertingPolicy_FieldTerminalPath{selector: AlertingPolicy_FieldPathSelectorState}, nil 125 } 126 } else { 127 switch fp[0] { 128 case "metadata": 129 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 130 return nil, err 131 } else { 132 return &AlertingPolicy_FieldSubPath{selector: AlertingPolicy_FieldPathSelectorMetadata, subPath: subpath}, nil 133 } 134 case "documentation": 135 if subpath, err := BuildAlertingPolicyDocumentation_FieldPath(fp[1:]); err != nil { 136 return nil, err 137 } else { 138 return &AlertingPolicy_FieldSubPath{selector: AlertingPolicy_FieldPathSelectorDocumentation, subPath: subpath}, nil 139 } 140 case "spec": 141 if subpath, err := BuildAlertingPolicySpec_FieldPath(fp[1:]); err != nil { 142 return nil, err 143 } else { 144 return &AlertingPolicy_FieldSubPath{selector: AlertingPolicy_FieldPathSelectorSpec, subPath: subpath}, nil 145 } 146 case "state": 147 if subpath, err := BuildAlertingPolicyState_FieldPath(fp[1:]); err != nil { 148 return nil, err 149 } else { 150 return &AlertingPolicy_FieldSubPath{selector: AlertingPolicy_FieldPathSelectorState, subPath: subpath}, nil 151 } 152 } 153 } 154 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object AlertingPolicy", fp) 155 } 156 157 func ParseAlertingPolicy_FieldPath(rawField string) (AlertingPolicy_FieldPath, error) { 158 fp, err := gotenobject.ParseRawFieldPath(rawField) 159 if err != nil { 160 return nil, err 161 } 162 return BuildAlertingPolicy_FieldPath(fp) 163 } 164 165 func MustParseAlertingPolicy_FieldPath(rawField string) AlertingPolicy_FieldPath { 166 fp, err := ParseAlertingPolicy_FieldPath(rawField) 167 if err != nil { 168 panic(err) 169 } 170 return fp 171 } 172 173 type AlertingPolicy_FieldTerminalPath struct { 174 selector AlertingPolicy_FieldPathSelector 175 } 176 177 var _ AlertingPolicy_FieldPath = (*AlertingPolicy_FieldTerminalPath)(nil) 178 179 func (fp *AlertingPolicy_FieldTerminalPath) Selector() AlertingPolicy_FieldPathSelector { 180 return fp.selector 181 } 182 183 // String returns path representation in proto convention 184 func (fp *AlertingPolicy_FieldTerminalPath) String() string { 185 return fp.selector.String() 186 } 187 188 // JSONString returns path representation is JSON convention 189 func (fp *AlertingPolicy_FieldTerminalPath) JSONString() string { 190 return strcase.ToLowerCamel(fp.String()) 191 } 192 193 // Get returns all values pointed by specific field from source AlertingPolicy 194 func (fp *AlertingPolicy_FieldTerminalPath) Get(source *AlertingPolicy) (values []interface{}) { 195 if source != nil { 196 switch fp.selector { 197 case AlertingPolicy_FieldPathSelectorName: 198 if source.Name != nil { 199 values = append(values, source.Name) 200 } 201 case AlertingPolicy_FieldPathSelectorMetadata: 202 if source.Metadata != nil { 203 values = append(values, source.Metadata) 204 } 205 case AlertingPolicy_FieldPathSelectorDisplayName: 206 values = append(values, source.DisplayName) 207 case AlertingPolicy_FieldPathSelectorDescription: 208 values = append(values, source.Description) 209 case AlertingPolicy_FieldPathSelectorDocumentation: 210 if source.Documentation != nil { 211 values = append(values, source.Documentation) 212 } 213 case AlertingPolicy_FieldPathSelectorSpec: 214 if source.Spec != nil { 215 values = append(values, source.Spec) 216 } 217 case AlertingPolicy_FieldPathSelectorState: 218 if source.State != nil { 219 values = append(values, source.State) 220 } 221 default: 222 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fp.selector)) 223 } 224 } 225 return 226 } 227 228 func (fp *AlertingPolicy_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 229 return fp.Get(source.(*AlertingPolicy)) 230 } 231 232 // GetSingle returns value pointed by specific field of from source AlertingPolicy 233 func (fp *AlertingPolicy_FieldTerminalPath) GetSingle(source *AlertingPolicy) (interface{}, bool) { 234 switch fp.selector { 235 case AlertingPolicy_FieldPathSelectorName: 236 res := source.GetName() 237 return res, res != nil 238 case AlertingPolicy_FieldPathSelectorMetadata: 239 res := source.GetMetadata() 240 return res, res != nil 241 case AlertingPolicy_FieldPathSelectorDisplayName: 242 return source.GetDisplayName(), source != nil 243 case AlertingPolicy_FieldPathSelectorDescription: 244 return source.GetDescription(), source != nil 245 case AlertingPolicy_FieldPathSelectorDocumentation: 246 res := source.GetDocumentation() 247 return res, res != nil 248 case AlertingPolicy_FieldPathSelectorSpec: 249 res := source.GetSpec() 250 return res, res != nil 251 case AlertingPolicy_FieldPathSelectorState: 252 res := source.GetState() 253 return res, res != nil 254 default: 255 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fp.selector)) 256 } 257 } 258 259 func (fp *AlertingPolicy_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 260 return fp.GetSingle(source.(*AlertingPolicy)) 261 } 262 263 // GetDefault returns a default value of the field type 264 func (fp *AlertingPolicy_FieldTerminalPath) GetDefault() interface{} { 265 switch fp.selector { 266 case AlertingPolicy_FieldPathSelectorName: 267 return (*Name)(nil) 268 case AlertingPolicy_FieldPathSelectorMetadata: 269 return (*meta.Meta)(nil) 270 case AlertingPolicy_FieldPathSelectorDisplayName: 271 return "" 272 case AlertingPolicy_FieldPathSelectorDescription: 273 return "" 274 case AlertingPolicy_FieldPathSelectorDocumentation: 275 return (*AlertingPolicy_Documentation)(nil) 276 case AlertingPolicy_FieldPathSelectorSpec: 277 return (*AlertingPolicy_Spec)(nil) 278 case AlertingPolicy_FieldPathSelectorState: 279 return (*AlertingPolicy_State)(nil) 280 default: 281 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fp.selector)) 282 } 283 } 284 285 func (fp *AlertingPolicy_FieldTerminalPath) ClearValue(item *AlertingPolicy) { 286 if item != nil { 287 switch fp.selector { 288 case AlertingPolicy_FieldPathSelectorName: 289 item.Name = nil 290 case AlertingPolicy_FieldPathSelectorMetadata: 291 item.Metadata = nil 292 case AlertingPolicy_FieldPathSelectorDisplayName: 293 item.DisplayName = "" 294 case AlertingPolicy_FieldPathSelectorDescription: 295 item.Description = "" 296 case AlertingPolicy_FieldPathSelectorDocumentation: 297 item.Documentation = nil 298 case AlertingPolicy_FieldPathSelectorSpec: 299 item.Spec = nil 300 case AlertingPolicy_FieldPathSelectorState: 301 item.State = nil 302 default: 303 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fp.selector)) 304 } 305 } 306 } 307 308 func (fp *AlertingPolicy_FieldTerminalPath) ClearValueRaw(item proto.Message) { 309 fp.ClearValue(item.(*AlertingPolicy)) 310 } 311 312 // IsLeaf - whether field path is holds simple value 313 func (fp *AlertingPolicy_FieldTerminalPath) IsLeaf() bool { 314 return fp.selector == AlertingPolicy_FieldPathSelectorName || 315 fp.selector == AlertingPolicy_FieldPathSelectorDisplayName || 316 fp.selector == AlertingPolicy_FieldPathSelectorDescription 317 } 318 319 func (fp *AlertingPolicy_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 320 return []gotenobject.FieldPath{fp} 321 } 322 323 func (fp *AlertingPolicy_FieldTerminalPath) WithIValue(value interface{}) AlertingPolicy_FieldPathValue { 324 switch fp.selector { 325 case AlertingPolicy_FieldPathSelectorName: 326 return &AlertingPolicy_FieldTerminalPathValue{AlertingPolicy_FieldTerminalPath: *fp, value: value.(*Name)} 327 case AlertingPolicy_FieldPathSelectorMetadata: 328 return &AlertingPolicy_FieldTerminalPathValue{AlertingPolicy_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 329 case AlertingPolicy_FieldPathSelectorDisplayName: 330 return &AlertingPolicy_FieldTerminalPathValue{AlertingPolicy_FieldTerminalPath: *fp, value: value.(string)} 331 case AlertingPolicy_FieldPathSelectorDescription: 332 return &AlertingPolicy_FieldTerminalPathValue{AlertingPolicy_FieldTerminalPath: *fp, value: value.(string)} 333 case AlertingPolicy_FieldPathSelectorDocumentation: 334 return &AlertingPolicy_FieldTerminalPathValue{AlertingPolicy_FieldTerminalPath: *fp, value: value.(*AlertingPolicy_Documentation)} 335 case AlertingPolicy_FieldPathSelectorSpec: 336 return &AlertingPolicy_FieldTerminalPathValue{AlertingPolicy_FieldTerminalPath: *fp, value: value.(*AlertingPolicy_Spec)} 337 case AlertingPolicy_FieldPathSelectorState: 338 return &AlertingPolicy_FieldTerminalPathValue{AlertingPolicy_FieldTerminalPath: *fp, value: value.(*AlertingPolicy_State)} 339 default: 340 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fp.selector)) 341 } 342 } 343 344 func (fp *AlertingPolicy_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 345 return fp.WithIValue(value) 346 } 347 348 func (fp *AlertingPolicy_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertingPolicy_FieldPathArrayOfValues { 349 fpaov := &AlertingPolicy_FieldTerminalPathArrayOfValues{AlertingPolicy_FieldTerminalPath: *fp} 350 switch fp.selector { 351 case AlertingPolicy_FieldPathSelectorName: 352 return &AlertingPolicy_FieldTerminalPathArrayOfValues{AlertingPolicy_FieldTerminalPath: *fp, values: values.([]*Name)} 353 case AlertingPolicy_FieldPathSelectorMetadata: 354 return &AlertingPolicy_FieldTerminalPathArrayOfValues{AlertingPolicy_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 355 case AlertingPolicy_FieldPathSelectorDisplayName: 356 return &AlertingPolicy_FieldTerminalPathArrayOfValues{AlertingPolicy_FieldTerminalPath: *fp, values: values.([]string)} 357 case AlertingPolicy_FieldPathSelectorDescription: 358 return &AlertingPolicy_FieldTerminalPathArrayOfValues{AlertingPolicy_FieldTerminalPath: *fp, values: values.([]string)} 359 case AlertingPolicy_FieldPathSelectorDocumentation: 360 return &AlertingPolicy_FieldTerminalPathArrayOfValues{AlertingPolicy_FieldTerminalPath: *fp, values: values.([]*AlertingPolicy_Documentation)} 361 case AlertingPolicy_FieldPathSelectorSpec: 362 return &AlertingPolicy_FieldTerminalPathArrayOfValues{AlertingPolicy_FieldTerminalPath: *fp, values: values.([]*AlertingPolicy_Spec)} 363 case AlertingPolicy_FieldPathSelectorState: 364 return &AlertingPolicy_FieldTerminalPathArrayOfValues{AlertingPolicy_FieldTerminalPath: *fp, values: values.([]*AlertingPolicy_State)} 365 default: 366 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fp.selector)) 367 } 368 return fpaov 369 } 370 371 func (fp *AlertingPolicy_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 372 return fp.WithIArrayOfValues(values) 373 } 374 375 func (fp *AlertingPolicy_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertingPolicy_FieldPathArrayItemValue { 376 switch fp.selector { 377 default: 378 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fp.selector)) 379 } 380 } 381 382 func (fp *AlertingPolicy_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 383 return fp.WithIArrayItemValue(value) 384 } 385 386 type AlertingPolicy_FieldSubPath struct { 387 selector AlertingPolicy_FieldPathSelector 388 subPath gotenobject.FieldPath 389 } 390 391 var _ AlertingPolicy_FieldPath = (*AlertingPolicy_FieldSubPath)(nil) 392 393 func (fps *AlertingPolicy_FieldSubPath) Selector() AlertingPolicy_FieldPathSelector { 394 return fps.selector 395 } 396 func (fps *AlertingPolicy_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 397 res, ok := fps.subPath.(meta.Meta_FieldPath) 398 return res, ok 399 } 400 func (fps *AlertingPolicy_FieldSubPath) AsDocumentationSubPath() (AlertingPolicyDocumentation_FieldPath, bool) { 401 res, ok := fps.subPath.(AlertingPolicyDocumentation_FieldPath) 402 return res, ok 403 } 404 func (fps *AlertingPolicy_FieldSubPath) AsSpecSubPath() (AlertingPolicySpec_FieldPath, bool) { 405 res, ok := fps.subPath.(AlertingPolicySpec_FieldPath) 406 return res, ok 407 } 408 func (fps *AlertingPolicy_FieldSubPath) AsStateSubPath() (AlertingPolicyState_FieldPath, bool) { 409 res, ok := fps.subPath.(AlertingPolicyState_FieldPath) 410 return res, ok 411 } 412 413 // String returns path representation in proto convention 414 func (fps *AlertingPolicy_FieldSubPath) String() string { 415 return fps.selector.String() + "." + fps.subPath.String() 416 } 417 418 // JSONString returns path representation is JSON convention 419 func (fps *AlertingPolicy_FieldSubPath) JSONString() string { 420 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 421 } 422 423 // Get returns all values pointed by selected field from source AlertingPolicy 424 func (fps *AlertingPolicy_FieldSubPath) Get(source *AlertingPolicy) (values []interface{}) { 425 switch fps.selector { 426 case AlertingPolicy_FieldPathSelectorMetadata: 427 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 428 case AlertingPolicy_FieldPathSelectorDocumentation: 429 values = append(values, fps.subPath.GetRaw(source.GetDocumentation())...) 430 case AlertingPolicy_FieldPathSelectorSpec: 431 values = append(values, fps.subPath.GetRaw(source.GetSpec())...) 432 case AlertingPolicy_FieldPathSelectorState: 433 values = append(values, fps.subPath.GetRaw(source.GetState())...) 434 default: 435 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fps.selector)) 436 } 437 return 438 } 439 440 func (fps *AlertingPolicy_FieldSubPath) GetRaw(source proto.Message) []interface{} { 441 return fps.Get(source.(*AlertingPolicy)) 442 } 443 444 // GetSingle returns value of selected field from source AlertingPolicy 445 func (fps *AlertingPolicy_FieldSubPath) GetSingle(source *AlertingPolicy) (interface{}, bool) { 446 switch fps.selector { 447 case AlertingPolicy_FieldPathSelectorMetadata: 448 if source.GetMetadata() == nil { 449 return nil, false 450 } 451 return fps.subPath.GetSingleRaw(source.GetMetadata()) 452 case AlertingPolicy_FieldPathSelectorDocumentation: 453 if source.GetDocumentation() == nil { 454 return nil, false 455 } 456 return fps.subPath.GetSingleRaw(source.GetDocumentation()) 457 case AlertingPolicy_FieldPathSelectorSpec: 458 if source.GetSpec() == nil { 459 return nil, false 460 } 461 return fps.subPath.GetSingleRaw(source.GetSpec()) 462 case AlertingPolicy_FieldPathSelectorState: 463 if source.GetState() == nil { 464 return nil, false 465 } 466 return fps.subPath.GetSingleRaw(source.GetState()) 467 default: 468 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fps.selector)) 469 } 470 } 471 472 func (fps *AlertingPolicy_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 473 return fps.GetSingle(source.(*AlertingPolicy)) 474 } 475 476 // GetDefault returns a default value of the field type 477 func (fps *AlertingPolicy_FieldSubPath) GetDefault() interface{} { 478 return fps.subPath.GetDefault() 479 } 480 481 func (fps *AlertingPolicy_FieldSubPath) ClearValue(item *AlertingPolicy) { 482 if item != nil { 483 switch fps.selector { 484 case AlertingPolicy_FieldPathSelectorMetadata: 485 fps.subPath.ClearValueRaw(item.Metadata) 486 case AlertingPolicy_FieldPathSelectorDocumentation: 487 fps.subPath.ClearValueRaw(item.Documentation) 488 case AlertingPolicy_FieldPathSelectorSpec: 489 fps.subPath.ClearValueRaw(item.Spec) 490 case AlertingPolicy_FieldPathSelectorState: 491 fps.subPath.ClearValueRaw(item.State) 492 default: 493 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fps.selector)) 494 } 495 } 496 } 497 498 func (fps *AlertingPolicy_FieldSubPath) ClearValueRaw(item proto.Message) { 499 fps.ClearValue(item.(*AlertingPolicy)) 500 } 501 502 // IsLeaf - whether field path is holds simple value 503 func (fps *AlertingPolicy_FieldSubPath) IsLeaf() bool { 504 return fps.subPath.IsLeaf() 505 } 506 507 func (fps *AlertingPolicy_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 508 iPaths := []gotenobject.FieldPath{&AlertingPolicy_FieldTerminalPath{selector: fps.selector}} 509 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 510 return iPaths 511 } 512 513 func (fps *AlertingPolicy_FieldSubPath) WithIValue(value interface{}) AlertingPolicy_FieldPathValue { 514 return &AlertingPolicy_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 515 } 516 517 func (fps *AlertingPolicy_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 518 return fps.WithIValue(value) 519 } 520 521 func (fps *AlertingPolicy_FieldSubPath) WithIArrayOfValues(values interface{}) AlertingPolicy_FieldPathArrayOfValues { 522 return &AlertingPolicy_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 523 } 524 525 func (fps *AlertingPolicy_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 526 return fps.WithIArrayOfValues(values) 527 } 528 529 func (fps *AlertingPolicy_FieldSubPath) WithIArrayItemValue(value interface{}) AlertingPolicy_FieldPathArrayItemValue { 530 return &AlertingPolicy_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 531 } 532 533 func (fps *AlertingPolicy_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 534 return fps.WithIArrayItemValue(value) 535 } 536 537 // AlertingPolicy_FieldPathValue allows storing values for AlertingPolicy fields according to their type 538 type AlertingPolicy_FieldPathValue interface { 539 AlertingPolicy_FieldPath 540 gotenobject.FieldPathValue 541 SetTo(target **AlertingPolicy) 542 CompareWith(*AlertingPolicy) (cmp int, comparable bool) 543 } 544 545 func ParseAlertingPolicy_FieldPathValue(pathStr, valueStr string) (AlertingPolicy_FieldPathValue, error) { 546 fp, err := ParseAlertingPolicy_FieldPath(pathStr) 547 if err != nil { 548 return nil, err 549 } 550 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 551 if err != nil { 552 return nil, status.Errorf(codes.InvalidArgument, "error parsing AlertingPolicy field path value from %s: %v", valueStr, err) 553 } 554 return fpv.(AlertingPolicy_FieldPathValue), nil 555 } 556 557 func MustParseAlertingPolicy_FieldPathValue(pathStr, valueStr string) AlertingPolicy_FieldPathValue { 558 fpv, err := ParseAlertingPolicy_FieldPathValue(pathStr, valueStr) 559 if err != nil { 560 panic(err) 561 } 562 return fpv 563 } 564 565 type AlertingPolicy_FieldTerminalPathValue struct { 566 AlertingPolicy_FieldTerminalPath 567 value interface{} 568 } 569 570 var _ AlertingPolicy_FieldPathValue = (*AlertingPolicy_FieldTerminalPathValue)(nil) 571 572 // GetRawValue returns raw value stored under selected path for 'AlertingPolicy' as interface{} 573 func (fpv *AlertingPolicy_FieldTerminalPathValue) GetRawValue() interface{} { 574 return fpv.value 575 } 576 func (fpv *AlertingPolicy_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 577 res, ok := fpv.value.(*Name) 578 return res, ok 579 } 580 func (fpv *AlertingPolicy_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 581 res, ok := fpv.value.(*meta.Meta) 582 return res, ok 583 } 584 func (fpv *AlertingPolicy_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) { 585 res, ok := fpv.value.(string) 586 return res, ok 587 } 588 func (fpv *AlertingPolicy_FieldTerminalPathValue) AsDescriptionValue() (string, bool) { 589 res, ok := fpv.value.(string) 590 return res, ok 591 } 592 func (fpv *AlertingPolicy_FieldTerminalPathValue) AsDocumentationValue() (*AlertingPolicy_Documentation, bool) { 593 res, ok := fpv.value.(*AlertingPolicy_Documentation) 594 return res, ok 595 } 596 func (fpv *AlertingPolicy_FieldTerminalPathValue) AsSpecValue() (*AlertingPolicy_Spec, bool) { 597 res, ok := fpv.value.(*AlertingPolicy_Spec) 598 return res, ok 599 } 600 func (fpv *AlertingPolicy_FieldTerminalPathValue) AsStateValue() (*AlertingPolicy_State, bool) { 601 res, ok := fpv.value.(*AlertingPolicy_State) 602 return res, ok 603 } 604 605 // SetTo stores value for selected field for object AlertingPolicy 606 func (fpv *AlertingPolicy_FieldTerminalPathValue) SetTo(target **AlertingPolicy) { 607 if *target == nil { 608 *target = new(AlertingPolicy) 609 } 610 switch fpv.selector { 611 case AlertingPolicy_FieldPathSelectorName: 612 (*target).Name = fpv.value.(*Name) 613 case AlertingPolicy_FieldPathSelectorMetadata: 614 (*target).Metadata = fpv.value.(*meta.Meta) 615 case AlertingPolicy_FieldPathSelectorDisplayName: 616 (*target).DisplayName = fpv.value.(string) 617 case AlertingPolicy_FieldPathSelectorDescription: 618 (*target).Description = fpv.value.(string) 619 case AlertingPolicy_FieldPathSelectorDocumentation: 620 (*target).Documentation = fpv.value.(*AlertingPolicy_Documentation) 621 case AlertingPolicy_FieldPathSelectorSpec: 622 (*target).Spec = fpv.value.(*AlertingPolicy_Spec) 623 case AlertingPolicy_FieldPathSelectorState: 624 (*target).State = fpv.value.(*AlertingPolicy_State) 625 default: 626 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fpv.selector)) 627 } 628 } 629 630 func (fpv *AlertingPolicy_FieldTerminalPathValue) SetToRaw(target proto.Message) { 631 typedObject := target.(*AlertingPolicy) 632 fpv.SetTo(&typedObject) 633 } 634 635 // CompareWith compares value in the 'AlertingPolicy_FieldTerminalPathValue' with the value under path in 'AlertingPolicy'. 636 func (fpv *AlertingPolicy_FieldTerminalPathValue) CompareWith(source *AlertingPolicy) (int, bool) { 637 switch fpv.selector { 638 case AlertingPolicy_FieldPathSelectorName: 639 leftValue := fpv.value.(*Name) 640 rightValue := source.GetName() 641 if leftValue == nil { 642 if rightValue != nil { 643 return -1, true 644 } 645 return 0, true 646 } 647 if rightValue == nil { 648 return 1, true 649 } 650 if leftValue.String() == rightValue.String() { 651 return 0, true 652 } else if leftValue.String() < rightValue.String() { 653 return -1, true 654 } else { 655 return 1, true 656 } 657 case AlertingPolicy_FieldPathSelectorMetadata: 658 return 0, false 659 case AlertingPolicy_FieldPathSelectorDisplayName: 660 leftValue := fpv.value.(string) 661 rightValue := source.GetDisplayName() 662 if (leftValue) == (rightValue) { 663 return 0, true 664 } else if (leftValue) < (rightValue) { 665 return -1, true 666 } else { 667 return 1, true 668 } 669 case AlertingPolicy_FieldPathSelectorDescription: 670 leftValue := fpv.value.(string) 671 rightValue := source.GetDescription() 672 if (leftValue) == (rightValue) { 673 return 0, true 674 } else if (leftValue) < (rightValue) { 675 return -1, true 676 } else { 677 return 1, true 678 } 679 case AlertingPolicy_FieldPathSelectorDocumentation: 680 return 0, false 681 case AlertingPolicy_FieldPathSelectorSpec: 682 return 0, false 683 case AlertingPolicy_FieldPathSelectorState: 684 return 0, false 685 default: 686 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fpv.selector)) 687 } 688 } 689 690 func (fpv *AlertingPolicy_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 691 return fpv.CompareWith(source.(*AlertingPolicy)) 692 } 693 694 type AlertingPolicy_FieldSubPathValue struct { 695 AlertingPolicy_FieldPath 696 subPathValue gotenobject.FieldPathValue 697 } 698 699 var _ AlertingPolicy_FieldPathValue = (*AlertingPolicy_FieldSubPathValue)(nil) 700 701 func (fpvs *AlertingPolicy_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 702 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 703 return res, ok 704 } 705 func (fpvs *AlertingPolicy_FieldSubPathValue) AsDocumentationPathValue() (AlertingPolicyDocumentation_FieldPathValue, bool) { 706 res, ok := fpvs.subPathValue.(AlertingPolicyDocumentation_FieldPathValue) 707 return res, ok 708 } 709 func (fpvs *AlertingPolicy_FieldSubPathValue) AsSpecPathValue() (AlertingPolicySpec_FieldPathValue, bool) { 710 res, ok := fpvs.subPathValue.(AlertingPolicySpec_FieldPathValue) 711 return res, ok 712 } 713 func (fpvs *AlertingPolicy_FieldSubPathValue) AsStatePathValue() (AlertingPolicyState_FieldPathValue, bool) { 714 res, ok := fpvs.subPathValue.(AlertingPolicyState_FieldPathValue) 715 return res, ok 716 } 717 718 func (fpvs *AlertingPolicy_FieldSubPathValue) SetTo(target **AlertingPolicy) { 719 if *target == nil { 720 *target = new(AlertingPolicy) 721 } 722 switch fpvs.Selector() { 723 case AlertingPolicy_FieldPathSelectorMetadata: 724 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 725 case AlertingPolicy_FieldPathSelectorDocumentation: 726 fpvs.subPathValue.(AlertingPolicyDocumentation_FieldPathValue).SetTo(&(*target).Documentation) 727 case AlertingPolicy_FieldPathSelectorSpec: 728 fpvs.subPathValue.(AlertingPolicySpec_FieldPathValue).SetTo(&(*target).Spec) 729 case AlertingPolicy_FieldPathSelectorState: 730 fpvs.subPathValue.(AlertingPolicyState_FieldPathValue).SetTo(&(*target).State) 731 default: 732 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fpvs.Selector())) 733 } 734 } 735 736 func (fpvs *AlertingPolicy_FieldSubPathValue) SetToRaw(target proto.Message) { 737 typedObject := target.(*AlertingPolicy) 738 fpvs.SetTo(&typedObject) 739 } 740 741 func (fpvs *AlertingPolicy_FieldSubPathValue) GetRawValue() interface{} { 742 return fpvs.subPathValue.GetRawValue() 743 } 744 745 func (fpvs *AlertingPolicy_FieldSubPathValue) CompareWith(source *AlertingPolicy) (int, bool) { 746 switch fpvs.Selector() { 747 case AlertingPolicy_FieldPathSelectorMetadata: 748 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 749 case AlertingPolicy_FieldPathSelectorDocumentation: 750 return fpvs.subPathValue.(AlertingPolicyDocumentation_FieldPathValue).CompareWith(source.GetDocumentation()) 751 case AlertingPolicy_FieldPathSelectorSpec: 752 return fpvs.subPathValue.(AlertingPolicySpec_FieldPathValue).CompareWith(source.GetSpec()) 753 case AlertingPolicy_FieldPathSelectorState: 754 return fpvs.subPathValue.(AlertingPolicyState_FieldPathValue).CompareWith(source.GetState()) 755 default: 756 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fpvs.Selector())) 757 } 758 } 759 760 func (fpvs *AlertingPolicy_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 761 return fpvs.CompareWith(source.(*AlertingPolicy)) 762 } 763 764 // AlertingPolicy_FieldPathArrayItemValue allows storing single item in Path-specific values for AlertingPolicy according to their type 765 // Present only for array (repeated) types. 766 type AlertingPolicy_FieldPathArrayItemValue interface { 767 gotenobject.FieldPathArrayItemValue 768 AlertingPolicy_FieldPath 769 ContainsValue(*AlertingPolicy) bool 770 } 771 772 // ParseAlertingPolicy_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 773 func ParseAlertingPolicy_FieldPathArrayItemValue(pathStr, valueStr string) (AlertingPolicy_FieldPathArrayItemValue, error) { 774 fp, err := ParseAlertingPolicy_FieldPath(pathStr) 775 if err != nil { 776 return nil, err 777 } 778 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 779 if err != nil { 780 return nil, status.Errorf(codes.InvalidArgument, "error parsing AlertingPolicy field path array item value from %s: %v", valueStr, err) 781 } 782 return fpaiv.(AlertingPolicy_FieldPathArrayItemValue), nil 783 } 784 785 func MustParseAlertingPolicy_FieldPathArrayItemValue(pathStr, valueStr string) AlertingPolicy_FieldPathArrayItemValue { 786 fpaiv, err := ParseAlertingPolicy_FieldPathArrayItemValue(pathStr, valueStr) 787 if err != nil { 788 panic(err) 789 } 790 return fpaiv 791 } 792 793 type AlertingPolicy_FieldTerminalPathArrayItemValue struct { 794 AlertingPolicy_FieldTerminalPath 795 value interface{} 796 } 797 798 var _ AlertingPolicy_FieldPathArrayItemValue = (*AlertingPolicy_FieldTerminalPathArrayItemValue)(nil) 799 800 // GetRawValue returns stored element value for array in object AlertingPolicy as interface{} 801 func (fpaiv *AlertingPolicy_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 802 return fpaiv.value 803 } 804 805 func (fpaiv *AlertingPolicy_FieldTerminalPathArrayItemValue) GetSingle(source *AlertingPolicy) (interface{}, bool) { 806 return nil, false 807 } 808 809 func (fpaiv *AlertingPolicy_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 810 return fpaiv.GetSingle(source.(*AlertingPolicy)) 811 } 812 813 // Contains returns a boolean indicating if value that is being held is present in given 'AlertingPolicy' 814 func (fpaiv *AlertingPolicy_FieldTerminalPathArrayItemValue) ContainsValue(source *AlertingPolicy) bool { 815 slice := fpaiv.AlertingPolicy_FieldTerminalPath.Get(source) 816 for _, v := range slice { 817 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 818 if proto.Equal(asProtoMsg, v.(proto.Message)) { 819 return true 820 } 821 } else if reflect.DeepEqual(v, fpaiv.value) { 822 return true 823 } 824 } 825 return false 826 } 827 828 type AlertingPolicy_FieldSubPathArrayItemValue struct { 829 AlertingPolicy_FieldPath 830 subPathItemValue gotenobject.FieldPathArrayItemValue 831 } 832 833 // GetRawValue returns stored array item value 834 func (fpaivs *AlertingPolicy_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 835 return fpaivs.subPathItemValue.GetRawItemValue() 836 } 837 func (fpaivs *AlertingPolicy_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 838 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 839 return res, ok 840 } 841 func (fpaivs *AlertingPolicy_FieldSubPathArrayItemValue) AsDocumentationPathItemValue() (AlertingPolicyDocumentation_FieldPathArrayItemValue, bool) { 842 res, ok := fpaivs.subPathItemValue.(AlertingPolicyDocumentation_FieldPathArrayItemValue) 843 return res, ok 844 } 845 func (fpaivs *AlertingPolicy_FieldSubPathArrayItemValue) AsSpecPathItemValue() (AlertingPolicySpec_FieldPathArrayItemValue, bool) { 846 res, ok := fpaivs.subPathItemValue.(AlertingPolicySpec_FieldPathArrayItemValue) 847 return res, ok 848 } 849 func (fpaivs *AlertingPolicy_FieldSubPathArrayItemValue) AsStatePathItemValue() (AlertingPolicyState_FieldPathArrayItemValue, bool) { 850 res, ok := fpaivs.subPathItemValue.(AlertingPolicyState_FieldPathArrayItemValue) 851 return res, ok 852 } 853 854 // Contains returns a boolean indicating if value that is being held is present in given 'AlertingPolicy' 855 func (fpaivs *AlertingPolicy_FieldSubPathArrayItemValue) ContainsValue(source *AlertingPolicy) bool { 856 switch fpaivs.Selector() { 857 case AlertingPolicy_FieldPathSelectorMetadata: 858 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 859 case AlertingPolicy_FieldPathSelectorDocumentation: 860 return fpaivs.subPathItemValue.(AlertingPolicyDocumentation_FieldPathArrayItemValue).ContainsValue(source.GetDocumentation()) 861 case AlertingPolicy_FieldPathSelectorSpec: 862 return fpaivs.subPathItemValue.(AlertingPolicySpec_FieldPathArrayItemValue).ContainsValue(source.GetSpec()) 863 case AlertingPolicy_FieldPathSelectorState: 864 return fpaivs.subPathItemValue.(AlertingPolicyState_FieldPathArrayItemValue).ContainsValue(source.GetState()) 865 default: 866 panic(fmt.Sprintf("Invalid selector for AlertingPolicy: %d", fpaivs.Selector())) 867 } 868 } 869 870 // AlertingPolicy_FieldPathArrayOfValues allows storing slice of values for AlertingPolicy fields according to their type 871 type AlertingPolicy_FieldPathArrayOfValues interface { 872 gotenobject.FieldPathArrayOfValues 873 AlertingPolicy_FieldPath 874 } 875 876 func ParseAlertingPolicy_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertingPolicy_FieldPathArrayOfValues, error) { 877 fp, err := ParseAlertingPolicy_FieldPath(pathStr) 878 if err != nil { 879 return nil, err 880 } 881 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 882 if err != nil { 883 return nil, status.Errorf(codes.InvalidArgument, "error parsing AlertingPolicy field path array of values from %s: %v", valuesStr, err) 884 } 885 return fpaov.(AlertingPolicy_FieldPathArrayOfValues), nil 886 } 887 888 func MustParseAlertingPolicy_FieldPathArrayOfValues(pathStr, valuesStr string) AlertingPolicy_FieldPathArrayOfValues { 889 fpaov, err := ParseAlertingPolicy_FieldPathArrayOfValues(pathStr, valuesStr) 890 if err != nil { 891 panic(err) 892 } 893 return fpaov 894 } 895 896 type AlertingPolicy_FieldTerminalPathArrayOfValues struct { 897 AlertingPolicy_FieldTerminalPath 898 values interface{} 899 } 900 901 var _ AlertingPolicy_FieldPathArrayOfValues = (*AlertingPolicy_FieldTerminalPathArrayOfValues)(nil) 902 903 func (fpaov *AlertingPolicy_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 904 switch fpaov.selector { 905 case AlertingPolicy_FieldPathSelectorName: 906 for _, v := range fpaov.values.([]*Name) { 907 values = append(values, v) 908 } 909 case AlertingPolicy_FieldPathSelectorMetadata: 910 for _, v := range fpaov.values.([]*meta.Meta) { 911 values = append(values, v) 912 } 913 case AlertingPolicy_FieldPathSelectorDisplayName: 914 for _, v := range fpaov.values.([]string) { 915 values = append(values, v) 916 } 917 case AlertingPolicy_FieldPathSelectorDescription: 918 for _, v := range fpaov.values.([]string) { 919 values = append(values, v) 920 } 921 case AlertingPolicy_FieldPathSelectorDocumentation: 922 for _, v := range fpaov.values.([]*AlertingPolicy_Documentation) { 923 values = append(values, v) 924 } 925 case AlertingPolicy_FieldPathSelectorSpec: 926 for _, v := range fpaov.values.([]*AlertingPolicy_Spec) { 927 values = append(values, v) 928 } 929 case AlertingPolicy_FieldPathSelectorState: 930 for _, v := range fpaov.values.([]*AlertingPolicy_State) { 931 values = append(values, v) 932 } 933 } 934 return 935 } 936 func (fpaov *AlertingPolicy_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 937 res, ok := fpaov.values.([]*Name) 938 return res, ok 939 } 940 func (fpaov *AlertingPolicy_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 941 res, ok := fpaov.values.([]*meta.Meta) 942 return res, ok 943 } 944 func (fpaov *AlertingPolicy_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) { 945 res, ok := fpaov.values.([]string) 946 return res, ok 947 } 948 func (fpaov *AlertingPolicy_FieldTerminalPathArrayOfValues) AsDescriptionArrayOfValues() ([]string, bool) { 949 res, ok := fpaov.values.([]string) 950 return res, ok 951 } 952 func (fpaov *AlertingPolicy_FieldTerminalPathArrayOfValues) AsDocumentationArrayOfValues() ([]*AlertingPolicy_Documentation, bool) { 953 res, ok := fpaov.values.([]*AlertingPolicy_Documentation) 954 return res, ok 955 } 956 func (fpaov *AlertingPolicy_FieldTerminalPathArrayOfValues) AsSpecArrayOfValues() ([]*AlertingPolicy_Spec, bool) { 957 res, ok := fpaov.values.([]*AlertingPolicy_Spec) 958 return res, ok 959 } 960 func (fpaov *AlertingPolicy_FieldTerminalPathArrayOfValues) AsStateArrayOfValues() ([]*AlertingPolicy_State, bool) { 961 res, ok := fpaov.values.([]*AlertingPolicy_State) 962 return res, ok 963 } 964 965 type AlertingPolicy_FieldSubPathArrayOfValues struct { 966 AlertingPolicy_FieldPath 967 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 968 } 969 970 var _ AlertingPolicy_FieldPathArrayOfValues = (*AlertingPolicy_FieldSubPathArrayOfValues)(nil) 971 972 func (fpsaov *AlertingPolicy_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 973 return fpsaov.subPathArrayOfValues.GetRawValues() 974 } 975 func (fpsaov *AlertingPolicy_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 976 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 977 return res, ok 978 } 979 func (fpsaov *AlertingPolicy_FieldSubPathArrayOfValues) AsDocumentationPathArrayOfValues() (AlertingPolicyDocumentation_FieldPathArrayOfValues, bool) { 980 res, ok := fpsaov.subPathArrayOfValues.(AlertingPolicyDocumentation_FieldPathArrayOfValues) 981 return res, ok 982 } 983 func (fpsaov *AlertingPolicy_FieldSubPathArrayOfValues) AsSpecPathArrayOfValues() (AlertingPolicySpec_FieldPathArrayOfValues, bool) { 984 res, ok := fpsaov.subPathArrayOfValues.(AlertingPolicySpec_FieldPathArrayOfValues) 985 return res, ok 986 } 987 func (fpsaov *AlertingPolicy_FieldSubPathArrayOfValues) AsStatePathArrayOfValues() (AlertingPolicyState_FieldPathArrayOfValues, bool) { 988 res, ok := fpsaov.subPathArrayOfValues.(AlertingPolicyState_FieldPathArrayOfValues) 989 return res, ok 990 } 991 992 // FieldPath provides implementation to handle 993 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 994 type AlertingPolicyDocumentation_FieldPath interface { 995 gotenobject.FieldPath 996 Selector() AlertingPolicyDocumentation_FieldPathSelector 997 Get(source *AlertingPolicy_Documentation) []interface{} 998 GetSingle(source *AlertingPolicy_Documentation) (interface{}, bool) 999 ClearValue(item *AlertingPolicy_Documentation) 1000 1001 // Those methods build corresponding AlertingPolicyDocumentation_FieldPathValue 1002 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1003 WithIValue(value interface{}) AlertingPolicyDocumentation_FieldPathValue 1004 WithIArrayOfValues(values interface{}) AlertingPolicyDocumentation_FieldPathArrayOfValues 1005 WithIArrayItemValue(value interface{}) AlertingPolicyDocumentation_FieldPathArrayItemValue 1006 } 1007 1008 type AlertingPolicyDocumentation_FieldPathSelector int32 1009 1010 const ( 1011 AlertingPolicyDocumentation_FieldPathSelectorContent AlertingPolicyDocumentation_FieldPathSelector = 0 1012 AlertingPolicyDocumentation_FieldPathSelectorMimeType AlertingPolicyDocumentation_FieldPathSelector = 1 1013 ) 1014 1015 func (s AlertingPolicyDocumentation_FieldPathSelector) String() string { 1016 switch s { 1017 case AlertingPolicyDocumentation_FieldPathSelectorContent: 1018 return "content" 1019 case AlertingPolicyDocumentation_FieldPathSelectorMimeType: 1020 return "mime_type" 1021 default: 1022 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Documentation: %d", s)) 1023 } 1024 } 1025 1026 func BuildAlertingPolicyDocumentation_FieldPath(fp gotenobject.RawFieldPath) (AlertingPolicyDocumentation_FieldPath, error) { 1027 if len(fp) == 0 { 1028 return nil, status.Error(codes.InvalidArgument, "empty field path for object AlertingPolicy_Documentation") 1029 } 1030 if len(fp) == 1 { 1031 switch fp[0] { 1032 case "content": 1033 return &AlertingPolicyDocumentation_FieldTerminalPath{selector: AlertingPolicyDocumentation_FieldPathSelectorContent}, nil 1034 case "mime_type", "mimeType", "mime-type": 1035 return &AlertingPolicyDocumentation_FieldTerminalPath{selector: AlertingPolicyDocumentation_FieldPathSelectorMimeType}, nil 1036 } 1037 } 1038 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object AlertingPolicy_Documentation", fp) 1039 } 1040 1041 func ParseAlertingPolicyDocumentation_FieldPath(rawField string) (AlertingPolicyDocumentation_FieldPath, error) { 1042 fp, err := gotenobject.ParseRawFieldPath(rawField) 1043 if err != nil { 1044 return nil, err 1045 } 1046 return BuildAlertingPolicyDocumentation_FieldPath(fp) 1047 } 1048 1049 func MustParseAlertingPolicyDocumentation_FieldPath(rawField string) AlertingPolicyDocumentation_FieldPath { 1050 fp, err := ParseAlertingPolicyDocumentation_FieldPath(rawField) 1051 if err != nil { 1052 panic(err) 1053 } 1054 return fp 1055 } 1056 1057 type AlertingPolicyDocumentation_FieldTerminalPath struct { 1058 selector AlertingPolicyDocumentation_FieldPathSelector 1059 } 1060 1061 var _ AlertingPolicyDocumentation_FieldPath = (*AlertingPolicyDocumentation_FieldTerminalPath)(nil) 1062 1063 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) Selector() AlertingPolicyDocumentation_FieldPathSelector { 1064 return fp.selector 1065 } 1066 1067 // String returns path representation in proto convention 1068 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) String() string { 1069 return fp.selector.String() 1070 } 1071 1072 // JSONString returns path representation is JSON convention 1073 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) JSONString() string { 1074 return strcase.ToLowerCamel(fp.String()) 1075 } 1076 1077 // Get returns all values pointed by specific field from source AlertingPolicy_Documentation 1078 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) Get(source *AlertingPolicy_Documentation) (values []interface{}) { 1079 if source != nil { 1080 switch fp.selector { 1081 case AlertingPolicyDocumentation_FieldPathSelectorContent: 1082 values = append(values, source.Content) 1083 case AlertingPolicyDocumentation_FieldPathSelectorMimeType: 1084 values = append(values, source.MimeType) 1085 default: 1086 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Documentation: %d", fp.selector)) 1087 } 1088 } 1089 return 1090 } 1091 1092 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1093 return fp.Get(source.(*AlertingPolicy_Documentation)) 1094 } 1095 1096 // GetSingle returns value pointed by specific field of from source AlertingPolicy_Documentation 1097 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) GetSingle(source *AlertingPolicy_Documentation) (interface{}, bool) { 1098 switch fp.selector { 1099 case AlertingPolicyDocumentation_FieldPathSelectorContent: 1100 return source.GetContent(), source != nil 1101 case AlertingPolicyDocumentation_FieldPathSelectorMimeType: 1102 return source.GetMimeType(), source != nil 1103 default: 1104 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Documentation: %d", fp.selector)) 1105 } 1106 } 1107 1108 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1109 return fp.GetSingle(source.(*AlertingPolicy_Documentation)) 1110 } 1111 1112 // GetDefault returns a default value of the field type 1113 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) GetDefault() interface{} { 1114 switch fp.selector { 1115 case AlertingPolicyDocumentation_FieldPathSelectorContent: 1116 return "" 1117 case AlertingPolicyDocumentation_FieldPathSelectorMimeType: 1118 return "" 1119 default: 1120 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Documentation: %d", fp.selector)) 1121 } 1122 } 1123 1124 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) ClearValue(item *AlertingPolicy_Documentation) { 1125 if item != nil { 1126 switch fp.selector { 1127 case AlertingPolicyDocumentation_FieldPathSelectorContent: 1128 item.Content = "" 1129 case AlertingPolicyDocumentation_FieldPathSelectorMimeType: 1130 item.MimeType = "" 1131 default: 1132 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Documentation: %d", fp.selector)) 1133 } 1134 } 1135 } 1136 1137 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1138 fp.ClearValue(item.(*AlertingPolicy_Documentation)) 1139 } 1140 1141 // IsLeaf - whether field path is holds simple value 1142 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) IsLeaf() bool { 1143 return fp.selector == AlertingPolicyDocumentation_FieldPathSelectorContent || 1144 fp.selector == AlertingPolicyDocumentation_FieldPathSelectorMimeType 1145 } 1146 1147 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1148 return []gotenobject.FieldPath{fp} 1149 } 1150 1151 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) WithIValue(value interface{}) AlertingPolicyDocumentation_FieldPathValue { 1152 switch fp.selector { 1153 case AlertingPolicyDocumentation_FieldPathSelectorContent: 1154 return &AlertingPolicyDocumentation_FieldTerminalPathValue{AlertingPolicyDocumentation_FieldTerminalPath: *fp, value: value.(string)} 1155 case AlertingPolicyDocumentation_FieldPathSelectorMimeType: 1156 return &AlertingPolicyDocumentation_FieldTerminalPathValue{AlertingPolicyDocumentation_FieldTerminalPath: *fp, value: value.(string)} 1157 default: 1158 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Documentation: %d", fp.selector)) 1159 } 1160 } 1161 1162 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1163 return fp.WithIValue(value) 1164 } 1165 1166 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertingPolicyDocumentation_FieldPathArrayOfValues { 1167 fpaov := &AlertingPolicyDocumentation_FieldTerminalPathArrayOfValues{AlertingPolicyDocumentation_FieldTerminalPath: *fp} 1168 switch fp.selector { 1169 case AlertingPolicyDocumentation_FieldPathSelectorContent: 1170 return &AlertingPolicyDocumentation_FieldTerminalPathArrayOfValues{AlertingPolicyDocumentation_FieldTerminalPath: *fp, values: values.([]string)} 1171 case AlertingPolicyDocumentation_FieldPathSelectorMimeType: 1172 return &AlertingPolicyDocumentation_FieldTerminalPathArrayOfValues{AlertingPolicyDocumentation_FieldTerminalPath: *fp, values: values.([]string)} 1173 default: 1174 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Documentation: %d", fp.selector)) 1175 } 1176 return fpaov 1177 } 1178 1179 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1180 return fp.WithIArrayOfValues(values) 1181 } 1182 1183 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertingPolicyDocumentation_FieldPathArrayItemValue { 1184 switch fp.selector { 1185 default: 1186 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Documentation: %d", fp.selector)) 1187 } 1188 } 1189 1190 func (fp *AlertingPolicyDocumentation_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1191 return fp.WithIArrayItemValue(value) 1192 } 1193 1194 // AlertingPolicyDocumentation_FieldPathValue allows storing values for Documentation fields according to their type 1195 type AlertingPolicyDocumentation_FieldPathValue interface { 1196 AlertingPolicyDocumentation_FieldPath 1197 gotenobject.FieldPathValue 1198 SetTo(target **AlertingPolicy_Documentation) 1199 CompareWith(*AlertingPolicy_Documentation) (cmp int, comparable bool) 1200 } 1201 1202 func ParseAlertingPolicyDocumentation_FieldPathValue(pathStr, valueStr string) (AlertingPolicyDocumentation_FieldPathValue, error) { 1203 fp, err := ParseAlertingPolicyDocumentation_FieldPath(pathStr) 1204 if err != nil { 1205 return nil, err 1206 } 1207 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1208 if err != nil { 1209 return nil, status.Errorf(codes.InvalidArgument, "error parsing Documentation field path value from %s: %v", valueStr, err) 1210 } 1211 return fpv.(AlertingPolicyDocumentation_FieldPathValue), nil 1212 } 1213 1214 func MustParseAlertingPolicyDocumentation_FieldPathValue(pathStr, valueStr string) AlertingPolicyDocumentation_FieldPathValue { 1215 fpv, err := ParseAlertingPolicyDocumentation_FieldPathValue(pathStr, valueStr) 1216 if err != nil { 1217 panic(err) 1218 } 1219 return fpv 1220 } 1221 1222 type AlertingPolicyDocumentation_FieldTerminalPathValue struct { 1223 AlertingPolicyDocumentation_FieldTerminalPath 1224 value interface{} 1225 } 1226 1227 var _ AlertingPolicyDocumentation_FieldPathValue = (*AlertingPolicyDocumentation_FieldTerminalPathValue)(nil) 1228 1229 // GetRawValue returns raw value stored under selected path for 'Documentation' as interface{} 1230 func (fpv *AlertingPolicyDocumentation_FieldTerminalPathValue) GetRawValue() interface{} { 1231 return fpv.value 1232 } 1233 func (fpv *AlertingPolicyDocumentation_FieldTerminalPathValue) AsContentValue() (string, bool) { 1234 res, ok := fpv.value.(string) 1235 return res, ok 1236 } 1237 func (fpv *AlertingPolicyDocumentation_FieldTerminalPathValue) AsMimeTypeValue() (string, bool) { 1238 res, ok := fpv.value.(string) 1239 return res, ok 1240 } 1241 1242 // SetTo stores value for selected field for object Documentation 1243 func (fpv *AlertingPolicyDocumentation_FieldTerminalPathValue) SetTo(target **AlertingPolicy_Documentation) { 1244 if *target == nil { 1245 *target = new(AlertingPolicy_Documentation) 1246 } 1247 switch fpv.selector { 1248 case AlertingPolicyDocumentation_FieldPathSelectorContent: 1249 (*target).Content = fpv.value.(string) 1250 case AlertingPolicyDocumentation_FieldPathSelectorMimeType: 1251 (*target).MimeType = fpv.value.(string) 1252 default: 1253 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Documentation: %d", fpv.selector)) 1254 } 1255 } 1256 1257 func (fpv *AlertingPolicyDocumentation_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1258 typedObject := target.(*AlertingPolicy_Documentation) 1259 fpv.SetTo(&typedObject) 1260 } 1261 1262 // CompareWith compares value in the 'AlertingPolicyDocumentation_FieldTerminalPathValue' with the value under path in 'AlertingPolicy_Documentation'. 1263 func (fpv *AlertingPolicyDocumentation_FieldTerminalPathValue) CompareWith(source *AlertingPolicy_Documentation) (int, bool) { 1264 switch fpv.selector { 1265 case AlertingPolicyDocumentation_FieldPathSelectorContent: 1266 leftValue := fpv.value.(string) 1267 rightValue := source.GetContent() 1268 if (leftValue) == (rightValue) { 1269 return 0, true 1270 } else if (leftValue) < (rightValue) { 1271 return -1, true 1272 } else { 1273 return 1, true 1274 } 1275 case AlertingPolicyDocumentation_FieldPathSelectorMimeType: 1276 leftValue := fpv.value.(string) 1277 rightValue := source.GetMimeType() 1278 if (leftValue) == (rightValue) { 1279 return 0, true 1280 } else if (leftValue) < (rightValue) { 1281 return -1, true 1282 } else { 1283 return 1, true 1284 } 1285 default: 1286 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Documentation: %d", fpv.selector)) 1287 } 1288 } 1289 1290 func (fpv *AlertingPolicyDocumentation_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1291 return fpv.CompareWith(source.(*AlertingPolicy_Documentation)) 1292 } 1293 1294 // AlertingPolicyDocumentation_FieldPathArrayItemValue allows storing single item in Path-specific values for Documentation according to their type 1295 // Present only for array (repeated) types. 1296 type AlertingPolicyDocumentation_FieldPathArrayItemValue interface { 1297 gotenobject.FieldPathArrayItemValue 1298 AlertingPolicyDocumentation_FieldPath 1299 ContainsValue(*AlertingPolicy_Documentation) bool 1300 } 1301 1302 // ParseAlertingPolicyDocumentation_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1303 func ParseAlertingPolicyDocumentation_FieldPathArrayItemValue(pathStr, valueStr string) (AlertingPolicyDocumentation_FieldPathArrayItemValue, error) { 1304 fp, err := ParseAlertingPolicyDocumentation_FieldPath(pathStr) 1305 if err != nil { 1306 return nil, err 1307 } 1308 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1309 if err != nil { 1310 return nil, status.Errorf(codes.InvalidArgument, "error parsing Documentation field path array item value from %s: %v", valueStr, err) 1311 } 1312 return fpaiv.(AlertingPolicyDocumentation_FieldPathArrayItemValue), nil 1313 } 1314 1315 func MustParseAlertingPolicyDocumentation_FieldPathArrayItemValue(pathStr, valueStr string) AlertingPolicyDocumentation_FieldPathArrayItemValue { 1316 fpaiv, err := ParseAlertingPolicyDocumentation_FieldPathArrayItemValue(pathStr, valueStr) 1317 if err != nil { 1318 panic(err) 1319 } 1320 return fpaiv 1321 } 1322 1323 type AlertingPolicyDocumentation_FieldTerminalPathArrayItemValue struct { 1324 AlertingPolicyDocumentation_FieldTerminalPath 1325 value interface{} 1326 } 1327 1328 var _ AlertingPolicyDocumentation_FieldPathArrayItemValue = (*AlertingPolicyDocumentation_FieldTerminalPathArrayItemValue)(nil) 1329 1330 // GetRawValue returns stored element value for array in object AlertingPolicy_Documentation as interface{} 1331 func (fpaiv *AlertingPolicyDocumentation_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1332 return fpaiv.value 1333 } 1334 1335 func (fpaiv *AlertingPolicyDocumentation_FieldTerminalPathArrayItemValue) GetSingle(source *AlertingPolicy_Documentation) (interface{}, bool) { 1336 return nil, false 1337 } 1338 1339 func (fpaiv *AlertingPolicyDocumentation_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1340 return fpaiv.GetSingle(source.(*AlertingPolicy_Documentation)) 1341 } 1342 1343 // Contains returns a boolean indicating if value that is being held is present in given 'Documentation' 1344 func (fpaiv *AlertingPolicyDocumentation_FieldTerminalPathArrayItemValue) ContainsValue(source *AlertingPolicy_Documentation) bool { 1345 slice := fpaiv.AlertingPolicyDocumentation_FieldTerminalPath.Get(source) 1346 for _, v := range slice { 1347 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1348 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1349 return true 1350 } 1351 } else if reflect.DeepEqual(v, fpaiv.value) { 1352 return true 1353 } 1354 } 1355 return false 1356 } 1357 1358 // AlertingPolicyDocumentation_FieldPathArrayOfValues allows storing slice of values for Documentation fields according to their type 1359 type AlertingPolicyDocumentation_FieldPathArrayOfValues interface { 1360 gotenobject.FieldPathArrayOfValues 1361 AlertingPolicyDocumentation_FieldPath 1362 } 1363 1364 func ParseAlertingPolicyDocumentation_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertingPolicyDocumentation_FieldPathArrayOfValues, error) { 1365 fp, err := ParseAlertingPolicyDocumentation_FieldPath(pathStr) 1366 if err != nil { 1367 return nil, err 1368 } 1369 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1370 if err != nil { 1371 return nil, status.Errorf(codes.InvalidArgument, "error parsing Documentation field path array of values from %s: %v", valuesStr, err) 1372 } 1373 return fpaov.(AlertingPolicyDocumentation_FieldPathArrayOfValues), nil 1374 } 1375 1376 func MustParseAlertingPolicyDocumentation_FieldPathArrayOfValues(pathStr, valuesStr string) AlertingPolicyDocumentation_FieldPathArrayOfValues { 1377 fpaov, err := ParseAlertingPolicyDocumentation_FieldPathArrayOfValues(pathStr, valuesStr) 1378 if err != nil { 1379 panic(err) 1380 } 1381 return fpaov 1382 } 1383 1384 type AlertingPolicyDocumentation_FieldTerminalPathArrayOfValues struct { 1385 AlertingPolicyDocumentation_FieldTerminalPath 1386 values interface{} 1387 } 1388 1389 var _ AlertingPolicyDocumentation_FieldPathArrayOfValues = (*AlertingPolicyDocumentation_FieldTerminalPathArrayOfValues)(nil) 1390 1391 func (fpaov *AlertingPolicyDocumentation_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1392 switch fpaov.selector { 1393 case AlertingPolicyDocumentation_FieldPathSelectorContent: 1394 for _, v := range fpaov.values.([]string) { 1395 values = append(values, v) 1396 } 1397 case AlertingPolicyDocumentation_FieldPathSelectorMimeType: 1398 for _, v := range fpaov.values.([]string) { 1399 values = append(values, v) 1400 } 1401 } 1402 return 1403 } 1404 func (fpaov *AlertingPolicyDocumentation_FieldTerminalPathArrayOfValues) AsContentArrayOfValues() ([]string, bool) { 1405 res, ok := fpaov.values.([]string) 1406 return res, ok 1407 } 1408 func (fpaov *AlertingPolicyDocumentation_FieldTerminalPathArrayOfValues) AsMimeTypeArrayOfValues() ([]string, bool) { 1409 res, ok := fpaov.values.([]string) 1410 return res, ok 1411 } 1412 1413 // FieldPath provides implementation to handle 1414 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 1415 type AlertingPolicySpec_FieldPath interface { 1416 gotenobject.FieldPath 1417 Selector() AlertingPolicySpec_FieldPathSelector 1418 Get(source *AlertingPolicy_Spec) []interface{} 1419 GetSingle(source *AlertingPolicy_Spec) (interface{}, bool) 1420 ClearValue(item *AlertingPolicy_Spec) 1421 1422 // Those methods build corresponding AlertingPolicySpec_FieldPathValue 1423 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1424 WithIValue(value interface{}) AlertingPolicySpec_FieldPathValue 1425 WithIArrayOfValues(values interface{}) AlertingPolicySpec_FieldPathArrayOfValues 1426 WithIArrayItemValue(value interface{}) AlertingPolicySpec_FieldPathArrayItemValue 1427 } 1428 1429 type AlertingPolicySpec_FieldPathSelector int32 1430 1431 const ( 1432 AlertingPolicySpec_FieldPathSelectorEnabled AlertingPolicySpec_FieldPathSelector = 0 1433 AlertingPolicySpec_FieldPathSelectorConditionCombiner AlertingPolicySpec_FieldPathSelector = 1 1434 AlertingPolicySpec_FieldPathSelectorNotification AlertingPolicySpec_FieldPathSelector = 2 1435 ) 1436 1437 func (s AlertingPolicySpec_FieldPathSelector) String() string { 1438 switch s { 1439 case AlertingPolicySpec_FieldPathSelectorEnabled: 1440 return "enabled" 1441 case AlertingPolicySpec_FieldPathSelectorConditionCombiner: 1442 return "condition_combiner" 1443 case AlertingPolicySpec_FieldPathSelectorNotification: 1444 return "notification" 1445 default: 1446 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", s)) 1447 } 1448 } 1449 1450 func BuildAlertingPolicySpec_FieldPath(fp gotenobject.RawFieldPath) (AlertingPolicySpec_FieldPath, error) { 1451 if len(fp) == 0 { 1452 return nil, status.Error(codes.InvalidArgument, "empty field path for object AlertingPolicy_Spec") 1453 } 1454 if len(fp) == 1 { 1455 switch fp[0] { 1456 case "enabled": 1457 return &AlertingPolicySpec_FieldTerminalPath{selector: AlertingPolicySpec_FieldPathSelectorEnabled}, nil 1458 case "condition_combiner", "conditionCombiner", "condition-combiner": 1459 return &AlertingPolicySpec_FieldTerminalPath{selector: AlertingPolicySpec_FieldPathSelectorConditionCombiner}, nil 1460 case "notification": 1461 return &AlertingPolicySpec_FieldTerminalPath{selector: AlertingPolicySpec_FieldPathSelectorNotification}, nil 1462 } 1463 } else { 1464 switch fp[0] { 1465 case "notification": 1466 if subpath, err := BuildAlertingPolicySpecNotification_FieldPath(fp[1:]); err != nil { 1467 return nil, err 1468 } else { 1469 return &AlertingPolicySpec_FieldSubPath{selector: AlertingPolicySpec_FieldPathSelectorNotification, subPath: subpath}, nil 1470 } 1471 } 1472 } 1473 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object AlertingPolicy_Spec", fp) 1474 } 1475 1476 func ParseAlertingPolicySpec_FieldPath(rawField string) (AlertingPolicySpec_FieldPath, error) { 1477 fp, err := gotenobject.ParseRawFieldPath(rawField) 1478 if err != nil { 1479 return nil, err 1480 } 1481 return BuildAlertingPolicySpec_FieldPath(fp) 1482 } 1483 1484 func MustParseAlertingPolicySpec_FieldPath(rawField string) AlertingPolicySpec_FieldPath { 1485 fp, err := ParseAlertingPolicySpec_FieldPath(rawField) 1486 if err != nil { 1487 panic(err) 1488 } 1489 return fp 1490 } 1491 1492 type AlertingPolicySpec_FieldTerminalPath struct { 1493 selector AlertingPolicySpec_FieldPathSelector 1494 } 1495 1496 var _ AlertingPolicySpec_FieldPath = (*AlertingPolicySpec_FieldTerminalPath)(nil) 1497 1498 func (fp *AlertingPolicySpec_FieldTerminalPath) Selector() AlertingPolicySpec_FieldPathSelector { 1499 return fp.selector 1500 } 1501 1502 // String returns path representation in proto convention 1503 func (fp *AlertingPolicySpec_FieldTerminalPath) String() string { 1504 return fp.selector.String() 1505 } 1506 1507 // JSONString returns path representation is JSON convention 1508 func (fp *AlertingPolicySpec_FieldTerminalPath) JSONString() string { 1509 return strcase.ToLowerCamel(fp.String()) 1510 } 1511 1512 // Get returns all values pointed by specific field from source AlertingPolicy_Spec 1513 func (fp *AlertingPolicySpec_FieldTerminalPath) Get(source *AlertingPolicy_Spec) (values []interface{}) { 1514 if source != nil { 1515 switch fp.selector { 1516 case AlertingPolicySpec_FieldPathSelectorEnabled: 1517 values = append(values, source.Enabled) 1518 case AlertingPolicySpec_FieldPathSelectorConditionCombiner: 1519 values = append(values, source.ConditionCombiner) 1520 case AlertingPolicySpec_FieldPathSelectorNotification: 1521 if source.Notification != nil { 1522 values = append(values, source.Notification) 1523 } 1524 default: 1525 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fp.selector)) 1526 } 1527 } 1528 return 1529 } 1530 1531 func (fp *AlertingPolicySpec_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1532 return fp.Get(source.(*AlertingPolicy_Spec)) 1533 } 1534 1535 // GetSingle returns value pointed by specific field of from source AlertingPolicy_Spec 1536 func (fp *AlertingPolicySpec_FieldTerminalPath) GetSingle(source *AlertingPolicy_Spec) (interface{}, bool) { 1537 switch fp.selector { 1538 case AlertingPolicySpec_FieldPathSelectorEnabled: 1539 return source.GetEnabled(), source != nil 1540 case AlertingPolicySpec_FieldPathSelectorConditionCombiner: 1541 return source.GetConditionCombiner(), source != nil 1542 case AlertingPolicySpec_FieldPathSelectorNotification: 1543 res := source.GetNotification() 1544 return res, res != nil 1545 default: 1546 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fp.selector)) 1547 } 1548 } 1549 1550 func (fp *AlertingPolicySpec_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1551 return fp.GetSingle(source.(*AlertingPolicy_Spec)) 1552 } 1553 1554 // GetDefault returns a default value of the field type 1555 func (fp *AlertingPolicySpec_FieldTerminalPath) GetDefault() interface{} { 1556 switch fp.selector { 1557 case AlertingPolicySpec_FieldPathSelectorEnabled: 1558 return false 1559 case AlertingPolicySpec_FieldPathSelectorConditionCombiner: 1560 return AlertingPolicy_Spec_OR 1561 case AlertingPolicySpec_FieldPathSelectorNotification: 1562 return (*AlertingPolicy_Spec_Notification)(nil) 1563 default: 1564 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fp.selector)) 1565 } 1566 } 1567 1568 func (fp *AlertingPolicySpec_FieldTerminalPath) ClearValue(item *AlertingPolicy_Spec) { 1569 if item != nil { 1570 switch fp.selector { 1571 case AlertingPolicySpec_FieldPathSelectorEnabled: 1572 item.Enabled = false 1573 case AlertingPolicySpec_FieldPathSelectorConditionCombiner: 1574 item.ConditionCombiner = AlertingPolicy_Spec_OR 1575 case AlertingPolicySpec_FieldPathSelectorNotification: 1576 item.Notification = nil 1577 default: 1578 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fp.selector)) 1579 } 1580 } 1581 } 1582 1583 func (fp *AlertingPolicySpec_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1584 fp.ClearValue(item.(*AlertingPolicy_Spec)) 1585 } 1586 1587 // IsLeaf - whether field path is holds simple value 1588 func (fp *AlertingPolicySpec_FieldTerminalPath) IsLeaf() bool { 1589 return fp.selector == AlertingPolicySpec_FieldPathSelectorEnabled || 1590 fp.selector == AlertingPolicySpec_FieldPathSelectorConditionCombiner 1591 } 1592 1593 func (fp *AlertingPolicySpec_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1594 return []gotenobject.FieldPath{fp} 1595 } 1596 1597 func (fp *AlertingPolicySpec_FieldTerminalPath) WithIValue(value interface{}) AlertingPolicySpec_FieldPathValue { 1598 switch fp.selector { 1599 case AlertingPolicySpec_FieldPathSelectorEnabled: 1600 return &AlertingPolicySpec_FieldTerminalPathValue{AlertingPolicySpec_FieldTerminalPath: *fp, value: value.(bool)} 1601 case AlertingPolicySpec_FieldPathSelectorConditionCombiner: 1602 return &AlertingPolicySpec_FieldTerminalPathValue{AlertingPolicySpec_FieldTerminalPath: *fp, value: value.(AlertingPolicy_Spec_ConditionsCombiner)} 1603 case AlertingPolicySpec_FieldPathSelectorNotification: 1604 return &AlertingPolicySpec_FieldTerminalPathValue{AlertingPolicySpec_FieldTerminalPath: *fp, value: value.(*AlertingPolicy_Spec_Notification)} 1605 default: 1606 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fp.selector)) 1607 } 1608 } 1609 1610 func (fp *AlertingPolicySpec_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1611 return fp.WithIValue(value) 1612 } 1613 1614 func (fp *AlertingPolicySpec_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertingPolicySpec_FieldPathArrayOfValues { 1615 fpaov := &AlertingPolicySpec_FieldTerminalPathArrayOfValues{AlertingPolicySpec_FieldTerminalPath: *fp} 1616 switch fp.selector { 1617 case AlertingPolicySpec_FieldPathSelectorEnabled: 1618 return &AlertingPolicySpec_FieldTerminalPathArrayOfValues{AlertingPolicySpec_FieldTerminalPath: *fp, values: values.([]bool)} 1619 case AlertingPolicySpec_FieldPathSelectorConditionCombiner: 1620 return &AlertingPolicySpec_FieldTerminalPathArrayOfValues{AlertingPolicySpec_FieldTerminalPath: *fp, values: values.([]AlertingPolicy_Spec_ConditionsCombiner)} 1621 case AlertingPolicySpec_FieldPathSelectorNotification: 1622 return &AlertingPolicySpec_FieldTerminalPathArrayOfValues{AlertingPolicySpec_FieldTerminalPath: *fp, values: values.([]*AlertingPolicy_Spec_Notification)} 1623 default: 1624 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fp.selector)) 1625 } 1626 return fpaov 1627 } 1628 1629 func (fp *AlertingPolicySpec_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1630 return fp.WithIArrayOfValues(values) 1631 } 1632 1633 func (fp *AlertingPolicySpec_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertingPolicySpec_FieldPathArrayItemValue { 1634 switch fp.selector { 1635 default: 1636 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fp.selector)) 1637 } 1638 } 1639 1640 func (fp *AlertingPolicySpec_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1641 return fp.WithIArrayItemValue(value) 1642 } 1643 1644 type AlertingPolicySpec_FieldSubPath struct { 1645 selector AlertingPolicySpec_FieldPathSelector 1646 subPath gotenobject.FieldPath 1647 } 1648 1649 var _ AlertingPolicySpec_FieldPath = (*AlertingPolicySpec_FieldSubPath)(nil) 1650 1651 func (fps *AlertingPolicySpec_FieldSubPath) Selector() AlertingPolicySpec_FieldPathSelector { 1652 return fps.selector 1653 } 1654 func (fps *AlertingPolicySpec_FieldSubPath) AsNotificationSubPath() (AlertingPolicySpecNotification_FieldPath, bool) { 1655 res, ok := fps.subPath.(AlertingPolicySpecNotification_FieldPath) 1656 return res, ok 1657 } 1658 1659 // String returns path representation in proto convention 1660 func (fps *AlertingPolicySpec_FieldSubPath) String() string { 1661 return fps.selector.String() + "." + fps.subPath.String() 1662 } 1663 1664 // JSONString returns path representation is JSON convention 1665 func (fps *AlertingPolicySpec_FieldSubPath) JSONString() string { 1666 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 1667 } 1668 1669 // Get returns all values pointed by selected field from source AlertingPolicy_Spec 1670 func (fps *AlertingPolicySpec_FieldSubPath) Get(source *AlertingPolicy_Spec) (values []interface{}) { 1671 switch fps.selector { 1672 case AlertingPolicySpec_FieldPathSelectorNotification: 1673 values = append(values, fps.subPath.GetRaw(source.GetNotification())...) 1674 default: 1675 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fps.selector)) 1676 } 1677 return 1678 } 1679 1680 func (fps *AlertingPolicySpec_FieldSubPath) GetRaw(source proto.Message) []interface{} { 1681 return fps.Get(source.(*AlertingPolicy_Spec)) 1682 } 1683 1684 // GetSingle returns value of selected field from source AlertingPolicy_Spec 1685 func (fps *AlertingPolicySpec_FieldSubPath) GetSingle(source *AlertingPolicy_Spec) (interface{}, bool) { 1686 switch fps.selector { 1687 case AlertingPolicySpec_FieldPathSelectorNotification: 1688 if source.GetNotification() == nil { 1689 return nil, false 1690 } 1691 return fps.subPath.GetSingleRaw(source.GetNotification()) 1692 default: 1693 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fps.selector)) 1694 } 1695 } 1696 1697 func (fps *AlertingPolicySpec_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1698 return fps.GetSingle(source.(*AlertingPolicy_Spec)) 1699 } 1700 1701 // GetDefault returns a default value of the field type 1702 func (fps *AlertingPolicySpec_FieldSubPath) GetDefault() interface{} { 1703 return fps.subPath.GetDefault() 1704 } 1705 1706 func (fps *AlertingPolicySpec_FieldSubPath) ClearValue(item *AlertingPolicy_Spec) { 1707 if item != nil { 1708 switch fps.selector { 1709 case AlertingPolicySpec_FieldPathSelectorNotification: 1710 fps.subPath.ClearValueRaw(item.Notification) 1711 default: 1712 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fps.selector)) 1713 } 1714 } 1715 } 1716 1717 func (fps *AlertingPolicySpec_FieldSubPath) ClearValueRaw(item proto.Message) { 1718 fps.ClearValue(item.(*AlertingPolicy_Spec)) 1719 } 1720 1721 // IsLeaf - whether field path is holds simple value 1722 func (fps *AlertingPolicySpec_FieldSubPath) IsLeaf() bool { 1723 return fps.subPath.IsLeaf() 1724 } 1725 1726 func (fps *AlertingPolicySpec_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1727 iPaths := []gotenobject.FieldPath{&AlertingPolicySpec_FieldTerminalPath{selector: fps.selector}} 1728 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 1729 return iPaths 1730 } 1731 1732 func (fps *AlertingPolicySpec_FieldSubPath) WithIValue(value interface{}) AlertingPolicySpec_FieldPathValue { 1733 return &AlertingPolicySpec_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 1734 } 1735 1736 func (fps *AlertingPolicySpec_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1737 return fps.WithIValue(value) 1738 } 1739 1740 func (fps *AlertingPolicySpec_FieldSubPath) WithIArrayOfValues(values interface{}) AlertingPolicySpec_FieldPathArrayOfValues { 1741 return &AlertingPolicySpec_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 1742 } 1743 1744 func (fps *AlertingPolicySpec_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1745 return fps.WithIArrayOfValues(values) 1746 } 1747 1748 func (fps *AlertingPolicySpec_FieldSubPath) WithIArrayItemValue(value interface{}) AlertingPolicySpec_FieldPathArrayItemValue { 1749 return &AlertingPolicySpec_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 1750 } 1751 1752 func (fps *AlertingPolicySpec_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1753 return fps.WithIArrayItemValue(value) 1754 } 1755 1756 // AlertingPolicySpec_FieldPathValue allows storing values for Spec fields according to their type 1757 type AlertingPolicySpec_FieldPathValue interface { 1758 AlertingPolicySpec_FieldPath 1759 gotenobject.FieldPathValue 1760 SetTo(target **AlertingPolicy_Spec) 1761 CompareWith(*AlertingPolicy_Spec) (cmp int, comparable bool) 1762 } 1763 1764 func ParseAlertingPolicySpec_FieldPathValue(pathStr, valueStr string) (AlertingPolicySpec_FieldPathValue, error) { 1765 fp, err := ParseAlertingPolicySpec_FieldPath(pathStr) 1766 if err != nil { 1767 return nil, err 1768 } 1769 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1770 if err != nil { 1771 return nil, status.Errorf(codes.InvalidArgument, "error parsing Spec field path value from %s: %v", valueStr, err) 1772 } 1773 return fpv.(AlertingPolicySpec_FieldPathValue), nil 1774 } 1775 1776 func MustParseAlertingPolicySpec_FieldPathValue(pathStr, valueStr string) AlertingPolicySpec_FieldPathValue { 1777 fpv, err := ParseAlertingPolicySpec_FieldPathValue(pathStr, valueStr) 1778 if err != nil { 1779 panic(err) 1780 } 1781 return fpv 1782 } 1783 1784 type AlertingPolicySpec_FieldTerminalPathValue struct { 1785 AlertingPolicySpec_FieldTerminalPath 1786 value interface{} 1787 } 1788 1789 var _ AlertingPolicySpec_FieldPathValue = (*AlertingPolicySpec_FieldTerminalPathValue)(nil) 1790 1791 // GetRawValue returns raw value stored under selected path for 'Spec' as interface{} 1792 func (fpv *AlertingPolicySpec_FieldTerminalPathValue) GetRawValue() interface{} { 1793 return fpv.value 1794 } 1795 func (fpv *AlertingPolicySpec_FieldTerminalPathValue) AsEnabledValue() (bool, bool) { 1796 res, ok := fpv.value.(bool) 1797 return res, ok 1798 } 1799 func (fpv *AlertingPolicySpec_FieldTerminalPathValue) AsConditionCombinerValue() (AlertingPolicy_Spec_ConditionsCombiner, bool) { 1800 res, ok := fpv.value.(AlertingPolicy_Spec_ConditionsCombiner) 1801 return res, ok 1802 } 1803 func (fpv *AlertingPolicySpec_FieldTerminalPathValue) AsNotificationValue() (*AlertingPolicy_Spec_Notification, bool) { 1804 res, ok := fpv.value.(*AlertingPolicy_Spec_Notification) 1805 return res, ok 1806 } 1807 1808 // SetTo stores value for selected field for object Spec 1809 func (fpv *AlertingPolicySpec_FieldTerminalPathValue) SetTo(target **AlertingPolicy_Spec) { 1810 if *target == nil { 1811 *target = new(AlertingPolicy_Spec) 1812 } 1813 switch fpv.selector { 1814 case AlertingPolicySpec_FieldPathSelectorEnabled: 1815 (*target).Enabled = fpv.value.(bool) 1816 case AlertingPolicySpec_FieldPathSelectorConditionCombiner: 1817 (*target).ConditionCombiner = fpv.value.(AlertingPolicy_Spec_ConditionsCombiner) 1818 case AlertingPolicySpec_FieldPathSelectorNotification: 1819 (*target).Notification = fpv.value.(*AlertingPolicy_Spec_Notification) 1820 default: 1821 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fpv.selector)) 1822 } 1823 } 1824 1825 func (fpv *AlertingPolicySpec_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1826 typedObject := target.(*AlertingPolicy_Spec) 1827 fpv.SetTo(&typedObject) 1828 } 1829 1830 // CompareWith compares value in the 'AlertingPolicySpec_FieldTerminalPathValue' with the value under path in 'AlertingPolicy_Spec'. 1831 func (fpv *AlertingPolicySpec_FieldTerminalPathValue) CompareWith(source *AlertingPolicy_Spec) (int, bool) { 1832 switch fpv.selector { 1833 case AlertingPolicySpec_FieldPathSelectorEnabled: 1834 leftValue := fpv.value.(bool) 1835 rightValue := source.GetEnabled() 1836 if (leftValue) == (rightValue) { 1837 return 0, true 1838 } else if !(leftValue) && (rightValue) { 1839 return -1, true 1840 } else { 1841 return 1, true 1842 } 1843 case AlertingPolicySpec_FieldPathSelectorConditionCombiner: 1844 leftValue := fpv.value.(AlertingPolicy_Spec_ConditionsCombiner) 1845 rightValue := source.GetConditionCombiner() 1846 if (leftValue) == (rightValue) { 1847 return 0, true 1848 } else if (leftValue) < (rightValue) { 1849 return -1, true 1850 } else { 1851 return 1, true 1852 } 1853 case AlertingPolicySpec_FieldPathSelectorNotification: 1854 return 0, false 1855 default: 1856 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fpv.selector)) 1857 } 1858 } 1859 1860 func (fpv *AlertingPolicySpec_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1861 return fpv.CompareWith(source.(*AlertingPolicy_Spec)) 1862 } 1863 1864 type AlertingPolicySpec_FieldSubPathValue struct { 1865 AlertingPolicySpec_FieldPath 1866 subPathValue gotenobject.FieldPathValue 1867 } 1868 1869 var _ AlertingPolicySpec_FieldPathValue = (*AlertingPolicySpec_FieldSubPathValue)(nil) 1870 1871 func (fpvs *AlertingPolicySpec_FieldSubPathValue) AsNotificationPathValue() (AlertingPolicySpecNotification_FieldPathValue, bool) { 1872 res, ok := fpvs.subPathValue.(AlertingPolicySpecNotification_FieldPathValue) 1873 return res, ok 1874 } 1875 1876 func (fpvs *AlertingPolicySpec_FieldSubPathValue) SetTo(target **AlertingPolicy_Spec) { 1877 if *target == nil { 1878 *target = new(AlertingPolicy_Spec) 1879 } 1880 switch fpvs.Selector() { 1881 case AlertingPolicySpec_FieldPathSelectorNotification: 1882 fpvs.subPathValue.(AlertingPolicySpecNotification_FieldPathValue).SetTo(&(*target).Notification) 1883 default: 1884 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fpvs.Selector())) 1885 } 1886 } 1887 1888 func (fpvs *AlertingPolicySpec_FieldSubPathValue) SetToRaw(target proto.Message) { 1889 typedObject := target.(*AlertingPolicy_Spec) 1890 fpvs.SetTo(&typedObject) 1891 } 1892 1893 func (fpvs *AlertingPolicySpec_FieldSubPathValue) GetRawValue() interface{} { 1894 return fpvs.subPathValue.GetRawValue() 1895 } 1896 1897 func (fpvs *AlertingPolicySpec_FieldSubPathValue) CompareWith(source *AlertingPolicy_Spec) (int, bool) { 1898 switch fpvs.Selector() { 1899 case AlertingPolicySpec_FieldPathSelectorNotification: 1900 return fpvs.subPathValue.(AlertingPolicySpecNotification_FieldPathValue).CompareWith(source.GetNotification()) 1901 default: 1902 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fpvs.Selector())) 1903 } 1904 } 1905 1906 func (fpvs *AlertingPolicySpec_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1907 return fpvs.CompareWith(source.(*AlertingPolicy_Spec)) 1908 } 1909 1910 // AlertingPolicySpec_FieldPathArrayItemValue allows storing single item in Path-specific values for Spec according to their type 1911 // Present only for array (repeated) types. 1912 type AlertingPolicySpec_FieldPathArrayItemValue interface { 1913 gotenobject.FieldPathArrayItemValue 1914 AlertingPolicySpec_FieldPath 1915 ContainsValue(*AlertingPolicy_Spec) bool 1916 } 1917 1918 // ParseAlertingPolicySpec_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1919 func ParseAlertingPolicySpec_FieldPathArrayItemValue(pathStr, valueStr string) (AlertingPolicySpec_FieldPathArrayItemValue, error) { 1920 fp, err := ParseAlertingPolicySpec_FieldPath(pathStr) 1921 if err != nil { 1922 return nil, err 1923 } 1924 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1925 if err != nil { 1926 return nil, status.Errorf(codes.InvalidArgument, "error parsing Spec field path array item value from %s: %v", valueStr, err) 1927 } 1928 return fpaiv.(AlertingPolicySpec_FieldPathArrayItemValue), nil 1929 } 1930 1931 func MustParseAlertingPolicySpec_FieldPathArrayItemValue(pathStr, valueStr string) AlertingPolicySpec_FieldPathArrayItemValue { 1932 fpaiv, err := ParseAlertingPolicySpec_FieldPathArrayItemValue(pathStr, valueStr) 1933 if err != nil { 1934 panic(err) 1935 } 1936 return fpaiv 1937 } 1938 1939 type AlertingPolicySpec_FieldTerminalPathArrayItemValue struct { 1940 AlertingPolicySpec_FieldTerminalPath 1941 value interface{} 1942 } 1943 1944 var _ AlertingPolicySpec_FieldPathArrayItemValue = (*AlertingPolicySpec_FieldTerminalPathArrayItemValue)(nil) 1945 1946 // GetRawValue returns stored element value for array in object AlertingPolicy_Spec as interface{} 1947 func (fpaiv *AlertingPolicySpec_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1948 return fpaiv.value 1949 } 1950 1951 func (fpaiv *AlertingPolicySpec_FieldTerminalPathArrayItemValue) GetSingle(source *AlertingPolicy_Spec) (interface{}, bool) { 1952 return nil, false 1953 } 1954 1955 func (fpaiv *AlertingPolicySpec_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1956 return fpaiv.GetSingle(source.(*AlertingPolicy_Spec)) 1957 } 1958 1959 // Contains returns a boolean indicating if value that is being held is present in given 'Spec' 1960 func (fpaiv *AlertingPolicySpec_FieldTerminalPathArrayItemValue) ContainsValue(source *AlertingPolicy_Spec) bool { 1961 slice := fpaiv.AlertingPolicySpec_FieldTerminalPath.Get(source) 1962 for _, v := range slice { 1963 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1964 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1965 return true 1966 } 1967 } else if reflect.DeepEqual(v, fpaiv.value) { 1968 return true 1969 } 1970 } 1971 return false 1972 } 1973 1974 type AlertingPolicySpec_FieldSubPathArrayItemValue struct { 1975 AlertingPolicySpec_FieldPath 1976 subPathItemValue gotenobject.FieldPathArrayItemValue 1977 } 1978 1979 // GetRawValue returns stored array item value 1980 func (fpaivs *AlertingPolicySpec_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 1981 return fpaivs.subPathItemValue.GetRawItemValue() 1982 } 1983 func (fpaivs *AlertingPolicySpec_FieldSubPathArrayItemValue) AsNotificationPathItemValue() (AlertingPolicySpecNotification_FieldPathArrayItemValue, bool) { 1984 res, ok := fpaivs.subPathItemValue.(AlertingPolicySpecNotification_FieldPathArrayItemValue) 1985 return res, ok 1986 } 1987 1988 // Contains returns a boolean indicating if value that is being held is present in given 'Spec' 1989 func (fpaivs *AlertingPolicySpec_FieldSubPathArrayItemValue) ContainsValue(source *AlertingPolicy_Spec) bool { 1990 switch fpaivs.Selector() { 1991 case AlertingPolicySpec_FieldPathSelectorNotification: 1992 return fpaivs.subPathItemValue.(AlertingPolicySpecNotification_FieldPathArrayItemValue).ContainsValue(source.GetNotification()) 1993 default: 1994 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec: %d", fpaivs.Selector())) 1995 } 1996 } 1997 1998 // AlertingPolicySpec_FieldPathArrayOfValues allows storing slice of values for Spec fields according to their type 1999 type AlertingPolicySpec_FieldPathArrayOfValues interface { 2000 gotenobject.FieldPathArrayOfValues 2001 AlertingPolicySpec_FieldPath 2002 } 2003 2004 func ParseAlertingPolicySpec_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertingPolicySpec_FieldPathArrayOfValues, error) { 2005 fp, err := ParseAlertingPolicySpec_FieldPath(pathStr) 2006 if err != nil { 2007 return nil, err 2008 } 2009 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 2010 if err != nil { 2011 return nil, status.Errorf(codes.InvalidArgument, "error parsing Spec field path array of values from %s: %v", valuesStr, err) 2012 } 2013 return fpaov.(AlertingPolicySpec_FieldPathArrayOfValues), nil 2014 } 2015 2016 func MustParseAlertingPolicySpec_FieldPathArrayOfValues(pathStr, valuesStr string) AlertingPolicySpec_FieldPathArrayOfValues { 2017 fpaov, err := ParseAlertingPolicySpec_FieldPathArrayOfValues(pathStr, valuesStr) 2018 if err != nil { 2019 panic(err) 2020 } 2021 return fpaov 2022 } 2023 2024 type AlertingPolicySpec_FieldTerminalPathArrayOfValues struct { 2025 AlertingPolicySpec_FieldTerminalPath 2026 values interface{} 2027 } 2028 2029 var _ AlertingPolicySpec_FieldPathArrayOfValues = (*AlertingPolicySpec_FieldTerminalPathArrayOfValues)(nil) 2030 2031 func (fpaov *AlertingPolicySpec_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 2032 switch fpaov.selector { 2033 case AlertingPolicySpec_FieldPathSelectorEnabled: 2034 for _, v := range fpaov.values.([]bool) { 2035 values = append(values, v) 2036 } 2037 case AlertingPolicySpec_FieldPathSelectorConditionCombiner: 2038 for _, v := range fpaov.values.([]AlertingPolicy_Spec_ConditionsCombiner) { 2039 values = append(values, v) 2040 } 2041 case AlertingPolicySpec_FieldPathSelectorNotification: 2042 for _, v := range fpaov.values.([]*AlertingPolicy_Spec_Notification) { 2043 values = append(values, v) 2044 } 2045 } 2046 return 2047 } 2048 func (fpaov *AlertingPolicySpec_FieldTerminalPathArrayOfValues) AsEnabledArrayOfValues() ([]bool, bool) { 2049 res, ok := fpaov.values.([]bool) 2050 return res, ok 2051 } 2052 func (fpaov *AlertingPolicySpec_FieldTerminalPathArrayOfValues) AsConditionCombinerArrayOfValues() ([]AlertingPolicy_Spec_ConditionsCombiner, bool) { 2053 res, ok := fpaov.values.([]AlertingPolicy_Spec_ConditionsCombiner) 2054 return res, ok 2055 } 2056 func (fpaov *AlertingPolicySpec_FieldTerminalPathArrayOfValues) AsNotificationArrayOfValues() ([]*AlertingPolicy_Spec_Notification, bool) { 2057 res, ok := fpaov.values.([]*AlertingPolicy_Spec_Notification) 2058 return res, ok 2059 } 2060 2061 type AlertingPolicySpec_FieldSubPathArrayOfValues struct { 2062 AlertingPolicySpec_FieldPath 2063 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 2064 } 2065 2066 var _ AlertingPolicySpec_FieldPathArrayOfValues = (*AlertingPolicySpec_FieldSubPathArrayOfValues)(nil) 2067 2068 func (fpsaov *AlertingPolicySpec_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 2069 return fpsaov.subPathArrayOfValues.GetRawValues() 2070 } 2071 func (fpsaov *AlertingPolicySpec_FieldSubPathArrayOfValues) AsNotificationPathArrayOfValues() (AlertingPolicySpecNotification_FieldPathArrayOfValues, bool) { 2072 res, ok := fpsaov.subPathArrayOfValues.(AlertingPolicySpecNotification_FieldPathArrayOfValues) 2073 return res, ok 2074 } 2075 2076 // FieldPath provides implementation to handle 2077 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 2078 type AlertingPolicyState_FieldPath interface { 2079 gotenobject.FieldPath 2080 Selector() AlertingPolicyState_FieldPathSelector 2081 Get(source *AlertingPolicy_State) []interface{} 2082 GetSingle(source *AlertingPolicy_State) (interface{}, bool) 2083 ClearValue(item *AlertingPolicy_State) 2084 2085 // Those methods build corresponding AlertingPolicyState_FieldPathValue 2086 // (or array of values) and holds passed value. Panics if injected type is incorrect. 2087 WithIValue(value interface{}) AlertingPolicyState_FieldPathValue 2088 WithIArrayOfValues(values interface{}) AlertingPolicyState_FieldPathArrayOfValues 2089 WithIArrayItemValue(value interface{}) AlertingPolicyState_FieldPathArrayItemValue 2090 } 2091 2092 type AlertingPolicyState_FieldPathSelector int32 2093 2094 const ( 2095 AlertingPolicyState_FieldPathSelectorActiveAlertsCount AlertingPolicyState_FieldPathSelector = 0 2096 ) 2097 2098 func (s AlertingPolicyState_FieldPathSelector) String() string { 2099 switch s { 2100 case AlertingPolicyState_FieldPathSelectorActiveAlertsCount: 2101 return "active_alerts_count" 2102 default: 2103 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_State: %d", s)) 2104 } 2105 } 2106 2107 func BuildAlertingPolicyState_FieldPath(fp gotenobject.RawFieldPath) (AlertingPolicyState_FieldPath, error) { 2108 if len(fp) == 0 { 2109 return nil, status.Error(codes.InvalidArgument, "empty field path for object AlertingPolicy_State") 2110 } 2111 if len(fp) == 1 { 2112 switch fp[0] { 2113 case "active_alerts_count", "activeAlertsCount", "active-alerts-count": 2114 return &AlertingPolicyState_FieldTerminalPath{selector: AlertingPolicyState_FieldPathSelectorActiveAlertsCount}, nil 2115 } 2116 } 2117 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object AlertingPolicy_State", fp) 2118 } 2119 2120 func ParseAlertingPolicyState_FieldPath(rawField string) (AlertingPolicyState_FieldPath, error) { 2121 fp, err := gotenobject.ParseRawFieldPath(rawField) 2122 if err != nil { 2123 return nil, err 2124 } 2125 return BuildAlertingPolicyState_FieldPath(fp) 2126 } 2127 2128 func MustParseAlertingPolicyState_FieldPath(rawField string) AlertingPolicyState_FieldPath { 2129 fp, err := ParseAlertingPolicyState_FieldPath(rawField) 2130 if err != nil { 2131 panic(err) 2132 } 2133 return fp 2134 } 2135 2136 type AlertingPolicyState_FieldTerminalPath struct { 2137 selector AlertingPolicyState_FieldPathSelector 2138 } 2139 2140 var _ AlertingPolicyState_FieldPath = (*AlertingPolicyState_FieldTerminalPath)(nil) 2141 2142 func (fp *AlertingPolicyState_FieldTerminalPath) Selector() AlertingPolicyState_FieldPathSelector { 2143 return fp.selector 2144 } 2145 2146 // String returns path representation in proto convention 2147 func (fp *AlertingPolicyState_FieldTerminalPath) String() string { 2148 return fp.selector.String() 2149 } 2150 2151 // JSONString returns path representation is JSON convention 2152 func (fp *AlertingPolicyState_FieldTerminalPath) JSONString() string { 2153 return strcase.ToLowerCamel(fp.String()) 2154 } 2155 2156 // Get returns all values pointed by specific field from source AlertingPolicy_State 2157 func (fp *AlertingPolicyState_FieldTerminalPath) Get(source *AlertingPolicy_State) (values []interface{}) { 2158 if source != nil { 2159 switch fp.selector { 2160 case AlertingPolicyState_FieldPathSelectorActiveAlertsCount: 2161 values = append(values, source.ActiveAlertsCount) 2162 default: 2163 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_State: %d", fp.selector)) 2164 } 2165 } 2166 return 2167 } 2168 2169 func (fp *AlertingPolicyState_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 2170 return fp.Get(source.(*AlertingPolicy_State)) 2171 } 2172 2173 // GetSingle returns value pointed by specific field of from source AlertingPolicy_State 2174 func (fp *AlertingPolicyState_FieldTerminalPath) GetSingle(source *AlertingPolicy_State) (interface{}, bool) { 2175 switch fp.selector { 2176 case AlertingPolicyState_FieldPathSelectorActiveAlertsCount: 2177 return source.GetActiveAlertsCount(), source != nil 2178 default: 2179 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_State: %d", fp.selector)) 2180 } 2181 } 2182 2183 func (fp *AlertingPolicyState_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 2184 return fp.GetSingle(source.(*AlertingPolicy_State)) 2185 } 2186 2187 // GetDefault returns a default value of the field type 2188 func (fp *AlertingPolicyState_FieldTerminalPath) GetDefault() interface{} { 2189 switch fp.selector { 2190 case AlertingPolicyState_FieldPathSelectorActiveAlertsCount: 2191 return int64(0) 2192 default: 2193 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_State: %d", fp.selector)) 2194 } 2195 } 2196 2197 func (fp *AlertingPolicyState_FieldTerminalPath) ClearValue(item *AlertingPolicy_State) { 2198 if item != nil { 2199 switch fp.selector { 2200 case AlertingPolicyState_FieldPathSelectorActiveAlertsCount: 2201 item.ActiveAlertsCount = int64(0) 2202 default: 2203 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_State: %d", fp.selector)) 2204 } 2205 } 2206 } 2207 2208 func (fp *AlertingPolicyState_FieldTerminalPath) ClearValueRaw(item proto.Message) { 2209 fp.ClearValue(item.(*AlertingPolicy_State)) 2210 } 2211 2212 // IsLeaf - whether field path is holds simple value 2213 func (fp *AlertingPolicyState_FieldTerminalPath) IsLeaf() bool { 2214 return fp.selector == AlertingPolicyState_FieldPathSelectorActiveAlertsCount 2215 } 2216 2217 func (fp *AlertingPolicyState_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 2218 return []gotenobject.FieldPath{fp} 2219 } 2220 2221 func (fp *AlertingPolicyState_FieldTerminalPath) WithIValue(value interface{}) AlertingPolicyState_FieldPathValue { 2222 switch fp.selector { 2223 case AlertingPolicyState_FieldPathSelectorActiveAlertsCount: 2224 return &AlertingPolicyState_FieldTerminalPathValue{AlertingPolicyState_FieldTerminalPath: *fp, value: value.(int64)} 2225 default: 2226 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_State: %d", fp.selector)) 2227 } 2228 } 2229 2230 func (fp *AlertingPolicyState_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 2231 return fp.WithIValue(value) 2232 } 2233 2234 func (fp *AlertingPolicyState_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertingPolicyState_FieldPathArrayOfValues { 2235 fpaov := &AlertingPolicyState_FieldTerminalPathArrayOfValues{AlertingPolicyState_FieldTerminalPath: *fp} 2236 switch fp.selector { 2237 case AlertingPolicyState_FieldPathSelectorActiveAlertsCount: 2238 return &AlertingPolicyState_FieldTerminalPathArrayOfValues{AlertingPolicyState_FieldTerminalPath: *fp, values: values.([]int64)} 2239 default: 2240 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_State: %d", fp.selector)) 2241 } 2242 return fpaov 2243 } 2244 2245 func (fp *AlertingPolicyState_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 2246 return fp.WithIArrayOfValues(values) 2247 } 2248 2249 func (fp *AlertingPolicyState_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertingPolicyState_FieldPathArrayItemValue { 2250 switch fp.selector { 2251 default: 2252 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_State: %d", fp.selector)) 2253 } 2254 } 2255 2256 func (fp *AlertingPolicyState_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 2257 return fp.WithIArrayItemValue(value) 2258 } 2259 2260 // AlertingPolicyState_FieldPathValue allows storing values for State fields according to their type 2261 type AlertingPolicyState_FieldPathValue interface { 2262 AlertingPolicyState_FieldPath 2263 gotenobject.FieldPathValue 2264 SetTo(target **AlertingPolicy_State) 2265 CompareWith(*AlertingPolicy_State) (cmp int, comparable bool) 2266 } 2267 2268 func ParseAlertingPolicyState_FieldPathValue(pathStr, valueStr string) (AlertingPolicyState_FieldPathValue, error) { 2269 fp, err := ParseAlertingPolicyState_FieldPath(pathStr) 2270 if err != nil { 2271 return nil, err 2272 } 2273 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 2274 if err != nil { 2275 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path value from %s: %v", valueStr, err) 2276 } 2277 return fpv.(AlertingPolicyState_FieldPathValue), nil 2278 } 2279 2280 func MustParseAlertingPolicyState_FieldPathValue(pathStr, valueStr string) AlertingPolicyState_FieldPathValue { 2281 fpv, err := ParseAlertingPolicyState_FieldPathValue(pathStr, valueStr) 2282 if err != nil { 2283 panic(err) 2284 } 2285 return fpv 2286 } 2287 2288 type AlertingPolicyState_FieldTerminalPathValue struct { 2289 AlertingPolicyState_FieldTerminalPath 2290 value interface{} 2291 } 2292 2293 var _ AlertingPolicyState_FieldPathValue = (*AlertingPolicyState_FieldTerminalPathValue)(nil) 2294 2295 // GetRawValue returns raw value stored under selected path for 'State' as interface{} 2296 func (fpv *AlertingPolicyState_FieldTerminalPathValue) GetRawValue() interface{} { 2297 return fpv.value 2298 } 2299 func (fpv *AlertingPolicyState_FieldTerminalPathValue) AsActiveAlertsCountValue() (int64, bool) { 2300 res, ok := fpv.value.(int64) 2301 return res, ok 2302 } 2303 2304 // SetTo stores value for selected field for object State 2305 func (fpv *AlertingPolicyState_FieldTerminalPathValue) SetTo(target **AlertingPolicy_State) { 2306 if *target == nil { 2307 *target = new(AlertingPolicy_State) 2308 } 2309 switch fpv.selector { 2310 case AlertingPolicyState_FieldPathSelectorActiveAlertsCount: 2311 (*target).ActiveAlertsCount = fpv.value.(int64) 2312 default: 2313 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_State: %d", fpv.selector)) 2314 } 2315 } 2316 2317 func (fpv *AlertingPolicyState_FieldTerminalPathValue) SetToRaw(target proto.Message) { 2318 typedObject := target.(*AlertingPolicy_State) 2319 fpv.SetTo(&typedObject) 2320 } 2321 2322 // CompareWith compares value in the 'AlertingPolicyState_FieldTerminalPathValue' with the value under path in 'AlertingPolicy_State'. 2323 func (fpv *AlertingPolicyState_FieldTerminalPathValue) CompareWith(source *AlertingPolicy_State) (int, bool) { 2324 switch fpv.selector { 2325 case AlertingPolicyState_FieldPathSelectorActiveAlertsCount: 2326 leftValue := fpv.value.(int64) 2327 rightValue := source.GetActiveAlertsCount() 2328 if (leftValue) == (rightValue) { 2329 return 0, true 2330 } else if (leftValue) < (rightValue) { 2331 return -1, true 2332 } else { 2333 return 1, true 2334 } 2335 default: 2336 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_State: %d", fpv.selector)) 2337 } 2338 } 2339 2340 func (fpv *AlertingPolicyState_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2341 return fpv.CompareWith(source.(*AlertingPolicy_State)) 2342 } 2343 2344 // AlertingPolicyState_FieldPathArrayItemValue allows storing single item in Path-specific values for State according to their type 2345 // Present only for array (repeated) types. 2346 type AlertingPolicyState_FieldPathArrayItemValue interface { 2347 gotenobject.FieldPathArrayItemValue 2348 AlertingPolicyState_FieldPath 2349 ContainsValue(*AlertingPolicy_State) bool 2350 } 2351 2352 // ParseAlertingPolicyState_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 2353 func ParseAlertingPolicyState_FieldPathArrayItemValue(pathStr, valueStr string) (AlertingPolicyState_FieldPathArrayItemValue, error) { 2354 fp, err := ParseAlertingPolicyState_FieldPath(pathStr) 2355 if err != nil { 2356 return nil, err 2357 } 2358 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 2359 if err != nil { 2360 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path array item value from %s: %v", valueStr, err) 2361 } 2362 return fpaiv.(AlertingPolicyState_FieldPathArrayItemValue), nil 2363 } 2364 2365 func MustParseAlertingPolicyState_FieldPathArrayItemValue(pathStr, valueStr string) AlertingPolicyState_FieldPathArrayItemValue { 2366 fpaiv, err := ParseAlertingPolicyState_FieldPathArrayItemValue(pathStr, valueStr) 2367 if err != nil { 2368 panic(err) 2369 } 2370 return fpaiv 2371 } 2372 2373 type AlertingPolicyState_FieldTerminalPathArrayItemValue struct { 2374 AlertingPolicyState_FieldTerminalPath 2375 value interface{} 2376 } 2377 2378 var _ AlertingPolicyState_FieldPathArrayItemValue = (*AlertingPolicyState_FieldTerminalPathArrayItemValue)(nil) 2379 2380 // GetRawValue returns stored element value for array in object AlertingPolicy_State as interface{} 2381 func (fpaiv *AlertingPolicyState_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 2382 return fpaiv.value 2383 } 2384 2385 func (fpaiv *AlertingPolicyState_FieldTerminalPathArrayItemValue) GetSingle(source *AlertingPolicy_State) (interface{}, bool) { 2386 return nil, false 2387 } 2388 2389 func (fpaiv *AlertingPolicyState_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 2390 return fpaiv.GetSingle(source.(*AlertingPolicy_State)) 2391 } 2392 2393 // Contains returns a boolean indicating if value that is being held is present in given 'State' 2394 func (fpaiv *AlertingPolicyState_FieldTerminalPathArrayItemValue) ContainsValue(source *AlertingPolicy_State) bool { 2395 slice := fpaiv.AlertingPolicyState_FieldTerminalPath.Get(source) 2396 for _, v := range slice { 2397 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 2398 if proto.Equal(asProtoMsg, v.(proto.Message)) { 2399 return true 2400 } 2401 } else if reflect.DeepEqual(v, fpaiv.value) { 2402 return true 2403 } 2404 } 2405 return false 2406 } 2407 2408 // AlertingPolicyState_FieldPathArrayOfValues allows storing slice of values for State fields according to their type 2409 type AlertingPolicyState_FieldPathArrayOfValues interface { 2410 gotenobject.FieldPathArrayOfValues 2411 AlertingPolicyState_FieldPath 2412 } 2413 2414 func ParseAlertingPolicyState_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertingPolicyState_FieldPathArrayOfValues, error) { 2415 fp, err := ParseAlertingPolicyState_FieldPath(pathStr) 2416 if err != nil { 2417 return nil, err 2418 } 2419 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 2420 if err != nil { 2421 return nil, status.Errorf(codes.InvalidArgument, "error parsing State field path array of values from %s: %v", valuesStr, err) 2422 } 2423 return fpaov.(AlertingPolicyState_FieldPathArrayOfValues), nil 2424 } 2425 2426 func MustParseAlertingPolicyState_FieldPathArrayOfValues(pathStr, valuesStr string) AlertingPolicyState_FieldPathArrayOfValues { 2427 fpaov, err := ParseAlertingPolicyState_FieldPathArrayOfValues(pathStr, valuesStr) 2428 if err != nil { 2429 panic(err) 2430 } 2431 return fpaov 2432 } 2433 2434 type AlertingPolicyState_FieldTerminalPathArrayOfValues struct { 2435 AlertingPolicyState_FieldTerminalPath 2436 values interface{} 2437 } 2438 2439 var _ AlertingPolicyState_FieldPathArrayOfValues = (*AlertingPolicyState_FieldTerminalPathArrayOfValues)(nil) 2440 2441 func (fpaov *AlertingPolicyState_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 2442 switch fpaov.selector { 2443 case AlertingPolicyState_FieldPathSelectorActiveAlertsCount: 2444 for _, v := range fpaov.values.([]int64) { 2445 values = append(values, v) 2446 } 2447 } 2448 return 2449 } 2450 func (fpaov *AlertingPolicyState_FieldTerminalPathArrayOfValues) AsActiveAlertsCountArrayOfValues() ([]int64, bool) { 2451 res, ok := fpaov.values.([]int64) 2452 return res, ok 2453 } 2454 2455 // FieldPath provides implementation to handle 2456 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 2457 type AlertingPolicySpecNotification_FieldPath interface { 2458 gotenobject.FieldPath 2459 Selector() AlertingPolicySpecNotification_FieldPathSelector 2460 Get(source *AlertingPolicy_Spec_Notification) []interface{} 2461 GetSingle(source *AlertingPolicy_Spec_Notification) (interface{}, bool) 2462 ClearValue(item *AlertingPolicy_Spec_Notification) 2463 2464 // Those methods build corresponding AlertingPolicySpecNotification_FieldPathValue 2465 // (or array of values) and holds passed value. Panics if injected type is incorrect. 2466 WithIValue(value interface{}) AlertingPolicySpecNotification_FieldPathValue 2467 WithIArrayOfValues(values interface{}) AlertingPolicySpecNotification_FieldPathArrayOfValues 2468 WithIArrayItemValue(value interface{}) AlertingPolicySpecNotification_FieldPathArrayItemValue 2469 } 2470 2471 type AlertingPolicySpecNotification_FieldPathSelector int32 2472 2473 const ( 2474 AlertingPolicySpecNotification_FieldPathSelectorEnabled AlertingPolicySpecNotification_FieldPathSelector = 0 2475 AlertingPolicySpecNotification_FieldPathSelectorChannels AlertingPolicySpecNotification_FieldPathSelector = 1 2476 ) 2477 2478 func (s AlertingPolicySpecNotification_FieldPathSelector) String() string { 2479 switch s { 2480 case AlertingPolicySpecNotification_FieldPathSelectorEnabled: 2481 return "enabled" 2482 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2483 return "channels" 2484 default: 2485 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec_Notification: %d", s)) 2486 } 2487 } 2488 2489 func BuildAlertingPolicySpecNotification_FieldPath(fp gotenobject.RawFieldPath) (AlertingPolicySpecNotification_FieldPath, error) { 2490 if len(fp) == 0 { 2491 return nil, status.Error(codes.InvalidArgument, "empty field path for object AlertingPolicy_Spec_Notification") 2492 } 2493 if len(fp) == 1 { 2494 switch fp[0] { 2495 case "enabled": 2496 return &AlertingPolicySpecNotification_FieldTerminalPath{selector: AlertingPolicySpecNotification_FieldPathSelectorEnabled}, nil 2497 case "channels": 2498 return &AlertingPolicySpecNotification_FieldTerminalPath{selector: AlertingPolicySpecNotification_FieldPathSelectorChannels}, nil 2499 } 2500 } 2501 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object AlertingPolicy_Spec_Notification", fp) 2502 } 2503 2504 func ParseAlertingPolicySpecNotification_FieldPath(rawField string) (AlertingPolicySpecNotification_FieldPath, error) { 2505 fp, err := gotenobject.ParseRawFieldPath(rawField) 2506 if err != nil { 2507 return nil, err 2508 } 2509 return BuildAlertingPolicySpecNotification_FieldPath(fp) 2510 } 2511 2512 func MustParseAlertingPolicySpecNotification_FieldPath(rawField string) AlertingPolicySpecNotification_FieldPath { 2513 fp, err := ParseAlertingPolicySpecNotification_FieldPath(rawField) 2514 if err != nil { 2515 panic(err) 2516 } 2517 return fp 2518 } 2519 2520 type AlertingPolicySpecNotification_FieldTerminalPath struct { 2521 selector AlertingPolicySpecNotification_FieldPathSelector 2522 } 2523 2524 var _ AlertingPolicySpecNotification_FieldPath = (*AlertingPolicySpecNotification_FieldTerminalPath)(nil) 2525 2526 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) Selector() AlertingPolicySpecNotification_FieldPathSelector { 2527 return fp.selector 2528 } 2529 2530 // String returns path representation in proto convention 2531 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) String() string { 2532 return fp.selector.String() 2533 } 2534 2535 // JSONString returns path representation is JSON convention 2536 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) JSONString() string { 2537 return strcase.ToLowerCamel(fp.String()) 2538 } 2539 2540 // Get returns all values pointed by specific field from source AlertingPolicy_Spec_Notification 2541 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) Get(source *AlertingPolicy_Spec_Notification) (values []interface{}) { 2542 if source != nil { 2543 switch fp.selector { 2544 case AlertingPolicySpecNotification_FieldPathSelectorEnabled: 2545 values = append(values, source.Enabled) 2546 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2547 for _, value := range source.GetChannels() { 2548 values = append(values, value) 2549 } 2550 default: 2551 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec_Notification: %d", fp.selector)) 2552 } 2553 } 2554 return 2555 } 2556 2557 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 2558 return fp.Get(source.(*AlertingPolicy_Spec_Notification)) 2559 } 2560 2561 // GetSingle returns value pointed by specific field of from source AlertingPolicy_Spec_Notification 2562 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) GetSingle(source *AlertingPolicy_Spec_Notification) (interface{}, bool) { 2563 switch fp.selector { 2564 case AlertingPolicySpecNotification_FieldPathSelectorEnabled: 2565 return source.GetEnabled(), source != nil 2566 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2567 res := source.GetChannels() 2568 return res, res != nil 2569 default: 2570 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec_Notification: %d", fp.selector)) 2571 } 2572 } 2573 2574 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 2575 return fp.GetSingle(source.(*AlertingPolicy_Spec_Notification)) 2576 } 2577 2578 // GetDefault returns a default value of the field type 2579 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) GetDefault() interface{} { 2580 switch fp.selector { 2581 case AlertingPolicySpecNotification_FieldPathSelectorEnabled: 2582 return false 2583 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2584 return ([]*notification_channel.Reference)(nil) 2585 default: 2586 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec_Notification: %d", fp.selector)) 2587 } 2588 } 2589 2590 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) ClearValue(item *AlertingPolicy_Spec_Notification) { 2591 if item != nil { 2592 switch fp.selector { 2593 case AlertingPolicySpecNotification_FieldPathSelectorEnabled: 2594 item.Enabled = false 2595 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2596 item.Channels = nil 2597 default: 2598 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec_Notification: %d", fp.selector)) 2599 } 2600 } 2601 } 2602 2603 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) ClearValueRaw(item proto.Message) { 2604 fp.ClearValue(item.(*AlertingPolicy_Spec_Notification)) 2605 } 2606 2607 // IsLeaf - whether field path is holds simple value 2608 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) IsLeaf() bool { 2609 return fp.selector == AlertingPolicySpecNotification_FieldPathSelectorEnabled || 2610 fp.selector == AlertingPolicySpecNotification_FieldPathSelectorChannels 2611 } 2612 2613 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 2614 return []gotenobject.FieldPath{fp} 2615 } 2616 2617 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) WithIValue(value interface{}) AlertingPolicySpecNotification_FieldPathValue { 2618 switch fp.selector { 2619 case AlertingPolicySpecNotification_FieldPathSelectorEnabled: 2620 return &AlertingPolicySpecNotification_FieldTerminalPathValue{AlertingPolicySpecNotification_FieldTerminalPath: *fp, value: value.(bool)} 2621 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2622 return &AlertingPolicySpecNotification_FieldTerminalPathValue{AlertingPolicySpecNotification_FieldTerminalPath: *fp, value: value.([]*notification_channel.Reference)} 2623 default: 2624 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec_Notification: %d", fp.selector)) 2625 } 2626 } 2627 2628 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 2629 return fp.WithIValue(value) 2630 } 2631 2632 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) WithIArrayOfValues(values interface{}) AlertingPolicySpecNotification_FieldPathArrayOfValues { 2633 fpaov := &AlertingPolicySpecNotification_FieldTerminalPathArrayOfValues{AlertingPolicySpecNotification_FieldTerminalPath: *fp} 2634 switch fp.selector { 2635 case AlertingPolicySpecNotification_FieldPathSelectorEnabled: 2636 return &AlertingPolicySpecNotification_FieldTerminalPathArrayOfValues{AlertingPolicySpecNotification_FieldTerminalPath: *fp, values: values.([]bool)} 2637 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2638 return &AlertingPolicySpecNotification_FieldTerminalPathArrayOfValues{AlertingPolicySpecNotification_FieldTerminalPath: *fp, values: values.([][]*notification_channel.Reference)} 2639 default: 2640 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec_Notification: %d", fp.selector)) 2641 } 2642 return fpaov 2643 } 2644 2645 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 2646 return fp.WithIArrayOfValues(values) 2647 } 2648 2649 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) WithIArrayItemValue(value interface{}) AlertingPolicySpecNotification_FieldPathArrayItemValue { 2650 switch fp.selector { 2651 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2652 return &AlertingPolicySpecNotification_FieldTerminalPathArrayItemValue{AlertingPolicySpecNotification_FieldTerminalPath: *fp, value: value.(*notification_channel.Reference)} 2653 default: 2654 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec_Notification: %d", fp.selector)) 2655 } 2656 } 2657 2658 func (fp *AlertingPolicySpecNotification_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 2659 return fp.WithIArrayItemValue(value) 2660 } 2661 2662 // AlertingPolicySpecNotification_FieldPathValue allows storing values for Notification fields according to their type 2663 type AlertingPolicySpecNotification_FieldPathValue interface { 2664 AlertingPolicySpecNotification_FieldPath 2665 gotenobject.FieldPathValue 2666 SetTo(target **AlertingPolicy_Spec_Notification) 2667 CompareWith(*AlertingPolicy_Spec_Notification) (cmp int, comparable bool) 2668 } 2669 2670 func ParseAlertingPolicySpecNotification_FieldPathValue(pathStr, valueStr string) (AlertingPolicySpecNotification_FieldPathValue, error) { 2671 fp, err := ParseAlertingPolicySpecNotification_FieldPath(pathStr) 2672 if err != nil { 2673 return nil, err 2674 } 2675 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 2676 if err != nil { 2677 return nil, status.Errorf(codes.InvalidArgument, "error parsing Notification field path value from %s: %v", valueStr, err) 2678 } 2679 return fpv.(AlertingPolicySpecNotification_FieldPathValue), nil 2680 } 2681 2682 func MustParseAlertingPolicySpecNotification_FieldPathValue(pathStr, valueStr string) AlertingPolicySpecNotification_FieldPathValue { 2683 fpv, err := ParseAlertingPolicySpecNotification_FieldPathValue(pathStr, valueStr) 2684 if err != nil { 2685 panic(err) 2686 } 2687 return fpv 2688 } 2689 2690 type AlertingPolicySpecNotification_FieldTerminalPathValue struct { 2691 AlertingPolicySpecNotification_FieldTerminalPath 2692 value interface{} 2693 } 2694 2695 var _ AlertingPolicySpecNotification_FieldPathValue = (*AlertingPolicySpecNotification_FieldTerminalPathValue)(nil) 2696 2697 // GetRawValue returns raw value stored under selected path for 'Notification' as interface{} 2698 func (fpv *AlertingPolicySpecNotification_FieldTerminalPathValue) GetRawValue() interface{} { 2699 return fpv.value 2700 } 2701 func (fpv *AlertingPolicySpecNotification_FieldTerminalPathValue) AsEnabledValue() (bool, bool) { 2702 res, ok := fpv.value.(bool) 2703 return res, ok 2704 } 2705 func (fpv *AlertingPolicySpecNotification_FieldTerminalPathValue) AsChannelsValue() ([]*notification_channel.Reference, bool) { 2706 res, ok := fpv.value.([]*notification_channel.Reference) 2707 return res, ok 2708 } 2709 2710 // SetTo stores value for selected field for object Notification 2711 func (fpv *AlertingPolicySpecNotification_FieldTerminalPathValue) SetTo(target **AlertingPolicy_Spec_Notification) { 2712 if *target == nil { 2713 *target = new(AlertingPolicy_Spec_Notification) 2714 } 2715 switch fpv.selector { 2716 case AlertingPolicySpecNotification_FieldPathSelectorEnabled: 2717 (*target).Enabled = fpv.value.(bool) 2718 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2719 (*target).Channels = fpv.value.([]*notification_channel.Reference) 2720 default: 2721 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec_Notification: %d", fpv.selector)) 2722 } 2723 } 2724 2725 func (fpv *AlertingPolicySpecNotification_FieldTerminalPathValue) SetToRaw(target proto.Message) { 2726 typedObject := target.(*AlertingPolicy_Spec_Notification) 2727 fpv.SetTo(&typedObject) 2728 } 2729 2730 // CompareWith compares value in the 'AlertingPolicySpecNotification_FieldTerminalPathValue' with the value under path in 'AlertingPolicy_Spec_Notification'. 2731 func (fpv *AlertingPolicySpecNotification_FieldTerminalPathValue) CompareWith(source *AlertingPolicy_Spec_Notification) (int, bool) { 2732 switch fpv.selector { 2733 case AlertingPolicySpecNotification_FieldPathSelectorEnabled: 2734 leftValue := fpv.value.(bool) 2735 rightValue := source.GetEnabled() 2736 if (leftValue) == (rightValue) { 2737 return 0, true 2738 } else if !(leftValue) && (rightValue) { 2739 return -1, true 2740 } else { 2741 return 1, true 2742 } 2743 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2744 return 0, false 2745 default: 2746 panic(fmt.Sprintf("Invalid selector for AlertingPolicy_Spec_Notification: %d", fpv.selector)) 2747 } 2748 } 2749 2750 func (fpv *AlertingPolicySpecNotification_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 2751 return fpv.CompareWith(source.(*AlertingPolicy_Spec_Notification)) 2752 } 2753 2754 // AlertingPolicySpecNotification_FieldPathArrayItemValue allows storing single item in Path-specific values for Notification according to their type 2755 // Present only for array (repeated) types. 2756 type AlertingPolicySpecNotification_FieldPathArrayItemValue interface { 2757 gotenobject.FieldPathArrayItemValue 2758 AlertingPolicySpecNotification_FieldPath 2759 ContainsValue(*AlertingPolicy_Spec_Notification) bool 2760 } 2761 2762 // ParseAlertingPolicySpecNotification_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 2763 func ParseAlertingPolicySpecNotification_FieldPathArrayItemValue(pathStr, valueStr string) (AlertingPolicySpecNotification_FieldPathArrayItemValue, error) { 2764 fp, err := ParseAlertingPolicySpecNotification_FieldPath(pathStr) 2765 if err != nil { 2766 return nil, err 2767 } 2768 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 2769 if err != nil { 2770 return nil, status.Errorf(codes.InvalidArgument, "error parsing Notification field path array item value from %s: %v", valueStr, err) 2771 } 2772 return fpaiv.(AlertingPolicySpecNotification_FieldPathArrayItemValue), nil 2773 } 2774 2775 func MustParseAlertingPolicySpecNotification_FieldPathArrayItemValue(pathStr, valueStr string) AlertingPolicySpecNotification_FieldPathArrayItemValue { 2776 fpaiv, err := ParseAlertingPolicySpecNotification_FieldPathArrayItemValue(pathStr, valueStr) 2777 if err != nil { 2778 panic(err) 2779 } 2780 return fpaiv 2781 } 2782 2783 type AlertingPolicySpecNotification_FieldTerminalPathArrayItemValue struct { 2784 AlertingPolicySpecNotification_FieldTerminalPath 2785 value interface{} 2786 } 2787 2788 var _ AlertingPolicySpecNotification_FieldPathArrayItemValue = (*AlertingPolicySpecNotification_FieldTerminalPathArrayItemValue)(nil) 2789 2790 // GetRawValue returns stored element value for array in object AlertingPolicy_Spec_Notification as interface{} 2791 func (fpaiv *AlertingPolicySpecNotification_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 2792 return fpaiv.value 2793 } 2794 func (fpaiv *AlertingPolicySpecNotification_FieldTerminalPathArrayItemValue) AsChannelsItemValue() (*notification_channel.Reference, bool) { 2795 res, ok := fpaiv.value.(*notification_channel.Reference) 2796 return res, ok 2797 } 2798 2799 func (fpaiv *AlertingPolicySpecNotification_FieldTerminalPathArrayItemValue) GetSingle(source *AlertingPolicy_Spec_Notification) (interface{}, bool) { 2800 return nil, false 2801 } 2802 2803 func (fpaiv *AlertingPolicySpecNotification_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 2804 return fpaiv.GetSingle(source.(*AlertingPolicy_Spec_Notification)) 2805 } 2806 2807 // Contains returns a boolean indicating if value that is being held is present in given 'Notification' 2808 func (fpaiv *AlertingPolicySpecNotification_FieldTerminalPathArrayItemValue) ContainsValue(source *AlertingPolicy_Spec_Notification) bool { 2809 slice := fpaiv.AlertingPolicySpecNotification_FieldTerminalPath.Get(source) 2810 for _, v := range slice { 2811 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 2812 if proto.Equal(asProtoMsg, v.(proto.Message)) { 2813 return true 2814 } 2815 } else if reflect.DeepEqual(v, fpaiv.value) { 2816 return true 2817 } 2818 } 2819 return false 2820 } 2821 2822 // AlertingPolicySpecNotification_FieldPathArrayOfValues allows storing slice of values for Notification fields according to their type 2823 type AlertingPolicySpecNotification_FieldPathArrayOfValues interface { 2824 gotenobject.FieldPathArrayOfValues 2825 AlertingPolicySpecNotification_FieldPath 2826 } 2827 2828 func ParseAlertingPolicySpecNotification_FieldPathArrayOfValues(pathStr, valuesStr string) (AlertingPolicySpecNotification_FieldPathArrayOfValues, error) { 2829 fp, err := ParseAlertingPolicySpecNotification_FieldPath(pathStr) 2830 if err != nil { 2831 return nil, err 2832 } 2833 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 2834 if err != nil { 2835 return nil, status.Errorf(codes.InvalidArgument, "error parsing Notification field path array of values from %s: %v", valuesStr, err) 2836 } 2837 return fpaov.(AlertingPolicySpecNotification_FieldPathArrayOfValues), nil 2838 } 2839 2840 func MustParseAlertingPolicySpecNotification_FieldPathArrayOfValues(pathStr, valuesStr string) AlertingPolicySpecNotification_FieldPathArrayOfValues { 2841 fpaov, err := ParseAlertingPolicySpecNotification_FieldPathArrayOfValues(pathStr, valuesStr) 2842 if err != nil { 2843 panic(err) 2844 } 2845 return fpaov 2846 } 2847 2848 type AlertingPolicySpecNotification_FieldTerminalPathArrayOfValues struct { 2849 AlertingPolicySpecNotification_FieldTerminalPath 2850 values interface{} 2851 } 2852 2853 var _ AlertingPolicySpecNotification_FieldPathArrayOfValues = (*AlertingPolicySpecNotification_FieldTerminalPathArrayOfValues)(nil) 2854 2855 func (fpaov *AlertingPolicySpecNotification_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 2856 switch fpaov.selector { 2857 case AlertingPolicySpecNotification_FieldPathSelectorEnabled: 2858 for _, v := range fpaov.values.([]bool) { 2859 values = append(values, v) 2860 } 2861 case AlertingPolicySpecNotification_FieldPathSelectorChannels: 2862 for _, v := range fpaov.values.([][]*notification_channel.Reference) { 2863 values = append(values, v) 2864 } 2865 } 2866 return 2867 } 2868 func (fpaov *AlertingPolicySpecNotification_FieldTerminalPathArrayOfValues) AsEnabledArrayOfValues() ([]bool, bool) { 2869 res, ok := fpaov.values.([]bool) 2870 return res, ok 2871 } 2872 func (fpaov *AlertingPolicySpecNotification_FieldTerminalPathArrayOfValues) AsChannelsArrayOfValues() ([][]*notification_channel.Reference, bool) { 2873 res, ok := fpaov.values.([][]*notification_channel.Reference) 2874 return res, ok 2875 }