github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v4/time_serie/time_serie.pb.object_ext.go (about)

     1  // Code generated by protoc-gen-goten-object
     2  // File: edgelq/monitoring/proto/v4/time_serie.proto
     3  // DO NOT EDIT!!!
     4  
     5  package time_serie
     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  	common "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/common"
    20  	metric_descriptor "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/metric_descriptor"
    21  )
    22  
    23  // ensure the imports are used
    24  var (
    25  	_ = new(fmt.Stringer)
    26  	_ = new(sort.Interface)
    27  
    28  	_ = new(proto.Message)
    29  	_ = googlefieldmaskpb.FieldMask{}
    30  
    31  	_ = new(gotenobject.FieldPath)
    32  )
    33  
    34  // make sure we're using proto imports
    35  var (
    36  	_ = &common.LabelDescriptor{}
    37  	_ = &metric_descriptor.MetricDescriptor{}
    38  )
    39  
    40  func (o *Point) GotenObjectExt() {}
    41  
    42  func (o *Point) MakeFullFieldMask() *Point_FieldMask {
    43  	return FullPoint_FieldMask()
    44  }
    45  
    46  func (o *Point) MakeRawFullFieldMask() gotenobject.FieldMask {
    47  	return FullPoint_FieldMask()
    48  }
    49  
    50  func (o *Point) MakeDiffFieldMask(other *Point) *Point_FieldMask {
    51  	if o == nil && other == nil {
    52  		return &Point_FieldMask{}
    53  	}
    54  	if o == nil || other == nil {
    55  		return FullPoint_FieldMask()
    56  	}
    57  
    58  	res := &Point_FieldMask{}
    59  	{
    60  		subMask := o.GetInterval().MakeDiffFieldMask(other.GetInterval())
    61  		if subMask.IsFull() {
    62  			res.Paths = append(res.Paths, &Point_FieldTerminalPath{selector: Point_FieldPathSelectorInterval})
    63  		} else {
    64  			for _, subpath := range subMask.Paths {
    65  				res.Paths = append(res.Paths, &Point_FieldSubPath{selector: Point_FieldPathSelectorInterval, subPath: subpath})
    66  			}
    67  		}
    68  	}
    69  	{
    70  		subMask := o.GetValue().MakeDiffFieldMask(other.GetValue())
    71  		if subMask.IsFull() {
    72  			res.Paths = append(res.Paths, &Point_FieldTerminalPath{selector: Point_FieldPathSelectorValue})
    73  		} else {
    74  			for _, subpath := range subMask.Paths {
    75  				res.Paths = append(res.Paths, &Point_FieldSubPath{selector: Point_FieldPathSelectorValue, subPath: subpath})
    76  			}
    77  		}
    78  	}
    79  	{
    80  		subMask := o.GetAggregation().MakeDiffFieldMask(other.GetAggregation())
    81  		if subMask.IsFull() {
    82  			res.Paths = append(res.Paths, &Point_FieldTerminalPath{selector: Point_FieldPathSelectorAggregation})
    83  		} else {
    84  			for _, subpath := range subMask.Paths {
    85  				res.Paths = append(res.Paths, &Point_FieldSubPath{selector: Point_FieldPathSelectorAggregation, subPath: subpath})
    86  			}
    87  		}
    88  	}
    89  	return res
    90  }
    91  
    92  func (o *Point) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
    93  	return o.MakeDiffFieldMask(other.(*Point))
    94  }
    95  
    96  func (o *Point) Clone() *Point {
    97  	if o == nil {
    98  		return nil
    99  	}
   100  	result := &Point{}
   101  	result.Interval = o.Interval.Clone()
   102  	result.Value = o.Value.Clone()
   103  	result.Aggregation = o.Aggregation.Clone()
   104  	return result
   105  }
   106  
   107  func (o *Point) CloneRaw() gotenobject.GotenObjectExt {
   108  	return o.Clone()
   109  }
   110  
   111  func (o *Point) Merge(source *Point) {
   112  	if source.GetInterval() != nil {
   113  		if o.Interval == nil {
   114  			o.Interval = new(common.TimeInterval)
   115  		}
   116  		o.Interval.Merge(source.GetInterval())
   117  	}
   118  	if source.GetValue() != nil {
   119  		if o.Value == nil {
   120  			o.Value = new(common.TypedValue)
   121  		}
   122  		o.Value.Merge(source.GetValue())
   123  	}
   124  	if source.GetAggregation() != nil {
   125  		if o.Aggregation == nil {
   126  			o.Aggregation = new(common.Aggregation)
   127  		}
   128  		o.Aggregation.Merge(source.GetAggregation())
   129  	}
   130  }
   131  
   132  func (o *Point) MergeRaw(source gotenobject.GotenObjectExt) {
   133  	o.Merge(source.(*Point))
   134  }
   135  
   136  func (o *TimeSerie) GotenObjectExt() {}
   137  
   138  func (o *TimeSerie) MakeFullFieldMask() *TimeSerie_FieldMask {
   139  	return FullTimeSerie_FieldMask()
   140  }
   141  
   142  func (o *TimeSerie) MakeRawFullFieldMask() gotenobject.FieldMask {
   143  	return FullTimeSerie_FieldMask()
   144  }
   145  
   146  func (o *TimeSerie) MakeDiffFieldMask(other *TimeSerie) *TimeSerie_FieldMask {
   147  	if o == nil && other == nil {
   148  		return &TimeSerie_FieldMask{}
   149  	}
   150  	if o == nil || other == nil {
   151  		return FullTimeSerie_FieldMask()
   152  	}
   153  
   154  	res := &TimeSerie_FieldMask{}
   155  	if string(o.GetKey()) != string(other.GetKey()) {
   156  		res.Paths = append(res.Paths, &TimeSerie_FieldTerminalPath{selector: TimeSerie_FieldPathSelectorKey})
   157  	}
   158  	if o.GetProject() != other.GetProject() {
   159  		res.Paths = append(res.Paths, &TimeSerie_FieldTerminalPath{selector: TimeSerie_FieldPathSelectorProject})
   160  	}
   161  	if o.GetRegion() != other.GetRegion() {
   162  		res.Paths = append(res.Paths, &TimeSerie_FieldTerminalPath{selector: TimeSerie_FieldPathSelectorRegion})
   163  	}
   164  	if o.GetUnit() != other.GetUnit() {
   165  		res.Paths = append(res.Paths, &TimeSerie_FieldTerminalPath{selector: TimeSerie_FieldPathSelectorUnit})
   166  	}
   167  	{
   168  		subMask := o.GetMetric().MakeDiffFieldMask(other.GetMetric())
   169  		if subMask.IsFull() {
   170  			res.Paths = append(res.Paths, &TimeSerie_FieldTerminalPath{selector: TimeSerie_FieldPathSelectorMetric})
   171  		} else {
   172  			for _, subpath := range subMask.Paths {
   173  				res.Paths = append(res.Paths, &TimeSerie_FieldSubPath{selector: TimeSerie_FieldPathSelectorMetric, subPath: subpath})
   174  			}
   175  		}
   176  	}
   177  	{
   178  		subMask := o.GetResource().MakeDiffFieldMask(other.GetResource())
   179  		if subMask.IsFull() {
   180  			res.Paths = append(res.Paths, &TimeSerie_FieldTerminalPath{selector: TimeSerie_FieldPathSelectorResource})
   181  		} else {
   182  			for _, subpath := range subMask.Paths {
   183  				res.Paths = append(res.Paths, &TimeSerie_FieldSubPath{selector: TimeSerie_FieldPathSelectorResource, subPath: subpath})
   184  			}
   185  		}
   186  	}
   187  	if o.GetMetricKind() != other.GetMetricKind() {
   188  		res.Paths = append(res.Paths, &TimeSerie_FieldTerminalPath{selector: TimeSerie_FieldPathSelectorMetricKind})
   189  	}
   190  	if o.GetValueType() != other.GetValueType() {
   191  		res.Paths = append(res.Paths, &TimeSerie_FieldTerminalPath{selector: TimeSerie_FieldPathSelectorValueType})
   192  	}
   193  
   194  	if len(o.GetPoints()) == len(other.GetPoints()) {
   195  		for i, lValue := range o.GetPoints() {
   196  			rValue := other.GetPoints()[i]
   197  			if len(lValue.MakeDiffFieldMask(rValue).Paths) > 0 {
   198  				res.Paths = append(res.Paths, &TimeSerie_FieldTerminalPath{selector: TimeSerie_FieldPathSelectorPoints})
   199  				break
   200  			}
   201  		}
   202  	} else {
   203  		res.Paths = append(res.Paths, &TimeSerie_FieldTerminalPath{selector: TimeSerie_FieldPathSelectorPoints})
   204  	}
   205  	return res
   206  }
   207  
   208  func (o *TimeSerie) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   209  	return o.MakeDiffFieldMask(other.(*TimeSerie))
   210  }
   211  
   212  func (o *TimeSerie) Clone() *TimeSerie {
   213  	if o == nil {
   214  		return nil
   215  	}
   216  	result := &TimeSerie{}
   217  	result.Key = make([]byte, len(o.Key))
   218  	for i, bt := range o.Key {
   219  		result.Key[i] = bt
   220  	}
   221  	result.Project = o.Project
   222  	result.Region = o.Region
   223  	result.Unit = o.Unit
   224  	result.Metric = o.Metric.Clone()
   225  	result.Resource = o.Resource.Clone()
   226  	result.MetricKind = o.MetricKind
   227  	result.ValueType = o.ValueType
   228  	result.Points = make([]*Point, len(o.Points))
   229  	for i, sourceValue := range o.Points {
   230  		result.Points[i] = sourceValue.Clone()
   231  	}
   232  	return result
   233  }
   234  
   235  func (o *TimeSerie) CloneRaw() gotenobject.GotenObjectExt {
   236  	return o.Clone()
   237  }
   238  
   239  func (o *TimeSerie) Merge(source *TimeSerie) {
   240  	o.Key = make([]byte, len(source.GetKey()))
   241  	for i, bt := range source.GetKey() {
   242  		o.Key[i] = bt
   243  	}
   244  	o.Project = source.GetProject()
   245  	o.Region = source.GetRegion()
   246  	o.Unit = source.GetUnit()
   247  	if source.GetMetric() != nil {
   248  		if o.Metric == nil {
   249  			o.Metric = new(common.Metric)
   250  		}
   251  		o.Metric.Merge(source.GetMetric())
   252  	}
   253  	if source.GetResource() != nil {
   254  		if o.Resource == nil {
   255  			o.Resource = new(common.MonitoredResource)
   256  		}
   257  		o.Resource.Merge(source.GetResource())
   258  	}
   259  	o.MetricKind = source.GetMetricKind()
   260  	o.ValueType = source.GetValueType()
   261  	for _, sourceValue := range source.GetPoints() {
   262  		exists := false
   263  		for _, currentValue := range o.Points {
   264  			if proto.Equal(sourceValue, currentValue) {
   265  				exists = true
   266  				break
   267  			}
   268  		}
   269  		if !exists {
   270  			var newDstElement *Point
   271  			if sourceValue != nil {
   272  				newDstElement = new(Point)
   273  				newDstElement.Merge(sourceValue)
   274  			}
   275  			o.Points = append(o.Points, newDstElement)
   276  		}
   277  	}
   278  
   279  }
   280  
   281  func (o *TimeSerie) MergeRaw(source gotenobject.GotenObjectExt) {
   282  	o.Merge(source.(*TimeSerie))
   283  }
   284  
   285  func (o *BulkTimeSeries) GotenObjectExt() {}
   286  
   287  func (o *BulkTimeSeries) MakeFullFieldMask() *BulkTimeSeries_FieldMask {
   288  	return FullBulkTimeSeries_FieldMask()
   289  }
   290  
   291  func (o *BulkTimeSeries) MakeRawFullFieldMask() gotenobject.FieldMask {
   292  	return FullBulkTimeSeries_FieldMask()
   293  }
   294  
   295  func (o *BulkTimeSeries) MakeDiffFieldMask(other *BulkTimeSeries) *BulkTimeSeries_FieldMask {
   296  	if o == nil && other == nil {
   297  		return &BulkTimeSeries_FieldMask{}
   298  	}
   299  	if o == nil || other == nil {
   300  		return FullBulkTimeSeries_FieldMask()
   301  	}
   302  
   303  	res := &BulkTimeSeries_FieldMask{}
   304  
   305  	if len(o.GetTimeSeries()) == len(other.GetTimeSeries()) {
   306  		for i, lValue := range o.GetTimeSeries() {
   307  			rValue := other.GetTimeSeries()[i]
   308  			if len(lValue.MakeDiffFieldMask(rValue).Paths) > 0 {
   309  				res.Paths = append(res.Paths, &BulkTimeSeries_FieldTerminalPath{selector: BulkTimeSeries_FieldPathSelectorTimeSeries})
   310  				break
   311  			}
   312  		}
   313  	} else {
   314  		res.Paths = append(res.Paths, &BulkTimeSeries_FieldTerminalPath{selector: BulkTimeSeries_FieldPathSelectorTimeSeries})
   315  	}
   316  	if o.GetPhantomFlag() != other.GetPhantomFlag() {
   317  		res.Paths = append(res.Paths, &BulkTimeSeries_FieldTerminalPath{selector: BulkTimeSeries_FieldPathSelectorPhantomFlag})
   318  	}
   319  	return res
   320  }
   321  
   322  func (o *BulkTimeSeries) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   323  	return o.MakeDiffFieldMask(other.(*BulkTimeSeries))
   324  }
   325  
   326  func (o *BulkTimeSeries) Clone() *BulkTimeSeries {
   327  	if o == nil {
   328  		return nil
   329  	}
   330  	result := &BulkTimeSeries{}
   331  	result.TimeSeries = make([]*TimeSerie, len(o.TimeSeries))
   332  	for i, sourceValue := range o.TimeSeries {
   333  		result.TimeSeries[i] = sourceValue.Clone()
   334  	}
   335  	result.PhantomFlag = o.PhantomFlag
   336  	return result
   337  }
   338  
   339  func (o *BulkTimeSeries) CloneRaw() gotenobject.GotenObjectExt {
   340  	return o.Clone()
   341  }
   342  
   343  func (o *BulkTimeSeries) Merge(source *BulkTimeSeries) {
   344  	for _, sourceValue := range source.GetTimeSeries() {
   345  		exists := false
   346  		for _, currentValue := range o.TimeSeries {
   347  			if proto.Equal(sourceValue, currentValue) {
   348  				exists = true
   349  				break
   350  			}
   351  		}
   352  		if !exists {
   353  			var newDstElement *TimeSerie
   354  			if sourceValue != nil {
   355  				newDstElement = new(TimeSerie)
   356  				newDstElement.Merge(sourceValue)
   357  			}
   358  			o.TimeSeries = append(o.TimeSeries, newDstElement)
   359  		}
   360  	}
   361  
   362  	o.PhantomFlag = source.GetPhantomFlag()
   363  }
   364  
   365  func (o *BulkTimeSeries) MergeRaw(source gotenobject.GotenObjectExt) {
   366  	o.Merge(source.(*BulkTimeSeries))
   367  }