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

     1  // Code generated by protoc-gen-goten-validate
     2  // File: edgelq/alerting/proto/v1/alert.proto
     3  // DO NOT EDIT!!!
     4  
     5  package alert
     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  	rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common"
    24  	log_condition "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/log_condition"
    25  	notification_channel "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/notification_channel"
    26  	ts_condition "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/ts_condition"
    27  	meta "github.com/cloudwan/goten-sdk/types/meta"
    28  	durationpb "google.golang.org/protobuf/types/known/durationpb"
    29  	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
    30  )
    31  
    32  var (
    33  	_ = bytes.Equal
    34  	_ = errors.New
    35  	_ = fmt.Errorf
    36  	_ = net.ParseIP
    37  	_ = regexp.Match
    38  	_ = strings.Split
    39  	_ = time.Now
    40  	_ = utf8.RuneCountInString
    41  	_ = url.Parse
    42  	_ = gotenvalidate.NewValidationError
    43  )
    44  
    45  // make sure we're using proto imports
    46  var (
    47  	_ = &log_condition.LogCondition{}
    48  	_ = &notification_channel.NotificationChannel{}
    49  	_ = &rcommon.LogCndSpec{}
    50  	_ = &ts_condition.TsCondition{}
    51  	_ = &durationpb.Duration{}
    52  	_ = &timestamppb.Timestamp{}
    53  	_ = &meta.Meta{}
    54  )
    55  
    56  func (obj *Alert) GotenValidate() error {
    57  	if obj == nil {
    58  		return nil
    59  	}
    60  	if subobj, ok := interface{}(obj.Metadata).(gotenvalidate.Validator); ok {
    61  		if err := subobj.GotenValidate(); err != nil {
    62  			return gotenvalidate.NewValidationError("Alert", "metadata", obj.Metadata, "nested object validation failed", err)
    63  		}
    64  	}
    65  	if subobj, ok := interface{}(obj.AlertingResource).(gotenvalidate.Validator); ok {
    66  		if err := subobj.GotenValidate(); err != nil {
    67  			return gotenvalidate.NewValidationError("Alert", "alertingResource", obj.AlertingResource, "nested object validation failed", err)
    68  		}
    69  	}
    70  	if obj.State == nil {
    71  		return gotenvalidate.NewValidationError("Alert", "state", obj.State, "field is required", nil)
    72  	}
    73  	if subobj, ok := interface{}(obj.State).(gotenvalidate.Validator); ok {
    74  		if err := subobj.GotenValidate(); err != nil {
    75  			return gotenvalidate.NewValidationError("Alert", "state", obj.State, "nested object validation failed", err)
    76  		}
    77  	}
    78  	if subobj, ok := interface{}(obj.Internal).(gotenvalidate.Validator); ok {
    79  		if err := subobj.GotenValidate(); err != nil {
    80  			return gotenvalidate.NewValidationError("Alert", "internal", obj.Internal, "nested object validation failed", err)
    81  		}
    82  	}
    83  	switch opt := obj.Info.(type) {
    84  	case *Alert_TsInfo_:
    85  		if subobj, ok := interface{}(opt.TsInfo).(gotenvalidate.Validator); ok {
    86  			if err := subobj.GotenValidate(); err != nil {
    87  				return gotenvalidate.NewValidationError("Alert", "tsInfo", opt.TsInfo, "nested object validation failed", err)
    88  			}
    89  		}
    90  	case *Alert_LogInfo_:
    91  		if subobj, ok := interface{}(opt.LogInfo).(gotenvalidate.Validator); ok {
    92  			if err := subobj.GotenValidate(); err != nil {
    93  				return gotenvalidate.NewValidationError("Alert", "logInfo", opt.LogInfo, "nested object validation failed", err)
    94  			}
    95  		}
    96  	default:
    97  		_ = opt
    98  	}
    99  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   100  		return cvobj.GotenCustomValidate()
   101  	}
   102  	return nil
   103  }
   104  func (obj *Alert_TsInfo) GotenValidate() error {
   105  	if obj == nil {
   106  		return nil
   107  	}
   108  	if _, ok := Alert_TsInfo_Type_name[int32(obj.Type)]; !ok {
   109  		return gotenvalidate.NewValidationError("TsInfo", "type", obj.Type, "field must be a defined enum value", nil)
   110  	}
   111  	for idx, elem := range obj.TimeSeries {
   112  		if subobj, ok := interface{}(elem).(gotenvalidate.Validator); ok {
   113  			if err := subobj.GotenValidate(); err != nil {
   114  				return gotenvalidate.NewValidationError("TsInfo", "timeSeries", obj.TimeSeries[idx], "nested object validation failed", err)
   115  			}
   116  		}
   117  	}
   118  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   119  		return cvobj.GotenCustomValidate()
   120  	}
   121  	return nil
   122  }
   123  func (obj *Alert_LogInfo) GotenValidate() error {
   124  	if obj == nil {
   125  		return nil
   126  	}
   127  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   128  		return cvobj.GotenCustomValidate()
   129  	}
   130  	return nil
   131  }
   132  func (obj *Alert_State) GotenValidate() error {
   133  	if obj == nil {
   134  		return nil
   135  	}
   136  	for idx, elem := range obj.NotificationStatuses {
   137  		if subobj, ok := interface{}(elem).(gotenvalidate.Validator); ok {
   138  			if err := subobj.GotenValidate(); err != nil {
   139  				return gotenvalidate.NewValidationError("State", "notificationStatuses", obj.NotificationStatuses[idx], "nested object validation failed", err)
   140  			}
   141  		}
   142  	}
   143  	if _, ok := Alert_State_EscalationLevel_name[int32(obj.EscalationLevel)]; !ok {
   144  		return gotenvalidate.NewValidationError("State", "escalationLevel", obj.EscalationLevel, "field must be a defined enum value", nil)
   145  	}
   146  	if subobj, ok := interface{}(obj.AiRemediation).(gotenvalidate.Validator); ok {
   147  		if err := subobj.GotenValidate(); err != nil {
   148  			return gotenvalidate.NewValidationError("State", "aiRemediation", obj.AiRemediation, "nested object validation failed", err)
   149  		}
   150  	}
   151  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   152  		return cvobj.GotenCustomValidate()
   153  	}
   154  	return nil
   155  }
   156  func (obj *Alert_Internal) 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 *Alert_TsInfo_TimeSeries) GotenValidate() error {
   166  	if obj == nil {
   167  		return nil
   168  	}
   169  	if len(obj.QueryName) > 256 {
   170  		return gotenvalidate.NewValidationError("TimeSeries", "queryName", obj.QueryName, "field must contain at most 256 characters", nil)
   171  	}
   172  	if obj.QueryName == "" {
   173  		return gotenvalidate.NewValidationError("TimeSeries", "queryName", obj.QueryName, "field is required", nil)
   174  	}
   175  	if subobj, ok := interface{}(obj.UpperThreshold).(gotenvalidate.Validator); ok {
   176  		if err := subobj.GotenValidate(); err != nil {
   177  			return gotenvalidate.NewValidationError("TimeSeries", "upperThreshold", obj.UpperThreshold, "nested object validation failed", err)
   178  		}
   179  	}
   180  	if subobj, ok := interface{}(obj.LowerThreshold).(gotenvalidate.Validator); ok {
   181  		if err := subobj.GotenValidate(); err != nil {
   182  			return gotenvalidate.NewValidationError("TimeSeries", "lowerThreshold", obj.LowerThreshold, "nested object validation failed", err)
   183  		}
   184  	}
   185  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   186  		return cvobj.GotenCustomValidate()
   187  	}
   188  	return nil
   189  }
   190  func (obj *Alert_State_Notification) GotenValidate() error {
   191  	if obj == nil {
   192  		return nil
   193  	}
   194  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   195  		return cvobj.GotenCustomValidate()
   196  	}
   197  	return nil
   198  }