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

     1  // Code generated by protoc-gen-goten-object
     2  // File: edgelq/alerting/proto/v1/log_condition.proto
     3  // DO NOT EDIT!!!
     4  
     5  package log_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  	rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common"
    20  	document "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/document"
    21  	log_condition_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/log_condition_template"
    22  	policy "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy"
    23  	meta "github.com/cloudwan/goten-sdk/types/meta"
    24  	fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
    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  	_ = &document.Document{}
    41  	_ = &log_condition_template.LogConditionTemplate{}
    42  	_ = &policy.Policy{}
    43  	_ = &rcommon.LogCndSpec{}
    44  	_ = &fieldmaskpb.FieldMask{}
    45  	_ = &meta.Meta{}
    46  )
    47  
    48  func (o *LogCondition) GotenObjectExt() {}
    49  
    50  func (o *LogCondition) MakeFullFieldMask() *LogCondition_FieldMask {
    51  	return FullLogCondition_FieldMask()
    52  }
    53  
    54  func (o *LogCondition) MakeRawFullFieldMask() gotenobject.FieldMask {
    55  	return FullLogCondition_FieldMask()
    56  }
    57  
    58  func (o *LogCondition) MakeDiffFieldMask(other *LogCondition) *LogCondition_FieldMask {
    59  	if o == nil && other == nil {
    60  		return &LogCondition_FieldMask{}
    61  	}
    62  	if o == nil || other == nil {
    63  		return FullLogCondition_FieldMask()
    64  	}
    65  
    66  	res := &LogCondition_FieldMask{}
    67  	if o.GetName().String() != other.GetName().String() {
    68  		res.Paths = append(res.Paths, &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorName})
    69  	}
    70  	{
    71  		subMask := o.GetMetadata().MakeDiffFieldMask(other.GetMetadata())
    72  		if subMask.IsFull() {
    73  			res.Paths = append(res.Paths, &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorMetadata})
    74  		} else {
    75  			for _, subpath := range subMask.Paths {
    76  				res.Paths = append(res.Paths, &LogCondition_FieldSubPath{selector: LogCondition_FieldPathSelectorMetadata, subPath: subpath})
    77  			}
    78  		}
    79  	}
    80  	if o.GetDisplayName() != other.GetDisplayName() {
    81  		res.Paths = append(res.Paths, &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorDisplayName})
    82  	}
    83  	if o.GetDescription() != other.GetDescription() {
    84  		res.Paths = append(res.Paths, &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorDescription})
    85  	}
    86  
    87  	if len(o.GetSupportingDocs()) == len(other.GetSupportingDocs()) {
    88  		for i, lValue := range o.GetSupportingDocs() {
    89  			rValue := other.GetSupportingDocs()[i]
    90  			if lValue.String() != rValue.String() {
    91  				res.Paths = append(res.Paths, &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorSupportingDocs})
    92  				break
    93  			}
    94  		}
    95  	} else {
    96  		res.Paths = append(res.Paths, &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorSupportingDocs})
    97  	}
    98  	{
    99  		subMask := o.GetSpec().MakeDiffFieldMask(other.GetSpec())
   100  		if subMask.IsFull() {
   101  			res.Paths = append(res.Paths, &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorSpec})
   102  		} else {
   103  			for _, subpath := range subMask.Paths {
   104  				res.Paths = append(res.Paths, &LogCondition_FieldSubPath{selector: LogCondition_FieldPathSelectorSpec, subPath: subpath})
   105  			}
   106  		}
   107  	}
   108  	{
   109  		subMask := o.GetInternal().MakeDiffFieldMask(other.GetInternal())
   110  		if subMask.IsFull() {
   111  			res.Paths = append(res.Paths, &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorInternal})
   112  		} else {
   113  			for _, subpath := range subMask.Paths {
   114  				res.Paths = append(res.Paths, &LogCondition_FieldSubPath{selector: LogCondition_FieldPathSelectorInternal, subPath: subpath})
   115  			}
   116  		}
   117  	}
   118  	{
   119  		subMask := o.GetTemplateSource().MakeDiffFieldMask(other.GetTemplateSource())
   120  		if subMask.IsFull() {
   121  			res.Paths = append(res.Paths, &LogCondition_FieldTerminalPath{selector: LogCondition_FieldPathSelectorTemplateSource})
   122  		} else {
   123  			for _, subpath := range subMask.Paths {
   124  				res.Paths = append(res.Paths, &LogCondition_FieldSubPath{selector: LogCondition_FieldPathSelectorTemplateSource, subPath: subpath})
   125  			}
   126  		}
   127  	}
   128  	return res
   129  }
   130  
   131  func (o *LogCondition) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   132  	return o.MakeDiffFieldMask(other.(*LogCondition))
   133  }
   134  
   135  func (o *LogCondition) Clone() *LogCondition {
   136  	if o == nil {
   137  		return nil
   138  	}
   139  	result := &LogCondition{}
   140  	if o.Name == nil {
   141  		result.Name = nil
   142  	} else if data, err := o.Name.ProtoString(); err != nil {
   143  		panic(err)
   144  	} else {
   145  		result.Name = &Name{}
   146  		if err := result.Name.ParseProtoString(data); err != nil {
   147  			panic(err)
   148  		}
   149  	}
   150  	result.Metadata = o.Metadata.Clone()
   151  	result.DisplayName = o.DisplayName
   152  	result.Description = o.Description
   153  	result.SupportingDocs = make([]*document.Reference, len(o.SupportingDocs))
   154  	for i, sourceValue := range o.SupportingDocs {
   155  		if sourceValue == nil {
   156  			result.SupportingDocs[i] = nil
   157  		} else if data, err := sourceValue.ProtoString(); err != nil {
   158  			panic(err)
   159  		} else {
   160  			result.SupportingDocs[i] = &document.Reference{}
   161  			if err := result.SupportingDocs[i].ParseProtoString(data); err != nil {
   162  				panic(err)
   163  			}
   164  		}
   165  	}
   166  	result.Spec = o.Spec.Clone()
   167  	result.Internal = o.Internal.Clone()
   168  	result.TemplateSource = o.TemplateSource.Clone()
   169  	return result
   170  }
   171  
   172  func (o *LogCondition) CloneRaw() gotenobject.GotenObjectExt {
   173  	return o.Clone()
   174  }
   175  
   176  func (o *LogCondition) Merge(source *LogCondition) {
   177  	if source.GetName() != nil {
   178  		if data, err := source.GetName().ProtoString(); err != nil {
   179  			panic(err)
   180  		} else {
   181  			o.Name = &Name{}
   182  			if err := o.Name.ParseProtoString(data); err != nil {
   183  				panic(err)
   184  			}
   185  		}
   186  	} else {
   187  		o.Name = nil
   188  	}
   189  	if source.GetMetadata() != nil {
   190  		if o.Metadata == nil {
   191  			o.Metadata = new(meta.Meta)
   192  		}
   193  		o.Metadata.Merge(source.GetMetadata())
   194  	}
   195  	o.DisplayName = source.GetDisplayName()
   196  	o.Description = source.GetDescription()
   197  	for _, sourceValue := range source.GetSupportingDocs() {
   198  		exists := false
   199  		for _, currentValue := range o.SupportingDocs {
   200  			leftProtoStr, _ := currentValue.ProtoString()
   201  			rightProtoStr, _ := sourceValue.ProtoString()
   202  			if leftProtoStr == rightProtoStr {
   203  				exists = true
   204  				break
   205  			}
   206  		}
   207  		if !exists {
   208  			var newDstElement *document.Reference
   209  			if sourceValue != nil {
   210  				if data, err := sourceValue.ProtoString(); err != nil {
   211  					panic(err)
   212  				} else {
   213  					newDstElement = &document.Reference{}
   214  					if err := newDstElement.ParseProtoString(data); err != nil {
   215  						panic(err)
   216  					}
   217  				}
   218  			}
   219  			o.SupportingDocs = append(o.SupportingDocs, newDstElement)
   220  		}
   221  	}
   222  
   223  	if source.GetSpec() != nil {
   224  		if o.Spec == nil {
   225  			o.Spec = new(rcommon.LogCndSpec)
   226  		}
   227  		o.Spec.Merge(source.GetSpec())
   228  	}
   229  	if source.GetInternal() != nil {
   230  		if o.Internal == nil {
   231  			o.Internal = new(LogCondition_Internal)
   232  		}
   233  		o.Internal.Merge(source.GetInternal())
   234  	}
   235  	if source.GetTemplateSource() != nil {
   236  		if o.TemplateSource == nil {
   237  			o.TemplateSource = new(LogCondition_TemplateSource)
   238  		}
   239  		o.TemplateSource.Merge(source.GetTemplateSource())
   240  	}
   241  }
   242  
   243  func (o *LogCondition) MergeRaw(source gotenobject.GotenObjectExt) {
   244  	o.Merge(source.(*LogCondition))
   245  }
   246  
   247  func (o *LogCondition_Internal) GotenObjectExt() {}
   248  
   249  func (o *LogCondition_Internal) MakeFullFieldMask() *LogCondition_Internal_FieldMask {
   250  	return FullLogCondition_Internal_FieldMask()
   251  }
   252  
   253  func (o *LogCondition_Internal) MakeRawFullFieldMask() gotenobject.FieldMask {
   254  	return FullLogCondition_Internal_FieldMask()
   255  }
   256  
   257  func (o *LogCondition_Internal) MakeDiffFieldMask(other *LogCondition_Internal) *LogCondition_Internal_FieldMask {
   258  	if o == nil && other == nil {
   259  		return &LogCondition_Internal_FieldMask{}
   260  	}
   261  	if o == nil || other == nil {
   262  		return FullLogCondition_Internal_FieldMask()
   263  	}
   264  
   265  	res := &LogCondition_Internal_FieldMask{}
   266  	if o.GetAlertingLocation() != other.GetAlertingLocation() {
   267  		res.Paths = append(res.Paths, &LogConditionInternal_FieldTerminalPath{selector: LogConditionInternal_FieldPathSelectorAlertingLocation})
   268  	}
   269  	return res
   270  }
   271  
   272  func (o *LogCondition_Internal) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   273  	return o.MakeDiffFieldMask(other.(*LogCondition_Internal))
   274  }
   275  
   276  func (o *LogCondition_Internal) Clone() *LogCondition_Internal {
   277  	if o == nil {
   278  		return nil
   279  	}
   280  	result := &LogCondition_Internal{}
   281  	result.AlertingLocation = o.AlertingLocation
   282  	return result
   283  }
   284  
   285  func (o *LogCondition_Internal) CloneRaw() gotenobject.GotenObjectExt {
   286  	return o.Clone()
   287  }
   288  
   289  func (o *LogCondition_Internal) Merge(source *LogCondition_Internal) {
   290  	o.AlertingLocation = source.GetAlertingLocation()
   291  }
   292  
   293  func (o *LogCondition_Internal) MergeRaw(source gotenobject.GotenObjectExt) {
   294  	o.Merge(source.(*LogCondition_Internal))
   295  }
   296  
   297  func (o *LogCondition_TemplateSource) GotenObjectExt() {}
   298  
   299  func (o *LogCondition_TemplateSource) MakeFullFieldMask() *LogCondition_TemplateSource_FieldMask {
   300  	return FullLogCondition_TemplateSource_FieldMask()
   301  }
   302  
   303  func (o *LogCondition_TemplateSource) MakeRawFullFieldMask() gotenobject.FieldMask {
   304  	return FullLogCondition_TemplateSource_FieldMask()
   305  }
   306  
   307  func (o *LogCondition_TemplateSource) MakeDiffFieldMask(other *LogCondition_TemplateSource) *LogCondition_TemplateSource_FieldMask {
   308  	if o == nil && other == nil {
   309  		return &LogCondition_TemplateSource_FieldMask{}
   310  	}
   311  	if o == nil || other == nil {
   312  		return FullLogCondition_TemplateSource_FieldMask()
   313  	}
   314  
   315  	res := &LogCondition_TemplateSource_FieldMask{}
   316  	if o.GetTemplate().String() != other.GetTemplate().String() {
   317  		res.Paths = append(res.Paths, &LogConditionTemplateSource_FieldTerminalPath{selector: LogConditionTemplateSource_FieldPathSelectorTemplate})
   318  	}
   319  	if !proto.Equal(o.GetUpdatedFields(), other.GetUpdatedFields()) {
   320  		res.Paths = append(res.Paths, &LogConditionTemplateSource_FieldTerminalPath{selector: LogConditionTemplateSource_FieldPathSelectorUpdatedFields})
   321  	}
   322  	return res
   323  }
   324  
   325  func (o *LogCondition_TemplateSource) MakeRawDiffFieldMask(other gotenobject.GotenObjectExt) gotenobject.FieldMask {
   326  	return o.MakeDiffFieldMask(other.(*LogCondition_TemplateSource))
   327  }
   328  
   329  func (o *LogCondition_TemplateSource) Clone() *LogCondition_TemplateSource {
   330  	if o == nil {
   331  		return nil
   332  	}
   333  	result := &LogCondition_TemplateSource{}
   334  	if o.Template == nil {
   335  		result.Template = nil
   336  	} else if data, err := o.Template.ProtoString(); err != nil {
   337  		panic(err)
   338  	} else {
   339  		result.Template = &log_condition_template.Reference{}
   340  		if err := result.Template.ParseProtoString(data); err != nil {
   341  			panic(err)
   342  		}
   343  	}
   344  	result.UpdatedFields = proto.Clone(o.UpdatedFields).(*fieldmaskpb.FieldMask)
   345  	return result
   346  }
   347  
   348  func (o *LogCondition_TemplateSource) CloneRaw() gotenobject.GotenObjectExt {
   349  	return o.Clone()
   350  }
   351  
   352  func (o *LogCondition_TemplateSource) Merge(source *LogCondition_TemplateSource) {
   353  	if source.GetTemplate() != nil {
   354  		if data, err := source.GetTemplate().ProtoString(); err != nil {
   355  			panic(err)
   356  		} else {
   357  			o.Template = &log_condition_template.Reference{}
   358  			if err := o.Template.ParseProtoString(data); err != nil {
   359  				panic(err)
   360  			}
   361  		}
   362  	} else {
   363  		o.Template = nil
   364  	}
   365  	if source.GetUpdatedFields() != nil {
   366  		if o.UpdatedFields == nil {
   367  			o.UpdatedFields = new(fieldmaskpb.FieldMask)
   368  		}
   369  		proto.Merge(o.UpdatedFields, source.GetUpdatedFields())
   370  	}
   371  }
   372  
   373  func (o *LogCondition_TemplateSource) MergeRaw(source gotenobject.GotenObjectExt) {
   374  	o.Merge(source.(*LogCondition_TemplateSource))
   375  }