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