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

     1  // Code generated by protoc-gen-goten-object
     2  // File: edgelq/iam/proto/v1alpha2/condition.proto
     3  // DO NOT EDIT!!!
     4  
     5  package condition
     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  	organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/organization"
    20  	project "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/project"
    21  	meta "github.com/cloudwan/goten-sdk/types/meta"
    22  	structpb "google.golang.org/protobuf/types/known/structpb"
    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  	_ = &organization.Organization{}
    39  	_ = &project.Project{}
    40  	_ = &structpb.Struct{}
    41  	_ = &meta.Meta{}
    42  )
    43  
    44  func (o *Condition) GotenObjectExt() {}
    45  
    46  func (o *Condition) MakeFullFieldMask() *Condition_FieldMask {
    47  	return FullCondition_FieldMask()
    48  }
    49  
    50  func (o *Condition) MakeRawFullFieldMask() gotenobject.FieldMask {
    51  	return FullCondition_FieldMask()
    52  }
    53  
    54  func (o *Condition) MakeDiffFieldMask(other *Condition) *Condition_FieldMask {
    55  	if o == nil && other == nil {
    56  		return &Condition_FieldMask{}
    57  	}
    58  	if o == nil || other == nil {
    59  		return FullCondition_FieldMask()
    60  	}
    61  
    62  	res := &Condition_FieldMask{}
    63  	if o.GetName().String() != other.GetName().String() {
    64  		res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorName})
    65  	}
    66  	if o.GetDisplayName() != other.GetDisplayName() {
    67  		res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorDisplayName})
    68  	}
    69  	if o.GetDescription() != other.GetDescription() {
    70  		res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorDescription})
    71  	}
    72  	if o.GetExpression() != other.GetExpression() {
    73  		res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorExpression})
    74  	}
    75  
    76  	if len(o.GetParameterDeclarations()) == len(other.GetParameterDeclarations()) {
    77  		for i, lValue := range o.GetParameterDeclarations() {
    78  			rValue := other.GetParameterDeclarations()[i]
    79  			if len(lValue.MakeDiffFieldMask(rValue).Paths) > 0 {
    80  				res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorParameterDeclarations})
    81  				break
    82  			}
    83  		}
    84  	} else {
    85  		res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorParameterDeclarations})
    86  	}
    87  	{
    88  		subMask := o.GetMetadata().MakeDiffFieldMask(other.GetMetadata())
    89  		if subMask.IsFull() {
    90  			res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorMetadata})
    91  		} else {
    92  			for _, subpath := range subMask.Paths {
    93  				res.Paths = append(res.Paths, &Condition_FieldSubPath{selector: Condition_FieldPathSelectorMetadata, subPath: subpath})
    94  			}
    95  		}
    96  	}
    97  	return res
    98  }
    99  
   100  func (o *Condition) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   101  	return o.MakeDiffFieldMask(other.(*Condition))
   102  }
   103  
   104  func (o *Condition) Clone() *Condition {
   105  	if o == nil {
   106  		return nil
   107  	}
   108  	result := &Condition{}
   109  	if o.Name == nil {
   110  		result.Name = nil
   111  	} else if data, err := o.Name.ProtoString(); err != nil {
   112  		panic(err)
   113  	} else {
   114  		result.Name = &Name{}
   115  		if err := result.Name.ParseProtoString(data); err != nil {
   116  			panic(err)
   117  		}
   118  	}
   119  	result.DisplayName = o.DisplayName
   120  	result.Description = o.Description
   121  	result.Expression = o.Expression
   122  	result.ParameterDeclarations = make([]*Condition_ParameterDeclaration, len(o.ParameterDeclarations))
   123  	for i, sourceValue := range o.ParameterDeclarations {
   124  		result.ParameterDeclarations[i] = sourceValue.Clone()
   125  	}
   126  	result.Metadata = o.Metadata.Clone()
   127  	return result
   128  }
   129  
   130  func (o *Condition) CloneRaw() gotenobject.GotenObjectExt {
   131  	return o.Clone()
   132  }
   133  
   134  func (o *Condition) Merge(source *Condition) {
   135  	if source.GetName() != nil {
   136  		if data, err := source.GetName().ProtoString(); err != nil {
   137  			panic(err)
   138  		} else {
   139  			o.Name = &Name{}
   140  			if err := o.Name.ParseProtoString(data); err != nil {
   141  				panic(err)
   142  			}
   143  		}
   144  	} else {
   145  		o.Name = nil
   146  	}
   147  	o.DisplayName = source.GetDisplayName()
   148  	o.Description = source.GetDescription()
   149  	o.Expression = source.GetExpression()
   150  	for _, sourceValue := range source.GetParameterDeclarations() {
   151  		exists := false
   152  		for _, currentValue := range o.ParameterDeclarations {
   153  			if proto.Equal(sourceValue, currentValue) {
   154  				exists = true
   155  				break
   156  			}
   157  		}
   158  		if !exists {
   159  			var newDstElement *Condition_ParameterDeclaration
   160  			if sourceValue != nil {
   161  				newDstElement = new(Condition_ParameterDeclaration)
   162  				newDstElement.Merge(sourceValue)
   163  			}
   164  			o.ParameterDeclarations = append(o.ParameterDeclarations, newDstElement)
   165  		}
   166  	}
   167  
   168  	if source.GetMetadata() != nil {
   169  		if o.Metadata == nil {
   170  			o.Metadata = new(meta.Meta)
   171  		}
   172  		o.Metadata.Merge(source.GetMetadata())
   173  	}
   174  }
   175  
   176  func (o *Condition) MergeRaw(source gotenobject.GotenObjectExt) {
   177  	o.Merge(source.(*Condition))
   178  }
   179  
   180  func (o *Condition_ParameterDeclaration) GotenObjectExt() {}
   181  
   182  func (o *Condition_ParameterDeclaration) MakeFullFieldMask() *Condition_ParameterDeclaration_FieldMask {
   183  	return FullCondition_ParameterDeclaration_FieldMask()
   184  }
   185  
   186  func (o *Condition_ParameterDeclaration) MakeRawFullFieldMask() gotenobject.FieldMask {
   187  	return FullCondition_ParameterDeclaration_FieldMask()
   188  }
   189  
   190  func (o *Condition_ParameterDeclaration) MakeDiffFieldMask(other *Condition_ParameterDeclaration) *Condition_ParameterDeclaration_FieldMask {
   191  	if o == nil && other == nil {
   192  		return &Condition_ParameterDeclaration_FieldMask{}
   193  	}
   194  	if o == nil || other == nil {
   195  		return FullCondition_ParameterDeclaration_FieldMask()
   196  	}
   197  
   198  	res := &Condition_ParameterDeclaration_FieldMask{}
   199  	if o.GetKey() != other.GetKey() {
   200  		res.Paths = append(res.Paths, &ConditionParameterDeclaration_FieldTerminalPath{selector: ConditionParameterDeclaration_FieldPathSelectorKey})
   201  	}
   202  	if o.GetType() != other.GetType() {
   203  		res.Paths = append(res.Paths, &ConditionParameterDeclaration_FieldTerminalPath{selector: ConditionParameterDeclaration_FieldPathSelectorType})
   204  	}
   205  	return res
   206  }
   207  
   208  func (o *Condition_ParameterDeclaration) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   209  	return o.MakeDiffFieldMask(other.(*Condition_ParameterDeclaration))
   210  }
   211  
   212  func (o *Condition_ParameterDeclaration) Clone() *Condition_ParameterDeclaration {
   213  	if o == nil {
   214  		return nil
   215  	}
   216  	result := &Condition_ParameterDeclaration{}
   217  	result.Key = o.Key
   218  	result.Type = o.Type
   219  	return result
   220  }
   221  
   222  func (o *Condition_ParameterDeclaration) CloneRaw() gotenobject.GotenObjectExt {
   223  	return o.Clone()
   224  }
   225  
   226  func (o *Condition_ParameterDeclaration) Merge(source *Condition_ParameterDeclaration) {
   227  	o.Key = source.GetKey()
   228  	o.Type = source.GetType()
   229  }
   230  
   231  func (o *Condition_ParameterDeclaration) MergeRaw(source gotenobject.GotenObjectExt) {
   232  	o.Merge(source.(*Condition_ParameterDeclaration))
   233  }
   234  
   235  func (o *ConditionBinding) GotenObjectExt() {}
   236  
   237  func (o *ConditionBinding) MakeFullFieldMask() *ConditionBinding_FieldMask {
   238  	return FullConditionBinding_FieldMask()
   239  }
   240  
   241  func (o *ConditionBinding) MakeRawFullFieldMask() gotenobject.FieldMask {
   242  	return FullConditionBinding_FieldMask()
   243  }
   244  
   245  func (o *ConditionBinding) MakeDiffFieldMask(other *ConditionBinding) *ConditionBinding_FieldMask {
   246  	if o == nil && other == nil {
   247  		return &ConditionBinding_FieldMask{}
   248  	}
   249  	if o == nil || other == nil {
   250  		return FullConditionBinding_FieldMask()
   251  	}
   252  
   253  	res := &ConditionBinding_FieldMask{}
   254  	if o.GetCondition().String() != other.GetCondition().String() {
   255  		res.Paths = append(res.Paths, &ConditionBinding_FieldTerminalPath{selector: ConditionBinding_FieldPathSelectorCondition})
   256  	}
   257  
   258  	if len(o.GetParameters()) == len(other.GetParameters()) {
   259  		for i, lValue := range o.GetParameters() {
   260  			rValue := other.GetParameters()[i]
   261  			if lValue != rValue {
   262  				res.Paths = append(res.Paths, &ConditionBinding_FieldTerminalPath{selector: ConditionBinding_FieldPathSelectorParameters})
   263  				break
   264  			}
   265  		}
   266  	} else {
   267  		res.Paths = append(res.Paths, &ConditionBinding_FieldTerminalPath{selector: ConditionBinding_FieldPathSelectorParameters})
   268  	}
   269  	if !proto.Equal(o.GetParams(), other.GetParams()) {
   270  		res.Paths = append(res.Paths, &ConditionBinding_FieldTerminalPath{selector: ConditionBinding_FieldPathSelectorParams})
   271  	}
   272  	return res
   273  }
   274  
   275  func (o *ConditionBinding) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   276  	return o.MakeDiffFieldMask(other.(*ConditionBinding))
   277  }
   278  
   279  func (o *ConditionBinding) Clone() *ConditionBinding {
   280  	if o == nil {
   281  		return nil
   282  	}
   283  	result := &ConditionBinding{}
   284  	if o.Condition == nil {
   285  		result.Condition = nil
   286  	} else if data, err := o.Condition.ProtoString(); err != nil {
   287  		panic(err)
   288  	} else {
   289  		result.Condition = &Reference{}
   290  		if err := result.Condition.ParseProtoString(data); err != nil {
   291  			panic(err)
   292  		}
   293  	}
   294  	result.Parameters = map[string]string{}
   295  	for key, sourceValue := range o.Parameters {
   296  		result.Parameters[key] = sourceValue
   297  	}
   298  	result.Params = proto.Clone(o.Params).(*structpb.Struct)
   299  	return result
   300  }
   301  
   302  func (o *ConditionBinding) CloneRaw() gotenobject.GotenObjectExt {
   303  	return o.Clone()
   304  }
   305  
   306  func (o *ConditionBinding) Merge(source *ConditionBinding) {
   307  	if source.GetCondition() != nil {
   308  		if data, err := source.GetCondition().ProtoString(); err != nil {
   309  			panic(err)
   310  		} else {
   311  			o.Condition = &Reference{}
   312  			if err := o.Condition.ParseProtoString(data); err != nil {
   313  				panic(err)
   314  			}
   315  		}
   316  	} else {
   317  		o.Condition = nil
   318  	}
   319  	if source.GetParameters() != nil {
   320  		if o.Parameters == nil {
   321  			o.Parameters = make(map[string]string, len(source.GetParameters()))
   322  		}
   323  		for key, sourceValue := range source.GetParameters() {
   324  			o.Parameters[key] = sourceValue
   325  		}
   326  	}
   327  	if source.GetParams() != nil {
   328  		if o.Params == nil {
   329  			o.Params = new(structpb.Struct)
   330  		}
   331  		proto.Merge(o.Params, source.GetParams())
   332  	}
   333  }
   334  
   335  func (o *ConditionBinding) MergeRaw(source gotenobject.GotenObjectExt) {
   336  	o.Merge(source.(*ConditionBinding))
   337  }