|
@@ -6,6 +6,7 @@ package models
|
|
|
// Editing this file might prove futile when you re-run the swagger generate command
|
|
|
|
|
|
import (
|
|
|
+ "context"
|
|
|
"strconv"
|
|
|
|
|
|
"github.com/go-openapi/errors"
|
|
@@ -168,7 +169,6 @@ func (m *Alert) validateCapacity(formats strfmt.Registry) error {
|
|
|
}
|
|
|
|
|
|
func (m *Alert) validateDecisions(formats strfmt.Registry) error {
|
|
|
-
|
|
|
if swag.IsZero(m.Decisions) { // not required
|
|
|
return nil
|
|
|
}
|
|
@@ -182,6 +182,8 @@ func (m *Alert) validateDecisions(formats strfmt.Registry) error {
|
|
|
if err := m.Decisions[i].Validate(formats); err != nil {
|
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
|
return ve.ValidateName("decisions" + "." + strconv.Itoa(i))
|
|
|
+ } else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
+ return ce.ValidateName("decisions" + "." + strconv.Itoa(i))
|
|
|
}
|
|
|
return err
|
|
|
}
|
|
@@ -207,6 +209,8 @@ func (m *Alert) validateEvents(formats strfmt.Registry) error {
|
|
|
if err := m.Events[i].Validate(formats); err != nil {
|
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
|
return ve.ValidateName("events" + "." + strconv.Itoa(i))
|
|
|
+ } else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
+ return ce.ValidateName("events" + "." + strconv.Itoa(i))
|
|
|
}
|
|
|
return err
|
|
|
}
|
|
@@ -245,7 +249,6 @@ func (m *Alert) validateMessage(formats strfmt.Registry) error {
|
|
|
}
|
|
|
|
|
|
func (m *Alert) validateMeta(formats strfmt.Registry) error {
|
|
|
-
|
|
|
if swag.IsZero(m.Meta) { // not required
|
|
|
return nil
|
|
|
}
|
|
@@ -253,6 +256,8 @@ func (m *Alert) validateMeta(formats strfmt.Registry) error {
|
|
|
if err := m.Meta.Validate(formats); err != nil {
|
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
|
return ve.ValidateName("meta")
|
|
|
+ } else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
+ return ce.ValidateName("meta")
|
|
|
}
|
|
|
return err
|
|
|
}
|
|
@@ -306,6 +311,8 @@ func (m *Alert) validateSource(formats strfmt.Registry) error {
|
|
|
if err := m.Source.Validate(formats); err != nil {
|
|
|
if ve, ok := err.(*errors.Validation); ok {
|
|
|
return ve.ValidateName("source")
|
|
|
+ } else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
+ return ce.ValidateName("source")
|
|
|
}
|
|
|
return err
|
|
|
}
|
|
@@ -332,6 +339,141 @@ func (m *Alert) validateStopAt(formats strfmt.Registry) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+// ContextValidate validate this alert based on the context it is used
|
|
|
+func (m *Alert) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
|
|
+ var res []error
|
|
|
+
|
|
|
+ if err := m.contextValidateCreatedAt(ctx, formats); err != nil {
|
|
|
+ res = append(res, err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := m.contextValidateDecisions(ctx, formats); err != nil {
|
|
|
+ res = append(res, err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := m.contextValidateEvents(ctx, formats); err != nil {
|
|
|
+ res = append(res, err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := m.contextValidateID(ctx, formats); err != nil {
|
|
|
+ res = append(res, err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := m.contextValidateMachineID(ctx, formats); err != nil {
|
|
|
+ res = append(res, err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := m.contextValidateMeta(ctx, formats); err != nil {
|
|
|
+ res = append(res, err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := m.contextValidateSource(ctx, formats); err != nil {
|
|
|
+ res = append(res, err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(res) > 0 {
|
|
|
+ return errors.CompositeValidationError(res...)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (m *Alert) contextValidateCreatedAt(ctx context.Context, formats strfmt.Registry) error {
|
|
|
+
|
|
|
+ if err := validate.ReadOnly(ctx, "created_at", "body", string(m.CreatedAt)); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (m *Alert) contextValidateDecisions(ctx context.Context, formats strfmt.Registry) error {
|
|
|
+
|
|
|
+ for i := 0; i < len(m.Decisions); i++ {
|
|
|
+
|
|
|
+ if m.Decisions[i] != nil {
|
|
|
+ if err := m.Decisions[i].ContextValidate(ctx, formats); err != nil {
|
|
|
+ if ve, ok := err.(*errors.Validation); ok {
|
|
|
+ return ve.ValidateName("decisions" + "." + strconv.Itoa(i))
|
|
|
+ } else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
+ return ce.ValidateName("decisions" + "." + strconv.Itoa(i))
|
|
|
+ }
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (m *Alert) contextValidateEvents(ctx context.Context, formats strfmt.Registry) error {
|
|
|
+
|
|
|
+ for i := 0; i < len(m.Events); i++ {
|
|
|
+
|
|
|
+ if m.Events[i] != nil {
|
|
|
+ if err := m.Events[i].ContextValidate(ctx, formats); err != nil {
|
|
|
+ if ve, ok := err.(*errors.Validation); ok {
|
|
|
+ return ve.ValidateName("events" + "." + strconv.Itoa(i))
|
|
|
+ } else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
+ return ce.ValidateName("events" + "." + strconv.Itoa(i))
|
|
|
+ }
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (m *Alert) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
|
|
|
+
|
|
|
+ if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (m *Alert) contextValidateMachineID(ctx context.Context, formats strfmt.Registry) error {
|
|
|
+
|
|
|
+ if err := validate.ReadOnly(ctx, "machine_id", "body", string(m.MachineID)); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (m *Alert) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error {
|
|
|
+
|
|
|
+ if err := m.Meta.ContextValidate(ctx, formats); err != nil {
|
|
|
+ if ve, ok := err.(*errors.Validation); ok {
|
|
|
+ return ve.ValidateName("meta")
|
|
|
+ } else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
+ return ce.ValidateName("meta")
|
|
|
+ }
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (m *Alert) contextValidateSource(ctx context.Context, formats strfmt.Registry) error {
|
|
|
+
|
|
|
+ if m.Source != nil {
|
|
|
+ if err := m.Source.ContextValidate(ctx, formats); err != nil {
|
|
|
+ if ve, ok := err.(*errors.Validation); ok {
|
|
|
+ return ve.ValidateName("source")
|
|
|
+ } else if ce, ok := err.(*errors.CompositeError); ok {
|
|
|
+ return ce.ValidateName("source")
|
|
|
+ }
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
// MarshalBinary interface implementation
|
|
|
func (m *Alert) MarshalBinary() ([]byte, error) {
|
|
|
if m == nil {
|