github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v3/alerting_condition/alerting_condition.pb.validate.go (about)

     1  // Code generated by protoc-gen-goten-validate
     2  // File: edgelq/monitoring/proto/v3/alerting_condition.proto
     3  // DO NOT EDIT!!!
     4  
     5  package alerting_condition
     6  
     7  import (
     8  	"bytes"
     9  	"errors"
    10  	"fmt"
    11  	"net"
    12  	"net/url"
    13  	"regexp"
    14  	"strings"
    15  	"time"
    16  	"unicode/utf8"
    17  
    18  	gotenvalidate "github.com/cloudwan/goten-sdk/runtime/validate"
    19  )
    20  
    21  // proto imports
    22  import (
    23  	alerting_policy "github.com/cloudwan/edgelq-sdk/monitoring/resources/v3/alerting_policy"
    24  	common "github.com/cloudwan/edgelq-sdk/monitoring/resources/v3/common"
    25  	meta "github.com/cloudwan/goten-sdk/types/meta"
    26  	durationpb "google.golang.org/protobuf/types/known/durationpb"
    27  )
    28  
    29  var (
    30  	_ = bytes.Equal
    31  	_ = errors.New
    32  	_ = fmt.Errorf
    33  	_ = net.ParseIP
    34  	_ = regexp.Match
    35  	_ = strings.Split
    36  	_ = time.Now
    37  	_ = utf8.RuneCountInString
    38  	_ = url.Parse
    39  	_ = gotenvalidate.NewValidationError
    40  )
    41  
    42  // make sure we're using proto imports
    43  var (
    44  	_ = &alerting_policy.AlertingPolicy{}
    45  	_ = &common.LabelDescriptor{}
    46  	_ = &durationpb.Duration{}
    47  	_ = &meta.Meta{}
    48  )
    49  
    50  func (obj *AlertingCondition) GotenValidate() error {
    51  	if obj == nil {
    52  		return nil
    53  	}
    54  	if subobj, ok := interface{}(obj.Metadata).(gotenvalidate.Validator); ok {
    55  		if err := subobj.GotenValidate(); err != nil {
    56  			return gotenvalidate.NewValidationError("AlertingCondition", "metadata", obj.Metadata, "nested object validation failed", err)
    57  		}
    58  	}
    59  	if obj.Spec == nil {
    60  		return gotenvalidate.NewValidationError("AlertingCondition", "spec", obj.Spec, "field is required", nil)
    61  	}
    62  	if subobj, ok := interface{}(obj.Spec).(gotenvalidate.Validator); ok {
    63  		if err := subobj.GotenValidate(); err != nil {
    64  			return gotenvalidate.NewValidationError("AlertingCondition", "spec", obj.Spec, "nested object validation failed", err)
    65  		}
    66  	}
    67  	if subobj, ok := interface{}(obj.State).(gotenvalidate.Validator); ok {
    68  		if err := subobj.GotenValidate(); err != nil {
    69  			return gotenvalidate.NewValidationError("AlertingCondition", "state", obj.State, "nested object validation failed", err)
    70  		}
    71  	}
    72  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
    73  		return cvobj.GotenCustomValidate()
    74  	}
    75  	return nil
    76  }
    77  func (obj *AlertingCondition_Spec) GotenValidate() error {
    78  	if obj == nil {
    79  		return nil
    80  	}
    81  	if obj.TimeSeries == nil {
    82  		return gotenvalidate.NewValidationError("Spec", "timeSeries", obj.TimeSeries, "field is required", nil)
    83  	}
    84  	if subobj, ok := interface{}(obj.TimeSeries).(gotenvalidate.Validator); ok {
    85  		if err := subobj.GotenValidate(); err != nil {
    86  			return gotenvalidate.NewValidationError("Spec", "timeSeries", obj.TimeSeries, "nested object validation failed", err)
    87  		}
    88  	}
    89  	if obj.Trigger == nil {
    90  		return gotenvalidate.NewValidationError("Spec", "trigger", obj.Trigger, "field is required", nil)
    91  	}
    92  	if subobj, ok := interface{}(obj.Trigger).(gotenvalidate.Validator); ok {
    93  		if err := subobj.GotenValidate(); err != nil {
    94  			return gotenvalidate.NewValidationError("Spec", "trigger", obj.Trigger, "nested object validation failed", err)
    95  		}
    96  	}
    97  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
    98  		return cvobj.GotenCustomValidate()
    99  	}
   100  	return nil
   101  }
   102  func (obj *AlertingCondition_State) GotenValidate() error {
   103  	if obj == nil {
   104  		return nil
   105  	}
   106  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   107  		return cvobj.GotenCustomValidate()
   108  	}
   109  	return nil
   110  }
   111  func (obj *AlertingCondition_Spec_TimeSeries) GotenValidate() error {
   112  	if obj == nil {
   113  		return nil
   114  	}
   115  	if obj.Query == nil {
   116  		return gotenvalidate.NewValidationError("TimeSeries", "query", obj.Query, "field is required", nil)
   117  	}
   118  	if subobj, ok := interface{}(obj.Query).(gotenvalidate.Validator); ok {
   119  		if err := subobj.GotenValidate(); err != nil {
   120  			return gotenvalidate.NewValidationError("TimeSeries", "query", obj.Query, "nested object validation failed", err)
   121  		}
   122  	}
   123  	if subobj, ok := interface{}(obj.Threshold).(gotenvalidate.Validator); ok {
   124  		if err := subobj.GotenValidate(); err != nil {
   125  			return gotenvalidate.NewValidationError("TimeSeries", "threshold", obj.Threshold, "nested object validation failed", err)
   126  		}
   127  	}
   128  	if subobj, ok := interface{}(obj.CombineThreshold).(gotenvalidate.Validator); ok {
   129  		if err := subobj.GotenValidate(); err != nil {
   130  			return gotenvalidate.NewValidationError("TimeSeries", "combineThreshold", obj.CombineThreshold, "nested object validation failed", err)
   131  		}
   132  	}
   133  	if obj.Duration == nil {
   134  		return gotenvalidate.NewValidationError("TimeSeries", "duration", obj.Duration, "field is required", nil)
   135  	}
   136  	if obj.Duration != nil && obj.Duration.CheckValid() != nil {
   137  		err := obj.Duration.CheckValid()
   138  		return gotenvalidate.NewValidationError("TimeSeries", "duration", obj.Duration, "could not validate duration", err)
   139  	} else {
   140  		d := obj.Duration.AsDuration()
   141  
   142  		if obj.Duration != nil {
   143  			if !(d >= time.Duration(60000000000)) {
   144  				return gotenvalidate.NewValidationError("TimeSeries", "duration", d, "field must be greater or equal to 1m0s", nil)
   145  			}
   146  		}
   147  	}
   148  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   149  		return cvobj.GotenCustomValidate()
   150  	}
   151  	return nil
   152  }
   153  func (obj *AlertingCondition_Spec_Trigger) GotenValidate() error {
   154  	if obj == nil {
   155  		return nil
   156  	}
   157  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   158  		return cvobj.GotenCustomValidate()
   159  	}
   160  	return nil
   161  }
   162  func (obj *AlertingCondition_Spec_TimeSeries_Query) GotenValidate() error {
   163  	if obj == nil {
   164  		return nil
   165  	}
   166  	if obj.Selector == nil {
   167  		return gotenvalidate.NewValidationError("Query", "selector", obj.Selector, "field is required", nil)
   168  	}
   169  	if subobj, ok := interface{}(obj.Selector).(gotenvalidate.Validator); ok {
   170  		if err := subobj.GotenValidate(); err != nil {
   171  			return gotenvalidate.NewValidationError("Query", "selector", obj.Selector, "nested object validation failed", err)
   172  		}
   173  	}
   174  	if obj.Aggregation == nil {
   175  		return gotenvalidate.NewValidationError("Query", "aggregation", obj.Aggregation, "field is required", nil)
   176  	}
   177  	if subobj, ok := interface{}(obj.Aggregation).(gotenvalidate.Validator); ok {
   178  		if err := subobj.GotenValidate(); err != nil {
   179  			return gotenvalidate.NewValidationError("Query", "aggregation", obj.Aggregation, "nested object validation failed", err)
   180  		}
   181  	}
   182  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   183  		return cvobj.GotenCustomValidate()
   184  	}
   185  	return nil
   186  }
   187  func (obj *AlertingCondition_Spec_TimeSeries_Threshold) GotenValidate() error {
   188  	if obj == nil {
   189  		return nil
   190  	}
   191  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   192  		return cvobj.GotenCustomValidate()
   193  	}
   194  	return nil
   195  }
   196  func (obj *AlertingCondition_Spec_TimeSeries_CombineThreshold) GotenValidate() error {
   197  	if obj == nil {
   198  		return nil
   199  	}
   200  	if obj.Combine != 0 {
   201  		return gotenvalidate.NewValidationError("CombineThreshold", "combine", obj.Combine, "field must be equal to exactly one of the following values: 0", nil)
   202  	}
   203  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   204  		return cvobj.GotenCustomValidate()
   205  	}
   206  	return nil
   207  }