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

     1  // Code generated by protoc-gen-goten-validate
     2  // File: edgelq/monitoring/proto/v3/common.proto
     3  // DO NOT EDIT!!!
     4  
     5  package common
     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  	durationpb "google.golang.org/protobuf/types/known/durationpb"
    24  	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
    25  )
    26  
    27  var (
    28  	_ = bytes.Equal
    29  	_ = errors.New
    30  	_ = fmt.Errorf
    31  	_ = net.ParseIP
    32  	_ = regexp.Match
    33  	_ = strings.Split
    34  	_ = time.Now
    35  	_ = utf8.RuneCountInString
    36  	_ = url.Parse
    37  	_ = gotenvalidate.NewValidationError
    38  
    39  	validation_regex_LabelDescriptor_key_3767d375e69c51f9742b2f17e9eb21a2 = regexp.MustCompile("^[_A-Za-z][_A-Za-z0-9]{0,31}$")
    40  	validation_regex_Metric_type_e8902cb4d938f84496a381cb8dc140e5         = regexp.MustCompile("^[A-Za-z0-9_\\-.,+!*()%\\\\/]{1,256}$")
    41  )
    42  
    43  // make sure we're using proto imports
    44  var (
    45  	_ = &durationpb.Duration{}
    46  	_ = &timestamppb.Timestamp{}
    47  )
    48  
    49  func (obj *LabelDescriptor) GotenValidate() error {
    50  	if obj == nil {
    51  		return nil
    52  	}
    53  	if !validation_regex_LabelDescriptor_key_3767d375e69c51f9742b2f17e9eb21a2.Match([]byte(obj.Key)) {
    54  		return gotenvalidate.NewValidationError("LabelDescriptor", "key", obj.Key, "field must match the regex ^[_A-Za-z][_A-Za-z0-9]{0,31}$", nil)
    55  	}
    56  	if int32(obj.ValueType) != 0 {
    57  		return gotenvalidate.NewValidationError("LabelDescriptor", "valueType", obj.ValueType, "field must be set to the value 0", nil)
    58  	}
    59  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
    60  		return cvobj.GotenCustomValidate()
    61  	}
    62  	return nil
    63  }
    64  func (obj *LabelKeySet) GotenValidate() error {
    65  	if obj == nil {
    66  		return nil
    67  	}
    68  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
    69  		return cvobj.GotenCustomValidate()
    70  	}
    71  	return nil
    72  }
    73  func (obj *Distribution) GotenValidate() error {
    74  	if obj == nil {
    75  		return nil
    76  	}
    77  	if subobj, ok := interface{}(obj.Range).(gotenvalidate.Validator); ok {
    78  		if err := subobj.GotenValidate(); err != nil {
    79  			return gotenvalidate.NewValidationError("Distribution", "range", obj.Range, "nested object validation failed", err)
    80  		}
    81  	}
    82  	if subobj, ok := interface{}(obj.BucketOptions).(gotenvalidate.Validator); ok {
    83  		if err := subobj.GotenValidate(); err != nil {
    84  			return gotenvalidate.NewValidationError("Distribution", "bucketOptions", obj.BucketOptions, "nested object validation failed", err)
    85  		}
    86  	}
    87  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
    88  		return cvobj.GotenCustomValidate()
    89  	}
    90  	return nil
    91  }
    92  func (obj *Distribution_Range) GotenValidate() error {
    93  	if obj == nil {
    94  		return nil
    95  	}
    96  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
    97  		return cvobj.GotenCustomValidate()
    98  	}
    99  	return nil
   100  }
   101  func (obj *Distribution_BucketOptions) GotenValidate() error {
   102  	if obj == nil {
   103  		return nil
   104  	}
   105  	switch opt := obj.Options.(type) {
   106  	case *Distribution_BucketOptions_LinearBuckets:
   107  		if subobj, ok := interface{}(opt.LinearBuckets).(gotenvalidate.Validator); ok {
   108  			if err := subobj.GotenValidate(); err != nil {
   109  				return gotenvalidate.NewValidationError("BucketOptions", "linearBuckets", opt.LinearBuckets, "nested object validation failed", err)
   110  			}
   111  		}
   112  	case *Distribution_BucketOptions_ExponentialBuckets:
   113  		if subobj, ok := interface{}(opt.ExponentialBuckets).(gotenvalidate.Validator); ok {
   114  			if err := subobj.GotenValidate(); err != nil {
   115  				return gotenvalidate.NewValidationError("BucketOptions", "exponentialBuckets", opt.ExponentialBuckets, "nested object validation failed", err)
   116  			}
   117  		}
   118  	case *Distribution_BucketOptions_ExplicitBuckets:
   119  		if subobj, ok := interface{}(opt.ExplicitBuckets).(gotenvalidate.Validator); ok {
   120  			if err := subobj.GotenValidate(); err != nil {
   121  				return gotenvalidate.NewValidationError("BucketOptions", "explicitBuckets", opt.ExplicitBuckets, "nested object validation failed", err)
   122  			}
   123  		}
   124  	case *Distribution_BucketOptions_DynamicBuckets:
   125  		if subobj, ok := interface{}(opt.DynamicBuckets).(gotenvalidate.Validator); ok {
   126  			if err := subobj.GotenValidate(); err != nil {
   127  				return gotenvalidate.NewValidationError("BucketOptions", "dynamicBuckets", opt.DynamicBuckets, "nested object validation failed", err)
   128  			}
   129  		}
   130  	default:
   131  		_ = opt
   132  	}
   133  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   134  		return cvobj.GotenCustomValidate()
   135  	}
   136  	return nil
   137  }
   138  func (obj *Distribution_BucketOptions_Linear) GotenValidate() error {
   139  	if obj == nil {
   140  		return nil
   141  	}
   142  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   143  		return cvobj.GotenCustomValidate()
   144  	}
   145  	return nil
   146  }
   147  func (obj *Distribution_BucketOptions_Exponential) GotenValidate() error {
   148  	if obj == nil {
   149  		return nil
   150  	}
   151  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   152  		return cvobj.GotenCustomValidate()
   153  	}
   154  	return nil
   155  }
   156  func (obj *Distribution_BucketOptions_Explicit) GotenValidate() error {
   157  	if obj == nil {
   158  		return nil
   159  	}
   160  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   161  		return cvobj.GotenCustomValidate()
   162  	}
   163  	return nil
   164  }
   165  func (obj *Distribution_BucketOptions_Dynamic) GotenValidate() error {
   166  	if obj == nil {
   167  		return nil
   168  	}
   169  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   170  		return cvobj.GotenCustomValidate()
   171  	}
   172  	return nil
   173  }
   174  func (obj *TypedValue) GotenValidate() error {
   175  	if obj == nil {
   176  		return nil
   177  	}
   178  	switch opt := obj.Value.(type) {
   179  	case *TypedValue_BoolValue:
   180  	case *TypedValue_Int64Value:
   181  	case *TypedValue_DoubleValue:
   182  	case *TypedValue_StringValue:
   183  	case *TypedValue_DistributionValue:
   184  		if subobj, ok := interface{}(opt.DistributionValue).(gotenvalidate.Validator); ok {
   185  			if err := subobj.GotenValidate(); err != nil {
   186  				return gotenvalidate.NewValidationError("TypedValue", "distributionValue", opt.DistributionValue, "nested object validation failed", err)
   187  			}
   188  		}
   189  	default:
   190  		_ = opt
   191  	}
   192  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   193  		return cvobj.GotenCustomValidate()
   194  	}
   195  	return nil
   196  }
   197  func (obj *TimeInterval) GotenValidate() error {
   198  	if obj == nil {
   199  		return nil
   200  	}
   201  	if obj.EndTime == nil {
   202  		return gotenvalidate.NewValidationError("TimeInterval", "endTime", obj.EndTime, "field is required", nil)
   203  	}
   204  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   205  		return cvobj.GotenCustomValidate()
   206  	}
   207  	return nil
   208  }
   209  func (obj *TimeRange) GotenValidate() error {
   210  	if obj == nil {
   211  		return nil
   212  	}
   213  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   214  		return cvobj.GotenCustomValidate()
   215  	}
   216  	return nil
   217  }
   218  func (obj *Aggregation) GotenValidate() error {
   219  	if obj == nil {
   220  		return nil
   221  	}
   222  	if obj.AlignmentPeriod != nil && obj.AlignmentPeriod.CheckValid() != nil {
   223  		err := obj.AlignmentPeriod.CheckValid()
   224  		return gotenvalidate.NewValidationError("Aggregation", "alignmentPeriod", obj.AlignmentPeriod, "could not validate duration", err)
   225  	} else {
   226  		d := obj.AlignmentPeriod.AsDuration()
   227  
   228  		if obj.AlignmentPeriod != nil {
   229  			if d != time.Duration(0) && d != time.Duration(60000000000) && d != time.Duration(180000000000) && d != time.Duration(300000000000) && d != time.Duration(900000000000) && d != time.Duration(1800000000000) && d != time.Duration(3600000000000) && d != time.Duration(10800000000000) && d != time.Duration(21600000000000) && d != time.Duration(43200000000000) && d != time.Duration(86400000000000) && d != time.Duration(604800000000000) && d != time.Duration(2419200000000000) {
   230  				return gotenvalidate.NewValidationError("Aggregation", "alignmentPeriod", d, "field must be equal to exactly one of the following values: 0s, 1m0s, 3m0s, 5m0s, 15m0s, 30m0s, 1h0m0s, 3h0m0s, 6h0m0s, 12h0m0s, 24h0m0s, 168h0m0s, 672h0m0s", nil)
   231  			}
   232  		}
   233  	}
   234  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   235  		return cvobj.GotenCustomValidate()
   236  	}
   237  	return nil
   238  }
   239  func (obj *Pagination) GotenValidate() error {
   240  	if obj == nil {
   241  		return nil
   242  	}
   243  	if obj.View == "" {
   244  		return gotenvalidate.NewValidationError("Pagination", "view", obj.View, "field is required", nil)
   245  	}
   246  	if obj.Function == "" {
   247  		return gotenvalidate.NewValidationError("Pagination", "function", obj.Function, "field is required", nil)
   248  	}
   249  	if obj.AlignmentPeriod != nil && obj.AlignmentPeriod.CheckValid() != nil {
   250  		err := obj.AlignmentPeriod.CheckValid()
   251  		return gotenvalidate.NewValidationError("Pagination", "alignmentPeriod", obj.AlignmentPeriod, "could not validate duration", err)
   252  	} else {
   253  		d := obj.AlignmentPeriod.AsDuration()
   254  
   255  		if obj.AlignmentPeriod != nil {
   256  			if d != time.Duration(0) && d != time.Duration(60000000000) && d != time.Duration(180000000000) && d != time.Duration(300000000000) && d != time.Duration(900000000000) && d != time.Duration(1800000000000) && d != time.Duration(3600000000000) && d != time.Duration(10800000000000) && d != time.Duration(21600000000000) && d != time.Duration(43200000000000) && d != time.Duration(86400000000000) && d != time.Duration(604800000000000) && d != time.Duration(2419200000000000) {
   257  				return gotenvalidate.NewValidationError("Pagination", "alignmentPeriod", d, "field must be equal to exactly one of the following values: 0s, 1m0s, 3m0s, 5m0s, 15m0s, 30m0s, 1h0m0s, 3h0m0s, 6h0m0s, 12h0m0s, 24h0m0s, 168h0m0s, 672h0m0s", nil)
   258  			}
   259  		}
   260  	}
   261  	if !(obj.Limit >= 0 && obj.Limit <= 100) {
   262  		return gotenvalidate.NewValidationError("Pagination", "limit", obj.Limit, "field must be in range [0, 100]", nil)
   263  	}
   264  	if !(obj.Offset >= 0) {
   265  		return gotenvalidate.NewValidationError("Pagination", "offset", obj.Offset, "field must be greater or equal to 0", nil)
   266  	}
   267  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   268  		return cvobj.GotenCustomValidate()
   269  	}
   270  	return nil
   271  }
   272  func (obj *Metric) GotenValidate() error {
   273  	if obj == nil {
   274  		return nil
   275  	}
   276  	if !validation_regex_Metric_type_e8902cb4d938f84496a381cb8dc140e5.Match([]byte(obj.Type)) {
   277  		return gotenvalidate.NewValidationError("Metric", "type", obj.Type, "field must match the regex ^[A-Za-z0-9_\\-.,+!*()%\\\\/]{1,256}$", nil)
   278  	}
   279  	for k, v := range obj.Labels {
   280  		_, _ = k, v
   281  		{
   282  			rlen := utf8.RuneCountInString(v)
   283  			if rlen > 1024 {
   284  				return gotenvalidate.NewValidationError("Metric", "labels", v, "field must contain at most 1024 characters", nil)
   285  			}
   286  		}
   287  	}
   288  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   289  		return cvobj.GotenCustomValidate()
   290  	}
   291  	return nil
   292  }
   293  func (obj *MonitoredResource) GotenValidate() error {
   294  	if obj == nil {
   295  		return nil
   296  	}
   297  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   298  		return cvobj.GotenCustomValidate()
   299  	}
   300  	return nil
   301  }
   302  func (obj *Strings) GotenValidate() error {
   303  	if obj == nil {
   304  		return nil
   305  	}
   306  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   307  		return cvobj.GotenCustomValidate()
   308  	}
   309  	return nil
   310  }
   311  func (obj *MonitoredResourceSelector) GotenValidate() error {
   312  	if obj == nil {
   313  		return nil
   314  	}
   315  	if len(obj.Types) < 1 {
   316  		return gotenvalidate.NewValidationError("MonitoredResourceSelector", "types", obj.Types, "field must have at least 1 items", nil)
   317  	}
   318  	if len(obj.Types) > 1 {
   319  		return gotenvalidate.NewValidationError("MonitoredResourceSelector", "types", obj.Types, "field must have at most 1 items", nil)
   320  	}
   321  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   322  		return cvobj.GotenCustomValidate()
   323  	}
   324  	return nil
   325  }
   326  func (obj *MetricSelector) GotenValidate() error {
   327  	if obj == nil {
   328  		return nil
   329  	}
   330  	if len(obj.Types) < 1 {
   331  		return gotenvalidate.NewValidationError("MetricSelector", "types", obj.Types, "field must have at least 1 items", nil)
   332  	}
   333  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   334  		return cvobj.GotenCustomValidate()
   335  	}
   336  	return nil
   337  }
   338  func (obj *TimeSeriesSelector) GotenValidate() error {
   339  	if obj == nil {
   340  		return nil
   341  	}
   342  	if obj.Metric == nil {
   343  		return gotenvalidate.NewValidationError("TimeSeriesSelector", "metric", obj.Metric, "field is required", nil)
   344  	}
   345  	if subobj, ok := interface{}(obj.Metric).(gotenvalidate.Validator); ok {
   346  		if err := subobj.GotenValidate(); err != nil {
   347  			return gotenvalidate.NewValidationError("TimeSeriesSelector", "metric", obj.Metric, "nested object validation failed", err)
   348  		}
   349  	}
   350  	if obj.Resource == nil {
   351  		return gotenvalidate.NewValidationError("TimeSeriesSelector", "resource", obj.Resource, "field is required", nil)
   352  	}
   353  	if subobj, ok := interface{}(obj.Resource).(gotenvalidate.Validator); ok {
   354  		if err := subobj.GotenValidate(); err != nil {
   355  			return gotenvalidate.NewValidationError("TimeSeriesSelector", "resource", obj.Resource, "nested object validation failed", err)
   356  		}
   357  	}
   358  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   359  		return cvobj.GotenCustomValidate()
   360  	}
   361  	return nil
   362  }