github.com/cloudwan/edgelq-sdk@v1.15.4/iam/resources/v1/invitation/invitation.pb.object_ext.go (about)

     1  // Code generated by protoc-gen-goten-object
     2  // File: edgelq/iam/proto/v1/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  	condition "github.com/cloudwan/edgelq-sdk/iam/resources/v1/condition"
    20  	group "github.com/cloudwan/edgelq-sdk/iam/resources/v1/group"
    21  	role "github.com/cloudwan/edgelq-sdk/iam/resources/v1/role"
    22  	service_account "github.com/cloudwan/edgelq-sdk/iam/resources/v1/service_account"
    23  	user "github.com/cloudwan/edgelq-sdk/iam/resources/v1/user"
    24  	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
    25  )
    26  
    27  // ensure the imports are used
    28  var (
    29  	_ = new(fmt.Stringer)
    30  	_ = new(sort.Interface)
    31  
    32  	_ = new(proto.Message)
    33  	_ = googlefieldmaskpb.FieldMask{}
    34  
    35  	_ = new(gotenobject.FieldPath)
    36  )
    37  
    38  // make sure we're using proto imports
    39  var (
    40  	_ = &condition.Condition{}
    41  	_ = &group.Group{}
    42  	_ = &role.Role{}
    43  	_ = &service_account.ServiceAccount{}
    44  	_ = &user.User{}
    45  	_ = &timestamppb.Timestamp{}
    46  )
    47  
    48  func (o *Actor) GotenObjectExt() {}
    49  
    50  func (o *Actor) MakeFullFieldMask() *Actor_FieldMask {
    51  	return FullActor_FieldMask()
    52  }
    53  
    54  func (o *Actor) MakeRawFullFieldMask() gotenobject.FieldMask {
    55  	return FullActor_FieldMask()
    56  }
    57  
    58  func (o *Actor) MakeDiffFieldMask(other *Actor) *Actor_FieldMask {
    59  	if o == nil && other == nil {
    60  		return &Actor_FieldMask{}
    61  	}
    62  	if o == nil || other == nil {
    63  		return FullActor_FieldMask()
    64  	}
    65  
    66  	res := &Actor_FieldMask{}
    67  	if o.GetUser().String() != other.GetUser().String() {
    68  		res.Paths = append(res.Paths, &Actor_FieldTerminalPath{selector: Actor_FieldPathSelectorUser})
    69  	}
    70  	if o.GetServiceAccount().String() != other.GetServiceAccount().String() {
    71  		res.Paths = append(res.Paths, &Actor_FieldTerminalPath{selector: Actor_FieldPathSelectorServiceAccount})
    72  	}
    73  	return res
    74  }
    75  
    76  func (o *Actor) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
    77  	return o.MakeDiffFieldMask(other.(*Actor))
    78  }
    79  
    80  func (o *Actor) Clone() *Actor {
    81  	if o == nil {
    82  		return nil
    83  	}
    84  	result := &Actor{}
    85  	if o.User == nil {
    86  		result.User = nil
    87  	} else if data, err := o.User.ProtoString(); err != nil {
    88  		panic(err)
    89  	} else {
    90  		result.User = &user.Reference{}
    91  		if err := result.User.ParseProtoString(data); err != nil {
    92  			panic(err)
    93  		}
    94  	}
    95  	if o.ServiceAccount == nil {
    96  		result.ServiceAccount = nil
    97  	} else if data, err := o.ServiceAccount.ProtoString(); err != nil {
    98  		panic(err)
    99  	} else {
   100  		result.ServiceAccount = &service_account.Reference{}
   101  		if err := result.ServiceAccount.ParseProtoString(data); err != nil {
   102  			panic(err)
   103  		}
   104  	}
   105  	return result
   106  }
   107  
   108  func (o *Actor) CloneRaw() gotenobject.GotenObjectExt {
   109  	return o.Clone()
   110  }
   111  
   112  func (o *Actor) Merge(source *Actor) {
   113  	if source.GetUser() != nil {
   114  		if data, err := source.GetUser().ProtoString(); err != nil {
   115  			panic(err)
   116  		} else {
   117  			o.User = &user.Reference{}
   118  			if err := o.User.ParseProtoString(data); err != nil {
   119  				panic(err)
   120  			}
   121  		}
   122  	} else {
   123  		o.User = nil
   124  	}
   125  	if source.GetServiceAccount() != nil {
   126  		if data, err := source.GetServiceAccount().ProtoString(); err != nil {
   127  			panic(err)
   128  		} else {
   129  			o.ServiceAccount = &service_account.Reference{}
   130  			if err := o.ServiceAccount.ParseProtoString(data); err != nil {
   131  				panic(err)
   132  			}
   133  		}
   134  	} else {
   135  		o.ServiceAccount = nil
   136  	}
   137  }
   138  
   139  func (o *Actor) MergeRaw(source gotenobject.GotenObjectExt) {
   140  	o.Merge(source.(*Actor))
   141  }
   142  
   143  func (o *Invitation) GotenObjectExt() {}
   144  
   145  func (o *Invitation) MakeFullFieldMask() *Invitation_FieldMask {
   146  	return FullInvitation_FieldMask()
   147  }
   148  
   149  func (o *Invitation) MakeRawFullFieldMask() gotenobject.FieldMask {
   150  	return FullInvitation_FieldMask()
   151  }
   152  
   153  func (o *Invitation) MakeDiffFieldMask(other *Invitation) *Invitation_FieldMask {
   154  	if o == nil && other == nil {
   155  		return &Invitation_FieldMask{}
   156  	}
   157  	if o == nil || other == nil {
   158  		return FullInvitation_FieldMask()
   159  	}
   160  
   161  	res := &Invitation_FieldMask{}
   162  	if o.GetInviteeEmail() != other.GetInviteeEmail() {
   163  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviteeEmail})
   164  	}
   165  	{
   166  		subMask := o.GetInviterActor().MakeDiffFieldMask(other.GetInviterActor())
   167  		if subMask.IsFull() {
   168  			res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviterActor})
   169  		} else {
   170  			for _, subpath := range subMask.Paths {
   171  				res.Paths = append(res.Paths, &Invitation_FieldSubPath{selector: Invitation_FieldPathSelectorInviterActor, subPath: subpath})
   172  			}
   173  		}
   174  	}
   175  	if o.GetInviterFullName() != other.GetInviterFullName() {
   176  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviterFullName})
   177  	}
   178  	if o.GetInviterEmail() != other.GetInviterEmail() {
   179  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorInviterEmail})
   180  	}
   181  	if o.GetLanguageCode() != other.GetLanguageCode() {
   182  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorLanguageCode})
   183  	}
   184  
   185  	if len(o.GetBindingRoles()) == len(other.GetBindingRoles()) {
   186  		for i, lValue := range o.GetBindingRoles() {
   187  			rValue := other.GetBindingRoles()[i]
   188  			if len(lValue.MakeDiffFieldMask(rValue).Paths) > 0 {
   189  				res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorBindingRoles})
   190  				break
   191  			}
   192  		}
   193  	} else {
   194  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorBindingRoles})
   195  	}
   196  
   197  	if len(o.GetGroups()) == len(other.GetGroups()) {
   198  		for i, lValue := range o.GetGroups() {
   199  			rValue := other.GetGroups()[i]
   200  			if lValue.String() != rValue.String() {
   201  				res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorGroups})
   202  				break
   203  			}
   204  		}
   205  	} else {
   206  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorGroups})
   207  	}
   208  	if !proto.Equal(o.GetExpirationDate(), other.GetExpirationDate()) {
   209  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorExpirationDate})
   210  	}
   211  
   212  	if len(o.GetExtras()) == len(other.GetExtras()) {
   213  		for i, lValue := range o.GetExtras() {
   214  			rValue := other.GetExtras()[i]
   215  			if lValue != rValue {
   216  				res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorExtras})
   217  				break
   218  			}
   219  		}
   220  	} else {
   221  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorExtras})
   222  	}
   223  	if o.GetState() != other.GetState() {
   224  		res.Paths = append(res.Paths, &Invitation_FieldTerminalPath{selector: Invitation_FieldPathSelectorState})
   225  	}
   226  	return res
   227  }
   228  
   229  func (o *Invitation) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   230  	return o.MakeDiffFieldMask(other.(*Invitation))
   231  }
   232  
   233  func (o *Invitation) Clone() *Invitation {
   234  	if o == nil {
   235  		return nil
   236  	}
   237  	result := &Invitation{}
   238  	result.InviteeEmail = o.InviteeEmail
   239  	result.InviterActor = o.InviterActor.Clone()
   240  	result.InviterFullName = o.InviterFullName
   241  	result.InviterEmail = o.InviterEmail
   242  	result.LanguageCode = o.LanguageCode
   243  	result.BindingRoles = make([]*Invitation_BindingRole, len(o.BindingRoles))
   244  	for i, sourceValue := range o.BindingRoles {
   245  		result.BindingRoles[i] = sourceValue.Clone()
   246  	}
   247  	result.Groups = make([]*group.Reference, len(o.Groups))
   248  	for i, sourceValue := range o.Groups {
   249  		if sourceValue == nil {
   250  			result.Groups[i] = nil
   251  		} else if data, err := sourceValue.ProtoString(); err != nil {
   252  			panic(err)
   253  		} else {
   254  			result.Groups[i] = &group.Reference{}
   255  			if err := result.Groups[i].ParseProtoString(data); err != nil {
   256  				panic(err)
   257  			}
   258  		}
   259  	}
   260  	result.ExpirationDate = proto.Clone(o.ExpirationDate).(*timestamppb.Timestamp)
   261  	result.Extras = map[string]string{}
   262  	for key, sourceValue := range o.Extras {
   263  		result.Extras[key] = sourceValue
   264  	}
   265  	result.State = o.State
   266  	return result
   267  }
   268  
   269  func (o *Invitation) CloneRaw() gotenobject.GotenObjectExt {
   270  	return o.Clone()
   271  }
   272  
   273  func (o *Invitation) Merge(source *Invitation) {
   274  	o.InviteeEmail = source.GetInviteeEmail()
   275  	if source.GetInviterActor() != nil {
   276  		if o.InviterActor == nil {
   277  			o.InviterActor = new(Actor)
   278  		}
   279  		o.InviterActor.Merge(source.GetInviterActor())
   280  	}
   281  	o.InviterFullName = source.GetInviterFullName()
   282  	o.InviterEmail = source.GetInviterEmail()
   283  	o.LanguageCode = source.GetLanguageCode()
   284  	for _, sourceValue := range source.GetBindingRoles() {
   285  		exists := false
   286  		for _, currentValue := range o.BindingRoles {
   287  			if proto.Equal(sourceValue, currentValue) {
   288  				exists = true
   289  				break
   290  			}
   291  		}
   292  		if !exists {
   293  			var newDstElement *Invitation_BindingRole
   294  			if sourceValue != nil {
   295  				newDstElement = new(Invitation_BindingRole)
   296  				newDstElement.Merge(sourceValue)
   297  			}
   298  			o.BindingRoles = append(o.BindingRoles, newDstElement)
   299  		}
   300  	}
   301  
   302  	for _, sourceValue := range source.GetGroups() {
   303  		exists := false
   304  		for _, currentValue := range o.Groups {
   305  			leftProtoStr, _ := currentValue.ProtoString()
   306  			rightProtoStr, _ := sourceValue.ProtoString()
   307  			if leftProtoStr == rightProtoStr {
   308  				exists = true
   309  				break
   310  			}
   311  		}
   312  		if !exists {
   313  			var newDstElement *group.Reference
   314  			if sourceValue != nil {
   315  				if data, err := sourceValue.ProtoString(); err != nil {
   316  					panic(err)
   317  				} else {
   318  					newDstElement = &group.Reference{}
   319  					if err := newDstElement.ParseProtoString(data); err != nil {
   320  						panic(err)
   321  					}
   322  				}
   323  			}
   324  			o.Groups = append(o.Groups, newDstElement)
   325  		}
   326  	}
   327  
   328  	if source.GetExpirationDate() != nil {
   329  		if o.ExpirationDate == nil {
   330  			o.ExpirationDate = new(timestamppb.Timestamp)
   331  		}
   332  		proto.Merge(o.ExpirationDate, source.GetExpirationDate())
   333  	}
   334  	if source.GetExtras() != nil {
   335  		if o.Extras == nil {
   336  			o.Extras = make(map[string]string, len(source.GetExtras()))
   337  		}
   338  		for key, sourceValue := range source.GetExtras() {
   339  			o.Extras[key] = sourceValue
   340  		}
   341  	}
   342  	o.State = source.GetState()
   343  }
   344  
   345  func (o *Invitation) MergeRaw(source gotenobject.GotenObjectExt) {
   346  	o.Merge(source.(*Invitation))
   347  }
   348  
   349  func (o *Invitation_BindingRole) GotenObjectExt() {}
   350  
   351  func (o *Invitation_BindingRole) MakeFullFieldMask() *Invitation_BindingRole_FieldMask {
   352  	return FullInvitation_BindingRole_FieldMask()
   353  }
   354  
   355  func (o *Invitation_BindingRole) MakeRawFullFieldMask() gotenobject.FieldMask {
   356  	return FullInvitation_BindingRole_FieldMask()
   357  }
   358  
   359  func (o *Invitation_BindingRole) MakeDiffFieldMask(other *Invitation_BindingRole) *Invitation_BindingRole_FieldMask {
   360  	if o == nil && other == nil {
   361  		return &Invitation_BindingRole_FieldMask{}
   362  	}
   363  	if o == nil || other == nil {
   364  		return FullInvitation_BindingRole_FieldMask()
   365  	}
   366  
   367  	res := &Invitation_BindingRole_FieldMask{}
   368  	if o.GetRole().String() != other.GetRole().String() {
   369  		res.Paths = append(res.Paths, &InvitationBindingRole_FieldTerminalPath{selector: InvitationBindingRole_FieldPathSelectorRole})
   370  	}
   371  
   372  	if len(o.GetExecutableConditions()) == len(other.GetExecutableConditions()) {
   373  		for i, lValue := range o.GetExecutableConditions() {
   374  			rValue := other.GetExecutableConditions()[i]
   375  			if len(lValue.MakeDiffFieldMask(rValue).Paths) > 0 {
   376  				res.Paths = append(res.Paths, &InvitationBindingRole_FieldTerminalPath{selector: InvitationBindingRole_FieldPathSelectorExecutableConditions})
   377  				break
   378  			}
   379  		}
   380  	} else {
   381  		res.Paths = append(res.Paths, &InvitationBindingRole_FieldTerminalPath{selector: InvitationBindingRole_FieldPathSelectorExecutableConditions})
   382  	}
   383  
   384  	if len(o.GetScopeParams()) == len(other.GetScopeParams()) {
   385  		for i, lValue := range o.GetScopeParams() {
   386  			rValue := other.GetScopeParams()[i]
   387  			if len(lValue.MakeDiffFieldMask(rValue).Paths) > 0 {
   388  				res.Paths = append(res.Paths, &InvitationBindingRole_FieldTerminalPath{selector: InvitationBindingRole_FieldPathSelectorScopeParams})
   389  				break
   390  			}
   391  		}
   392  	} else {
   393  		res.Paths = append(res.Paths, &InvitationBindingRole_FieldTerminalPath{selector: InvitationBindingRole_FieldPathSelectorScopeParams})
   394  	}
   395  	return res
   396  }
   397  
   398  func (o *Invitation_BindingRole) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   399  	return o.MakeDiffFieldMask(other.(*Invitation_BindingRole))
   400  }
   401  
   402  func (o *Invitation_BindingRole) Clone() *Invitation_BindingRole {
   403  	if o == nil {
   404  		return nil
   405  	}
   406  	result := &Invitation_BindingRole{}
   407  	if o.Role == nil {
   408  		result.Role = nil
   409  	} else if data, err := o.Role.ProtoString(); err != nil {
   410  		panic(err)
   411  	} else {
   412  		result.Role = &role.Reference{}
   413  		if err := result.Role.ParseProtoString(data); err != nil {
   414  			panic(err)
   415  		}
   416  	}
   417  	result.ExecutableConditions = make([]*condition.ExecutableCondition, len(o.ExecutableConditions))
   418  	for i, sourceValue := range o.ExecutableConditions {
   419  		result.ExecutableConditions[i] = sourceValue.Clone()
   420  	}
   421  	result.ScopeParams = make([]*role.ScopeParam, len(o.ScopeParams))
   422  	for i, sourceValue := range o.ScopeParams {
   423  		result.ScopeParams[i] = sourceValue.Clone()
   424  	}
   425  	return result
   426  }
   427  
   428  func (o *Invitation_BindingRole) CloneRaw() gotenobject.GotenObjectExt {
   429  	return o.Clone()
   430  }
   431  
   432  func (o *Invitation_BindingRole) Merge(source *Invitation_BindingRole) {
   433  	if source.GetRole() != nil {
   434  		if data, err := source.GetRole().ProtoString(); err != nil {
   435  			panic(err)
   436  		} else {
   437  			o.Role = &role.Reference{}
   438  			if err := o.Role.ParseProtoString(data); err != nil {
   439  				panic(err)
   440  			}
   441  		}
   442  	} else {
   443  		o.Role = nil
   444  	}
   445  	for _, sourceValue := range source.GetExecutableConditions() {
   446  		exists := false
   447  		for _, currentValue := range o.ExecutableConditions {
   448  			if proto.Equal(sourceValue, currentValue) {
   449  				exists = true
   450  				break
   451  			}
   452  		}
   453  		if !exists {
   454  			var newDstElement *condition.ExecutableCondition
   455  			if sourceValue != nil {
   456  				newDstElement = new(condition.ExecutableCondition)
   457  				newDstElement.Merge(sourceValue)
   458  			}
   459  			o.ExecutableConditions = append(o.ExecutableConditions, newDstElement)
   460  		}
   461  	}
   462  
   463  	for _, sourceValue := range source.GetScopeParams() {
   464  		exists := false
   465  		for _, currentValue := range o.ScopeParams {
   466  			if proto.Equal(sourceValue, currentValue) {
   467  				exists = true
   468  				break
   469  			}
   470  		}
   471  		if !exists {
   472  			var newDstElement *role.ScopeParam
   473  			if sourceValue != nil {
   474  				newDstElement = new(role.ScopeParam)
   475  				newDstElement.Merge(sourceValue)
   476  			}
   477  			o.ScopeParams = append(o.ScopeParams, newDstElement)
   478  		}
   479  	}
   480  
   481  }
   482  
   483  func (o *Invitation_BindingRole) MergeRaw(source gotenobject.GotenObjectExt) {
   484  	o.Merge(source.(*Invitation_BindingRole))
   485  }