github.com/cloudwan/edgelq-sdk@v1.15.4/iam/resources/v1alpha2/invitation/invitation.pb.fieldmask.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/iam/proto/v1alpha2/invitation.proto 3 // DO NOT EDIT!!! 4 5 package iam_invitation 6 7 import ( 8 "encoding/json" 9 "strings" 10 11 "google.golang.org/grpc/codes" 12 "google.golang.org/grpc/status" 13 "google.golang.org/protobuf/proto" 14 preflect "google.golang.org/protobuf/reflect/protoreflect" 15 googlefieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" 16 17 gotenobject "github.com/cloudwan/goten-sdk/runtime/object" 18 ) 19 20 // proto imports 21 import ( 22 role "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/role" 23 service_account "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/service_account" 24 user "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/user" 25 timestamppb "google.golang.org/protobuf/types/known/timestamppb" 26 ) 27 28 // ensure the imports are used 29 var ( 30 _ = new(json.Marshaler) 31 _ = strings.Builder{} 32 33 _ = codes.NotFound 34 _ = status.Status{} 35 _ = new(proto.Message) 36 _ = new(preflect.Message) 37 _ = googlefieldmaskpb.FieldMask{} 38 39 _ = new(gotenobject.FieldMask) 40 ) 41 42 // make sure we're using proto imports 43 var ( 44 _ = &role.Role{} 45 _ = &service_account.ServiceAccount{} 46 _ = &user.User{} 47 _ = ×tamppb.Timestamp{} 48 ) 49 50 type Actor_FieldMask struct { 51 Paths []Actor_FieldPath 52 } 53 54 func FullActor_FieldMask() *Actor_FieldMask { 55 res := &Actor_FieldMask{} 56 res.Paths = append(res.Paths, &Actor_FieldTerminalPath{selector: Actor_FieldPathSelectorUser}) 57 res.Paths = append(res.Paths, &Actor_FieldTerminalPath{selector: Actor_FieldPathSelectorServiceAccount}) 58 return res 59 } 60 61 func (fieldMask *Actor_FieldMask) String() string { 62 if fieldMask == nil { 63 return "<nil>" 64 } 65 pathsStr := make([]string, 0, len(fieldMask.Paths)) 66 for _, path := range fieldMask.Paths { 67 pathsStr = append(pathsStr, path.String()) 68 } 69 return strings.Join(pathsStr, ", ") 70 } 71 72 func (fieldMask *Actor_FieldMask) IsFull() bool { 73 if fieldMask == nil { 74 return false 75 } 76 presentSelectors := make([]bool, 2) 77 for _, path := range fieldMask.Paths { 78 if asFinal, ok := path.(*Actor_FieldTerminalPath); ok { 79 presentSelectors[int(asFinal.selector)] = true 80 } 81 } 82 for _, flag := range presentSelectors { 83 if !flag { 84 return false 85 } 86 } 87 return true 88 } 89 90 func (fieldMask *Actor_FieldMask) ProtoReflect() preflect.Message { 91 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 92 return ParseActor_FieldPath(raw) 93 }) 94 } 95 96 func (fieldMask *Actor_FieldMask) ProtoMessage() {} 97 98 func (fieldMask *Actor_FieldMask) Reset() { 99 if fieldMask != nil { 100 fieldMask.Paths = nil 101 } 102 } 103 104 func (fieldMask *Actor_FieldMask) Subtract(other *Actor_FieldMask) *Actor_FieldMask { 105 result := &Actor_FieldMask{} 106 removedSelectors := make([]bool, 2) 107 108 for _, path := range other.GetPaths() { 109 switch tp := path.(type) { 110 case *Actor_FieldTerminalPath: 111 removedSelectors[int(tp.selector)] = true 112 } 113 } 114 for _, path := range fieldMask.GetPaths() { 115 if !removedSelectors[int(path.Selector())] { 116 result.Paths = append(result.Paths, path) 117 } 118 } 119 120 if len(result.Paths) == 0 { 121 return nil 122 } 123 return result 124 } 125 126 func (fieldMask *Actor_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 127 return fieldMask.Subtract(other.(*Actor_FieldMask)) 128 } 129 130 // FilterInputFields generates copy of field paths with output_only field paths removed 131 func (fieldMask *Actor_FieldMask) FilterInputFields() *Actor_FieldMask { 132 result := &Actor_FieldMask{} 133 result.Paths = append(result.Paths, fieldMask.Paths...) 134 return result 135 } 136 137 // ToFieldMask is used for proto conversions 138 func (fieldMask *Actor_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 139 protoFieldMask := &googlefieldmaskpb.FieldMask{} 140 for _, path := range fieldMask.Paths { 141 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 142 } 143 return protoFieldMask 144 } 145 146 func (fieldMask *Actor_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 147 if fieldMask == nil { 148 return status.Error(codes.Internal, "target field mask is nil") 149 } 150 fieldMask.Paths = make([]Actor_FieldPath, 0, len(protoFieldMask.Paths)) 151 for _, strPath := range protoFieldMask.Paths { 152 path, err := ParseActor_FieldPath(strPath) 153 if err != nil { 154 return err 155 } 156 fieldMask.Paths = append(fieldMask.Paths, path) 157 } 158 return nil 159 } 160 161 // implement methods required by customType 162 func (fieldMask Actor_FieldMask) Marshal() ([]byte, error) { 163 protoFieldMask := fieldMask.ToProtoFieldMask() 164 return proto.Marshal(protoFieldMask) 165 } 166 167 func (fieldMask *Actor_FieldMask) Unmarshal(data []byte) error { 168 protoFieldMask := &googlefieldmaskpb.FieldMask{} 169 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 170 return err 171 } 172 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 173 return err 174 } 175 return nil 176 } 177 178 func (fieldMask *Actor_FieldMask) Size() int { 179 return proto.Size(fieldMask.ToProtoFieldMask()) 180 } 181 182 func (fieldMask Actor_FieldMask) MarshalJSON() ([]byte, error) { 183 return json.Marshal(fieldMask.ToProtoFieldMask()) 184 } 185 186 func (fieldMask *Actor_FieldMask) UnmarshalJSON(data []byte) error { 187 protoFieldMask := &googlefieldmaskpb.FieldMask{} 188 if err := json.Unmarshal(data, protoFieldMask); err != nil { 189 return err 190 } 191 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 192 return err 193 } 194 return nil 195 } 196 197 func (fieldMask *Actor_FieldMask) AppendPath(path Actor_FieldPath) { 198 fieldMask.Paths = append(fieldMask.Paths, path) 199 } 200 201 func (fieldMask *Actor_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 202 fieldMask.Paths = append(fieldMask.Paths, path.(Actor_FieldPath)) 203 } 204 205 func (fieldMask *Actor_FieldMask) GetPaths() []Actor_FieldPath { 206 if fieldMask == nil { 207 return nil 208 } 209 return fieldMask.Paths 210 } 211 212 func (fieldMask *Actor_FieldMask) GetRawPaths() []gotenobject.FieldPath { 213 if fieldMask == nil { 214 return nil 215 } 216 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 217 for _, path := range fieldMask.Paths { 218 rawPaths = append(rawPaths, path) 219 } 220 return rawPaths 221 } 222 223 func (fieldMask *Actor_FieldMask) SetFromCliFlag(raw string) error { 224 path, err := ParseActor_FieldPath(raw) 225 if err != nil { 226 return err 227 } 228 fieldMask.Paths = append(fieldMask.Paths, path) 229 return nil 230 } 231 232 func (fieldMask *Actor_FieldMask) Set(target, source *Actor) { 233 for _, path := range fieldMask.Paths { 234 val, _ := path.GetSingle(source) 235 // if val is nil, then field does not exist in source, skip 236 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 237 if val != nil { 238 path.WithIValue(val).SetTo(&target) 239 } 240 } 241 } 242 243 func (fieldMask *Actor_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 244 fieldMask.Set(target.(*Actor), source.(*Actor)) 245 } 246 247 func (fieldMask *Actor_FieldMask) Project(source *Actor) *Actor { 248 if source == nil { 249 return nil 250 } 251 if fieldMask == nil { 252 return source 253 } 254 result := &Actor{} 255 256 for _, p := range fieldMask.Paths { 257 switch tp := p.(type) { 258 case *Actor_FieldTerminalPath: 259 switch tp.selector { 260 case Actor_FieldPathSelectorUser: 261 result.User = source.User 262 case Actor_FieldPathSelectorServiceAccount: 263 result.ServiceAccount = source.ServiceAccount 264 } 265 } 266 } 267 return result 268 } 269 270 func (fieldMask *Actor_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 271 return fieldMask.Project(source.(*Actor)) 272 } 273 274 func (fieldMask *Actor_FieldMask) PathsCount() int { 275 if fieldMask == nil { 276 return 0 277 } 278 return len(fieldMask.Paths) 279 } 280 281 type Invitation_FieldMask struct { 282 Paths []Invitation_FieldPath 283 } 284 285 func FullInvitation_FieldMask() *Invitation_FieldMask { 286 res := &Invitation_FieldMask{} 287 res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviteeEmail}) 288 res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviterActor}) 289 res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviterFullName}) 290 res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviterEmail}) 291 res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorLanguageCode}) 292 res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorRoles}) 293 res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorExpirationDate}) 294 res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorExtras}) 295 res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorState}) 296 return res 297 } 298 299 func (fieldMask *Invitation_FieldMask) String() string { 300 if fieldMask == nil { 301 return "<nil>" 302 } 303 pathsStr := make([]string, 0, len(fieldMask.Paths)) 304 for _, path := range fieldMask.Paths { 305 pathsStr = append(pathsStr, path.String()) 306 } 307 return strings.Join(pathsStr, ", ") 308 } 309 310 func (fieldMask *Invitation_FieldMask) IsFull() bool { 311 if fieldMask == nil { 312 return false 313 } 314 presentSelectors := make([]bool, 9) 315 for _, path := range fieldMask.Paths { 316 if asFinal, ok := path.(*Invitation_FieldTerminalPath); ok { 317 presentSelectors[int(asFinal.selector)] = true 318 } 319 } 320 for _, flag := range presentSelectors { 321 if !flag { 322 return false 323 } 324 } 325 return true 326 } 327 328 func (fieldMask *Invitation_FieldMask) ProtoReflect() preflect.Message { 329 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 330 return ParseInvitation_FieldPath(raw) 331 }) 332 } 333 334 func (fieldMask *Invitation_FieldMask) ProtoMessage() {} 335 336 func (fieldMask *Invitation_FieldMask) Reset() { 337 if fieldMask != nil { 338 fieldMask.Paths = nil 339 } 340 } 341 342 func (fieldMask *Invitation_FieldMask) Subtract(other *Invitation_FieldMask) *Invitation_FieldMask { 343 result := &Invitation_FieldMask{} 344 removedSelectors := make([]bool, 9) 345 otherSubMasks := map[Invitation_FieldPathSelector]gotenobject.FieldMask{ 346 Invitation_FieldPathSelectorInviterActor: &Actor_FieldMask{}, 347 } 348 mySubMasks := map[Invitation_FieldPathSelector]gotenobject.FieldMask{ 349 Invitation_FieldPathSelectorInviterActor: &Actor_FieldMask{}, 350 } 351 352 for _, path := range other.GetPaths() { 353 switch tp := path.(type) { 354 case *Invitation_FieldTerminalPath: 355 removedSelectors[int(tp.selector)] = true 356 case *Invitation_FieldSubPath: 357 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 358 } 359 } 360 for _, path := range fieldMask.GetPaths() { 361 if !removedSelectors[int(path.Selector())] { 362 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 363 if tp, ok := path.(*Invitation_FieldTerminalPath); ok { 364 switch tp.selector { 365 case Invitation_FieldPathSelectorInviterActor: 366 mySubMasks[Invitation_FieldPathSelectorInviterActor] = FullActor_FieldMask() 367 } 368 } else if tp, ok := path.(*Invitation_FieldSubPath); ok { 369 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 370 } 371 } else { 372 result.Paths = append(result.Paths, path) 373 } 374 } 375 } 376 for selector, mySubMask := range mySubMasks { 377 if mySubMask.PathsCount() > 0 { 378 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 379 result.Paths = append(result.Paths, &Invitation_FieldSubPath{selector: selector, subPath: allowedPath}) 380 } 381 } 382 } 383 384 if len(result.Paths) == 0 { 385 return nil 386 } 387 return result 388 } 389 390 func (fieldMask *Invitation_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 391 return fieldMask.Subtract(other.(*Invitation_FieldMask)) 392 } 393 394 // FilterInputFields generates copy of field paths with output_only field paths removed 395 func (fieldMask *Invitation_FieldMask) FilterInputFields() *Invitation_FieldMask { 396 result := &Invitation_FieldMask{} 397 result.Paths = append(result.Paths, fieldMask.Paths...) 398 return result 399 } 400 401 // ToFieldMask is used for proto conversions 402 func (fieldMask *Invitation_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 403 protoFieldMask := &googlefieldmaskpb.FieldMask{} 404 for _, path := range fieldMask.Paths { 405 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 406 } 407 return protoFieldMask 408 } 409 410 func (fieldMask *Invitation_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 411 if fieldMask == nil { 412 return status.Error(codes.Internal, "target field mask is nil") 413 } 414 fieldMask.Paths = make([]Invitation_FieldPath, 0, len(protoFieldMask.Paths)) 415 for _, strPath := range protoFieldMask.Paths { 416 path, err := ParseInvitation_FieldPath(strPath) 417 if err != nil { 418 return err 419 } 420 fieldMask.Paths = append(fieldMask.Paths, path) 421 } 422 return nil 423 } 424 425 // implement methods required by customType 426 func (fieldMask Invitation_FieldMask) Marshal() ([]byte, error) { 427 protoFieldMask := fieldMask.ToProtoFieldMask() 428 return proto.Marshal(protoFieldMask) 429 } 430 431 func (fieldMask *Invitation_FieldMask) Unmarshal(data []byte) error { 432 protoFieldMask := &googlefieldmaskpb.FieldMask{} 433 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 434 return err 435 } 436 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 437 return err 438 } 439 return nil 440 } 441 442 func (fieldMask *Invitation_FieldMask) Size() int { 443 return proto.Size(fieldMask.ToProtoFieldMask()) 444 } 445 446 func (fieldMask Invitation_FieldMask) MarshalJSON() ([]byte, error) { 447 return json.Marshal(fieldMask.ToProtoFieldMask()) 448 } 449 450 func (fieldMask *Invitation_FieldMask) UnmarshalJSON(data []byte) error { 451 protoFieldMask := &googlefieldmaskpb.FieldMask{} 452 if err := json.Unmarshal(data, protoFieldMask); err != nil { 453 return err 454 } 455 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 456 return err 457 } 458 return nil 459 } 460 461 func (fieldMask *Invitation_FieldMask) AppendPath(path Invitation_FieldPath) { 462 fieldMask.Paths = append(fieldMask.Paths, path) 463 } 464 465 func (fieldMask *Invitation_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 466 fieldMask.Paths = append(fieldMask.Paths, path.(Invitation_FieldPath)) 467 } 468 469 func (fieldMask *Invitation_FieldMask) GetPaths() []Invitation_FieldPath { 470 if fieldMask == nil { 471 return nil 472 } 473 return fieldMask.Paths 474 } 475 476 func (fieldMask *Invitation_FieldMask) GetRawPaths() []gotenobject.FieldPath { 477 if fieldMask == nil { 478 return nil 479 } 480 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 481 for _, path := range fieldMask.Paths { 482 rawPaths = append(rawPaths, path) 483 } 484 return rawPaths 485 } 486 487 func (fieldMask *Invitation_FieldMask) SetFromCliFlag(raw string) error { 488 path, err := ParseInvitation_FieldPath(raw) 489 if err != nil { 490 return err 491 } 492 fieldMask.Paths = append(fieldMask.Paths, path) 493 return nil 494 } 495 496 func (fieldMask *Invitation_FieldMask) Set(target, source *Invitation) { 497 for _, path := range fieldMask.Paths { 498 val, _ := path.GetSingle(source) 499 // if val is nil, then field does not exist in source, skip 500 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 501 if val != nil { 502 path.WithIValue(val).SetTo(&target) 503 } 504 } 505 } 506 507 func (fieldMask *Invitation_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 508 fieldMask.Set(target.(*Invitation), source.(*Invitation)) 509 } 510 511 func (fieldMask *Invitation_FieldMask) Project(source *Invitation) *Invitation { 512 if source == nil { 513 return nil 514 } 515 if fieldMask == nil { 516 return source 517 } 518 result := &Invitation{} 519 inviterActorMask := &Actor_FieldMask{} 520 wholeInviterActorAccepted := false 521 var extrasMapKeys []string 522 wholeExtrasAccepted := false 523 524 for _, p := range fieldMask.Paths { 525 switch tp := p.(type) { 526 case *Invitation_FieldTerminalPath: 527 switch tp.selector { 528 case Invitation_FieldPathSelectorInviteeEmail: 529 result.InviteeEmail = source.InviteeEmail 530 case Invitation_FieldPathSelectorInviterActor: 531 result.InviterActor = source.InviterActor 532 wholeInviterActorAccepted = true 533 case Invitation_FieldPathSelectorInviterFullName: 534 result.InviterFullName = source.InviterFullName 535 case Invitation_FieldPathSelectorInviterEmail: 536 result.InviterEmail = source.InviterEmail 537 case Invitation_FieldPathSelectorLanguageCode: 538 result.LanguageCode = source.LanguageCode 539 case Invitation_FieldPathSelectorRoles: 540 result.Roles = source.Roles 541 case Invitation_FieldPathSelectorExpirationDate: 542 result.ExpirationDate = source.ExpirationDate 543 case Invitation_FieldPathSelectorExtras: 544 result.Extras = source.Extras 545 wholeExtrasAccepted = true 546 case Invitation_FieldPathSelectorState: 547 result.State = source.State 548 } 549 case *Invitation_FieldSubPath: 550 switch tp.selector { 551 case Invitation_FieldPathSelectorInviterActor: 552 inviterActorMask.AppendPath(tp.subPath.(Actor_FieldPath)) 553 } 554 case *Invitation_FieldPathMap: 555 switch tp.selector { 556 case Invitation_FieldPathSelectorExtras: 557 extrasMapKeys = append(extrasMapKeys, tp.key) 558 } 559 } 560 } 561 if wholeInviterActorAccepted == false && len(inviterActorMask.Paths) > 0 { 562 result.InviterActor = inviterActorMask.Project(source.GetInviterActor()) 563 } 564 if wholeExtrasAccepted == false && len(extrasMapKeys) > 0 && source.GetExtras() != nil { 565 copiedMap := map[string]string{} 566 sourceMap := source.GetExtras() 567 for _, key := range extrasMapKeys { 568 copiedMap[key] = sourceMap[key] 569 } 570 result.Extras = copiedMap 571 } 572 return result 573 } 574 575 func (fieldMask *Invitation_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 576 return fieldMask.Project(source.(*Invitation)) 577 } 578 579 func (fieldMask *Invitation_FieldMask) PathsCount() int { 580 if fieldMask == nil { 581 return 0 582 } 583 return len(fieldMask.Paths) 584 }