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

     1  // Code generated by protoc-gen-goten-validate
     2  // File: edgelq/monitoring/proto/v4/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/v4/alerting_policy"
    24  	common "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/common"
    25  	time_serie "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/time_serie"
    26  	meta "github.com/cloudwan/goten-sdk/types/meta"
    27  	durationpb "google.golang.org/protobuf/types/known/durationpb"
    28  )
    29  
    30  var (
    31  	_ = bytes.Equal
    32  	_ = errors.New
    33  	_ = fmt.Errorf
    34  	_ = net.ParseIP
    35  	_ = regexp.Match
    36  	_ = strings.Split
    37  	_ = time.Now
    38  	_ = utf8.RuneCountInString
    39  	_ = url.Parse
    40  	_ = gotenvalidate.NewValidationError
    41  )
    42  
    43  // make sure we're using proto imports
    44  var (
    45  	_ = &alerting_policy.AlertingPolicy{}
    46  	_ = &common.LabelDescriptor{}
    47  	_ = &time_serie.Point{}
    48  	_ = &durationpb.Duration{}
    49  	_ = &meta.Meta{}
    50  )
    51  
    52  func (obj *AlertingCondition) GotenValidate() error {
    53  	if obj == nil {
    54  		return nil
    55  	}
    56  	if subobj, ok := interface{}(obj.Metadata).(gotenvalidate.Validator); ok {
    57  		if err := subobj.GotenValidate(); err != nil {
    58  			return gotenvalidate.NewValidationError("AlertingCondition", "metadata", obj.Metadata, "nested object validation failed", err)
    59  		}
    60  	}
    61  	{
    62  		rlen := utf8.RuneCountInString(obj.Description)
    63  		if rlen > 256 {
    64  			return gotenvalidate.NewValidationError("AlertingCondition", "description", obj.Description, "field must contain at most 256 characters", nil)
    65  		}
    66  	}
    67  	if obj.Spec == nil {
    68  		return gotenvalidate.NewValidationError("AlertingCondition", "spec", obj.Spec, "field is required", nil)
    69  	}
    70  	if subobj, ok := interface{}(obj.Spec).(gotenvalidate.Validator); ok {
    71  		if err := subobj.GotenValidate(); err != nil {
    72  			return gotenvalidate.NewValidationError("AlertingCondition", "spec", obj.Spec, "nested object validation failed", err)
    73  		}
    74  	}
    75  	if subobj, ok := interface{}(obj.State).(gotenvalidate.Validator); ok {
    76  		if err := subobj.GotenValidate(); err != nil {
    77  			return gotenvalidate.NewValidationError("AlertingCondition", "state", obj.State, "nested object validation failed", err)
    78  		}
    79  	}
    80  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
    81  		return cvobj.GotenCustomValidate()
    82  	}
    83  	return nil
    84  }
    85  func (obj *AlertingCondition_Spec) GotenValidate() error {
    86  	if obj == nil {
    87  		return nil
    88  	}
    89  	if obj.TimeSeries == nil {
    90  		return gotenvalidate.NewValidationError("Spec", "timeSeries", obj.TimeSeries, "field is required", nil)
    91  	}
    92  	if subobj, ok := interface{}(obj.TimeSeries).(gotenvalidate.Validator); ok {
    93  		if err := subobj.GotenValidate(); err != nil {
    94  			return gotenvalidate.NewValidationError("Spec", "timeSeries", obj.TimeSeries, "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_TimeSeries_Query) GotenValidate() error {
   154  	if obj == nil {
   155  		return nil
   156  	}
   157  	if subobj, ok := interface{}(obj.Selector).(gotenvalidate.Validator); ok {
   158  		if err := subobj.GotenValidate(); err != nil {
   159  			return gotenvalidate.NewValidationError("Query", "selector", obj.Selector, "nested object validation failed", err)
   160  		}
   161  	}
   162  	if obj.Aggregation == nil {
   163  		return gotenvalidate.NewValidationError("Query", "aggregation", obj.Aggregation, "field is required", nil)
   164  	}
   165  	if subobj, ok := interface{}(obj.Aggregation).(gotenvalidate.Validator); ok {
   166  		if err := subobj.GotenValidate(); err != nil {
   167  			return gotenvalidate.NewValidationError("Query", "aggregation", obj.Aggregation, "nested object validation failed", err)
   168  		}
   169  	}
   170  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   171  		return cvobj.GotenCustomValidate()
   172  	}
   173  	return nil
   174  }
   175  func (obj *AlertingCondition_Spec_TimeSeries_Threshold) GotenValidate() error {
   176  	if obj == nil {
   177  		return nil
   178  	}
   179  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   180  		return cvobj.GotenCustomValidate()
   181  	}
   182  	return nil
   183  }
   184  func (obj *AlertingCondition_Spec_TimeSeries_CombineThreshold) GotenValidate() error {
   185  	if obj == nil {
   186  		return nil
   187  	}
   188  	if obj.MainMetricType == "" {
   189  		return gotenvalidate.NewValidationError("CombineThreshold", "mainMetricType", obj.MainMetricType, "field is required", nil)
   190  	}
   191  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   192  		return cvobj.GotenCustomValidate()
   193  	}
   194  	return nil
   195  }