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