diff --git a/pkg/models/decision.go b/pkg/models/decision.go index de9a78edc..1a8d1b912 100644 --- a/pkg/models/decision.go +++ b/pkg/models/decision.go @@ -6,6 +6,8 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" + "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" @@ -17,7 +19,7 @@ import ( // swagger:model Decision type Decision struct { - // duration + // the duration of the decisions // Required: true Duration *string `json:"duration"` @@ -45,6 +47,9 @@ type Decision struct { // Required: true Type *string `json:"type"` + // the date until the decisions must be active + Until string `json:"until,omitempty"` + // the value of the decision scope : an IP, a range, a username, etc // Required: true Value *string `json:"value"` @@ -138,6 +143,42 @@ func (m *Decision) validateValue(formats strfmt.Registry) error { return nil } +// ContextValidate validate this decision based on the context it is used +func (m *Decision) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateID(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSimulated(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Decision) 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 *Decision) contextValidateSimulated(ctx context.Context, formats strfmt.Registry) error { + + if err := validate.ReadOnly(ctx, "simulated", "body", m.Simulated); err != nil { + return err + } + + return nil +} + // MarshalBinary interface implementation func (m *Decision) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/pkg/models/localapi_swagger.yaml b/pkg/models/localapi_swagger.yaml index 2256f2868..ad67c8fa0 100644 --- a/pkg/models/localapi_swagger.yaml +++ b/pkg/models/localapi_swagger.yaml @@ -831,7 +831,11 @@ definitions: description: 'the value of the decision scope : an IP, a range, a username, etc' type: string duration: + description: 'the duration of the decisions' type: string + until: + type: string + description: 'the date until the decisions must be active' scenario: type: string simulated: