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

     1  // Code generated by protoc-gen-goten-object
     2  // File: edgelq/limits/proto/v1/plan.proto
     3  // DO NOT EDIT!!!
     4  
     5  package plan
     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  	iam_iam_common "github.com/cloudwan/edgelq-sdk/iam/resources/v1/common"
    20  	iam_organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1/organization"
    21  	meta_resource "github.com/cloudwan/goten-sdk/meta-service/resources/v1/resource"
    22  	meta_service "github.com/cloudwan/goten-sdk/meta-service/resources/v1/service"
    23  	meta "github.com/cloudwan/goten-sdk/types/meta"
    24  )
    25  
    26  // ensure the imports are used
    27  var (
    28  	_ = new(fmt.Stringer)
    29  	_ = new(sort.Interface)
    30  
    31  	_ = new(proto.Message)
    32  	_ = googlefieldmaskpb.FieldMask{}
    33  
    34  	_ = new(gotenobject.FieldPath)
    35  )
    36  
    37  // make sure we're using proto imports
    38  var (
    39  	_ = &iam_iam_common.PCR{}
    40  	_ = &iam_organization.Organization{}
    41  	_ = &meta_resource.Resource{}
    42  	_ = &meta_service.Service{}
    43  	_ = &meta.Meta{}
    44  )
    45  
    46  func (o *Plan) GotenObjectExt() {}
    47  
    48  func (o *Plan) MakeFullFieldMask() *Plan_FieldMask {
    49  	return FullPlan_FieldMask()
    50  }
    51  
    52  func (o *Plan) MakeRawFullFieldMask() gotenobject.FieldMask {
    53  	return FullPlan_FieldMask()
    54  }
    55  
    56  func (o *Plan) MakeDiffFieldMask(other *Plan) *Plan_FieldMask {
    57  	if o == nil && other == nil {
    58  		return &Plan_FieldMask{}
    59  	}
    60  	if o == nil || other == nil {
    61  		return FullPlan_FieldMask()
    62  	}
    63  
    64  	res := &Plan_FieldMask{}
    65  	if o.GetName().String() != other.GetName().String() {
    66  		res.Paths = append(res.Paths, &Plan_FieldTerminalPath{selector: Plan_FieldPathSelectorName})
    67  	}
    68  	{
    69  		subMask := o.GetMetadata().MakeDiffFieldMask(other.GetMetadata())
    70  		if subMask.IsFull() {
    71  			res.Paths = append(res.Paths, &Plan_FieldTerminalPath{selector: Plan_FieldPathSelectorMetadata})
    72  		} else {
    73  			for _, subpath := range subMask.Paths {
    74  				res.Paths = append(res.Paths, &Plan_FieldSubPath{selector: Plan_FieldPathSelectorMetadata, subPath: subpath})
    75  			}
    76  		}
    77  	}
    78  	if o.GetDisplayName() != other.GetDisplayName() {
    79  		res.Paths = append(res.Paths, &Plan_FieldTerminalPath{selector: Plan_FieldPathSelectorDisplayName})
    80  	}
    81  	if o.GetService().String() != other.GetService().String() {
    82  		res.Paths = append(res.Paths, &Plan_FieldTerminalPath{selector: Plan_FieldPathSelectorService})
    83  	}
    84  
    85  	if len(o.GetResourceLimits()) == len(other.GetResourceLimits()) {
    86  		for i, lValue := range o.GetResourceLimits() {
    87  			rValue := other.GetResourceLimits()[i]
    88  			if len(lValue.MakeDiffFieldMask(rValue).Paths) > 0 {
    89  				res.Paths = append(res.Paths, &Plan_FieldTerminalPath{selector: Plan_FieldPathSelectorResourceLimits})
    90  				break
    91  			}
    92  		}
    93  	} else {
    94  		res.Paths = append(res.Paths, &Plan_FieldTerminalPath{selector: Plan_FieldPathSelectorResourceLimits})
    95  	}
    96  	if o.GetPlanLevel() != other.GetPlanLevel() {
    97  		res.Paths = append(res.Paths, &Plan_FieldTerminalPath{selector: Plan_FieldPathSelectorPlanLevel})
    98  	}
    99  	if o.GetBusinessTier() != other.GetBusinessTier() {
   100  		res.Paths = append(res.Paths, &Plan_FieldTerminalPath{selector: Plan_FieldPathSelectorBusinessTier})
   101  	}
   102  	if o.GetGeneration() != other.GetGeneration() {
   103  		res.Paths = append(res.Paths, &Plan_FieldTerminalPath{selector: Plan_FieldPathSelectorGeneration})
   104  	}
   105  	return res
   106  }
   107  
   108  func (o *Plan) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   109  	return o.MakeDiffFieldMask(other.(*Plan))
   110  }
   111  
   112  func (o *Plan) Clone() *Plan {
   113  	if o == nil {
   114  		return nil
   115  	}
   116  	result := &Plan{}
   117  	if o.Name == nil {
   118  		result.Name = nil
   119  	} else if data, err := o.Name.ProtoString(); err != nil {
   120  		panic(err)
   121  	} else {
   122  		result.Name = &Name{}
   123  		if err := result.Name.ParseProtoString(data); err != nil {
   124  			panic(err)
   125  		}
   126  	}
   127  	result.Metadata = o.Metadata.Clone()
   128  	result.DisplayName = o.DisplayName
   129  	if o.Service == nil {
   130  		result.Service = nil
   131  	} else if data, err := o.Service.ProtoString(); err != nil {
   132  		panic(err)
   133  	} else {
   134  		result.Service = &meta_service.Reference{}
   135  		if err := result.Service.ParseProtoString(data); err != nil {
   136  			panic(err)
   137  		}
   138  	}
   139  	result.ResourceLimits = make([]*Plan_LimitValue, len(o.ResourceLimits))
   140  	for i, sourceValue := range o.ResourceLimits {
   141  		result.ResourceLimits[i] = sourceValue.Clone()
   142  	}
   143  	result.PlanLevel = o.PlanLevel
   144  	result.BusinessTier = o.BusinessTier
   145  	result.Generation = o.Generation
   146  	return result
   147  }
   148  
   149  func (o *Plan) CloneRaw() gotenobject.GotenObjectExt {
   150  	return o.Clone()
   151  }
   152  
   153  func (o *Plan) Merge(source *Plan) {
   154  	if source.GetName() != nil {
   155  		if data, err := source.GetName().ProtoString(); err != nil {
   156  			panic(err)
   157  		} else {
   158  			o.Name = &Name{}
   159  			if err := o.Name.ParseProtoString(data); err != nil {
   160  				panic(err)
   161  			}
   162  		}
   163  	} else {
   164  		o.Name = nil
   165  	}
   166  	if source.GetMetadata() != nil {
   167  		if o.Metadata == nil {
   168  			o.Metadata = new(meta.Meta)
   169  		}
   170  		o.Metadata.Merge(source.GetMetadata())
   171  	}
   172  	o.DisplayName = source.GetDisplayName()
   173  	if source.GetService() != nil {
   174  		if data, err := source.GetService().ProtoString(); err != nil {
   175  			panic(err)
   176  		} else {
   177  			o.Service = &meta_service.Reference{}
   178  			if err := o.Service.ParseProtoString(data); err != nil {
   179  				panic(err)
   180  			}
   181  		}
   182  	} else {
   183  		o.Service = nil
   184  	}
   185  	for _, sourceValue := range source.GetResourceLimits() {
   186  		exists := false
   187  		for _, currentValue := range o.ResourceLimits {
   188  			if proto.Equal(sourceValue, currentValue) {
   189  				exists = true
   190  				break
   191  			}
   192  		}
   193  		if !exists {
   194  			var newDstElement *Plan_LimitValue
   195  			if sourceValue != nil {
   196  				newDstElement = new(Plan_LimitValue)
   197  				newDstElement.Merge(sourceValue)
   198  			}
   199  			o.ResourceLimits = append(o.ResourceLimits, newDstElement)
   200  		}
   201  	}
   202  
   203  	o.PlanLevel = source.GetPlanLevel()
   204  	o.BusinessTier = source.GetBusinessTier()
   205  	o.Generation = source.GetGeneration()
   206  }
   207  
   208  func (o *Plan) MergeRaw(source gotenobject.GotenObjectExt) {
   209  	o.Merge(source.(*Plan))
   210  }
   211  
   212  func (o *Plan_LimitValue) GotenObjectExt() {}
   213  
   214  func (o *Plan_LimitValue) MakeFullFieldMask() *Plan_LimitValue_FieldMask {
   215  	return FullPlan_LimitValue_FieldMask()
   216  }
   217  
   218  func (o *Plan_LimitValue) MakeRawFullFieldMask() gotenobject.FieldMask {
   219  	return FullPlan_LimitValue_FieldMask()
   220  }
   221  
   222  func (o *Plan_LimitValue) MakeDiffFieldMask(other *Plan_LimitValue) *Plan_LimitValue_FieldMask {
   223  	if o == nil && other == nil {
   224  		return &Plan_LimitValue_FieldMask{}
   225  	}
   226  	if o == nil || other == nil {
   227  		return FullPlan_LimitValue_FieldMask()
   228  	}
   229  
   230  	res := &Plan_LimitValue_FieldMask{}
   231  	if o.GetResource().String() != other.GetResource().String() {
   232  		res.Paths = append(res.Paths, &PlanLimitValue_FieldTerminalPath{selector: PlanLimitValue_FieldPathSelectorResource})
   233  	}
   234  	if o.GetValue() != other.GetValue() {
   235  		res.Paths = append(res.Paths, &PlanLimitValue_FieldTerminalPath{selector: PlanLimitValue_FieldPathSelectorValue})
   236  	}
   237  	return res
   238  }
   239  
   240  func (o *Plan_LimitValue) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   241  	return o.MakeDiffFieldMask(other.(*Plan_LimitValue))
   242  }
   243  
   244  func (o *Plan_LimitValue) Clone() *Plan_LimitValue {
   245  	if o == nil {
   246  		return nil
   247  	}
   248  	result := &Plan_LimitValue{}
   249  	if o.Resource == nil {
   250  		result.Resource = nil
   251  	} else if data, err := o.Resource.ProtoString(); err != nil {
   252  		panic(err)
   253  	} else {
   254  		result.Resource = &meta_resource.Reference{}
   255  		if err := result.Resource.ParseProtoString(data); err != nil {
   256  			panic(err)
   257  		}
   258  	}
   259  	result.Value = o.Value
   260  	return result
   261  }
   262  
   263  func (o *Plan_LimitValue) CloneRaw() gotenobject.GotenObjectExt {
   264  	return o.Clone()
   265  }
   266  
   267  func (o *Plan_LimitValue) Merge(source *Plan_LimitValue) {
   268  	if source.GetResource() != nil {
   269  		if data, err := source.GetResource().ProtoString(); err != nil {
   270  			panic(err)
   271  		} else {
   272  			o.Resource = &meta_resource.Reference{}
   273  			if err := o.Resource.ParseProtoString(data); err != nil {
   274  				panic(err)
   275  			}
   276  		}
   277  	} else {
   278  		o.Resource = nil
   279  	}
   280  	o.Value = source.GetValue()
   281  }
   282  
   283  func (o *Plan_LimitValue) MergeRaw(source gotenobject.GotenObjectExt) {
   284  	o.Merge(source.(*Plan_LimitValue))
   285  }