github.com/crowdsecurity/crowdsec@v1.6.1/pkg/models/event.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 "github.com/go-openapi/validate" 15 ) 16 17 // Event Event 18 // 19 // swagger:model Event 20 type Event struct { 21 22 // meta 23 // Required: true 24 Meta Meta `json:"meta"` 25 26 // timestamp 27 // Required: true 28 Timestamp *string `json:"timestamp"` 29 } 30 31 // Validate validates this event 32 func (m *Event) Validate(formats strfmt.Registry) error { 33 var res []error 34 35 if err := m.validateMeta(formats); err != nil { 36 res = append(res, err) 37 } 38 39 if err := m.validateTimestamp(formats); err != nil { 40 res = append(res, err) 41 } 42 43 if len(res) > 0 { 44 return errors.CompositeValidationError(res...) 45 } 46 return nil 47 } 48 49 func (m *Event) validateMeta(formats strfmt.Registry) error { 50 51 if err := validate.Required("meta", "body", m.Meta); err != nil { 52 return err 53 } 54 55 if err := m.Meta.Validate(formats); err != nil { 56 if ve, ok := err.(*errors.Validation); ok { 57 return ve.ValidateName("meta") 58 } else if ce, ok := err.(*errors.CompositeError); ok { 59 return ce.ValidateName("meta") 60 } 61 return err 62 } 63 64 return nil 65 } 66 67 func (m *Event) validateTimestamp(formats strfmt.Registry) error { 68 69 if err := validate.Required("timestamp", "body", m.Timestamp); err != nil { 70 return err 71 } 72 73 return nil 74 } 75 76 // ContextValidate validate this event based on the context it is used 77 func (m *Event) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 78 var res []error 79 80 if err := m.contextValidateMeta(ctx, formats); err != nil { 81 res = append(res, err) 82 } 83 84 if len(res) > 0 { 85 return errors.CompositeValidationError(res...) 86 } 87 return nil 88 } 89 90 func (m *Event) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { 91 92 if err := m.Meta.ContextValidate(ctx, formats); err != nil { 93 if ve, ok := err.(*errors.Validation); ok { 94 return ve.ValidateName("meta") 95 } else if ce, ok := err.(*errors.CompositeError); ok { 96 return ce.ValidateName("meta") 97 } 98 return err 99 } 100 101 return nil 102 } 103 104 // MarshalBinary interface implementation 105 func (m *Event) MarshalBinary() ([]byte, error) { 106 if m == nil { 107 return nil, nil 108 } 109 return swag.WriteJSON(m) 110 } 111 112 // UnmarshalBinary interface implementation 113 func (m *Event) UnmarshalBinary(b []byte) error { 114 var res Event 115 if err := swag.ReadJSON(b, &res); err != nil { 116 return err 117 } 118 *m = res 119 return nil 120 }