github.com/cloudwan/edgelq-sdk@v1.15.4/iam/resources/v1/role_binding/role_binding.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/iam/proto/v1/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/v1/condition" 27 organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1/organization" 28 project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project" 29 role "github.com/cloudwan/edgelq-sdk/iam/resources/v1/role" 30 meta_service "github.com/cloudwan/goten-sdk/meta-service/resources/v1/service" 31 meta "github.com/cloudwan/goten-sdk/types/meta" 32 ) 33 34 // ensure the imports are used 35 var ( 36 _ = new(json.Marshaler) 37 _ = new(fmt.Stringer) 38 _ = reflect.DeepEqual 39 _ = strings.Builder{} 40 _ = time.Second 41 42 _ = strcase.ToLowerCamel 43 _ = codes.NotFound 44 _ = status.Status{} 45 _ = protojson.UnmarshalOptions{} 46 _ = new(proto.Message) 47 _ = protoregistry.GlobalTypes 48 49 _ = new(gotenobject.FieldPath) 50 ) 51 52 // make sure we're using proto imports 53 var ( 54 _ = &condition.Condition{} 55 _ = &organization.Organization{} 56 _ = &project.Project{} 57 _ = &role.Role{} 58 _ = &meta_service.Service{} 59 _ = &meta.Meta{} 60 ) 61 62 // FieldPath provides implementation to handle 63 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 64 type RoleBinding_FieldPath interface { 65 gotenobject.FieldPath 66 Selector() RoleBinding_FieldPathSelector 67 Get(source *RoleBinding) []interface{} 68 GetSingle(source *RoleBinding) (interface{}, bool) 69 ClearValue(item *RoleBinding) 70 71 // Those methods build corresponding RoleBinding_FieldPathValue 72 // (or array of values) and holds passed value. Panics if injected type is incorrect. 73 WithIValue(value interface{}) RoleBinding_FieldPathValue 74 WithIArrayOfValues(values interface{}) RoleBinding_FieldPathArrayOfValues 75 WithIArrayItemValue(value interface{}) RoleBinding_FieldPathArrayItemValue 76 } 77 78 type RoleBinding_FieldPathSelector int32 79 80 const ( 81 RoleBinding_FieldPathSelectorName RoleBinding_FieldPathSelector = 0 82 RoleBinding_FieldPathSelectorMetadata RoleBinding_FieldPathSelector = 1 83 RoleBinding_FieldPathSelectorRole RoleBinding_FieldPathSelector = 2 84 RoleBinding_FieldPathSelectorMember RoleBinding_FieldPathSelector = 3 85 RoleBinding_FieldPathSelectorScopeParams RoleBinding_FieldPathSelector = 4 86 RoleBinding_FieldPathSelectorExecutableConditions RoleBinding_FieldPathSelector = 5 87 RoleBinding_FieldPathSelectorOwnedObjects RoleBinding_FieldPathSelector = 6 88 RoleBinding_FieldPathSelectorMemberType RoleBinding_FieldPathSelector = 7 89 RoleBinding_FieldPathSelectorCategory RoleBinding_FieldPathSelector = 8 90 RoleBinding_FieldPathSelectorAncestryPath RoleBinding_FieldPathSelector = 9 91 RoleBinding_FieldPathSelectorParentByOrg RoleBinding_FieldPathSelector = 10 92 RoleBinding_FieldPathSelectorSpecGeneration RoleBinding_FieldPathSelector = 11 93 RoleBinding_FieldPathSelectorHasOwnedObjects RoleBinding_FieldPathSelector = 12 94 RoleBinding_FieldPathSelectorDisableForChildScopes RoleBinding_FieldPathSelector = 13 95 ) 96 97 func (s RoleBinding_FieldPathSelector) String() string { 98 switch s { 99 case RoleBinding_FieldPathSelectorName: 100 return "name" 101 case RoleBinding_FieldPathSelectorMetadata: 102 return "metadata" 103 case RoleBinding_FieldPathSelectorRole: 104 return "role" 105 case RoleBinding_FieldPathSelectorMember: 106 return "member" 107 case RoleBinding_FieldPathSelectorScopeParams: 108 return "scope_params" 109 case RoleBinding_FieldPathSelectorExecutableConditions: 110 return "executable_conditions" 111 case RoleBinding_FieldPathSelectorOwnedObjects: 112 return "owned_objects" 113 case RoleBinding_FieldPathSelectorMemberType: 114 return "member_type" 115 case RoleBinding_FieldPathSelectorCategory: 116 return "category" 117 case RoleBinding_FieldPathSelectorAncestryPath: 118 return "ancestry_path" 119 case RoleBinding_FieldPathSelectorParentByOrg: 120 return "parent_by_org" 121 case RoleBinding_FieldPathSelectorSpecGeneration: 122 return "spec_generation" 123 case RoleBinding_FieldPathSelectorHasOwnedObjects: 124 return "has_owned_objects" 125 case RoleBinding_FieldPathSelectorDisableForChildScopes: 126 return "disable_for_child_scopes" 127 default: 128 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", s)) 129 } 130 } 131 132 func BuildRoleBinding_FieldPath(fp gotenobject.RawFieldPath) (RoleBinding_FieldPath, error) { 133 if len(fp) == 0 { 134 return nil, status.Error(codes.InvalidArgument, "empty field path for object RoleBinding") 135 } 136 if len(fp) == 1 { 137 switch fp[0] { 138 case "name": 139 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorName}, nil 140 case "metadata": 141 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorMetadata}, nil 142 case "role": 143 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorRole}, nil 144 case "member": 145 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorMember}, nil 146 case "scope_params", "scopeParams", "scope-params": 147 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorScopeParams}, nil 148 case "executable_conditions", "executableConditions", "executable-conditions": 149 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorExecutableConditions}, nil 150 case "owned_objects", "ownedObjects", "owned-objects": 151 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorOwnedObjects}, nil 152 case "member_type", "memberType", "member-type": 153 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorMemberType}, nil 154 case "category": 155 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorCategory}, nil 156 case "ancestry_path", "ancestryPath", "ancestry-path": 157 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorAncestryPath}, nil 158 case "parent_by_org", "parentByOrg", "parent-by-org": 159 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorParentByOrg}, nil 160 case "spec_generation", "specGeneration", "spec-generation": 161 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorSpecGeneration}, nil 162 case "has_owned_objects", "hasOwnedObjects", "has-owned-objects": 163 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorHasOwnedObjects}, nil 164 case "disable_for_child_scopes", "disableForChildScopes", "disable-for-child-scopes": 165 return &RoleBinding_FieldTerminalPath{selector: RoleBinding_FieldPathSelectorDisableForChildScopes}, nil 166 } 167 } else { 168 switch fp[0] { 169 case "metadata": 170 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 171 return nil, err 172 } else { 173 return &RoleBinding_FieldSubPath{selector: RoleBinding_FieldPathSelectorMetadata, subPath: subpath}, nil 174 } 175 case "scope_params", "scopeParams", "scope-params": 176 if subpath, err := role.BuildScopeParam_FieldPath(fp[1:]); err != nil { 177 return nil, err 178 } else { 179 return &RoleBinding_FieldSubPath{selector: RoleBinding_FieldPathSelectorScopeParams, subPath: subpath}, nil 180 } 181 case "executable_conditions", "executableConditions", "executable-conditions": 182 if subpath, err := condition.BuildExecutableCondition_FieldPath(fp[1:]); err != nil { 183 return nil, err 184 } else { 185 return &RoleBinding_FieldSubPath{selector: RoleBinding_FieldPathSelectorExecutableConditions, subPath: subpath}, nil 186 } 187 case "ancestry_path", "ancestryPath", "ancestry-path": 188 if subpath, err := BuildRoleBindingParent_FieldPath(fp[1:]); err != nil { 189 return nil, err 190 } else { 191 return &RoleBinding_FieldSubPath{selector: RoleBinding_FieldPathSelectorAncestryPath, subPath: subpath}, nil 192 } 193 } 194 } 195 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object RoleBinding", fp) 196 } 197 198 func ParseRoleBinding_FieldPath(rawField string) (RoleBinding_FieldPath, error) { 199 fp, err := gotenobject.ParseRawFieldPath(rawField) 200 if err != nil { 201 return nil, err 202 } 203 return BuildRoleBinding_FieldPath(fp) 204 } 205 206 func MustParseRoleBinding_FieldPath(rawField string) RoleBinding_FieldPath { 207 fp, err := ParseRoleBinding_FieldPath(rawField) 208 if err != nil { 209 panic(err) 210 } 211 return fp 212 } 213 214 type RoleBinding_FieldTerminalPath struct { 215 selector RoleBinding_FieldPathSelector 216 } 217 218 var _ RoleBinding_FieldPath = (*RoleBinding_FieldTerminalPath)(nil) 219 220 func (fp *RoleBinding_FieldTerminalPath) Selector() RoleBinding_FieldPathSelector { 221 return fp.selector 222 } 223 224 // String returns path representation in proto convention 225 func (fp *RoleBinding_FieldTerminalPath) String() string { 226 return fp.selector.String() 227 } 228 229 // JSONString returns path representation is JSON convention 230 func (fp *RoleBinding_FieldTerminalPath) JSONString() string { 231 return strcase.ToLowerCamel(fp.String()) 232 } 233 234 // Get returns all values pointed by specific field from source RoleBinding 235 func (fp *RoleBinding_FieldTerminalPath) Get(source *RoleBinding) (values []interface{}) { 236 if source != nil { 237 switch fp.selector { 238 case RoleBinding_FieldPathSelectorName: 239 if source.Name != nil { 240 values = append(values, source.Name) 241 } 242 case RoleBinding_FieldPathSelectorMetadata: 243 if source.Metadata != nil { 244 values = append(values, source.Metadata) 245 } 246 case RoleBinding_FieldPathSelectorRole: 247 if source.Role != nil { 248 values = append(values, source.Role) 249 } 250 case RoleBinding_FieldPathSelectorMember: 251 values = append(values, source.Member) 252 case RoleBinding_FieldPathSelectorScopeParams: 253 for _, value := range source.GetScopeParams() { 254 values = append(values, value) 255 } 256 case RoleBinding_FieldPathSelectorExecutableConditions: 257 for _, value := range source.GetExecutableConditions() { 258 values = append(values, value) 259 } 260 case RoleBinding_FieldPathSelectorOwnedObjects: 261 for _, value := range source.GetOwnedObjects() { 262 values = append(values, value) 263 } 264 case RoleBinding_FieldPathSelectorMemberType: 265 values = append(values, source.MemberType) 266 case RoleBinding_FieldPathSelectorCategory: 267 values = append(values, source.Category) 268 case RoleBinding_FieldPathSelectorAncestryPath: 269 for _, value := range source.GetAncestryPath() { 270 values = append(values, value) 271 } 272 case RoleBinding_FieldPathSelectorParentByOrg: 273 if source.ParentByOrg != nil { 274 values = append(values, source.ParentByOrg) 275 } 276 case RoleBinding_FieldPathSelectorSpecGeneration: 277 values = append(values, source.SpecGeneration) 278 case RoleBinding_FieldPathSelectorHasOwnedObjects: 279 values = append(values, source.HasOwnedObjects) 280 case RoleBinding_FieldPathSelectorDisableForChildScopes: 281 values = append(values, source.DisableForChildScopes) 282 default: 283 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 284 } 285 } 286 return 287 } 288 289 func (fp *RoleBinding_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 290 return fp.Get(source.(*RoleBinding)) 291 } 292 293 // GetSingle returns value pointed by specific field of from source RoleBinding 294 func (fp *RoleBinding_FieldTerminalPath) GetSingle(source *RoleBinding) (interface{}, bool) { 295 switch fp.selector { 296 case RoleBinding_FieldPathSelectorName: 297 res := source.GetName() 298 return res, res != nil 299 case RoleBinding_FieldPathSelectorMetadata: 300 res := source.GetMetadata() 301 return res, res != nil 302 case RoleBinding_FieldPathSelectorRole: 303 res := source.GetRole() 304 return res, res != nil 305 case RoleBinding_FieldPathSelectorMember: 306 return source.GetMember(), source != nil 307 case RoleBinding_FieldPathSelectorScopeParams: 308 res := source.GetScopeParams() 309 return res, res != nil 310 case RoleBinding_FieldPathSelectorExecutableConditions: 311 res := source.GetExecutableConditions() 312 return res, res != nil 313 case RoleBinding_FieldPathSelectorOwnedObjects: 314 res := source.GetOwnedObjects() 315 return res, res != nil 316 case RoleBinding_FieldPathSelectorMemberType: 317 return source.GetMemberType(), source != nil 318 case RoleBinding_FieldPathSelectorCategory: 319 return source.GetCategory(), source != nil 320 case RoleBinding_FieldPathSelectorAncestryPath: 321 res := source.GetAncestryPath() 322 return res, res != nil 323 case RoleBinding_FieldPathSelectorParentByOrg: 324 res := source.GetParentByOrg() 325 return res, res != nil 326 case RoleBinding_FieldPathSelectorSpecGeneration: 327 return source.GetSpecGeneration(), source != nil 328 case RoleBinding_FieldPathSelectorHasOwnedObjects: 329 return source.GetHasOwnedObjects(), source != nil 330 case RoleBinding_FieldPathSelectorDisableForChildScopes: 331 return source.GetDisableForChildScopes(), source != nil 332 default: 333 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 334 } 335 } 336 337 func (fp *RoleBinding_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 338 return fp.GetSingle(source.(*RoleBinding)) 339 } 340 341 // GetDefault returns a default value of the field type 342 func (fp *RoleBinding_FieldTerminalPath) GetDefault() interface{} { 343 switch fp.selector { 344 case RoleBinding_FieldPathSelectorName: 345 return (*Name)(nil) 346 case RoleBinding_FieldPathSelectorMetadata: 347 return (*meta.Meta)(nil) 348 case RoleBinding_FieldPathSelectorRole: 349 return (*role.Reference)(nil) 350 case RoleBinding_FieldPathSelectorMember: 351 return "" 352 case RoleBinding_FieldPathSelectorScopeParams: 353 return ([]*role.ScopeParam)(nil) 354 case RoleBinding_FieldPathSelectorExecutableConditions: 355 return ([]*condition.ExecutableCondition)(nil) 356 case RoleBinding_FieldPathSelectorOwnedObjects: 357 return ([]string)(nil) 358 case RoleBinding_FieldPathSelectorMemberType: 359 return "" 360 case RoleBinding_FieldPathSelectorCategory: 361 return role.Role_UNDEFINED 362 case RoleBinding_FieldPathSelectorAncestryPath: 363 return ([]*RoleBinding_Parent)(nil) 364 case RoleBinding_FieldPathSelectorParentByOrg: 365 return (*Reference)(nil) 366 case RoleBinding_FieldPathSelectorSpecGeneration: 367 return int64(0) 368 case RoleBinding_FieldPathSelectorHasOwnedObjects: 369 return false 370 case RoleBinding_FieldPathSelectorDisableForChildScopes: 371 return false 372 default: 373 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 374 } 375 } 376 377 func (fp *RoleBinding_FieldTerminalPath) ClearValue(item *RoleBinding) { 378 if item != nil { 379 switch fp.selector { 380 case RoleBinding_FieldPathSelectorName: 381 item.Name = nil 382 case RoleBinding_FieldPathSelectorMetadata: 383 item.Metadata = nil 384 case RoleBinding_FieldPathSelectorRole: 385 item.Role = nil 386 case RoleBinding_FieldPathSelectorMember: 387 item.Member = "" 388 case RoleBinding_FieldPathSelectorScopeParams: 389 item.ScopeParams = nil 390 case RoleBinding_FieldPathSelectorExecutableConditions: 391 item.ExecutableConditions = nil 392 case RoleBinding_FieldPathSelectorOwnedObjects: 393 item.OwnedObjects = nil 394 case RoleBinding_FieldPathSelectorMemberType: 395 item.MemberType = "" 396 case RoleBinding_FieldPathSelectorCategory: 397 item.Category = role.Role_UNDEFINED 398 case RoleBinding_FieldPathSelectorAncestryPath: 399 item.AncestryPath = nil 400 case RoleBinding_FieldPathSelectorParentByOrg: 401 item.ParentByOrg = nil 402 case RoleBinding_FieldPathSelectorSpecGeneration: 403 item.SpecGeneration = int64(0) 404 case RoleBinding_FieldPathSelectorHasOwnedObjects: 405 item.HasOwnedObjects = false 406 case RoleBinding_FieldPathSelectorDisableForChildScopes: 407 item.DisableForChildScopes = false 408 default: 409 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 410 } 411 } 412 } 413 414 func (fp *RoleBinding_FieldTerminalPath) ClearValueRaw(item proto.Message) { 415 fp.ClearValue(item.(*RoleBinding)) 416 } 417 418 // IsLeaf - whether field path is holds simple value 419 func (fp *RoleBinding_FieldTerminalPath) IsLeaf() bool { 420 return fp.selector == RoleBinding_FieldPathSelectorName || 421 fp.selector == RoleBinding_FieldPathSelectorRole || 422 fp.selector == RoleBinding_FieldPathSelectorMember || 423 fp.selector == RoleBinding_FieldPathSelectorOwnedObjects || 424 fp.selector == RoleBinding_FieldPathSelectorMemberType || 425 fp.selector == RoleBinding_FieldPathSelectorCategory || 426 fp.selector == RoleBinding_FieldPathSelectorParentByOrg || 427 fp.selector == RoleBinding_FieldPathSelectorSpecGeneration || 428 fp.selector == RoleBinding_FieldPathSelectorHasOwnedObjects || 429 fp.selector == RoleBinding_FieldPathSelectorDisableForChildScopes 430 } 431 432 func (fp *RoleBinding_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 433 return []gotenobject.FieldPath{fp} 434 } 435 436 func (fp *RoleBinding_FieldTerminalPath) WithIValue(value interface{}) RoleBinding_FieldPathValue { 437 switch fp.selector { 438 case RoleBinding_FieldPathSelectorName: 439 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*Name)} 440 case RoleBinding_FieldPathSelectorMetadata: 441 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 442 case RoleBinding_FieldPathSelectorRole: 443 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*role.Reference)} 444 case RoleBinding_FieldPathSelectorMember: 445 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(string)} 446 case RoleBinding_FieldPathSelectorScopeParams: 447 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.([]*role.ScopeParam)} 448 case RoleBinding_FieldPathSelectorExecutableConditions: 449 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.([]*condition.ExecutableCondition)} 450 case RoleBinding_FieldPathSelectorOwnedObjects: 451 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.([]string)} 452 case RoleBinding_FieldPathSelectorMemberType: 453 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(string)} 454 case RoleBinding_FieldPathSelectorCategory: 455 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(role.Role_Category)} 456 case RoleBinding_FieldPathSelectorAncestryPath: 457 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.([]*RoleBinding_Parent)} 458 case RoleBinding_FieldPathSelectorParentByOrg: 459 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*Reference)} 460 case RoleBinding_FieldPathSelectorSpecGeneration: 461 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(int64)} 462 case RoleBinding_FieldPathSelectorHasOwnedObjects: 463 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(bool)} 464 case RoleBinding_FieldPathSelectorDisableForChildScopes: 465 return &RoleBinding_FieldTerminalPathValue{RoleBinding_FieldTerminalPath: *fp, value: value.(bool)} 466 default: 467 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 468 } 469 } 470 471 func (fp *RoleBinding_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 472 return fp.WithIValue(value) 473 } 474 475 func (fp *RoleBinding_FieldTerminalPath) WithIArrayOfValues(values interface{}) RoleBinding_FieldPathArrayOfValues { 476 fpaov := &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp} 477 switch fp.selector { 478 case RoleBinding_FieldPathSelectorName: 479 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]*Name)} 480 case RoleBinding_FieldPathSelectorMetadata: 481 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 482 case RoleBinding_FieldPathSelectorRole: 483 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]*role.Reference)} 484 case RoleBinding_FieldPathSelectorMember: 485 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]string)} 486 case RoleBinding_FieldPathSelectorScopeParams: 487 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([][]*role.ScopeParam)} 488 case RoleBinding_FieldPathSelectorExecutableConditions: 489 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([][]*condition.ExecutableCondition)} 490 case RoleBinding_FieldPathSelectorOwnedObjects: 491 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([][]string)} 492 case RoleBinding_FieldPathSelectorMemberType: 493 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]string)} 494 case RoleBinding_FieldPathSelectorCategory: 495 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]role.Role_Category)} 496 case RoleBinding_FieldPathSelectorAncestryPath: 497 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([][]*RoleBinding_Parent)} 498 case RoleBinding_FieldPathSelectorParentByOrg: 499 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]*Reference)} 500 case RoleBinding_FieldPathSelectorSpecGeneration: 501 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]int64)} 502 case RoleBinding_FieldPathSelectorHasOwnedObjects: 503 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]bool)} 504 case RoleBinding_FieldPathSelectorDisableForChildScopes: 505 return &RoleBinding_FieldTerminalPathArrayOfValues{RoleBinding_FieldTerminalPath: *fp, values: values.([]bool)} 506 default: 507 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 508 } 509 return fpaov 510 } 511 512 func (fp *RoleBinding_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 513 return fp.WithIArrayOfValues(values) 514 } 515 516 func (fp *RoleBinding_FieldTerminalPath) WithIArrayItemValue(value interface{}) RoleBinding_FieldPathArrayItemValue { 517 switch fp.selector { 518 case RoleBinding_FieldPathSelectorScopeParams: 519 return &RoleBinding_FieldTerminalPathArrayItemValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*role.ScopeParam)} 520 case RoleBinding_FieldPathSelectorExecutableConditions: 521 return &RoleBinding_FieldTerminalPathArrayItemValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*condition.ExecutableCondition)} 522 case RoleBinding_FieldPathSelectorOwnedObjects: 523 return &RoleBinding_FieldTerminalPathArrayItemValue{RoleBinding_FieldTerminalPath: *fp, value: value.(string)} 524 case RoleBinding_FieldPathSelectorAncestryPath: 525 return &RoleBinding_FieldTerminalPathArrayItemValue{RoleBinding_FieldTerminalPath: *fp, value: value.(*RoleBinding_Parent)} 526 default: 527 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fp.selector)) 528 } 529 } 530 531 func (fp *RoleBinding_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 532 return fp.WithIArrayItemValue(value) 533 } 534 535 type RoleBinding_FieldSubPath struct { 536 selector RoleBinding_FieldPathSelector 537 subPath gotenobject.FieldPath 538 } 539 540 var _ RoleBinding_FieldPath = (*RoleBinding_FieldSubPath)(nil) 541 542 func (fps *RoleBinding_FieldSubPath) Selector() RoleBinding_FieldPathSelector { 543 return fps.selector 544 } 545 func (fps *RoleBinding_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 546 res, ok := fps.subPath.(meta.Meta_FieldPath) 547 return res, ok 548 } 549 func (fps *RoleBinding_FieldSubPath) AsScopeParamsSubPath() (role.ScopeParam_FieldPath, bool) { 550 res, ok := fps.subPath.(role.ScopeParam_FieldPath) 551 return res, ok 552 } 553 func (fps *RoleBinding_FieldSubPath) AsExecutableConditionsSubPath() (condition.ExecutableCondition_FieldPath, bool) { 554 res, ok := fps.subPath.(condition.ExecutableCondition_FieldPath) 555 return res, ok 556 } 557 func (fps *RoleBinding_FieldSubPath) AsAncestryPathSubPath() (RoleBindingParent_FieldPath, bool) { 558 res, ok := fps.subPath.(RoleBindingParent_FieldPath) 559 return res, ok 560 } 561 562 // String returns path representation in proto convention 563 func (fps *RoleBinding_FieldSubPath) String() string { 564 return fps.selector.String() + "." + fps.subPath.String() 565 } 566 567 // JSONString returns path representation is JSON convention 568 func (fps *RoleBinding_FieldSubPath) JSONString() string { 569 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 570 } 571 572 // Get returns all values pointed by selected field from source RoleBinding 573 func (fps *RoleBinding_FieldSubPath) Get(source *RoleBinding) (values []interface{}) { 574 switch fps.selector { 575 case RoleBinding_FieldPathSelectorMetadata: 576 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 577 case RoleBinding_FieldPathSelectorScopeParams: 578 for _, item := range source.GetScopeParams() { 579 values = append(values, fps.subPath.GetRaw(item)...) 580 } 581 case RoleBinding_FieldPathSelectorExecutableConditions: 582 for _, item := range source.GetExecutableConditions() { 583 values = append(values, fps.subPath.GetRaw(item)...) 584 } 585 case RoleBinding_FieldPathSelectorAncestryPath: 586 for _, item := range source.GetAncestryPath() { 587 values = append(values, fps.subPath.GetRaw(item)...) 588 } 589 default: 590 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fps.selector)) 591 } 592 return 593 } 594 595 func (fps *RoleBinding_FieldSubPath) GetRaw(source proto.Message) []interface{} { 596 return fps.Get(source.(*RoleBinding)) 597 } 598 599 // GetSingle returns value of selected field from source RoleBinding 600 func (fps *RoleBinding_FieldSubPath) GetSingle(source *RoleBinding) (interface{}, bool) { 601 switch fps.selector { 602 case RoleBinding_FieldPathSelectorMetadata: 603 if source.GetMetadata() == nil { 604 return nil, false 605 } 606 return fps.subPath.GetSingleRaw(source.GetMetadata()) 607 case RoleBinding_FieldPathSelectorScopeParams: 608 if len(source.GetScopeParams()) == 0 { 609 return nil, false 610 } 611 return fps.subPath.GetSingleRaw(source.GetScopeParams()[0]) 612 case RoleBinding_FieldPathSelectorExecutableConditions: 613 if len(source.GetExecutableConditions()) == 0 { 614 return nil, false 615 } 616 return fps.subPath.GetSingleRaw(source.GetExecutableConditions()[0]) 617 case RoleBinding_FieldPathSelectorAncestryPath: 618 if len(source.GetAncestryPath()) == 0 { 619 return nil, false 620 } 621 return fps.subPath.GetSingleRaw(source.GetAncestryPath()[0]) 622 default: 623 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fps.selector)) 624 } 625 } 626 627 func (fps *RoleBinding_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 628 return fps.GetSingle(source.(*RoleBinding)) 629 } 630 631 // GetDefault returns a default value of the field type 632 func (fps *RoleBinding_FieldSubPath) GetDefault() interface{} { 633 return fps.subPath.GetDefault() 634 } 635 636 func (fps *RoleBinding_FieldSubPath) ClearValue(item *RoleBinding) { 637 if item != nil { 638 switch fps.selector { 639 case RoleBinding_FieldPathSelectorMetadata: 640 fps.subPath.ClearValueRaw(item.Metadata) 641 case RoleBinding_FieldPathSelectorScopeParams: 642 for _, subItem := range item.ScopeParams { 643 fps.subPath.ClearValueRaw(subItem) 644 } 645 case RoleBinding_FieldPathSelectorExecutableConditions: 646 for _, subItem := range item.ExecutableConditions { 647 fps.subPath.ClearValueRaw(subItem) 648 } 649 case RoleBinding_FieldPathSelectorAncestryPath: 650 for _, subItem := range item.AncestryPath { 651 fps.subPath.ClearValueRaw(subItem) 652 } 653 default: 654 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fps.selector)) 655 } 656 } 657 } 658 659 func (fps *RoleBinding_FieldSubPath) ClearValueRaw(item proto.Message) { 660 fps.ClearValue(item.(*RoleBinding)) 661 } 662 663 // IsLeaf - whether field path is holds simple value 664 func (fps *RoleBinding_FieldSubPath) IsLeaf() bool { 665 return fps.subPath.IsLeaf() 666 } 667 668 func (fps *RoleBinding_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 669 iPaths := []gotenobject.FieldPath{&RoleBinding_FieldTerminalPath{selector: fps.selector}} 670 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 671 return iPaths 672 } 673 674 func (fps *RoleBinding_FieldSubPath) WithIValue(value interface{}) RoleBinding_FieldPathValue { 675 return &RoleBinding_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 676 } 677 678 func (fps *RoleBinding_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 679 return fps.WithIValue(value) 680 } 681 682 func (fps *RoleBinding_FieldSubPath) WithIArrayOfValues(values interface{}) RoleBinding_FieldPathArrayOfValues { 683 return &RoleBinding_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 684 } 685 686 func (fps *RoleBinding_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 687 return fps.WithIArrayOfValues(values) 688 } 689 690 func (fps *RoleBinding_FieldSubPath) WithIArrayItemValue(value interface{}) RoleBinding_FieldPathArrayItemValue { 691 return &RoleBinding_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 692 } 693 694 func (fps *RoleBinding_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 695 return fps.WithIArrayItemValue(value) 696 } 697 698 // RoleBinding_FieldPathValue allows storing values for RoleBinding fields according to their type 699 type RoleBinding_FieldPathValue interface { 700 RoleBinding_FieldPath 701 gotenobject.FieldPathValue 702 SetTo(target **RoleBinding) 703 CompareWith(*RoleBinding) (cmp int, comparable bool) 704 } 705 706 func ParseRoleBinding_FieldPathValue(pathStr, valueStr string) (RoleBinding_FieldPathValue, error) { 707 fp, err := ParseRoleBinding_FieldPath(pathStr) 708 if err != nil { 709 return nil, err 710 } 711 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 712 if err != nil { 713 return nil, status.Errorf(codes.InvalidArgument, "error parsing RoleBinding field path value from %s: %v", valueStr, err) 714 } 715 return fpv.(RoleBinding_FieldPathValue), nil 716 } 717 718 func MustParseRoleBinding_FieldPathValue(pathStr, valueStr string) RoleBinding_FieldPathValue { 719 fpv, err := ParseRoleBinding_FieldPathValue(pathStr, valueStr) 720 if err != nil { 721 panic(err) 722 } 723 return fpv 724 } 725 726 type RoleBinding_FieldTerminalPathValue struct { 727 RoleBinding_FieldTerminalPath 728 value interface{} 729 } 730 731 var _ RoleBinding_FieldPathValue = (*RoleBinding_FieldTerminalPathValue)(nil) 732 733 // GetRawValue returns raw value stored under selected path for 'RoleBinding' as interface{} 734 func (fpv *RoleBinding_FieldTerminalPathValue) GetRawValue() interface{} { 735 return fpv.value 736 } 737 func (fpv *RoleBinding_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 738 res, ok := fpv.value.(*Name) 739 return res, ok 740 } 741 func (fpv *RoleBinding_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 742 res, ok := fpv.value.(*meta.Meta) 743 return res, ok 744 } 745 func (fpv *RoleBinding_FieldTerminalPathValue) AsRoleValue() (*role.Reference, bool) { 746 res, ok := fpv.value.(*role.Reference) 747 return res, ok 748 } 749 func (fpv *RoleBinding_FieldTerminalPathValue) AsMemberValue() (string, bool) { 750 res, ok := fpv.value.(string) 751 return res, ok 752 } 753 func (fpv *RoleBinding_FieldTerminalPathValue) AsScopeParamsValue() ([]*role.ScopeParam, bool) { 754 res, ok := fpv.value.([]*role.ScopeParam) 755 return res, ok 756 } 757 func (fpv *RoleBinding_FieldTerminalPathValue) AsExecutableConditionsValue() ([]*condition.ExecutableCondition, bool) { 758 res, ok := fpv.value.([]*condition.ExecutableCondition) 759 return res, ok 760 } 761 func (fpv *RoleBinding_FieldTerminalPathValue) AsOwnedObjectsValue() ([]string, bool) { 762 res, ok := fpv.value.([]string) 763 return res, ok 764 } 765 func (fpv *RoleBinding_FieldTerminalPathValue) AsMemberTypeValue() (string, bool) { 766 res, ok := fpv.value.(string) 767 return res, ok 768 } 769 func (fpv *RoleBinding_FieldTerminalPathValue) AsCategoryValue() (role.Role_Category, bool) { 770 res, ok := fpv.value.(role.Role_Category) 771 return res, ok 772 } 773 func (fpv *RoleBinding_FieldTerminalPathValue) AsAncestryPathValue() ([]*RoleBinding_Parent, bool) { 774 res, ok := fpv.value.([]*RoleBinding_Parent) 775 return res, ok 776 } 777 func (fpv *RoleBinding_FieldTerminalPathValue) AsParentByOrgValue() (*Reference, bool) { 778 res, ok := fpv.value.(*Reference) 779 return res, ok 780 } 781 func (fpv *RoleBinding_FieldTerminalPathValue) AsSpecGenerationValue() (int64, bool) { 782 res, ok := fpv.value.(int64) 783 return res, ok 784 } 785 func (fpv *RoleBinding_FieldTerminalPathValue) AsHasOwnedObjectsValue() (bool, bool) { 786 res, ok := fpv.value.(bool) 787 return res, ok 788 } 789 func (fpv *RoleBinding_FieldTerminalPathValue) AsDisableForChildScopesValue() (bool, bool) { 790 res, ok := fpv.value.(bool) 791 return res, ok 792 } 793 794 // SetTo stores value for selected field for object RoleBinding 795 func (fpv *RoleBinding_FieldTerminalPathValue) SetTo(target **RoleBinding) { 796 if *target == nil { 797 *target = new(RoleBinding) 798 } 799 switch fpv.selector { 800 case RoleBinding_FieldPathSelectorName: 801 (*target).Name = fpv.value.(*Name) 802 case RoleBinding_FieldPathSelectorMetadata: 803 (*target).Metadata = fpv.value.(*meta.Meta) 804 case RoleBinding_FieldPathSelectorRole: 805 (*target).Role = fpv.value.(*role.Reference) 806 case RoleBinding_FieldPathSelectorMember: 807 (*target).Member = fpv.value.(string) 808 case RoleBinding_FieldPathSelectorScopeParams: 809 (*target).ScopeParams = fpv.value.([]*role.ScopeParam) 810 case RoleBinding_FieldPathSelectorExecutableConditions: 811 (*target).ExecutableConditions = fpv.value.([]*condition.ExecutableCondition) 812 case RoleBinding_FieldPathSelectorOwnedObjects: 813 (*target).OwnedObjects = fpv.value.([]string) 814 case RoleBinding_FieldPathSelectorMemberType: 815 (*target).MemberType = fpv.value.(string) 816 case RoleBinding_FieldPathSelectorCategory: 817 (*target).Category = fpv.value.(role.Role_Category) 818 case RoleBinding_FieldPathSelectorAncestryPath: 819 (*target).AncestryPath = fpv.value.([]*RoleBinding_Parent) 820 case RoleBinding_FieldPathSelectorParentByOrg: 821 (*target).ParentByOrg = fpv.value.(*Reference) 822 case RoleBinding_FieldPathSelectorSpecGeneration: 823 (*target).SpecGeneration = fpv.value.(int64) 824 case RoleBinding_FieldPathSelectorHasOwnedObjects: 825 (*target).HasOwnedObjects = fpv.value.(bool) 826 case RoleBinding_FieldPathSelectorDisableForChildScopes: 827 (*target).DisableForChildScopes = fpv.value.(bool) 828 default: 829 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fpv.selector)) 830 } 831 } 832 833 func (fpv *RoleBinding_FieldTerminalPathValue) SetToRaw(target proto.Message) { 834 typedObject := target.(*RoleBinding) 835 fpv.SetTo(&typedObject) 836 } 837 838 // CompareWith compares value in the 'RoleBinding_FieldTerminalPathValue' with the value under path in 'RoleBinding'. 839 func (fpv *RoleBinding_FieldTerminalPathValue) CompareWith(source *RoleBinding) (int, bool) { 840 switch fpv.selector { 841 case RoleBinding_FieldPathSelectorName: 842 leftValue := fpv.value.(*Name) 843 rightValue := source.GetName() 844 if leftValue == nil { 845 if rightValue != nil { 846 return -1, true 847 } 848 return 0, true 849 } 850 if rightValue == nil { 851 return 1, true 852 } 853 if leftValue.String() == rightValue.String() { 854 return 0, true 855 } else if leftValue.String() < rightValue.String() { 856 return -1, true 857 } else { 858 return 1, true 859 } 860 case RoleBinding_FieldPathSelectorMetadata: 861 return 0, false 862 case RoleBinding_FieldPathSelectorRole: 863 leftValue := fpv.value.(*role.Reference) 864 rightValue := source.GetRole() 865 if leftValue == nil { 866 if rightValue != nil { 867 return -1, true 868 } 869 return 0, true 870 } 871 if rightValue == nil { 872 return 1, true 873 } 874 if leftValue.String() == rightValue.String() { 875 return 0, true 876 } else if leftValue.String() < rightValue.String() { 877 return -1, true 878 } else { 879 return 1, true 880 } 881 case RoleBinding_FieldPathSelectorMember: 882 leftValue := fpv.value.(string) 883 rightValue := source.GetMember() 884 if (leftValue) == (rightValue) { 885 return 0, true 886 } else if (leftValue) < (rightValue) { 887 return -1, true 888 } else { 889 return 1, true 890 } 891 case RoleBinding_FieldPathSelectorScopeParams: 892 return 0, false 893 case RoleBinding_FieldPathSelectorExecutableConditions: 894 return 0, false 895 case RoleBinding_FieldPathSelectorOwnedObjects: 896 return 0, false 897 case RoleBinding_FieldPathSelectorMemberType: 898 leftValue := fpv.value.(string) 899 rightValue := source.GetMemberType() 900 if (leftValue) == (rightValue) { 901 return 0, true 902 } else if (leftValue) < (rightValue) { 903 return -1, true 904 } else { 905 return 1, true 906 } 907 case RoleBinding_FieldPathSelectorCategory: 908 leftValue := fpv.value.(role.Role_Category) 909 rightValue := source.GetCategory() 910 if (leftValue) == (rightValue) { 911 return 0, true 912 } else if (leftValue) < (rightValue) { 913 return -1, true 914 } else { 915 return 1, true 916 } 917 case RoleBinding_FieldPathSelectorAncestryPath: 918 return 0, false 919 case RoleBinding_FieldPathSelectorParentByOrg: 920 leftValue := fpv.value.(*Reference) 921 rightValue := source.GetParentByOrg() 922 if leftValue == nil { 923 if rightValue != nil { 924 return -1, true 925 } 926 return 0, true 927 } 928 if rightValue == nil { 929 return 1, true 930 } 931 if leftValue.String() == rightValue.String() { 932 return 0, true 933 } else if leftValue.String() < rightValue.String() { 934 return -1, true 935 } else { 936 return 1, true 937 } 938 case RoleBinding_FieldPathSelectorSpecGeneration: 939 leftValue := fpv.value.(int64) 940 rightValue := source.GetSpecGeneration() 941 if (leftValue) == (rightValue) { 942 return 0, true 943 } else if (leftValue) < (rightValue) { 944 return -1, true 945 } else { 946 return 1, true 947 } 948 case RoleBinding_FieldPathSelectorHasOwnedObjects: 949 leftValue := fpv.value.(bool) 950 rightValue := source.GetHasOwnedObjects() 951 if (leftValue) == (rightValue) { 952 return 0, true 953 } else if !(leftValue) && (rightValue) { 954 return -1, true 955 } else { 956 return 1, true 957 } 958 case RoleBinding_FieldPathSelectorDisableForChildScopes: 959 leftValue := fpv.value.(bool) 960 rightValue := source.GetDisableForChildScopes() 961 if (leftValue) == (rightValue) { 962 return 0, true 963 } else if !(leftValue) && (rightValue) { 964 return -1, true 965 } else { 966 return 1, true 967 } 968 default: 969 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fpv.selector)) 970 } 971 } 972 973 func (fpv *RoleBinding_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 974 return fpv.CompareWith(source.(*RoleBinding)) 975 } 976 977 type RoleBinding_FieldSubPathValue struct { 978 RoleBinding_FieldPath 979 subPathValue gotenobject.FieldPathValue 980 } 981 982 var _ RoleBinding_FieldPathValue = (*RoleBinding_FieldSubPathValue)(nil) 983 984 func (fpvs *RoleBinding_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 985 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 986 return res, ok 987 } 988 func (fpvs *RoleBinding_FieldSubPathValue) AsScopeParamsPathValue() (role.ScopeParam_FieldPathValue, bool) { 989 res, ok := fpvs.subPathValue.(role.ScopeParam_FieldPathValue) 990 return res, ok 991 } 992 func (fpvs *RoleBinding_FieldSubPathValue) AsExecutableConditionsPathValue() (condition.ExecutableCondition_FieldPathValue, bool) { 993 res, ok := fpvs.subPathValue.(condition.ExecutableCondition_FieldPathValue) 994 return res, ok 995 } 996 func (fpvs *RoleBinding_FieldSubPathValue) AsAncestryPathPathValue() (RoleBindingParent_FieldPathValue, bool) { 997 res, ok := fpvs.subPathValue.(RoleBindingParent_FieldPathValue) 998 return res, ok 999 } 1000 1001 func (fpvs *RoleBinding_FieldSubPathValue) SetTo(target **RoleBinding) { 1002 if *target == nil { 1003 *target = new(RoleBinding) 1004 } 1005 switch fpvs.Selector() { 1006 case RoleBinding_FieldPathSelectorMetadata: 1007 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 1008 case RoleBinding_FieldPathSelectorScopeParams: 1009 panic("FieldPath setter is unsupported for array subpaths") 1010 case RoleBinding_FieldPathSelectorExecutableConditions: 1011 panic("FieldPath setter is unsupported for array subpaths") 1012 case RoleBinding_FieldPathSelectorAncestryPath: 1013 panic("FieldPath setter is unsupported for array subpaths") 1014 default: 1015 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fpvs.Selector())) 1016 } 1017 } 1018 1019 func (fpvs *RoleBinding_FieldSubPathValue) SetToRaw(target proto.Message) { 1020 typedObject := target.(*RoleBinding) 1021 fpvs.SetTo(&typedObject) 1022 } 1023 1024 func (fpvs *RoleBinding_FieldSubPathValue) GetRawValue() interface{} { 1025 return fpvs.subPathValue.GetRawValue() 1026 } 1027 1028 func (fpvs *RoleBinding_FieldSubPathValue) CompareWith(source *RoleBinding) (int, bool) { 1029 switch fpvs.Selector() { 1030 case RoleBinding_FieldPathSelectorMetadata: 1031 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 1032 case RoleBinding_FieldPathSelectorScopeParams: 1033 return 0, false // repeated field 1034 case RoleBinding_FieldPathSelectorExecutableConditions: 1035 return 0, false // repeated field 1036 case RoleBinding_FieldPathSelectorAncestryPath: 1037 return 0, false // repeated field 1038 default: 1039 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fpvs.Selector())) 1040 } 1041 } 1042 1043 func (fpvs *RoleBinding_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1044 return fpvs.CompareWith(source.(*RoleBinding)) 1045 } 1046 1047 // RoleBinding_FieldPathArrayItemValue allows storing single item in Path-specific values for RoleBinding according to their type 1048 // Present only for array (repeated) types. 1049 type RoleBinding_FieldPathArrayItemValue interface { 1050 gotenobject.FieldPathArrayItemValue 1051 RoleBinding_FieldPath 1052 ContainsValue(*RoleBinding) bool 1053 } 1054 1055 // ParseRoleBinding_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1056 func ParseRoleBinding_FieldPathArrayItemValue(pathStr, valueStr string) (RoleBinding_FieldPathArrayItemValue, error) { 1057 fp, err := ParseRoleBinding_FieldPath(pathStr) 1058 if err != nil { 1059 return nil, err 1060 } 1061 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1062 if err != nil { 1063 return nil, status.Errorf(codes.InvalidArgument, "error parsing RoleBinding field path array item value from %s: %v", valueStr, err) 1064 } 1065 return fpaiv.(RoleBinding_FieldPathArrayItemValue), nil 1066 } 1067 1068 func MustParseRoleBinding_FieldPathArrayItemValue(pathStr, valueStr string) RoleBinding_FieldPathArrayItemValue { 1069 fpaiv, err := ParseRoleBinding_FieldPathArrayItemValue(pathStr, valueStr) 1070 if err != nil { 1071 panic(err) 1072 } 1073 return fpaiv 1074 } 1075 1076 type RoleBinding_FieldTerminalPathArrayItemValue struct { 1077 RoleBinding_FieldTerminalPath 1078 value interface{} 1079 } 1080 1081 var _ RoleBinding_FieldPathArrayItemValue = (*RoleBinding_FieldTerminalPathArrayItemValue)(nil) 1082 1083 // GetRawValue returns stored element value for array in object RoleBinding as interface{} 1084 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1085 return fpaiv.value 1086 } 1087 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) AsScopeParamsItemValue() (*role.ScopeParam, bool) { 1088 res, ok := fpaiv.value.(*role.ScopeParam) 1089 return res, ok 1090 } 1091 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) AsExecutableConditionsItemValue() (*condition.ExecutableCondition, bool) { 1092 res, ok := fpaiv.value.(*condition.ExecutableCondition) 1093 return res, ok 1094 } 1095 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) AsOwnedObjectsItemValue() (string, bool) { 1096 res, ok := fpaiv.value.(string) 1097 return res, ok 1098 } 1099 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) AsAncestryPathItemValue() (*RoleBinding_Parent, bool) { 1100 res, ok := fpaiv.value.(*RoleBinding_Parent) 1101 return res, ok 1102 } 1103 1104 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) GetSingle(source *RoleBinding) (interface{}, bool) { 1105 return nil, false 1106 } 1107 1108 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1109 return fpaiv.GetSingle(source.(*RoleBinding)) 1110 } 1111 1112 // Contains returns a boolean indicating if value that is being held is present in given 'RoleBinding' 1113 func (fpaiv *RoleBinding_FieldTerminalPathArrayItemValue) ContainsValue(source *RoleBinding) bool { 1114 slice := fpaiv.RoleBinding_FieldTerminalPath.Get(source) 1115 for _, v := range slice { 1116 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1117 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1118 return true 1119 } 1120 } else if reflect.DeepEqual(v, fpaiv.value) { 1121 return true 1122 } 1123 } 1124 return false 1125 } 1126 1127 type RoleBinding_FieldSubPathArrayItemValue struct { 1128 RoleBinding_FieldPath 1129 subPathItemValue gotenobject.FieldPathArrayItemValue 1130 } 1131 1132 // GetRawValue returns stored array item value 1133 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 1134 return fpaivs.subPathItemValue.GetRawItemValue() 1135 } 1136 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 1137 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 1138 return res, ok 1139 } 1140 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) AsScopeParamsPathItemValue() (role.ScopeParam_FieldPathArrayItemValue, bool) { 1141 res, ok := fpaivs.subPathItemValue.(role.ScopeParam_FieldPathArrayItemValue) 1142 return res, ok 1143 } 1144 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) AsExecutableConditionsPathItemValue() (condition.ExecutableCondition_FieldPathArrayItemValue, bool) { 1145 res, ok := fpaivs.subPathItemValue.(condition.ExecutableCondition_FieldPathArrayItemValue) 1146 return res, ok 1147 } 1148 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) AsAncestryPathPathItemValue() (RoleBindingParent_FieldPathArrayItemValue, bool) { 1149 res, ok := fpaivs.subPathItemValue.(RoleBindingParent_FieldPathArrayItemValue) 1150 return res, ok 1151 } 1152 1153 // Contains returns a boolean indicating if value that is being held is present in given 'RoleBinding' 1154 func (fpaivs *RoleBinding_FieldSubPathArrayItemValue) ContainsValue(source *RoleBinding) bool { 1155 switch fpaivs.Selector() { 1156 case RoleBinding_FieldPathSelectorMetadata: 1157 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 1158 case RoleBinding_FieldPathSelectorScopeParams: 1159 return false // repeated/map field 1160 case RoleBinding_FieldPathSelectorExecutableConditions: 1161 return false // repeated/map field 1162 case RoleBinding_FieldPathSelectorAncestryPath: 1163 return false // repeated/map field 1164 default: 1165 panic(fmt.Sprintf("Invalid selector for RoleBinding: %d", fpaivs.Selector())) 1166 } 1167 } 1168 1169 // RoleBinding_FieldPathArrayOfValues allows storing slice of values for RoleBinding fields according to their type 1170 type RoleBinding_FieldPathArrayOfValues interface { 1171 gotenobject.FieldPathArrayOfValues 1172 RoleBinding_FieldPath 1173 } 1174 1175 func ParseRoleBinding_FieldPathArrayOfValues(pathStr, valuesStr string) (RoleBinding_FieldPathArrayOfValues, error) { 1176 fp, err := ParseRoleBinding_FieldPath(pathStr) 1177 if err != nil { 1178 return nil, err 1179 } 1180 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1181 if err != nil { 1182 return nil, status.Errorf(codes.InvalidArgument, "error parsing RoleBinding field path array of values from %s: %v", valuesStr, err) 1183 } 1184 return fpaov.(RoleBinding_FieldPathArrayOfValues), nil 1185 } 1186 1187 func MustParseRoleBinding_FieldPathArrayOfValues(pathStr, valuesStr string) RoleBinding_FieldPathArrayOfValues { 1188 fpaov, err := ParseRoleBinding_FieldPathArrayOfValues(pathStr, valuesStr) 1189 if err != nil { 1190 panic(err) 1191 } 1192 return fpaov 1193 } 1194 1195 type RoleBinding_FieldTerminalPathArrayOfValues struct { 1196 RoleBinding_FieldTerminalPath 1197 values interface{} 1198 } 1199 1200 var _ RoleBinding_FieldPathArrayOfValues = (*RoleBinding_FieldTerminalPathArrayOfValues)(nil) 1201 1202 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1203 switch fpaov.selector { 1204 case RoleBinding_FieldPathSelectorName: 1205 for _, v := range fpaov.values.([]*Name) { 1206 values = append(values, v) 1207 } 1208 case RoleBinding_FieldPathSelectorMetadata: 1209 for _, v := range fpaov.values.([]*meta.Meta) { 1210 values = append(values, v) 1211 } 1212 case RoleBinding_FieldPathSelectorRole: 1213 for _, v := range fpaov.values.([]*role.Reference) { 1214 values = append(values, v) 1215 } 1216 case RoleBinding_FieldPathSelectorMember: 1217 for _, v := range fpaov.values.([]string) { 1218 values = append(values, v) 1219 } 1220 case RoleBinding_FieldPathSelectorScopeParams: 1221 for _, v := range fpaov.values.([][]*role.ScopeParam) { 1222 values = append(values, v) 1223 } 1224 case RoleBinding_FieldPathSelectorExecutableConditions: 1225 for _, v := range fpaov.values.([][]*condition.ExecutableCondition) { 1226 values = append(values, v) 1227 } 1228 case RoleBinding_FieldPathSelectorOwnedObjects: 1229 for _, v := range fpaov.values.([][]string) { 1230 values = append(values, v) 1231 } 1232 case RoleBinding_FieldPathSelectorMemberType: 1233 for _, v := range fpaov.values.([]string) { 1234 values = append(values, v) 1235 } 1236 case RoleBinding_FieldPathSelectorCategory: 1237 for _, v := range fpaov.values.([]role.Role_Category) { 1238 values = append(values, v) 1239 } 1240 case RoleBinding_FieldPathSelectorAncestryPath: 1241 for _, v := range fpaov.values.([][]*RoleBinding_Parent) { 1242 values = append(values, v) 1243 } 1244 case RoleBinding_FieldPathSelectorParentByOrg: 1245 for _, v := range fpaov.values.([]*Reference) { 1246 values = append(values, v) 1247 } 1248 case RoleBinding_FieldPathSelectorSpecGeneration: 1249 for _, v := range fpaov.values.([]int64) { 1250 values = append(values, v) 1251 } 1252 case RoleBinding_FieldPathSelectorHasOwnedObjects: 1253 for _, v := range fpaov.values.([]bool) { 1254 values = append(values, v) 1255 } 1256 case RoleBinding_FieldPathSelectorDisableForChildScopes: 1257 for _, v := range fpaov.values.([]bool) { 1258 values = append(values, v) 1259 } 1260 } 1261 return 1262 } 1263 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 1264 res, ok := fpaov.values.([]*Name) 1265 return res, ok 1266 } 1267 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 1268 res, ok := fpaov.values.([]*meta.Meta) 1269 return res, ok 1270 } 1271 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsRoleArrayOfValues() ([]*role.Reference, bool) { 1272 res, ok := fpaov.values.([]*role.Reference) 1273 return res, ok 1274 } 1275 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsMemberArrayOfValues() ([]string, bool) { 1276 res, ok := fpaov.values.([]string) 1277 return res, ok 1278 } 1279 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsScopeParamsArrayOfValues() ([][]*role.ScopeParam, bool) { 1280 res, ok := fpaov.values.([][]*role.ScopeParam) 1281 return res, ok 1282 } 1283 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsExecutableConditionsArrayOfValues() ([][]*condition.ExecutableCondition, bool) { 1284 res, ok := fpaov.values.([][]*condition.ExecutableCondition) 1285 return res, ok 1286 } 1287 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsOwnedObjectsArrayOfValues() ([][]string, bool) { 1288 res, ok := fpaov.values.([][]string) 1289 return res, ok 1290 } 1291 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsMemberTypeArrayOfValues() ([]string, bool) { 1292 res, ok := fpaov.values.([]string) 1293 return res, ok 1294 } 1295 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsCategoryArrayOfValues() ([]role.Role_Category, bool) { 1296 res, ok := fpaov.values.([]role.Role_Category) 1297 return res, ok 1298 } 1299 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsAncestryPathArrayOfValues() ([][]*RoleBinding_Parent, bool) { 1300 res, ok := fpaov.values.([][]*RoleBinding_Parent) 1301 return res, ok 1302 } 1303 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsParentByOrgArrayOfValues() ([]*Reference, bool) { 1304 res, ok := fpaov.values.([]*Reference) 1305 return res, ok 1306 } 1307 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsSpecGenerationArrayOfValues() ([]int64, bool) { 1308 res, ok := fpaov.values.([]int64) 1309 return res, ok 1310 } 1311 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsHasOwnedObjectsArrayOfValues() ([]bool, bool) { 1312 res, ok := fpaov.values.([]bool) 1313 return res, ok 1314 } 1315 func (fpaov *RoleBinding_FieldTerminalPathArrayOfValues) AsDisableForChildScopesArrayOfValues() ([]bool, bool) { 1316 res, ok := fpaov.values.([]bool) 1317 return res, ok 1318 } 1319 1320 type RoleBinding_FieldSubPathArrayOfValues struct { 1321 RoleBinding_FieldPath 1322 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 1323 } 1324 1325 var _ RoleBinding_FieldPathArrayOfValues = (*RoleBinding_FieldSubPathArrayOfValues)(nil) 1326 1327 func (fpsaov *RoleBinding_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 1328 return fpsaov.subPathArrayOfValues.GetRawValues() 1329 } 1330 func (fpsaov *RoleBinding_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 1331 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 1332 return res, ok 1333 } 1334 func (fpsaov *RoleBinding_FieldSubPathArrayOfValues) AsScopeParamsPathArrayOfValues() (role.ScopeParam_FieldPathArrayOfValues, bool) { 1335 res, ok := fpsaov.subPathArrayOfValues.(role.ScopeParam_FieldPathArrayOfValues) 1336 return res, ok 1337 } 1338 func (fpsaov *RoleBinding_FieldSubPathArrayOfValues) AsExecutableConditionsPathArrayOfValues() (condition.ExecutableCondition_FieldPathArrayOfValues, bool) { 1339 res, ok := fpsaov.subPathArrayOfValues.(condition.ExecutableCondition_FieldPathArrayOfValues) 1340 return res, ok 1341 } 1342 func (fpsaov *RoleBinding_FieldSubPathArrayOfValues) AsAncestryPathPathArrayOfValues() (RoleBindingParent_FieldPathArrayOfValues, bool) { 1343 res, ok := fpsaov.subPathArrayOfValues.(RoleBindingParent_FieldPathArrayOfValues) 1344 return res, ok 1345 } 1346 1347 // FieldPath provides implementation to handle 1348 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 1349 type RoleBindingParent_FieldPath interface { 1350 gotenobject.FieldPath 1351 Selector() RoleBindingParent_FieldPathSelector 1352 Get(source *RoleBinding_Parent) []interface{} 1353 GetSingle(source *RoleBinding_Parent) (interface{}, bool) 1354 ClearValue(item *RoleBinding_Parent) 1355 1356 // Those methods build corresponding RoleBindingParent_FieldPathValue 1357 // (or array of values) and holds passed value. Panics if injected type is incorrect. 1358 WithIValue(value interface{}) RoleBindingParent_FieldPathValue 1359 WithIArrayOfValues(values interface{}) RoleBindingParent_FieldPathArrayOfValues 1360 WithIArrayItemValue(value interface{}) RoleBindingParent_FieldPathArrayItemValue 1361 } 1362 1363 type RoleBindingParent_FieldPathSelector int32 1364 1365 const ( 1366 RoleBindingParent_FieldPathSelectorParent RoleBindingParent_FieldPathSelector = 0 1367 RoleBindingParent_FieldPathSelectorMember RoleBindingParent_FieldPathSelector = 1 1368 ) 1369 1370 func (s RoleBindingParent_FieldPathSelector) String() string { 1371 switch s { 1372 case RoleBindingParent_FieldPathSelectorParent: 1373 return "parent" 1374 case RoleBindingParent_FieldPathSelectorMember: 1375 return "member" 1376 default: 1377 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", s)) 1378 } 1379 } 1380 1381 func BuildRoleBindingParent_FieldPath(fp gotenobject.RawFieldPath) (RoleBindingParent_FieldPath, error) { 1382 if len(fp) == 0 { 1383 return nil, status.Error(codes.InvalidArgument, "empty field path for object RoleBinding_Parent") 1384 } 1385 if len(fp) == 1 { 1386 switch fp[0] { 1387 case "parent": 1388 return &RoleBindingParent_FieldTerminalPath{selector: RoleBindingParent_FieldPathSelectorParent}, nil 1389 case "member": 1390 return &RoleBindingParent_FieldTerminalPath{selector: RoleBindingParent_FieldPathSelectorMember}, nil 1391 } 1392 } 1393 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object RoleBinding_Parent", fp) 1394 } 1395 1396 func ParseRoleBindingParent_FieldPath(rawField string) (RoleBindingParent_FieldPath, error) { 1397 fp, err := gotenobject.ParseRawFieldPath(rawField) 1398 if err != nil { 1399 return nil, err 1400 } 1401 return BuildRoleBindingParent_FieldPath(fp) 1402 } 1403 1404 func MustParseRoleBindingParent_FieldPath(rawField string) RoleBindingParent_FieldPath { 1405 fp, err := ParseRoleBindingParent_FieldPath(rawField) 1406 if err != nil { 1407 panic(err) 1408 } 1409 return fp 1410 } 1411 1412 type RoleBindingParent_FieldTerminalPath struct { 1413 selector RoleBindingParent_FieldPathSelector 1414 } 1415 1416 var _ RoleBindingParent_FieldPath = (*RoleBindingParent_FieldTerminalPath)(nil) 1417 1418 func (fp *RoleBindingParent_FieldTerminalPath) Selector() RoleBindingParent_FieldPathSelector { 1419 return fp.selector 1420 } 1421 1422 // String returns path representation in proto convention 1423 func (fp *RoleBindingParent_FieldTerminalPath) String() string { 1424 return fp.selector.String() 1425 } 1426 1427 // JSONString returns path representation is JSON convention 1428 func (fp *RoleBindingParent_FieldTerminalPath) JSONString() string { 1429 return strcase.ToLowerCamel(fp.String()) 1430 } 1431 1432 // Get returns all values pointed by specific field from source RoleBinding_Parent 1433 func (fp *RoleBindingParent_FieldTerminalPath) Get(source *RoleBinding_Parent) (values []interface{}) { 1434 if source != nil { 1435 switch fp.selector { 1436 case RoleBindingParent_FieldPathSelectorParent: 1437 if source.Parent != nil { 1438 values = append(values, source.Parent) 1439 } 1440 case RoleBindingParent_FieldPathSelectorMember: 1441 values = append(values, source.Member) 1442 default: 1443 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1444 } 1445 } 1446 return 1447 } 1448 1449 func (fp *RoleBindingParent_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 1450 return fp.Get(source.(*RoleBinding_Parent)) 1451 } 1452 1453 // GetSingle returns value pointed by specific field of from source RoleBinding_Parent 1454 func (fp *RoleBindingParent_FieldTerminalPath) GetSingle(source *RoleBinding_Parent) (interface{}, bool) { 1455 switch fp.selector { 1456 case RoleBindingParent_FieldPathSelectorParent: 1457 res := source.GetParent() 1458 return res, res != nil 1459 case RoleBindingParent_FieldPathSelectorMember: 1460 return source.GetMember(), source != nil 1461 default: 1462 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1463 } 1464 } 1465 1466 func (fp *RoleBindingParent_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 1467 return fp.GetSingle(source.(*RoleBinding_Parent)) 1468 } 1469 1470 // GetDefault returns a default value of the field type 1471 func (fp *RoleBindingParent_FieldTerminalPath) GetDefault() interface{} { 1472 switch fp.selector { 1473 case RoleBindingParent_FieldPathSelectorParent: 1474 return (*Reference)(nil) 1475 case RoleBindingParent_FieldPathSelectorMember: 1476 return "" 1477 default: 1478 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1479 } 1480 } 1481 1482 func (fp *RoleBindingParent_FieldTerminalPath) ClearValue(item *RoleBinding_Parent) { 1483 if item != nil { 1484 switch fp.selector { 1485 case RoleBindingParent_FieldPathSelectorParent: 1486 item.Parent = nil 1487 case RoleBindingParent_FieldPathSelectorMember: 1488 item.Member = "" 1489 default: 1490 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1491 } 1492 } 1493 } 1494 1495 func (fp *RoleBindingParent_FieldTerminalPath) ClearValueRaw(item proto.Message) { 1496 fp.ClearValue(item.(*RoleBinding_Parent)) 1497 } 1498 1499 // IsLeaf - whether field path is holds simple value 1500 func (fp *RoleBindingParent_FieldTerminalPath) IsLeaf() bool { 1501 return fp.selector == RoleBindingParent_FieldPathSelectorParent || 1502 fp.selector == RoleBindingParent_FieldPathSelectorMember 1503 } 1504 1505 func (fp *RoleBindingParent_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 1506 return []gotenobject.FieldPath{fp} 1507 } 1508 1509 func (fp *RoleBindingParent_FieldTerminalPath) WithIValue(value interface{}) RoleBindingParent_FieldPathValue { 1510 switch fp.selector { 1511 case RoleBindingParent_FieldPathSelectorParent: 1512 return &RoleBindingParent_FieldTerminalPathValue{RoleBindingParent_FieldTerminalPath: *fp, value: value.(*Reference)} 1513 case RoleBindingParent_FieldPathSelectorMember: 1514 return &RoleBindingParent_FieldTerminalPathValue{RoleBindingParent_FieldTerminalPath: *fp, value: value.(string)} 1515 default: 1516 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1517 } 1518 } 1519 1520 func (fp *RoleBindingParent_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 1521 return fp.WithIValue(value) 1522 } 1523 1524 func (fp *RoleBindingParent_FieldTerminalPath) WithIArrayOfValues(values interface{}) RoleBindingParent_FieldPathArrayOfValues { 1525 fpaov := &RoleBindingParent_FieldTerminalPathArrayOfValues{RoleBindingParent_FieldTerminalPath: *fp} 1526 switch fp.selector { 1527 case RoleBindingParent_FieldPathSelectorParent: 1528 return &RoleBindingParent_FieldTerminalPathArrayOfValues{RoleBindingParent_FieldTerminalPath: *fp, values: values.([]*Reference)} 1529 case RoleBindingParent_FieldPathSelectorMember: 1530 return &RoleBindingParent_FieldTerminalPathArrayOfValues{RoleBindingParent_FieldTerminalPath: *fp, values: values.([]string)} 1531 default: 1532 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1533 } 1534 return fpaov 1535 } 1536 1537 func (fp *RoleBindingParent_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 1538 return fp.WithIArrayOfValues(values) 1539 } 1540 1541 func (fp *RoleBindingParent_FieldTerminalPath) WithIArrayItemValue(value interface{}) RoleBindingParent_FieldPathArrayItemValue { 1542 switch fp.selector { 1543 default: 1544 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fp.selector)) 1545 } 1546 } 1547 1548 func (fp *RoleBindingParent_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 1549 return fp.WithIArrayItemValue(value) 1550 } 1551 1552 // RoleBindingParent_FieldPathValue allows storing values for Parent fields according to their type 1553 type RoleBindingParent_FieldPathValue interface { 1554 RoleBindingParent_FieldPath 1555 gotenobject.FieldPathValue 1556 SetTo(target **RoleBinding_Parent) 1557 CompareWith(*RoleBinding_Parent) (cmp int, comparable bool) 1558 } 1559 1560 func ParseRoleBindingParent_FieldPathValue(pathStr, valueStr string) (RoleBindingParent_FieldPathValue, error) { 1561 fp, err := ParseRoleBindingParent_FieldPath(pathStr) 1562 if err != nil { 1563 return nil, err 1564 } 1565 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 1566 if err != nil { 1567 return nil, status.Errorf(codes.InvalidArgument, "error parsing Parent field path value from %s: %v", valueStr, err) 1568 } 1569 return fpv.(RoleBindingParent_FieldPathValue), nil 1570 } 1571 1572 func MustParseRoleBindingParent_FieldPathValue(pathStr, valueStr string) RoleBindingParent_FieldPathValue { 1573 fpv, err := ParseRoleBindingParent_FieldPathValue(pathStr, valueStr) 1574 if err != nil { 1575 panic(err) 1576 } 1577 return fpv 1578 } 1579 1580 type RoleBindingParent_FieldTerminalPathValue struct { 1581 RoleBindingParent_FieldTerminalPath 1582 value interface{} 1583 } 1584 1585 var _ RoleBindingParent_FieldPathValue = (*RoleBindingParent_FieldTerminalPathValue)(nil) 1586 1587 // GetRawValue returns raw value stored under selected path for 'Parent' as interface{} 1588 func (fpv *RoleBindingParent_FieldTerminalPathValue) GetRawValue() interface{} { 1589 return fpv.value 1590 } 1591 func (fpv *RoleBindingParent_FieldTerminalPathValue) AsParentValue() (*Reference, bool) { 1592 res, ok := fpv.value.(*Reference) 1593 return res, ok 1594 } 1595 func (fpv *RoleBindingParent_FieldTerminalPathValue) AsMemberValue() (string, bool) { 1596 res, ok := fpv.value.(string) 1597 return res, ok 1598 } 1599 1600 // SetTo stores value for selected field for object Parent 1601 func (fpv *RoleBindingParent_FieldTerminalPathValue) SetTo(target **RoleBinding_Parent) { 1602 if *target == nil { 1603 *target = new(RoleBinding_Parent) 1604 } 1605 switch fpv.selector { 1606 case RoleBindingParent_FieldPathSelectorParent: 1607 (*target).Parent = fpv.value.(*Reference) 1608 case RoleBindingParent_FieldPathSelectorMember: 1609 (*target).Member = fpv.value.(string) 1610 default: 1611 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fpv.selector)) 1612 } 1613 } 1614 1615 func (fpv *RoleBindingParent_FieldTerminalPathValue) SetToRaw(target proto.Message) { 1616 typedObject := target.(*RoleBinding_Parent) 1617 fpv.SetTo(&typedObject) 1618 } 1619 1620 // CompareWith compares value in the 'RoleBindingParent_FieldTerminalPathValue' with the value under path in 'RoleBinding_Parent'. 1621 func (fpv *RoleBindingParent_FieldTerminalPathValue) CompareWith(source *RoleBinding_Parent) (int, bool) { 1622 switch fpv.selector { 1623 case RoleBindingParent_FieldPathSelectorParent: 1624 leftValue := fpv.value.(*Reference) 1625 rightValue := source.GetParent() 1626 if leftValue == nil { 1627 if rightValue != nil { 1628 return -1, true 1629 } 1630 return 0, true 1631 } 1632 if rightValue == nil { 1633 return 1, true 1634 } 1635 if leftValue.String() == rightValue.String() { 1636 return 0, true 1637 } else if leftValue.String() < rightValue.String() { 1638 return -1, true 1639 } else { 1640 return 1, true 1641 } 1642 case RoleBindingParent_FieldPathSelectorMember: 1643 leftValue := fpv.value.(string) 1644 rightValue := source.GetMember() 1645 if (leftValue) == (rightValue) { 1646 return 0, true 1647 } else if (leftValue) < (rightValue) { 1648 return -1, true 1649 } else { 1650 return 1, true 1651 } 1652 default: 1653 panic(fmt.Sprintf("Invalid selector for RoleBinding_Parent: %d", fpv.selector)) 1654 } 1655 } 1656 1657 func (fpv *RoleBindingParent_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 1658 return fpv.CompareWith(source.(*RoleBinding_Parent)) 1659 } 1660 1661 // RoleBindingParent_FieldPathArrayItemValue allows storing single item in Path-specific values for Parent according to their type 1662 // Present only for array (repeated) types. 1663 type RoleBindingParent_FieldPathArrayItemValue interface { 1664 gotenobject.FieldPathArrayItemValue 1665 RoleBindingParent_FieldPath 1666 ContainsValue(*RoleBinding_Parent) bool 1667 } 1668 1669 // ParseRoleBindingParent_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 1670 func ParseRoleBindingParent_FieldPathArrayItemValue(pathStr, valueStr string) (RoleBindingParent_FieldPathArrayItemValue, error) { 1671 fp, err := ParseRoleBindingParent_FieldPath(pathStr) 1672 if err != nil { 1673 return nil, err 1674 } 1675 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 1676 if err != nil { 1677 return nil, status.Errorf(codes.InvalidArgument, "error parsing Parent field path array item value from %s: %v", valueStr, err) 1678 } 1679 return fpaiv.(RoleBindingParent_FieldPathArrayItemValue), nil 1680 } 1681 1682 func MustParseRoleBindingParent_FieldPathArrayItemValue(pathStr, valueStr string) RoleBindingParent_FieldPathArrayItemValue { 1683 fpaiv, err := ParseRoleBindingParent_FieldPathArrayItemValue(pathStr, valueStr) 1684 if err != nil { 1685 panic(err) 1686 } 1687 return fpaiv 1688 } 1689 1690 type RoleBindingParent_FieldTerminalPathArrayItemValue struct { 1691 RoleBindingParent_FieldTerminalPath 1692 value interface{} 1693 } 1694 1695 var _ RoleBindingParent_FieldPathArrayItemValue = (*RoleBindingParent_FieldTerminalPathArrayItemValue)(nil) 1696 1697 // GetRawValue returns stored element value for array in object RoleBinding_Parent as interface{} 1698 func (fpaiv *RoleBindingParent_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 1699 return fpaiv.value 1700 } 1701 1702 func (fpaiv *RoleBindingParent_FieldTerminalPathArrayItemValue) GetSingle(source *RoleBinding_Parent) (interface{}, bool) { 1703 return nil, false 1704 } 1705 1706 func (fpaiv *RoleBindingParent_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 1707 return fpaiv.GetSingle(source.(*RoleBinding_Parent)) 1708 } 1709 1710 // Contains returns a boolean indicating if value that is being held is present in given 'Parent' 1711 func (fpaiv *RoleBindingParent_FieldTerminalPathArrayItemValue) ContainsValue(source *RoleBinding_Parent) bool { 1712 slice := fpaiv.RoleBindingParent_FieldTerminalPath.Get(source) 1713 for _, v := range slice { 1714 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 1715 if proto.Equal(asProtoMsg, v.(proto.Message)) { 1716 return true 1717 } 1718 } else if reflect.DeepEqual(v, fpaiv.value) { 1719 return true 1720 } 1721 } 1722 return false 1723 } 1724 1725 // RoleBindingParent_FieldPathArrayOfValues allows storing slice of values for Parent fields according to their type 1726 type RoleBindingParent_FieldPathArrayOfValues interface { 1727 gotenobject.FieldPathArrayOfValues 1728 RoleBindingParent_FieldPath 1729 } 1730 1731 func ParseRoleBindingParent_FieldPathArrayOfValues(pathStr, valuesStr string) (RoleBindingParent_FieldPathArrayOfValues, error) { 1732 fp, err := ParseRoleBindingParent_FieldPath(pathStr) 1733 if err != nil { 1734 return nil, err 1735 } 1736 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 1737 if err != nil { 1738 return nil, status.Errorf(codes.InvalidArgument, "error parsing Parent field path array of values from %s: %v", valuesStr, err) 1739 } 1740 return fpaov.(RoleBindingParent_FieldPathArrayOfValues), nil 1741 } 1742 1743 func MustParseRoleBindingParent_FieldPathArrayOfValues(pathStr, valuesStr string) RoleBindingParent_FieldPathArrayOfValues { 1744 fpaov, err := ParseRoleBindingParent_FieldPathArrayOfValues(pathStr, valuesStr) 1745 if err != nil { 1746 panic(err) 1747 } 1748 return fpaov 1749 } 1750 1751 type RoleBindingParent_FieldTerminalPathArrayOfValues struct { 1752 RoleBindingParent_FieldTerminalPath 1753 values interface{} 1754 } 1755 1756 var _ RoleBindingParent_FieldPathArrayOfValues = (*RoleBindingParent_FieldTerminalPathArrayOfValues)(nil) 1757 1758 func (fpaov *RoleBindingParent_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 1759 switch fpaov.selector { 1760 case RoleBindingParent_FieldPathSelectorParent: 1761 for _, v := range fpaov.values.([]*Reference) { 1762 values = append(values, v) 1763 } 1764 case RoleBindingParent_FieldPathSelectorMember: 1765 for _, v := range fpaov.values.([]string) { 1766 values = append(values, v) 1767 } 1768 } 1769 return 1770 } 1771 func (fpaov *RoleBindingParent_FieldTerminalPathArrayOfValues) AsParentArrayOfValues() ([]*Reference, bool) { 1772 res, ok := fpaov.values.([]*Reference) 1773 return res, ok 1774 } 1775 func (fpaov *RoleBindingParent_FieldTerminalPathArrayOfValues) AsMemberArrayOfValues() ([]string, bool) { 1776 res, ok := fpaov.values.([]string) 1777 return res, ok 1778 }