github.com/cloudwan/edgelq-sdk@v1.15.4/iam/resources/v1alpha2/invitation/invitation.pb.object_ext.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  	"fmt"
     9  	"sort"
    10  
    11  	"google.golang.org/protobuf/proto"
    12  	googlefieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
    13  
    14  	gotenobject "github.com/cloudwan/goten-sdk/runtime/object"
    15  )
    16  
    17  // proto imports
    18  import (
    19  	role "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/role"
    20  	service_account "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/service_account"
    21  	user "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/user"
    22  	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
    23  )
    24  
    25  // ensure the imports are used
    26  var (
    27  	_ = new(fmt.Stringer)
    28  	_ = new(sort.Interface)
    29  
    30  	_ = new(proto.Message)
    31  	_ = googlefieldmaskpb.FieldMask{}
    32  
    33  	_ = new(gotenobject.FieldPath)
    34  )
    35  
    36  // make sure we're using proto imports
    37  var (
    38  	_ = &role.Role{}
    39  	_ = &service_account.ServiceAccount{}
    40  	_ = &user.User{}
    41  	_ = &timestamppb.Timestamp{}
    42  )
    43  
    44  func (o *Actor) GotenObjectExt() {}
    45  
    46  func (o *Actor) MakeFullFieldMask() *Actor_FieldMask {
    47  	return FullActor_FieldMask()
    48  }
    49  
    50  func (o *Actor) MakeRawFullFieldMask() gotenobject.FieldMask {
    51  	return FullActor_FieldMask()
    52  }
    53  
    54  func (o *Actor) MakeDiffFieldMask(other *Actor) *Actor_FieldMask {
    55  	if o == nil && other == nil {
    56  		return &Actor_FieldMask{}
    57  	}
    58  	if o == nil || other == nil {
    59  		return FullActor_FieldMask()
    60  	}
    61  
    62  	res := &Actor_FieldMask{}
    63  	if o.GetUser().String() != other.GetUser().String() {
    64  		res.Paths = append(res.Paths, &Actor_FieldTerminalPath{selector: Actor_FieldPathSelectorUser})
    65  	}
    66  	if o.GetServiceAccount().String() != other.GetServiceAccount().String() {
    67  		res.Paths = append(res.Paths, &Actor_FieldTerminalPath{selector: Actor_FieldPathSelectorServiceAccount})
    68  	}
    69  	return res
    70  }
    71  
    72  func (o *Actor) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
    73  	return o.MakeDiffFieldMask(other.(*Actor))
    74  }
    75  
    76  func (o *Actor) Clone() *Actor {
    77  	if o == nil {
    78  		return nil
    79  	}
    80  	result := &Actor{}
    81  	if o.User == nil {
    82  		result.User = nil
    83  	} else if data, err := o.User.ProtoString(); err != nil {
    84  		panic(err)
    85  	} else {
    86  		result.User = &user.Reference{}
    87  		if err := result.User.ParseProtoString(data); err != nil {
    88  			panic(err)
    89  		}
    90  	}
    91  	if o.ServiceAccount == nil {
    92  		result.ServiceAccount = nil
    93  	} else if data, err := o.ServiceAccount.ProtoString(); err != nil {
    94  		panic(err)
    95  	} else {
    96  		result.ServiceAccount = &service_account.Reference{}
    97  		if err := result.ServiceAccount.ParseProtoString(data); err != nil {
    98  			panic(err)
    99  		}
   100  	}
   101  	return result
   102  }
   103  
   104  func (o *Actor) CloneRaw() gotenobject.GotenObjectExt {
   105  	return o.Clone()
   106  }
   107  
   108  func (o *Actor) Merge(source *Actor) {
   109  	if source.GetUser() != nil {
   110  		if data, err := source.GetUser().ProtoString(); err != nil {
   111  			panic(err)
   112  		} else {
   113  			o.User = &user.Reference{}
   114  			if err := o.User.ParseProtoString(data); err != nil {
   115  				panic(err)
   116  			}
   117  		}
   118  	} else {
   119  		o.User = nil
   120  	}
   121  	if source.GetServiceAccount() != nil {
   122  		if data, err := source.GetServiceAccount().ProtoString(); err != nil {
   123  			panic(err)
   124  		} else {
   125  			o.ServiceAccount = &service_account.Reference{}
   126  			if err := o.ServiceAccount.ParseProtoString(data); err != nil {
   127  				panic(err)
   128  			}
   129  		}
   130  	} else {
   131  		o.ServiceAccount = nil
   132  	}
   133  }
   134  
   135  func (o *Actor) MergeRaw(source gotenobject.GotenObjectExt) {
   136  	o.Merge(source.(*Actor))
   137  }
   138  
   139  func (o *Invitation) GotenObjectExt() {}
   140  
   141  func (o *Invitation) MakeFullFieldMask() *Invitation_FieldMask {
   142  	return FullInvitation_FieldMask()
   143  }
   144  
   145  func (o *Invitation) MakeRawFullFieldMask() gotenobject.FieldMask {
   146  	return FullInvitation_FieldMask()
   147  }
   148  
   149  func (o *Invitation) MakeDiffFieldMask(other *Invitation) *Invitation_FieldMask {
   150  	if o == nil && other == nil {
   151  		return &Invitation_FieldMask{}
   152  	}
   153  	if o == nil || other == nil {
   154  		return FullInvitation_FieldMask()
   155  	}
   156  
   157  	res := &Invitation_FieldMask{}
   158  	if o.GetInviteeEmail() != other.GetInviteeEmail() {
   159  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviteeEmail})
   160  	}
   161  	{
   162  		subMask := o.GetInviterActor().MakeDiffFieldMask(other.GetInviterActor())
   163  		if subMask.IsFull() {
   164  			res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviterActor})
   165  		} else {
   166  			for _, subpath := range subMask.Paths {
   167  				res.Paths = append(res.Paths, &Invitation_FieldSubPath{selector: Invitation_FieldPathSelectorInviterActor, subPath: subpath})
   168  			}
   169  		}
   170  	}
   171  	if o.GetInviterFullName() != other.GetInviterFullName() {
   172  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviterFullName})
   173  	}
   174  	if o.GetInviterEmail() != other.GetInviterEmail() {
   175  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviterEmail})
   176  	}
   177  	if o.GetLanguageCode() != other.GetLanguageCode() {
   178  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorLanguageCode})
   179  	}
   180  
   181  	if len(o.GetRoles()) == len(other.GetRoles()) {
   182  		for i, lValue := range o.GetRoles() {
   183  			rValue := other.GetRoles()[i]
   184  			if lValue.String() != rValue.String() {
   185  				res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorRoles})
   186  				break
   187  			}
   188  		}
   189  	} else {
   190  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorRoles})
   191  	}
   192  	if !proto.Equal(o.GetExpirationDate(), other.GetExpirationDate()) {
   193  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorExpirationDate})
   194  	}
   195  
   196  	if len(o.GetExtras()) == len(other.GetExtras()) {
   197  		for i, lValue := range o.GetExtras() {
   198  			rValue := other.GetExtras()[i]
   199  			if lValue != rValue {
   200  				res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorExtras})
   201  				break
   202  			}
   203  		}
   204  	} else {
   205  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorExtras})
   206  	}
   207  	if o.GetState() != other.GetState() {
   208  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorState})
   209  	}
   210  	return res
   211  }
   212  
   213  func (o *Invitation) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   214  	return o.MakeDiffFieldMask(other.(*Invitation))
   215  }
   216  
   217  func (o *Invitation) Clone() *Invitation {
   218  	if o == nil {
   219  		return nil
   220  	}
   221  	result := &Invitation{}
   222  	result.InviteeEmail = o.InviteeEmail
   223  	result.InviterActor = o.InviterActor.Clone()
   224  	result.InviterFullName = o.InviterFullName
   225  	result.InviterEmail = o.InviterEmail
   226  	result.LanguageCode = o.LanguageCode
   227  	result.Roles = make([]*role.Reference, len(o.Roles))
   228  	for i, sourceValue := range o.Roles {
   229  		if sourceValue == nil {
   230  			result.Roles[i] = nil
   231  		} else if data, err := sourceValue.ProtoString(); err != nil {
   232  			panic(err)
   233  		} else {
   234  			result.Roles[i] = &role.Reference{}
   235  			if err := result.Roles[i].ParseProtoString(data); err != nil {
   236  				panic(err)
   237  			}
   238  		}
   239  	}
   240  	result.ExpirationDate = proto.Clone(o.ExpirationDate).(*timestamppb.Timestamp)
   241  	result.Extras = map[string]string{}
   242  	for key, sourceValue := range o.Extras {
   243  		result.Extras[key] = sourceValue
   244  	}
   245  	result.State = o.State
   246  	return result
   247  }
   248  
   249  func (o *Invitation) CloneRaw() gotenobject.GotenObjectExt {
   250  	return o.Clone()
   251  }
   252  
   253  func (o *Invitation) Merge(source *Invitation) {
   254  	o.InviteeEmail = source.GetInviteeEmail()
   255  	if source.GetInviterActor() != nil {
   256  		if o.InviterActor == nil {
   257  			o.InviterActor = new(Actor)
   258  		}
   259  		o.InviterActor.Merge(source.GetInviterActor())
   260  	}
   261  	o.InviterFullName = source.GetInviterFullName()
   262  	o.InviterEmail = source.GetInviterEmail()
   263  	o.LanguageCode = source.GetLanguageCode()
   264  	for _, sourceValue := range source.GetRoles() {
   265  		exists := false
   266  		for _, currentValue := range o.Roles {
   267  			leftProtoStr, _ := currentValue.ProtoString()
   268  			rightProtoStr, _ := sourceValue.ProtoString()
   269  			if leftProtoStr == rightProtoStr {
   270  				exists = true
   271  				break
   272  			}
   273  		}
   274  		if !exists {
   275  			var newDstElement *role.Reference
   276  			if sourceValue != nil {
   277  				if data, err := sourceValue.ProtoString(); err != nil {
   278  					panic(err)
   279  				} else {
   280  					newDstElement = &role.Reference{}
   281  					if err := newDstElement.ParseProtoString(data); err != nil {
   282  						panic(err)
   283  					}
   284  				}
   285  			}
   286  			o.Roles = append(o.Roles, newDstElement)
   287  		}
   288  	}
   289  
   290  	if source.GetExpirationDate() != nil {
   291  		if o.ExpirationDate == nil {
   292  			o.ExpirationDate = new(timestamppb.Timestamp)
   293  		}
   294  		proto.Merge(o.ExpirationDate, source.GetExpirationDate())
   295  	}
   296  	if source.GetExtras() != nil {
   297  		if o.Extras == nil {
   298  			o.Extras = make(map[string]string, len(source.GetExtras()))
   299  		}
   300  		for key, sourceValue := range source.GetExtras() {
   301  			o.Extras[key] = sourceValue
   302  		}
   303  	}
   304  	o.State = source.GetState()
   305  }
   306  
   307  func (o *Invitation) MergeRaw(source gotenobject.GotenObjectExt) {
   308  	o.Merge(source.(*Invitation))
   309  }