github.com/cloudwan/edgelq-sdk@v1.15.4/iam/resources/v1alpha2/role_binding/role_binding.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/iam/proto/v1alpha2/role_binding.proto 3 // DO NOT EDIT!!! 4 5 package role_binding 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 condition "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/condition" 27 organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/organization" 28 project "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/project" 29 role "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/role" 30 meta "github.com/cloudwan/goten-sdk/types/meta" 31 ) 32 33 // ensure the imports are used 34 var ( 35 _ = new(json.Marshaler) 36 _ = new(fmt.Stringer) 37 _ = reflect.DeepEqual 38 _ = strings.Builder{} 39 _ = time.Second 40 41 _ = strcase.ToLowerCamel 42 _ = codes.NotFound 43 _ = status.Status{} 44 _ = protojson.UnmarshalOptions{} 45 _ = new(proto.Message) 46 _ = protoregistry.GlobalTypes 47 48 _ = new(gotenobject.FieldPath) 49 ) 50 51 // make sure we're using proto imports 52 var ( 53 _ = &condition.Condition{} 54 _ = &organization.Organization{} 55 _ = &project.Project{} 56 _ = &role.Role{} 57 _ = &meta.Meta{} 58 ) 59 60 // FieldPath provides implementation to handle 61 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 62 type RoleBinding_FieldPath interface { 63 gotenobject.FieldPath 64 Selector() RoleBinding_FieldPathSelector 65 Get(source *RoleBinding) []interface{} 66 GetSingle(source *RoleBinding) (interface{}, bool) 67 ClearValue(item *RoleBinding) 68 69 // Those methods build corresponding RoleBinding_FieldPathValue 70 // (or array of values) and holds passed value. Panics if injected type is incorrect. 71 WithIValue(value interface{}) RoleBinding_FieldPathValue 72 WithIArrayOfValues(values interface{}) RoleBinding_FieldPathArrayOfValues 73 WithIArrayItemValue(value interface{}) RoleBinding_FieldPathArrayItemValue 74 } 75 76 type RoleBinding_FieldPathSelector int32 77 78 const ( 79 RoleBinding_FieldPathSelectorName RoleBinding_FieldPathSelector = 0 80 RoleBinding_FieldPathSelectorRole RoleBinding_FieldPathSelector = 1 81 RoleBinding_FieldPathSelectorMember RoleBinding_FieldPathSelector = 2 82 RoleBinding_FieldPathSelectorConditionBinding RoleBinding_FieldPathSelector = 3 83 RoleBinding_FieldPathSelectorAncestryPath RoleBinding_FieldPathSelector = 4 84 RoleBinding_FieldPathSelectorMetadata RoleBinding_FieldPathSelector = 5 85 ) 86 87 func (s RoleBinding_FieldPathSelector) String() string { 88 switch s { 89 case RoleBinding_FieldPathSelectorName: 90 return "name" 91 case RoleBinding_FieldPathSelectorRole: 92 return "role" 93 case RoleBinding_FieldPathSelectorMember: 94 return "member" 95 case RoleBinding_FieldPathSelectorConditionBinding: 96 return "condition_binding" 97 case RoleBinding_FieldPathSelectorAncestryPath: 98 return "ancestry_path" 99 case RoleBinding_FieldPathSelectorMetadata: 100 return "metadata" 101 default: 102 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", s)) 103 } 104 } 105 106 func BuildRoleBinding_FieldPath(fp gotenobject.RawFieldPath) (RoleBinding_FieldPath, error) { 107 if len(fp) == 0 { 108 return nil, status.Error(codes.InvalidArgument, "empty field path for object RoleBinding") 109 } 110 if len(fp) == 1 { 111 switch fp[0] { 112 case "name": 113 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorName}, nil 114 case "role": 115 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorRole}, nil 116 case "member": 117 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorMember}, nil 118 case "condition_binding", "conditionBinding", "condition-binding": 119 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorConditionBinding}, nil 120 case "ancestry_path", "ancestryPath", "ancestry-path": 121 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorAncestryPath}, nil 122 case "metadata": 123 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorMetadata}, nil 124 } 125 } else { 126 switch fp[0] { 127 case "condition_binding", "conditionBinding", "condition-binding": 128 if subpath, err := condition.BuildConditionBinding_FieldPath(fp[1:]); err != nil { 129 return nil, err 130 } else { 131 return &RoleBinding_FieldSubPath{selector: RoleBinding_FieldPathSelectorConditionBinding, subPath: subpath}, nil 132 } 133 case "ancestry_path", "ancestryPath", "ancestry-path": 134 if subpath, err := BuildRoleBindingParent_FieldPath(fp[1:]); err != nil { 135 return nil, err 136 } else { 137 return &RoleBinding_FieldSubPath{selector: RoleBinding_FieldPathSelectorAncestryPath, subPath: subpath}, nil 138 } 139 case "metadata": 140 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 141 return nil, err 142 } else { 143 return &RoleBinding_FieldSubPath{selector: RoleBinding_FieldPathSelectorMetadata, subPath: subpath}, nil 144 } 145 } 146 } 147 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object RoleBinding", fp) 148 } 149 150 func ParseRoleBinding_FieldPath(rawField string) (RoleBinding_FieldPath, error) { 151 fp, err := gotenobject.ParseRawFieldPath(rawField) 152 if err != nil { 153 return nil, err 154 } 155 return BuildRoleBinding_FieldPath(fp) 156 } 157 158 func MustParseRoleBinding_FieldPath(rawField string) RoleBinding_FieldPath { 159 fp, err := ParseRoleBinding_FieldPath(rawField) 160 if err != nil { 161 panic(err) 162 } 163 return fp 164 } 165 166 type RoleBinding_FieldTerminalPath struct { 167 selector RoleBinding_FieldPathSelector 168 } 169 170 var _ RoleBinding_FieldPath = (*RoleBinding_FieldTerminalPath)(nil) 171 172 func (fp *RoleBinding_FieldTerminalPath) Selector() RoleBinding_FieldPathSelector { 173 return fp.selector 174 } 175 176 // String returns path representation in proto convention 177 func (fp *RoleBinding_FieldTerminalPath) String() string { 178 return fp.selector.String() 179 } 180 181 // JSONString returns path representation is JSON convention 182 func (fp *RoleBinding_FieldTerminalPath) JSONString() string { 183 return strcase.ToLowerCamel(fp.String()) 184 } 185 186 // Get returns all values pointed by specific field from source RoleBinding 187 func (fp *RoleBinding_FieldTerminalPath) Get(source *RoleBinding) (values []interface{}) { 188 if source != nil { 189 switch fp.selector { 190 case RoleBinding_FieldPathSelectorName: 191 if source.Name != nil { 192 values = append(values, source.Name) 193 } 194 case RoleBinding_FieldPathSelectorRole: 195 if source.Role != nil { 196 values = append(values, source.Role) 197 } 198 case RoleBinding_FieldPathSelectorMember: 199 values = append(values, source.Member) 200 case RoleBinding_FieldPathSelectorConditionBinding: 201 if source.ConditionBinding != nil { 202 values = append(values, source.ConditionBinding) 203 } 204 case RoleBinding_FieldPathSelectorAncestryPath: 205 for _, value := range source.GetAncestryPath() { 206 values = append(values, value) 207 } 208 case RoleBinding_FieldPathSelectorMetadata: 209 if source.Metadata != nil { 210 values = append(values, source.Metadata) 211 } 212 default: 213 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 214 } 215 } 216 return 217 } 218 219 func (fp *RoleBinding_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 220 return fp.Get(source.(*RoleBinding)) 221 } 222 223 // GetSingle returns value pointed by specific field of from source RoleBinding 224 func (fp *RoleBinding_FieldTerminalPath) GetSingle(source *RoleBinding) (interface{}, bool) { 225 switch fp.selector { 226 case RoleBinding_FieldPathSelectorName: 227 res := source.GetName() 228 return res, res != nil 229 case RoleBinding_FieldPathSelectorRole: 230 res := source.GetRole() 231 return res, res != nil 232 case RoleBinding_FieldPathSelectorMember: 233 return source.GetMember(), source != nil 234 case RoleBinding_FieldPathSelectorConditionBinding: 235 res := source.GetConditionBinding() 236 return res, res != nil 237 case RoleBinding_FieldPathSelectorAncestryPath: 238 res := source.GetAncestryPath() 239 return res, res != nil 240 case RoleBinding_FieldPathSelectorMetadata: 241 res := source.GetMetadata() 242 return res, res != nil 243 default: 244 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 245 } 246 } 247 248 func (fp *RoleBinding_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 249 return fp.GetSingle(source.(*RoleBinding)) 250 } 251 252 // GetDefault returns a default value of the field type 253 func (fp *RoleBinding_FieldTerminalPath) GetDefault() interface{} { 254 switch fp.selector { 255 case RoleBinding_FieldPathSelectorName: 256 return (*Name)(nil) 257 case RoleBinding_FieldPathSelectorRole: 258 return (*role.Reference)(nil) 259 case RoleBinding_FieldPathSelectorMember: 260 return "" 261 case RoleBinding_FieldPathSelectorConditionBinding: 262 return (*condition.ConditionBinding)(nil) 263 case RoleBinding_FieldPathSelectorAncestryPath: 264 return ([]*RoleBinding_Parent)(nil) 265 case RoleBinding_FieldPathSelectorMetadata: 266 return (*meta.Meta)(nil) 267 default: 268 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 269 } 270 } 271 272 func (fp *RoleBinding_FieldTerminalPath) ClearValue(item *RoleBinding) { 273 if item != nil { 274 switch fp.selector { 275 case RoleBinding_FieldPathSelectorName: 276 item.Name = nil 277 case RoleBinding_FieldPathSelectorRole: 278 item.Role = nil 279 case RoleBinding_FieldPathSelectorMember: 280 item.Member = "" 281 case RoleBinding_FieldPathSelectorConditionBinding: 282 item.ConditionBinding = nil 283 case RoleBinding_FieldPathSelectorAncestryPath: 284 item.AncestryPath = nil 285 case RoleBinding_FieldPathSelectorMetadata: 286 item.Metadata = nil 287 default: 288 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 289 } 290 } 291 } 292 293 func (fp *RoleBinding_FieldTerminalPath) ClearValueRaw(item proto.Message) { 294 fp.ClearValue(item.(*RoleBinding)) 295 } 296 297 // IsLeaf - whether field path is holds simple value 298 func (fp *RoleBinding_FieldTerminalPath) IsLeaf() bool { 299 return fp.selector == RoleBinding_FieldPathSelectorName || 300 fp.selector == RoleBinding_FieldPathSelectorRole || 301 fp.selector == RoleBinding_FieldPathSelectorMember 302 } 303 304 func (fp *RoleBinding_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 305 return []gotenobject.FieldPath{fp} 306 } 307 308 func (fp *RoleBinding_FieldTerminalPath) WithIValue(value interface{}) RoleBinding_FieldPathValue { 309 switch fp.selector { 310 case RoleBinding_FieldPathSelectorName: 311 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*Name)} 312 case RoleBinding_FieldPathSelectorRole: 313 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*role.Reference)} 314 case RoleBinding_FieldPathSelectorMember: 315 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(string)} 316 case RoleBinding_FieldPathSelectorConditionBinding: 317 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*condition.ConditionBinding)} 318 case RoleBinding_FieldPathSelectorAncestryPath: 319 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.([]*RoleBinding_Parent)} 320 case RoleBinding_FieldPathSelectorMetadata: 321 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 322 default: 323 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 324 } 325 } 326 327 func (fp *RoleBinding_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 328 return fp.WithIValue(value) 329 } 330 331 func (fp *RoleBinding_FieldTerminalPath) WithIArrayOfValues(values interface{}) RoleBinding_FieldPathArrayOfValues { 332 fpaov := &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp} 333 switch fp.selector { 334 case RoleBinding_FieldPathSelectorName: 335 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]*Name)} 336 case RoleBinding_FieldPathSelectorRole: 337 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]*role.Reference)} 338 case RoleBinding_FieldPathSelectorMember: 339 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]string)} 340 case RoleBinding_FieldPathSelectorConditionBinding: 341 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]*condition.ConditionBinding)} 342 case RoleBinding_FieldPathSelectorAncestryPath: 343 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([][]*RoleBinding_Parent)} 344 case RoleBinding_FieldPathSelectorMetadata: 345 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 346 default: 347 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 348 } 349 return fpaov 350 } 351 352 func (fp *RoleBinding_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 353 return fp.WithIArrayOfValues(values) 354 } 355 356 func (fp *RoleBinding_FieldTerminalPath) WithIArrayItemValue(value interface{}) RoleBinding_FieldPathArrayItemValue { 357 switch fp.selector { 358 case RoleBinding_FieldPathSelectorAncestryPath: 359 return &RoleBinding_FieldTerminalPathArrayItemValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*RoleBinding_Parent)} 360 default: 361 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 362 } 363 } 364 365 func (fp *RoleBinding_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 366 return fp.WithIArrayItemValue(value) 367 } 368 369 type RoleBinding_FieldSubPath struct { 370 selector RoleBinding_FieldPathSelector 371 subPath gotenobject.FieldPath 372 } 373 374 var _ RoleBinding_FieldPath = (*RoleBinding_FieldSubPath)(nil) 375 376 func (fps *RoleBinding_FieldSubPath) Selector() RoleBinding_FieldPathSelector { 377 return fps.selector 378 } 379 func (fps *RoleBinding_FieldSubPath) AsConditionBindingSubPath() (condition.ConditionBinding_FieldPath, bool) { 380 res, ok := fps.subPath.(condition.ConditionBinding_FieldPath) 381 return res, ok 382 } 383 func (fps *RoleBinding_FieldSubPath) AsAncestryPathSubPath() (RoleBindingParent_FieldPath, bool) { 384 res, ok := fps.subPath.(RoleBindingParent_FieldPath) 385 return res, ok 386 } 387 func (fps *RoleBinding_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 388 res, ok := fps.subPath.(meta.Meta_FieldPath) 389 return res, ok 390 } 391 392 // String returns path representation in proto convention 393 func (fps *RoleBinding_FieldSubPath) String() string { 394 return fps.selector.String() + "." + fps.subPath.String() 395 } 396 397 // JSONString returns path representation is JSON convention 398 func (fps *RoleBinding_FieldSubPath) JSONString() string { 399 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 400 } 401 402 // Get returns all values pointed by selected field from source RoleBinding 403 func (fps *RoleBinding_FieldSubPath) Get(source *RoleBinding) (values []interface{}) { 404 switch fps.selector { 405 case RoleBinding_FieldPathSelectorConditionBinding: 406 values = append(values, fps.subPath.GetRaw(source.GetConditionBinding())...) 407 case RoleBinding_FieldPathSelectorAncestryPath: 408 for _, item := range source.GetAncestryPath() { 409 values = append(values, fps.subPath.GetRaw(item)...) 410 } 411 case RoleBinding_FieldPathSelectorMetadata: 412 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 413 default: 414 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fps.selector)) 415 } 416 return 417 } 418 419 func (fps *RoleBinding_FieldSubPath) GetRaw(source proto.Message) []interface{} { 420 return fps.Get(source.(*RoleBinding)) 421 } 422 423 // GetSingle returns value of selected field from source RoleBinding 424 func (fps *RoleBinding_FieldSubPath) GetSingle(source *RoleBinding) (interface{}, bool) { 425 switch fps.selector { 426 case RoleBinding_FieldPathSelectorConditionBinding: 427 if source.GetConditionBinding() == nil { 428 return nil, false 429 } 430 return fps.subPath.GetSingleRaw(source.GetConditionBinding()) 431 case RoleBinding_FieldPathSelectorAncestryPath: 432 if len(source.GetAncestryPath()) == 0 { 433 return nil, false 434 } 435 return fps.subPath.GetSingleRaw(source.GetAncestryPath()[0]) 436 case RoleBinding_FieldPathSelectorMetadata: 437 if source.GetMetadata() == nil { 438 return nil, false 439 } 440 return fps.subPath.GetSingleRaw(source.GetMetadata()) 441 default: 442 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fps.selector)) 443 } 444 } 445 446 func (fps *RoleBinding_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 447 return fps.GetSingle(source.(*RoleBinding)) 448 } 449 450 // GetDefault returns a default value of the field type 451 func (fps *RoleBinding_FieldSubPath) GetDefault() interface{} { 452 return fps.subPath.GetDefault() 453 } 454 455 func (fps *RoleBinding_FieldSubPath) ClearValue(item *RoleBinding) { 456 if item != nil { 457 switch fps.selector { 458 case RoleBinding_FieldPathSelectorConditionBinding: 459 fps.subPath.ClearValueRaw(item.ConditionBinding) 460 case RoleBinding_FieldPathSelectorAncestryPath: 461 for _, subItem := range item.AncestryPath { 462 fps.subPath.ClearValueRaw(subItem) 463 } 464 case RoleBinding_FieldPathSelectorMetadata: 465 fps.subPath.ClearValueRaw(item.Metadata) 466 default: 467 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fps.selector)) 468 } 469 } 470 } 471 472 func (fps *RoleBinding_FieldSubPath) ClearValueRaw(item proto.Message) { 473 fps.ClearValue(item.(*RoleBinding)) 474 } 475 476 // IsLeaf - whether field path is holds simple value 477 func (fps *RoleBinding_FieldSubPath) IsLeaf() bool { 478 return fps.subPath.IsLeaf() 479 } 480 481 func (fps *RoleBinding_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 482 iPaths := []gotenobject.FieldPath{&RoleBinding_FieldTerminalPath{selector: fps.selector}} 483 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 484 return iPaths 485 } 486 487 func (fps *RoleBinding_FieldSubPath) WithIValue(value interface{}) RoleBinding_FieldPathValue { 488 return &RoleBinding_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 489 } 490 491 func (fps *RoleBinding_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 492 return fps.WithIValue(value) 493 } 494 495 func (fps *RoleBinding_FieldSubPath) WithIArrayOfValues(values interface{}) RoleBinding_FieldPathArrayOfValues { 496 return &RoleBinding_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 497 } 498 499 func (fps *RoleBinding_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 500 return fps.WithIArrayOfValues(values) 501 } 502 503 func (fps *RoleBinding_FieldSubPath) WithIArrayItemValue(value interface{}) RoleBinding_FieldPathArrayItemValue { 504 return &RoleBinding_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 505 } 506 507 func (fps *RoleBinding_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 508 return fps.WithIArrayItemValue(value) 509 } 510 511 // RoleBinding_FieldPathValue allows storing values for RoleBinding fields according to their type 512 type RoleBinding_FieldPathValue interface { 513 RoleBinding_FieldPath 514 gotenobject.FieldPathValue 515 SetTo(target **RoleBinding) 516 CompareWith(*RoleBinding) (cmp int, comparable bool) 517 } 518 519 func ParseRoleBinding_FieldPathValue(pathStr, valueStr string) (RoleBinding_FieldPathValue, error) { 520 fp, err := ParseRoleBinding_FieldPath(pathStr) 521 if err != nil { 522 return nil, err 523 } 524 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 525 if err != nil { 526 return nil, status.Errorf(codes.InvalidArgument, "error parsing RoleBinding field path value from %s: %v", valueStr, err) 527 } 528 return fpv.(RoleBinding_FieldPathValue), nil 529 } 530 531 func MustParseRoleBinding_FieldPathValue(pathStr, valueStr string) RoleBinding_FieldPathValue { 532 fpv, err := ParseRoleBinding_FieldPathValue(pathStr, valueStr) 533 if err != nil { 534 panic(err) 535 } 536 return fpv 537 } 538 539 type RoleBinding_FieldTerminalPathValue struct { 540 RoleBinding_FieldTerminalPath 541 value interface{} 542 } 543 544 var _ RoleBinding_FieldPathValue = (*RoleBinding_FieldTerminalPathValue)(nil) 545 546 // GetRawValue returns raw value stored under selected path for 'RoleBinding' as interface{} 547 func (fpv *RoleBinding_FieldTerminalPathValue) GetRawValue() interface{} { 548 return fpv.value 549 } 550 func (fpv *RoleBinding_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 551 res, ok := fpv.value.(*Name) 552 return res, ok 553 } 554 func (fpv *RoleBinding_FieldTerminalPathValue) AsRoleValue() (*role.Reference, bool) { 555 res, ok := fpv.value.(*role.Reference) 556 return res, ok 557 } 558 func (fpv *RoleBinding_FieldTerminalPathValue) AsMemberValue() (string, bool) { 559 res, ok := fpv.value.(string) 560 return res, ok 561 } 562 func (fpv *RoleBinding_FieldTerminalPathValue) AsConditionBindingValue() (*condition.ConditionBinding, bool) { 563 res, ok := fpv.value.(*condition.ConditionBinding) 564 return res, ok 565 } 566 func (fpv *RoleBinding_FieldTerminalPathValue) AsAncestryPathValue() ([]*RoleBinding_Parent, bool) { 567 res, ok := fpv.value.([]*RoleBinding_Parent) 568 return res, ok 569 } 570 func (fpv *RoleBinding_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 571 res, ok := fpv.value.(*meta.Meta) 572 return res, ok 573 } 574 575 // SetTo stores value for selected field for object RoleBinding 576 func (fpv *RoleBinding_FieldTerminalPathValue) SetTo(target **RoleBinding) { 577 if *target == nil { 578 *target = new(RoleBinding) 579 } 580 switch fpv.selector { 581 case RoleBinding_FieldPathSelectorName: 582 (*target).Name = fpv.value.(*Name) 583 case RoleBinding_FieldPathSelectorRole: 584 (*target).Role = fpv.value.(*role.Reference) 585 case RoleBinding_FieldPathSelectorMember: 586 (*target).Member = fpv.value.(string) 587 case RoleBinding_FieldPathSelectorConditionBinding: 588 (*target).ConditionBinding = fpv.value.(*condition.ConditionBinding) 589 case RoleBinding_FieldPathSelectorAncestryPath: 590 (*target).AncestryPath = fpv.value.([]*RoleBinding_Parent) 591 case RoleBinding_FieldPathSelectorMetadata: 592 (*target).Metadata = fpv.value.(*meta.Meta) 593 default: 594 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fpv.selector)) 595 } 596 } 597 598 func (fpv *RoleBinding_FieldTerminalPathValue) SetToRaw(target proto.Message) { 599 typedObject := target.(*RoleBinding) 600 fpv.SetTo(&typedObject) 601 } 602 603 // CompareWith compares value in the 'RoleBinding_FieldTerminalPathValue' with the value under path in 'RoleBinding'. 604 func (fpv *RoleBinding_FieldTerminalPathValue) CompareWith(source *RoleBinding) (int, bool) { 605 switch fpv.selector { 606 case RoleBinding_FieldPathSelectorName: 607 leftValue := fpv.value.(*Name) 608 rightValue := source.GetName() 609 if leftValue == nil { 610 if rightValue != nil { 611 return -1, true 612 } 613 return 0, true 614 } 615 if rightValue == nil { 616 return 1, true 617 } 618 if leftValue.String() == rightValue.String() { 619 return 0, true 620 } else if leftValue.String() < rightValue.String() { 621 return -1, true 622 } else { 623 return 1, true 624 } 625 case RoleBinding_FieldPathSelectorRole: 626 leftValue := fpv.value.(*role.Reference) 627 rightValue := source.GetRole() 628 if leftValue == nil { 629 if rightValue != nil { 630 return -1, true 631 } 632 return 0, true 633 } 634 if rightValue == nil { 635 return 1, true 636 } 637 if leftValue.String() == rightValue.String() { 638 return 0, true 639 } else if leftValue.String() < rightValue.String() { 640 return -1, true 641 } else { 642 return 1, true 643 } 644 case RoleBinding_FieldPathSelectorMember: 645 leftValue := fpv.value.(string) 646 rightValue := source.GetMember() 647 if (leftValue) == (rightValue) { 648 return 0, true 649 } else if (leftValue) < (rightValue) { 650 return -1, true 651 } else { 652 return 1, true 653 } 654 case RoleBinding_FieldPathSelectorConditionBinding: 655 return 0, false 656 case RoleBinding_FieldPathSelectorAncestryPath: 657 return 0, false 658 case RoleBinding_FieldPathSelectorMetadata: 659 return 0, false 660 default: 661 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fpv.selector)) 662 } 663 } 664 665 func (fpv *RoleBinding_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 666 return fpv.CompareWith(source.(*RoleBinding)) 667 } 668 669 type RoleBinding_FieldSubPathValue struct { 670 RoleBinding_FieldPath 671 subPathValue gotenobject.FieldPathValue 672 } 673 674 var _ RoleBinding_FieldPathValue = (*RoleBinding_FieldSubPathValue)(nil) 675 676 func (fpvs *RoleBinding_FieldSubPathValue) AsConditionBindingPathValue() (condition.ConditionBinding_FieldPathValue, bool) { 677 res, ok := fpvs.subPathValue.(condition.ConditionBinding_FieldPathValue) 678 return res, ok 679 } 680 func (fpvs *RoleBinding_FieldSubPathValue) AsAncestryPathPathValue() (RoleBindingParent_FieldPathValue, bool) { 681 res, ok := fpvs.subPathValue.(RoleBindingParent_FieldPathValue) 682 return res, ok 683 } 684 func (fpvs *RoleBinding_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 685 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 686 return res, ok 687 } 688 689 func (fpvs *RoleBinding_FieldSubPathValue) SetTo(target **RoleBinding) { 690 if *target == nil { 691 *target = new(RoleBinding) 692 } 693 switch fpvs.Selector() { 694 case RoleBinding_FieldPathSelectorConditionBinding: 695 fpvs.subPathValue.(condition.ConditionBinding_FieldPathValue).SetTo(&(*target).ConditionBinding) 696 case RoleBinding_FieldPathSelectorAncestryPath: 697 panic("FieldPath setter is unsupported for array subpaths") 698 case RoleBinding_FieldPathSelectorMetadata: 699 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 700 default: 701 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fpvs.Selector())) 702 } 703 } 704 705 func (fpvs *RoleBinding_FieldSubPathValue) SetToRaw(target proto.Message) { 706 typedObject := target.(*RoleBinding) 707 fpvs.SetTo(&typedObject) 708 } 709 710 func (fpvs *RoleBinding_FieldSubPathValue) GetRawValue() interface{} { 711 return fpvs.subPathValue.GetRawValue() 712 } 713 714 func (fpvs *RoleBinding_FieldSubPathValue) CompareWith(source *RoleBinding) (int, bool) { 715 switch fpvs.Selector() { 716 case RoleBinding_FieldPathSelectorConditionBinding: 717 return fpvs.subPathValue.(condition.ConditionBinding_FieldPathValue).CompareWith(source.GetConditionBinding()) 718 case RoleBinding_FieldPathSelectorAncestryPath: 719 return 0, false // repeated field 720 case RoleBinding_FieldPathSelectorMetadata: 721 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 722 default: 723 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fpvs.Selector())) 724 } 725 } 726 727 func (fpvs *RoleBinding_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 728 return fpvs.CompareWith(source.(*RoleBinding)) 729 } 730 731 // RoleBinding_FieldPathArrayItemValue allows storing single item in Path-specific values for RoleBinding according to their type 732 // Present only for array (repeated) types. 733 type RoleBinding_FieldPathArrayItemValue interface { 734 gotenobject.FieldPathArrayItemValue 735 RoleBinding_FieldPath 736 ContainsValue(*RoleBinding) bool 737 } 738 739 // ParseRoleBinding_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 740 func ParseRoleBinding_FieldPathArrayItemValue(pathStr, valueStr string) (RoleBinding_FieldPathArrayItemValue, error) { 741 fp, err := ParseRoleBinding_FieldPath(pathStr) 742 if err != nil { 743 return nil, err 744 } 745 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 746 if err != nil { 747 return nil, status.Errorf(codes.InvalidArgument, "error parsing RoleBinding field path array item value from %s: %v", valueStr, err) 748 } 749 return fpaiv.(RoleBinding_FieldPathArrayItemValue), nil 750 } 751 752 func MustParseRoleBinding_FieldPathArrayItemValue(pathStr, valueStr string) RoleBinding_FieldPathArrayItemValue { 753 fpaiv, err := ParseRoleBinding_FieldPathArrayItemValue(pathStr, valueStr) 754 if err != nil { 755 panic(err) 756 } 757 return fpaiv 758 } 759 760 type RoleBinding_FieldTerminalPathArrayItemValue struct { 761 RoleBinding_FieldTerminalPath 762 value interface{} 763 } 764 765 var _ RoleBinding_FieldPathArrayItemValue = (*RoleBinding_FieldTerminalPathArrayItemValue)(nil) 766 767 // GetRawValue returns stored element value for array in object RoleBinding as interface{} 768 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 769 return fpaiv.value 770 } 771 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) AsAncestryPathItemValue() (*RoleBinding_Parent, bool) { 772 res, ok := fpaiv.value.(*RoleBinding_Parent) 773 return res, ok 774 } 775 776 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) GetSingle(source *RoleBinding) (interface{}, bool) { 777 return nil, false 778 } 779 780 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 781 return fpaiv.GetSingle(source.(*RoleBinding)) 782 } 783 784 // Contains returns a boolean indicating if value that is being held is present in given 'RoleBinding' 785 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) ContainsValue(source *RoleBinding) bool { 786 slice := fpaiv.RoleBinding_FieldTerminalPath.Get(source) 787 for _, v := range slice { 788 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 789 if proto.Equal(asProtoMsg, v.(proto.Message)) { 790 return true 791 } 792 } else if reflect.DeepEqual(v, fpaiv.value) { 793 return true 794 } 795 } 796 return false 797 } 798 799 type RoleBinding_FieldSubPathArrayItemValue struct { 800 RoleBinding_FieldPath 801 subPathItemValue gotenobject.FieldPathArrayItemValue 802 } 803 804 // GetRawValue returns stored array item value 805 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 806 return fpaivs.subPathItemValue.GetRawItemValue() 807 } 808 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) AsConditionBindingPathItemValue() (condition.ConditionBinding_FieldPathArrayItemValue, bool) { 809 res, ok := fpaivs.subPathItemValue.(condition.ConditionBinding_FieldPathArrayItemValue) 810 return res, ok 811 } 812 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) AsAncestryPathPathItemValue() (RoleBindingParent_FieldPathArrayItemValue, bool) { 813 res, ok := fpaivs.subPathItemValue.(RoleBindingParent_FieldPathArrayItemValue) 814 return res, ok 815 } 816 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 817 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 818 return res, ok 819 } 820 821 // Contains returns a boolean indicating if value that is being held is present in given 'RoleBinding' 822 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) ContainsValue(source *RoleBinding) bool { 823 switch fpaivs.Selector() { 824 case RoleBinding_FieldPathSelectorConditionBinding: 825 return fpaivs.subPathItemValue.(condition.ConditionBinding_FieldPathArrayItemValue).ContainsValue(source.GetConditionBinding()) 826 case RoleBinding_FieldPathSelectorAncestryPath: 827 return false // repeated/map field 828 case RoleBinding_FieldPathSelectorMetadata: 829 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 830 default: 831 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fpaivs.Selector())) 832 } 833 } 834 835 // RoleBinding_FieldPathArrayOfValues allows storing slice of values for RoleBinding fields according to their type 836 type RoleBinding_FieldPathArrayOfValues interface { 837 gotenobject.FieldPathArrayOfValues 838 RoleBinding_FieldPath 839 } 840 841 func ParseRoleBinding_FieldPathArrayOfValues(pathStr, valuesStr string) (RoleBinding_FieldPathArrayOfValues, error) { 842 fp, err := ParseRoleBinding_FieldPath(pathStr) 843 if err != nil { 844 return nil, err 845 } 846 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 847 if err != nil { 848 return nil, status.Errorf(codes.InvalidArgument, "error parsing RoleBinding field path array of values from %s: %v", valuesStr, err) 849 } 850 return fpaov.(RoleBinding_FieldPathArrayOfValues), nil 851 } 852 853 func MustParseRoleBinding_FieldPathArrayOfValues(pathStr, valuesStr string) RoleBinding_FieldPathArrayOfValues { 854 fpaov, err := ParseRoleBinding_FieldPathArrayOfValues(pathStr, valuesStr) 855 if err != nil { 856 panic(err) 857 } 858 return fpaov 859 } 860 861 type RoleBinding_FieldTerminalPathArrayOfValues struct { 862 RoleBinding_FieldTerminalPath 863 values interface{} 864 } 865 866 var _ RoleBinding_FieldPathArrayOfValues = (*RoleBinding_FieldTerminalPathArrayOfValues)(nil) 867 868 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 869 switch fpaov.selector { 870 case RoleBinding_FieldPathSelectorName: 871 for _, v := range fpaov.values.([]*Name) { 872 values = append(values, v) 873 } 874 case RoleBinding_FieldPathSelectorRole: 875 for _, v := range fpaov.values.([]*role.Reference) { 876 values = append(values, v) 877 } 878 case RoleBinding_FieldPathSelectorMember: 879 for _, v := range fpaov.values.([]string) { 880 values = append(values, v) 881 } 882 case RoleBinding_FieldPathSelectorConditionBinding: 883 for _, v := range fpaov.values.([]*condition.ConditionBinding) { 884 values = append(values, v) 885 } 886 case RoleBinding_FieldPathSelectorAncestryPath: 887 for _, v := range fpaov.values.([][]*RoleBinding_Parent) { 888 values = append(values, v) 889 } 890 case RoleBinding_FieldPathSelectorMetadata: 891 for _, v := range fpaov.values.([]*meta.Meta) { 892 values = append(values, v) 893 } 894 } 895 return 896 } 897 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 898 res, ok := fpaov.values.([]*Name) 899 return res, ok 900 } 901 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsRoleArrayOfValues() ([]*role.Reference, bool) { 902 res, ok := fpaov.values.([]*role.Reference) 903 return res, ok 904 } 905 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsMemberArrayOfValues() ([]string, bool) { 906 res, ok := fpaov.values.([]string) 907 return res, ok 908 } 909 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsConditionBindingArrayOfValues() ([]*condition.ConditionBinding, bool) { 910 res, ok := fpaov.values.([]*condition.ConditionBinding) 911 return res, ok 912 } 913 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsAncestryPathArrayOfValues() ([][]*RoleBinding_Parent, bool) { 914 res, ok := fpaov.values.([][]*RoleBinding_Parent) 915 return res, ok 916 } 917 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 918 res, ok := fpaov.values.([]*meta.Meta) 919 return res, ok 920 } 921 922 type RoleBinding_FieldSubPathArrayOfValues struct { 923 RoleBinding_FieldPath 924 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 925 } 926 927 var _ RoleBinding_FieldPathArrayOfValues = (*RoleBinding_FieldSubPathArrayOfValues)(nil) 928 929 func (fpsaov *RoleBinding_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 930 return fpsaov.subPathArrayOfValues.GetRawValues() 931 } 932 func (fpsaov *RoleBinding_FieldSubPathArrayOfValues) AsConditionBindingPathArrayOfValues() (condition.ConditionBinding_FieldPathArrayOfValues, bool) { 933 res, ok := fpsaov.subPathArrayOfValues.(condition.ConditionBinding_FieldPathArrayOfValues) 934 return res, ok 935 } 936 func (fpsaov *RoleBinding_FieldSubPathArrayOfValues) AsAncestryPathPathArrayOfValues() (RoleBindingParent_FieldPathArrayOfValues, bool) { 937 res, ok := fpsaov.subPathArrayOfValues.(RoleBindingParent_FieldPathArrayOfValues) 938 return res, ok 939 } 940 func (fpsaov *RoleBinding_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 941 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 942 return res, ok 943 } 944 945 // FieldPath provides implementation to handle 946 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 947 type RoleBindingParent_FieldPath interface { 948 gotenobject.FieldPath 949 Selector() RoleBindingParent_FieldPathSelector 950 Get(source *RoleBinding_Parent) []interface{} 951 GetSingle(source *RoleBinding_Parent) (interface{}, bool) 952 ClearValue(item *RoleBinding_Parent) 953 954 // Those methods build corresponding RoleBindingParent_FieldPathValue 955 // (or array of values) and holds passed value. Panics if injected type is incorrect. 956 WithIValue(value interface{}) RoleBindingParent_FieldPathValue 957 WithIArrayOfValues(values interface{}) RoleBindingParent_FieldPathArrayOfValues 958 WithIArrayItemValue(value interface{}) RoleBindingParent_FieldPathArrayItemValue 959 } 960 961 type RoleBindingParent_FieldPathSelector int32 962 963 const ( 964 RoleBindingParent_FieldPathSelectorParent RoleBindingParent_FieldPathSelector = 0 965 RoleBindingParent_FieldPathSelectorMember RoleBindingParent_FieldPathSelector = 1 966 ) 967 968 func (s RoleBindingParent_FieldPathSelector) String() string { 969 switch s { 970 case RoleBindingParent_FieldPathSelectorParent: 971 return "parent" 972 case RoleBindingParent_FieldPathSelectorMember: 973 return "member" 974 default: 975 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", s)) 976 } 977 } 978 979 func BuildRoleBindingParent_FieldPath(fp gotenobject.RawFieldPath) (RoleBindingParent_FieldPath, error) { 980 if len(fp) == 0 { 981 return nil, status.Error(codes.InvalidArgument, "empty field path for object RoleBinding_Parent") 982 } 983 if len(fp) == 1 { 984 switch fp[0] { 985 case "parent": 986 return &RoleBindingParent_FieldTerminalPath{selector: RoleBindingParent_FieldPathSelectorParent}, nil 987 case "member": 988 return &RoleBindingParent_FieldTerminalPath{selector: RoleBindingParent_FieldPathSelectorMember}, nil 989 } 990 } 991 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object RoleBinding_Parent", fp) 992 } 993 994 func ParseRoleBindingParent_FieldPath(rawField string) (RoleBindingParent_FieldPath, error) { 995 fp, err := gotenobject.ParseRawFieldPath(rawField) 996 if err != nil { 997 return nil, err 998 } 999 return BuildRoleBindingParent_FieldPath(fp) 1000 } 1001 1002 func MustParseRoleBindingParent_FieldPath(rawField string) RoleBindingParent_FieldPath { 1003 fp, err := ParseRoleBindingParent_FieldPath(rawField) 1004 if err != nil { 1005 panic(err) 1006 } 1007 return fp 1008 } 1009 1010 type RoleBindingParent_FieldTerminalPath struct { 1011 selector RoleBindingParent_FieldPathSelector 1012 } 1013 1014 var _ RoleBindingParent_FieldPath = (*RoleBindingParent_FieldTerminalPath)(nil) 1015 1016 func (fp *RoleBindingParent_FieldTerminalPath) Selector() RoleBindingParent_FieldPathSelector { 1017 return fp.selector 1018 } 1019 1020 // String returns path representation in proto convention 1021 func (fp *RoleBindingParent_FieldTerminalPath) String() string { 1022 return fp.selector.String() 1023 } 1024 1025 // JSONString returns path representation is JSON convention 1026 func (fp *RoleBindingParent_FieldTerminalPath) JSONString() string { 1027 return strcase.ToLowerCamel(fp.String()) 1028 } 1029 1030 // Get returns all values pointed by specific field from source RoleBinding_Parent 1031 func (fp *RoleBindingParent_FieldTerminalPath) Get(source *RoleBinding_Parent) (values []interface{}) { 1032 if source != nil { 1033 switch fp.selector { 1034 case RoleBindingParent_FieldPathSelectorParent: 1035 if source.Parent != nil { 1036 values = append(values, source.Parent) 1037 } 1038 case RoleBindingParent_FieldPathSelectorMember: 1039 values = append(values, source.Member) 1040 default: 1041 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1042 } 1043 } 1044 return 1045 } 1046 1047 func (fp *RoleBindingParent_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1048 return fp.Get(source.(*RoleBinding_Parent)) 1049 } 1050 1051 // GetSingle returns value pointed by specific field of from source RoleBinding_Parent 1052 func (fp *RoleBindingParent_FieldTerminalPath) GetSingle(source *RoleBinding_Parent) (interface{}, bool) { 1053 switch fp.selector { 1054 case RoleBindingParent_FieldPathSelectorParent: 1055 res := source.GetParent() 1056 return res, res != nil 1057 case RoleBindingParent_FieldPathSelectorMember: 1058 return source.GetMember(), source != nil 1059 default: 1060 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1061 } 1062 } 1063 1064 func (fp *RoleBindingParent_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1065 return fp.GetSingle(source.(*RoleBinding_Parent)) 1066 } 1067 1068 // GetDefault returns a default value of the field type 1069 func (fp *RoleBindingParent_FieldTerminalPath) GetDefault() interface{} { 1070 switch fp.selector { 1071 case RoleBindingParent_FieldPathSelectorParent: 1072 return (*Reference)(nil) 1073 case RoleBindingParent_FieldPathSelectorMember: 1074 return "" 1075 default: 1076 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1077 } 1078 } 1079 1080 func (fp *RoleBindingParent_FieldTerminalPath) ClearValue(item *RoleBinding_Parent) { 1081 if item != nil { 1082 switch fp.selector { 1083 case RoleBindingParent_FieldPathSelectorParent: 1084 item.Parent = nil 1085 case RoleBindingParent_FieldPathSelectorMember: 1086 item.Member = "" 1087 default: 1088 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1089 } 1090 } 1091 } 1092 1093 func (fp *RoleBindingParent_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1094 fp.ClearValue(item.(*RoleBinding_Parent)) 1095 } 1096 1097 // IsLeaf - whether field path is holds simple value 1098 func (fp *RoleBindingParent_FieldTerminalPath) IsLeaf() bool { 1099 return fp.selector == RoleBindingParent_FieldPathSelectorParent || 1100 fp.selector == RoleBindingParent_FieldPathSelectorMember 1101 } 1102 1103 func (fp *RoleBindingParent_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1104 return []gotenobject.FieldPath{fp} 1105 } 1106 1107 func (fp *RoleBindingParent_FieldTerminalPath) WithIValue(value interface{}) RoleBindingParent_FieldPathValue { 1108 switch fp.selector { 1109 case RoleBindingParent_FieldPathSelectorParent: 1110 return &RoleBindingParent_FieldTerminalPathValue{RoleBindingParent_FieldTerminalPath: *fp, value: value.(*Reference)} 1111 case RoleBindingParent_FieldPathSelectorMember: 1112 return &RoleBindingParent_FieldTerminalPathValue{RoleBindingParent_FieldTerminalPath: *fp, value: value.(string)} 1113 default: 1114 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1115 } 1116 } 1117 1118 func (fp *RoleBindingParent_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1119 return fp.WithIValue(value) 1120 } 1121 1122 func (fp *RoleBindingParent_FieldTerminalPath) WithIArrayOfValues(values interface{}) RoleBindingParent_FieldPathArrayOfValues { 1123 fpaov := &RoleBindingParent_FieldTerminalPathArrayOfValues{RoleBindingParent_FieldTerminalPath: *fp} 1124 switch fp.selector { 1125 case RoleBindingParent_FieldPathSelectorParent: 1126 return &RoleBindingParent_FieldTerminalPathArrayOfValues{RoleBindingParent_FieldTerminalPath: *fp, values: values.([]*Reference)} 1127 case RoleBindingParent_FieldPathSelectorMember: 1128 return &RoleBindingParent_FieldTerminalPathArrayOfValues{RoleBindingParent_FieldTerminalPath: *fp, values: values.([]string)} 1129 default: 1130 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1131 } 1132 return fpaov 1133 } 1134 1135 func (fp *RoleBindingParent_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1136 return fp.WithIArrayOfValues(values) 1137 } 1138 1139 func (fp *RoleBindingParent_FieldTerminalPath) WithIArrayItemValue(value interface{}) RoleBindingParent_FieldPathArrayItemValue { 1140 switch fp.selector { 1141 default: 1142 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1143 } 1144 } 1145 1146 func (fp *RoleBindingParent_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1147 return fp.WithIArrayItemValue(value) 1148 } 1149 1150 // RoleBindingParent_FieldPathValue allows storing values for Parent fields according to their type 1151 type RoleBindingParent_FieldPathValue interface { 1152 RoleBindingParent_FieldPath 1153 gotenobject.FieldPathValue 1154 SetTo(target **RoleBinding_Parent) 1155 CompareWith(*RoleBinding_Parent) (cmp int, comparable bool) 1156 } 1157 1158 func ParseRoleBindingParent_FieldPathValue(pathStr, valueStr string) (RoleBindingParent_FieldPathValue, error) { 1159 fp, err := ParseRoleBindingParent_FieldPath(pathStr) 1160 if err != nil { 1161 return nil, err 1162 } 1163 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1164 if err != nil { 1165 return nil, status.Errorf(codes.InvalidArgument, "error parsing Parent field path value from %s: %v", valueStr, err) 1166 } 1167 return fpv.(RoleBindingParent_FieldPathValue), nil 1168 } 1169 1170 func MustParseRoleBindingParent_FieldPathValue(pathStr, valueStr string) RoleBindingParent_FieldPathValue { 1171 fpv, err := ParseRoleBindingParent_FieldPathValue(pathStr, valueStr) 1172 if err != nil { 1173 panic(err) 1174 } 1175 return fpv 1176 } 1177 1178 type RoleBindingParent_FieldTerminalPathValue struct { 1179 RoleBindingParent_FieldTerminalPath 1180 value interface{} 1181 } 1182 1183 var _ RoleBindingParent_FieldPathValue = (*RoleBindingParent_FieldTerminalPathValue)(nil) 1184 1185 // GetRawValue returns raw value stored under selected path for 'Parent' as interface{} 1186 func (fpv *RoleBindingParent_FieldTerminalPathValue) GetRawValue() interface{} { 1187 return fpv.value 1188 } 1189 func (fpv *RoleBindingParent_FieldTerminalPathValue) AsParentValue() (*Reference, bool) { 1190 res, ok := fpv.value.(*Reference) 1191 return res, ok 1192 } 1193 func (fpv *RoleBindingParent_FieldTerminalPathValue) AsMemberValue() (string, bool) { 1194 res, ok := fpv.value.(string) 1195 return res, ok 1196 } 1197 1198 // SetTo stores value for selected field for object Parent 1199 func (fpv *RoleBindingParent_FieldTerminalPathValue) SetTo(target **RoleBinding_Parent) { 1200 if *target == nil { 1201 *target = new(RoleBinding_Parent) 1202 } 1203 switch fpv.selector { 1204 case RoleBindingParent_FieldPathSelectorParent: 1205 (*target).Parent = fpv.value.(*Reference) 1206 case RoleBindingParent_FieldPathSelectorMember: 1207 (*target).Member = fpv.value.(string) 1208 default: 1209 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fpv.selector)) 1210 } 1211 } 1212 1213 func (fpv *RoleBindingParent_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1214 typedObject := target.(*RoleBinding_Parent) 1215 fpv.SetTo(&typedObject) 1216 } 1217 1218 // CompareWith compares value in the 'RoleBindingParent_FieldTerminalPathValue' with the value under path in 'RoleBinding_Parent'. 1219 func (fpv *RoleBindingParent_FieldTerminalPathValue) CompareWith(source *RoleBinding_Parent) (int, bool) { 1220 switch fpv.selector { 1221 case RoleBindingParent_FieldPathSelectorParent: 1222 leftValue := fpv.value.(*Reference) 1223 rightValue := source.GetParent() 1224 if leftValue == nil { 1225 if rightValue != nil { 1226 return -1, true 1227 } 1228 return 0, true 1229 } 1230 if rightValue == nil { 1231 return 1, true 1232 } 1233 if leftValue.String() == rightValue.String() { 1234 return 0, true 1235 } else if leftValue.String() < rightValue.String() { 1236 return -1, true 1237 } else { 1238 return 1, true 1239 } 1240 case RoleBindingParent_FieldPathSelectorMember: 1241 leftValue := fpv.value.(string) 1242 rightValue := source.GetMember() 1243 if (leftValue) == (rightValue) { 1244 return 0, true 1245 } else if (leftValue) < (rightValue) { 1246 return -1, true 1247 } else { 1248 return 1, true 1249 } 1250 default: 1251 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fpv.selector)) 1252 } 1253 } 1254 1255 func (fpv *RoleBindingParent_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1256 return fpv.CompareWith(source.(*RoleBinding_Parent)) 1257 } 1258 1259 // RoleBindingParent_FieldPathArrayItemValue allows storing single item in Path-specific values for Parent according to their type 1260 // Present only for array (repeated) types. 1261 type RoleBindingParent_FieldPathArrayItemValue interface { 1262 gotenobject.FieldPathArrayItemValue 1263 RoleBindingParent_FieldPath 1264 ContainsValue(*RoleBinding_Parent) bool 1265 } 1266 1267 // ParseRoleBindingParent_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1268 func ParseRoleBindingParent_FieldPathArrayItemValue(pathStr, valueStr string) (RoleBindingParent_FieldPathArrayItemValue, error) { 1269 fp, err := ParseRoleBindingParent_FieldPath(pathStr) 1270 if err != nil { 1271 return nil, err 1272 } 1273 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1274 if err != nil { 1275 return nil, status.Errorf(codes.InvalidArgument, "error parsing Parent field path array item value from %s: %v", valueStr, err) 1276 } 1277 return fpaiv.(RoleBindingParent_FieldPathArrayItemValue), nil 1278 } 1279 1280 func MustParseRoleBindingParent_FieldPathArrayItemValue(pathStr, valueStr string) RoleBindingParent_FieldPathArrayItemValue { 1281 fpaiv, err := ParseRoleBindingParent_FieldPathArrayItemValue(pathStr, valueStr) 1282 if err != nil { 1283 panic(err) 1284 } 1285 return fpaiv 1286 } 1287 1288 type RoleBindingParent_FieldTerminalPathArrayItemValue struct { 1289 RoleBindingParent_FieldTerminalPath 1290 value interface{} 1291 } 1292 1293 var _ RoleBindingParent_FieldPathArrayItemValue = (*RoleBindingParent_FieldTerminalPathArrayItemValue)(nil) 1294 1295 // GetRawValue returns stored element value for array in object RoleBinding_Parent as interface{} 1296 func (fpaiv *RoleBindingParent_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1297 return fpaiv.value 1298 } 1299 1300 func (fpaiv *RoleBindingParent_FieldTerminalPathArrayItemValue) GetSingle(source *RoleBinding_Parent) (interface{}, bool) { 1301 return nil, false 1302 } 1303 1304 func (fpaiv *RoleBindingParent_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1305 return fpaiv.GetSingle(source.(*RoleBinding_Parent)) 1306 } 1307 1308 // Contains returns a boolean indicating if value that is being held is present in given 'Parent' 1309 func (fpaiv *RoleBindingParent_FieldTerminalPathArrayItemValue) ContainsValue(source *RoleBinding_Parent) bool { 1310 slice := fpaiv.RoleBindingParent_FieldTerminalPath.Get(source) 1311 for _, v := range slice { 1312 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1313 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1314 return true 1315 } 1316 } else if reflect.DeepEqual(v, fpaiv.value) { 1317 return true 1318 } 1319 } 1320 return false 1321 } 1322 1323 // RoleBindingParent_FieldPathArrayOfValues allows storing slice of values for Parent fields according to their type 1324 type RoleBindingParent_FieldPathArrayOfValues interface { 1325 gotenobject.FieldPathArrayOfValues 1326 RoleBindingParent_FieldPath 1327 } 1328 1329 func ParseRoleBindingParent_FieldPathArrayOfValues(pathStr, valuesStr string) (RoleBindingParent_FieldPathArrayOfValues, error) { 1330 fp, err := ParseRoleBindingParent_FieldPath(pathStr) 1331 if err != nil { 1332 return nil, err 1333 } 1334 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1335 if err != nil { 1336 return nil, status.Errorf(codes.InvalidArgument, "error parsing Parent field path array of values from %s: %v", valuesStr, err) 1337 } 1338 return fpaov.(RoleBindingParent_FieldPathArrayOfValues), nil 1339 } 1340 1341 func MustParseRoleBindingParent_FieldPathArrayOfValues(pathStr, valuesStr string) RoleBindingParent_FieldPathArrayOfValues { 1342 fpaov, err := ParseRoleBindingParent_FieldPathArrayOfValues(pathStr, valuesStr) 1343 if err != nil { 1344 panic(err) 1345 } 1346 return fpaov 1347 } 1348 1349 type RoleBindingParent_FieldTerminalPathArrayOfValues struct { 1350 RoleBindingParent_FieldTerminalPath 1351 values interface{} 1352 } 1353 1354 var _ RoleBindingParent_FieldPathArrayOfValues = (*RoleBindingParent_FieldTerminalPathArrayOfValues)(nil) 1355 1356 func (fpaov *RoleBindingParent_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1357 switch fpaov.selector { 1358 case RoleBindingParent_FieldPathSelectorParent: 1359 for _, v := range fpaov.values.([]*Reference) { 1360 values = append(values, v) 1361 } 1362 case RoleBindingParent_FieldPathSelectorMember: 1363 for _, v := range fpaov.values.([]string) { 1364 values = append(values, v) 1365 } 1366 } 1367 return 1368 } 1369 func (fpaov *RoleBindingParent_FieldTerminalPathArrayOfValues) AsParentArrayOfValues() ([]*Reference, bool) { 1370 res, ok := fpaov.values.([]*Reference) 1371 return res, ok 1372 } 1373 func (fpaov *RoleBindingParent_FieldTerminalPathArrayOfValues) AsMemberArrayOfValues() ([]string, bool) { 1374 res, ok := fpaov.values.([]string) 1375 return res, ok 1376 }