Update LAPI swagger (#1155)

This commit is contained in:
blotus 2022-01-11 16:45:34 +01:00 committed by GitHub
parent 3bca25fd6d
commit cc72800f50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 585 additions and 7 deletions

2
go.mod
View file

@ -24,7 +24,7 @@ require (
github.com/fsnotify/fsnotify v1.4.9
github.com/gin-gonic/gin v1.6.3
github.com/go-co-op/gocron v1.9.0
github.com/go-openapi/errors v0.19.9
github.com/go-openapi/errors v0.20.1
github.com/go-openapi/strfmt v0.19.11
github.com/go-openapi/swag v0.19.12
github.com/go-openapi/validate v0.20.0

2
go.sum
View file

@ -202,6 +202,8 @@ github.com/go-openapi/errors v0.19.7/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpX
github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/errors v0.19.9 h1:9SnKdGhiPZHF3ttwFMiCBEb8jQ4IDdrK+5+a0oTygA4=
github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/errors v0.20.1 h1:j23mMDtRxMwIobkpId7sWh7Ddcx4ivaoqUbfXx5P+a8=
github.com/go-openapi/errors v0.20.1/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=

View file

@ -123,7 +123,7 @@ func TestCreateAlert(t *testing.T) {
router.ServeHTTP(w, req)
assert.Equal(t, 500, w.Code)
assert.Equal(t, "{\"message\":\"validation failure list:\\nscenario in body is required\\nscenario_hash in body is required\\nscenario_version in body is required\\nsimulated in body is required\\nsource in body is required\"}", w.Body.String())
assert.Equal(t, "{\"message\":\"validation failure list:\\n0.scenario in body is required\\n0.scenario_hash in body is required\\n0.scenario_version in body is required\\n0.simulated in body is required\\n0.source in body is required\"}", w.Body.String())
// Create Valid Alert
alertContentBytes, err = ioutil.ReadFile("./tests/alert_sample.json")

View file

@ -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"
@ -31,6 +32,33 @@ func (m AddAlertsRequest) Validate(formats strfmt.Registry) error {
if err := m[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName(strconv.Itoa(i))
}
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// ContextValidate validate this add alerts request based on the context it is used
func (m AddAlertsRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
for i := 0; i < len(m); i++ {
if m[i] != nil {
if err := m[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName(strconv.Itoa(i))
}
return err
}

View file

@ -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/strfmt"
)
@ -18,3 +20,8 @@ type AddAlertsResponse []string
func (m AddAlertsResponse) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this add alerts response based on context it is used
func (m AddAlertsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}

View file

@ -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"
@ -33,6 +34,33 @@ func (m AddSignalsRequest) Validate(formats strfmt.Registry) error {
if err := m[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName(strconv.Itoa(i))
}
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// ContextValidate validate this add signals request based on the context it is used
func (m AddSignalsRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
for i := 0; i < len(m); i++ {
if m[i] != nil {
if err := m[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName(strconv.Itoa(i))
}
return err
}

View file

@ -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"
@ -136,6 +138,8 @@ func (m *AddSignalsRequestItem) 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
}
@ -162,6 +166,36 @@ func (m *AddSignalsRequestItem) validateStopAt(formats strfmt.Registry) error {
return nil
}
// ContextValidate validate this add signals request item based on the context it is used
func (m *AddSignalsRequestItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateSource(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *AddSignalsRequestItem) 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 *AddSignalsRequestItem) MarshalBinary() ([]byte, error) {
if m == nil {

View file

@ -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 {

View file

@ -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"
@ -138,6 +140,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 {

View file

@ -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"
@ -42,7 +44,6 @@ func (m *DecisionsStreamResponse) Validate(formats strfmt.Registry) error {
}
func (m *DecisionsStreamResponse) validateDeleted(formats strfmt.Registry) error {
if swag.IsZero(m.Deleted) { // not required
return nil
}
@ -50,6 +51,8 @@ func (m *DecisionsStreamResponse) validateDeleted(formats strfmt.Registry) error
if err := m.Deleted.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("deleted")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("deleted")
}
return err
}
@ -58,7 +61,6 @@ func (m *DecisionsStreamResponse) validateDeleted(formats strfmt.Registry) error
}
func (m *DecisionsStreamResponse) validateNew(formats strfmt.Registry) error {
if swag.IsZero(m.New) { // not required
return nil
}
@ -66,6 +68,54 @@ func (m *DecisionsStreamResponse) validateNew(formats strfmt.Registry) error {
if err := m.New.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("new")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("new")
}
return err
}
return nil
}
// ContextValidate validate this decisions stream response based on the context it is used
func (m *DecisionsStreamResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateDeleted(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateNew(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *DecisionsStreamResponse) contextValidateDeleted(ctx context.Context, formats strfmt.Registry) error {
if err := m.Deleted.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("deleted")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("deleted")
}
return err
}
return nil
}
func (m *DecisionsStreamResponse) contextValidateNew(ctx context.Context, formats strfmt.Registry) error {
if err := m.New.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("new")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("new")
}
return err
}

View file

@ -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/strfmt"
"github.com/go-openapi/swag"
)
@ -24,6 +26,11 @@ func (m *DeleteAlertsResponse) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this delete alerts response based on context it is used
func (m *DeleteAlertsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *DeleteAlertsResponse) MarshalBinary() ([]byte, error) {
if m == nil {

View file

@ -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/strfmt"
"github.com/go-openapi/swag"
)
@ -24,6 +26,11 @@ func (m *DeleteDecisionResponse) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this delete decision response based on context it is used
func (m *DeleteDecisionResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *DeleteDecisionResponse) MarshalBinary() ([]byte, error) {
if m == nil {

View file

@ -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"
@ -50,6 +52,11 @@ func (m *ErrorResponse) validateMessage(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this error response based on context it is used
func (m *ErrorResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *ErrorResponse) MarshalBinary() ([]byte, error) {
if m == nil {

View file

@ -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"
@ -53,6 +55,8 @@ func (m *Event) 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
}
@ -69,6 +73,34 @@ func (m *Event) validateTimestamp(formats strfmt.Registry) error {
return nil
}
// ContextValidate validate this event based on the context it is used
func (m *Event) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateMeta(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Event) 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
}
// MarshalBinary interface implementation
func (m *Event) MarshalBinary() ([]byte, error) {
if m == nil {

View file

@ -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"
@ -31,6 +32,33 @@ func (m GetAlertsResponse) Validate(formats strfmt.Registry) error {
if err := m[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName(strconv.Itoa(i))
}
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// ContextValidate validate this get alerts response based on the context it is used
func (m GetAlertsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
for i := 0; i < len(m); i++ {
if m[i] != nil {
if err := m[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName(strconv.Itoa(i))
}
return err
}

View file

@ -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"
@ -31,6 +32,33 @@ func (m GetDecisionsResponse) Validate(formats strfmt.Registry) error {
if err := m[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName(strconv.Itoa(i))
}
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// ContextValidate validate this get decisions response based on the context it is used
func (m GetDecisionsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
for i := 0; i < len(m); i++ {
if m[i] != nil {
if err := m[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName(strconv.Itoa(i))
}
return err
}

View file

@ -45,7 +45,6 @@ paths:
required: false
type: string
description: 'Comma separated scopes of decisions to fetch'
example: ip,range,country
responses:
'200':
description: successful operation
@ -406,6 +405,11 @@ paths:
required: false
type: number
description: 'number of alerts to return'
- name: origin
in: query
required: false
type: string
description: 'restrict results to this origin (ie. lists,CAPI,cscli)'
responses:
'200':
description: successful operation
@ -485,6 +489,11 @@ paths:
required: false
type: number
description: 'number of alerts to return'
- name: origin
in: query
required: false
type: string
description: 'restrict results to this origin (ie. lists,CAPI,cscli)'
responses:
'200':
description: successful operation

View file

@ -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"
@ -33,6 +34,33 @@ func (m Meta) Validate(formats strfmt.Registry) error {
if err := m[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName(strconv.Itoa(i))
}
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// ContextValidate validate this meta based on the context it is used
func (m Meta) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
for i := 0; i < len(m); i++ {
if m[i] != nil {
if err := m[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName(strconv.Itoa(i))
}
return err
}
@ -63,6 +91,11 @@ func (m *MetaItems0) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this meta items0 based on context it is used
func (m *MetaItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *MetaItems0) MarshalBinary() ([]byte, error) {
if m == nil {

View file

@ -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"
@ -78,6 +79,8 @@ func (m *Metrics) validateBouncers(formats strfmt.Registry) error {
if err := m.Bouncers[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("bouncers" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("bouncers" + "." + strconv.Itoa(i))
}
return err
}
@ -103,6 +106,66 @@ func (m *Metrics) validateMachines(formats strfmt.Registry) error {
if err := m.Machines[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("machines" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("machines" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this metrics based on the context it is used
func (m *Metrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateBouncers(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateMachines(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Metrics) contextValidateBouncers(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Bouncers); i++ {
if m.Bouncers[i] != nil {
if err := m.Bouncers[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("bouncers" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("bouncers" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *Metrics) contextValidateMachines(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Machines); i++ {
if m.Machines[i] != nil {
if err := m.Machines[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("machines" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("machines" + "." + strconv.Itoa(i))
}
return err
}

View file

@ -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/strfmt"
"github.com/go-openapi/swag"
)
@ -29,6 +31,11 @@ func (m *MetricsSoftInfo) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this metrics soft info based on context it is used
func (m *MetricsSoftInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *MetricsSoftInfo) MarshalBinary() ([]byte, error) {
if m == nil {

View file

@ -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"
@ -83,6 +85,11 @@ func (m *Source) validateValue(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this source based on context it is used
func (m *Source) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *Source) MarshalBinary() ([]byte, error) {
if m == nil {

View file

@ -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"
@ -70,6 +72,11 @@ func (m *WatcherAuthRequest) validatePassword(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this watcher auth request based on context it is used
func (m *WatcherAuthRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *WatcherAuthRequest) MarshalBinary() ([]byte, error) {
if m == nil {

View file

@ -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/strfmt"
"github.com/go-openapi/swag"
)
@ -32,6 +34,11 @@ func (m *WatcherAuthResponse) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this watcher auth response based on context it is used
func (m *WatcherAuthResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *WatcherAuthResponse) MarshalBinary() ([]byte, error) {
if m == nil {

View file

@ -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"
@ -67,6 +69,11 @@ func (m *WatcherRegistrationRequest) validatePassword(formats strfmt.Registry) e
return nil
}
// ContextValidate validates this watcher registration request based on context it is used
func (m *WatcherRegistrationRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *WatcherRegistrationRequest) MarshalBinary() ([]byte, error) {
if m == nil {