github.com/cloudwan/edgelq-sdk@v1.15.4/audit/resources/v1alpha2/method_descriptor/method_descriptor.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/audit/proto/v1alpha2/method_descriptor.proto 3 // DO NOT EDIT!!! 4 5 package method_descriptor 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 common "github.com/cloudwan/edgelq-sdk/audit/resources/v1alpha2/common" 27 meta "github.com/cloudwan/goten-sdk/types/meta" 28 ) 29 30 // ensure the imports are used 31 var ( 32 _ = new(json.Marshaler) 33 _ = new(fmt.Stringer) 34 _ = reflect.DeepEqual 35 _ = strings.Builder{} 36 _ = time.Second 37 38 _ = strcase.ToLowerCamel 39 _ = codes.NotFound 40 _ = status.Status{} 41 _ = protojson.UnmarshalOptions{} 42 _ = new(proto.Message) 43 _ = protoregistry.GlobalTypes 44 45 _ = new(gotenobject.FieldPath) 46 ) 47 48 // make sure we're using proto imports 49 var ( 50 _ = &common.Authentication{} 51 _ = &meta.Meta{} 52 ) 53 54 // FieldPath provides implementation to handle 55 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 56 type MethodDescriptor_FieldPath interface { 57 gotenobject.FieldPath 58 Selector() MethodDescriptor_FieldPathSelector 59 Get(source *MethodDescriptor) []interface{} 60 GetSingle(source *MethodDescriptor) (interface{}, bool) 61 ClearValue(item *MethodDescriptor) 62 63 // Those methods build corresponding MethodDescriptor_FieldPathValue 64 // (or array of values) and holds passed value. Panics if injected type is incorrect. 65 WithIValue(value interface{}) MethodDescriptor_FieldPathValue 66 WithIArrayOfValues(values interface{}) MethodDescriptor_FieldPathArrayOfValues 67 WithIArrayItemValue(value interface{}) MethodDescriptor_FieldPathArrayItemValue 68 } 69 70 type MethodDescriptor_FieldPathSelector int32 71 72 const ( 73 MethodDescriptor_FieldPathSelectorName MethodDescriptor_FieldPathSelector = 0 74 MethodDescriptor_FieldPathSelectorDisplayName MethodDescriptor_FieldPathSelector = 1 75 MethodDescriptor_FieldPathSelectorDescription MethodDescriptor_FieldPathSelector = 2 76 MethodDescriptor_FieldPathSelectorLabels MethodDescriptor_FieldPathSelector = 3 77 MethodDescriptor_FieldPathSelectorPromotedLabelKeySets MethodDescriptor_FieldPathSelector = 4 78 MethodDescriptor_FieldPathSelectorVersions MethodDescriptor_FieldPathSelector = 5 79 MethodDescriptor_FieldPathSelectorMetadata MethodDescriptor_FieldPathSelector = 6 80 ) 81 82 func (s MethodDescriptor_FieldPathSelector) String() string { 83 switch s { 84 case MethodDescriptor_FieldPathSelectorName: 85 return "name" 86 case MethodDescriptor_FieldPathSelectorDisplayName: 87 return "display_name" 88 case MethodDescriptor_FieldPathSelectorDescription: 89 return "description" 90 case MethodDescriptor_FieldPathSelectorLabels: 91 return "labels" 92 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 93 return "promoted_label_key_sets" 94 case MethodDescriptor_FieldPathSelectorVersions: 95 return "versions" 96 case MethodDescriptor_FieldPathSelectorMetadata: 97 return "metadata" 98 default: 99 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", s)) 100 } 101 } 102 103 func BuildMethodDescriptor_FieldPath(fp gotenobject.RawFieldPath) (MethodDescriptor_FieldPath, error) { 104 if len(fp) == 0 { 105 return nil, status.Error(codes.InvalidArgument, "empty field path for object MethodDescriptor") 106 } 107 if len(fp) == 1 { 108 switch fp[0] { 109 case "name": 110 return &MethodDescriptor_FieldTerminalPath{selector: MethodDescriptor_FieldPathSelectorName}, nil 111 case "display_name", "displayName", "display-name": 112 return &MethodDescriptor_FieldTerminalPath{selector: MethodDescriptor_FieldPathSelectorDisplayName}, nil 113 case "description": 114 return &MethodDescriptor_FieldTerminalPath{selector: MethodDescriptor_FieldPathSelectorDescription}, nil 115 case "labels": 116 return &MethodDescriptor_FieldTerminalPath{selector: MethodDescriptor_FieldPathSelectorLabels}, nil 117 case "promoted_label_key_sets", "promotedLabelKeySets", "promoted-label-key-sets": 118 return &MethodDescriptor_FieldTerminalPath{selector: MethodDescriptor_FieldPathSelectorPromotedLabelKeySets}, nil 119 case "versions": 120 return &MethodDescriptor_FieldTerminalPath{selector: MethodDescriptor_FieldPathSelectorVersions}, nil 121 case "metadata": 122 return &MethodDescriptor_FieldTerminalPath{selector: MethodDescriptor_FieldPathSelectorMetadata}, nil 123 } 124 } else { 125 switch fp[0] { 126 case "labels": 127 if subpath, err := common.BuildLabelDescriptor_FieldPath(fp[1:]); err != nil { 128 return nil, err 129 } else { 130 return &MethodDescriptor_FieldSubPath{selector: MethodDescriptor_FieldPathSelectorLabels, subPath: subpath}, nil 131 } 132 case "promoted_label_key_sets", "promotedLabelKeySets", "promoted-label-key-sets": 133 if subpath, err := common.BuildLabelKeySet_FieldPath(fp[1:]); err != nil { 134 return nil, err 135 } else { 136 return &MethodDescriptor_FieldSubPath{selector: MethodDescriptor_FieldPathSelectorPromotedLabelKeySets, subPath: subpath}, nil 137 } 138 case "metadata": 139 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 140 return nil, err 141 } else { 142 return &MethodDescriptor_FieldSubPath{selector: MethodDescriptor_FieldPathSelectorMetadata, subPath: subpath}, nil 143 } 144 } 145 } 146 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object MethodDescriptor", fp) 147 } 148 149 func ParseMethodDescriptor_FieldPath(rawField string) (MethodDescriptor_FieldPath, error) { 150 fp, err := gotenobject.ParseRawFieldPath(rawField) 151 if err != nil { 152 return nil, err 153 } 154 return BuildMethodDescriptor_FieldPath(fp) 155 } 156 157 func MustParseMethodDescriptor_FieldPath(rawField string) MethodDescriptor_FieldPath { 158 fp, err := ParseMethodDescriptor_FieldPath(rawField) 159 if err != nil { 160 panic(err) 161 } 162 return fp 163 } 164 165 type MethodDescriptor_FieldTerminalPath struct { 166 selector MethodDescriptor_FieldPathSelector 167 } 168 169 var _ MethodDescriptor_FieldPath = (*MethodDescriptor_FieldTerminalPath)(nil) 170 171 func (fp *MethodDescriptor_FieldTerminalPath) Selector() MethodDescriptor_FieldPathSelector { 172 return fp.selector 173 } 174 175 // String returns path representation in proto convention 176 func (fp *MethodDescriptor_FieldTerminalPath) String() string { 177 return fp.selector.String() 178 } 179 180 // JSONString returns path representation is JSON convention 181 func (fp *MethodDescriptor_FieldTerminalPath) JSONString() string { 182 return strcase.ToLowerCamel(fp.String()) 183 } 184 185 // Get returns all values pointed by specific field from source MethodDescriptor 186 func (fp *MethodDescriptor_FieldTerminalPath) Get(source *MethodDescriptor) (values []interface{}) { 187 if source != nil { 188 switch fp.selector { 189 case MethodDescriptor_FieldPathSelectorName: 190 if source.Name != nil { 191 values = append(values, source.Name) 192 } 193 case MethodDescriptor_FieldPathSelectorDisplayName: 194 values = append(values, source.DisplayName) 195 case MethodDescriptor_FieldPathSelectorDescription: 196 values = append(values, source.Description) 197 case MethodDescriptor_FieldPathSelectorLabels: 198 for _, value := range source.GetLabels() { 199 values = append(values, value) 200 } 201 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 202 for _, value := range source.GetPromotedLabelKeySets() { 203 values = append(values, value) 204 } 205 case MethodDescriptor_FieldPathSelectorVersions: 206 for _, value := range source.GetVersions() { 207 values = append(values, value) 208 } 209 case MethodDescriptor_FieldPathSelectorMetadata: 210 if source.Metadata != nil { 211 values = append(values, source.Metadata) 212 } 213 default: 214 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fp.selector)) 215 } 216 } 217 return 218 } 219 220 func (fp *MethodDescriptor_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 221 return fp.Get(source.(*MethodDescriptor)) 222 } 223 224 // GetSingle returns value pointed by specific field of from source MethodDescriptor 225 func (fp *MethodDescriptor_FieldTerminalPath) GetSingle(source *MethodDescriptor) (interface{}, bool) { 226 switch fp.selector { 227 case MethodDescriptor_FieldPathSelectorName: 228 res := source.GetName() 229 return res, res != nil 230 case MethodDescriptor_FieldPathSelectorDisplayName: 231 return source.GetDisplayName(), source != nil 232 case MethodDescriptor_FieldPathSelectorDescription: 233 return source.GetDescription(), source != nil 234 case MethodDescriptor_FieldPathSelectorLabels: 235 res := source.GetLabels() 236 return res, res != nil 237 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 238 res := source.GetPromotedLabelKeySets() 239 return res, res != nil 240 case MethodDescriptor_FieldPathSelectorVersions: 241 res := source.GetVersions() 242 return res, res != nil 243 case MethodDescriptor_FieldPathSelectorMetadata: 244 res := source.GetMetadata() 245 return res, res != nil 246 default: 247 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fp.selector)) 248 } 249 } 250 251 func (fp *MethodDescriptor_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 252 return fp.GetSingle(source.(*MethodDescriptor)) 253 } 254 255 // GetDefault returns a default value of the field type 256 func (fp *MethodDescriptor_FieldTerminalPath) GetDefault() interface{} { 257 switch fp.selector { 258 case MethodDescriptor_FieldPathSelectorName: 259 return (*Name)(nil) 260 case MethodDescriptor_FieldPathSelectorDisplayName: 261 return "" 262 case MethodDescriptor_FieldPathSelectorDescription: 263 return "" 264 case MethodDescriptor_FieldPathSelectorLabels: 265 return ([]*common.LabelDescriptor)(nil) 266 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 267 return ([]*common.LabelKeySet)(nil) 268 case MethodDescriptor_FieldPathSelectorVersions: 269 return ([]string)(nil) 270 case MethodDescriptor_FieldPathSelectorMetadata: 271 return (*meta.Meta)(nil) 272 default: 273 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fp.selector)) 274 } 275 } 276 277 func (fp *MethodDescriptor_FieldTerminalPath) ClearValue(item *MethodDescriptor) { 278 if item != nil { 279 switch fp.selector { 280 case MethodDescriptor_FieldPathSelectorName: 281 item.Name = nil 282 case MethodDescriptor_FieldPathSelectorDisplayName: 283 item.DisplayName = "" 284 case MethodDescriptor_FieldPathSelectorDescription: 285 item.Description = "" 286 case MethodDescriptor_FieldPathSelectorLabels: 287 item.Labels = nil 288 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 289 item.PromotedLabelKeySets = nil 290 case MethodDescriptor_FieldPathSelectorVersions: 291 item.Versions = nil 292 case MethodDescriptor_FieldPathSelectorMetadata: 293 item.Metadata = nil 294 default: 295 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fp.selector)) 296 } 297 } 298 } 299 300 func (fp *MethodDescriptor_FieldTerminalPath) ClearValueRaw(item proto.Message) { 301 fp.ClearValue(item.(*MethodDescriptor)) 302 } 303 304 // IsLeaf - whether field path is holds simple value 305 func (fp *MethodDescriptor_FieldTerminalPath) IsLeaf() bool { 306 return fp.selector == MethodDescriptor_FieldPathSelectorName || 307 fp.selector == MethodDescriptor_FieldPathSelectorDisplayName || 308 fp.selector == MethodDescriptor_FieldPathSelectorDescription || 309 fp.selector == MethodDescriptor_FieldPathSelectorVersions 310 } 311 312 func (fp *MethodDescriptor_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 313 return []gotenobject.FieldPath{fp} 314 } 315 316 func (fp *MethodDescriptor_FieldTerminalPath) WithIValue(value interface{}) MethodDescriptor_FieldPathValue { 317 switch fp.selector { 318 case MethodDescriptor_FieldPathSelectorName: 319 return &MethodDescriptor_FieldTerminalPathValue{MethodDescriptor_FieldTerminalPath: *fp, value: value.(*Name)} 320 case MethodDescriptor_FieldPathSelectorDisplayName: 321 return &MethodDescriptor_FieldTerminalPathValue{MethodDescriptor_FieldTerminalPath: *fp, value: value.(string)} 322 case MethodDescriptor_FieldPathSelectorDescription: 323 return &MethodDescriptor_FieldTerminalPathValue{MethodDescriptor_FieldTerminalPath: *fp, value: value.(string)} 324 case MethodDescriptor_FieldPathSelectorLabels: 325 return &MethodDescriptor_FieldTerminalPathValue{MethodDescriptor_FieldTerminalPath: *fp, value: value.([]*common.LabelDescriptor)} 326 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 327 return &MethodDescriptor_FieldTerminalPathValue{MethodDescriptor_FieldTerminalPath: *fp, value: value.([]*common.LabelKeySet)} 328 case MethodDescriptor_FieldPathSelectorVersions: 329 return &MethodDescriptor_FieldTerminalPathValue{MethodDescriptor_FieldTerminalPath: *fp, value: value.([]string)} 330 case MethodDescriptor_FieldPathSelectorMetadata: 331 return &MethodDescriptor_FieldTerminalPathValue{MethodDescriptor_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 332 default: 333 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fp.selector)) 334 } 335 } 336 337 func (fp *MethodDescriptor_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 338 return fp.WithIValue(value) 339 } 340 341 func (fp *MethodDescriptor_FieldTerminalPath) WithIArrayOfValues(values interface{}) MethodDescriptor_FieldPathArrayOfValues { 342 fpaov := &MethodDescriptor_FieldTerminalPathArrayOfValues{MethodDescriptor_FieldTerminalPath: *fp} 343 switch fp.selector { 344 case MethodDescriptor_FieldPathSelectorName: 345 return &MethodDescriptor_FieldTerminalPathArrayOfValues{MethodDescriptor_FieldTerminalPath: *fp, values: values.([]*Name)} 346 case MethodDescriptor_FieldPathSelectorDisplayName: 347 return &MethodDescriptor_FieldTerminalPathArrayOfValues{MethodDescriptor_FieldTerminalPath: *fp, values: values.([]string)} 348 case MethodDescriptor_FieldPathSelectorDescription: 349 return &MethodDescriptor_FieldTerminalPathArrayOfValues{MethodDescriptor_FieldTerminalPath: *fp, values: values.([]string)} 350 case MethodDescriptor_FieldPathSelectorLabels: 351 return &MethodDescriptor_FieldTerminalPathArrayOfValues{MethodDescriptor_FieldTerminalPath: *fp, values: values.([][]*common.LabelDescriptor)} 352 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 353 return &MethodDescriptor_FieldTerminalPathArrayOfValues{MethodDescriptor_FieldTerminalPath: *fp, values: values.([][]*common.LabelKeySet)} 354 case MethodDescriptor_FieldPathSelectorVersions: 355 return &MethodDescriptor_FieldTerminalPathArrayOfValues{MethodDescriptor_FieldTerminalPath: *fp, values: values.([][]string)} 356 case MethodDescriptor_FieldPathSelectorMetadata: 357 return &MethodDescriptor_FieldTerminalPathArrayOfValues{MethodDescriptor_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 358 default: 359 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fp.selector)) 360 } 361 return fpaov 362 } 363 364 func (fp *MethodDescriptor_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 365 return fp.WithIArrayOfValues(values) 366 } 367 368 func (fp *MethodDescriptor_FieldTerminalPath) WithIArrayItemValue(value interface{}) MethodDescriptor_FieldPathArrayItemValue { 369 switch fp.selector { 370 case MethodDescriptor_FieldPathSelectorLabels: 371 return &MethodDescriptor_FieldTerminalPathArrayItemValue{MethodDescriptor_FieldTerminalPath: *fp, value: value.(*common.LabelDescriptor)} 372 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 373 return &MethodDescriptor_FieldTerminalPathArrayItemValue{MethodDescriptor_FieldTerminalPath: *fp, value: value.(*common.LabelKeySet)} 374 case MethodDescriptor_FieldPathSelectorVersions: 375 return &MethodDescriptor_FieldTerminalPathArrayItemValue{MethodDescriptor_FieldTerminalPath: *fp, value: value.(string)} 376 default: 377 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fp.selector)) 378 } 379 } 380 381 func (fp *MethodDescriptor_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 382 return fp.WithIArrayItemValue(value) 383 } 384 385 type MethodDescriptor_FieldSubPath struct { 386 selector MethodDescriptor_FieldPathSelector 387 subPath gotenobject.FieldPath 388 } 389 390 var _ MethodDescriptor_FieldPath = (*MethodDescriptor_FieldSubPath)(nil) 391 392 func (fps *MethodDescriptor_FieldSubPath) Selector() MethodDescriptor_FieldPathSelector { 393 return fps.selector 394 } 395 func (fps *MethodDescriptor_FieldSubPath) AsLabelsSubPath() (common.LabelDescriptor_FieldPath, bool) { 396 res, ok := fps.subPath.(common.LabelDescriptor_FieldPath) 397 return res, ok 398 } 399 func (fps *MethodDescriptor_FieldSubPath) AsPromotedLabelKeySetsSubPath() (common.LabelKeySet_FieldPath, bool) { 400 res, ok := fps.subPath.(common.LabelKeySet_FieldPath) 401 return res, ok 402 } 403 func (fps *MethodDescriptor_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 404 res, ok := fps.subPath.(meta.Meta_FieldPath) 405 return res, ok 406 } 407 408 // String returns path representation in proto convention 409 func (fps *MethodDescriptor_FieldSubPath) String() string { 410 return fps.selector.String() + "." + fps.subPath.String() 411 } 412 413 // JSONString returns path representation is JSON convention 414 func (fps *MethodDescriptor_FieldSubPath) JSONString() string { 415 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 416 } 417 418 // Get returns all values pointed by selected field from source MethodDescriptor 419 func (fps *MethodDescriptor_FieldSubPath) Get(source *MethodDescriptor) (values []interface{}) { 420 switch fps.selector { 421 case MethodDescriptor_FieldPathSelectorLabels: 422 for _, item := range source.GetLabels() { 423 values = append(values, fps.subPath.GetRaw(item)...) 424 } 425 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 426 for _, item := range source.GetPromotedLabelKeySets() { 427 values = append(values, fps.subPath.GetRaw(item)...) 428 } 429 case MethodDescriptor_FieldPathSelectorMetadata: 430 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 431 default: 432 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fps.selector)) 433 } 434 return 435 } 436 437 func (fps *MethodDescriptor_FieldSubPath) GetRaw(source proto.Message) []interface{} { 438 return fps.Get(source.(*MethodDescriptor)) 439 } 440 441 // GetSingle returns value of selected field from source MethodDescriptor 442 func (fps *MethodDescriptor_FieldSubPath) GetSingle(source *MethodDescriptor) (interface{}, bool) { 443 switch fps.selector { 444 case MethodDescriptor_FieldPathSelectorLabels: 445 if len(source.GetLabels()) == 0 { 446 return nil, false 447 } 448 return fps.subPath.GetSingleRaw(source.GetLabels()[0]) 449 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 450 if len(source.GetPromotedLabelKeySets()) == 0 { 451 return nil, false 452 } 453 return fps.subPath.GetSingleRaw(source.GetPromotedLabelKeySets()[0]) 454 case MethodDescriptor_FieldPathSelectorMetadata: 455 if source.GetMetadata() == nil { 456 return nil, false 457 } 458 return fps.subPath.GetSingleRaw(source.GetMetadata()) 459 default: 460 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fps.selector)) 461 } 462 } 463 464 func (fps *MethodDescriptor_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 465 return fps.GetSingle(source.(*MethodDescriptor)) 466 } 467 468 // GetDefault returns a default value of the field type 469 func (fps *MethodDescriptor_FieldSubPath) GetDefault() interface{} { 470 return fps.subPath.GetDefault() 471 } 472 473 func (fps *MethodDescriptor_FieldSubPath) ClearValue(item *MethodDescriptor) { 474 if item != nil { 475 switch fps.selector { 476 case MethodDescriptor_FieldPathSelectorLabels: 477 for _, subItem := range item.Labels { 478 fps.subPath.ClearValueRaw(subItem) 479 } 480 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 481 for _, subItem := range item.PromotedLabelKeySets { 482 fps.subPath.ClearValueRaw(subItem) 483 } 484 case MethodDescriptor_FieldPathSelectorMetadata: 485 fps.subPath.ClearValueRaw(item.Metadata) 486 default: 487 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fps.selector)) 488 } 489 } 490 } 491 492 func (fps *MethodDescriptor_FieldSubPath) ClearValueRaw(item proto.Message) { 493 fps.ClearValue(item.(*MethodDescriptor)) 494 } 495 496 // IsLeaf - whether field path is holds simple value 497 func (fps *MethodDescriptor_FieldSubPath) IsLeaf() bool { 498 return fps.subPath.IsLeaf() 499 } 500 501 func (fps *MethodDescriptor_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 502 iPaths := []gotenobject.FieldPath{&MethodDescriptor_FieldTerminalPath{selector: fps.selector}} 503 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 504 return iPaths 505 } 506 507 func (fps *MethodDescriptor_FieldSubPath) WithIValue(value interface{}) MethodDescriptor_FieldPathValue { 508 return &MethodDescriptor_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 509 } 510 511 func (fps *MethodDescriptor_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 512 return fps.WithIValue(value) 513 } 514 515 func (fps *MethodDescriptor_FieldSubPath) WithIArrayOfValues(values interface{}) MethodDescriptor_FieldPathArrayOfValues { 516 return &MethodDescriptor_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 517 } 518 519 func (fps *MethodDescriptor_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 520 return fps.WithIArrayOfValues(values) 521 } 522 523 func (fps *MethodDescriptor_FieldSubPath) WithIArrayItemValue(value interface{}) MethodDescriptor_FieldPathArrayItemValue { 524 return &MethodDescriptor_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 525 } 526 527 func (fps *MethodDescriptor_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 528 return fps.WithIArrayItemValue(value) 529 } 530 531 // MethodDescriptor_FieldPathValue allows storing values for MethodDescriptor fields according to their type 532 type MethodDescriptor_FieldPathValue interface { 533 MethodDescriptor_FieldPath 534 gotenobject.FieldPathValue 535 SetTo(target **MethodDescriptor) 536 CompareWith(*MethodDescriptor) (cmp int, comparable bool) 537 } 538 539 func ParseMethodDescriptor_FieldPathValue(pathStr, valueStr string) (MethodDescriptor_FieldPathValue, error) { 540 fp, err := ParseMethodDescriptor_FieldPath(pathStr) 541 if err != nil { 542 return nil, err 543 } 544 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 545 if err != nil { 546 return nil, status.Errorf(codes.InvalidArgument, "error parsing MethodDescriptor field path value from %s: %v", valueStr, err) 547 } 548 return fpv.(MethodDescriptor_FieldPathValue), nil 549 } 550 551 func MustParseMethodDescriptor_FieldPathValue(pathStr, valueStr string) MethodDescriptor_FieldPathValue { 552 fpv, err := ParseMethodDescriptor_FieldPathValue(pathStr, valueStr) 553 if err != nil { 554 panic(err) 555 } 556 return fpv 557 } 558 559 type MethodDescriptor_FieldTerminalPathValue struct { 560 MethodDescriptor_FieldTerminalPath 561 value interface{} 562 } 563 564 var _ MethodDescriptor_FieldPathValue = (*MethodDescriptor_FieldTerminalPathValue)(nil) 565 566 // GetRawValue returns raw value stored under selected path for 'MethodDescriptor' as interface{} 567 func (fpv *MethodDescriptor_FieldTerminalPathValue) GetRawValue() interface{} { 568 return fpv.value 569 } 570 func (fpv *MethodDescriptor_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 571 res, ok := fpv.value.(*Name) 572 return res, ok 573 } 574 func (fpv *MethodDescriptor_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) { 575 res, ok := fpv.value.(string) 576 return res, ok 577 } 578 func (fpv *MethodDescriptor_FieldTerminalPathValue) AsDescriptionValue() (string, bool) { 579 res, ok := fpv.value.(string) 580 return res, ok 581 } 582 func (fpv *MethodDescriptor_FieldTerminalPathValue) AsLabelsValue() ([]*common.LabelDescriptor, bool) { 583 res, ok := fpv.value.([]*common.LabelDescriptor) 584 return res, ok 585 } 586 func (fpv *MethodDescriptor_FieldTerminalPathValue) AsPromotedLabelKeySetsValue() ([]*common.LabelKeySet, bool) { 587 res, ok := fpv.value.([]*common.LabelKeySet) 588 return res, ok 589 } 590 func (fpv *MethodDescriptor_FieldTerminalPathValue) AsVersionsValue() ([]string, bool) { 591 res, ok := fpv.value.([]string) 592 return res, ok 593 } 594 func (fpv *MethodDescriptor_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 595 res, ok := fpv.value.(*meta.Meta) 596 return res, ok 597 } 598 599 // SetTo stores value for selected field for object MethodDescriptor 600 func (fpv *MethodDescriptor_FieldTerminalPathValue) SetTo(target **MethodDescriptor) { 601 if *target == nil { 602 *target = new(MethodDescriptor) 603 } 604 switch fpv.selector { 605 case MethodDescriptor_FieldPathSelectorName: 606 (*target).Name = fpv.value.(*Name) 607 case MethodDescriptor_FieldPathSelectorDisplayName: 608 (*target).DisplayName = fpv.value.(string) 609 case MethodDescriptor_FieldPathSelectorDescription: 610 (*target).Description = fpv.value.(string) 611 case MethodDescriptor_FieldPathSelectorLabels: 612 (*target).Labels = fpv.value.([]*common.LabelDescriptor) 613 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 614 (*target).PromotedLabelKeySets = fpv.value.([]*common.LabelKeySet) 615 case MethodDescriptor_FieldPathSelectorVersions: 616 (*target).Versions = fpv.value.([]string) 617 case MethodDescriptor_FieldPathSelectorMetadata: 618 (*target).Metadata = fpv.value.(*meta.Meta) 619 default: 620 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fpv.selector)) 621 } 622 } 623 624 func (fpv *MethodDescriptor_FieldTerminalPathValue) SetToRaw(target proto.Message) { 625 typedObject := target.(*MethodDescriptor) 626 fpv.SetTo(&typedObject) 627 } 628 629 // CompareWith compares value in the 'MethodDescriptor_FieldTerminalPathValue' with the value under path in 'MethodDescriptor'. 630 func (fpv *MethodDescriptor_FieldTerminalPathValue) CompareWith(source *MethodDescriptor) (int, bool) { 631 switch fpv.selector { 632 case MethodDescriptor_FieldPathSelectorName: 633 leftValue := fpv.value.(*Name) 634 rightValue := source.GetName() 635 if leftValue == nil { 636 if rightValue != nil { 637 return -1, true 638 } 639 return 0, true 640 } 641 if rightValue == nil { 642 return 1, true 643 } 644 if leftValue.String() == rightValue.String() { 645 return 0, true 646 } else if leftValue.String() < rightValue.String() { 647 return -1, true 648 } else { 649 return 1, true 650 } 651 case MethodDescriptor_FieldPathSelectorDisplayName: 652 leftValue := fpv.value.(string) 653 rightValue := source.GetDisplayName() 654 if (leftValue) == (rightValue) { 655 return 0, true 656 } else if (leftValue) < (rightValue) { 657 return -1, true 658 } else { 659 return 1, true 660 } 661 case MethodDescriptor_FieldPathSelectorDescription: 662 leftValue := fpv.value.(string) 663 rightValue := source.GetDescription() 664 if (leftValue) == (rightValue) { 665 return 0, true 666 } else if (leftValue) < (rightValue) { 667 return -1, true 668 } else { 669 return 1, true 670 } 671 case MethodDescriptor_FieldPathSelectorLabels: 672 return 0, false 673 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 674 return 0, false 675 case MethodDescriptor_FieldPathSelectorVersions: 676 return 0, false 677 case MethodDescriptor_FieldPathSelectorMetadata: 678 return 0, false 679 default: 680 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fpv.selector)) 681 } 682 } 683 684 func (fpv *MethodDescriptor_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 685 return fpv.CompareWith(source.(*MethodDescriptor)) 686 } 687 688 type MethodDescriptor_FieldSubPathValue struct { 689 MethodDescriptor_FieldPath 690 subPathValue gotenobject.FieldPathValue 691 } 692 693 var _ MethodDescriptor_FieldPathValue = (*MethodDescriptor_FieldSubPathValue)(nil) 694 695 func (fpvs *MethodDescriptor_FieldSubPathValue) AsLabelsPathValue() (common.LabelDescriptor_FieldPathValue, bool) { 696 res, ok := fpvs.subPathValue.(common.LabelDescriptor_FieldPathValue) 697 return res, ok 698 } 699 func (fpvs *MethodDescriptor_FieldSubPathValue) AsPromotedLabelKeySetsPathValue() (common.LabelKeySet_FieldPathValue, bool) { 700 res, ok := fpvs.subPathValue.(common.LabelKeySet_FieldPathValue) 701 return res, ok 702 } 703 func (fpvs *MethodDescriptor_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 704 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 705 return res, ok 706 } 707 708 func (fpvs *MethodDescriptor_FieldSubPathValue) SetTo(target **MethodDescriptor) { 709 if *target == nil { 710 *target = new(MethodDescriptor) 711 } 712 switch fpvs.Selector() { 713 case MethodDescriptor_FieldPathSelectorLabels: 714 panic("FieldPath setter is unsupported for array subpaths") 715 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 716 panic("FieldPath setter is unsupported for array subpaths") 717 case MethodDescriptor_FieldPathSelectorMetadata: 718 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 719 default: 720 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fpvs.Selector())) 721 } 722 } 723 724 func (fpvs *MethodDescriptor_FieldSubPathValue) SetToRaw(target proto.Message) { 725 typedObject := target.(*MethodDescriptor) 726 fpvs.SetTo(&typedObject) 727 } 728 729 func (fpvs *MethodDescriptor_FieldSubPathValue) GetRawValue() interface{} { 730 return fpvs.subPathValue.GetRawValue() 731 } 732 733 func (fpvs *MethodDescriptor_FieldSubPathValue) CompareWith(source *MethodDescriptor) (int, bool) { 734 switch fpvs.Selector() { 735 case MethodDescriptor_FieldPathSelectorLabels: 736 return 0, false // repeated field 737 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 738 return 0, false // repeated field 739 case MethodDescriptor_FieldPathSelectorMetadata: 740 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 741 default: 742 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fpvs.Selector())) 743 } 744 } 745 746 func (fpvs *MethodDescriptor_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 747 return fpvs.CompareWith(source.(*MethodDescriptor)) 748 } 749 750 // MethodDescriptor_FieldPathArrayItemValue allows storing single item in Path-specific values for MethodDescriptor according to their type 751 // Present only for array (repeated) types. 752 type MethodDescriptor_FieldPathArrayItemValue interface { 753 gotenobject.FieldPathArrayItemValue 754 MethodDescriptor_FieldPath 755 ContainsValue(*MethodDescriptor) bool 756 } 757 758 // ParseMethodDescriptor_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 759 func ParseMethodDescriptor_FieldPathArrayItemValue(pathStr, valueStr string) (MethodDescriptor_FieldPathArrayItemValue, error) { 760 fp, err := ParseMethodDescriptor_FieldPath(pathStr) 761 if err != nil { 762 return nil, err 763 } 764 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 765 if err != nil { 766 return nil, status.Errorf(codes.InvalidArgument, "error parsing MethodDescriptor field path array item value from %s: %v", valueStr, err) 767 } 768 return fpaiv.(MethodDescriptor_FieldPathArrayItemValue), nil 769 } 770 771 func MustParseMethodDescriptor_FieldPathArrayItemValue(pathStr, valueStr string) MethodDescriptor_FieldPathArrayItemValue { 772 fpaiv, err := ParseMethodDescriptor_FieldPathArrayItemValue(pathStr, valueStr) 773 if err != nil { 774 panic(err) 775 } 776 return fpaiv 777 } 778 779 type MethodDescriptor_FieldTerminalPathArrayItemValue struct { 780 MethodDescriptor_FieldTerminalPath 781 value interface{} 782 } 783 784 var _ MethodDescriptor_FieldPathArrayItemValue = (*MethodDescriptor_FieldTerminalPathArrayItemValue)(nil) 785 786 // GetRawValue returns stored element value for array in object MethodDescriptor as interface{} 787 func (fpaiv *MethodDescriptor_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 788 return fpaiv.value 789 } 790 func (fpaiv *MethodDescriptor_FieldTerminalPathArrayItemValue) AsLabelsItemValue() (*common.LabelDescriptor, bool) { 791 res, ok := fpaiv.value.(*common.LabelDescriptor) 792 return res, ok 793 } 794 func (fpaiv *MethodDescriptor_FieldTerminalPathArrayItemValue) AsPromotedLabelKeySetsItemValue() (*common.LabelKeySet, bool) { 795 res, ok := fpaiv.value.(*common.LabelKeySet) 796 return res, ok 797 } 798 func (fpaiv *MethodDescriptor_FieldTerminalPathArrayItemValue) AsVersionsItemValue() (string, bool) { 799 res, ok := fpaiv.value.(string) 800 return res, ok 801 } 802 803 func (fpaiv *MethodDescriptor_FieldTerminalPathArrayItemValue) GetSingle(source *MethodDescriptor) (interface{}, bool) { 804 return nil, false 805 } 806 807 func (fpaiv *MethodDescriptor_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 808 return fpaiv.GetSingle(source.(*MethodDescriptor)) 809 } 810 811 // Contains returns a boolean indicating if value that is being held is present in given 'MethodDescriptor' 812 func (fpaiv *MethodDescriptor_FieldTerminalPathArrayItemValue) ContainsValue(source *MethodDescriptor) bool { 813 slice := fpaiv.MethodDescriptor_FieldTerminalPath.Get(source) 814 for _, v := range slice { 815 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 816 if proto.Equal(asProtoMsg, v.(proto.Message)) { 817 return true 818 } 819 } else if reflect.DeepEqual(v, fpaiv.value) { 820 return true 821 } 822 } 823 return false 824 } 825 826 type MethodDescriptor_FieldSubPathArrayItemValue struct { 827 MethodDescriptor_FieldPath 828 subPathItemValue gotenobject.FieldPathArrayItemValue 829 } 830 831 // GetRawValue returns stored array item value 832 func (fpaivs *MethodDescriptor_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 833 return fpaivs.subPathItemValue.GetRawItemValue() 834 } 835 func (fpaivs *MethodDescriptor_FieldSubPathArrayItemValue) AsLabelsPathItemValue() (common.LabelDescriptor_FieldPathArrayItemValue, bool) { 836 res, ok := fpaivs.subPathItemValue.(common.LabelDescriptor_FieldPathArrayItemValue) 837 return res, ok 838 } 839 func (fpaivs *MethodDescriptor_FieldSubPathArrayItemValue) AsPromotedLabelKeySetsPathItemValue() (common.LabelKeySet_FieldPathArrayItemValue, bool) { 840 res, ok := fpaivs.subPathItemValue.(common.LabelKeySet_FieldPathArrayItemValue) 841 return res, ok 842 } 843 func (fpaivs *MethodDescriptor_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 844 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 845 return res, ok 846 } 847 848 // Contains returns a boolean indicating if value that is being held is present in given 'MethodDescriptor' 849 func (fpaivs *MethodDescriptor_FieldSubPathArrayItemValue) ContainsValue(source *MethodDescriptor) bool { 850 switch fpaivs.Selector() { 851 case MethodDescriptor_FieldPathSelectorLabels: 852 return false // repeated/map field 853 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 854 return false // repeated/map field 855 case MethodDescriptor_FieldPathSelectorMetadata: 856 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 857 default: 858 panic(fmt.Sprintf("Invalid selector for MethodDescriptor: %d", fpaivs.Selector())) 859 } 860 } 861 862 // MethodDescriptor_FieldPathArrayOfValues allows storing slice of values for MethodDescriptor fields according to their type 863 type MethodDescriptor_FieldPathArrayOfValues interface { 864 gotenobject.FieldPathArrayOfValues 865 MethodDescriptor_FieldPath 866 } 867 868 func ParseMethodDescriptor_FieldPathArrayOfValues(pathStr, valuesStr string) (MethodDescriptor_FieldPathArrayOfValues, error) { 869 fp, err := ParseMethodDescriptor_FieldPath(pathStr) 870 if err != nil { 871 return nil, err 872 } 873 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 874 if err != nil { 875 return nil, status.Errorf(codes.InvalidArgument, "error parsing MethodDescriptor field path array of values from %s: %v", valuesStr, err) 876 } 877 return fpaov.(MethodDescriptor_FieldPathArrayOfValues), nil 878 } 879 880 func MustParseMethodDescriptor_FieldPathArrayOfValues(pathStr, valuesStr string) MethodDescriptor_FieldPathArrayOfValues { 881 fpaov, err := ParseMethodDescriptor_FieldPathArrayOfValues(pathStr, valuesStr) 882 if err != nil { 883 panic(err) 884 } 885 return fpaov 886 } 887 888 type MethodDescriptor_FieldTerminalPathArrayOfValues struct { 889 MethodDescriptor_FieldTerminalPath 890 values interface{} 891 } 892 893 var _ MethodDescriptor_FieldPathArrayOfValues = (*MethodDescriptor_FieldTerminalPathArrayOfValues)(nil) 894 895 func (fpaov *MethodDescriptor_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 896 switch fpaov.selector { 897 case MethodDescriptor_FieldPathSelectorName: 898 for _, v := range fpaov.values.([]*Name) { 899 values = append(values, v) 900 } 901 case MethodDescriptor_FieldPathSelectorDisplayName: 902 for _, v := range fpaov.values.([]string) { 903 values = append(values, v) 904 } 905 case MethodDescriptor_FieldPathSelectorDescription: 906 for _, v := range fpaov.values.([]string) { 907 values = append(values, v) 908 } 909 case MethodDescriptor_FieldPathSelectorLabels: 910 for _, v := range fpaov.values.([][]*common.LabelDescriptor) { 911 values = append(values, v) 912 } 913 case MethodDescriptor_FieldPathSelectorPromotedLabelKeySets: 914 for _, v := range fpaov.values.([][]*common.LabelKeySet) { 915 values = append(values, v) 916 } 917 case MethodDescriptor_FieldPathSelectorVersions: 918 for _, v := range fpaov.values.([][]string) { 919 values = append(values, v) 920 } 921 case MethodDescriptor_FieldPathSelectorMetadata: 922 for _, v := range fpaov.values.([]*meta.Meta) { 923 values = append(values, v) 924 } 925 } 926 return 927 } 928 func (fpaov *MethodDescriptor_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 929 res, ok := fpaov.values.([]*Name) 930 return res, ok 931 } 932 func (fpaov *MethodDescriptor_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) { 933 res, ok := fpaov.values.([]string) 934 return res, ok 935 } 936 func (fpaov *MethodDescriptor_FieldTerminalPathArrayOfValues) AsDescriptionArrayOfValues() ([]string, bool) { 937 res, ok := fpaov.values.([]string) 938 return res, ok 939 } 940 func (fpaov *MethodDescriptor_FieldTerminalPathArrayOfValues) AsLabelsArrayOfValues() ([][]*common.LabelDescriptor, bool) { 941 res, ok := fpaov.values.([][]*common.LabelDescriptor) 942 return res, ok 943 } 944 func (fpaov *MethodDescriptor_FieldTerminalPathArrayOfValues) AsPromotedLabelKeySetsArrayOfValues() ([][]*common.LabelKeySet, bool) { 945 res, ok := fpaov.values.([][]*common.LabelKeySet) 946 return res, ok 947 } 948 func (fpaov *MethodDescriptor_FieldTerminalPathArrayOfValues) AsVersionsArrayOfValues() ([][]string, bool) { 949 res, ok := fpaov.values.([][]string) 950 return res, ok 951 } 952 func (fpaov *MethodDescriptor_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 953 res, ok := fpaov.values.([]*meta.Meta) 954 return res, ok 955 } 956 957 type MethodDescriptor_FieldSubPathArrayOfValues struct { 958 MethodDescriptor_FieldPath 959 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 960 } 961 962 var _ MethodDescriptor_FieldPathArrayOfValues = (*MethodDescriptor_FieldSubPathArrayOfValues)(nil) 963 964 func (fpsaov *MethodDescriptor_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 965 return fpsaov.subPathArrayOfValues.GetRawValues() 966 } 967 func (fpsaov *MethodDescriptor_FieldSubPathArrayOfValues) AsLabelsPathArrayOfValues() (common.LabelDescriptor_FieldPathArrayOfValues, bool) { 968 res, ok := fpsaov.subPathArrayOfValues.(common.LabelDescriptor_FieldPathArrayOfValues) 969 return res, ok 970 } 971 func (fpsaov *MethodDescriptor_FieldSubPathArrayOfValues) AsPromotedLabelKeySetsPathArrayOfValues() (common.LabelKeySet_FieldPathArrayOfValues, bool) { 972 res, ok := fpsaov.subPathArrayOfValues.(common.LabelKeySet_FieldPathArrayOfValues) 973 return res, ok 974 } 975 func (fpsaov *MethodDescriptor_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 976 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 977 return res, ok 978 }